@mui/codemod 5.15.8 → 5.15.9

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
@@ -80,10 +80,10 @@ A combination of all deprecations.
80
80
 
81
81
  ```diff
82
82
  <Accordion
83
- - TransitionComponent={CustomTransition}
84
- - TransitionProps={{ unmountOnExit: true }}
85
- + slots={{ transition: CustomTransition }}
86
- + slotProps={{ transition: { unmountOnExit: true } }}
83
+ - TransitionComponent={CustomTransition}
84
+ - TransitionProps={{ unmountOnExit: true }}
85
+ + slots={{ transition: CustomTransition }}
86
+ + slotProps={{ transition: { unmountOnExit: true } }}
87
87
  />
88
88
  ```
89
89
 
@@ -91,6 +91,19 @@ A combination of all deprecations.
91
91
  npx @mui/codemod@latest deprecations/accordion-props <path>
92
92
  ```
93
93
 
94
+ #### `divider-props`
95
+
96
+ ```diff
97
+ <Divider
98
+ - light
99
+ + sx={{opacity: "0.6"}}
100
+ />
101
+ ```
102
+
103
+ ```bash
104
+ npx @mui/codemod@latest deprecations/divider-props <path>
105
+ ```
106
+
94
107
  ### v5.0.0
95
108
 
96
109
  #### `base-use-named-exports`
@@ -102,10 +115,10 @@ See https://github.com/mui/material-ui/issues/21862 for more context.
102
115
  This codemod updates the import and re-export statements.
103
116
 
104
117
  ```diff
105
- - import BaseButton from '@mui/base/Button';
106
- + import { Button as BaseButton } from '@mui/base/Button';
107
- - export { default as BaseSlider } from '@mui/base/Slider';
108
- + export { Slider as BaseSlider } from '@mui/base/Slider';
118
+ -import BaseButton from '@mui/base/Button';
119
+ -export { default as BaseSlider } from '@mui/base/Slider';
120
+ +import { Button as BaseButton } from '@mui/base/Button';
121
+ +export { Slider as BaseSlider } from '@mui/base/Slider';
109
122
  ```
110
123
 
111
124
  ```bash
@@ -117,8 +130,8 @@ npx @mui/codemod@latest v5.0.0/base-use-named-exports <path>
117
130
  The `Unstyled` suffix has been removed from all Base UI component names, including names of types and other related identifiers.
118
131
 
119
132
  ```diff
120
- - <Input component='a' href='url' />;
121
- + <Input slots={{ root: 'a' }} href='url' />;
133
+ -<Input component='a' href='url' />;
134
+ +<Input slots={{ root: 'a' }} href='url' />;
122
135
  ```
123
136
 
124
137
  ```bash
@@ -132,8 +145,8 @@ Remove `component` prop from all Base UI components by transferring its value i
132
145
  This change only affects Base UI components.
133
146
 
134
147
  ```diff
135
- - <Input component={CustomRoot} />
136
- + <Input slots={{ root: CustomRoot }} />
148
+ -<Input component={CustomRoot} />
149
+ +<Input slots={{ root: CustomRoot }} />
137
150
  ```
138
151
 
139
152
  ```bash
@@ -145,10 +158,10 @@ npx @mui/codemod@latest v5.0.0/base-remove-component-prop <path>
145
158
  Updates the names of the CSS variables of the Joy UI components to adapt to the new naming standards of the CSS variables for components.
146
159
 
147
160
  ```diff
148
- - <List sx={{ py: 'var(--List-divider-gap)' }}>
149
- + <List sx={{ py: 'var(--ListDivider-gap)' }}>
150
- - <Switch sx={{ '--Switch-track-width': '40px' }}>
151
- + <Switch sx={{ '--Switch-trackWidth': '40px' }}>
161
+ -<List sx={{ py: 'var(--List-divider-gap)' }}>
162
+ -<Switch sx={{ '--Switch-track-width': '40px' }}>
163
+ +<List sx={{ py: 'var(--ListDivider-gap)' }}>
164
+ +<Switch sx={{ '--Switch-trackWidth': '40px' }}>
152
165
  ```
153
166
 
