-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui][Popper] Deprecate components and componentProps props f…
…or v6 (#42111)
- Loading branch information
1 parent
78d723b
commit 7e361e5
Showing
11 changed files
with
177 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './popper-props'; |
15 changes: 15 additions & 0 deletions
15
packages/mui-codemod/src/deprecations/popper-props/popper-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,15 @@ | ||
import replaceComponentsWithSlots from '../utils/replaceComponentsWithSlots'; | ||
|
||
/** | ||
* @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; | ||
|
||
replaceComponentsWithSlots(j, { root, componentName: 'Popper' }); | ||
|
||
return root.toSource(printOptions); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/popper-props/popper-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 './popper-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'popper-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' }, | ||
], | ||
}); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/mui-codemod/src/deprecations/popper-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,12 @@ | ||
import Popper from '@mui/material/Popper'; | ||
|
||
<Popper | ||
components={{ Root: ComponentsRoot }} | ||
componentsProps={{ root: componentsRootProps }} | ||
/>; | ||
<Popper | ||
slots={{ root: SlotsRoot }} | ||
components={{ Root: ComponentsRoot }} | ||
slotProps={{ root: slotsRootProps }} | ||
componentsProps={{ root: componentsRootProps }} | ||
/>; |
14 changes: 14 additions & 0 deletions
14
packages/mui-codemod/src/deprecations/popper-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,14 @@ | ||
import Popper from '@mui/material/Popper'; | ||
|
||
<Popper | ||
slots={{ | ||
root: ComponentsRoot | ||
}} | ||
slotProps={{ root: componentsRootProps }} | ||
/>; | ||
<Popper | ||
slots={{ root: SlotsRoot }} | ||
slotProps={{ root: { | ||
...componentsRootProps, | ||
...slotsRootProps | ||
} }} />; |
19 changes: 19 additions & 0 deletions
19
packages/mui-codemod/src/deprecations/popper-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,19 @@ | ||
fn({ | ||
MuiPopper: { | ||
defaultProps: { | ||
components: { Root: ComponentsRoot }, | ||
componentsProps: { root: componentsRootProps }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiPopper: { | ||
defaultProps: { | ||
components: { Root: ComponentsRoot }, | ||
slots: { root: SlotsRoot }, | ||
componentsProps: { root: componentsRootProps }, | ||
slotProps: { root: slotsRootProps }, | ||
}, | ||
}, | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/mui-codemod/src/deprecations/popper-props/test-cases/theme.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,30 @@ | ||
fn({ | ||
MuiPopper: { | ||
defaultProps: { | ||
slots: { | ||
root: ComponentsRoot | ||
}, | ||
|
||
slotProps: { | ||
root: componentsRootProps | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiPopper: { | ||
defaultProps: { | ||
slots: { | ||
root: SlotsRoot | ||
}, | ||
|
||
slotProps: { | ||
root: { | ||
...componentsRootProps, | ||
...slotsRootProps | ||
} | ||
} | ||
}, | ||
}, | ||
}); |
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