@mui/codemod 5.15.12 → 5.15.14

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 CHANGED
@@ -1632,14 +1632,14 @@ npx @mui/codemod@latest v5.0.0/jss-to-tss-react <path>
1632
1632
  The following scenarios are not currently handled by this codemod and will be marked with a
1633
1633
  "TODO jss-to-tss-react codemod" comment:
1634
1634
 
1635
- - If the hook returned by `makeStyles` (e.g. `useStyles`) is exported and used in another file,
1635
+ - If the hook returned by `makeStyles` (for example `useStyles`) is exported and used in another file,
1636
1636
  the usages in other files will not be converted.
1637
1637
  - Arrow functions as the value for a CSS prop will not be converted. Arrow functions **are**
1638
1638
  supported at the rule level, though with some caveats listed below.
1639
1639
  - In order for arrow functions at the rule level to be converted, the parameter must use object
1640
- destructuring (e.g. `root: ({color, padding}) => (...)`). If the parameter is not destructured
1641
- (e.g. `root: (props) => (...)`), it will not be converted.
1642
- - If an arrow function at the rule level contains a code block (i.e. contains an explicit `return`
1640
+ destructuring (for example `root: ({color, padding}) => (...)`). If the parameter is not destructured
1641
+ (for example `root: (props) => (...)`), it will not be converted.
1642
+ - If an arrow function at the rule level contains a code block (that is contains an explicit `return`
1643
1643
  statement) rather than just an object expression, it will not be converted.
1644
1644
 
1645
1645
  You can find more details about migrating from JSS to tss-react in [the migration guide](https://mui.com/material-ui/migration/migrating-from-jss/#2-use-tss-react).
@@ -40,4 +40,21 @@ var _jsxRuntime = require("react/jsx-runtime");
40
40
  componentsProps: {
41
41
  closeButton: componentsButtonProps
42
42
  }
43
+ });
44
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
45
+ slots: {
46
+ closeIcon: SlotsIcon,
47
+ closeButton: SlotsButton
48
+ },
49
+ components: {
50
+ CloseButton: ComponentsButton
51
+ },
52
+ slotProps: {
53
+ closeIcon: slotsIconProps,
54
+ closeButton: slotsButtonProps
55
+ },
56
+ componentsProps: {
57
+ closeButton: componentsButtonProps,
58
+ closeIcon: componentsIconProps
59
+ }
43
60
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
4
5
  var _Alert = _interopRequireDefault(require("@mui/material/Alert"));
5
6
  var _jsxRuntime = require("react/jsx-runtime");
6
7
  /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
@@ -28,6 +29,16 @@ var _jsxRuntime = require("react/jsx-runtime");
28
29
  },
29
30
  slotProps: {
30
31
  closeIcon: slotsIconProps,
31
- closeButton: slotsButtonProps
32
+ closeButton: (0, _extends2.default)({}, componentsButtonProps, slotsButtonProps)
33
+ }
34
+ });
35
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Alert.default, {
36
+ slots: {
37
+ closeIcon: SlotsIcon,
38
+ closeButton: SlotsButton
39
+ },
40
+ slotProps: {
41
+ closeButton: (0, _extends2.default)({}, componentsButtonProps, slotsButtonProps),
42
+ closeIcon: (0, _extends2.default)({}, componentsIconProps, slotsIconProps)
32
43
  }
33
44
  });
@@ -49,4 +49,25 @@ fn({
49
49
  }
50
50
  }
51
51
  }
