@mui/codemod 5.10.16 → 5.10.17
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 +21 -0
- package/codemod.js +0 -0
- package/node/v5.0.0/joy-rename-components-to-slots.js +62 -0
- package/node/v5.0.0/joy-rename-components-to-slots.test/actual.js +51 -0
- package/node/v5.0.0/joy-rename-components-to-slots.test/expected.js +51 -0
- package/node/v5.0.0/theme-spacing.test/large-actual.js +2 -2
- package/node/v5.0.0/theme-spacing.test/large-expected.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,27 @@ npx @mui/codemod <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"
|
|
|
62
62
|
|
|
63
63
|
### v5.0.0
|
|
64
64
|
|
|
65
|
+
#### `joy-rename-components-to-slots`
|
|
66
|
+
|
|
67
|
+
Renames the `components` and `componentsProps` props to `slots` and `slotProps`, respectively.
|
|
68
|
+
|
|
69
|
+
This change only affects Joy UI components.
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
<Autocomplete
|
|
73
|
+
- components={{ listbox: CustomListbox }}
|
|
74
|
+
+ slots={{ listbox: CustomListbox }}
|
|
75
|
+
- componentsProps={{ root: { className: 'root' }, listbox: { 'data-testid': 'listbox' } }}
|
|
76
|
+
+ slotProps={{ root: { className: 'root' }, listbox: { 'data-testid': 'listbox' } }}
|
|
77
|
+
/>;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npx @mui/codemod v5.0.0/joy-rename-components-to-slots <path>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The associated breaking change was done in [#34997](https://github.com/mui/material-ui/pull/34997).
|
|
85
|
+
|
|
65
86
|
#### `date-pickers-moved-to-x`
|
|
66
87
|
|
|
67
88
|
Rename the imports of date and time pickers from `@mui/lab` to `@mui/x-date-pickers` and `@mui/x-date-pickers-pro`.
|
package/codemod.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
function transformComponentsProp(attributeNode) {
|
|
8
|
+
attributeNode.name.name = 'slots';
|
|
9
|
+
const valueExpression = attributeNode.value.expression;
|
|
10
|
+
if ((valueExpression == null ? void 0 : valueExpression.type) !== 'ObjectExpression') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
valueExpression.properties.forEach(property => {
|
|
14
|
+
property.key.name = property.key.name[0].toLowerCase() + property.key.name.slice(1);
|
|
15
|
+
if (property.shorthand) {
|
|
16
|
+
property.shorthand = false;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function transformComponentsPropsProp(attributeNode) {
|
|
21
|
+
attributeNode.name.name = 'slotProps';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
26
|
+
* @param {import('jscodeshift').API} api
|
|
27
|
+
*/
|
|
28
|
+
function transformer(file, api, options) {
|
|
29
|
+
const j = api.jscodeshift;
|
|
30
|
+
const root = j(file.source);
|
|
31
|
+
const printOptions = options.printOptions;
|
|
32
|
+
root.find(j.ImportDeclaration).filter(({
|
|
33
|
+
node
|
|
34
|
+
}) => {
|
|
35
|
+
return node.source.value.startsWith('@mui/joy');
|
|
36
|
+
}).forEach(path => {
|
|
37
|
+
path.node.specifiers.forEach(node => {
|
|
38
|
+
// Process only Joy UI components
|
|
39
|
+
root.findJSXElements(node.local.name).forEach(elementPath => {
|
|
40
|
+
if (elementPath.node.type !== 'JSXElement') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
elementPath.node.openingElement.attributes.forEach(elementNode => {
|
|
44
|
+
if (elementNode.type !== 'JSXAttribute') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
switch (elementNode.name.name) {
|
|
48
|
+
case 'components':
|
|
49
|
+
transformComponentsProp(elementNode);
|
|
50
|
+
break;
|
|
51
|
+
case 'componentsProps':
|
|
52
|
+
transformComponentsPropsProp(elementNode);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
const transformed = root.findJSXElements();
|
|
61
|
+
return transformed.toSource(printOptions);
|
|
62
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _joy = require("@mui/joy");
|
|
5
|
+
var _Autocomplete = _interopRequireDefault(require("@mui/joy/Autocomplete"));
|
|
6
|
+
var _Custom = _interopRequireDefault(require("components/Custom"));
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
// the codemod should transform only Joy UI components;
|
|
9
|
+
|
|
10
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
11
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_joy.Alert, {
|
|
12
|
+
components: {
|
|
13
|
+
Root,
|
|
14
|
+
Input: CustomInput
|
|
15
|
+
},
|
|
16
|
+
componentsProps: {
|
|
17
|
+
root: {
|
|
18
|
+
className: 'root'
|
|
19
|
+
},
|
|
20
|
+
input: {
|
|
21
|
+
'data-testid': 'input'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
25
|
+
components: {
|
|
26
|
+
Root,
|
|
27
|
+
Input: CustomInput
|
|
28
|
+
},
|
|
29
|
+
componentsProps: {
|
|
30
|
+
root: {
|
|
31
|
+
className: 'root'
|
|
32
|
+
},
|
|
33
|
+
input: {
|
|
34
|
+
'data-testid': 'input'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Custom.default, {
|
|
38
|
+
components: {
|
|
39
|
+
Root,
|
|
40
|
+
Input: CustomInput
|
|
41
|
+
},
|
|
42
|
+
componentsProps: {
|
|
43
|
+
root: {
|
|
44
|
+
className: 'root'
|
|
45
|
+
},
|
|
46
|
+
input: {
|
|
47
|
+
'data-testid': 'input'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _joy = require("@mui/joy");
|
|
5
|
+
var _Autocomplete = _interopRequireDefault(require("@mui/joy/Autocomplete"));
|
|
6
|
+
var _Custom = _interopRequireDefault(require("components/Custom"));
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
// the codemod should transform only Joy UI components;
|
|
9
|
+
|
|
10
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
11
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_joy.Alert, {
|
|
12
|
+
slots: {
|
|
13
|
+
root: Root,
|
|
14
|
+
input: CustomInput
|
|
15
|
+
},
|
|
16
|
+
slotProps: {
|
|
17
|
+
root: {
|
|
18
|
+
className: 'root'
|
|
19
|
+
},
|
|
20
|
+
input: {
|
|
21
|
+
'data-testid': 'input'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, {
|
|
25
|
+
slots: {
|
|
26
|
+
root: Root,
|
|
27
|
+
input: CustomInput
|
|
28
|
+
},
|
|
29
|
+
slotProps: {
|
|
30
|
+
root: {
|
|
31
|
+
className: 'root'
|
|
32
|
+
},
|
|
33
|
+
input: {
|
|
34
|
+
'data-testid': 'input'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Custom.default, {
|
|
38
|
+
components: {
|
|
39
|
+
Root,
|
|
40
|
+
Input: CustomInput
|
|
41
|
+
},
|
|
42
|
+
componentsProps: {
|
|
43
|
+
root: {
|
|
44
|
+
className: 'root'
|
|
45
|
+
},
|
|
46
|
+
input: {
|
|
47
|
+
'data-testid': 'input'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
@@ -23,7 +23,7 @@ var _KeyboardArrowRightRounded = _interopRequireDefault(require("@mui/icons-mate
|
|
|
23
23
|
var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
|
|
24
24
|
var _GlobalStyles = _interopRequireDefault(require("@mui/material/GlobalStyles"));
|
|
25
25
|
var _styles = require("@mui/material/styles");
|
|
26
|
-
var
|
|
26
|
+
var _config = require("docs/config");
|
|
27
27
|
var _Link = _interopRequireDefault(require("docs/src/modules/components/Link"));
|
|
28
28
|
var _i18n = require("docs/src/modules/utils/i18n");
|
|
29
29
|
var _useLazyCSS = _interopRequireDefault(require("docs/src/modules/utils/useLazyCSS"));
|
|
@@ -250,7 +250,7 @@ function AppSearch() {
|
|
|
250
250
|
const searchButtonRef = React.useRef(null);
|
|
251
251
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
252
252
|
const [initialQuery, setInitialQuery] = React.useState(undefined);
|
|
253
|
-
const facetFilterLanguage =
|
|
253
|
+
const facetFilterLanguage = _config.LANGUAGES_SSR.indexOf(userLanguage) !== -1 ? `language:${userLanguage}` : `language:en`;
|
|
254
254
|
const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
255
255
|
const onOpen = React.useCallback(() => {
|
|
256
256
|
setIsOpen(true);
|
|
@@ -23,7 +23,7 @@ var _KeyboardArrowRightRounded = _interopRequireDefault(require("@mui/icons-mate
|
|
|
23
23
|
var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
|
|
24
24
|
var _GlobalStyles = _interopRequireDefault(require("@mui/material/GlobalStyles"));
|
|
25
25
|
var _styles = require("@mui/material/styles");
|
|
26
|
-
var
|
|
26
|
+
var _config = require("docs/config");
|
|
27
27
|
var _Link = _interopRequireDefault(require("docs/src/modules/components/Link"));
|
|
28
28
|
var _i18n = require("docs/src/modules/utils/i18n");
|
|
29
29
|
var _useLazyCSS = _interopRequireDefault(require("docs/src/modules/utils/useLazyCSS"));
|
|
@@ -250,7 +250,7 @@ function AppSearch() {
|
|
|
250
250
|
const searchButtonRef = React.useRef(null);
|
|
251
251
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
252
252
|
const [initialQuery, setInitialQuery] = React.useState(undefined);
|
|
253
|
-
const facetFilterLanguage =
|
|
253
|
+
const facetFilterLanguage = _config.LANGUAGES_SSR.indexOf(userLanguage) !== -1 ? `language:${userLanguage}` : `language:en`;
|
|
254
254
|
const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
255
255
|
const onOpen = React.useCallback(() => {
|
|
256
256
|
setIsOpen(true);
|