@mui/codemod 6.0.0-beta.4 → 6.0.0-beta.4-dev.20240802-144226-85a3b55d22
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.
|
@@ -8,6 +8,7 @@ exports.default = transformer;
|
|
|
8
8
|
var _appendAttribute = _interopRequireDefault(require("../../util/appendAttribute"));
|
|
9
9
|
var _assignObject = _interopRequireDefault(require("../../util/assignObject"));
|
|
10
10
|
var _findComponentJSX = _interopRequireDefault(require("../../util/findComponentJSX"));
|
|
11
|
+
var _findComponentDefaultProps = _interopRequireDefault(require("../../util/findComponentDefaultProps"));
|
|
11
12
|
/**
|
|
12
13
|
* @param {import('jscodeshift').FileInfo} file
|
|
13
14
|
* @param {import('jscodeshift').API} api
|
|
@@ -53,34 +54,30 @@ function transformer(file, api, options) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
|
-
|
|
57
|
+
const defaultPropsPathCollection = (0, _findComponentDefaultProps.default)(j, {
|
|
58
|
+
root,
|
|
59
|
+
componentName: 'Divider'
|
|
60
|
+
});
|
|
61
|
+
defaultPropsPathCollection.find(j.ObjectProperty, {
|
|
57
62
|
key: {
|
|
58
|
-
name: '
|
|
63
|
+
name: 'light'
|
|
59
64
|
}
|
|
60
65
|
}).forEach(path => {
|
|
61
|
-
var
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
defaultPropsObject.value.properties = defaultPropsObject.value.properties.filter(prop => {
|
|
68
|
-
var _prop$key;
|
|
69
|
-
return !['light'].includes(prop == null || (_prop$key = prop.key) == null ? void 0 : _prop$key.name);
|
|
70
|
-
});
|
|
71
|
-
const isLightPropTruthy = ((_lightProp$value2 = lightProp.value) == null ? void 0 : _lightProp$value2.value) !== false;
|
|
72
|
-
if (!isLightPropTruthy) {
|
|
66
|
+
var _path$value;
|
|
67
|
+
const {
|
|
68
|
+
properties: defaultPropsProperties
|
|
69
|
+
} = path.parent.value;
|
|
70
|
+
if (((_path$value = path.value) == null ? void 0 : _path$value.value.value) === false) {
|
|
71
|
+
path.prune();
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
} else {
|
|
79
|
-
|
|
80
|
-
if (opacityIndex === -1) {
|
|
81
|
-
defaultPropsObject.value.properties[sxIndex].value.properties.push(j.objectProperty(j.identifier('opacity'), j.literal('0.6')));
|
|
82
|
-
}
|
|
74
|
+
const existingSx = defaultPropsProperties.find(prop => prop.key.name === 'sx');
|
|
75
|
+
if (!existingSx) {
|
|
76
|
+
defaultPropsProperties.push(j.property('init', j.identifier('sx'), j.objectExpression([j.objectProperty(j.identifier('opacity'), j.literal('0.6'))])));
|
|
77
|
+
} else if (!existingSx.value.properties.find(prop => prop.key.name === 'opacity')) {
|
|
78
|
+
existingSx.value.properties.push(j.property('init', j.identifier('opacity'), j.literal('0.6')));
|
|
83
79
|
}
|
|
80
|
+
path.prune();
|
|
84
81
|
});
|
|
85
82
|
return root.toSource(printOptions);
|
|
86
83
|
}
|