-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui][Popover] Deprecate *Props and complete
slots
, `slotPr…
…ops` (#45035)
- Loading branch information
1 parent
bc2337f
commit 3c9e995
Showing
18 changed files
with
486 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './popover-props'; |
49 changes: 49 additions & 0 deletions
49
packages/mui-codemod/src/deprecations/popover-props/popover-props.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import movePropIntoSlots from '../utils/movePropIntoSlots'; | ||
import movePropIntoSlotProps from '../utils/movePropIntoSlotProps'; | ||
|
||
/** | ||
* @param {import('jscodeshift').FileInfo} file | ||
* @param {import('jscodeshift').API} api | ||
*/ | ||
export default function transformer(file, api, options) { | ||
const j = api.jscodeshift; | ||
const root = j(file.source); | ||
const printOptions = options.printOptions; | ||
|
||
movePropIntoSlots(j, { | ||
root, | ||
componentName: 'Popover', | ||
propName: 'BackdropComponent', | ||
slotName: 'backdrop', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'Popover', | ||
propName: 'BackdropProps', | ||
slotName: 'backdrop', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'Popover', | ||
propName: 'PaperProps', | ||
slotName: 'paper', | ||
}); | ||
|
||
movePropIntoSlots(j, { | ||
root, | ||
componentName: 'Popover', | ||
propName: 'TransitionComponent', | ||
slotName: 'transition', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'Popover', | ||
propName: 'TransitionProps', | ||
slotName: 'transition', | ||
}); | ||
|
||
return root.toSource(printOptions); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/popover-props/popover-props.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { describeJscodeshiftTransform } from '../../../testUtils'; | ||
import transform from './popover-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'popover-props', | ||
dirname: __dirname, | ||
testCases: [ | ||
{ actual: '/test-cases/actual.js', expected: '/test-cases/expected.js' }, | ||
{ actual: '/test-cases/theme.actual.js', expected: '/test-cases/theme.expected.js' }, | ||
], | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/mui-codemod/src/deprecations/popover-props/test-cases/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Popover from '@mui/material/Popover'; | ||
import { Popover as MyPopover } from '@mui/material'; | ||
|
||
<Popover | ||
BackdropComponent={CustomBackdrop} | ||
BackdropProps={{ timeout: 200 }} | ||
PaperProps={{ elevation: 4 }} | ||
TransitionComponent={CustomTransition} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; | ||
|
||
<Popover | ||
BackdropComponent={CustomBackdrop} | ||
BackdropProps={{ timeout: 200 }} | ||
PaperProps={{ elevation: 4 }} | ||
TransitionComponent={CustomTransition} | ||
TransitionProps={{ timeout: 200 }} | ||
slotProps={{ | ||
backdrop: { sx: { backgroundColor: 'red' } }, | ||
paper: { sx: { backgroundColor: 'blue' } }, | ||
transition: { onEnter: () => {} }, | ||
}} | ||
/>; | ||
|
||
<MyPopover | ||
BackdropComponent={CustomBackdrop} | ||
BackdropProps={{ timeout: 200 }} | ||
PaperProps={{ elevation: 4 }} | ||
TransitionComponent={CustomTransition} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; | ||
|
||
<CustomPopover | ||
BackdropComponent={CustomBackdrop} | ||
BackdropProps={{ timeout: 200 }} | ||
PaperProps={{ elevation: 4 }} | ||
TransitionComponent={CustomTransition} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; |
52 changes: 52 additions & 0 deletions
52
packages/mui-codemod/src/deprecations/popover-props/test-cases/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Popover from '@mui/material/Popover'; | ||
import { Popover as MyPopover } from '@mui/material'; | ||
|
||
<Popover | ||
slots={{ | ||
backdrop: CustomBackdrop, | ||
transition: CustomTransition | ||
}} | ||
slotProps={{ | ||
backdrop: { timeout: 200 }, | ||
paper: { elevation: 4 }, | ||
transition: { timeout: 200 } | ||
}} />; | ||
|
||
<Popover | ||
slotProps={{ | ||
backdrop: { | ||
...{ timeout: 200 }, | ||
...{ sx: { backgroundColor: 'red' } } | ||
}, | ||
paper: { | ||
...{ elevation: 4 }, | ||
...{ sx: { backgroundColor: 'blue' } } | ||
}, | ||
transition: { | ||
...{ timeout: 200 }, | ||
...{ onEnter: () => {} } | ||
}, | ||
}} | ||
slots={{ | ||
backdrop: CustomBackdrop, | ||
transition: CustomTransition | ||
}} />; | ||
|
||
<MyPopover | ||
slots={{ | ||
backdrop: CustomBackdrop, | ||
transition: CustomTransition | ||
}} | ||
slotProps={{ | ||
backdrop: { timeout: 200 }, | ||
paper: { elevation: 4 }, | ||
transition: { timeout: 200 } | ||
}} />; | ||
|
||
<CustomPopover | ||
BackdropComponent={CustomBackdrop} | ||
BackdropProps={{ timeout: 200 }} | ||
PaperProps={{ elevation: 4 }} | ||
TransitionComponent={CustomTransition} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; |
11 changes: 11 additions & 0 deletions
11
packages/mui-codemod/src/deprecations/popover-props/test-cases/theme.actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn({ | ||
MuiPopover: { | ||
defaultProps: { | ||
BackdropComponent: 'div', | ||
BackdropProps: { timeout: 200 }, | ||
PaperProps: { elevation: 8 }, | ||
TransitionComponent: 'em', | ||
TransitionProps: { timeout: 200 }, | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.