-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[material-ui][StepLabel] Deprecate componentProps prop
#41321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2d9d973
Update StepLabel component to use slots and slotProps
sai6855 6e69774
docs:api
sai6855 d7a0343
update test
sai6855 a360d52
Add slots prop to StepLabelProps
sai6855 9d345a2
update name
sai6855 a745c16
add codemod
sai6855 54e7709
update
sai6855 f986c3c
fix test
sai6855 fa18b6d
add expected.js
sai6855 cd2fc76
fix test
sai6855 273a35a
add migration guide
sai6855 18899ec
diego review
sai6855 b8c4210
Minor guide fixes
DiegoAndai 656ac20
Merge branch 'next' into deprecate-slider-components
sai6855 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
1 change: 1 addition & 0 deletions
1
packages/mui-codemod/src/deprecations/step-label-props/index.js
This file contains hidden or 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 './step-label-props'; |
15 changes: 15 additions & 0 deletions
15
packages/mui-codemod/src/deprecations/step-label-props/step-label-props.js
This file contains hidden or 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: 'StepLabel' }); | ||
|
|
||
| return root.toSource(printOptions); | ||
| } |
53 changes: 53 additions & 0 deletions
53
packages/mui-codemod/src/deprecations/step-label-props/step-label-props.test.js
This file contains hidden or 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,53 @@ | ||
| import path from 'path'; | ||
| import { expect } from 'chai'; | ||
| import { jscodeshift } from '../../../testUtils'; | ||
| import transform from './step-label-props'; | ||
| import readFile from '../../util/readFile'; | ||
|
|
||
| function read(fileName) { | ||
| return readFile(path.join(__dirname, fileName)); | ||
| } | ||
|
|
||
| describe('@mui/codemod', () => { | ||
| describe('deprecations', () => { | ||
| describe('step-label-props', () => { | ||
| it('transforms props as needed', () => { | ||
| const actual = transform({ source: read('./test-cases/actual.js') }, { jscodeshift }, {}); | ||
|
|
||
| const expected = read('./test-cases/expected.js'); | ||
| expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
| }); | ||
|
|
||
| it('should be idempotent', () => { | ||
| const actual = transform({ source: read('./test-cases/expected.js') }, { jscodeshift }, {}); | ||
|
|
||
| const expected = read('./test-cases/expected.js'); | ||
| expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('[theme] step-label-props', () => { | ||
| it('transforms props as needed', () => { | ||
| const actual = transform( | ||
| { source: read('./test-cases/theme.actual.js') }, | ||
| { jscodeshift }, | ||
| { printOptions: { trailingComma: false } }, | ||
| ); | ||
|
|
||
| const expected = read('./test-cases/theme.expected.js'); | ||
| expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
| }); | ||
|
|
||
| it('should be idempotent', () => { | ||
| const actual = transform( | ||
| { source: read('./test-cases/theme.expected.js') }, | ||
| { jscodeshift }, | ||
| {}, | ||
| ); | ||
|
|
||
| const expected = read('./test-cases/theme.expected.js'); | ||
| expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
8 changes: 8 additions & 0 deletions
8
packages/mui-codemod/src/deprecations/step-label-props/test-cases/actual.js
This file contains hidden or 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,8 @@ | ||
| import StepLabel from '@mui/material/StepLabel'; | ||
|
|
||
| <StepLabel componentsProps={{ label: componentsLabelProps }} />; | ||
| <StepLabel | ||
| slots={{ label: SlotsLabel }} | ||
| slotProps={{ label: slotLabelProps }} | ||
| componentsProps={{ label: componentsLabelProps }} | ||
| />; |
9 changes: 9 additions & 0 deletions
9
packages/mui-codemod/src/deprecations/step-label-props/test-cases/expected.js
This file contains hidden or 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,9 @@ | ||
| import StepLabel from '@mui/material/StepLabel'; | ||
|
|
||
| <StepLabel slotProps={{ label: componentsLabelProps }} />; | ||
| <StepLabel | ||
| slots={{ label: SlotsLabel }} | ||
| slotProps={{ label: { | ||
| ...componentsLabelProps, | ||
| ...slotLabelProps | ||
| } }} />; |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/step-label-props/test-cases/theme.actual.js
This file contains hidden or 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 @@ | ||
| fn({ | ||
| MuiStepLabel: { | ||
| defaultProps: { | ||
| componentsProps: { label: componentsLabelProps }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fn({ | ||
| MuiStepLabel: { | ||
| defaultProps: { | ||
| componentsProps: { label: componentsLabelProps }, | ||
| slotProps: { label: slotLabelProps }, | ||
| }, | ||
| }, | ||
| }); |
22 changes: 22 additions & 0 deletions
22
packages/mui-codemod/src/deprecations/step-label-props/test-cases/theme.expected.js
This file contains hidden or 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,22 @@ | ||
| fn({ | ||
| MuiStepLabel: { | ||
| defaultProps: { | ||
| slotProps: { | ||
| label: componentsLabelProps | ||
| } | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| fn({ | ||
| MuiStepLabel: { | ||
| defaultProps: { | ||
| slotProps: { | ||
| label: { | ||
| ...componentsLabelProps, | ||
| ...slotLabelProps | ||
| } | ||
| } | ||
| }, | ||
| }, | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.