-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
03e3b8f
commit 698dd35
Showing
16 changed files
with
575 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './menu-props'; |
35 changes: 35 additions & 0 deletions
35
packages/mui-codemod/src/deprecations/menu-props/menu-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,35 @@ | ||
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; | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'Menu', | ||
propName: 'MenuListProps', | ||
slotName: 'list', | ||
}); | ||
|
||
movePropIntoSlots(j, { | ||
root, | ||
componentName: 'Menu', | ||
propName: 'TransitionComponent', | ||
slotName: 'transition', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'Menu', | ||
propName: 'TransitionProps', | ||
slotName: 'transition', | ||
}); | ||
|
||
return root.toSource(printOptions); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/menu-props/menu-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 './menu-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'menu-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' }, | ||
], | ||
}); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
packages/mui-codemod/src/deprecations/menu-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,48 @@ | ||
import Menu from '@mui/material/Menu'; | ||
import { Menu as MyMenu } from '@mui/material'; | ||
|
||
<Menu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; | ||
|
||
<Menu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
slotProps={{ | ||
root: { | ||
disablePortal: true, | ||
}, | ||
}} | ||
/>; | ||
|
||
<Menu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
slotProps={{ | ||
root: { | ||
disablePortal: true, | ||
}, | ||
list: { | ||
disableListWrap: true, | ||
}, | ||
transition: { | ||
'aria-hidden': true, | ||
}, | ||
}} | ||
/>; | ||
|
||
<MyMenu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; | ||
|
||
<CustomMenu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; |
63 changes: 63 additions & 0 deletions
63
packages/mui-codemod/src/deprecations/menu-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,63 @@ | ||
import Menu from '@mui/material/Menu'; | ||
import { Menu as MyMenu } from '@mui/material'; | ||
|
||
<Menu | ||
slotProps={{ | ||
list: { disablePadding: true }, | ||
transition: { timeout: 200 } | ||
}} | ||
slots={{ | ||
transition: CustomTransition | ||
}} />; | ||
|
||
<Menu | ||
slotProps={{ | ||
root: { | ||
disablePortal: true, | ||
}, | ||
|
||
list: { disablePadding: true }, | ||
transition: { timeout: 200 } | ||
}} | ||
slots={{ | ||
transition: CustomTransition | ||
}} />; | ||
|
||
<Menu | ||
slotProps={{ | ||
root: { | ||
disablePortal: true, | ||
}, | ||
list: { | ||
...{ disablePadding: true }, | ||
|
||
...{ | ||
disableListWrap: true, | ||
} | ||
}, | ||
transition: { | ||
...{ timeout: 200 }, | ||
|
||
...{ | ||
'aria-hidden': true, | ||
} | ||
}, | ||
}} | ||
slots={{ | ||
transition: CustomTransition | ||
}} />; | ||
|
||
<MyMenu | ||
slotProps={{ | ||
list: { disablePadding: true }, | ||
transition: { timeout: 200 } | ||
}} | ||
slots={{ | ||
transition: CustomTransition | ||
}} />; | ||
|
||
<CustomMenu | ||
TransitionComponent={CustomTransition} | ||
MenuListProps={{ disablePadding: true }} | ||
TransitionProps={{ timeout: 200 }} | ||
/>; |
22 changes: 22 additions & 0 deletions
22
packages/mui-codemod/src/deprecations/menu-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,22 @@ | ||
fn({ | ||
MuiMenu: { | ||
defaultProps: { | ||
MenuListProps: { disablePadding: true }, | ||
TransitionComponent: CustomTransition, | ||
TransitionProps: { timeout: 200 }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiMenu: { | ||
defaultProps: { | ||
TransitionComponent: CustomTransition, | ||
MenuListProps: { disablePadding: true }, | ||
TransitionProps: { timeout: 200 }, | ||
slotProps: { | ||
root: { disablePortal: true }, | ||
}, | ||
}, | ||
}, | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/mui-codemod/src/deprecations/menu-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({ | ||
MuiMenu: { | ||
defaultProps: { | ||
slotProps: { | ||
list: { disablePadding: true }, | ||
transition: { timeout: 200 } | ||
}, | ||
|
||
slots: { | ||
transition: CustomTransition | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiMenu: { | ||
defaultProps: { | ||
slotProps: { | ||
root: { disablePortal: true }, | ||
list: { disablePadding: true }, | ||
transition: { timeout: 200 } | ||
}, | ||
|
||
slots: { | ||
transition: CustomTransition | ||
} | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.