52
+ });
53
+ fn({
54
+ MuiAlert: {
55
+ defaultProps: {
56
+ components: {
57
+ CloseButton: ComponentsButton
58
+ },
59
+ slots: {
60
+ closeIcon: SlotsIcon,
61
+ closeButton: SlotsButton
62
+ },
63
+ componentsProps: {
64
+ closeButton: componentsButtonProps,
65
+ closeIcon: componentsIconProps
66
+ },
67
+ slotProps: {
68
+ closeIcon: slotsIconProps,
69
+ closeButton: slotsButtonProps
70
+ }
71
+ }
72
+ }
52
73
  });
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
3
5
  fn({
4
6
  MuiAlert: {
5
7
  defaultProps: {
@@ -34,9 +36,23 @@ fn({
34
36
  closeIcon: SlotsIcon
35
37
  },
36
38
  slotProps: {
37
- closeButton: slotsButtonProps,
39
+ closeButton: (0, _extends2.default)({}, componentsButtonProps, slotsButtonProps),
38
40
  closeIcon: slotsIconProps
39
41
  }
40
42
  }
41
43
  }
44
+ });
45
+ fn({
46
+ MuiAlert: {
47
+ defaultProps: {
48
+ slots: {
49
+ closeButton: SlotsButton,
50
+ closeIcon: SlotsIcon
51
+ },
52
+ slotProps: {
53
+ closeButton: (0, _extends2.default)({}, componentsButtonProps, slotsButtonProps),
54
+ closeIcon: (0, _extends2.default)({}, componentsIconProps, slotsIconProps)
55
+ }
56
+ }
57
+ }
42
58
  });
@@ -40,4 +40,21 @@ var _jsxRuntime = require("react/jsx-runtime");
40
40
  componentsProps: {
41
41
  track: componentsTrackProps
42
42
  }
43
+ });
44
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider.default, {
45
+ slots: {
46
+ rail: SlotsRail,
47
+ track: SlotsTrack
48
+ },
49
+ components: {
50
+ Track: ComponentsTrack
51
+ },
52
+ slotProps: {
53
+ rail: slotsRailProps,
54
+ track: slotsTrackProps
55
+ },
56
+ componentsProps: {
57
+ track: componentsTrackProps,
58
+ rail: componentsRailProps
59
+ }
43
60
  });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
4
5
  var _Slider = _interopRequireDefault(require("@mui/material/Slider"));
5
6
  var _jsxRuntime = require("react/jsx-runtime");
6
7
  /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider.default, {
@@ -28,6 +29,16 @@ var _jsxRuntime = require("react/jsx-runtime");
28
29
  },
29
30
  slotProps: {
30
31
  rail: slotsRailProps,
31
- track: slotsTrackProps
32
+ track: (0, _extends2.default)({}, componentsTrackProps, slotsTrackProps)
33
+ }
34
+ });
35
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider.default, {
36
+ slots: {
37
+ rail: SlotsRail,
38
+ track: SlotsTrack
39
+ },
40
+ slotProps: {
41
+ track: (0, _extends2.default)({}, componentsTrackProps, slotsTrackProps),
42
+ rail: (0, _extends2.default)({}, componentsRailProps, slotsRailProps)
32
43
  }
33
44
  });
@@ -49,4 +49,25 @@ fn({
49
49
  }
50
50
  }
51
51
  }
52
+ });
53
+ fn({
54
+ MuiSlider: {
55
+ defaultProps: {
56
+ components: {
57
+ Track: ComponentsTrack
58
+ },
59
+ slots: {
60
+ rail: SlotsRail,
61
+ track: SlotsTrack
62
+ },
63
+ componentsProps: {
64
+ track: componentsTrackProps,
65
+ rail: componentsRailProps
66
+ },
67
+ slotProps: {
68
+ rail: slotsRailProps,
69
+ track: slotsTrackProps
70
+ }
71
+ }
72
+ }
52
73
  });
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
3
5
  fn({
4
6
  MuiSlider: {
5
7
  defaultProps: {
@@ -34,9 +36,23 @@ fn({
34
36
  rail: SlotsRail
35
37
  },
36
38
  slotProps: {
37
- track: slotsTrackProps,
39
+ track: (0, _extends2.default)({}, componentsTrackProps, slotsTrackProps),
38
40
  rail: slotsRailProps
39
41
  }
40
42
  }
41
43
  }
44
+ });
45
+ fn({
46
+ MuiSlider: {
47
+ defaultProps: {
48
+ slots: {
49
+ track: SlotsTrack,
50
+ rail: SlotsRail
51
+ },
52
+ slotProps: {
53
+ track: (0, _extends2.default)({}, componentsTrackProps, slotsTrackProps),
54
+ rail: (0, _extends2.default)({}, componentsRailProps, slotsRailProps)
55
+ }
56
+ }
57
+ }
42
58
  });
@@ -76,6 +76,16 @@ function replaceJsxComponentsPropsProp(j, element) {
76
76
  key: prop.key.name,
77
77
  expression: prop.value
78
78
  });
