@mui/codemod 5.10.10 → 5.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -57
- package/codemod.js +0 -0
- package/node/v1.0.0/color-imports.js +1 -1
- package/node/v5.0.0/base-rename-components-to-slots.js +63 -0
- package/node/v5.0.0/base-rename-components-to-slots.test/actual.js +51 -0
- package/node/v5.0.0/base-rename-components-to-slots.test/expected.js +51 -0
- package/node/v5.0.0/jss-to-styled.test/seventh.actual.js +0 -4
- package/node/v5.0.0/jss-to-styled.test/seventh.expected.js +0 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,10 +169,10 @@ You can find more details about this breaking change in [the migration guide](ht
|
|
|
169
169
|
Renames `Autocomplete`'s `getOptionSelected` to `isOptionEqualToValue`.
|
|
170
170
|
|
|
171
171
|
```diff
|
|
172
|
-
<Autocomplete
|
|
173
|
-
-
|
|
174
|
-
+
|
|
175
|
-
/>
|
|
172
|
+
<Autocomplete
|
|
173
|
+
- getOptionSelected={(option, value) => option.title === value.title}
|
|
174
|
+
+ isOptionEqualToValue={(option, value) => option.title === value.title}
|
|
175
|
+
/>
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
<!-- #default-branch-switch -->
|
|
@@ -211,22 +211,22 @@ Renames the badge's props.
|
|
|
211
211
|
-<Badge overlap="rectangle">
|
|
212
212
|
+<Badge overlap="circular">
|
|
213
213
|
+<Badge overlap="rectangular">
|
|
214
|
-
<Badge classes={{
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
219
|
-
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
+
|
|
223
|
-
+
|
|
224
|
-
+
|
|
225
|
-
+
|
|
226
|
-
+
|
|
227
|
-
+
|
|
228
|
-
+
|
|
229
|
-
}}>
|
|
214
|
+
<Badge classes={{
|
|
215
|
+
- anchorOriginTopRightRectangle: 'className',
|
|
216
|
+
- anchorOriginBottomRightRectangle: 'className',
|
|
217
|
+
- anchorOriginTopLeftRectangle: 'className',
|
|
218
|
+
- anchorOriginBottomLeftRectangle: 'className',
|
|
219
|
+
- anchorOriginTopRightCircle: 'className',
|
|
220
|
+
- anchorOriginBottomRightCircle: 'className',
|
|
221
|
+
- anchorOriginTopLeftCircle: 'className',
|
|
222
|
+
+ anchorOriginTopRightRectangular: 'className',
|
|
223
|
+
+ anchorOriginBottomRightRectangular: 'className',
|
|
224
|
+
+ anchorOriginTopLeftRectangular: 'className',
|
|
225
|
+
+ anchorOriginBottomLeftRectangular: 'className',
|
|
226
|
+
+ anchorOriginTopRightCircular: 'className',
|
|
227
|
+
+ anchorOriginBottomRightCircular: 'className',
|
|
228
|
+
+ anchorOriginTopLeftCircular: 'className',
|
|
229
|
+
}}>
|
|
230
230
|
```
|
|
231
231
|
|
|
232
232
|
<!-- #default-branch-switch -->
|
|
@@ -237,6 +237,30 @@ npx @mui/codemod v5.0.0/badge-overlap-value <path>
|
|
|
237
237
|
|
|
238
238
|
You can find more details about this breaking change in [the migration guide](https://mui.com/material-ui/migration/v5-component-changes/#badge).
|
|
239
239
|
|
|
240
|
+
#### `base-rename-components-to-slots`
|
|
241
|
+
|
|
242
|
+
Renames the `components` and `componentsProps` props to `slots` and `slotProps`, respectively.
|
|
243
|
+
Also, changes `slots`' fields names to camelCase.
|
|
244
|
+
|
|
245
|
+
This change only affects MUI Base components.
|
|
246
|
+
|
|
247
|
+
```diff
|
|
248
|
+
<BadgeUnstyled
|
|
249
|
+
- components={{ Root, Badge: CustomBadge }}
|
|
250
|
+
+ slots={{ root: Root, badge: CustomBadge }}
|
|
251
|
+
- componentsProps={{ root: { className: 'root' }, badge: { 'data-testid': 'badge' } }}
|
|
252
|
+
+ slotProps={{ root: { className: 'root' }, badge: { 'data-testid': 'badge' } }}
|
|
253
|
+
/>;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
<!-- #default-branch-switch -->
|
|
257
|
+
|
|
258
|
+
```sh
|
|
259
|
+
npx @mui/codemod v5.0.0/base-rename-components-to-slots <path>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The associated breaking change was done in [#34693](https://github.com/mui/material-ui/pull/34693).
|
|
263
|
+
|
|
240
264
|
#### `box-borderradius-values`
|
|
241
265
|
|
|
242
266
|
Updates the Box API from separate system props to `sx`.
|
|
@@ -440,10 +464,10 @@ You can find more details about this breaking change in [the migration guide](ht
|
|
|
440
464
|
Adds `prepend: true` to Emotion `createCache`
|
|
441
465
|
|
|
442
466
|
```diff
|
|
443
|
-
const cache = emotionCreateCache({
|
|
444
|
-
|
|
445
|
-
+
|
|
446
|
-
});
|
|
467
|
+
const cache = emotionCreateCache({
|
|
468
|
+
key: 'css',
|
|
469
|
+
+ prepend: true,
|
|
470
|
+
});
|
|
447
471
|
```
|
|
448
472
|
|
|
449
473
|
```sh
|
|
@@ -542,7 +566,7 @@ You can find more details about this breaking change in [the migration guide](ht
|
|
|
542
566
|
Replace JSS styling with `makeStyles` or `withStyles` to `styled` API.
|
|
543
567
|
|
|
544
568
|
```diff
|
|
545
|
-
import Typography from '@material-ui/core/Typography';
|
|
569
|
+
import Typography from '@material-ui/core/Typography';
|
|
546
570
|
-import makeStyles from '@material-ui/styles/makeStyles';
|
|
547
571
|
+import { styled } from '@material-ui/core/styles';
|
|
548
572
|
|
|
@@ -583,17 +607,17 @@ import Typography from '@material-ui/core/Typography';
|
|
|
583
607
|
+ },
|
|
584
608
|
+}))
|
|
585
609
|
|
|
586
|
-
export const MyCard = () => {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
-
|
|
590
|
-
+
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
610
|
+
export const MyCard = () => {
|
|
611
|
+
const classes = useStyles();
|
|
612
|
+
return (
|
|
613
|
+
- <div className={classes.root}>
|
|
614
|
+
+ <Root className={classes.root}>
|
|
615
|
+
<Typography className={classes.content}>...</Typography>
|
|
616
|
+
<Button className={classes.cta}>Go</Button>
|
|
617
|
+
- </div>
|
|
618
|
+
+ </Root>
|
|
619
|
+
)
|
|
620
|
+
}
|
|
597
621
|
```
|
|
598
622
|
|
|
599
623
|
```sh
|
|
@@ -661,11 +685,11 @@ Migrate JSS styling with `makeStyles` or `withStyles` to the corresponding `tss-
|
|
|
661
685
|
The Background take the primary theme color when the mouse hovers the parent.
|
|
662
686
|
I am smaller than the other child.
|
|
663
687
|
</div>
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
688
|
+
</div>
|
|
689
|
+
);
|
|
690
|
+
}
|
|
667
691
|
|
|
668
|
-
export default App;
|
|
692
|
+
export default App;
|
|
669
693
|
```
|
|
670
694
|
|
|
671
695
|
```sh
|
|
@@ -731,7 +755,7 @@ Moves JSS imports to `@material-ui/styles`
|
|
|
731
755
|
+import withStyles from '@material-ui/styles/withStyles';
|
|
732
756
|
+import withTheme from '@material-ui/styles/withTheme';
|
|
733
757
|
+import getStylesCreator from '@material-ui/styles/getStylesCreator';
|
|
734
|
-
import mergeClasses from '@material-ui/styles/mergeClasses';
|
|
758
|
+
import mergeClasses from '@material-ui/styles/mergeClasses';
|
|
735
759
|
```
|
|
736
760
|
|
|
737
761
|
```sh
|
|
@@ -758,10 +782,10 @@ You can find more details about this breaking change in [the migration guide](ht
|
|
|
758
782
|
Removes `disableBackdropClick` and `onEscapeKeyDown` from `<Modal>`
|
|
759
783
|
|
|
760
784
|
```diff
|
|
761
|
-
<Modal
|
|
762
|
-
-
|
|
763
|
-
-
|
|
764
|
-
/>
|
|
785
|
+
<Modal
|
|
786
|
+
- disableBackdropClick
|
|
787
|
+
- onEscapeKeyDown={handleEscapeKeyDown}
|
|
788
|
+
/>
|
|
765
789
|
```
|
|
766
790
|
|
|
767
791
|
```sh
|
|
@@ -1100,7 +1124,7 @@ npx @mui/codemod v5.0.0/use-autocomplete <path>
|
|
|
1100
1124
|
Updates Dialog, Menu, Popover, and Snackbar to use the `TransitionProps` prop to replace the `onEnter*` and `onExit*` props.
|
|
1101
1125
|
|
|
1102
1126
|
```diff
|
|
1103
|
-
<Dialog
|
|
1127
|
+
<Dialog
|
|
1104
1128
|
- onEnter={onEnter}
|
|
1105
1129
|
- onEntered={onEntered}
|
|
1106
1130
|
- onEntering={onEntering}
|
|
@@ -1115,7 +1139,7 @@ Updates Dialog, Menu, Popover, and Snackbar to use the `TransitionProps` prop to
|
|
|
1115
1139
|
+ onExited,
|
|
1116
1140
|
+ onExiting,
|
|
1117
1141
|
+ }}
|
|
1118
|
-
/>
|
|
1142
|
+
/>
|
|
1119
1143
|
```
|
|
1120
1144
|
|
|
1121
1145
|
<!-- #default-branch-switch -->
|
|
@@ -1159,9 +1183,9 @@ npx @mui/codemod v5.0.0/variant-prop <path>
|
|
|
1159
1183
|
Removes imported `withMobileDialog`, and inserts hardcoded version to prevent application crash.
|
|
1160
1184
|
|
|
1161
1185
|
```diff
|
|
1162
|
-
-
|
|
1163
|
-
|
|
1164
|
-
+
|
|
1186
|
+
-import withMobileDialog from '@material-ui/core/withMobileDialog';
|
|
1187
|
+
+// FIXME checkout https://mui.com/material-ui/migration/v5-component-changes/#dialog
|
|
1188
|
+
+const withMobileDialog = () => (WrappedComponent) => (props) => <WrappedComponent {...props} width="lg" fullScreen={false} />;
|
|
1165
1189
|
```
|
|
1166
1190
|
|
|
1167
1191
|
```sh
|
|
@@ -1175,9 +1199,9 @@ You can find more details about this breaking change in [the migration guide](ht
|
|
|
1175
1199
|
Removes `withWidth` import, and inserts hardcoded version to prevent application crash.
|
|
1176
1200
|
|
|
1177
1201
|
```diff
|
|
1178
|
-
-
|
|
1179
|
-
|
|
1180
|
-
+
|
|
1202
|
+
-import withWidth from '@material-ui/core/withWidth';
|
|
1203
|
+
+// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
|
|
1204
|
+
+const withWidth = () => (WrappedComponent) => (props) => <WrappedComponent {...props} width="xs" />;
|
|
1181
1205
|
```
|
|
1182
1206
|
|
|
1183
1207
|
```sh
|
|
@@ -1228,7 +1252,7 @@ Replace every occurrence of `material-ui` related package with the new package n
|
|
|
1228
1252
|
**Dependencies**
|
|
1229
1253
|
|
|
1230
1254
|
```diff
|
|
1231
|
-
// package.json
|
|
1255
|
+
// package.json
|
|
1232
1256
|
-"@material-ui/core": "next",
|
|
1233
1257
|
-"@material-ui/icons": "next",
|
|
1234
1258
|
-"@material-ui/lab": "next",
|
|
@@ -1271,7 +1295,7 @@ This codemod tries to perform a basic expression simplification which can be imp
|
|
|
1271
1295
|
-const spacing = theme.spacing.unit / 5;
|
|
1272
1296
|
+const spacing = theme.spacing(0.2);
|
|
1273
1297
|
|
|
1274
|
-
// Limitation
|
|
1298
|
+
// Limitation
|
|
1275
1299
|
-const spacing = theme.spacing.unit * 5 * 5;
|
|
1276
1300
|
+const spacing = theme.spacing(5) * 5;
|
|
1277
1301
|
```
|
|
@@ -1411,11 +1435,11 @@ MUI v0.15.0 is reorganizing the folder distribution of the project.
|
|
|
1411
1435
|
The diff should look like this:
|
|
1412
1436
|
|
|
1413
1437
|
```diff
|
|
1414
|
-
// From the source
|
|
1438
|
+
// From the source
|
|
1415
1439
|
-import FlatButton from 'material-ui/src/flat-button';
|
|
1416
1440
|
+import FlatButton from 'material-ui/src/FlatButton';
|
|
1417
1441
|
|
|
1418
|
-
// From npm
|
|
1442
|
+
// From npm
|
|
1419
1443
|
-import RaisedButton from 'material-ui/lib/raised-button';
|
|
1420
1444
|
+import RaisedButton from 'material-ui/RaisedButton';
|
|
1421
1445
|
```
|
package/codemod.js
CHANGED
|
File without changes
|
|
@@ -11,7 +11,7 @@ const commonColors = ['black', 'white', 'transparent', 'fullBlack', 'darkBlack',
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
function colorAccent(colorIdentifier) {
|
|
14
|
-
const [, palette, hue] = colorIdentifier.match(/([A-
|
|
14
|
+
const [, palette, hue] = colorIdentifier.match(/([A-Za-z]+?)(A?\d+)?$/);
|
|
15
15
|
return {
|
|
16
16
|
palette,
|
|
17
17
|
hue
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
|
|
8
|
+
function transformComponentsProp(attributeNode) {
|
|
9
|
+
attributeNode.name.name = 'slots';
|
|
10
|
+
const valueExpression = attributeNode.value.expression;
|
|
11
|
+
|
|
12
|
+
if ((valueExpression == null ? void 0 : valueExpression.type) !== 'ObjectExpression') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
valueExpression.properties.forEach(property => {
|
|
17
|
+
property.key.name = property.key.name[0].toLowerCase() + property.key.name.slice(1);
|
|
18
|
+
|
|
19
|
+
if (property.shorthand) {
|
|
20
|
+
property.shorthand = false;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function transformComponentsPropsProp(attributeNode) {
|
|
26
|
+
attributeNode.name.name = 'slotProps';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
30
|
+
* @param {import('jscodeshift').API} api
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function transformer(file, api, options) {
|
|
35
|
+
const j = api.jscodeshift;
|
|
36
|
+
const root = j(file.source);
|
|
37
|
+
const printOptions = options.printOptions;
|
|
38
|
+
const transformed = root.findJSXElements().forEach(path => {
|
|
39
|
+
// Process only unstyled components
|
|
40
|
+
if (!path.node.openingElement.name.name.endsWith('Unstyled')) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
path.node.openingElement.attributes.forEach(node => {
|
|
45
|
+
if (node.type !== 'JSXAttribute') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
switch (node.name.name) {
|
|
50
|
+
case 'components':
|
|
51
|
+
transformComponentsProp(node);
|
|
52
|
+
break;
|
|
53
|
+
|
|
54
|
+
case 'componentsProps':
|
|
55
|
+
transformComponentsPropsProp(node);
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return transformed.toSource(printOptions);
|
|
63
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
(0, _jsxRuntime.jsx)(BadgeUnstyled, {
|
|
7
|
+
components: {
|
|
8
|
+
Root,
|
|
9
|
+
Badge: CustomBadge
|
|
10
|
+
},
|
|
11
|
+
componentsProps: {
|
|
12
|
+
root: {
|
|
13
|
+
className: 'root'
|
|
14
|
+
},
|
|
15
|
+
badge: {
|
|
16
|
+
'data-testid': 'badge'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/*#__PURE__*/
|
|
22
|
+
(0, _jsxRuntime.jsx)(InputUnstyled, {
|
|
23
|
+
components: {
|
|
24
|
+
Input: CustomInput,
|
|
25
|
+
Root: CustomRoot
|
|
26
|
+
},
|
|
27
|
+
componentsProps: {
|
|
28
|
+
root: {
|
|
29
|
+
className: 'root'
|
|
30
|
+
},
|
|
31
|
+
input: {
|
|
32
|
+
className: 'input'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
(0, _jsxRuntime.jsx)(Badge, {
|
|
39
|
+
components: {
|
|
40
|
+
Root,
|
|
41
|
+
Badge: CustomBadge
|
|
42
|
+
},
|
|
43
|
+
componentsProps: {
|
|
44
|
+
root: {
|
|
45
|
+
className: 'root'
|
|
46
|
+
},
|
|
47
|
+
badge: {
|
|
48
|
+
'data-testid': 'badge'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
(0, _jsxRuntime.jsx)(BadgeUnstyled, {
|
|
7
|
+
slots: {
|
|
8
|
+
root: Root,
|
|
9
|
+
badge: CustomBadge
|
|
10
|
+
},
|
|
11
|
+
slotProps: {
|
|
12
|
+
root: {
|
|
13
|
+
className: 'root'
|
|
14
|
+
},
|
|
15
|
+
badge: {
|
|
16
|
+
'data-testid': 'badge'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/*#__PURE__*/
|
|
22
|
+
(0, _jsxRuntime.jsx)(InputUnstyled, {
|
|
23
|
+
slots: {
|
|
24
|
+
input: CustomInput,
|
|
25
|
+
root: CustomRoot
|
|
26
|
+
},
|
|
27
|
+
slotProps: {
|
|
28
|
+
root: {
|
|
29
|
+
className: 'root'
|
|
30
|
+
},
|
|
31
|
+
input: {
|
|
32
|
+
className: 'input'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
(0, _jsxRuntime.jsx)(Badge, {
|
|
39
|
+
components: {
|
|
40
|
+
Root,
|
|
41
|
+
Badge: CustomBadge
|
|
42
|
+
},
|
|
43
|
+
componentsProps: {
|
|
44
|
+
root: {
|
|
45
|
+
className: 'root'
|
|
46
|
+
},
|
|
47
|
+
badge: {
|
|
48
|
+
'data-testid': 'badge'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|