@mui/codemod 6.0.0-alpha.5 → 6.0.0-alpha.6
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 +66 -0
- package/node/deprecations/all/deprecations-all.js +2 -0
- package/node/deprecations/speed-dial-props/index.js +13 -0
- package/node/deprecations/speed-dial-props/speed-dial-props.js +31 -0
- package/node/deprecations/speed-dial-props/test-cases/actual.js +40 -0
- package/node/deprecations/speed-dial-props/test-cases/expected.js +54 -0
- package/node/deprecations/speed-dial-props/test-cases/theme.actual.js +33 -0
- package/node/deprecations/speed-dial-props/test-cases/theme.expected.js +40 -0
- package/node/util/getReturnExpression.js +20 -0
- package/node/util/migrateToVariants.js +472 -0
- package/node/v6.0.0/styled/styled-v6.js +2 -415
- package/node/v6.0.0/styled/test-cases/ConditionalStyled.actual.js +28 -1
- package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +38 -1
- package/node/v6.0.0/theme-v6/index.js +13 -0
- package/node/v6.0.0/theme-v6/test-cases/basicTheme.actual.js +530 -0
- package/node/v6.0.0/theme-v6/test-cases/basicTheme.expected.js +626 -0
- package/node/v6.0.0/theme-v6/test-cases/themeVariants.actual.js +63 -0
- package/node/v6.0.0/theme-v6/test-cases/themeVariants.expected.js +73 -0
- package/node/v6.0.0/theme-v6/theme-v6.js +87 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1099,8 +1099,74 @@ npx @mui/codemod@next deprecations/step-connector-classes <path>
|
|
|
1099
1099
|
|
|
1100
1100
|
### v6.0.0
|
|
1101
1101
|
|
|
1102
|
+
#### `theme-v6`
|
|
1103
|
+
|
|
1104
|
+
```bash
|
|
1105
|
+
npx @mui/codemod@next v6.0.0/theme-v6 <path>
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
Update the theme creation from `@mui/system@v5` to be compatible with `@pigment-css/react`.
|
|
1109
|
+
|
|
1110
|
+
- replace palette mode conditional with `theme.applyStyles()`
|
|
1111
|
+
- replace `ownerState` with `variants`
|
|
1112
|
+
- move theme variants to the root slot
|
|
1113
|
+
|
|
1114
|
+
```diff
|
|
1115
|
+
createTheme({
|
|
1116
|
+
components: {
|
|
1117
|
+
MuiButton: {
|
|
1118
|
+
- variants: [
|
|
1119
|
+
- {
|
|
1120
|
+
- props: { color: 'primary' },
|
|
1121
|
+
- style: {
|
|
1122
|
+
- color: 'red',
|
|
1123
|
+
- },
|
|
1124
|
+
- },
|
|
1125
|
+
- ],
|
|
1126
|
+
styleOverrides: {
|
|
1127
|
+
- root: ({ theme, ownerState }) => ({
|
|
1128
|
+
+ root: ({ theme }) => ({
|
|
1129
|
+
...ownerState.variant === 'contained' && {
|
|
1130
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.8),
|
|
1131
|
+
...theme.palette.mode === 'dark' && {
|
|
1132
|
+
backgroundColor: alpha(theme.palette.primary.light, 0.9),
|
|
1133
|
+
}
|
|
1134
|
+
},
|
|
1135
|
+
+ variants: [
|
|
1136
|
+
+ {
|
|
1137
|
+
+ prop: { variant: 'contained' },
|
|
1138
|
+
+ style: {
|
|
1139
|
+
+ backgroundColor: alpha(theme.palette.primary.main, 0.8),
|
|
1140
|
+
+ },
|
|
1141
|
+
+ },
|
|
1142
|
+
+ {
|
|
1143
|
+
+ prop: { variant: 'contained' },
|
|
1144
|
+
+ style: {
|
|
1145
|
+
+ ...theme.applyStyles('dark', {
|
|
1146
|
+
+ backgroundColor: alpha(theme.palette.primary.light, 0.9),
|
|
1147
|
+
+ })
|
|
1148
|
+
+ },
|
|
1149
|
+
+ },
|
|
1150
|
+
+ {
|
|
1151
|
+
+ prop: { color: 'primary' },
|
|
1152
|
+
+ style: {
|
|
1153
|
+
+ color: 'red',
|
|
1154
|
+
+ },
|
|
1155
|
+
+ },
|
|
1156
|
+
+ ],
|
|
1157
|
+
})
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
})
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1102
1164
|
#### `styled-v6`
|
|
1103
1165
|
|
|
1166
|
+
```bash
|
|
1167
|
+
npx @mui/codemod@next v6.0.0/styled-v6 <path>
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1104
1170
|
Updates the usage of `styled` from `@mui/system@v5` to be compatible with `@pigment-css/react`.
|
|
1105
1171
|
|
|
1106
1172
|
This codemod transforms the styles based on props to `variants` by looking for `styled` calls:
|
|
@@ -19,6 +19,7 @@ var _toggleButtonGroupClasses = _interopRequireDefault(require("../toggle-button
|
|
|
19
19
|
var _stepLabelProps = _interopRequireDefault(require("../step-label-props"));
|
|
20
20
|
var _backdropProps = _interopRequireDefault(require("../backdrop-props"));
|
|
21
21
|
var _stepConnectorClasses = _interopRequireDefault(require("../step-connector-classes"));
|
|
22
|
+
var _speedDialProps = _interopRequireDefault(require("../speed-dial-props"));
|
|
22
23
|
/**
|
|
23
24
|
* @param {import('jscodeshift').FileInfo} file
|
|
24
25
|
* @param {import('jscodeshift').API} api
|
|
@@ -38,5 +39,6 @@ function deprecationsAll(file, api, options) {
|
|
|
38
39
|
file.source = (0, _stepLabelProps.default)(file, api, options);
|
|
39
40
|
file.source = (0, _backdropProps.default)(file, api, options);
|
|
40
41
|
file.source = (0, _stepConnectorClasses.default)(file, api, options);
|
|
42
|
+
file.source = (0, _speedDialProps.default)(file, api, options);
|
|
41
43
|
return file.source;
|
|
42
44
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _speedDialProps.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _speedDialProps = _interopRequireDefault(require("./speed-dial-props"));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = transformer;
|
|
8
|
+
var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
|
|
9
|
+
var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
12
|
+
* @param {import('jscodeshift').API} api
|
|
13
|
+
*/
|
|
14
|
+
function transformer(file, api, options) {
|
|
15
|
+
const j = api.jscodeshift;
|
|
16
|
+
const root = j(file.source);
|
|
17
|
+
const printOptions = options.printOptions;
|
|
18
|
+
(0, _movePropIntoSlots.default)(j, {
|
|
19
|
+
root,
|
|
20
|
+
componentName: 'SpeedDial',
|
|
21
|
+
propName: 'TransitionComponent',
|
|
22
|
+
slotName: 'transition'
|
|
23
|
+
});
|
|
24
|
+
(0, _movePropIntoSlotProps.default)(j, {
|
|
25
|
+
root,
|
|
26
|
+
componentName: 'SpeedDial',
|
|
27
|
+
propName: 'TransitionProps',
|
|
28
|
+
slotName: 'transition'
|
|
29
|
+
});
|
|
30
|
+
return root.toSource(printOptions);
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _SpeedDial = _interopRequireDefault(require("@mui/material/SpeedDial"));
|
|
6
|
+
var _material = require("@mui/material");
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
9
|
+
TransitionComponent: CustomTransition,
|
|
10
|
+
TransitionProps: CustomTransitionProps
|
|
11
|
+
});
|
|
12
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
|
|
13
|
+
TransitionComponent: CustomTransition,
|
|
14
|
+
TransitionProps: CustomTransitionProps
|
|
15
|
+
});
|
|
16
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
17
|
+
TransitionComponent: CustomTransition,
|
|
18
|
+
TransitionProps: CustomTransitionProps,
|
|
19
|
+
slots: {
|
|
20
|
+
root: 'div'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
|
|
24
|
+
TransitionComponent: CustomTransition,
|
|
25
|
+
TransitionProps: CustomTransitionProps,
|
|
26
|
+
slots: (0, _extends2.default)({}, outerSlots)
|
|
27
|
+
});
|
|
28
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
29
|
+
TransitionComponent: ComponentTransition,
|
|
30
|
+
TransitionProps: CustomTransitionProps,
|
|
31
|
+
slots: {
|
|
32
|
+
root: 'div',
|
|
33
|
+
transition: SlotTransition
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
// should skip non MUI components
|
|
37
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiSpeedDial, {
|
|
38
|
+
TransitionComponent: CustomTransition,
|
|
39
|
+
TransitionProps: CustomTransitionProps
|
|
40
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _SpeedDial = _interopRequireDefault(require("@mui/material/SpeedDial"));
|
|
6
|
+
var _material = require("@mui/material");
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
9
|
+
slots: {
|
|
10
|
+
transition: CustomTransition
|
|
11
|
+
},
|
|
12
|
+
slotProps: {
|
|
13
|
+
transition: CustomTransitionProps
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
|
|
17
|
+
slots: {
|
|
18
|
+
transition: CustomTransition
|
|
19
|
+
},
|
|
20
|
+
slotProps: {
|
|
21
|
+
transition: CustomTransitionProps
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
25
|
+
slots: {
|
|
26
|
+
root: 'div',
|
|
27
|
+
transition: CustomTransition
|
|
28
|
+
},
|
|
29
|
+
slotProps: {
|
|
30
|
+
transition: CustomTransitionProps
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.SpeedDial, {
|
|
34
|
+
slots: (0, _extends2.default)({}, outerSlots, {
|
|
35
|
+
transition: CustomTransition
|
|
36
|
+
}),
|
|
37
|
+
slotProps: {
|
|
38
|
+
transition: CustomTransitionProps
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_SpeedDial.default, {
|
|
42
|
+
slots: {
|
|
43
|
+
root: 'div',
|
|
44
|
+
transition: SlotTransition
|
|
45
|
+
},
|
|
46
|
+
slotProps: {
|
|
47
|
+
transition: CustomTransitionProps
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// should skip non MUI components
|
|
51
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiSpeedDial, {
|
|
52
|
+
TransitionComponent: CustomTransition,
|
|
53
|
+
TransitionProps: CustomTransitionProps
|
|
54
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
fn({
|
|
4
|
+
MuiSpeedDial: {
|
|
5
|
+
defaultProps: {
|
|
6
|
+
TransitionComponent: CustomTransition,
|
|
7
|
+
TransitionProps: CustomTransitionProps
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
fn({
|
|
12
|
+
MuiSpeedDial: {
|
|
13
|
+
defaultProps: {
|
|
14
|
+
TransitionComponent: CustomTransition,
|
|
15
|
+
TransitionProps: CustomTransitionProps,
|
|
16
|
+
slots: {
|
|
17
|
+
root: 'div'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
fn({
|
|
23
|
+
MuiSpeedDial: {
|
|
24
|
+
defaultProps: {
|
|
25
|
+
TransitionComponent: ComponentTransition,
|
|
26
|
+
TransitionProps: CustomTransitionProps,
|
|
27
|
+
slots: {
|
|
28
|
+
root: 'div',
|
|
29
|
+
transition: SlotTransition
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
fn({
|
|
4
|
+
MuiSpeedDial: {
|
|
5
|
+
defaultProps: {
|
|
6
|
+
slots: {
|
|
7
|
+
transition: CustomTransition
|
|
8
|
+
},
|
|
9
|
+
slotProps: {
|
|
10
|
+
transition: CustomTransitionProps
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
fn({
|
|
16
|
+
MuiSpeedDial: {
|
|
17
|
+
defaultProps: {
|
|
18
|
+
slots: {
|
|
19
|
+
root: 'div',
|
|
20
|
+
transition: CustomTransition
|
|
21
|
+
},
|
|
22
|
+
slotProps: {
|
|
23
|
+
transition: CustomTransitionProps
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
fn({
|
|
29
|
+
MuiSpeedDial: {
|
|
30
|
+
defaultProps: {
|
|
31
|
+
slots: {
|
|
32
|
+
root: 'div',
|
|
33
|
+
transition: SlotTransition
|
|
34
|
+
},
|
|
35
|
+
slotProps: {
|
|
36
|
+
transition: CustomTransitionProps
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getReturnExpression;
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('ast-types').namedTypes.ArrowFunctionExpression | import('ast-types').namedTypes.FunctionExpression} node
|
|
9
|
+
*/
|
|
10
|
+
function getReturnExpression(node) {
|
|
11
|
+
let body = node.body;
|
|
12
|
+
if (body === 'BlockStatement') {
|
|
13
|
+
body = body.body;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(body)) {
|
|
16
|
+
var _body$find;
|
|
17
|
+
return (_body$find = body.find(statement => statement.type === 'ReturnStatement')) == null ? void 0 : _body$find.argument;
|
|
18
|
+
}
|
|
19
|
+
return body;
|
|
20
|
+
}
|