79
+ } else {
80
+ attr.value.expression.properties = attr.value.expression.properties.filter(p => {
81
+ var _p$key;
82
+ return (p == null || (_p$key = p.key) == null ? void 0 : _p$key.name) !== prop.key.name;
83
+ });
84
+ (0, _assignObject.default)(j, {
85
+ target: attr,
86
+ key: prop.key.name,
87
+ expression: j.objectExpression([j.spreadElement(prop.value), j.spreadElement(slotProps[prop.key.name])])
88
+ });
79
89
  }
80
90
  });
81
91
  }
@@ -137,7 +147,7 @@ function replaceDefaultPropsComponentsPropsProp(j, defaultPropsPathCollection) {
137
147
  const existingSlots = defaultPropsProperties.find(prop => prop.key.name === 'slotProps');
138
148
  const slots = existingSlots ? existingSlots.value.properties.reduce((acc, prop) => {
139
149
  return (0, _extends2.default)({}, acc, {
140
- [prop.key.name]: prop.value
150
+ [prop.key.name]: components[prop.key.name] ? j.objectExpression([j.spreadElement(components[prop.key.name]), j.spreadElement(prop.value)]) : prop.value
141
151
  });
142
152
  }, {}) : {};
143
153
  const updatedSlots = j.objectExpression(Object.entries((0, _extends2.default)({}, components, slots)).map(([slot, value]) => {
@@ -102,7 +102,7 @@ function transformStylesExpression(j, comments, stylesExpression, nestedKeys, se
102
102
  if (prop.value.body.type === 'ObjectExpression') {
103
103
  let example = '';
104
104
  if (prop.value.params[0].type === 'Identifier') {
105
- example = ' (e.g. `(props) => ({...})` instead of `({color}) => ({...})`)';
105
+ example = ' (for example `(props) => ({...})` instead of `({color}) => ({...})`)';
106
106
  }
107
107
  extraComment = ` Arrow function has parameter type of ${prop.value.params[0].type} instead of ObjectPattern${example}.`;
108
108
  } else {
@@ -303,7 +303,7 @@ function transformer(file, api, options) {
303
303
  });
304
304
  });
305
305
  /**
306
- * Convert classes assignment syntax in calls to the hook (e.g. useStyles) and
306
+ * Convert classes assignment syntax in calls to the hook (for example useStyles) and
307
307
  * convert usages of clsx or classnames to cx.
308
308
  */
309
309
  styleHooks.forEach(hookName => {
@@ -38,7 +38,7 @@ const useExportedStyles = exports.useExportedStyles = (0, _mui.makeStyles)()({
38
38
  });
39
39
 
40
40
  // TODO jss-to-tss-react codemod: Unable to handle style definition reliably. Unsupported arrow function syntax.
41
- // Arrow function has parameter type of Identifier instead of ObjectPattern (e.g. `(props) => ({...})` instead of `({color}) => ({...})`).
41
+ // Arrow function has parameter type of Identifier instead of ObjectPattern (for example `(props) => ({...})` instead of `({color}) => ({...})`).
42
42
  const useStyles2 = (0, _mui.makeStyles)()({
43
43
  test2: props => ({
44
44
  backgroundColor: "blue",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "5.15.12",
3
+ "version": "5.15.14",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",