forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e77bec9
commit e7d9b70
Showing
14 changed files
with
237 additions
and
14 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 './modal-props'; |
15 changes: 15 additions & 0 deletions
15
packages/mui-codemod/src/deprecations/modal-props/modal-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: 'Modal' }); | ||
|
||
return root.toSource(printOptions); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/modal-props/modal-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 './modal-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'modal-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' }, | ||
], | ||
}); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/mui-codemod/src/deprecations/modal-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,20 @@ | ||
import Modal from '@mui/material/Modal'; | ||
|
||
<Modal | ||
components={{ Root: ComponentsRoot }} | ||
componentsProps={{ root: componentsRootProps }} | ||
/>; | ||
<Modal | ||
components={{ Root: ComponentsRoot }} | ||
slotProps={{ root: slotsRootProps }} | ||
/>; | ||
<Modal | ||
slots={{ root: SlotsRoot }} | ||
componentsProps={{ root: componentsRootProps }} | ||
/>; | ||
<Modal | ||
slots={{ root: SlotsRoot }} | ||
components={{ Root: ComponentsRoot }} | ||
slotProps={{ root: slotsRootProps }} | ||
componentsProps={{ root: componentsRootProps }} | ||
/>; |
24 changes: 24 additions & 0 deletions
24
packages/mui-codemod/src/deprecations/modal-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,24 @@ | ||
import Modal from '@mui/material/Modal'; | ||
|
||
<Modal | ||
slots={{ | ||
root: ComponentsRoot | ||
}} | ||
slotProps={{ root: componentsRootProps }} | ||
/>; | ||
<Modal | ||
slotProps={{ root: slotsRootProps }} | ||
slots={{ | ||
root: ComponentsRoot | ||
}} | ||
/>; | ||
<Modal | ||
slots={{ root: SlotsRoot }} | ||
slotProps={{ root: componentsRootProps }} | ||
/>; | ||
<Modal | ||
slots={{ root: SlotsRoot }} | ||
slotProps={{ root: { | ||
...componentsRootProps, | ||
...slotsRootProps | ||
} }} />; |
37 changes: 37 additions & 0 deletions
37
packages/mui-codemod/src/deprecations/modal-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,37 @@ | ||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
components: { Root: ComponentsRoot }, | ||
componentsProps: { root: componentsRootProps }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
components: { Root: ComponentsRoot }, | ||
slotProps: { root: slotsRootProps }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
slots: { root: SlotsRoot }, | ||
componentsProps: { root: componentsRootProps }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
slots: { root: SlotsRoot }, | ||
components: { Root: ComponentsRoot }, | ||
slotProps: { root: slotsRootProps }, | ||
componentsProps: { root: componentsRootProps }, | ||
}, | ||
}, | ||
}); |
54 changes: 54 additions & 0 deletions
54
packages/mui-codemod/src/deprecations/modal-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,54 @@ | ||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
slots: { | ||
root: ComponentsRoot | ||
}, | ||
|
||
slotProps: { | ||
root: componentsRootProps | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
slotProps: { root: slotsRootProps }, | ||
|
||
slots: { | ||
root: ComponentsRoot | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
defaultProps: { | ||
slots: { root: SlotsRoot }, | ||
|
||
slotProps: { | ||
root: componentsRootProps | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiModal: { | ||
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
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