@mui/codemod 6.0.0-alpha.5 → 6.0.0-alpha.7

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.
Files changed (38) hide show
  1. package/README.md +168 -0
  2. package/node/deprecations/all/deprecations-all.js +6 -0
  3. package/node/deprecations/all/postcss.config.js +4 -1
  4. package/node/deprecations/autocomplete-props/autocomplete-props.js +54 -0
  5. package/node/deprecations/autocomplete-props/index.js +13 -0
  6. package/node/deprecations/autocomplete-props/test-cases/actual.js +97 -0
  7. package/node/deprecations/autocomplete-props/test-cases/expected.js +101 -0
  8. package/node/deprecations/autocomplete-props/test-cases/theme.actual.js +65 -0
  9. package/node/deprecations/autocomplete-props/test-cases/theme.expected.js +68 -0
  10. package/node/deprecations/circular-progress-classes/circular-progress-classes.js +77 -0
  11. package/node/deprecations/circular-progress-classes/index.js +13 -0
  12. package/node/deprecations/circular-progress-classes/postcss-plugin.js +33 -0
  13. package/node/deprecations/circular-progress-classes/postcss.config.js +8 -0
  14. package/node/deprecations/circular-progress-classes/test-cases/actual.js +7 -0
  15. package/node/deprecations/circular-progress-classes/test-cases/expected.js +7 -0
  16. package/node/deprecations/divider-props/divider-props.js +36 -30
  17. package/node/deprecations/divider-props/test-cases/actual.js +3 -0
  18. package/node/deprecations/divider-props/test-cases/expected.js +3 -0
  19. package/node/deprecations/divider-props/test-cases/theme.actual.js +7 -0
  20. package/node/deprecations/divider-props/test-cases/theme.expected.js +7 -0
  21. package/node/deprecations/speed-dial-props/index.js +13 -0
  22. package/node/deprecations/speed-dial-props/speed-dial-props.js +31 -0
  23. package/node/deprecations/speed-dial-props/test-cases/actual.js +40 -0
  24. package/node/deprecations/speed-dial-props/test-cases/expected.js +54 -0
  25. package/node/deprecations/speed-dial-props/test-cases/theme.actual.js +33 -0
  26. package/node/deprecations/speed-dial-props/test-cases/theme.expected.js +40 -0
  27. package/node/util/getReturnExpression.js +20 -0
  28. package/node/util/migrateToVariants.js +472 -0
  29. package/node/v6.0.0/styled/styled-v6.js +2 -415
  30. package/node/v6.0.0/styled/test-cases/ConditionalStyled.actual.js +28 -1
  31. package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +38 -1
  32. package/node/v6.0.0/theme-v6/index.js +13 -0
  33. package/node/v6.0.0/theme-v6/test-cases/basicTheme.actual.js +530 -0
  34. package/node/v6.0.0/theme-v6/test-cases/basicTheme.expected.js +626 -0
  35. package/node/v6.0.0/theme-v6/test-cases/themeVariants.actual.js +63 -0
  36. package/node/v6.0.0/theme-v6/test-cases/themeVariants.expected.js +73 -0
  37. package/node/v6.0.0/theme-v6/theme-v6.js +87 -0
  38. package/package.json +5 -5
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "6.0.0-alpha.5",
3
+ "version": "6.0.0-alpha.7",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -24,9 +24,9 @@
24
24
  "url": "https://opencollective.com/mui-org"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/core": "^7.24.4",
28
- "@babel/runtime": "^7.24.4",
29
- "@babel/traverse": "^7.24.1",
27
+ "@babel/core": "^7.24.5",
28
+ "@babel/runtime": "^7.24.5",
29
+ "@babel/traverse": "^7.24.5",
30
30
  "jscodeshift": "^0.15.2",
31
31
  "jscodeshift-add-imports": "^1.0.10",
32
32
  "postcss": "^8.4.38",
@@ -34,7 +34,7 @@
34
34
  "yargs": "^17.7.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/chai": "^4.3.14",
37
+ "@types/chai": "^4.3.16",
38
38
  "@types/jscodeshift": "0.11.11",
39
39
  "chai": "^4.4.1"
40
40
  },