-
-
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
cef5e6c
commit 95ae871
Showing
16 changed files
with
608 additions
and
182 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
1 change: 1 addition & 0 deletions
1
packages/mui-codemod/src/deprecations/table-pagination-props/index.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 @@ | ||
export { default } from './table-pagination-props'; |
28 changes: 28 additions & 0 deletions
28
packages/mui-codemod/src/deprecations/table-pagination-props/table-pagination-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,28 @@ | ||
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: 'TablePagination', | ||
propName: 'ActionsComponent', | ||
slotName: 'actions', | ||
}); | ||
|
||
movePropIntoSlotProps(j, { | ||
root, | ||
componentName: 'TablePagination', | ||
propName: 'SelectProps', | ||
slotName: 'select', | ||
}); | ||
|
||
return root.toSource(printOptions); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/mui-codemod/src/deprecations/table-pagination-props/table-pagination-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 './table-pagination-props'; | ||
|
||
describe('@mui/codemod', () => { | ||
describe('deprecations', () => { | ||
describeJscodeshiftTransform({ | ||
transform, | ||
transformName: 'table-pagination-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' }, | ||
], | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/mui-codemod/src/deprecations/table-pagination-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,32 @@ | ||
import TablePagination from '@mui/material/TablePagination'; | ||
import { TablePagination as MyTablePagination } from '@mui/material'; | ||
|
||
<TablePagination ActionsComponent="div" SelectProps={{ native: true }} />; | ||
<TablePagination | ||
ActionsComponent="div" | ||
SelectProps={{ native: true }} | ||
slots={{ | ||
actions: 'div', | ||
select: 'div', | ||
}} | ||
/>; | ||
<TablePagination | ||
ActionsComponent="div" | ||
SelectProps={{ native: true }} | ||
slots={{ | ||
root: 'div', | ||
}} | ||
slotProps={{ | ||
root: { 'aria-label': '' }, | ||
}} | ||
/>; | ||
<TablePagination | ||
ActionsComponent="div" | ||
SelectProps={{ native: true }} | ||
slots={{ actions: () => null }} | ||
slotProps={{ select: { native: false } }} | ||
/>; | ||
|
||
<MyTablePagination ActionsComponent="div" SelectProps={{ native: true }} />; | ||
|
||
<CustomTablePagination ActionsComponent="div" SelectProps={{ native: true }} />; |
39 changes: 39 additions & 0 deletions
39
packages/mui-codemod/src/deprecations/table-pagination-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,39 @@ | ||
import TablePagination from '@mui/material/TablePagination'; | ||
import { TablePagination as MyTablePagination } from '@mui/material'; | ||
|
||
<TablePagination slots={{ | ||
actions: "div" | ||
}} slotProps={{ | ||
select: { native: true } | ||
}} />; | ||
<TablePagination | ||
slots={{ | ||
actions: 'div', | ||
select: 'div', | ||
}} | ||
slotProps={{ | ||
select: { native: true } | ||
}} />; | ||
<TablePagination | ||
slots={{ | ||
root: 'div', | ||
actions: "div" | ||
}} | ||
slotProps={{ | ||
root: { 'aria-label': '' }, | ||
select: { native: true } | ||
}} />; | ||
<TablePagination | ||
slots={{ actions: () => null }} | ||
slotProps={{ select: { | ||
...{ native: true }, | ||
...{ native: false } | ||
} }} />; | ||
|
||
<MyTablePagination slots={{ | ||
actions: "div" | ||
}} slotProps={{ | ||
select: { native: true } | ||
}} />; | ||
|
||
<CustomTablePagination ActionsComponent="div" SelectProps={{ native: true }} />; |
23 changes: 23 additions & 0 deletions
23
packages/mui-codemod/src/deprecations/table-pagination-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,23 @@ | ||
fn({ | ||
MuiTablePagination: { | ||
defaultProps: { | ||
ActionsComponent: 'div', | ||
SelectProps: { native: true }, | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiTablePagination: { | ||
defaultProps: { | ||
ActionsComponent: 'div', | ||
SelectProps: { native: true }, | ||
slotProps: { | ||
root: { id: 'test' }, | ||
}, | ||
slots: { | ||
root: 'div', | ||
}, | ||
}, | ||
}, | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/mui-codemod/src/deprecations/table-pagination-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,29 @@ | ||
fn({ | ||
MuiTablePagination: { | ||
defaultProps: { | ||
slots: { | ||
actions: 'div' | ||
}, | ||
|
||
slotProps: { | ||
select: { native: true } | ||
} | ||
}, | ||
}, | ||
}); | ||
|
||
fn({ | ||
MuiTablePagination: { | ||
defaultProps: { | ||
slotProps: { | ||
root: { id: 'test' }, | ||
select: { native: true } | ||
}, | ||
|
||
slots: { | ||
root: 'div', | ||
actions: 'div' | ||
} | ||
}, | ||
}, | ||
}); |
Oops, something went wrong.