@mui/codemod 6.0.0-beta.5 → 6.0.0-beta.6
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 +0 -1
- package/node/deprecations/avatar-group-props/avatar-group-props.js +2 -8
- package/node/deprecations/divider-props/divider-props.js +2 -4
- package/node/deprecations/typography-props/typography-props.js +3 -8
- package/node/deprecations/utils/movePropIntoSlotProps.js +4 -12
- package/node/deprecations/utils/movePropIntoSlots.js +4 -12
- package/node/deprecations/utils/replaceComponentsWithSlots.js +3 -8
- package/node/util/getReturnExpression.js +1 -2
- package/node/util/migrateToVariants.js +13 -24
- package/node/util/propsToObject.js +2 -6
- package/node/util/renameClassKey.js +1 -2
- package/node/v5.0.0/avatar-circle-circular.js +2 -4
- package/node/v5.0.0/badge-overlap-value.js +4 -7
- package/node/v5.0.0/base-hook-imports.js +1 -2
- package/node/v5.0.0/base-remove-unstyled-suffix.js +1 -2
- package/node/v5.0.0/base-rename-components-to-slots.js +1 -1
- package/node/v5.0.0/base-use-named-exports.js +5 -8
- package/node/v5.0.0/box-sx-prop.js +1 -2
- package/node/v5.0.0/button-color-prop.js +1 -2
- package/node/v5.0.0/chip-variant-prop.js +1 -2
- package/node/v5.0.0/circularprogress-variant.js +2 -4
- package/node/v5.0.0/fab-variant.js +2 -4
- package/node/v5.0.0/grid-list-component.test/actual.js +1 -1
- package/node/v5.0.0/grid-list-component.test/expected.js +1 -1
- package/node/v5.0.0/joy-avatar-remove-imgProps.js +3 -7
- package/node/v5.0.0/joy-rename-components-to-slots.js +1 -1
- package/node/v5.0.0/joy-rename-row-prop.js +1 -2
- package/node/v5.0.0/joy-text-field-to-input.js +4 -7
- package/node/v5.0.0/jss-to-tss-react.js +4 -6
- package/node/v5.0.0/link-underline-hover.js +1 -4
- package/node/v5.0.0/pagination-round-circular.js +3 -8
- package/node/v5.0.0/skeleton-variant.js +3 -5
- package/node/v5.0.0/table-props.js +4 -9
- package/node/v5.0.0/tabs-scroll-buttons.js +4 -5
- package/node/v6.0.0/grid-v2-props/grid-v2-props.js +4 -11
- package/node/v6.0.0/list-item-button-prop/list-item-button-prop.js +1 -2
- package/node/v6.0.0/styled/test-cases/NestedSpread.actual.js +2 -3
- package/node/v6.0.0/styled/test-cases/NestedSpread.expected.js +2 -3
- package/node/v6.0.0/sx-prop/sx-v6.js +18 -34
- package/node/v6.0.0/sx-prop/test-cases/sx-condition.actual.js +3 -4
- package/node/v6.0.0/sx-prop/test-cases/sx-condition.expected.js +3 -4
- package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.actual.js +17 -0
- package/node/v6.0.0/sx-prop/test-cases/sx-inheritance.expected.js +17 -0
- package/node/v6.0.0/system-props/removeSystemProps.js +10 -19
- package/node/v6.0.0/theme-v6/theme-v6.js +2 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,15 +29,9 @@ function transformer(file, api, options) {
|
|
|
29
29
|
const slotPropsIndex = elementPath.node.openingElement.attributes.findIndex(attr => attr.type === 'JSXAttribute' && attr.name.name === 'slotProps');
|
|
30
30
|
if (slotPropsIndex !== -1) {
|
|
31
31
|
const slotProps = elementPath.node.openingElement.attributes[slotPropsIndex].value.expression;
|
|
32
|
-
const additionalAvatarIndex = slotProps.properties.findIndex(prop =>
|
|
33
|
-
var _prop$key;
|
|
34
|
-
return (prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name) === 'additionalAvatar';
|
|
35
|
-
});
|
|
32
|
+
const additionalAvatarIndex = slotProps.properties.findIndex(prop => prop?.key?.name === 'additionalAvatar');
|
|
36
33
|
if (additionalAvatarIndex !== -1) {
|
|
37
|
-
const surplusIndex = slotProps.properties.findIndex(prop =>
|
|
38
|
-
var _prop$key2;
|
|
39
|
-
return (prop == null || (_prop$key2 = prop.key) == null ? void 0 : _prop$key2.name) === 'surplus';
|
|
40
|
-
});
|
|
34
|
+
const surplusIndex = slotProps.properties.findIndex(prop => prop?.key?.name === 'surplus');
|
|
41
35
|
const removedValue = slotProps.properties.splice(additionalAvatarIndex, 1)[0].value;
|
|
42
36
|
if (surplusIndex === -1) {
|
|
43
37
|
(0, _assignObject.default)(j, {
|
|
@@ -21,7 +21,6 @@ function transformer(file, api, options) {
|
|
|
21
21
|
root,
|
|
22
22
|
componentName: 'Divider'
|
|
23
23
|
}, elementPath => {
|
|
24
|
-
var _lightProp$value;
|
|
25
24
|
const lightProp = elementPath.node.openingElement.attributes.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'light');
|
|
26
25
|
if (!lightProp) {
|
|
27
26
|
return;
|
|
@@ -32,7 +31,7 @@ function transformer(file, api, options) {
|
|
|
32
31
|
}
|
|
33
32
|
return true;
|
|
34
33
|
});
|
|
35
|
-
const isLightPropTruthy =
|
|
34
|
+
const isLightPropTruthy = lightProp.value?.expression.value !== false;
|
|
36
35
|
if (!isLightPropTruthy) {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
@@ -63,11 +62,10 @@ function transformer(file, api, options) {
|
|
|
63
62
|
name: 'light'
|
|
64
63
|
}
|
|
65
64
|
}).forEach(path => {
|
|
66
|
-
var _path$value;
|
|
67
65
|
const {
|
|
68
66
|
properties: defaultPropsProperties
|
|
69
67
|
} = path.parent.value;
|
|
70
|
-
if (
|
|
68
|
+
if (path.value?.value.value === false) {
|
|
71
69
|
path.prune();
|
|
72
70
|
return;
|
|
73
71
|
}
|
|
@@ -20,7 +20,6 @@ function transformer(file, api, options) {
|
|
|
20
20
|
root,
|
|
21
21
|
componentName: 'Typography'
|
|
22
22
|
}, elementPath => {
|
|
23
|
-
var _paragraphProp$value;
|
|
24
23
|
const paragraphProp = elementPath.node.openingElement.attributes.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'paragraph');
|
|
25
24
|
if (!paragraphProp) {
|
|
26
25
|
return;
|
|
@@ -31,7 +30,7 @@ function transformer(file, api, options) {
|
|
|
31
30
|
}
|
|
32
31
|
return true;
|
|
33
32
|
});
|
|
34
|
-
const isParagraphPropTruthy =
|
|
33
|
+
const isParagraphPropTruthy = paragraphProp.value?.expression.value !== false;
|
|
35
34
|
if (!isParagraphPropTruthy) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
@@ -58,17 +57,13 @@ function transformer(file, api, options) {
|
|
|
58
57
|
name: 'MuiTypography'
|
|
59
58
|
}
|
|
60
59
|
}).forEach(path => {
|
|
61
|
-
var _paragraphProp$value2;
|
|
62
60
|
const defaultPropsObject = path.value.value.properties.find(key => key.key.name === 'defaultProps');
|
|
63
61
|
const paragraphProp = defaultPropsObject.value.properties.find(prop => prop.key.name === 'paragraph');
|
|
64
62
|
if (!paragraphProp) {
|
|
65
63
|
return;
|
|
66
64
|
}
|
|
67
|
-
defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop =>
|
|
68
|
-
|
|
69
|
-
return !['paragraph'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
|
|
70
|
-
});
|
|
71
|
-
const isParagraphPropTruthy = ((_paragraphProp$value2 = paragraphProp.value) == null ? void 0 : _paragraphProp$value2.value) !== false;
|
|
65
|
+
defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => !['paragraph'].includes(prop?.key?.name));
|
|
66
|
+
const isParagraphPropTruthy = paragraphProp.value?.value !== false;
|
|
72
67
|
if (!isParagraphPropTruthy) {
|
|
73
68
|
return;
|
|
74
69
|
}
|
|
@@ -15,14 +15,10 @@ function moveJsxPropIntoSlotProps(j, element, propName, slotName) {
|
|
|
15
15
|
const removedValue = element.openingElement.attributes.splice(propIndex, 1)[0].value.expression;
|
|
16
16
|
let hasSlotProps = false;
|
|
17
17
|
element.openingElement.attributes.forEach(attr => {
|
|
18
|
-
|
|
19
|
-
if (((_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'slotProps') {
|
|
18
|
+
if (attr.name?.name === 'slotProps') {
|
|
20
19
|
hasSlotProps = true;
|
|
21
20
|
const slots = attr.value.expression;
|
|
22
|
-
const slotIndex = slots.properties.findIndex(prop =>
|
|
23
|
-
var _prop$key;
|
|
24
|
-
return (prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name) === slotName;
|
|
25
|
-
});
|
|
21
|
+
const slotIndex = slots.properties.findIndex(prop => prop?.key?.name === slotName);
|
|
26
22
|
if (slotIndex === -1) {
|
|
27
23
|
(0, _assignObject.default)(j, {
|
|
28
24
|
target: attr,
|
|
@@ -58,13 +54,9 @@ function moveDefaultPropsPropIntoslotProps(j, defaultPropsPathCollection, propNa
|
|
|
58
54
|
const defaultProps = path.parent.value;
|
|
59
55
|
let hasSlotProps = false;
|
|
60
56
|
defaultProps.properties.forEach(property => {
|
|
61
|
-
|
|
62
|
-
if (((_property$key = property.key) == null ? void 0 : _property$key.name) === 'slotProps') {
|
|
57
|
+
if (property.key?.name === 'slotProps') {
|
|
63
58
|
hasSlotProps = true;
|
|
64
|
-
const slotIndex = property.value.properties.findIndex(prop =>
|
|
65
|
-
var _prop$key2;
|
|
66
|
-
return (prop == null || (_prop$key2 = prop.key) == null ? void 0 : _prop$key2.name) === slotName;
|
|
67
|
-
});
|
|
59
|
+
const slotIndex = property.value.properties.findIndex(prop => prop?.key?.name === slotName);
|
|
68
60
|
if (slotIndex === -1) {
|
|
69
61
|
property.value.properties.push(j.objectProperty(j.identifier(slotName), removedValue));
|
|
70
62
|
} else {
|
|
@@ -15,13 +15,9 @@ function moveJsxPropIntoSlots(j, element, propName, slotName) {
|
|
|
15
15
|
const removedValue = element.openingElement.attributes.splice(index, 1)[0].value.expression;
|
|
16
16
|
let hasSlots = false;
|
|
17
17
|
element.openingElement.attributes.forEach(attr => {
|
|
18
|
-
|
|
19
|
-
if (((_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'slots') {
|
|
18
|
+
if (attr.name?.name === 'slots') {
|
|
20
19
|
hasSlots = true;
|
|
21
|
-
const slotIndex = attr.value.expression.properties.findIndex(prop =>
|
|
22
|
-
var _prop$key;
|
|
23
|
-
return (prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name) === slotName;
|
|
24
|
-
});
|
|
20
|
+
const slotIndex = attr.value.expression.properties.findIndex(prop => prop?.key?.name === slotName);
|
|
25
21
|
if (slotIndex === -1) {
|
|
26
22
|
(0, _assignObject.default)(j, {
|
|
27
23
|
target: attr,
|
|
@@ -50,14 +46,10 @@ function moveDefaultPropsPropIntoSlots(j, defaultPropsPathCollection, propName,
|
|
|
50
46
|
const defaultProps = path.parent.value;
|
|
51
47
|
let hasSlots = false;
|
|
52
48
|
defaultProps.properties.forEach(property => {
|
|
53
|
-
|
|
54
|
-
if (((_property$key = property.key) == null ? void 0 : _property$key.name) === 'slots') {
|
|
49
|
+
if (property.key?.name === 'slots') {
|
|
55
50
|
hasSlots = true;
|
|
56
51
|
const slots = property.value;
|
|
57
|
-
const slotIndex = slots.properties.findIndex(prop =>
|
|
58
|
-
var _prop$key2;
|
|
59
|
-
return (prop == null || (_prop$key2 = prop.key) == null ? void 0 : _prop$key2.name) === slotName;
|
|
60
|
-
});
|
|
52
|
+
const slotIndex = slots.properties.findIndex(prop => prop?.key?.name === slotName);
|
|
61
53
|
if (slotIndex === -1) {
|
|
62
54
|
slots.properties.push(j.objectProperty(j.identifier(slotName), removedValue));
|
|
63
55
|
}
|
|
@@ -25,8 +25,7 @@ function replaceJsxComponentsProp(j, elementPath) {
|
|
|
25
25
|
}, {});
|
|
26
26
|
let hasNode = false;
|
|
27
27
|
element.openingElement.attributes.forEach(attr => {
|
|
28
|
-
|
|
29
|
-
if (((_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'slots') {
|
|
28
|
+
if (attr.name?.name === 'slots') {
|
|
30
29
|
hasNode = true;
|
|
31
30
|
const slots = attr.value.expression.properties.reduce((acc, prop) => {
|
|
32
31
|
return {
|
|
@@ -62,8 +61,7 @@ function replaceJsxComponentsPropsProp(j, element) {
|
|
|
62
61
|
const removed = element.openingElement.attributes.splice(index, 1);
|
|
63
62
|
let hasNode = false;
|
|
64
63
|
element.openingElement.attributes.forEach(attr => {
|
|
65
|
-
|
|
66
|
-
if (((_attr$name2 = attr.name) == null ? void 0 : _attr$name2.name) === 'slotProps') {
|
|
64
|
+
if (attr.name?.name === 'slotProps') {
|
|
67
65
|
hasNode = true;
|
|
68
66
|
const slotProps = attr.value.expression.properties.reduce((acc, prop) => {
|
|
69
67
|
return {
|
|
@@ -79,10 +77,7 @@ function replaceJsxComponentsPropsProp(j, element) {
|
|
|
79
77
|
expression: prop.value
|
|
80
78
|
});
|
|
81
79
|
} else {
|
|
82
|
-
attr.value.expression.properties = attr.value.expression.properties.filter(p =>
|
|
83
|
-
var _p$key;
|
|
84
|
-
return (p == null || (_p$key = p.key) == null ? void 0 : _p$key.name) !== prop.key.name;
|
|
85
|
-
});
|
|
80
|
+
attr.value.expression.properties = attr.value.expression.properties.filter(p => p?.key?.name !== prop.key.name);
|
|
86
81
|
(0, _assignObject.default)(j, {
|
|
87
82
|
target: attr,
|
|
88
83
|
key: prop.key.name,
|
|
@@ -13,8 +13,7 @@ function getReturnExpression(node) {
|
|
|
13
13
|
body = body.body;
|
|
14
14
|
}
|
|
15
15
|
if (Array.isArray(body)) {
|
|
16
|
-
|
|
17
|
-
return (_body$find = body.find(statement => statement.type === 'ReturnStatement')) == null ? void 0 : _body$find.argument;
|
|
16
|
+
return body.find(statement => statement.type === 'ReturnStatement')?.argument;
|
|
18
17
|
}
|
|
19
18
|
return body;
|
|
20
19
|
}
|
|
@@ -149,7 +149,7 @@ const getObjectToArrowFunction = j => {
|
|
|
149
149
|
*/
|
|
150
150
|
exports.getObjectToArrowFunction = getObjectToArrowFunction;
|
|
151
151
|
function isThemePaletteMode(node) {
|
|
152
|
-
return
|
|
152
|
+
return node?.type === 'MemberExpression' && node.object.type === 'MemberExpression' && node.object.object.name === 'theme' && node.object.property.name === 'palette' && node.property.name === 'mode';
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -189,8 +189,7 @@ function migrateToVariants(j, styles) {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
if (node.operator === '!') {
|
|
192
|
-
|
|
193
|
-
if (((_node$argument = node.argument) == null ? void 0 : _node$argument.operator) === '!') {
|
|
192
|
+
if (node.argument?.operator === '!') {
|
|
194
193
|
return node.argument;
|
|
195
194
|
}
|
|
196
195
|
return j.unaryExpression('!', node);
|
|
@@ -387,8 +386,7 @@ function migrateToVariants(j, styles) {
|
|
|
387
386
|
}
|
|
388
387
|
if (data.node.type === 'SpreadElement') {
|
|
389
388
|
if (data.node.argument.type === 'LogicalExpression') {
|
|
390
|
-
|
|
391
|
-
const paramName = data.node.argument.left.type === 'BinaryExpression' ? (_getObjectKey = getObjectKey(data.node.argument.left.left)) == null ? void 0 : _getObjectKey.name : (_getObjectKey2 = getObjectKey(data.node.argument.left)) == null ? void 0 : _getObjectKey2.name;
|
|
389
|
+
const paramName = data.node.argument.left.type === 'BinaryExpression' ? getObjectKey(data.node.argument.left.left)?.name : getObjectKey(data.node.argument.left)?.name;
|
|
392
390
|
if (paramName === 'theme' && data.node.argument.left.right.type === 'StringLiteral') {
|
|
393
391
|
if (data.node.argument.right.type === 'ObjectExpression') {
|
|
394
392
|
const mode = data.node.argument.left.right.value;
|
|
@@ -473,15 +471,12 @@ function migrateToVariants(j, styles) {
|
|
|
473
471
|
}
|
|
474
472
|
if (data.node.type === 'ConditionalExpression') {
|
|
475
473
|
if (data.node.test.type === 'BinaryExpression' || data.node.test.type === 'UnaryExpression' || data.node.test.type === 'Identifier' || data.node.test.type === 'MemberExpression') {
|
|
476
|
-
|
|
477
|
-
let leftName = (_getObjectKey3 = getObjectKey(data.node.test)) == null ? void 0 : _getObjectKey3.name;
|
|
474
|
+
let leftName = getObjectKey(data.node.test)?.name;
|
|
478
475
|
if (data.node.test.left) {
|
|
479
|
-
|
|
480
|
-
leftName = (_getObjectKey4 = getObjectKey(data.node.test.left)) == null ? void 0 : _getObjectKey4.name;
|
|
476
|
+
leftName = getObjectKey(data.node.test.left)?.name;
|
|
481
477
|
}
|
|
482
478
|
if (data.node.test.argument) {
|
|
483
|
-
|
|
484
|
-
leftName = (_getObjectKey5 = getObjectKey(data.node.test.argument)) == null ? void 0 : _getObjectKey5.name;
|
|
479
|
+
leftName = getObjectKey(data.node.test.argument)?.name;
|
|
485
480
|
}
|
|
486
481
|
if (parameters.has(leftName) && leftName !== 'theme') {
|
|
487
482
|
let props = buildProps(data.node.test);
|
|
@@ -495,7 +490,6 @@ function migrateToVariants(j, styles) {
|
|
|
495
490
|
};
|
|
496
491
|
variants.push(buildObjectAST(variant));
|
|
497
492
|
if (data.node.consequent.type === 'ObjectExpression' && data.node.alternate.type === 'ObjectExpression') {
|
|
498
|
-
var _data$parentNode;
|
|
499
493
|
// create another variant with inverted condition
|
|
500
494
|
let props2 = buildProps(inverseBinaryExpression(data.node.test));
|
|
501
495
|
if (data.props) {
|
|
@@ -507,31 +501,28 @@ function migrateToVariants(j, styles) {
|
|
|
507
501
|
style: styleVal2
|
|
508
502
|
};
|
|
509
503
|
variants.push(buildObjectAST(variant2));
|
|
510
|
-
if (
|
|
504
|
+
if (data.parentNode?.type === 'ObjectExpression') {
|
|
511
505
|
removeProperty(data.parentNode, data.node);
|
|
512
506
|
}
|
|
513
507
|
} else {
|
|
514
|
-
|
|
515
|
-
(_data$replaceValue = data.replaceValue) == null || _data$replaceValue.call(data, data.node.alternate);
|
|
508
|
+
data.replaceValue?.(data.node.alternate);
|
|
516
509
|
}
|
|
517
510
|
}
|
|
518
|
-
if (leftName === 'theme' &&
|
|
511
|
+
if (leftName === 'theme' && data.parentNode?.type === 'ObjectExpression' && data.node.test?.type === 'BinaryExpression' && isThemePaletteMode(data.node.test.left)) {
|
|
519
512
|
if (data.node.consequent.type !== 'ObjectExpression' && data.node.alternate.type !== 'ObjectExpression') {
|
|
520
|
-
var _data$replaceValue2;
|
|
521
513
|
if (data.modeStyles) {
|
|
522
514
|
if (!data.modeStyles[data.node.test.right.value]) {
|
|
523
515
|
data.modeStyles[data.node.test.right.value] = [];
|
|
524
516
|
}
|
|
525
517
|
data.modeStyles[data.node.test.right.value].push(j.objectProperty(data.key, data.node.consequent));
|
|
526
518
|
}
|
|
527
|
-
|
|
519
|
+
data.replaceValue?.(data.node.alternate);
|
|
528
520
|
}
|
|
529
521
|
}
|
|
530
522
|
}
|
|
531
523
|
}
|
|
532
524
|
if (data.node.type === 'TemplateLiteral') {
|
|
533
|
-
|
|
534
|
-
if (((_data$parentNode3 = data.parentNode) == null ? void 0 : _data$parentNode3.type) === 'ObjectExpression') {
|
|
525
|
+
if (data.parentNode?.type === 'ObjectExpression') {
|
|
535
526
|
const modeStyles = {};
|
|
536
527
|
data.node.expressions.forEach((expression, index) => {
|
|
537
528
|
recurseObjectExpression({
|
|
@@ -560,10 +551,9 @@ function migrateToVariants(j, styles) {
|
|
|
560
551
|
data.modeStyles[mode].push(j.objectProperty(data.key, clonedNode));
|
|
561
552
|
});
|
|
562
553
|
if (data.key) {
|
|
563
|
-
var _data$replaceValue3;
|
|
564
554
|
// to remove the arrow function
|
|
565
555
|
// { ...: theme => `1px solid...` } to { ...: `1px solid...` }
|
|
566
|
-
|
|
556
|
+
data.replaceValue?.(data.node);
|
|
567
557
|
}
|
|
568
558
|
}
|
|
569
559
|
}
|
|
@@ -586,8 +576,7 @@ function migrateToVariants(j, styles) {
|
|
|
586
576
|
if (style.body.type === 'ObjectExpression') {
|
|
587
577
|
// Remove empty `...theme.applyStyles('...', {})`
|
|
588
578
|
style.body.properties = style.body.properties.filter(prop => {
|
|
589
|
-
|
|
590
|
-
if (((_prop$argument = prop.argument) == null || (_prop$argument = _prop$argument.callee) == null || (_prop$argument = _prop$argument.object) == null ? void 0 : _prop$argument.name) === 'theme' && typeof ((_prop$argument2 = prop.argument) == null || (_prop$argument2 = _prop$argument2.arguments[0]) == null ? void 0 : _prop$argument2.value) === 'string' && !((_prop$argument3 = prop.argument) != null && (_prop$argument3 = _prop$argument3.arguments) != null && (_prop$argument3 = _prop$argument3[1]) != null && (_prop$argument3 = _prop$argument3.properties) != null && _prop$argument3.length)) {
|
|
579
|
+
if (prop.argument?.callee?.object?.name === 'theme' && typeof prop.argument?.arguments[0]?.value === 'string' && !prop.argument?.arguments?.[1]?.properties?.length) {
|
|
591
580
|
return false;
|
|
592
581
|
}
|
|
593
582
|
return true;
|
|
@@ -40,13 +40,9 @@ function propsToObject({
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
if (propValue.length > 0) {
|
|
43
|
-
const propNameAttr = attributes.find(attr =>
|
|
44
|
-
var _attr$name;
|
|
45
|
-
return (attr == null || (_attr$name = attr.name) == null ? void 0 : _attr$name.name) === propName;
|
|
46
|
-
});
|
|
43
|
+
const propNameAttr = attributes.find(attr => attr?.name?.name === propName);
|
|
47
44
|
if (propNameAttr) {
|
|
48
|
-
|
|
49
|
-
(((_propNameAttr$value$e = propNameAttr.value.expression) == null ? void 0 : _propNameAttr$value$e.properties) || []).push(...j.objectExpression(propValue).properties);
|
|
45
|
+
(propNameAttr.value.expression?.properties || []).push(...j.objectExpression(propValue).properties);
|
|
50
46
|
} else {
|
|
51
47
|
attributes.push(j.jsxAttribute(j.jsxIdentifier(propName), j.jsxExpressionContainer(j.objectExpression(propValue))));
|
|
52
48
|
}
|
|
@@ -13,8 +13,7 @@ function renameClassKey({
|
|
|
13
13
|
const source = root.findJSXElements(componentName).forEach(path => {
|
|
14
14
|
path.node.openingElement.attributes.forEach(node => {
|
|
15
15
|
if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
|
|
16
|
-
|
|
17
|
-
(_node$value = node.value) == null || (_node$value = _node$value.expression) == null || (_node$value = _node$value.properties) == null || _node$value.forEach(subNode => {
|
|
16
|
+
node.value?.expression?.properties?.forEach(subNode => {
|
|
18
17
|
if (Object.keys(classes).includes(subNode.key.name)) {
|
|
19
18
|
subNode.key.name = classes[subNode.key.name];
|
|
20
19
|
}
|
|
@@ -13,13 +13,11 @@ function transformer(file, api, options) {
|
|
|
13
13
|
const printOptions = options.printOptions;
|
|
14
14
|
const source = j(file.source).findJSXElements('Avatar').forEach(path => {
|
|
15
15
|
path.node.openingElement.attributes.forEach(node => {
|
|
16
|
-
|
|
17
|
-
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'circle' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'circle')) {
|
|
16
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'circle' || node.value.expression?.value === 'circle')) {
|
|
18
17
|
node.value = j.literal('circular');
|
|
19
18
|
}
|
|
20
19
|
if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
|
|
21
|
-
|
|
22
|
-
(_node$value = node.value) == null || (_node$value = _node$value.expression) == null || (_node$value = _node$value.properties) == null || _node$value.forEach(subNode => {
|
|
20
|
+
node.value?.expression?.properties?.forEach(subNode => {
|
|
23
21
|
if (subNode.key.name === 'circle') {
|
|
24
22
|
subNode.key.name = 'circular';
|
|
25
23
|
}
|
|
@@ -13,18 +13,15 @@ function transformer(file, api, options) {
|
|
|
13
13
|
const printOptions = options.printOptions;
|
|
14
14
|
const source = j(file.source).findJSXElements('Badge').forEach(path => {
|
|
15
15
|
path.node.openingElement.attributes.forEach(node => {
|
|
16
|
-
var _node$value;
|
|
17
16
|
if (node.type === 'JSXAttribute' && node.name.name === 'overlap') {
|
|
18
|
-
|
|
19
|
-
if (node.value.value === 'circle' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'circle') {
|
|
17
|
+
if (node.value.value === 'circle' || node.value.expression?.value === 'circle') {
|
|
20
18
|
node.value = j.literal('circular');
|
|
21
|
-
} else if (node.value.value === 'rectangle' ||
|
|
19
|
+
} else if (node.value.value === 'rectangle' || node.value.expression?.value === 'rectangle') {
|
|
22
20
|
node.value = j.literal('rectangular');
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
if (node.type === 'JSXAttribute' && node.name.name === 'classes' && Array.isArray(
|
|
26
|
-
|
|
27
|
-
(_node$value2 = node.value) == null || (_node$value2 = _node$value2.expression) == null || (_node$value2 = _node$value2.properties) == null || _node$value2.forEach(subNode => {
|
|
23
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'classes' && Array.isArray(node.value?.expression?.properties)) {
|
|
24
|
+
node.value?.expression?.properties?.forEach(subNode => {
|
|
28
25
|
if (subNode.key) {
|
|
29
26
|
if (subNode.key.name.endsWith('Circle')) {
|
|
30
27
|
subNode.key.name = subNode.key.name.replace('Circle', 'Circular');
|
|
@@ -46,8 +46,7 @@ function transformer(file, api, options) {
|
|
|
46
46
|
const filteredSpecifiers = [];
|
|
47
47
|
const hookName = sourceVal.replace(/@mui\/base\/([a-zA-Z]+)Unstyled/, 'use$1');
|
|
48
48
|
path.node.specifiers.forEach(elementNode => {
|
|
49
|
-
|
|
50
|
-
if (elementNode.type !== 'ImportSpecifier' || !((_elementNode$imported = elementNode.imported) != null && _elementNode$imported.name)) {
|
|
49
|
+
if (elementNode.type !== 'ImportSpecifier' || !elementNode.imported?.name) {
|
|
51
50
|
filteredSpecifiers.push(elementNode);
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
@@ -23,8 +23,7 @@ function transformer(file, api) {
|
|
|
23
23
|
}
|
|
24
24
|
const specifiers = [];
|
|
25
25
|
path.node.specifiers.forEach(elementNode => {
|
|
26
|
-
|
|
27
|
-
const importedName = ((_elementNode$imported = elementNode.imported) == null ? void 0 : _elementNode$imported.name) || '';
|
|
26
|
+
const importedName = elementNode.imported?.name || '';
|
|
28
27
|
if (elementNode.type === 'ImportSpecifier' && importedName.match(/unstyled/im)) {
|
|
29
28
|
elementNode.imported.name = importedName.replace(/unstyled/im, '');
|
|
30
29
|
if (elementNode.local.name === importedName) {
|
|
@@ -7,7 +7,7 @@ exports.default = transformer;
|
|
|
7
7
|
function transformComponentsProp(attributeNode) {
|
|
8
8
|
attributeNode.name.name = 'slots';
|
|
9
9
|
const valueExpression = attributeNode.value.expression;
|
|
10
|
-
if (
|
|
10
|
+
if (valueExpression?.type !== 'ObjectExpression') {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
valueExpression.properties.forEach(property => {
|
|
@@ -18,12 +18,10 @@ const pathMapping = {
|
|
|
18
18
|
'@mui/base/className': '@mui/base/ClassNameGenerator'
|
|
19
19
|
};
|
|
20
20
|
function getExportedIdentifier(importPath) {
|
|
21
|
-
|
|
22
|
-
return (_nameMapping$importPa = nameMapping[importPath]) != null ? _nameMapping$importPa : importPath;
|
|
21
|
+
return nameMapping[importPath] ?? importPath;
|
|
23
22
|
}
|
|
24
23
|
function getTransformedPath(originalPath) {
|
|
25
|
-
|
|
26
|
-
return (_pathMapping$original = pathMapping[originalPath]) != null ? _pathMapping$original : originalPath;
|
|
24
|
+
return pathMapping[originalPath] ?? originalPath;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
@@ -33,8 +31,7 @@ function getTransformedPath(originalPath) {
|
|
|
33
31
|
* @example '@mui/base' ➔ null
|
|
34
32
|
*/
|
|
35
33
|
function getBaseImportIdentifier(path, filePath) {
|
|
36
|
-
|
|
37
|
-
const source = path == null || (_path$node = path.node) == null || (_path$node = _path$node.source) == null ? void 0 : _path$node.value;
|
|
34
|
+
const source = path?.node?.source?.value;
|
|
38
35
|
if (!source) {
|
|
39
36
|
return null;
|
|
40
37
|
}
|
|
@@ -42,11 +39,11 @@ function getBaseImportIdentifier(path, filePath) {
|
|
|
42
39
|
if (baseImportPathMatch == null) {
|
|
43
40
|
return null;
|
|
44
41
|
}
|
|
45
|
-
if (
|
|
42
|
+
if (baseImportPathMatch[1]?.includes('/')) {
|
|
46
43
|
console.warn(`WARNING: ${filePath}: "${source}" is more than one level deep. This is not supported.`);
|
|
47
44
|
return null;
|
|
48
45
|
}
|
|
49
|
-
return
|
|
46
|
+
return baseImportPathMatch[1] ?? null;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
/**
|
|
@@ -21,8 +21,7 @@ function transformer(file, api, options) {
|
|
|
21
21
|
let aliasName;
|
|
22
22
|
root.find(j.ImportDeclaration).forEach(path => {
|
|
23
23
|
if (path.node.source.value.match(/^(@mui\/material|@material-ui\/core)$/)) {
|
|
24
|
-
|
|
25
|
-
if (((_path$node$specifiers = path.node.specifiers[0]) == null ? void 0 : _path$node$specifiers.type) === 'ImportNamespaceSpecifier') {
|
|
24
|
+
if (path.node.specifiers[0]?.type === 'ImportNamespaceSpecifier') {
|
|
26
25
|
aliasName = path.node.specifiers[0].local.name;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -14,8 +14,7 @@ function transformer(file, api, options) {
|
|
|
14
14
|
return j(file.source).findJSXElements('Button').forEach(path => {
|
|
15
15
|
const attributes = path.node.openingElement.attributes;
|
|
16
16
|
attributes.forEach((node, index) => {
|
|
17
|
-
|
|
18
|
-
if (node.type === 'JSXAttribute' && node.name.name === 'color' && (node.value.value === 'default' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'default')) {
|
|
17
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'color' && (node.value.value === 'default' || node.value.expression?.value === 'default')) {
|
|
19
18
|
delete attributes[index];
|
|
20
19
|
}
|
|
21
20
|
});
|
|
@@ -14,8 +14,7 @@ function transformer(file, api, options) {
|
|
|
14
14
|
return j(file.source).findJSXElements('Chip').forEach(path => {
|
|
15
15
|
const attributes = path.node.openingElement.attributes;
|
|
16
16
|
attributes.forEach((node, index) => {
|
|
17
|
-
|
|
18
|
-
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'default' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'default')) {
|
|
17
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'default' || node.value.expression?.value === 'default')) {
|
|
19
18
|
delete attributes[index];
|
|
20
19
|
}
|
|
21
20
|
});
|
|
@@ -13,13 +13,11 @@ function transformer(file, api, options) {
|
|
|
13
13
|
const printOptions = options.printOptions;
|
|
14
14
|
return j(file.source).findJSXElements('CircularProgress').forEach(path => {
|
|
15
15
|
path.node.openingElement.attributes.forEach(node => {
|
|
16
|
-
|
|
17
|
-
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'static' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'static')) {
|
|
16
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'variant' && (node.value.value === 'static' || node.value.expression?.value === 'static')) {
|
|
18
17
|
node.value = j.literal('determinate');
|
|
19
18
|
}
|
|
20
19
|
if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
|
|
21
|
-
|
|
22
|
-
(_node$value = node.value) == null || (_node$value = _node$value.expression) == null || (_node$value = _node$value.properties) == null || _node$value.forEach(subNode => {
|
|
20
|
+
node.value?.expression?.properties?.forEach(subNode => {
|
|
23
21
|
if (subNode.key.name === 'static') {
|
|
24
22
|
subNode.key.name = 'determinate';
|
|
25
23
|
}
|
|
@@ -14,14 +14,12 @@ function transformer(file, api, options) {
|
|
|
14
14
|
const source = j(file.source).findJSXElements('Fab').forEach(path => {
|
|
15
15
|
path.node.openingElement.attributes.forEach(node => {
|
|
16
16
|
if (node.type === 'JSXAttribute' && node.name.name === 'variant') {
|
|
17
|
-
|
|
18
|
-
if (node.value.value === 'round' || ((_node$value$expressio = node.value.expression) == null ? void 0 : _node$value$expressio.value) === 'round') {
|
|
17
|
+
if (node.value.value === 'round' || node.value.expression?.value === 'round') {
|
|
19
18
|
node.value = j.literal('circular');
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
if (node.type === 'JSXAttribute' && node.name.name === 'classes') {
|
|
23
|
-
|
|
24
|
-
(((_node$value = node.value) == null || (_node$value = _node$value.expression) == null ? void 0 : _node$value.properties) || []).forEach(subNode => {
|
|
22
|
+
(node.value?.expression?.properties || []).forEach(subNode => {
|
|
25
23
|
if (subNode.key.name === 'round') {
|
|
26
24
|
subNode.key.name = 'circular';
|
|
27
25
|
}
|
|
@@ -18,7 +18,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
}, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.GridListTile, {
|
|
19
19
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconLink, {
|
|
20
20
|
href: href,
|
|
21
|
-
text: text
|
|
21
|
+
text: text ?? href,
|
|
22
22
|
Icon: Icon
|
|
23
23
|
})
|
|
24
24
|
}, i)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_other.default, {})]
|
|
@@ -18,7 +18,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
}, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_core.ImageListItem, {
|
|
19
19
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(IconLink, {
|
|
20
20
|
href: href,
|
|
21
|
-
text: text
|
|
21
|
+
text: text ?? href,
|
|
22
22
|
Icon: Icon
|
|
23
23
|
})
|
|
24
24
|
}, i)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_other.default, {})]
|
|
@@ -22,17 +22,13 @@ function transformer(file, api, options) {
|
|
|
22
22
|
].includes(sourceVal);
|
|
23
23
|
}).forEach(path => {
|
|
24
24
|
path.node.specifiers.forEach(elementNode => {
|
|
25
|
-
|
|
26
|
-
if (elementNode.type === 'ImportSpecifier' && ((_elementNode$imported = elementNode.imported) == null ? void 0 : _elementNode$imported.name) === 'Avatar' || elementNode.type === 'ImportDefaultSpecifier') {
|
|
25
|
+
if (elementNode.type === 'ImportSpecifier' && elementNode.imported?.name === 'Avatar' || elementNode.type === 'ImportDefaultSpecifier') {
|
|
27
26
|
// Process only Joy `Avatar` component
|
|
28
27
|
root.findJSXElements(elementNode.local.name).forEach(elementPath => {
|
|
29
28
|
if (elementPath.node.type !== 'JSXElement') {
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
|
-
const slotPropsAttributeNode = elementPath.node.openingElement.attributes.find(attributeNode =>
|
|
33
|
-
var _attributeNode$value$;
|
|
34
|
-
return attributeNode.type === 'JSXAttribute' && attributeNode.name.name === 'slotProps' && ((_attributeNode$value$ = attributeNode.value.expression) == null ? void 0 : _attributeNode$value$.type) === 'ObjectExpression';
|
|
35
|
-
});
|
|
31
|
+
const slotPropsAttributeNode = elementPath.node.openingElement.attributes.find(attributeNode => attributeNode.type === 'JSXAttribute' && attributeNode.name.name === 'slotProps' && attributeNode.value.expression?.type === 'ObjectExpression');
|
|
36
32
|
const newAttributeNodes = [];
|
|
37
33
|
elementPath.node.openingElement.attributes.forEach(attributeNode => {
|
|
38
34
|
if (attributeNode.type !== 'JSXAttribute') {
|
|
@@ -43,7 +39,7 @@ function transformer(file, api, options) {
|
|
|
43
39
|
return;
|
|
44
40
|
}
|
|
45
41
|
const val = attributeNode.value;
|
|
46
|
-
if (!
|
|
42
|
+
if (!val?.expression) {
|
|
47
43
|
return;
|
|
48
44
|
}
|
|
49
45
|
if (slotPropsAttributeNode) {
|
|
@@ -7,7 +7,7 @@ exports.default = transformer;
|
|
|
7
7
|
function transformComponentsProp(attributeNode) {
|
|
8
8
|
attributeNode.name.name = 'slots';
|
|
9
9
|
const valueExpression = attributeNode.value.expression;
|
|
10
|
-
if (
|
|
10
|
+
if (valueExpression?.type !== 'ObjectExpression') {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
valueExpression.properties.forEach(property => {
|
|
@@ -28,9 +28,8 @@ function transformer(file, api, options) {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
if (attributeNode.name.name === 'row') {
|
|
31
|
-
var _val$expression;
|
|
32
31
|
const val = attributeNode.value;
|
|
33
|
-
if (val === null ||
|
|
32
|
+
if (val === null || val?.expression?.value === true) {
|
|
34
33
|
attributeNode.name.name = 'orientation';
|
|
35
34
|
attributeNode.value = j.jsxExpressionContainer(j.literal('horizontal'));
|
|
36
35
|
}
|