@mui/codemod 7.1.0 → 7.1.1

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 (178) hide show
  1. package/README.md +10 -0
  2. package/codemod.js +8 -0
  3. package/deprecations/accordion-props/accordion-props.js +2 -0
  4. package/deprecations/accordion-props/test-cases/package.actual.js +68 -0
  5. package/deprecations/accordion-props/test-cases/package.expected.js +74 -0
  6. package/deprecations/accordion-summary-classes/accordion-summary-classes.js +1 -1
  7. package/deprecations/accordion-summary-classes/test-cases/package.actual.js +54 -0
  8. package/deprecations/accordion-summary-classes/test-cases/package.expected.js +54 -0
  9. package/deprecations/alert-classes/alert-classes.js +1 -1
  10. package/deprecations/alert-classes/test-cases/package.actual.js +27 -0
  11. package/deprecations/alert-classes/test-cases/package.expected.js +27 -0
  12. package/deprecations/alert-props/alert-props.js +1 -0
  13. package/deprecations/alert-props/test-cases/package.actual.js +60 -0
  14. package/deprecations/alert-props/test-cases/package.expected.js +52 -0
  15. package/deprecations/autocomplete-props/autocomplete-props.js +7 -0
  16. package/deprecations/autocomplete-props/test-cases/package.actual.js +113 -0
  17. package/deprecations/autocomplete-props/test-cases/package.expected.js +125 -0
  18. package/deprecations/avatar-group-props/avatar-group-props.js +4 -2
  19. package/deprecations/avatar-group-props/test-cases/package.actual.js +56 -0
  20. package/deprecations/avatar-group-props/test-cases/package.expected.js +58 -0
  21. package/deprecations/avatar-props/avatar-props.js +2 -1
  22. package/deprecations/avatar-props/test-cases/package.actual.js +36 -0
  23. package/deprecations/avatar-props/test-cases/package.expected.js +42 -0
  24. package/deprecations/backdrop-props/backdrop-props.js +2 -0
  25. package/deprecations/backdrop-props/test-cases/package.actual.js +81 -0
  26. package/deprecations/backdrop-props/test-cases/package.expected.js +81 -0
  27. package/deprecations/badge-props/badge-props.js +2 -1
  28. package/deprecations/badge-props/test-cases/package.actual.js +59 -0
  29. package/deprecations/badge-props/test-cases/package.expected.js +51 -0
  30. package/deprecations/button-classes/button-classes.js +1 -1
  31. package/deprecations/button-classes/test-cases/package.actual.js +69 -0
  32. package/deprecations/button-classes/test-cases/package.expected.js +69 -0
  33. package/deprecations/button-group-classes/button-group-classes.js +1 -1
  34. package/deprecations/button-group-classes/test-cases/package.actual.js +37 -0
  35. package/deprecations/button-group-classes/test-cases/package.expected.js +37 -0
  36. package/deprecations/card-header-props/card-header-props.js +2 -0
  37. package/deprecations/card-header-props/test-cases/package.actual.js +66 -0
  38. package/deprecations/card-header-props/test-cases/package.expected.js +78 -0
  39. package/deprecations/chip-classes/chip-classes.js +1 -1
  40. package/deprecations/chip-classes/test-cases/package.actual.js +55 -0
  41. package/deprecations/chip-classes/test-cases/package.expected.js +55 -0
  42. package/deprecations/circular-progress-classes/circular-progress-classes.js +1 -1
  43. package/deprecations/circular-progress-classes/test-cases/package.actual.js +7 -0
  44. package/deprecations/circular-progress-classes/test-cases/package.expected.js +7 -0
  45. package/deprecations/dialog-classes/dialog-classes.js +1 -1
  46. package/deprecations/dialog-classes/test-cases/package.actual.js +7 -0
  47. package/deprecations/dialog-classes/test-cases/package.expected.js +7 -0
  48. package/deprecations/divider-props/divider-props.js +3 -1
  49. package/deprecations/divider-props/test-cases/package.actual.js +45 -0
  50. package/deprecations/divider-props/test-cases/package.expected.js +50 -0
  51. package/deprecations/drawer-classes/drawer-classes.js +1 -1
  52. package/deprecations/drawer-classes/test-cases/package.actual.js +19 -0
  53. package/deprecations/drawer-classes/test-cases/package.expected.js +19 -0
  54. package/deprecations/drawer-props/drawer-props.js +8 -0
  55. package/deprecations/drawer-props/test-cases/package.actual.js +73 -0
  56. package/deprecations/drawer-props/test-cases/package.expected.js +97 -0
  57. package/deprecations/filled-input-props/filled-input-props.js +1 -0
  58. package/deprecations/filled-input-props/test-cases/package.actual.js +60 -0
  59. package/deprecations/filled-input-props/test-cases/package.expected.js +52 -0
  60. package/deprecations/form-control-label-props/form-control-label-props.js +1 -0
  61. package/deprecations/form-control-label-props/test-cases/package.actual.js +21 -0
  62. package/deprecations/form-control-label-props/test-cases/package.expected.js +21 -0
  63. package/deprecations/image-list-item-bar-classes/image-list-item-bar-classes.js +1 -1
  64. package/deprecations/image-list-item-bar-classes/test-cases/package.actual.js +11 -0
  65. package/deprecations/image-list-item-bar-classes/test-cases/package.expected.js +11 -0
  66. package/deprecations/input-base-classes/input-base-classes.js +1 -1
  67. package/deprecations/input-base-classes/test-cases/package.actual.js +13 -0
  68. package/deprecations/input-base-classes/test-cases/package.expected.js +13 -0
  69. package/deprecations/input-base-props/input-base-props.js +1 -0
  70. package/deprecations/input-base-props/test-cases/package.actual.js +60 -0
  71. package/deprecations/input-base-props/test-cases/package.expected.js +52 -0
  72. package/deprecations/input-props/input-props.js +1 -0
  73. package/deprecations/input-props/test-cases/package.actual.js +60 -0
  74. package/deprecations/input-props/test-cases/package.expected.js +52 -0
  75. package/deprecations/linear-progress-classes/linear-progress-classes.js +1 -1
  76. package/deprecations/linear-progress-classes/test-cases/package.actual.js +21 -0
  77. package/deprecations/linear-progress-classes/test-cases/package.expected.js +21 -0
  78. package/deprecations/list-item-props/list-item-props.js +3 -0
  79. package/deprecations/list-item-props/test-cases/package.actual.js +49 -0
  80. package/deprecations/list-item-props/test-cases/package.expected.js +50 -0
  81. package/deprecations/list-item-text-props/list-item-text-props.js +3 -0
  82. package/deprecations/list-item-text-props/test-cases/package.actual.js +21 -0
  83. package/deprecations/list-item-text-props/test-cases/package.expected.js +27 -0
  84. package/deprecations/menu-props/menu-props.js +3 -0
  85. package/deprecations/menu-props/test-cases/package.actual.js +67 -0
  86. package/deprecations/menu-props/test-cases/package.expected.js +83 -0
  87. package/deprecations/mobile-stepper-props/mobile-stepper-props.js +1 -0
  88. package/deprecations/mobile-stepper-props/test-cases/package.actual.js +30 -0
  89. package/deprecations/mobile-stepper-props/test-cases/package.expected.js +34 -0
  90. package/deprecations/modal-props/modal-props.js +3 -0
  91. package/deprecations/modal-props/test-cases/package.actual.js +49 -0
  92. package/deprecations/modal-props/test-cases/package.expected.js +50 -0
  93. package/deprecations/outlined-input-props/outlined-input-props.js +1 -0
  94. package/deprecations/outlined-input-props/test-cases/package.actual.js +60 -0
  95. package/deprecations/outlined-input-props/test-cases/package.expected.js +52 -0
  96. package/deprecations/pagination-item-classes/pagination-item-classes.js +1 -1
  97. package/deprecations/pagination-item-classes/test-cases/package.actual.js +108 -0
  98. package/deprecations/pagination-item-classes/test-cases/package.expected.js +108 -0
  99. package/deprecations/pagination-item-props/pagination-item-props.js +1 -0
  100. package/deprecations/pagination-item-props/test-cases/package.actual.js +27 -0
  101. package/deprecations/pagination-item-props/test-cases/package.expected.js +21 -0
  102. package/deprecations/popover-props/popover-props.js +5 -0
  103. package/deprecations/popover-props/test-cases/package.actual.js +73 -0
  104. package/deprecations/popover-props/test-cases/package.expected.js +89 -0
  105. package/deprecations/popper-props/popper-props.js +1 -0
  106. package/deprecations/popper-props/test-cases/package.actual.js +27 -0
  107. package/deprecations/popper-props/test-cases/package.expected.js +24 -0
  108. package/deprecations/rating-props/rating-props.js +1 -0
  109. package/deprecations/rating-props/test-cases/package.actual.js +37 -0
  110. package/deprecations/rating-props/test-cases/package.expected.js +53 -0
  111. package/deprecations/select-classes/select-classes.js +1 -1
  112. package/deprecations/select-classes/test-cases/package.actual.js +9 -0
  113. package/deprecations/select-classes/test-cases/package.expected.js +9 -0
  114. package/deprecations/slider-classes/slider-classes.js +1 -1
  115. package/deprecations/slider-classes/test-cases/package.actual.js +19 -0
  116. package/deprecations/slider-classes/test-cases/package.expected.js +19 -0
  117. package/deprecations/slider-props/slider-props.js +1 -0
  118. package/deprecations/slider-props/test-cases/package.actual.js +60 -0
  119. package/deprecations/slider-props/test-cases/package.expected.js +52 -0
  120. package/deprecations/snackbar-props/snackbar-props.js +4 -0
  121. package/deprecations/snackbar-props/test-cases/package.actual.js +54 -0
  122. package/deprecations/snackbar-props/test-cases/package.expected.js +67 -0
  123. package/deprecations/speed-dial-action-props/speed-dial-action-props.js +5 -0
  124. package/deprecations/speed-dial-action-props/test-cases/package.actual.js +56 -0
  125. package/deprecations/speed-dial-action-props/test-cases/package.expected.js +104 -0
  126. package/deprecations/speed-dial-props/speed-dial-props.js +2 -0
  127. package/deprecations/speed-dial-props/test-cases/package.actual.js +41 -0
  128. package/deprecations/speed-dial-props/test-cases/package.expected.js +54 -0
  129. package/deprecations/step-connector-classes/step-connector-classes.js +1 -1
  130. package/deprecations/step-connector-classes/test-cases/package.actual.js +7 -0
  131. package/deprecations/step-connector-classes/test-cases/package.expected.js +7 -0
  132. package/deprecations/step-content-props/step-content-props.js +2 -0
  133. package/deprecations/step-content-props/test-cases/package.actual.js +65 -0
  134. package/deprecations/step-content-props/test-cases/package.expected.js +74 -0
  135. package/deprecations/step-label-props/step-label-props.js +3 -0
  136. package/deprecations/step-label-props/test-cases/package.actual.js +44 -0
  137. package/deprecations/step-label-props/test-cases/package.expected.js +48 -0
  138. package/deprecations/tab-classes/tab-classes.js +1 -1
  139. package/deprecations/tab-classes/test-cases/package.actual.js +5 -0
  140. package/deprecations/tab-classes/test-cases/package.expected.js +5 -0
  141. package/deprecations/table-pagination-props/table-pagination-props.js +2 -0
  142. package/deprecations/table-pagination-props/test-cases/package.actual.js +62 -0
  143. package/deprecations/table-pagination-props/test-cases/package.expected.js +72 -0
  144. package/deprecations/table-sort-label-classes/table-sort-label-classes.js +1 -1
  145. package/deprecations/table-sort-label-classes/test-cases/package.actual.js +7 -0
  146. package/deprecations/table-sort-label-classes/test-cases/package.expected.js +7 -0
  147. package/deprecations/tabs-classes/tabs-classes.js +1 -1
  148. package/deprecations/tabs-classes/test-cases/package.actual.js +7 -0
  149. package/deprecations/tabs-classes/test-cases/package.expected.js +7 -0
  150. package/deprecations/tabs-props/tabs-props.js +3 -0
  151. package/deprecations/tabs-props/test-cases/package.actual.js +33 -0
  152. package/deprecations/tabs-props/test-cases/package.expected.js +41 -0
  153. package/deprecations/text-field-props/test-cases/package.actual.js +27 -0
  154. package/deprecations/text-field-props/test-cases/package.expected.js +31 -0
  155. package/deprecations/text-field-props/text-field-props.js +5 -0
  156. package/deprecations/toggle-button-group-classes/test-cases/package.actual.js +7 -0
  157. package/deprecations/toggle-button-group-classes/test-cases/package.expected.js +7 -0
  158. package/deprecations/toggle-button-group-classes/toggle-button-group-classes.js +1 -1
  159. package/deprecations/tooltip-props/test-cases/package.actual.js +141 -0
  160. package/deprecations/tooltip-props/test-cases/package.expected.js +141 -0
  161. package/deprecations/tooltip-props/tooltip-props.js +5 -0
  162. package/deprecations/typography-props/test-cases/package.actual.js +88 -0
  163. package/deprecations/typography-props/test-cases/package.expected.js +98 -0
  164. package/deprecations/typography-props/typography-props.js +1 -0
  165. package/deprecations/utils/movePropIntoSlotProps.js +2 -10
  166. package/deprecations/utils/movePropIntoSlots.js +2 -10
  167. package/deprecations/utils/replaceComponentsWithSlots.js +3 -13
  168. package/package.json +1 -1
  169. package/util/findComponentJSX.js +4 -3
  170. package/v6.0.0/grid-v2-props/grid-v2-props.js +5 -0
  171. package/v6.0.0/grid-v2-props/test-cases/package.actual.js +91 -0
  172. package/v6.0.0/grid-v2-props/test-cases/package.expected.js +91 -0
  173. package/v6.0.0/list-item-button-prop/list-item-button-prop.js +8 -4
  174. package/v6.0.0/list-item-button-prop/test-cases/package.actual.js +31 -0
  175. package/v6.0.0/list-item-button-prop/test-cases/package.expected.js +20 -0
  176. package/v7.0.0/grid-props/grid-props.js +5 -0
  177. package/v7.0.0/grid-props/test-cases/package.actual.js +91 -0
  178. package/v7.0.0/grid-props/test-cases/package.expected.js +91 -0
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _Typography = _interopRequireDefault(require("@org/ui/material/Typography"));
5
+ var _material = require("@org/ui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {});
8
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {});
9
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
10
+ className: "my-class"
11
+ });
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
13
+ className: "my-class"
14
+ });
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
16
+ paragraph: true
17
+ });
18
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
19
+ paragraph: true
20
+ });
21
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
22
+ paragraph: true,
23
+ className: "my-class"
24
+ });
25
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
26
+ paragraph: true,
27
+ className: "my-class"
28
+ });
29
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
30
+ paragraph: false,
31
+ className: "my-class"
32
+ });
33
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
34
+ paragraph: false,
35
+ className: "my-class"
36
+ });
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
38
+ paragraph: true,
39
+ className: "my-class"
40
+ });
41
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
42
+ paragraph: true,
43
+ className: "my-class"
44
+ });
45
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
46
+ paragraph: paragraph,
47
+ className: "my-class"
48
+ });
49
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
50
+ paragraph: paragraph,
51
+ className: "my-class"
52
+ });
53
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
54
+ paragraph: true,
55
+ sx: {
56
+ marginBottom: "32px"
57
+ }
58
+ });
59
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
60
+ paragraph: true,
61
+ sx: {
62
+ marginBottom: "32px"
63
+ }
64
+ });
65
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
66
+ paragraph: true,
67
+ sx: {
68
+ mb: "32px"
69
+ }
70
+ });
71
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
72
+ paragraph: true,
73
+ sx: {
74
+ mb: "32px"
75
+ }
76
+ });
77
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
78
+ paragraph: true,
79
+ sx: {
80
+ color: "black"
81
+ }
82
+ });
83
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
84
+ paragraph: true,
85
+ sx: {
86
+ color: "black"
87
+ }
88
+ });
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _Typography = _interopRequireDefault(require("@org/ui/material/Typography"));
5
+ var _material = require("@org/ui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {});
8
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {});
9
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
10
+ className: "my-class"
11
+ });
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
13
+ className: "my-class"
14
+ });
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
16
+ sx: {
17
+ marginBottom: "16px"
18
+ }
19
+ });
20
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
21
+ sx: {
22
+ marginBottom: "16px"
23
+ }
24
+ });
25
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
26
+ className: "my-class",
27
+ sx: {
28
+ marginBottom: "16px"
29
+ }
30
+ });
31
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
32
+ className: "my-class",
33
+ sx: {
34
+ marginBottom: "16px"
35
+ }
36
+ });
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
38
+ className: "my-class"
39
+ });
40
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
41
+ className: "my-class"
42
+ });
43
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
44
+ className: "my-class",
45
+ sx: {
46
+ marginBottom: "16px"
47
+ }
48
+ });
49
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
50
+ className: "my-class",
51
+ sx: {
52
+ marginBottom: "16px"
53
+ }
54
+ });
55
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
56
+ className: "my-class",
57
+ sx: paragraph ? {
58
+ marginBottom: "16px"
59
+ } : undefined
60
+ });
61
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
62
+ className: "my-class",
63
+ sx: paragraph ? {
64
+ marginBottom: "16px"
65
+ } : undefined
66
+ });
67
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
68
+ sx: {
69
+ marginBottom: "32px"
70
+ }
71
+ });
72
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
73
+ sx: {
74
+ marginBottom: "32px"
75
+ }
76
+ });
77
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
78
+ sx: {
79
+ mb: "32px"
80
+ }
81
+ });
82
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
83
+ sx: {
84
+ mb: "32px"
85
+ }
86
+ });
87
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
88
+ sx: {
89
+ color: "black",
90
+ marginBottom: "16px"
91
+ }
92
+ });
93
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
94
+ sx: {
95
+ color: "black",
96
+ marginBottom: "16px"
97
+ }
98
+ });
@@ -18,6 +18,7 @@ function transformer(file, api, options) {
18
18
  const printOptions = options.printOptions;
19
19
  (0, _findComponentJSX.default)(j, {
20
20
  root,
21
+ packageName: options.packageName,
21
22
  componentName: 'Typography'
22
23
  }, elementPath => {
23
24
  const paragraphProp = elementPath.node.openingElement.attributes.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'paragraph');
@@ -108,21 +108,13 @@ function moveDefaultPropsPropIntoslotProps(j, defaultPropsPathCollection, propNa
108
108
  */
109
109
  function movePropIntoSlotProps(j, options) {
110
110
  const {
111
- root,
112
- componentName,
113
111
  propName,
114
112
  slotName,
115
113
  slotPropName
116
114
  } = options;
117
- (0, _findComponentJSX.default)(j, {
118
- root,
119
- componentName
120
- }, elementPath => {
115
+ (0, _findComponentJSX.default)(j, options, elementPath => {
121
116
  moveJsxPropIntoSlotProps(j, elementPath.node, propName, slotName, slotPropName);
122
117
  });
123
- const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, {
124
- root,
125
- componentName
126
- });
118
+ const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, options);
127
119
  moveDefaultPropsPropIntoslotProps(j, defaultPropsPathCollection, propName, slotName, slotPropName);
128
120
  }
@@ -75,20 +75,12 @@ function moveDefaultPropsPropIntoSlots(j, defaultPropsPathCollection, propName,
75
75
  */
76
76
  function movePropIntoSlots(j, options) {
77
77
  const {
78
- root,
79
- componentName,
80
78
  propName,
81
79
  slotName
82
80
  } = options;
83
- (0, _findComponentJSX.default)(j, {
84
- root,
85
- componentName
86
- }, elementPath => {
81
+ (0, _findComponentJSX.default)(j, options, elementPath => {
87
82
  moveJsxPropIntoSlots(j, elementPath.node, propName, slotName);
88
83
  });
89
- const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, {
90
- root,
91
- componentName
92
- });
84
+ const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, options);
93
85
  moveDefaultPropsPropIntoSlots(j, defaultPropsPathCollection, propName, slotName);
94
86
  }
@@ -176,26 +176,16 @@ function replaceDefaultPropsComponentsPropsProp(j, defaultPropsPathCollection) {
176
176
  * If there are duplicated values, the slots values will be used.
177
177
  *
178
178
  * @param {import('jscodeshift')} j
179
- * @param {{ element: import('jscodeshift').JSXElement }} options
179
+ * @param {{ element: import('jscodeshift').JSXElement, packageName?: string }} options
180
180
  *
181
181
  * @example <Component componentsProps={{ root: { 'testid': 'root-id'} }} /> => <Component slotProps={{ root: { 'testid': 'root-id'} }} />
182
182
  */
183
183
  function replaceComponentsWithSlots(j, options) {
184
- const {
185
- root,
186
- componentName
187
- } = options;
188
- (0, _findComponentJSX.default)(j, {
189
- root,
190
- componentName
191
- }, elementPath => {
184
+ (0, _findComponentJSX.default)(j, options, elementPath => {
192
185
  replaceJsxComponentsProp(j, elementPath);
193
186
  replaceJsxComponentsPropsProp(j, elementPath.node);
194
187
  });
195
- const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, {
196
- root,
197
- componentName
198
- });
188
+ const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, options);
199
189
  replaceDefaultPropsComponentsProp(j, defaultPropsPathCollection);
200
190
  replaceDefaultPropsComponentsPropsProp(j, defaultPropsPathCollection);
201
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "author": "MUI Team",
5
5
  "description": "Codemod scripts for Material UI.",
6
6
  "bin": "./codemod.js",
@@ -8,14 +8,15 @@ exports.default = findComponentJSX;
8
8
  * Find all the JSXElements of a given component name.
9
9
  *
10
10
  * @param {import('jscodeshift')} j
11
- * @param {{ root: import('jscodeshift').Collection; componentName: string }} options
11
+ * @param {{ root: import('jscodeshift').Collection; componentName: string; packageName?: string }} options
12
12
  * @param {(path: import('jscodeshift').ASTPath<import('jscodeshift').JSXElement>) => void} callback
13
13
  *
14
14
  */
15
15
  function findComponentJSX(j, options, callback) {
16
16
  const {
17
17
  root,
18
- componentName
18
+ componentName,
19
+ packageName = '@mui/material'
19
20
  } = options;
20
21
 
21
22
  // case 1: import ComponentName from '@mui/material/ComponentName';
@@ -23,7 +24,7 @@ function findComponentJSX(j, options, callback) {
23
24
  // case 3: import { ComponentName as SomethingElse } from '@mui/material';
24
25
 
25
26
  const importName = new Set();
26
- root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(new RegExp(`^@mui/material(/${componentName})?$`))).forEach(path => {
27
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(new RegExp(`^${packageName}(/${componentName})?$`))).forEach(path => {
27
28
  path.node.specifiers.forEach(specifier => {
28
29
  if (specifier.type === 'ImportDefaultSpecifier') {
29
30
  importName.add(specifier.local.name);
@@ -24,6 +24,11 @@ function gridV2Props(file, api, options) {
24
24
  const root = j(file.source);
25
25
  const breakpoints = options.muiBreakpoints?.split(',') || defaultBreakpoints;
26
26
  const printOptions = options.printOptions;
27
+ const packageName = options.packageName;
28
+ if (packageName) {
29
+ possibleDefaultImports.push(`${packageName}/Grid2`);
30
+ possibleNamedImports[packageName] = 'Grid2';
31
+ }
27
32
  const gridLocalNames = [];
28
33
  root.find(j.ImportDeclaration, decl => possibleDefaultImports.includes(decl.source.value)).forEach(decl => {
29
34
  decl.node.specifiers.forEach(spec => {
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _Grid = _interopRequireDefault(require("@org/ui/material/Grid2"));
5
+ var _Grid2 = _interopRequireDefault(require("@org/ui/material/Grid"));
6
+ var _material = require("@org/ui/material");
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ // Transforms on all the possible imports
9
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
10
+ xs: 2
11
+ });
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid2, {
13
+ xs: 2
14
+ });
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
16
+ item: true
17
+ });
18
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
19
+ item: true
20
+ });
21
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
22
+ item: false
23
+ });
24
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
25
+ zeroMinWidth: true
26
+ });
27
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
28
+ zeroMinWidth: true
29
+ });
30
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
31
+ zeroMinWidth: false
32
+ });
33
+
34
+ // Transforms responsive sizes
35
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
36
+ xs: 2,
37
+ sm: 4,
38
+ md: 6,
39
+ lg: 8,
40
+ xl: 10
41
+ });
42
+
43
+ // Transforms all the possible size values
44
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
45
+ xs: true,
46
+ sm: "auto",
47
+ md: 2,
48
+ lg: true,
49
+ xl: false
50
+ });
51
+
52
+ // Doesn't add jsx object expression for single string values
53
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
54
+ xs: "auto"
55
+ });
56
+
57
+ // Transforms offset
58
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
59
+ xsOffset: 2
60
+ });
61
+
62
+ // Transforms responsive offset
63
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
64
+ xsOffset: 2,
65
+ smOffset: 4,
66
+ mdOffset: 6,
67
+ lgOffset: 8,
68
+ xlOffset: 10
69
+ });
70
+
71
+ // Transforms all the possible offset values
72
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
73
+ xsOffset: 2,
74
+ smOffset: "auto"
75
+ });
76
+
77
+ // Transforms spread props
78
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
79
+ xs: 2,
80
+ sm: 4,
81
+ xsOffset: 0,
82
+ smOffset: 2
83
+ });
84
+
85
+ // Doesn't transform Grid v1
86
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid2.default, {
87
+ xs: 2
88
+ });
89
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
90
+ xs: 2
91
+ });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _Grid = _interopRequireDefault(require("@org/ui/material/Grid2"));
5
+ var _Grid2 = _interopRequireDefault(require("@org/ui/material/Grid"));
6
+ var _material = require("@org/ui/material");
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ // Transforms on all the possible imports
9
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
10
+ size: 2
11
+ });
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid2, {
13
+ size: 2
14
+ });
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
16
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
17
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
18
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
19
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
20
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {});
21
+
22
+ // Transforms responsive sizes
23
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
24
+ size: {
25
+ xs: 2,
26
+ sm: 4,
27
+ md: 6,
28
+ lg: 8,
29
+ xl: 10
30
+ }
31
+ });
32
+
33
+ // Transforms all the possible size values
34
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
35
+ size: {
36
+ xs: "grow",
37
+ sm: "auto",
38
+ md: 2,
39
+ lg: "grow",
40
+ xl: false
41
+ }
42
+ });
43
+
44
+ // Doesn't add jsx object expression for single string values
45
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
46
+ size: "auto"
47
+ });
48
+
49
+ // Transforms offset
50
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
51
+ offset: 2
52
+ });
53
+
54
+ // Transforms responsive offset
55
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
56
+ offset: {
57
+ xs: 2,
58
+ sm: 4,
59
+ md: 6,
60
+ lg: 8,
61
+ xl: 10
62
+ }
63
+ });
64
+
65
+ // Transforms all the possible offset values
66
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
67
+ offset: {
68
+ xs: 2,
69
+ sm: "auto"
70
+ }
71
+ });
72
+
73
+ // Transforms spread props
74
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid.default, {
75
+ size: {
76
+ xs: 2,
77
+ sm: 4
78
+ },
79
+ offset: {
80
+ xs: 0,
81
+ sm: 2
82
+ }
83
+ });
84
+
85
+ // Doesn't transform Grid v1
86
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Grid2.default, {
87
+ xs: 2
88
+ });
89
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
90
+ xs: 2
91
+ });
@@ -15,6 +15,9 @@ function transformer(file, api, options) {
15
15
  const j = api.jscodeshift;
16
16
  const root = j(file.source);
17
17
  const printOptions = options.printOptions;
18
+ const {
19
+ packageName = '@mui/material'
20
+ } = options;
18
21
  const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, {
19
22
  root,
20
23
  componentName: 'ListItem'
@@ -45,6 +48,7 @@ function transformer(file, api, options) {
45
48
  // Rename components that have ListItem button to ListItemButton
46
49
  (0, _findComponentJSX.default)(j, {
47
50
  root,
51
+ packageName,
48
52
  componentName: 'ListItem'
49
53
  }, elementPath => {
50
54
  const index = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'button');
@@ -59,7 +63,7 @@ function transformer(file, api, options) {
59
63
  }
60
64
  });
61
65
  const importsToRemove = [...openTaggedHavingButtonProp].filter(item => !openTaggedNotHavingButtonProp.has(item));
62
- root.find(j.ImportDeclaration).filter(path => path.node.source.value === '@mui/material/ListItem').filter(path => {
66
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(new RegExp(`^${packageName}(/ListItem)?$`))).filter(path => {
63
67
  path.node.specifiers.forEach(specifier => {
64
68
  if (specifier.type === 'ImportDefaultSpecifier') {
65
69
  if (importsToRemove.includes(specifier.local.name)) {
@@ -72,7 +76,7 @@ function transformer(file, api, options) {
72
76
  }
73
77
  return false;
74
78
  }).remove();
75
- root.find(j.ImportDeclaration).filter(path => path.node.source.value === '@mui/material').filter(path => {
79
+ root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(new RegExp(`^${packageName}$`))).filter(path => {
76
80
  path.node.specifiers.forEach(specifier => {
77
81
  if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'ListItem' && importsToRemove.includes(specifier.local.name)) {
78
82
  path.node.specifiers = path.node.specifiers.filter(spec => spec !== specifier);
@@ -85,12 +89,12 @@ function transformer(file, api, options) {
85
89
  }).remove();
86
90
 
87
91
  // If ListItemButton import does not already exist, add it at the end
88
- const imports = root.find(j.ImportDeclaration).filter(path => path.node.source.value === '@mui/material/ListItemButton');
92
+ const imports = root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(new RegExp(`^${packageName}/ListItemButton$`)));
89
93
  if (addedListItemButton && imports.length === 0) {
90
94
  const lastImport = root.find(j.ImportDeclaration).at(-1);
91
95
 
92
96
  // Insert the import for 'ListItemButton' after the last import declaration
93
- lastImport.insertAfter(j.importDeclaration([j.importDefaultSpecifier(j.identifier('ListItemButton'))], j.stringLiteral('@mui/material/ListItemButton')));
97
+ lastImport.insertAfter(j.importDeclaration([j.importDefaultSpecifier(j.identifier('ListItemButton'))], j.stringLiteral(`${packageName}/ListItemButton`)));
94
98
  }
95
99
  return root.toSource(printOptions);
96
100
  }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _ListItem = _interopRequireDefault(require("@org/ui/material/ListItem"));
5
+ var _material = require("@org/ui/material");
6
+ var _ui = _interopRequireDefault(require("ui"));
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem.default, {
9
+ button: true
10
+ });
11
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem.default, {});
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {});
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
14
+ button: true
15
+ });
16
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem.default, {
17
+ button: true
18
+ });
19
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
20
+ button: true
21
+ });
22
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
23
+ button: true
24
+ });
25
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {});
26
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
27
+ button: true
28
+ });
29
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.default, {
30
+ button: true
31
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _ListItem = _interopRequireDefault(require("@org/ui/material/ListItem"));
5
+ var _material = require("@org/ui/material");
6
+ var _ui = _interopRequireDefault(require("ui"));
7
+ var _ListItemButton = _interopRequireDefault(require("@org/ui/material/ListItemButton"));
8
+ var _jsxRuntime = require("react/jsx-runtime");
9
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
10
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItem.default, {});
11
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {});
12
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
14
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
16
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {});
17
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemButton.default, {});
18
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.default, {
19
+ button: true
20
+ });
@@ -24,6 +24,11 @@ function gridV2Props(file, api, options) {
24
24
  const root = j(file.source);
25
25
  const breakpoints = options.muiBreakpoints?.split(',') || defaultBreakpoints;
26
26
  const printOptions = options.printOptions;
27
+ const packageName = options.packageName;
28
+ if (packageName) {
29
+ possibleDefaultImports.push(`${packageName}/Grid`);
30
+ possibleNamedImports[packageName] = 'Grid';
31
+ }
27
32
  const gridLocalNames = [];
28
33
  root.find(j.ImportDeclaration, decl => possibleDefaultImports.includes(decl.source.value)).forEach(decl => {
29
34
  decl.node.specifiers.forEach(spec => {