154
167
  ```bash
@@ -160,8 +173,8 @@ npx @mui/codemod@latest v5.0.0/rename-css-variables <path>
160
173
  Updates the sources of the imports of the Base UI hooks to adapt to the new directories of the hooks.
161
174
 
162
175
  ```diff
163
- - import { useBadge } from '@mui/base/BadgeUnstyled';
164
- + import useBadge from '@mui/base/useBadge';
176
+ -import { useBadge } from '@mui/base/BadgeUnstyled';
177
+ +import useBadge from '@mui/base/useBadge';
165
178
  ```
166
179
 
167
180
  ```bash
@@ -283,8 +296,8 @@ This change only affects Joy UI components.
283
296
  ```diff
284
297
  <Autocomplete
285
298
  - components={{ listbox: CustomListbox }}
286
- + slots={{ listbox: CustomListbox }}
287
299
  - componentsProps={{ root: { className: 'root' }, listbox: { 'data-testid': 'listbox' } }}
300
+ + slots={{ listbox: CustomListbox }}
288
301
  + slotProps={{ root: { className: 'root' }, listbox: { 'data-testid': 'listbox' } }}
289
302
  />;
290
303
  ```
@@ -488,8 +501,8 @@ This change only affects Base UI components.
488
501
  ```diff
489
502
  <BadgeUnstyled
490
503
  - components={{ Root, Badge: CustomBadge }}
491
- + slots={{ root: Root, badge: CustomBadge }}
492
504
  - componentsProps={{ root: { className: 'root' }, badge: { 'data-testid': 'badge' } }}
505
+ + slots={{ root: Root, badge: CustomBadge }}
493
506
  + slotProps={{ root: { className: 'root' }, badge: { 'data-testid': 'badge' } }}
494
507
  />;
495
508
  ```
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = transformer;
8
+ var _appendAttribute = _interopRequireDefault(require("../../util/appendAttribute"));
9
+ var _assignObject = _interopRequireDefault(require("../../util/assignObject"));
10
+ var _findComponentJSX = _interopRequireDefault(require("../../util/findComponentJSX"));
11
+ /**
12
+ * @param {import('jscodeshift').FileInfo} file
13
+ * @param {import('jscodeshift').API} api
14
+ */
15
+ function transformer(file, api, options) {
16
+ const j = api.jscodeshift;
17
+ const root = j(file.source);
18
+ const printOptions = options.printOptions;
19
+ (0, _findComponentJSX.default)(j, {
20
+ root,
21
+ componentName: 'Divider'
22
+ }, elementPath => {
23
+ elementPath.node.openingElement.attributes = elementPath.node.openingElement.attributes.filter(attr => {
24
+ if (attr.type === 'JSXAttribute' && attr.name.name === 'light') {
25
+ return false;
26
+ }
27
+ return true;
28
+ });
29
+ const sxIndex = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'sx');
30
+ if (sxIndex === -1) {
31
+ (0, _appendAttribute.default)(j, {
32
+ target: elementPath.node,
33
+ attributeName: 'sx',
34
+ expression: j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])
35
+ });
36
+ } else {
37
+ const opacityIndex = elementPath.node.openingElement.attributes[sxIndex].value.expression.properties.findIndex(key => key.key.name === 'opacity');
38
+ if (opacityIndex === -1) {
39
+ (0, _assignObject.default)(j, {
40
+ target: elementPath.node.openingElement.attributes[sxIndex],
41
+ key: 'opacity',
42
+ expression: j.literal('0.6')
43
+ });
44
+ }
45
+ }
46
+ });
47
+ root.find(j.ObjectProperty, {
48
+ key: {
49
+ name: 'MuiDivider'
50
+ }
51
+ }).forEach(path => {
52
+ const defaultPropsObject = path.value.value.properties.find(key => key.key.name === 'defaultProps');
53
+ defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => {
54
+ var _prop$key;
55
+ return !['light'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
56
+ });
57
+ const sxIndex = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'sx');
58
+ if (sxIndex === -1) {
59
+ defaultPropsObject.value.properties.push(j.objectProperty(j.identifier('sx'), j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])));
60
+ } else {
61
+ const opacityIndex = defaultPropsObject.value.properties[sxIndex].value.properties.findIndex(key => key.key.name === 'opacity');
62
+ if (opacityIndex === -1) {
63
+ defaultPropsObject.value.properties[sxIndex].value.properties.push(j.objectProperty(j.identifier('opacity'), j.literal('0.6')));
64
+ }
65
+ }
66
+ });
67
+ return root.toSource(printOptions);
68
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _dividerProps.default;
11
+ }
12
+ });
13
+ var _dividerProps = _interopRequireDefault(require("./divider-props"));
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
8
+ light: true,
9
+ className: "test"
10
+ });
11
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
12
+ light: true,
13
+ className: "test"
14
+ });
15
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
16
+ light: false,
17
+ className: "test"
18
+ });
19
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
20
+ light: false,
21
+ className: "test"
22
+ });
23
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
24
+ light: light,
25
+ className: "test"
26
+ });
27
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
28
+ light: light,
29
+ className: "test"
30
+ });
31
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
32
+ light: true,
33
+ sx: {
34
+ opacity: '0.7'
35
+ }
36
+ });
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
38
+ light: true,
39
+ sx: {
40
+ bgcolor: 'black'
41
+ }
42
+ });
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
5
+ var _material = require("@mui/material");
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
8
+ className: "test",
9
+ sx: {
10
+ opacity: "0.6"
11
+ }
12
+ });
13
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
14
+ className: "test",
15
+ sx: {
16
+ opacity: "0.6"
17
+ }
18
+ });
19
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
20
+ className: "test",
21
+ sx: {
22
+ opacity: "0.6"
23
+ }
24
+ });
25
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
26
+ className: "test",
27
+ sx: {
28
+ opacity: "0.6"
29
+ }
30
+ });
31
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
32
+ className: "test",
33
+ sx: {
34
+ opacity: "0.6"
35
+ }
36
+ });
37
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
38
+ className: "test",
39
+ sx: {
40
+ opacity: "0.6"
41
+ }
42
+ });
43
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {
44
+ sx: {
45
+ opacity: '0.7'
46
+ }
47
+ });
48
+ /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {
49
+ sx: {
50
+ bgcolor: 'black',
51
+ opacity: "0.6"
52
+ }
53
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiDivider: {
5
+ defaultProps: {
6
+ light: true
7
+ }
8
+ }
9
+ });
10
+ fn({
11
+ MuiDivider: {
12
+ defaultProps: {
13
+ light: true,
14
+ className: 'my-class'
15
+ }
16
+ }
17
+ });
18
+ fn({
19
+ MuiDivider: {
20
+ defaultProps: {
21
+ light,
22
+ className: 'my-class'
23
+ }
24
+ }
25
+ });
26
+ fn({
27
+ MuiDivider: {
28
+ defaultProps: {
29
+ light,
30
+ className: 'my-class',
31
+ sx: {
32
+ opacity: '0.7'
33
+ }
34
+ }
35
+ }
36
+ });
37
+ fn({
38
+ MuiDivider: {
39
+ defaultProps: {
40
+ light,
41
+ className: 'my-class',
42
+ sx: {
43
+ bgcolor: 'black'
44
+ }
45
+ }
46
+ }
47
+ });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ fn({
4
+ MuiDivider: {
5
+ defaultProps: {
6
+ sx: {
7
+ opacity: "0.6"
8
+ }
9
+ }
10
+ }
11
+ });
12
+ fn({
13
+ MuiDivider: {
14
+ defaultProps: {
15
+ className: 'my-class',
16
+ sx: {
17
+ opacity: "0.6"
18
+ }
19
+ }
20
+ }
21
+ });
22
+ fn({
23
+ MuiDivider: {
24
+ defaultProps: {
25
+ className: 'my-class',
26
+ sx: {
27
+ opacity: "0.6"
28
+ }
29
+ }
30
+ }
31
+ });
32
+ fn({
33
+ MuiDivider: {
34
+ defaultProps: {
35
+ className: 'my-class',
36
+ sx: {
37
+ opacity: '0.7'
38
+ }
39
+ }
40
+ }
41
+ });
42
+ fn({
43
+ MuiDivider: {
44
+ defaultProps: {
45
+ className: 'my-class',
46
+ sx: {
47
+ bgcolor: 'black',
48
+ opacity: "0.6"
49
+ }
50
+ }
51
+ }
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "5.15.8",
3
+ "version": "5.15.9",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",