@mui/codemod 6.0.0-alpha.6 → 6.0.0-alpha.7
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 +102 -0
- package/node/deprecations/all/deprecations-all.js +4 -0
- package/node/deprecations/all/postcss.config.js +4 -1
- package/node/deprecations/autocomplete-props/autocomplete-props.js +54 -0
- package/node/deprecations/autocomplete-props/index.js +13 -0
- package/node/deprecations/autocomplete-props/test-cases/actual.js +97 -0
- package/node/deprecations/autocomplete-props/test-cases/expected.js +101 -0
- package/node/deprecations/autocomplete-props/test-cases/theme.actual.js +65 -0
- package/node/deprecations/autocomplete-props/test-cases/theme.expected.js +68 -0
- package/node/deprecations/circular-progress-classes/circular-progress-classes.js +77 -0
- package/node/deprecations/circular-progress-classes/index.js +13 -0
- package/node/deprecations/circular-progress-classes/postcss-plugin.js +33 -0
- package/node/deprecations/circular-progress-classes/postcss.config.js +8 -0
- package/node/deprecations/circular-progress-classes/test-cases/actual.js +7 -0
- package/node/deprecations/circular-progress-classes/test-cases/expected.js +7 -0
- package/node/deprecations/divider-props/divider-props.js +36 -30
- package/node/deprecations/divider-props/test-cases/actual.js +3 -0
- package/node/deprecations/divider-props/test-cases/expected.js +3 -0
- package/node/deprecations/divider-props/test-cases/theme.actual.js +7 -0
- package/node/deprecations/divider-props/test-cases/theme.expected.js +7 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -259,6 +259,72 @@ npx @mui/codemod@next deprecations/alert-classes <path>
|
|
|
259
259
|
npx @mui/codemod@next deprecations/alert-props <path>
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
+
#### `autocomplete-props`
|
|
263
|
+
|
|
264
|
+
```diff
|
|
265
|
+
<Autocomplete
|
|
266
|
+
- ChipProps={{ height: 10 }}
|
|
267
|
+
- PaperComponent={CustomPaper}
|
|
268
|
+
- PopperComponent={CustomPopper}
|
|
269
|
+
- ListboxComponent={CustomListbox}
|
|
270
|
+
- ListboxProps={{ height: 12 }}
|
|
271
|
+
- componentsProps={{
|
|
272
|
+
- clearIndicator: { width: 10 },
|
|
273
|
+
- paper: { width: 12 },
|
|
274
|
+
- popper: { width: 14 },
|
|
275
|
+
- popupIndicator: { width: 16 },
|
|
276
|
+
- }}
|
|
277
|
+
+ slots={{
|
|
278
|
+
+ paper: CustomPaper,
|
|
279
|
+
+ popper: CustomPopper,
|
|
280
|
+
+ listbox: CustomListbox,
|
|
281
|
+
+ }}
|
|
282
|
+
+ slotProps={{
|
|
283
|
+
+ chip: { height: 10 },
|
|
284
|
+
+ listbox: { height: 12 },
|
|
285
|
+
+ clearIndicator: { width: 10 },
|
|
286
|
+
+ paper: { width: 12 },
|
|
287
|
+
+ popper: { width: 14 },
|
|
288
|
+
+ popupIndicator: { width: 16 },
|
|
289
|
+
+ }}
|
|
290
|
+
/>
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
```diff
|
|
294
|
+
MuiAutocomplete: {
|
|
295
|
+
defaultProps: {
|
|
296
|
+
- ChipProps: { height: 10 },
|
|
297
|
+
- PaperComponent: CustomPaper,
|
|
298
|
+
- PopperComponent: CustomPopper,
|
|
299
|
+
- ListboxComponent: CustomListbox,
|
|
300
|
+
- ListboxProps: { height: 12 },
|
|
301
|
+
- componentsProps: {
|
|
302
|
+
- clearIndicator: { width: 10 },
|
|
303
|
+
- paper: { width: 12 },
|
|
304
|
+
- popper: { width: 14 },
|
|
305
|
+
- popupIndicator: { width: 16 },
|
|
306
|
+
- }
|
|
307
|
+
+ slots: {
|
|
308
|
+
+ paper: CustomPaper,
|
|
309
|
+
+ popper: CustomPopper,
|
|
310
|
+
+ listbox: CustomListbox,
|
|
311
|
+
+ },
|
|
312
|
+
+ slotProps: {
|
|
313
|
+
+ chip: { height: 10 },
|
|
314
|
+
+ listbox: { height: 12 },
|
|
315
|
+
+ clearIndicator: { width: 10 },
|
|
316
|
+
+ paper: { width: 12 },
|
|
317
|
+
+ popper: { width: 14 },
|
|
318
|
+
+ popupIndicator: { width: 16 },
|
|
319
|
+
+ },
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
npx @mui/codemod@next deprecations/autocomplete-props <path>
|
|
326
|
+
```
|
|
327
|
+
|
|
262
328
|
#### `avatar-props`
|
|
263
329
|
|
|
264
330
|
```diff
|
|
@@ -845,6 +911,42 @@ CSS transforms:
|
|
|
845
911
|
npx @mui/codemod@next deprecations/chip-classes <path>
|
|
846
912
|
```
|
|
847
913
|
|
|
914
|
+
#### `circular-progress-classes`
|
|
915
|
+
|
|
916
|
+
JS transforms:
|
|
917
|
+
|
|
918
|
+
```diff
|
|
919
|
+
import { circularProgressClasses } from '@mui/material/CircularProgress';
|
|
920
|
+
|
|
921
|
+
MuiCircularProgress: {
|
|
922
|
+
styleOverrides: {
|
|
923
|
+
root: {
|
|
924
|
+
- [`& .${circularProgressClasses.circleDeterminate}`]: {
|
|
925
|
+
+ [`&.${circularProgressClasses.determinate} > .${circularProgressClasses.circle}`]: {
|
|
926
|
+
color: 'red',
|
|
927
|
+
},
|
|
928
|
+
- [`& .${circularProgressClasses.circleIndeterminate}`]: {
|
|
929
|
+
+ [`&.${circularProgressClasses.indeterminate} > .${circularProgressClasses.circle}`]: {
|
|
930
|
+
color: 'red',
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
},
|
|
934
|
+
},
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
CSS transforms:
|
|
938
|
+
|
|
939
|
+
```diff
|
|
940
|
+
- .MuiCircularProgress-circleDeterminate
|
|
941
|
+
+.MuiCircularProgress-determinate > .MuiCircularProgress-circle
|
|
942
|
+
- .MuiCircularProgress-circleIndeterminate
|
|
943
|
+
+.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
```bash
|
|
947
|
+
npx @mui/codemod@next deprecations/circular-progress-classes <path>
|
|
948
|
+
```
|
|
949
|
+
|
|
848
950
|
#### `divider-props`
|
|
849
951
|
|
|
850
952
|
```diff
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = deprecationsAll;
|
|
8
8
|
var _accordionProps = _interopRequireDefault(require("../accordion-props"));
|
|
9
|
+
var _autocompleteProps = _interopRequireDefault(require("../autocomplete-props"));
|
|
9
10
|
var _formControlLabelProps = _interopRequireDefault(require("../form-control-label-props"));
|
|
10
11
|
var _avatarProps = _interopRequireDefault(require("../avatar-props"));
|
|
11
12
|
var _dividerProps = _interopRequireDefault(require("../divider-props"));
|
|
@@ -19,6 +20,7 @@ var _toggleButtonGroupClasses = _interopRequireDefault(require("../toggle-button
|
|
|
19
20
|
var _stepLabelProps = _interopRequireDefault(require("../step-label-props"));
|
|
20
21
|
var _backdropProps = _interopRequireDefault(require("../backdrop-props"));
|
|
21
22
|
var _stepConnectorClasses = _interopRequireDefault(require("../step-connector-classes"));
|
|
23
|
+
var _circularProgressClasses = _interopRequireDefault(require("../circular-progress-classes"));
|
|
22
24
|
var _speedDialProps = _interopRequireDefault(require("../speed-dial-props"));
|
|
23
25
|
/**
|
|
24
26
|
* @param {import('jscodeshift').FileInfo} file
|
|
@@ -26,6 +28,7 @@ var _speedDialProps = _interopRequireDefault(require("../speed-dial-props"));
|
|
|
26
28
|
*/
|
|
27
29
|
function deprecationsAll(file, api, options) {
|
|
28
30
|
file.source = (0, _accordionProps.default)(file, api, options);
|
|
31
|
+
file.source = (0, _autocompleteProps.default)(file, api, options);
|
|
29
32
|
file.source = (0, _formControlLabelProps.default)(file, api, options);
|
|
30
33
|
file.source = (0, _avatarProps.default)(file, api, options);
|
|
31
34
|
file.source = (0, _dividerProps.default)(file, api, options);
|
|
@@ -39,6 +42,7 @@ function deprecationsAll(file, api, options) {
|
|
|
39
42
|
file.source = (0, _stepLabelProps.default)(file, api, options);
|
|
40
43
|
file.source = (0, _backdropProps.default)(file, api, options);
|
|
41
44
|
file.source = (0, _stepConnectorClasses.default)(file, api, options);
|
|
45
|
+
file.source = (0, _circularProgressClasses.default)(file, api, options);
|
|
42
46
|
file.source = (0, _speedDialProps.default)(file, api, options);
|
|
43
47
|
return file.source;
|
|
44
48
|
}
|
|
@@ -24,6 +24,9 @@ const {
|
|
|
24
24
|
const {
|
|
25
25
|
plugin: toggleButtonGroupClassesPlugin
|
|
26
26
|
} = require('../toggle-button-group-classes/postcss-plugin');
|
|
27
|
+
const {
|
|
28
|
+
plugin: circularProgressClassesPlugin
|
|
29
|
+
} = require('../circular-progress-classes/postcss-plugin');
|
|
27
30
|
module.exports = {
|
|
28
|
-
plugins: [accordionSummaryClassesPlugin, alertClassesPlugin, buttonClassesPlugin, buttonGroupClassesPlugin, chipClassesPlugin, paginationItemClassesPlugin, stepConnectorClassesPlugin, toggleButtonGroupClassesPlugin]
|
|
31
|
+
plugins: [accordionSummaryClassesPlugin, alertClassesPlugin, buttonClassesPlugin, buttonGroupClassesPlugin, chipClassesPlugin, circularProgressClassesPlugin, paginationItemClassesPlugin, stepConnectorClassesPlugin, toggleButtonGroupClassesPlugin]
|
|
29
32
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
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 _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
|
|
9
|
+
var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
|
|
10
|
+
var _replaceComponentsWithSlots = _interopRequireDefault(require("../utils/replaceComponentsWithSlots"));
|
|
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, _movePropIntoSlots.default)(j, {
|
|
20
|
+
root,
|
|
21
|
+
componentName: 'Autocomplete',
|
|
22
|
+
propName: 'PaperComponent',
|
|
23
|
+
slotName: 'paper'
|
|
24
|
+
});
|
|
25
|
+
(0, _movePropIntoSlots.default)(j, {
|
|
26
|
+
root,
|
|
27
|
+
componentName: 'Autocomplete',
|
|
28
|
+
propName: 'PopperComponent',
|
|
29
|
+
slotName: 'popper'
|
|
30
|
+
});
|
|
31
|
+
(0, _movePropIntoSlots.default)(j, {
|
|
32
|
+
root,
|
|
33
|
+
componentName: 'Autocomplete',
|
|
34
|
+
propName: 'ListboxComponent',
|
|
35
|
+
slotName: 'listbox'
|
|
36
|
+
});
|
|
37
|
+
(0, _movePropIntoSlotProps.default)(j, {
|
|
38
|
+
root,
|
|
39
|
+
componentName: 'Autocomplete',
|
|
40
|
+
propName: 'ListboxProps',
|
|
41
|
+
slotName: 'listbox'
|
|
42
|
+
});
|
|
43
|
+
(0, _movePropIntoSlotProps.default)(j, {
|
|
44
|
+
root,
|
|
45
|
+
componentName: 'Autocomplete',
|
|
46
|
+
propName: 'ChipProps',
|
|
47
|
+
slotName: 'chip'
|
|
48
|
+
});
|
|
49
|
+
(0, _replaceComponentsWithSlots.default)(j, {
|
|
50
|
+
root,
|
|
51
|
+
componentName: 'Autocomplete'
|
|
52
|
+
});
|
|
53
|
+
return root.toSource(printOptions);
|
|
54
|
+
}
|
|
@@ -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 _autocompleteProps.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _autocompleteProps = _interopRequireDefault(require("./autocomplete-props"));
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _Autocomplete = _interopRequireDefault(require("@mui/material/Autocomplete"));
|
|
5
|
+
var _material = require("@mui/material");
|
|
6
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
8
|
+
ChipProps: {
|
|
9
|
+
height: 10
|
|
10
|
+
},
|
|
11
|
+
PaperComponent: CustomPaper,
|
|
12
|
+
PopperComponent: CustomPopper,
|
|
13
|
+
ListboxComponent: CustomListbox,
|
|
14
|
+
ListboxProps: {
|
|
15
|
+
height: 12
|
|
16
|
+
},
|
|
17
|
+
componentsProps: {
|
|
18
|
+
clearIndicator: {
|
|
19
|
+
width: 10
|
|
20
|
+
},
|
|
21
|
+
paper: {
|
|
22
|
+
width: 12
|
|
23
|
+
},
|
|
24
|
+
popper: {
|
|
25
|
+
width: 14
|
|
26
|
+
},
|
|
27
|
+
popupIndicator: {
|
|
28
|
+
width: 16
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
33
|
+
ChipProps: {
|
|
34
|
+
height: 10
|
|
35
|
+
},
|
|
36
|
+
PaperComponent: CustomPaper,
|
|
37
|
+
PopperComponent: CustomPopper,
|
|
38
|
+
ListboxComponent: CustomListbox,
|
|
39
|
+
ListboxProps: {
|
|
40
|
+
height: 12
|
|
41
|
+
},
|
|
42
|
+
slotProps: {
|
|
43
|
+
popupIndicator: {
|
|
44
|
+
width: 20
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
componentsProps: {
|
|
48
|
+
clearIndicator: {
|
|
49
|
+
width: 10
|
|
50
|
+
},
|
|
51
|
+
paper: {
|
|
52
|
+
width: 12
|
|
53
|
+
},
|
|
54
|
+
popper: {
|
|
55
|
+
width: 14
|
|
56
|
+
},
|
|
57
|
+
popupIndicator: {
|
|
58
|
+
width: 16
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
63
|
+
ChipProps: {
|
|
64
|
+
height: 10
|
|
65
|
+
},
|
|
66
|
+
PaperComponent: CustomPaper,
|
|
67
|
+
PopperComponent: CustomPopper,
|
|
68
|
+
ListboxComponent: CustomListbox,
|
|
69
|
+
ListboxProps: {
|
|
70
|
+
height: 12
|
|
71
|
+
},
|
|
72
|
+
componentsProps: {
|
|
73
|
+
clearIndicator: {
|
|
74
|
+
width: 10
|
|
75
|
+
},
|
|
76
|
+
paper: {
|
|
77
|
+
width: 12
|
|
78
|
+
},
|
|
79
|
+
popper: {
|
|
80
|
+
width: 14
|
|
81
|
+
},
|
|
82
|
+
popupIndicator: {
|
|
83
|
+
width: 16
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(CustomAutocomplete, {
|
|
88
|
+
ChipProps: {
|
|
89
|
+
height: 10
|
|
90
|
+
},
|
|
91
|
+
PaperComponent: CustomPaper,
|
|
92
|
+
PopperComponent: CustomPopper,
|
|
93
|
+
ListboxComponent: CustomListbox,
|
|
94
|
+
ListboxProps: {
|
|
95
|
+
height: 12
|
|
96
|
+
}
|
|
97
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _Autocomplete = _interopRequireDefault(require("@mui/material/Autocomplete"));
|
|
6
|
+
var _material = require("@mui/material");
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
9
|
+
slots: {
|
|
10
|
+
paper: CustomPaper,
|
|
11
|
+
popper: CustomPopper,
|
|
12
|
+
listbox: CustomListbox
|
|
13
|
+
},
|
|
14
|
+
slotProps: {
|
|
15
|
+
listbox: {
|
|
16
|
+
height: 12
|
|
17
|
+
},
|
|
18
|
+
chip: {
|
|
19
|
+
height: 10
|
|
20
|
+
},
|
|
21
|
+
clearIndicator: {
|
|
22
|
+
width: 10
|
|
23
|
+
},
|
|
24
|
+
paper: {
|
|
25
|
+
width: 12
|
|
26
|
+
},
|
|
27
|
+
popper: {
|
|
28
|
+
width: 14
|
|
29
|
+
},
|
|
30
|
+
popupIndicator: {
|
|
31
|
+
width: 16
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
36
|
+
slotProps: {
|
|
37
|
+
listbox: {
|
|
38
|
+
height: 12
|
|
39
|
+
},
|
|
40
|
+
chip: {
|
|
41
|
+
height: 10
|
|
42
|
+
},
|
|
43
|
+
clearIndicator: {
|
|
44
|
+
width: 10
|
|
45
|
+
},
|
|
46
|
+
paper: {
|
|
47
|
+
width: 12
|
|
48
|
+
},
|
|
49
|
+
popper: {
|
|
50
|
+
width: 14
|
|
51
|
+
},
|
|
52
|
+
popupIndicator: (0, _extends2.default)({}, {
|
|
53
|
+
width: 16
|
|
54
|
+
}, {
|
|
55
|
+
width: 20
|
|
56
|
+
})
|
|
57
|
+
},
|
|
58
|
+
slots: {
|
|
59
|
+
paper: CustomPaper,
|
|
60
|
+
popper: CustomPopper,
|
|
61
|
+
listbox: CustomListbox
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, {
|
|
65
|
+
slots: {
|
|
66
|
+
paper: CustomPaper,
|
|
67
|
+
popper: CustomPopper,
|
|
68
|
+
listbox: CustomListbox
|
|
69
|
+
},
|
|
70
|
+
slotProps: {
|
|
71
|
+
listbox: {
|
|
72
|
+
height: 12
|
|
73
|
+
},
|
|
74
|
+
chip: {
|
|
75
|
+
height: 10
|
|
76
|
+
},
|
|
77
|
+
clearIndicator: {
|
|
78
|
+
width: 10
|
|
79
|
+
},
|
|
80
|
+
paper: {
|
|
81
|
+
width: 12
|
|
82
|
+
},
|
|
83
|
+
popper: {
|
|
84
|
+
width: 14
|
|
85
|
+
},
|
|
86
|
+
popupIndicator: {
|
|
87
|
+
width: 16
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(CustomAutocomplete, {
|
|
92
|
+
ChipProps: {
|
|
93
|
+
height: 10
|
|
94
|
+
},
|
|
95
|
+
PaperComponent: CustomPaper,
|
|
96
|
+
PopperComponent: CustomPopper,
|
|
97
|
+
ListboxComponent: CustomListbox,
|
|
98
|
+
ListboxProps: {
|
|
99
|
+
height: 12
|
|
100
|
+
}
|
|
101
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
fn({
|
|
4
|
+
MuiAutocomplete: {
|
|
5
|
+
defaultProps: {
|
|
6
|
+
ChipProps: {
|
|
7
|
+
height: 10
|
|
8
|
+
},
|
|
9
|
+
PaperComponent: CustomPaper,
|
|
10
|
+
PopperComponent: CustomPopper,
|
|
11
|
+
ListboxComponent: CustomListbox,
|
|
12
|
+
ListboxProps: {
|
|
13
|
+
height: 12
|
|
14
|
+
},
|
|
15
|
+
componentsProps: {
|
|
16
|
+
clearIndicator: {
|
|
17
|
+
width: 10
|
|
18
|
+
},
|
|
19
|
+
paper: {
|
|
20
|
+
width: 12
|
|
21
|
+
},
|
|
22
|
+
popper: {
|
|
23
|
+
width: 14
|
|
24
|
+
},
|
|
25
|
+
popupIndicator: {
|
|
26
|
+
width: 16
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
fn({
|
|
33
|
+
MuiAutocomplete: {
|
|
34
|
+
defaultProps: {
|
|
35
|
+
ChipProps: {
|
|
36
|
+
height: 10
|
|
37
|
+
},
|
|
38
|
+
PaperComponent: CustomPaper,
|
|
39
|
+
PopperComponent: CustomPopper,
|
|
40
|
+
ListboxComponent: CustomListbox,
|
|
41
|
+
ListboxProps: {
|
|
42
|
+
height: 12
|
|
43
|
+
},
|
|
44
|
+
slotProps: {
|
|
45
|
+
popupIndicator: {
|
|
46
|
+
width: 20
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
componentsProps: {
|
|
50
|
+
clearIndicator: {
|
|
51
|
+
width: 10
|
|
52
|
+
},
|
|
53
|
+
paper: {
|
|
54
|
+
width: 12
|
|
55
|
+
},
|
|
56
|
+
popper: {
|
|
57
|
+
width: 14
|
|
58
|
+
},
|
|
59
|
+
popupIndicator: {
|
|
60
|
+
width: 16
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
fn({
|
|
6
|
+
MuiAutocomplete: {
|
|
7
|
+
defaultProps: {
|
|
8
|
+
slots: {
|
|
9
|
+
paper: CustomPaper,
|
|
10
|
+
popper: CustomPopper,
|
|
11
|
+
listbox: CustomListbox
|
|
12
|
+
},
|
|
13
|
+
slotProps: {
|
|
14
|
+
clearIndicator: {
|
|
15
|
+
width: 10
|
|
16
|
+
},
|
|
17
|
+
paper: {
|
|
18
|
+
width: 12
|
|
19
|
+
},
|
|
20
|
+
popper: {
|
|
21
|
+
width: 14
|
|
22
|
+
},
|
|
23
|
+
popupIndicator: {
|
|
24
|
+
width: 16
|
|
25
|
+
},
|
|
26
|
+
listbox: {
|
|
27
|
+
height: 12
|
|
28
|
+
},
|
|
29
|
+
chip: {
|
|
30
|
+
height: 10
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
fn({
|
|
37
|
+
MuiAutocomplete: {
|
|
38
|
+
defaultProps: {
|
|
39
|
+
slotProps: {
|
|
40
|
+
clearIndicator: {
|
|
41
|
+
width: 10
|
|
42
|
+
},
|
|
43
|
+
paper: {
|
|
44
|
+
width: 12
|
|
45
|
+
},
|
|
46
|
+
popper: {
|
|
47
|
+
width: 14
|
|
48
|
+
},
|
|
49
|
+
popupIndicator: (0, _extends2.default)({}, {
|
|
50
|
+
width: 16
|
|
51
|
+
}, {
|
|
52
|
+
width: 20
|
|
53
|
+
}),
|
|
54
|
+
listbox: {
|
|
55
|
+
height: 12
|
|
56
|
+
},
|
|
57
|
+
chip: {
|
|
58
|
+
height: 10
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
slots: {
|
|
62
|
+
paper: CustomPaper,
|
|
63
|
+
popper: CustomPopper,
|
|
64
|
+
listbox: CustomListbox
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
var _postcssPlugin = require("./postcss-plugin");
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
10
|
+
* @param {import('jscodeshift').API} api
|
|
11
|
+
*/
|
|
12
|
+
function transformer(file, api, options) {
|
|
13
|
+
const j = api.jscodeshift;
|
|
14
|
+
const root = j(file.source);
|
|
15
|
+
const printOptions = options.printOptions;
|
|
16
|
+
_postcssPlugin.classes.forEach(({
|
|
17
|
+
deprecatedClass,
|
|
18
|
+
replacementSelector
|
|
19
|
+
}) => {
|
|
20
|
+
const replacementSelectorPrefix = '&';
|
|
21
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(/^@mui\/material\/CircularProgress$/)).forEach(path => {
|
|
22
|
+
path.node.specifiers.forEach(specifier => {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'circularProgressClasses') {
|
|
24
|
+
const deprecatedAtomicClass = deprecatedClass.replace(`${deprecatedClass.split('-')[0]}-`, '');
|
|
25
|
+
root.find(j.MemberExpression, {
|
|
26
|
+
object: {
|
|
27
|
+
name: specifier.local.name
|
|
28
|
+
},
|
|
29
|
+
property: {
|
|
30
|
+
name: deprecatedAtomicClass
|
|
31
|
+
}
|
|
32
|
+
}).forEach(memberExpression => {
|
|
33
|
+
const parent = memberExpression.parentPath.parentPath.value;
|
|
34
|
+
if (parent.type === j.TemplateLiteral.name) {
|
|
35
|
+
const memberExpressionIndex = parent.expressions.findIndex(expression => expression === memberExpression.value);
|
|
36
|
+
const precedingTemplateElement = parent.quasis[memberExpressionIndex];
|
|
37
|
+
const atomicClasses = replacementSelector.replaceAll('MuiCircularProgress-', '').replaceAll(replacementSelectorPrefix, '').replaceAll(' > ', '').split('.').filter(Boolean);
|
|
38
|
+
if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
|
|
39
|
+
const atomicClassesArgs = [memberExpressionIndex, 1, ...atomicClasses.map(atomicClass => j.memberExpression(memberExpression.value.object, j.identifier(atomicClass)))];
|
|
40
|
+
parent.expressions.splice(...atomicClassesArgs);
|
|
41
|
+
if (replacementSelector.includes(' > ')) {
|
|
42
|
+
const quasisArgs = [memberExpressionIndex, 1, j.templateElement({
|
|
43
|
+
raw: precedingTemplateElement.value.raw.replace(' ', ''),
|
|
44
|
+
cooked: precedingTemplateElement.value.cooked.replace(' ', '')
|
|
45
|
+
}, false), j.templateElement({
|
|
46
|
+
raw: ' > .',
|
|
47
|
+
cooked: ' > .'
|
|
48
|
+
}, false)];
|
|
49
|
+
if (atomicClasses.length === 3) {
|
|
50
|
+
quasisArgs.splice(3, 0, j.templateElement({
|
|
51
|
+
raw: '.',
|
|
52
|
+
cooked: '.'
|
|
53
|
+
}, false));
|
|
54
|
+
}
|
|
55
|
+
parent.quasis.splice(...quasisArgs);
|
|
56
|
+
} else {
|
|
57
|
+
parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
|
|
58
|
+
raw: precedingTemplateElement.value.raw,
|
|
59
|
+
cooked: precedingTemplateElement.value.cooked
|
|
60
|
+
}, false), j.templateElement({
|
|
61
|
+
raw: '.',
|
|
62
|
+
cooked: '.'
|
|
63
|
+
}, false));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}$`);
|
|
72
|
+
root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
|
|
73
|
+
path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`)));
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return root.toSource(printOptions);
|
|
77
|
+
}
|
|
@@ -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 _circularProgressClasses.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _circularProgressClasses = _interopRequireDefault(require("./circular-progress-classes"));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const classes = [{
|
|
4
|
+
deprecatedClass: ' .MuiCircularProgress-circleDeterminate',
|
|
5
|
+
replacementSelector: '.MuiCircularProgress-determinate > .MuiCircularProgress-circle'
|
|
6
|
+
}, {
|
|
7
|
+
deprecatedClass: ' .MuiCircularProgress-circleIndeterminate',
|
|
8
|
+
replacementSelector: '.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle'
|
|
9
|
+
}];
|
|
10
|
+
const plugin = () => {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: `Replace deprecated CircularProgress classes with new classes`,
|
|
13
|
+
Rule(rule) {
|
|
14
|
+
const {
|
|
15
|
+
selector
|
|
16
|
+
} = rule;
|
|
17
|
+
classes.forEach(({
|
|
18
|
+
deprecatedClass,
|
|
19
|
+
replacementSelector
|
|
20
|
+
}) => {
|
|
21
|
+
const selectorRegex = new RegExp(`${deprecatedClass}$`);
|
|
22
|
+
if (selector.match(selectorRegex)) {
|
|
23
|
+
rule.selector = selector.replace(selectorRegex, replacementSelector);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
plugin.postcss = true;
|
|
30
|
+
module.exports = {
|
|
31
|
+
plugin,
|
|
32
|
+
classes
|
|
33
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _CircularProgress = require("@mui/material/CircularProgress");
|
|
4
|
+
'& .MuiCircularProgress-circleDeterminate';
|
|
5
|
+
'& .MuiCircularProgress-circleIndeterminate';
|
|
6
|
+
`& .${_CircularProgress.circularProgressClasses.circleDeterminate}`;
|
|
7
|
+
`& .${_CircularProgress.circularProgressClasses.circleIndeterminate}`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _CircularProgress = require("@mui/material/CircularProgress");
|
|
4
|
+
"&.MuiCircularProgress-determinate > .MuiCircularProgress-circle";
|
|
5
|
+
"&.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle";
|
|
6
|
+
`&.${_CircularProgress.circularProgressClasses.determinate} > .${_CircularProgress.circularProgressClasses.circle}`;
|
|
7
|
+
`&.${_CircularProgress.circularProgressClasses.indeterminate} > .${_CircularProgress.circularProgressClasses.circle}`;
|
|
@@ -20,27 +20,30 @@ function transformer(file, api, options) {
|
|
|
20
20
|
root,
|
|
21
21
|
componentName: 'Divider'
|
|
22
22
|
}, elementPath => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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'))])
|
|
23
|
+
const hasLightProp = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'light') !== -1;
|
|
24
|
+
if (hasLightProp) {
|
|
25
|
+
elementPath.node.openingElement.attributes = elementPath.node.openingElement.attributes.filter(attr => {
|
|
26
|
+
if (attr.type === 'JSXAttribute' && attr.name.name === 'light') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
35
30
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
expression: j.literal('0.6')
|
|
31
|
+
const sxIndex = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'sx');
|
|
32
|
+
if (sxIndex === -1) {
|
|
33
|
+
(0, _appendAttribute.default)(j, {
|
|
34
|
+
target: elementPath.node,
|
|
35
|
+
attributeName: 'sx',
|
|
36
|
+
expression: j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])
|
|
43
37
|
});
|
|
38
|
+
} else {
|
|
39
|
+
const opacityIndex = elementPath.node.openingElement.attributes[sxIndex].value.expression.properties.findIndex(key => key.key.name === 'opacity');
|
|
40
|
+
if (opacityIndex === -1) {
|
|
41
|
+
(0, _assignObject.default)(j, {
|
|
42
|
+
target: elementPath.node.openingElement.attributes[sxIndex],
|
|
43
|
+
key: 'opacity',
|
|
44
|
+
expression: j.literal('0.6')
|
|
45
|
+
});
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
});
|
|
@@ -50,17 +53,20 @@ function transformer(file, api, options) {
|
|
|
50
53
|
}
|
|
51
54
|
}).forEach(path => {
|
|
52
55
|
const defaultPropsObject = path.value.value.properties.find(key => key.key.name === 'defaultProps');
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
defaultPropsObject.value.properties.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
defaultPropsObject.value.properties[sxIndex].value.properties.
|
|
56
|
+
const hasLightProp = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'light') !== -1;
|
|
57
|
+
if (hasLightProp) {
|
|
58
|
+
defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => {
|
|
59
|
+
var _prop$key;
|
|
60
|
+
return !['light'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
|
|
61
|
+
});
|
|
62
|
+
const sxIndex = defaultPropsObject.value.properties.findIndex(prop => prop.key.name === 'sx');
|
|
63
|
+
if (sxIndex === -1) {
|
|
64
|
+
defaultPropsObject.value.properties.push(j.objectProperty(j.identifier('sx'), j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])));
|
|
65
|
+
} else {
|
|
66
|
+
const opacityIndex = defaultPropsObject.value.properties[sxIndex].value.properties.findIndex(key => key.key.name === 'opacity');
|
|
67
|
+
if (opacityIndex === -1) {
|
|
68
|
+
defaultPropsObject.value.properties[sxIndex].value.properties.push(j.objectProperty(j.identifier('opacity'), j.literal('0.6')));
|
|
69
|
+
}
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.7",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"url": "https://opencollective.com/mui-org"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@babel/core": "^7.24.
|
|
28
|
-
"@babel/runtime": "^7.24.
|
|
29
|
-
"@babel/traverse": "^7.24.
|
|
27
|
+
"@babel/core": "^7.24.5",
|
|
28
|
+
"@babel/runtime": "^7.24.5",
|
|
29
|
+
"@babel/traverse": "^7.24.5",
|
|
30
30
|
"jscodeshift": "^0.15.2",
|
|
31
31
|
"jscodeshift-add-imports": "^1.0.10",
|
|
32
32
|
"postcss": "^8.4.38",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"yargs": "^17.7.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/chai": "^4.3.
|
|
37
|
+
"@types/chai": "^4.3.16",
|
|
38
38
|
"@types/jscodeshift": "0.11.11",
|
|
39
39
|
"chai": "^4.4.1"
|
|
40
40
|
},
|