@mui/codemod 7.1.0 → 7.2.0

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 (187) hide show
  1. package/README.md +32 -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/all/deprecations-all.js +2 -0
  16. package/deprecations/autocomplete-props/autocomplete-props.js +7 -0
  17. package/deprecations/autocomplete-props/test-cases/package.actual.js +113 -0
  18. package/deprecations/autocomplete-props/test-cases/package.expected.js +125 -0
  19. package/deprecations/avatar-group-props/avatar-group-props.js +4 -2
  20. package/deprecations/avatar-group-props/test-cases/package.actual.js +56 -0
  21. package/deprecations/avatar-group-props/test-cases/package.expected.js +58 -0
  22. package/deprecations/avatar-props/avatar-props.js +2 -1
  23. package/deprecations/avatar-props/test-cases/package.actual.js +36 -0
  24. package/deprecations/avatar-props/test-cases/package.expected.js +42 -0
  25. package/deprecations/backdrop-props/backdrop-props.js +2 -0
  26. package/deprecations/backdrop-props/test-cases/package.actual.js +81 -0
  27. package/deprecations/backdrop-props/test-cases/package.expected.js +81 -0
  28. package/deprecations/badge-props/badge-props.js +2 -1
  29. package/deprecations/badge-props/test-cases/package.actual.js +59 -0
  30. package/deprecations/badge-props/test-cases/package.expected.js +51 -0
  31. package/deprecations/button-classes/button-classes.js +1 -1
  32. package/deprecations/button-classes/test-cases/package.actual.js +69 -0
  33. package/deprecations/button-classes/test-cases/package.expected.js +69 -0
  34. package/deprecations/button-group-classes/button-group-classes.js +1 -1
  35. package/deprecations/button-group-classes/test-cases/package.actual.js +37 -0
  36. package/deprecations/button-group-classes/test-cases/package.expected.js +37 -0
  37. package/deprecations/card-header-props/card-header-props.js +2 -0
  38. package/deprecations/card-header-props/test-cases/package.actual.js +66 -0
  39. package/deprecations/card-header-props/test-cases/package.expected.js +78 -0
  40. package/deprecations/chip-classes/chip-classes.js +1 -1
  41. package/deprecations/chip-classes/test-cases/package.actual.js +55 -0
  42. package/deprecations/chip-classes/test-cases/package.expected.js +55 -0
  43. package/deprecations/circular-progress-classes/circular-progress-classes.js +1 -1
  44. package/deprecations/circular-progress-classes/test-cases/package.actual.js +7 -0
  45. package/deprecations/circular-progress-classes/test-cases/package.expected.js +7 -0
  46. package/deprecations/dialog-classes/dialog-classes.js +1 -1
  47. package/deprecations/dialog-classes/test-cases/package.actual.js +7 -0
  48. package/deprecations/dialog-classes/test-cases/package.expected.js +7 -0
  49. package/deprecations/dialog-props/dialog-props.js +40 -0
  50. package/deprecations/dialog-props/index.js +13 -0
  51. package/deprecations/dialog-props/test-cases/actual.js +47 -0
  52. package/deprecations/dialog-props/test-cases/expected.js +60 -0
  53. package/deprecations/dialog-props/test-cases/package.actual.js +47 -0
  54. package/deprecations/dialog-props/test-cases/package.expected.js +60 -0
  55. package/deprecations/dialog-props/test-cases/theme.actual.js +36 -0
  56. package/deprecations/dialog-props/test-cases/theme.expected.js +43 -0
  57. package/deprecations/divider-props/divider-props.js +3 -1
  58. package/deprecations/divider-props/test-cases/package.actual.js +45 -0
  59. package/deprecations/divider-props/test-cases/package.expected.js +50 -0
  60. package/deprecations/drawer-classes/drawer-classes.js +1 -1
  61. package/deprecations/drawer-classes/test-cases/package.actual.js +19 -0
  62. package/deprecations/drawer-classes/test-cases/package.expected.js +19 -0
  63. package/deprecations/drawer-props/drawer-props.js +8 -0
  64. package/deprecations/drawer-props/test-cases/package.actual.js +73 -0
  65. package/deprecations/drawer-props/test-cases/package.expected.js +97 -0
  66. package/deprecations/filled-input-props/filled-input-props.js +1 -0
  67. package/deprecations/filled-input-props/test-cases/package.actual.js +60 -0
  68. package/deprecations/filled-input-props/test-cases/package.expected.js +52 -0
  69. package/deprecations/form-control-label-props/form-control-label-props.js +1 -0
  70. package/deprecations/form-control-label-props/test-cases/package.actual.js +21 -0
  71. package/deprecations/form-control-label-props/test-cases/package.expected.js +21 -0
  72. package/deprecations/image-list-item-bar-classes/image-list-item-bar-classes.js +1 -1
  73. package/deprecations/image-list-item-bar-classes/test-cases/package.actual.js +11 -0
  74. package/deprecations/image-list-item-bar-classes/test-cases/package.expected.js +11 -0
  75. package/deprecations/input-base-classes/input-base-classes.js +1 -1
  76. package/deprecations/input-base-classes/test-cases/package.actual.js +13 -0
  77. package/deprecations/input-base-classes/test-cases/package.expected.js +13 -0
  78. package/deprecations/input-base-props/input-base-props.js +1 -0
  79. package/deprecations/input-base-props/test-cases/package.actual.js +60 -0
  80. package/deprecations/input-base-props/test-cases/package.expected.js +52 -0
  81. package/deprecations/input-props/input-props.js +1 -0
  82. package/deprecations/input-props/test-cases/package.actual.js +60 -0
  83. package/deprecations/input-props/test-cases/package.expected.js +52 -0
  84. package/deprecations/linear-progress-classes/linear-progress-classes.js +1 -1
  85. package/deprecations/linear-progress-classes/test-cases/package.actual.js +21 -0
  86. package/deprecations/linear-progress-classes/test-cases/package.expected.js +21 -0
  87. package/deprecations/list-item-props/list-item-props.js +3 -0
  88. package/deprecations/list-item-props/test-cases/package.actual.js +49 -0
  89. package/deprecations/list-item-props/test-cases/package.expected.js +50 -0
  90. package/deprecations/list-item-text-props/list-item-text-props.js +3 -0
  91. package/deprecations/list-item-text-props/test-cases/package.actual.js +21 -0
  92. package/deprecations/list-item-text-props/test-cases/package.expected.js +27 -0
  93. package/deprecations/menu-props/menu-props.js +3 -0
  94. package/deprecations/menu-props/test-cases/package.actual.js +67 -0
  95. package/deprecations/menu-props/test-cases/package.expected.js +83 -0
  96. package/deprecations/mobile-stepper-props/mobile-stepper-props.js +1 -0
  97. package/deprecations/mobile-stepper-props/test-cases/package.actual.js +30 -0
  98. package/deprecations/mobile-stepper-props/test-cases/package.expected.js +34 -0
  99. package/deprecations/modal-props/modal-props.js +3 -0
  100. package/deprecations/modal-props/test-cases/package.actual.js +49 -0
  101. package/deprecations/modal-props/test-cases/package.expected.js +50 -0
  102. package/deprecations/outlined-input-props/outlined-input-props.js +1 -0
  103. package/deprecations/outlined-input-props/test-cases/package.actual.js +60 -0
  104. package/deprecations/outlined-input-props/test-cases/package.expected.js +52 -0
  105. package/deprecations/pagination-item-classes/pagination-item-classes.js +1 -1
  106. package/deprecations/pagination-item-classes/test-cases/package.actual.js +108 -0
  107. package/deprecations/pagination-item-classes/test-cases/package.expected.js +108 -0
  108. package/deprecations/pagination-item-props/pagination-item-props.js +1 -0
  109. package/deprecations/pagination-item-props/test-cases/package.actual.js +27 -0
  110. package/deprecations/pagination-item-props/test-cases/package.expected.js +21 -0
  111. package/deprecations/popover-props/popover-props.js +5 -0
  112. package/deprecations/popover-props/test-cases/package.actual.js +73 -0
  113. package/deprecations/popover-props/test-cases/package.expected.js +89 -0
  114. package/deprecations/popper-props/popper-props.js +1 -0
  115. package/deprecations/popper-props/test-cases/package.actual.js +27 -0
  116. package/deprecations/popper-props/test-cases/package.expected.js +24 -0
  117. package/deprecations/rating-props/rating-props.js +1 -0
  118. package/deprecations/rating-props/test-cases/package.actual.js +37 -0
  119. package/deprecations/rating-props/test-cases/package.expected.js +53 -0
  120. package/deprecations/select-classes/select-classes.js +1 -1
  121. package/deprecations/select-classes/test-cases/package.actual.js +9 -0
  122. package/deprecations/select-classes/test-cases/package.expected.js +9 -0
  123. package/deprecations/slider-classes/slider-classes.js +1 -1
  124. package/deprecations/slider-classes/test-cases/package.actual.js +19 -0
  125. package/deprecations/slider-classes/test-cases/package.expected.js +19 -0
  126. package/deprecations/slider-props/slider-props.js +1 -0
  127. package/deprecations/slider-props/test-cases/package.actual.js +60 -0
  128. package/deprecations/slider-props/test-cases/package.expected.js +52 -0
  129. package/deprecations/snackbar-props/snackbar-props.js +4 -0
  130. package/deprecations/snackbar-props/test-cases/package.actual.js +54 -0
  131. package/deprecations/snackbar-props/test-cases/package.expected.js +67 -0
  132. package/deprecations/speed-dial-action-props/speed-dial-action-props.js +5 -0
  133. package/deprecations/speed-dial-action-props/test-cases/package.actual.js +56 -0
  134. package/deprecations/speed-dial-action-props/test-cases/package.expected.js +104 -0
  135. package/deprecations/speed-dial-props/speed-dial-props.js +2 -0
  136. package/deprecations/speed-dial-props/test-cases/package.actual.js +41 -0
  137. package/deprecations/speed-dial-props/test-cases/package.expected.js +54 -0
  138. package/deprecations/step-connector-classes/step-connector-classes.js +1 -1
  139. package/deprecations/step-connector-classes/test-cases/package.actual.js +7 -0
  140. package/deprecations/step-connector-classes/test-cases/package.expected.js +7 -0
  141. package/deprecations/step-content-props/step-content-props.js +2 -0
  142. package/deprecations/step-content-props/test-cases/package.actual.js +65 -0
  143. package/deprecations/step-content-props/test-cases/package.expected.js +74 -0
  144. package/deprecations/step-label-props/step-label-props.js +3 -0
  145. package/deprecations/step-label-props/test-cases/package.actual.js +44 -0
  146. package/deprecations/step-label-props/test-cases/package.expected.js +48 -0
  147. package/deprecations/tab-classes/tab-classes.js +1 -1
  148. package/deprecations/tab-classes/test-cases/package.actual.js +5 -0
  149. package/deprecations/tab-classes/test-cases/package.expected.js +5 -0
  150. package/deprecations/table-pagination-props/table-pagination-props.js +2 -0
  151. package/deprecations/table-pagination-props/test-cases/package.actual.js +62 -0
  152. package/deprecations/table-pagination-props/test-cases/package.expected.js +72 -0
  153. package/deprecations/table-sort-label-classes/table-sort-label-classes.js +1 -1
  154. package/deprecations/table-sort-label-classes/test-cases/package.actual.js +7 -0
  155. package/deprecations/table-sort-label-classes/test-cases/package.expected.js +7 -0
  156. package/deprecations/tabs-classes/tabs-classes.js +1 -1
  157. package/deprecations/tabs-classes/test-cases/package.actual.js +7 -0
  158. package/deprecations/tabs-classes/test-cases/package.expected.js +7 -0
  159. package/deprecations/tabs-props/tabs-props.js +3 -0
  160. package/deprecations/tabs-props/test-cases/package.actual.js +33 -0
  161. package/deprecations/tabs-props/test-cases/package.expected.js +41 -0
  162. package/deprecations/text-field-props/test-cases/package.actual.js +27 -0
  163. package/deprecations/text-field-props/test-cases/package.expected.js +31 -0
  164. package/deprecations/text-field-props/text-field-props.js +5 -0
  165. package/deprecations/toggle-button-group-classes/test-cases/package.actual.js +7 -0
  166. package/deprecations/toggle-button-group-classes/test-cases/package.expected.js +7 -0
  167. package/deprecations/toggle-button-group-classes/toggle-button-group-classes.js +1 -1
  168. package/deprecations/tooltip-props/test-cases/package.actual.js +141 -0
  169. package/deprecations/tooltip-props/test-cases/package.expected.js +141 -0
  170. package/deprecations/tooltip-props/tooltip-props.js +5 -0
  171. package/deprecations/typography-props/test-cases/package.actual.js +88 -0
  172. package/deprecations/typography-props/test-cases/package.expected.js +98 -0
  173. package/deprecations/typography-props/typography-props.js +1 -0
  174. package/deprecations/utils/movePropIntoSlotProps.js +2 -10
  175. package/deprecations/utils/movePropIntoSlots.js +2 -10
  176. package/deprecations/utils/replaceComponentsWithSlots.js +3 -13
  177. package/package.json +5 -5
  178. package/util/findComponentJSX.js +4 -3
  179. package/v6.0.0/grid-v2-props/grid-v2-props.js +5 -0
  180. package/v6.0.0/grid-v2-props/test-cases/package.actual.js +91 -0
  181. package/v6.0.0/grid-v2-props/test-cases/package.expected.js +91 -0
  182. package/v6.0.0/list-item-button-prop/list-item-button-prop.js +8 -4
  183. package/v6.0.0/list-item-button-prop/test-cases/package.actual.js +31 -0
  184. package/v6.0.0/list-item-button-prop/test-cases/package.expected.js +20 -0
  185. package/v7.0.0/grid-props/grid-props.js +5 -0
  186. package/v7.0.0/grid-props/test-cases/package.actual.js +91 -0
  187. package/v7.0.0/grid-props/test-cases/package.expected.js +91 -0
@@ -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 => {
@@ -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/Grid"));
5
+ var _GridLegacy = _interopRequireDefault(require("@org/ui/material/GridLegacy"));
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.Grid, {
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)(_GridLegacy.default, {
87
+ xs: 2
88
+ });
89
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.GridLegacy, {
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/Grid"));
5
+ var _GridLegacy = _interopRequireDefault(require("@org/ui/material/GridLegacy"));
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.Grid, {
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)(_GridLegacy.default, {
87
+ xs: 2
88
+ });
89
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.GridLegacy, {
90
+ xs: 2
91
+ });