@mui/codemod 5.12.0 → 5.12.3
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 +15 -0
- package/codemod.js +0 -0
- package/node/v5.0.0/base-remove-component-prop.js +78 -0
- package/node/v5.0.0/base-remove-component-prop.test/actual.js +49 -0
- package/node/v5.0.0/base-remove-component-prop.test/expected.js +57 -0
- package/node/v5.0.0/base-remove-unstyled-suffix.js +42 -0
- package/node/v5.0.0/base-remove-unstyled-suffix.test/actual.js +16 -0
- package/node/v5.0.0/base-remove-unstyled-suffix.test/expected.js +16 -0
- package/node/v5.0.0/grid-list-component.test/actual.js +0 -1
- package/node/v5.0.0/grid-list-component.test/expected.js +0 -1
- package/node/v5.0.0/jss-to-tss-react.test/actual-from-material-ui-core-styles.js +0 -1
- package/node/v5.0.0/jss-to-tss-react.test/actual-from-material-ui-core.js +7 -0
- package/node/v5.0.0/jss-to-tss-react.test/actual-todo-comments.js +7 -0
- package/node/v5.0.0/jss-to-tss-react.test/actual-typescript.js +1 -3
- package/node/v5.0.0/jss-to-tss-react.test/expected-from-material-ui-core-styles.js +0 -1
- package/node/v5.0.0/jss-to-tss-react.test/expected-from-material-ui-core.js +3 -0
- package/node/v5.0.0/jss-to-tss-react.test/expected-todo-comments.js +8 -1
- package/node/v5.0.0/mui-replace.test/actual.js +7 -1
- package/node/v5.0.0/mui-replace.test/expected.js +7 -1
- package/node/v5.0.0/preset-safe.test/expected.js +1 -2
- package/node/v5.0.0/root-ref.test/actual.js +1 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -62,6 +62,21 @@ npx @mui/codemod <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"
|
|
|
62
62
|
|
|
63
63
|
### v5.0.0
|
|
64
64
|
|
|
65
|
+
#### `base-remove-component-prop`
|
|
66
|
+
|
|
67
|
+
Remove `component` prop from all Base UI components by transferring its value into `slots.root`.
|
|
68
|
+
|
|
69
|
+
This change only affects Base UI components.
|
|
70
|
+
|
|
71
|
+
```diff
|
|
72
|
+
- <Input component={CustomRoot} />
|
|
73
|
+
+ <Input slots={{ root: CustomRoot }} />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
npx @mui/codemod v5.0.0/base-remove-component-prop <path>
|
|
78
|
+
```
|
|
79
|
+
|
|
65
80
|
#### `rename-css-variables`
|
|
66
81
|
|
|
67
82
|
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.
|
package/codemod.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
const transformed = root.find(j.ImportDeclaration)
|
|
16
|
+
// Process only Base UI components
|
|
17
|
+
.filter(({
|
|
18
|
+
node
|
|
19
|
+
}) => node.source.value.startsWith('@mui/base')).forEach(path => {
|
|
20
|
+
path.node.specifiers.forEach(elementNode => {
|
|
21
|
+
root.findJSXElements(elementNode.local.name).forEach(elementPath => {
|
|
22
|
+
if (elementPath.node.type !== 'JSXElement') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const attributeNodes = [];
|
|
26
|
+
let slotPropNodeInserted = false;
|
|
27
|
+
let slotsPropNode;
|
|
28
|
+
elementPath.node.openingElement.attributes.forEach(attributeNode => {
|
|
29
|
+
if (attributeNode.type !== 'JSXAttribute' && attributeNode.type !== 'JSXSpreadAttribute') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (attributeNode.type === 'JSXSpreadAttribute') {
|
|
33
|
+
attributeNodes.push(attributeNode);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const attributeName = attributeNode.name.name;
|
|
37
|
+
if (attributeName !== 'component' && attributeName !== 'slots') {
|
|
38
|
+
attributeNodes.push(attributeNode);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (attributeName === 'component') {
|
|
42
|
+
const valueNode = attributeNode.value.expression || attributeNode.value;
|
|
43
|
+
const rootObject = j.objectProperty(j.identifier('root'), valueNode);
|
|
44
|
+
if (slotsPropNode && slotsPropNode.value.expression) {
|
|
45
|
+
slotsPropNode.value.expression.properties.push(rootObject);
|
|
46
|
+
} else {
|
|
47
|
+
slotsPropNode = j.jsxAttribute(j.jsxIdentifier('slots'), j.jsxExpressionContainer(j.objectExpression([rootObject])));
|
|
48
|
+
if (!slotPropNodeInserted) {
|
|
49
|
+
slotPropNodeInserted = true;
|
|
50
|
+
attributeNodes.push(slotsPropNode);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (file.path.endsWith('.ts') || file.path.endsWith('.tsx')) {
|
|
54
|
+
if (valueNode.type === 'Literal' && valueNode.value && valueNode.raw) {
|
|
55
|
+
elementPath.node.openingElement.name.name += `<${valueNode.raw}>`;
|
|
56
|
+
} else if (valueNode.type === 'Identifier' && valueNode.name) {
|
|
57
|
+
elementPath.node.openingElement.name.name += `<typeof ${valueNode.name}>`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (attributeName === 'slots') {
|
|
62
|
+
if (slotsPropNode && slotsPropNode.value.expression && attributeNode.value.expression) {
|
|
63
|
+
slotsPropNode.value.expression.properties = [...slotsPropNode.value.expression.properties, ...attributeNode.value.expression.properties];
|
|
64
|
+
} else {
|
|
65
|
+
slotsPropNode = attributeNode;
|
|
66
|
+
}
|
|
67
|
+
if (!slotPropNodeInserted) {
|
|
68
|
+
slotPropNodeInserted = true;
|
|
69
|
+
attributeNodes.push(slotsPropNode);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
elementPath.node.openingElement.attributes = attributeNodes;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
return transformed.toSource(printOptions);
|
|
78
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _Input = _interopRequireDefault(require("@mui/material/Input"));
|
|
6
|
+
var _Input2 = _interopRequireDefault(require("@mui/base/Input"));
|
|
7
|
+
var _Switch = _interopRequireDefault(require("@mui/base/Switch"));
|
|
8
|
+
var _Badge = _interopRequireDefault(require("@mui/base/Badge"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
// @ts-nocheck
|
|
11
|
+
|
|
12
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
|
|
13
|
+
component: CustomRoot
|
|
14
|
+
});
|
|
15
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, {
|
|
16
|
+
component: CustomRoot
|
|
17
|
+
});
|
|
18
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, (0, _extends2.default)({
|
|
19
|
+
component: CustomRoot
|
|
20
|
+
}, others));
|
|
21
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
22
|
+
component: CustomRoot,
|
|
23
|
+
randomProp: "1",
|
|
24
|
+
randomProp2: "2",
|
|
25
|
+
randomProp3: "3",
|
|
26
|
+
slotProps: {
|
|
27
|
+
root: {
|
|
28
|
+
className: 'root'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
|
|
33
|
+
slots: {
|
|
34
|
+
badge: CustomBadge
|
|
35
|
+
},
|
|
36
|
+
component: CustomRoot,
|
|
37
|
+
randomProp: "1",
|
|
38
|
+
randomProp2: "2",
|
|
39
|
+
randomProp3: "3",
|
|
40
|
+
slotProps: {
|
|
41
|
+
badge: {
|
|
42
|
+
className: 'badge'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, {
|
|
47
|
+
component: "a",
|
|
48
|
+
href: "url"
|
|
49
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _Input = _interopRequireDefault(require("@mui/material/Input"));
|
|
6
|
+
var _Input2 = _interopRequireDefault(require("@mui/base/Input"));
|
|
7
|
+
var _Switch = _interopRequireDefault(require("@mui/base/Switch"));
|
|
8
|
+
var _Badge = _interopRequireDefault(require("@mui/base/Badge"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
// @ts-nocheck
|
|
11
|
+
|
|
12
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default, {
|
|
13
|
+
component: CustomRoot
|
|
14
|
+
});
|
|
15
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, {
|
|
16
|
+
slots: {
|
|
17
|
+
root: CustomRoot
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, (0, _extends2.default)({
|
|
21
|
+
slots: {
|
|
22
|
+
root: CustomRoot
|
|
23
|
+
}
|
|
24
|
+
}, others));
|
|
25
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
26
|
+
slots: {
|
|
27
|
+
root: CustomRoot
|
|
28
|
+
},
|
|
29
|
+
randomProp: "1",
|
|
30
|
+
randomProp2: "2",
|
|
31
|
+
randomProp3: "3",
|
|
32
|
+
slotProps: {
|
|
33
|
+
root: {
|
|
34
|
+
className: 'root'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
|
|
39
|
+
slots: {
|
|
40
|
+
badge: CustomBadge,
|
|
41
|
+
root: CustomRoot
|
|
42
|
+
},
|
|
43
|
+
randomProp: "1",
|
|
44
|
+
randomProp2: "2",
|
|
45
|
+
randomProp3: "3",
|
|
46
|
+
slotProps: {
|
|
47
|
+
badge: {
|
|
48
|
+
className: 'badge'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input2.default, {
|
|
53
|
+
slots: {
|
|
54
|
+
root: 'a'
|
|
55
|
+
},
|
|
56
|
+
href: "url"
|
|
57
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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) {
|
|
12
|
+
const j = api.jscodeshift;
|
|
13
|
+
const root = j(file.source);
|
|
14
|
+
const transformed = root.find(j.ImportDeclaration).filter(({
|
|
15
|
+
node
|
|
16
|
+
}) => {
|
|
17
|
+
const sourceVal = node.source.value;
|
|
18
|
+
if (sourceVal.startsWith('@mui/base')) {
|
|
19
|
+
node.source.value = sourceVal.replace(/unstyled/im, '');
|
|
20
|
+
node.source.raw = sourceVal.replace(/unstyled/im, '');
|
|
21
|
+
}
|
|
22
|
+
return sourceVal.startsWith('@mui/base');
|
|
23
|
+
}).forEach(path => {
|
|
24
|
+
const specifiers = [];
|
|
25
|
+
path.node.specifiers.forEach(elementNode => {
|
|
26
|
+
var _elementNode$imported;
|
|
27
|
+
const importedName = ((_elementNode$imported = elementNode.imported) == null ? void 0 : _elementNode$imported.name) || '';
|
|
28
|
+
if (elementNode.type === 'ImportSpecifier' && importedName.match(/unstyled/im)) {
|
|
29
|
+
elementNode.imported.name = importedName.replace(/unstyled/im, '');
|
|
30
|
+
if (elementNode.local.name === importedName) {
|
|
31
|
+
// specifier must be newly created to add "as";
|
|
32
|
+
// e.g., import { SwitchUnstyled } to import { Switch as SwitchUnstyled}
|
|
33
|
+
specifiers.push(j.importSpecifier(elementNode.imported, elementNode.local));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
specifiers.push(elementNode);
|
|
38
|
+
});
|
|
39
|
+
path.node.specifiers = specifiers;
|
|
40
|
+
}).toSource();
|
|
41
|
+
return transformed;
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _ButtonUnstyled2 = _interopRequireWildcard(require("@mui/base/ButtonUnstyled"));
|
|
5
|
+
var _base = require("@mui/base");
|
|
6
|
+
var _Slider = _interopRequireDefault(require("@mui/base/Slider"));
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _ButtonUnstyled, _SwitchUnstyled, _BaseInput, _BaseSlider;
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
function App() {
|
|
12
|
+
return;
|
|
13
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
14
|
+
children: [_ButtonUnstyled || (_ButtonUnstyled = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonUnstyled2.default, {})), ";", _SwitchUnstyled || (_SwitchUnstyled = /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.SwitchUnstyled, {})), ";", _BaseInput || (_BaseInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.InputUnstyled, {})), ";", _BaseSlider || (_BaseSlider = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider.default, {})), ";"]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _Button = _interopRequireWildcard(require("@mui/base/Button"));
|
|
5
|
+
var _base = require("@mui/base");
|
|
6
|
+
var _Slider = _interopRequireDefault(require("@mui/base/Slider"));
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _ButtonUnstyled, _SwitchUnstyled, _BaseInput, _BaseSlider;
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
function App() {
|
|
12
|
+
return;
|
|
13
|
+
/*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
14
|
+
children: [_ButtonUnstyled || (_ButtonUnstyled = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {})), ";", _SwitchUnstyled || (_SwitchUnstyled = /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.Switch, {})), ";", _BaseInput || (_BaseInput = /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.Input, {})), ";", _BaseSlider || (_BaseSlider = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Slider.default, {})), ";"]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -7,7 +7,6 @@ var _other = _interopRequireDefault(require("./other"));
|
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
// import GridList from '@material-ui/core/GridList';
|
|
9
9
|
// import GridListTile from '@material-ui/core/GridListTile';
|
|
10
|
-
|
|
11
10
|
/*#__PURE__*/(0, _jsxRuntime.jsxs)(_core.GridList, {
|
|
12
11
|
cellHeight: "auto",
|
|
13
12
|
cols: numOfCols,
|
|
@@ -7,7 +7,6 @@ var _other = _interopRequireDefault(require("./other"));
|
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
// import ImageList from '@material-ui/core/ImageList';
|
|
9
9
|
// import ImageListItem from '@material-ui/core/ImageListItem';
|
|
10
|
-
|
|
11
10
|
/*#__PURE__*/(0, _jsxRuntime.jsxs)(_core.ImageList, {
|
|
12
11
|
cellHeight: "auto",
|
|
13
12
|
cols: numOfCols,
|
|
@@ -14,7 +14,6 @@ Sandboxes for verifying correct behavior:
|
|
|
14
14
|
JSS - https://codesandbox.io/s/case1-jss-dedp2f?file=/src/App.js
|
|
15
15
|
TSS - https://codesandbox.io/s/case1-tss-s0z7tx?file=/src/App.js
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
17
|
const useStyles = (0, _styles.makeStyles)({
|
|
19
18
|
test: {
|
|
20
19
|
backgroundColor: "purple",
|
|
@@ -10,6 +10,13 @@ var _core = require("@material-ui/core");
|
|
|
10
10
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
var _InnerComponent;
|
|
13
|
+
/*
|
|
14
|
+
Test makeStyles comment
|
|
15
|
+
*/
|
|
16
|
+
/*
|
|
17
|
+
clsx comment that will not be preserved since the import is being removed (not just replaced)
|
|
18
|
+
and is not at the beginning of the file.
|
|
19
|
+
*/
|
|
13
20
|
const useStyles = (0, _core.makeStyles)(() => ({
|
|
14
21
|
test: {
|
|
15
22
|
backgroundColor: "purple",
|
|
@@ -10,6 +10,13 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _core = require("@material-ui/core");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
var _InnerComponent;
|
|
13
|
+
/*
|
|
14
|
+
Comments to be preserved when clsx import is removed. These comments should come before
|
|
15
|
+
any comments that they get combined with.
|
|
16
|
+
*/
|
|
17
|
+
/*
|
|
18
|
+
Comments that should not be lost when the clsx import comments are preserved.
|
|
19
|
+
*/
|
|
13
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
22
|
const useStyles = (0, _core.makeStyles)(() => ({
|
|
@@ -14,9 +14,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
Sandboxes for verifying correct behavior:
|
|
15
15
|
JSS - https://codesandbox.io/s/typescript-case-bt065c?file=/demo.tsx
|
|
16
16
|
TSS - https://codesandbox.io/s/typescript-case-7jwpms?file=/demo.tsx
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const useStyles = (0, _styles.makeStyles)(theme => (0, _styles.createStyles)({
|
|
17
|
+
*/const useStyles = (0, _styles.makeStyles)(theme => (0, _styles.createStyles)({
|
|
20
18
|
test: {
|
|
21
19
|
backgroundColor: "purple",
|
|
22
20
|
color: "white",
|
|
@@ -9,6 +9,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _mui = require("tss-react/mui");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var _InnerComponent;
|
|
12
|
+
/*
|
|
13
|
+
Test makeStyles comment
|
|
14
|
+
*/
|
|
12
15
|
const useStyles = (0, _mui.makeStyles)()((_theme, _params, classes) => ({
|
|
13
16
|
test: {
|
|
14
17
|
backgroundColor: "purple",
|
|
@@ -8,9 +8,16 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _mui = require("tss-react/mui");
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
var _InnerComponent;
|
|
11
|
+
/*
|
|
12
|
+
Comments to be preserved when clsx import is removed. These comments should come before
|
|
13
|
+
any comments that they get combined with.
|
|
14
|
+
*/
|
|
15
|
+
/*
|
|
16
|
+
Comments that should not be lost when the clsx import comments are preserved.
|
|
17
|
+
*/
|
|
18
|
+
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.
|
|
11
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.
|
|
14
21
|
const useStyles = (0, _mui.makeStyles)()((_theme, _params, classes) => ({
|
|
15
22
|
test: {
|
|
16
23
|
backgroundColor: "purple",
|
|
@@ -31,8 +31,7 @@ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
|
31
31
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
32
32
|
var _colors = require("@mui/material/colors");
|
|
33
33
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
34
|
-
var _Box, _Box2, _CssBaseline, _Header, _Box3, _Grid, _DialogTitle, _DialogContent;
|
|
35
|
-
// FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
|
|
34
|
+
var _Box, _Box2, _CssBaseline, _Header, _Box3, _Grid, _DialogTitle, _DialogContent; // FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
|
|
36
35
|
const withWidth = () => WrappedComponent => props => /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, (0, _extends2.default)({}, props, {
|
|
37
36
|
width: "xs"
|
|
38
37
|
}));
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _RootRef = _interopRequireDefault(require("@material-ui/core/RootRef"));
|
|
5
5
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
6
|
-
var _Typography, _CssBaseline;
|
|
7
|
-
// import { RootRef } from '@material-ui/core';
|
|
6
|
+
var _Typography, _CssBaseline; // import { RootRef } from '@material-ui/core';
|
|
8
7
|
// import { RootRef, Button } from '@material-ui/core';
|
|
9
8
|
// import { Tooltip, RootRef, Button } from '@material-ui/core';
|
|
10
|
-
|
|
11
9
|
function App() {
|
|
12
10
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_RootRef.default, {
|
|
13
11
|
rootRef: this.container,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.3",
|
|
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.21.
|
|
33
|
+
"@babel/core": "^7.21.4",
|
|
34
34
|
"@babel/runtime": "^7.21.0",
|
|
35
|
-
"@babel/traverse": "^7.21.
|
|
35
|
+
"@babel/traverse": "^7.21.4",
|
|
36
36
|
"jscodeshift": "^0.13.1",
|
|
37
37
|
"jscodeshift-add-imports": "^1.0.10",
|
|
38
38
|
"yargs": "^17.7.1"
|