@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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = getCheckoutTheme;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
function getCheckoutTheme(mode) {
|
|
10
|
+
return (0, _extends2.default)({}, getDesignTokens(mode), {
|
|
11
|
+
components: {
|
|
12
|
+
MuiStepIcon: {
|
|
13
|
+
styleOverrides: {
|
|
14
|
+
root: ({
|
|
15
|
+
theme
|
|
16
|
+
}) => (0, _extends2.default)({
|
|
17
|
+
color: 'transparent',
|
|
18
|
+
border: `1px solid ${gray[400]}`,
|
|
19
|
+
width: 12,
|
|
20
|
+
height: 12,
|
|
21
|
+
borderRadius: '50%',
|
|
22
|
+
'& text': {
|
|
23
|
+
display: 'none'
|
|
24
|
+
},
|
|
25
|
+
'&.Mui-active': {
|
|
26
|
+
border: 'none',
|
|
27
|
+
color: theme.palette.primary.main
|
|
28
|
+
},
|
|
29
|
+
'&.Mui-completed': {
|
|
30
|
+
border: 'none',
|
|
31
|
+
color: theme.palette.success.main
|
|
32
|
+
}
|
|
33
|
+
}, theme.applyStyles("dark", {
|
|
34
|
+
border: `1px solid ${gray[700]}`,
|
|
35
|
+
'&.Mui-active': {
|
|
36
|
+
border: 'none',
|
|
37
|
+
color: theme.palette.primary.light
|
|
38
|
+
},
|
|
39
|
+
'&.Mui-completed': {
|
|
40
|
+
border: 'none',
|
|
41
|
+
color: theme.palette.success.light
|
|
42
|
+
}
|
|
43
|
+
}), {
|
|
44
|
+
variants: [{
|
|
45
|
+
props: {
|
|
46
|
+
size: 'large'
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
width: 20,
|
|
50
|
+
height: 20
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
props: {
|
|
54
|
+
variant: 'shadow'
|
|
55
|
+
},
|
|
56
|
+
style: (0, _extends2.default)({}, theme.applyStyles("dark", {
|
|
57
|
+
boxShadow: theme.shadows[2]
|
|
58
|
+
}))
|
|
59
|
+
}, {
|
|
60
|
+
props: {
|
|
61
|
+
completed: true
|
|
62
|
+
},
|
|
63
|
+
style: {
|
|
64
|
+
width: 12,
|
|
65
|
+
height: 12
|
|
66
|
+
}
|
|
67
|
+
}]
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = styledV6;
|
|
8
|
+
var _getReturnExpression = _interopRequireDefault(require("../../util/getReturnExpression"));
|
|
9
|
+
var _migrateToVariants = _interopRequireDefault(require("../../util/migrateToVariants"));
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
12
|
+
* @param {import('jscodeshift').API} api
|
|
13
|
+
*/
|
|
14
|
+
function styledV6(file, api, options) {
|
|
15
|
+
const j = api.jscodeshift;
|
|
16
|
+
const root = j(file.source);
|
|
17
|
+
const printOptions = options.printOptions;
|
|
18
|
+
let shouldTransform = false;
|
|
19
|
+
root.find(j.ArrowFunctionExpression).forEach(path => {
|
|
20
|
+
const styles = [];
|
|
21
|
+
let args = [];
|
|
22
|
+
if (path.parent.parent.parent.get('key', 'name').value === 'styleOverrides') {
|
|
23
|
+
args = [path.node];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 1. collecting styles that should be tranformed
|
|
27
|
+
args.forEach(arg => {
|
|
28
|
+
if (arg.type === 'ArrowFunctionExpression' && arg.params[0] && arg.params[0].type === 'ObjectPattern') {
|
|
29
|
+
styles.push(arg);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (!shouldTransform && styles.length > 0) {
|
|
33
|
+
shouldTransform = true;
|
|
34
|
+
}
|
|
35
|
+
(0, _migrateToVariants.default)(j, styles);
|
|
36
|
+
if (path.parent.get('key', 'name').value === 'root') {
|
|
37
|
+
const componentTheme = path.parent.parent.parent.parent.get('properties');
|
|
38
|
+
if (componentTheme.node.type === 'ObjectExpression') {
|
|
39
|
+
componentTheme.node.properties.forEach(prop => {
|
|
40
|
+
if (prop.key.name === 'variants') {
|
|
41
|
+
prop.value.elements = prop.value.elements.map(element => {
|
|
42
|
+
const styleIndex = element.properties.findIndex(styleProp => styleProp.type === 'ObjectProperty' && styleProp.key.name === 'style');
|
|
43
|
+
if (styleIndex !== -1 && element.properties[styleIndex].value.type !== 'ObjectExpression') {
|
|
44
|
+
element.properties[styleIndex].value = (0, _getReturnExpression.default)(element.properties[styleIndex].value);
|
|
45
|
+
}
|
|
46
|
+
return element;
|
|
47
|
+
});
|
|
48
|
+
const stylesNode = (0, _getReturnExpression.default)(path.node);
|
|
49
|
+
const variantsNode = stylesNode == null ? void 0 : stylesNode.properties.find(styleProp => styleProp.type === 'ObjectProperty' && styleProp.key.name === 'variants');
|
|
50
|
+
if (variantsNode) {
|
|
51
|
+
variantsNode.value.elements.push(...prop.value.elements);
|
|
52
|
+
} else {
|
|
53
|
+
stylesNode.properties.push(j.property('init', j.identifier('variants'), prop.value));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
componentTheme.node.properties = componentTheme.node.properties.filter(prop => prop.key.name !== 'variants');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const transformed = root.toSource(printOptions);
|
|
62
|
+
if (shouldTransform) {
|
|
63
|
+
// recast adds extra newlines that we don't want, https://github.com/facebook/jscodeshift/issues/249
|
|
64
|
+
// need to remove them manually
|
|
65
|
+
const lines = [];
|
|
66
|
+
let isInStyled = false;
|
|
67
|
+
let spaceMatch;
|
|
68
|
+
transformed.split('\n').forEach(line => {
|
|
69
|
+
if (!isInStyled) {
|
|
70
|
+
lines.push(line);
|
|
71
|
+
} else if (line !== '') {
|
|
72
|
+
var _line$match, _spaceMatch;
|
|
73
|
+
if (spaceMatch && ((_line$match = line.match(/^\s+/)) == null ? void 0 : _line$match[0]) === ((_spaceMatch = spaceMatch) == null ? void 0 : _spaceMatch[0])) {
|
|
74
|
+
isInStyled = false;
|
|
75
|
+
spaceMatch = null;
|
|
76
|
+
}
|
|
77
|
+
lines.push(line);
|
|
78
|
+
}
|
|
79
|
+
if (line.includes('styleOverrides')) {
|
|
80
|
+
isInStyled = true;
|
|
81
|
+
spaceMatch = line.match(/^\s+/);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return lines.join('\n');
|
|
85
|
+
}
|
|
86
|
+
return transformed;
|
|
87
|
+
}
|