@mui/codemod 6.2.0 → 6.3.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.
package/README.md CHANGED
@@ -1509,6 +1509,21 @@ JS transforms:
1509
1509
  npx @mui/codemod@next deprecations/step-connector-classes <path>
1510
1510
  ```
1511
1511
 
1512
+ #### `step-content-props`
1513
+
1514
+ ```diff
1515
+ <StepContent
1516
+ - TransitionComponent={CustomTransition}
1517
+ - TransitionProps={{ unmountOnExit: true }}
1518
+ + slots={{ transition: CustomTransition }}
1519
+ + slotProps={{ transition: { unmountOnExit: true } }}
1520
+ />
1521
+ ```
1522
+
1523
+ ```bash
1524
+ npx @mui/codemod@latest deprecations/step-content-props <path>
1525
+ ```
1526
+
1512
1527
  #### `step-label-props`
1513
1528
 
1514
1529
  ```diff
@@ -29,11 +29,13 @@ var _paginationItemClasses = _interopRequireDefault(require("../pagination-item-
29
29
  var _speedDialProps = _interopRequireDefault(require("../speed-dial-props"));
30
30
  var _tableSortLabelClasses = _interopRequireDefault(require("../table-sort-label-classes"));
31
31
  var _stepConnectorClasses = _interopRequireDefault(require("../step-connector-classes"));
32
+ var _stepContentProps = _interopRequireDefault(require("../step-content-props"));
32
33
  var _stepLabelProps = _interopRequireDefault(require("../step-label-props"));
33
34
  var _textFieldProps = _interopRequireDefault(require("../text-field-props"));
34
35
  var _tabClasses = _interopRequireDefault(require("../tab-classes"));
35
36
  var _toggleButtonGroupClasses = _interopRequireDefault(require("../toggle-button-group-classes"));
36
37
  var _tooltipProps = _interopRequireDefault(require("../tooltip-props"));
38
+ var _tablePaginationProps = _interopRequireDefault(require("../table-pagination-props"));
37
39
  /**
38
40
  * @param {import('jscodeshift').FileInfo} file
39
41
  * @param {import('jscodeshift').API} api
@@ -62,11 +64,13 @@ function deprecationsAll(file, api, options) {
62
64
  file.source = (0, _paginationItemClasses.default)(file, api, options);
63
65
  file.source = (0, _speedDialProps.default)(file, api, options);
64
66
  file.source = (0, _stepConnectorClasses.default)(file, api, options);
67
+ file.source = (0, _stepContentProps.default)(file, api, options);
65
68
  file.source = (0, _stepLabelProps.default)(file, api, options);
66
69
  file.source = (0, _tableSortLabelClasses.default)(file, api, options);
67
70
  file.source = (0, _textFieldProps.default)(file, api, options);
68
71
  file.source = (0, _tabClasses.default)(file, api, options);
69
72
  file.source = (0, _toggleButtonGroupClasses.default)(file, api, options);
70
73
  file.source = (0, _tooltipProps.default)(file, api, options);
74
+ file.source = (0, _tablePaginationProps.default)(file, api, options);
71
75
  return file.source;
72
76
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _stepContentProps.default;
11
+ }
12
+ });
13
+ var _stepContentProps = _interopRequireDefault(require("./step-content-props"));
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
9
+ var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
10
+ /**
11
+ * @param {import('jscodeshift').FileInfo} file
12
+ * @param {import('jscodeshift').API} api
13
+ */
14
+ function transformer(file, api, options) {
15
+ const j = api.jscodeshift;
16
+ const root = j(file.source);
17
+ const printOptions = options.printOptions;
18
+ (0, _movePropIntoSlots.default)(j, {
19
+ root,
20
+ componentName: 'StepContent',
21
+ propName: 'TransitionComponent',
22
+ slotName: 'transition'
23
+ });
24
+ (0, _movePropIntoSlotProps.default)(j, {
25
+ root,
26
+ componentName: 'StepContent',
27
+ propName: 'TransitionProps',
28
+ slotName: 'transition'
29
+ });
30
+ return root.toSource(printOptions);
31
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _StepContent = _interopRequireDefault(require("@mui/material/StepContent"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
8
+ TransitionComponent: CustomTransition,
9
+ TransitionProps: {
10
+ unmountOnExit: true
11
+ }
12
+ });
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StepContent, {
14
+ TransitionComponent: CustomTransition,
15
+ TransitionProps: transitionVars
16
+ });
17
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
18
+ TransitionComponent: CustomTransition,
19
+ TransitionProps: {
20
+ unmountOnExit: true
21
+ },
22
+ slots: {
23
+ root: 'div'
24
+ },
25
+ slotProps: {
26
+ root: {
27
+ className: 'foo'
28
+ }
29
+ }
30
+ });
31
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StepContent, {
32
+ TransitionComponent: CustomTransition,
33
+ TransitionProps: {
34
+ unmountOnExit: true
35
+ },
36
+ slots: {
37
+ ...outerSlots
38
+ },
39
+ slotProps: {
40
+ ...outerSlotProps
41
+ }
42
+ });
43
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
44
+ TransitionComponent: ComponentTransition,
45
+ slots: {
46
+ transition: SlotTransition
47
+ }
48
+ });
49
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
50
+ TransitionProps: {
51
+ unmountOnExit: true
52
+ },
53
+ slotProps: {
54
+ transition: {
55
+ id: 'test'
56
+ }
57
+ }
58
+ });
59
+ // should skip non MUI components
60
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiStepContent, {
61
+ TransitionComponent: CustomTransition,
62
+ TransitionProps: {
63
+ unmountOnExit: true
64
+ }
65
+ });
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _StepContent = _interopRequireDefault(require("@mui/material/StepContent"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
8
+ slots: {
9
+ transition: CustomTransition
10
+ },
11
+ slotProps: {
12
+ transition: {
13
+ unmountOnExit: true
14
+ }
15
+ }
16
+ });
17
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StepContent, {
18
+ slots: {
19
+ transition: CustomTransition
20
+ },
21
+ slotProps: {
22
+ transition: transitionVars
23
+ }
24
+ });
25
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
26
+ slots: {
27
+ root: 'div',
28
+ transition: CustomTransition
29
+ },
30
+ slotProps: {
31
+ root: {
32
+ className: 'foo'
33
+ },
34
+ transition: {
35
+ unmountOnExit: true
36
+ }
37
+ }
38
+ });
39
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StepContent, {
40
+ slots: {
41
+ ...outerSlots,
42
+ transition: CustomTransition
43
+ },
44
+ slotProps: {
45
+ ...outerSlotProps,
46
+ transition: {
47
+ unmountOnExit: true
48
+ }
49
+ }
50
+ });
51
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
52
+ slots: {
53
+ transition: SlotTransition
54
+ }
55
+ });
56
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepContent.default, {
57
+ slotProps: {
58
+ transition: {
59
+ ...{
60
+ unmountOnExit: true
61
+ },
62
+ ...{
63
+ id: 'test'
64
+ }
65
+ }
66
+ }
67
+ });
68
+ // should skip non MUI components
69
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiStepContent, {
70
+ TransitionComponent: CustomTransition,
71
+ TransitionProps: {
72
+ unmountOnExit: true
73
+ }
74
+ });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiStepContent: {
5
+ defaultProps: {
6
+ TransitionComponent: CustomTransition,
7
+ TransitionProps: {
8
+ unmountOnExit: true
9
+ }
10
+ }
11
+ }
12
+ });
13
+ fn({
14
+ MuiStepContent: {
15
+ defaultProps: {
16
+ TransitionComponent: ComponentTransition,
17
+ slots: {
18
+ transition: SlotTransition
19
+ }
20
+ }
21
+ }
22
+ });
23
+ fn({
24
+ MuiStepContent: {
25
+ defaultProps: {
26
+ slotProps: {
27
+ transition: {
28
+ id: 'test'
29
+ }
30
+ },
31
+ TransitionProps: {
32
+ unmountOnExit: true
33
+ }
34
+ }
35
+ }
36
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiStepContent: {
5
+ defaultProps: {
6
+ slots: {
7
+ transition: CustomTransition
8
+ },
9
+ slotProps: {
10
+ transition: {
11
+ unmountOnExit: true
12
+ }
13
+ }
14
+ }
15
+ }
16
+ });
17
+ fn({
18
+ MuiStepContent: {
19
+ defaultProps: {
20
+ slots: {
21
+ transition: SlotTransition
22
+ }
23
+ }
24
+ }
25
+ });
26
+ fn({
27
+ MuiStepContent: {
28
+ defaultProps: {
29
+ slotProps: {
30
+ transition: {
31
+ ...{
32
+ unmountOnExit: true
33
+ },
34
+ ...{
35
+ id: 'test'
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ });
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _tablePaginationProps.default;
11
+ }
12
+ });
13
+ var _tablePaginationProps = _interopRequireDefault(require("./table-pagination-props"));
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
9
+ var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
10
+ /**
11
+ * @param {import('jscodeshift').FileInfo} file
12
+ * @param {import('jscodeshift').API} api
13
+ */
14
+ function transformer(file, api, options) {
15
+ const j = api.jscodeshift;
16
+ const root = j(file.source);
17
+ const printOptions = options.printOptions;
18
+ (0, _movePropIntoSlots.default)(j, {
19
+ root,
20
+ componentName: 'TablePagination',
21
+ propName: 'ActionsComponent',
22
+ slotName: 'actions'
23
+ });
24
+ (0, _movePropIntoSlotProps.default)(j, {
25
+ root,
26
+ componentName: 'TablePagination',
27
+ propName: 'SelectProps',
28
+ slotName: 'select'
29
+ });
30
+ return root.toSource(printOptions);
31
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _TablePagination = _interopRequireDefault(require("@mui/material/TablePagination"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
8
+ ActionsComponent: "div",
9
+ SelectProps: {
10
+ native: true
11
+ }
12
+ });
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
14
+ ActionsComponent: "div",
15
+ SelectProps: {
16
+ native: true
17
+ },
18
+ slots: {
19
+ actions: 'div',
20
+ select: 'div'
21
+ }
22
+ });
23
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
24
+ ActionsComponent: "div",
25
+ SelectProps: {
26
+ native: true
27
+ },
28
+ slots: {
29
+ root: 'div'
30
+ },
31
+ slotProps: {
32
+ root: {
33
+ 'aria-label': ''
34
+ }
35
+ }
36
+ });
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
38
+ ActionsComponent: "div",
39
+ SelectProps: {
40
+ native: true
41
+ },
42
+ slots: {
43
+ actions: () => null
44
+ },
45
+ slotProps: {
46
+ select: {
47
+ native: false
48
+ }
49
+ }
50
+ });
51
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TablePagination, {
52
+ ActionsComponent: "div",
53
+ SelectProps: {
54
+ native: true
55
+ }
56
+ });
57
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomTablePagination, {
58
+ ActionsComponent: "div",
59
+ SelectProps: {
60
+ native: true
61
+ }
62
+ });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _TablePagination = _interopRequireDefault(require("@mui/material/TablePagination"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
8
+ slots: {
9
+ actions: "div"
10
+ },
11
+ slotProps: {
12
+ select: {
13
+ native: true
14
+ }
15
+ }
16
+ });
17
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
18
+ slots: {
19
+ actions: 'div',
20
+ select: 'div'
21
+ },
22
+ slotProps: {
23
+ select: {
24
+ native: true
25
+ }
26
+ }
27
+ });
28
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
29
+ slots: {
30
+ root: 'div',
31
+ actions: "div"
32
+ },
33
+ slotProps: {
34
+ root: {
35
+ 'aria-label': ''
36
+ },
37
+ select: {
38
+ native: true
39
+ }
40
+ }
41
+ });
42
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_TablePagination.default, {
43
+ slots: {
44
+ actions: () => null
45
+ },
46
+ slotProps: {
47
+ select: {
48
+ ...{
49
+ native: true
50
+ },
51
+ ...{
52
+ native: false
53
+ }
54
+ }
55
+ }
56
+ });
57
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TablePagination, {
58
+ slots: {
59
+ actions: "div"
60
+ },
61
+ slotProps: {
62
+ select: {
63
+ native: true
64
+ }
65
+ }
66
+ });
67
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomTablePagination, {
68
+ ActionsComponent: "div",
69
+ SelectProps: {
70
+ native: true
71
+ }
72
+ });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiTablePagination: {
5
+ defaultProps: {
6
+ ActionsComponent: 'div',
7
+ SelectProps: {
8
+ native: true
9
+ }
10
+ }
11
+ }
12
+ });
13
+ fn({
14
+ MuiTablePagination: {
15
+ defaultProps: {
16
+ ActionsComponent: 'div',
17
+ SelectProps: {
18
+ native: true
19
+ },
20
+ slotProps: {
21
+ root: {
22
+ id: 'test'
23
+ }
24
+ },
25
+ slots: {
26
+ root: 'div'
27
+ }
28
+ }
29
+ }
30
+ });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiTablePagination: {
5
+ defaultProps: {
6
+ slots: {
7
+ actions: 'div'
8
+ },
9
+ slotProps: {
10
+ select: {
11
+ native: true
12
+ }
13
+ }
14
+ }
15
+ }
16
+ });
17
+ fn({
18
+ MuiTablePagination: {
19
+ defaultProps: {
20
+ slotProps: {
21
+ root: {
22
+ id: 'test'
23
+ },
24
+ select: {
25
+ native: true
26
+ }
27
+ },
28
+ slots: {
29
+ root: 'div',
30
+ actions: 'div'
31
+ }
32
+ }
33
+ }
34
+ });
@@ -12,7 +12,8 @@ var _appendAttribute = _interopRequireDefault(require("../../util/appendAttribut
12
12
  function moveJsxPropIntoSlots(j, element, propName, slotName) {
13
13
  const index = element.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === propName);
14
14
  if (index !== -1) {
15
- const removedValue = element.openingElement.attributes.splice(index, 1)[0].value.expression;
15
+ const attrNode = element.openingElement.attributes.splice(index, 1)[0];
16
+ const removedValue = attrNode.value.expression || attrNode.value;
16
17
  let hasSlots = false;
17
18
  element.openingElement.attributes.forEach(attr => {
18
19
  if (attr.name?.name === 'slots') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@babel/core": "^7.26.0",
28
28
  "@babel/runtime": "^7.26.0",
29
- "@babel/traverse": "^7.25.9",
29
+ "@babel/traverse": "^7.26.4",
30
30
  "jscodeshift": "^17.1.1",
31
31
  "jscodeshift-add-imports": "^1.0.11",
32
32
  "postcss": "^8.4.49",