From cd5136768191a8d1ebc8662ccdf6e76461ccb528 Mon Sep 17 00:00:00 2001 From: Harry Whorlow Date: Wed, 6 Mar 2024 15:30:17 +0100 Subject: [PATCH] removal of transition duration from tests --- packages/mui-codemod/README.md | 2 - .../backdrop-props/backdrop-props.js | 37 +------------------ .../backdrop-props/test-cases/actual.js | 8 ++-- .../backdrop-props/test-cases/expected.js | 22 +---------- .../backdrop-props/test-cases/theme.actual.js | 1 - .../test-cases/theme.expected.js | 4 +- .../mui-material/src/Backdrop/Backdrop.d.ts | 6 ++- 7 files changed, 10 insertions(+), 70 deletions(-) diff --git a/packages/mui-codemod/README.md b/packages/mui-codemod/README.md index 260004b688e229..eb060b7d74048e 100644 --- a/packages/mui-codemod/README.md +++ b/packages/mui-codemod/README.md @@ -125,9 +125,7 @@ npx @mui/codemod@latest deprecations/divider-props ```diff ``` diff --git a/packages/mui-codemod/src/deprecations/backdrop-props/backdrop-props.js b/packages/mui-codemod/src/deprecations/backdrop-props/backdrop-props.js index 55f9924f9d03fc..3b256eba0ada0c 100644 --- a/packages/mui-codemod/src/deprecations/backdrop-props/backdrop-props.js +++ b/packages/mui-codemod/src/deprecations/backdrop-props/backdrop-props.js @@ -12,7 +12,7 @@ export default function transformer(file, api, options) { const printOptions = options.printOptions; findComponentJSX(j, { root, componentName: 'Backdrop' }, (elementPath) => { - let index = elementPath.node.openingElement.attributes.findIndex( + const index = elementPath.node.openingElement.attributes.findIndex( (attr) => attr.type === 'JSXAttribute' && attr.name.name === 'TransitionComponent', ); if (index !== -1) { @@ -38,41 +38,6 @@ export default function transformer(file, api, options) { }); } } - - index = elementPath.node.openingElement.attributes.findIndex( - (attr) => attr.type === 'JSXAttribute' && attr.name.name === 'transitionDuration', - ); - - if (index !== -1) { - const removed = elementPath.node.openingElement.attributes.splice(index, 1); - const updated = j.objectExpression([ - j.objectProperty( - j.identifier('transition'), - j.objectExpression([ - j.objectProperty(j.identifier('timeout'), removed[0].value.expression), - ]), - ), - ]); - - let hasNode = false; - elementPath.node.openingElement.attributes.forEach((attr) => { - if (attr.name?.name === 'slotProps') { - hasNode = true; - assignObject(j, { - target: attr, - key: 'transition', - expression: updated, - }); - } - }); - if (!hasNode) { - appendAttribute(j, { - target: elementPath.node, - attributeName: 'slotProps', - expression: updated, - }); - } - } }); root.find(j.ObjectProperty, { key: { name: 'TransitionComponent' } }).forEach((path) => { diff --git a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/actual.js b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/actual.js index 4bab29ba9bf291..8cca730fda99e4 100644 --- a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/actual.js +++ b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/actual.js @@ -1,11 +1,10 @@ import Backdrop from '@mui/material/Backdrop'; import { Backdrop as MyBackdrop } from '@mui/material'; -; -; +; +; ; ; // should skip non MUI components -; +; diff --git a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/expected.js b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/expected.js index 8687319d10c95c..ca22506cedab88 100644 --- a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/expected.js +++ b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/expected.js @@ -3,17 +3,9 @@ import { Backdrop as MyBackdrop } from '@mui/material'; ; ; ; ; // should skip non MUI components -; +; diff --git a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.actual.js b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.actual.js index 35db3022e912af..01e16b9707a077 100644 --- a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.actual.js +++ b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.actual.js @@ -2,7 +2,6 @@ fn({ MuiBackdrop: { defaultProps: { TransitionComponent: CustomTransition, - TransitionProps: { unmountOnExit: true }, }, }, }); diff --git a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.expected.js b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.expected.js index 4ec528d2b5af8f..219957d501b4c7 100644 --- a/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.expected.js +++ b/packages/mui-codemod/src/deprecations/backdrop-props/test-cases/theme.expected.js @@ -3,9 +3,7 @@ fn({ defaultProps: { slots: { transition: CustomTransition - }, - - TransitionProps: { unmountOnExit: true } + } }, }, }); diff --git a/packages/mui-material/src/Backdrop/Backdrop.d.ts b/packages/mui-material/src/Backdrop/Backdrop.d.ts index 9ad54c084363b7..41380fe5e6532b 100644 --- a/packages/mui-material/src/Backdrop/Backdrop.d.ts +++ b/packages/mui-material/src/Backdrop/Backdrop.d.ts @@ -42,7 +42,9 @@ export type BackdropSlotsAndSlotProps = CreateSlotsAndSlotProps< } >; -export interface BackdropOwnProps extends Partial> { +export interface BackdropOwnProps + extends Partial>, + BackdropSlotsAndSlotProps { /** * The content of the component. */ @@ -110,7 +112,7 @@ export interface BackdropTypeMap< AdditionalProps = {}, RootComponent extends React.ElementType = 'div', > { - props: AdditionalProps & BackdropOwnProps & BackdropSlotsAndSlotProps; + props: AdditionalProps & BackdropOwnProps; defaultComponent: RootComponent; }