@mui/codemod 7.0.0-rc.0 → 7.0.2
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 +61 -25
- package/deprecations/all/deprecations-all.js +2 -0
- package/deprecations/dialog-classes/dialog-classes.js +69 -0
- package/deprecations/dialog-classes/index.js +13 -0
- package/deprecations/dialog-classes/postcss-plugin.js +33 -0
- package/deprecations/dialog-classes/postcss.config.js +8 -0
- package/deprecations/dialog-classes/test-cases/actual.js +7 -0
- package/deprecations/dialog-classes/test-cases/expected.js +7 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Some of the codemods also run [postcss](https://github.com/postcss/postcss) plug
|
|
|
14
14
|
<!-- #npm-tag-reference -->
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npx @mui/codemod
|
|
17
|
+
npx @mui/codemod <codemod> <paths...>
|
|
18
18
|
|
|
19
19
|
Applies a `@mui/codemod` to the specified paths
|
|
20
20
|
|
|
@@ -393,6 +393,10 @@ npx @mui/codemod@latest deprecations/avatar-group-props <path>
|
|
|
393
393
|
/>
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
+
```bash
|
|
397
|
+
npx @mui/codemod@latest deprecations/avatar-props <path>
|
|
398
|
+
```
|
|
399
|
+
|
|
396
400
|
#### `backdrop-props`
|
|
397
401
|
|
|
398
402
|
```diff
|
|
@@ -1033,6 +1037,42 @@ npx @mui/codemod@latest deprecations/circular-progress-classes <path>
|
|
|
1033
1037
|
npx @mui/codemod@latest deprecations/divider-props <path>
|
|
1034
1038
|
```
|
|
1035
1039
|
|
|
1040
|
+
#### `dialog-classes`
|
|
1041
|
+
|
|
1042
|
+
JS transforms:
|
|
1043
|
+
|
|
1044
|
+
```diff
|
|
1045
|
+
import { dialogClasses } from '@mui/material/Dialog';
|
|
1046
|
+
|
|
1047
|
+
MuiDialog: {
|
|
1048
|
+
styleOverrides: {
|
|
1049
|
+
root: {
|
|
1050
|
+
- [`& .${dialogClasses.paperScrollBody}`]: {
|
|
1051
|
+
+ [`& .${dialogClasses.scrollBody} > .${dialogClasses.paper}`]: {
|
|
1052
|
+
color: 'red',
|
|
1053
|
+
},
|
|
1054
|
+
- [`& .${dialogClasses.paperScrollPaper}`]: {
|
|
1055
|
+
+ [`& .${dialogClasses.scrollPaper} > .${dialogClasses.paper}`]: {
|
|
1056
|
+
color: 'red',
|
|
1057
|
+
},
|
|
1058
|
+
},
|
|
1059
|
+
},
|
|
1060
|
+
},
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
CSS transforms:
|
|
1064
|
+
|
|
1065
|
+
```diff
|
|
1066
|
+
-.MuiDialog-root .MuiDialog-paperScrollBody
|
|
1067
|
+
+.MuiDialog-root .MuiDialog-scrollBody > .MuiDialog-paper
|
|
1068
|
+
-.MuiDialog-root .MuiDialog-paperScrollPaper
|
|
1069
|
+
+.MuiDialog-root .MuiDialog-scrollPaper > .MuiDialog-paper
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
```bash
|
|
1073
|
+
npx @mui/codemod@latest deprecations/dialog-classes <path>
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1036
1076
|
#### `drawer-classes`
|
|
1037
1077
|
|
|
1038
1078
|
JS transforms:
|
|
@@ -1609,7 +1649,7 @@ npx @mui/codemod@latest deprecations/outlined-input-props <path>
|
|
|
1609
1649
|
#### `rating-props`
|
|
1610
1650
|
|
|
1611
1651
|
```diff
|
|
1612
|
-
<
|
|
1652
|
+
<Rating
|
|
1613
1653
|
- IconContainerComponent={CustomContainer}
|
|
1614
1654
|
+ slots={{
|
|
1615
1655
|
+ icon: { component: CustomContainer }
|
|
@@ -1618,7 +1658,7 @@ npx @mui/codemod@latest deprecations/outlined-input-props <path>
|
|
|
1618
1658
|
```
|
|
1619
1659
|
|
|
1620
1660
|
```bash
|
|
1621
|
-
npx @mui/codemod
|
|
1661
|
+
npx @mui/codemod deprecations/rating-props <path>
|
|
1622
1662
|
```
|
|
1623
1663
|
|
|
1624
1664
|
#### `select-classes`
|
|
@@ -1713,7 +1753,7 @@ npx @mui/codemod@latest deprecations/slider-props <path>
|
|
|
1713
1753
|
```
|
|
1714
1754
|
|
|
1715
1755
|
```bash
|
|
1716
|
-
npx @mui/codemod
|
|
1756
|
+
npx @mui/codemod deprecations/snackbar-props <path>
|
|
1717
1757
|
```
|
|
1718
1758
|
|
|
1719
1759
|
#### `slider-classes`
|
|
@@ -1861,8 +1901,20 @@ JS transforms:
|
|
|
1861
1901
|
},
|
|
1862
1902
|
```
|
|
1863
1903
|
|
|
1904
|
+
CSS transforms:
|
|
1905
|
+
|
|
1906
|
+
```diff
|
|
1907
|
+
-.MuiStepConnector-lineHorizontal
|
|
1908
|
+
+.MuiStepConnector-horizontal > .MuiStepConnector-line
|
|
1909
|
+
```
|
|
1910
|
+
|
|
1911
|
+
```diff
|
|
1912
|
+
-.MuiStepConnector-lineVertical
|
|
1913
|
+
+.MuiStepConnector-vertical > .MuiStepConnector-line
|
|
1914
|
+
```
|
|
1915
|
+
|
|
1864
1916
|
```bash
|
|
1865
|
-
npx @mui/codemod
|
|
1917
|
+
npx @mui/codemod deprecations/step-connector-classes <path>
|
|
1866
1918
|
```
|
|
1867
1919
|
|
|
1868
1920
|
#### `step-content-props`
|
|
@@ -1972,22 +2024,6 @@ CSS transforms:
|
|
|
1972
2024
|
npx @mui/codemod@latest deprecations/toggle-button-group-classes <path>
|
|
1973
2025
|
```
|
|
1974
2026
|
|
|
1975
|
-
CSS transforms:
|
|
1976
|
-
|
|
1977
|
-
```diff
|
|
1978
|
-
-.MuiStepConnector-lineHorizontal
|
|
1979
|
-
+.MuiStepConnector-horizontal > .MuiStepConnector-line
|
|
1980
|
-
```
|
|
1981
|
-
|
|
1982
|
-
```diff
|
|
1983
|
-
-.MuiStepConnector-lineVertical
|
|
1984
|
-
+.MuiStepConnector-vertical > .MuiStepConnector-line
|
|
1985
|
-
```
|
|
1986
|
-
|
|
1987
|
-
```bash
|
|
1988
|
-
npx @mui/codemod@latest deprecations/step-connector-classes <path>
|
|
1989
|
-
```
|
|
1990
|
-
|
|
1991
2027
|
#### `tab-classes`
|
|
1992
2028
|
|
|
1993
2029
|
JS transforms:
|
|
@@ -2093,7 +2129,7 @@ npx @mui/codemod@latest deprecations/typography-props <path>
|
|
|
2093
2129
|
<!-- #npm-tag-reference -->
|
|
2094
2130
|
|
|
2095
2131
|
```bash
|
|
2096
|
-
npx @mui/codemod
|
|
2132
|
+
npx @mui/codemod v7.0.0/grid-props <path>
|
|
2097
2133
|
```
|
|
2098
2134
|
|
|
2099
2135
|
Updates the usage of the `@mui/material/Grid`, `@mui/system/Grid`, and `@mui/joy/Grid` components to their updated APIs.
|
|
@@ -2114,7 +2150,7 @@ You can provide the theme breakpoints via options, for example, `--jscodeshift='
|
|
|
2114
2150
|
<!-- #npm-tag-reference -->
|
|
2115
2151
|
|
|
2116
2152
|
```bash
|
|
2117
|
-
npx @mui/codemod
|
|
2153
|
+
npx @mui/codemod v7.0.0/grid-props <path> --jscodeshift='--muiBreakpoints=mobile,desktop'
|
|
2118
2154
|
```
|
|
2119
2155
|
|
|
2120
2156
|
```diff
|
|
@@ -2127,7 +2163,7 @@ npx @mui/codemod@next v7.0.0/grid-props <path> --jscodeshift='--muiBreakpoints=m
|
|
|
2127
2163
|
<!-- #npm-tag-reference -->
|
|
2128
2164
|
|
|
2129
2165
|
```bash
|
|
2130
|
-
npx @mui/codemod
|
|
2166
|
+
npx @mui/codemod v7.0.0/lab-removed-components <path>
|
|
2131
2167
|
```
|
|
2132
2168
|
|
|
2133
2169
|
Update the import of the following components and hook moved from `@mui/lab` to `@mui/material`:
|
|
@@ -2173,7 +2209,7 @@ Updates the `InputLabel`'s `size` value from `normal` to `medium`.
|
|
|
2173
2209
|
<!-- #npm-tag-reference -->
|
|
2174
2210
|
|
|
2175
2211
|
```bash
|
|
2176
|
-
npx @mui/codemod
|
|
2212
|
+
npx @mui/codemod v7.0.0/input-label-size-normal-medium <path>
|
|
2177
2213
|
```
|
|
2178
2214
|
|
|
2179
2215
|
<!-- #host-reference -->
|
|
@@ -19,6 +19,7 @@ var _chipClasses = _interopRequireDefault(require("../chip-classes"));
|
|
|
19
19
|
var _circularProgressClasses = _interopRequireDefault(require("../circular-progress-classes"));
|
|
20
20
|
var _dividerProps = _interopRequireDefault(require("../divider-props"));
|
|
21
21
|
var _drawerClasses = _interopRequireDefault(require("../drawer-classes"));
|
|
22
|
+
var _dialogClasses = _interopRequireDefault(require("../dialog-classes"));
|
|
22
23
|
var _filledInputProps = _interopRequireDefault(require("../filled-input-props"));
|
|
23
24
|
var _formControlLabelProps = _interopRequireDefault(require("../form-control-label-props"));
|
|
24
25
|
var _imageListItemBarClasses = _interopRequireDefault(require("../image-list-item-bar-classes"));
|
|
@@ -74,6 +75,7 @@ function deprecationsAll(file, api, options) {
|
|
|
74
75
|
file.source = (0, _circularProgressClasses.default)(file, api, options);
|
|
75
76
|
file.source = (0, _dividerProps.default)(file, api, options);
|
|
76
77
|
file.source = (0, _drawerClasses.default)(file, api, options);
|
|
78
|
+
file.source = (0, _dialogClasses.default)(file, api, options);
|
|
77
79
|
file.source = (0, _filledInputProps.default)(file, api, options);
|
|
78
80
|
file.source = (0, _formControlLabelProps.default)(file, api, options);
|
|
79
81
|
file.source = (0, _imageListItemBarClasses.default)(file, api, options);
|
|
@@ -0,0 +1,69 @@
|
|
|
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\/Dialog$/)).forEach(path => {
|
|
22
|
+
path.node.specifiers.forEach(specifier => {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'dialogClasses') {
|
|
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('MuiDialog-', '').replaceAll(replacementSelectorPrefix, '').replaceAll(' > ', '').replaceAll(' ', '').split('.').filter(Boolean);
|
|
38
|
+
if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
|
|
39
|
+
parent.expressions.splice(memberExpressionIndex, 1, j.memberExpression(memberExpression.value.object, j.identifier(atomicClasses[0])), j.memberExpression(memberExpression.value.object, j.identifier(atomicClasses[1])));
|
|
40
|
+
if (replacementSelector.includes(' > ')) {
|
|
41
|
+
parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
|
|
42
|
+
raw: precedingTemplateElement.value.raw,
|
|
43
|
+
cooked: precedingTemplateElement.value.cooked
|
|
44
|
+
}, false), j.templateElement({
|
|
45
|
+
raw: ' > .',
|
|
46
|
+
cooked: ' > .'
|
|
47
|
+
}, false));
|
|
48
|
+
} else {
|
|
49
|
+
parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
|
|
50
|
+
raw: precedingTemplateElement.value.raw,
|
|
51
|
+
cooked: precedingTemplateElement.value.cooked
|
|
52
|
+
}, false), j.templateElement({
|
|
53
|
+
raw: '.',
|
|
54
|
+
cooked: '.'
|
|
55
|
+
}, false));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
const selectorRegex = new RegExp(`^${replacementSelectorPrefix}${deprecatedClass}`);
|
|
64
|
+
root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
|
|
65
|
+
path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${deprecatedClass.startsWith(' ') ? ' ' : ''}${replacementSelector.trim()}`)));
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
return root.toSource(printOptions);
|
|
69
|
+
}
|
|
@@ -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 _dialogClasses.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _dialogClasses = _interopRequireDefault(require("./dialog-classes"));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const classes = [{
|
|
4
|
+
deprecatedClass: ' .MuiDialog-paperScrollBody',
|
|
5
|
+
replacementSelector: ' .MuiDialog-scrollBody > .MuiDialog-paper'
|
|
6
|
+
}, {
|
|
7
|
+
deprecatedClass: ' .MuiDialog-paperScrollPaper',
|
|
8
|
+
replacementSelector: ' .MuiDialog-scrollPaper > .MuiDialog-paper'
|
|
9
|
+
}];
|
|
10
|
+
const plugin = () => {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: `Replace deprecated Dialog 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 _Dialog = require("@mui/material/Dialog");
|
|
4
|
+
"& .MuiDialog-scrollBody > .MuiDialog-paper";
|
|
5
|
+
"& .MuiDialog-scrollPaper > .MuiDialog-paper";
|
|
6
|
+
`& .${_Dialog.dialogClasses.scrollBody} > .${_Dialog.dialogClasses.paper}`;
|
|
7
|
+
`& .${_Dialog.dialogClasses.scrollPaper} > .${_Dialog.dialogClasses.paper}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/core": "^7.26.10",
|
|
28
|
-
"@babel/runtime": "^7.
|
|
29
|
-
"@babel/traverse": "^7.
|
|
28
|
+
"@babel/runtime": "^7.27.0",
|
|
29
|
+
"@babel/traverse": "^7.27.0",
|
|
30
30
|
"jscodeshift": "^17.1.2",
|
|
31
31
|
"jscodeshift-add-imports": "^1.0.11",
|
|
32
32
|
"postcss": "^8.5.3",
|