@mui/codemod 5.11.6 → 5.11.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 +30 -0
- package/node/v5.0.0/joy-rename-classname-prefix.js +12 -0
- package/node/v5.0.0/joy-rename-classname-prefix.test/actual.js +13 -0
- package/node/v5.0.0/joy-rename-classname-prefix.test/expected.js +13 -0
- package/node/v5.0.0/joy-rename-row-prop.js +44 -0
- package/node/v5.0.0/joy-rename-row-prop.test/actual.js +21 -0
- package/node/v5.0.0/joy-rename-row-prop.test/expected.js +21 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -62,6 +62,36 @@ npx @mui/codemod <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"
|
|
|
62
62
|
|
|
63
63
|
### v5.0.0
|
|
64
64
|
|
|
65
|
+
#### `joy-rename-classname-prefix`
|
|
66
|
+
|
|
67
|
+
Renames the classname prefix from `'Joy'` to `'Mui'` for Joy UI components.
|
|
68
|
+
|
|
69
|
+
```diff
|
|
70
|
+
<Button
|
|
71
|
+
- sx={{ '& .JoyButton-root': { '& .JoyButton-button': {} } }}
|
|
72
|
+
+ sx={{ '& .MuiButton-root': { '& .MuiButton-button': {} } }}
|
|
73
|
+
/>;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
npx @mui/codemod v5.0.0/joy-rename-classname-prefix <path>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### `joy-rename-row-prop`
|
|
81
|
+
|
|
82
|
+
Transforms `row` prop to `orientation` prop across `Card`, `List` and `RadioGroup` components.
|
|
83
|
+
|
|
84
|
+
```diff
|
|
85
|
+
<Card
|
|
86
|
+
- row
|
|
87
|
+
+ orientation={"horizontal"}
|
|
88
|
+
/>;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npx @mui/codemod v5.0.0/joy-rename-row-prop <path>
|
|
93
|
+
```
|
|
94
|
+
|
|
65
95
|
#### `joy-avatar-remove-imgProps`
|
|
66
96
|
|
|
67
97
|
Remove `imgProps` prop by transferring its value into `slotProps.img`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
9
|
+
*/
|
|
10
|
+
function transformer(file) {
|
|
11
|
+
return file.source.replace(/Joy([A-Z]+)/gm, 'Mui$1');
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
5
|
+
className: "JoyButton-button"
|
|
6
|
+
});
|
|
7
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(Button, {
|
|
8
|
+
sx: {
|
|
9
|
+
'& .JoyButton-root': {
|
|
10
|
+
'& .JoyButton-button': {}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
5
|
+
className: "MuiButton-button"
|
|
6
|
+
});
|
|
7
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(Button, {
|
|
8
|
+
sx: {
|
|
9
|
+
'& .MuiButton-root': {
|
|
10
|
+
'& .MuiButton-button': {}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
9
|
+
* @param {import('jscodeshift').API} api
|
|
10
|
+
*/
|
|
11
|
+
function transformer(file, api, options) {
|
|
12
|
+
const j = api.jscodeshift;
|
|
13
|
+
const root = j(file.source);
|
|
14
|
+
const printOptions = options.printOptions;
|
|
15
|
+
root.find(j.ImportDeclaration).filter(({
|
|
16
|
+
node
|
|
17
|
+
}) => {
|
|
18
|
+
return node.source.value.startsWith('@mui/joy');
|
|
19
|
+
}).forEach(path => {
|
|
20
|
+
path.node.specifiers.forEach(node => {
|
|
21
|
+
// Process only Joy UI components
|
|
22
|
+
root.findJSXElements(node.local.name).forEach(elementPath => {
|
|
23
|
+
if (elementPath.node.type !== 'JSXElement') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
elementPath.node.openingElement.attributes.forEach(attributeNode => {
|
|
27
|
+
if (attributeNode.type !== 'JSXAttribute') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (attributeNode.name.name === 'row') {
|
|
31
|
+
var _val$expression;
|
|
32
|
+
const val = attributeNode.value;
|
|
33
|
+
if (val === null || (val == null ? void 0 : (_val$expression = val.expression) == null ? void 0 : _val$expression.value) === true) {
|
|
34
|
+
attributeNode.name.name = 'orientation';
|
|
35
|
+
attributeNode.value = j.jsxExpressionContainer(j.literal('horizontal'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
const transformed = root.findJSXElements();
|
|
43
|
+
return transformed.toSource(printOptions);
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _joy = require("@mui/joy");
|
|
5
|
+
var _Card = _interopRequireDefault(require("@mui/joy/Card"));
|
|
6
|
+
var _RadioGroup = _interopRequireDefault(require("@mui/joy/RadioGroup"));
|
|
7
|
+
var _Custom = _interopRequireDefault(require("components/Custom"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
// the codemod should transform only Joy UI components;
|
|
10
|
+
|
|
11
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
12
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.default, {
|
|
13
|
+
row: true
|
|
14
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_joy.List, {
|
|
15
|
+
row: true
|
|
16
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioGroup.default, {
|
|
17
|
+
row: true
|
|
18
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Custom.default, {
|
|
19
|
+
row: true
|
|
20
|
+
})]
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _joy = require("@mui/joy");
|
|
5
|
+
var _Card = _interopRequireDefault(require("@mui/joy/Card"));
|
|
6
|
+
var _RadioGroup = _interopRequireDefault(require("@mui/joy/RadioGroup"));
|
|
7
|
+
var _Custom = _interopRequireDefault(require("components/Custom"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
// the codemod should transform only Joy UI components;
|
|
10
|
+
|
|
11
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
12
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Card.default, {
|
|
13
|
+
orientation: "horizontal"
|
|
14
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_joy.List, {
|
|
15
|
+
orientation: "horizontal"
|
|
16
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioGroup.default, {
|
|
17
|
+
orientation: "horizontal"
|
|
18
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Custom.default, {
|
|
19
|
+
row: true
|
|
20
|
+
})]
|
|
21
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.9",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"url": "https://opencollective.com/mui"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@babel/core": "^7.20.
|
|
34
|
-
"@babel/runtime": "^7.20.
|
|
35
|
-
"@babel/traverse": "^7.20.
|
|
33
|
+
"@babel/core": "^7.20.12",
|
|
34
|
+
"@babel/runtime": "^7.20.13",
|
|
35
|
+
"@babel/traverse": "^7.20.13",
|
|
36
36
|
"jscodeshift": "^0.13.1",
|
|
37
37
|
"jscodeshift-add-imports": "^1.0.10",
|
|
38
38
|
"yargs": "^17.6.2"
|