@mui/codemod 6.0.0-alpha.0 → 6.0.0-alpha.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 +182 -2
- package/node/deprecations/accordion-props/accordion-props.js +11 -71
- package/node/deprecations/accordion-props/test-cases/actual.js +16 -0
- package/node/deprecations/accordion-props/test-cases/expected.js +14 -0
- package/node/deprecations/accordion-props/test-cases/theme.actual.js +24 -0
- package/node/deprecations/accordion-props/test-cases/theme.expected.js +24 -0
- package/node/deprecations/all/deprecations-all.js +4 -0
- package/node/deprecations/all/postcss.config.js +7 -1
- package/node/deprecations/avatar-props/avatar-props.js +5 -39
- package/node/deprecations/avatar-props/test-cases/actual.js +10 -0
- package/node/deprecations/avatar-props/test-cases/expected.js +10 -0
- package/node/deprecations/avatar-props/test-cases/theme.actual.js +14 -0
- package/node/deprecations/avatar-props/test-cases/theme.expected.js +15 -0
- package/node/deprecations/backdrop-props/backdrop-props.js +5 -61
- package/node/deprecations/backdrop-props/test-cases/actual.js +8 -7
- package/node/deprecations/backdrop-props/test-cases/expected.js +7 -7
- package/node/deprecations/backdrop-props/test-cases/theme.actual.js +11 -0
- package/node/deprecations/backdrop-props/test-cases/theme.expected.js +12 -2
- package/node/deprecations/badge-props/badge-props.js +22 -0
- package/node/deprecations/badge-props/index.js +13 -0
- package/node/deprecations/badge-props/test-cases/actual.js +59 -0
- package/node/deprecations/badge-props/test-cases/expected.js +44 -0
- package/node/deprecations/badge-props/test-cases/theme.actual.js +73 -0
- package/node/deprecations/badge-props/test-cases/theme.expected.js +58 -0
- package/node/deprecations/step-connector-classes/index.js +13 -0
- package/node/deprecations/step-connector-classes/postcss-plugin.js +33 -0
- package/node/deprecations/step-connector-classes/postcss.config.js +8 -0
- package/node/deprecations/step-connector-classes/step-connector-classes.js +77 -0
- package/node/deprecations/step-connector-classes/test-cases/actual.js +7 -0
- package/node/deprecations/step-connector-classes/test-cases/expected.js +7 -0
- package/node/deprecations/step-label-props/step-label-props.js +14 -0
- package/node/deprecations/step-label-props/test-cases/actual.js +23 -0
- package/node/deprecations/step-label-props/test-cases/expected.js +24 -0
- package/node/deprecations/step-label-props/test-cases/theme.actual.js +22 -0
- package/node/deprecations/step-label-props/test-cases/theme.expected.js +25 -0
- package/node/deprecations/toggle-button-group-classes/index.js +13 -0
- package/node/deprecations/toggle-button-group-classes/postcss-plugin.js +33 -0
- package/node/deprecations/toggle-button-group-classes/postcss.config.js +8 -0
- package/node/deprecations/toggle-button-group-classes/test-cases/actual.js +7 -0
- package/node/deprecations/toggle-button-group-classes/test-cases/expected.js +7 -0
- package/node/deprecations/toggle-button-group-classes/toggle-button-group-classes.js +77 -0
- package/node/deprecations/utils/movePropIntoSlotProps.js +111 -0
- package/node/deprecations/utils/movePropIntoSlots.js +101 -0
- package/node/v5.0.0/base-remove-unstyled-suffix.js +4 -4
- package/node/v5.0.0/styled-engine-provider.test/theme-provider.expected.js +3 -3
- package/node/v6.0.0/all/index.js +13 -0
- package/node/v6.0.0/all/postcss.config.js +9 -0
- package/node/v6.0.0/all/v6-all.js +17 -0
- package/node/v6.0.0/styled/index.js +13 -0
- package/node/v6.0.0/styled/styled-v6.js +478 -0
- package/node/v6.0.0/styled/test-cases/BasicStyled.actual.js +54 -0
- package/node/v6.0.0/styled/test-cases/BasicStyled.expected.js +104 -0
- package/node/v6.0.0/styled/test-cases/ConditionalStyled.actual.js +115 -0
- package/node/v6.0.0/styled/test-cases/ConditionalStyled.expected.js +206 -0
- package/node/v6.0.0/styled/test-cases/LogicalStyled.actual.js +28 -0
- package/node/v6.0.0/styled/test-cases/LogicalStyled.expected.js +52 -0
- package/node/v6.0.0/styled/test-cases/NestedSpread.actual.js +42 -0
- package/node/v6.0.0/styled/test-cases/NestedSpread.expected.js +85 -0
- package/node/v6.0.0/styled/test-cases/ObjectMap.actual.js +36 -0
- package/node/v6.0.0/styled/test-cases/ObjectMap.expected.js +109 -0
- package/node/v6.0.0/styled/test-cases/ThemePaletteMode.actual.js +62 -0
- package/node/v6.0.0/styled/test-cases/ThemePaletteMode.expected.js +76 -0
- package/node/v6.0.0/styled/test-cases/VariantAndModeStyled.actual.js +11 -0
- package/node/v6.0.0/styled/test-cases/VariantAndModeStyled.expected.js +19 -0
- package/package.json +8 -8
|
@@ -5,10 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = transformer;
|
|
8
|
-
var
|
|
9
|
-
var _findComponentJSX = _interopRequireDefault(require("../../util/findComponentJSX"));
|
|
10
|
-
var _assignObject = _interopRequireDefault(require("../../util/assignObject"));
|
|
11
|
-
var _appendAttribute = _interopRequireDefault(require("../../util/appendAttribute"));
|
|
8
|
+
var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
|
|
12
9
|
/**
|
|
13
10
|
* @param {import('jscodeshift').FileInfo} file
|
|
14
11
|
* @param {import('jscodeshift').API} api
|
|
@@ -17,64 +14,11 @@ function transformer(file, api, options) {
|
|
|
17
14
|
const j = api.jscodeshift;
|
|
18
15
|
const root = j(file.source);
|
|
19
16
|
const printOptions = options.printOptions;
|
|
20
|
-
(0,
|
|
17
|
+
(0, _movePropIntoSlots.default)(j, {
|
|
21
18
|
root,
|
|
22
|
-
componentName: 'Backdrop'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (index !== -1) {
|
|
26
|
-
const removed = elementPath.node.openingElement.attributes.splice(index, 1);
|
|
27
|
-
let hasNode = false;
|
|
28
|
-
elementPath.node.openingElement.attributes.forEach(attr => {
|
|
29
|
-
var _attr$name;
|
|
30
|
-
if (((_attr$name = attr.name) == null ? void 0 : _attr$name.name) === 'slots') {
|
|
31
|
-
hasNode = true;
|
|
32
|
-
(0, _assignObject.default)(j, {
|
|
33
|
-
target: attr,
|
|
34
|
-
key: 'transition',
|
|
35
|
-
expression: removed[0].value.expression
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
if (!hasNode) {
|
|
40
|
-
(0, _appendAttribute.default)(j, {
|
|
41
|
-
target: elementPath.node,
|
|
42
|
-
attributeName: 'slots',
|
|
43
|
-
expression: j.objectExpression([j.objectProperty(j.identifier('transition'), removed[0].value.expression)])
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
root.find(j.ObjectProperty, {
|
|
49
|
-
key: {
|
|
50
|
-
name: 'TransitionComponent'
|
|
51
|
-
}
|
|
52
|
-
}).forEach(path => {
|
|
53
|
-
var _path$parent;
|
|
54
|
-
if (((_path$parent = path.parent) == null || (_path$parent = _path$parent.parent) == null || (_path$parent = _path$parent.parent) == null || (_path$parent = _path$parent.parent) == null || (_path$parent = _path$parent.node.key) == null ? void 0 : _path$parent.name) === 'MuiBackdrop') {
|
|
55
|
-
var _defaultPropsProperti;
|
|
56
|
-
const {
|
|
57
|
-
properties: defaultPropsProperties
|
|
58
|
-
} = path.parent.value;
|
|
59
|
-
const existingSlots = defaultPropsProperties.find(prop => prop.key.name === 'slots');
|
|
60
|
-
const slots = existingSlots ? existingSlots.value.properties.reduce((acc, prop) => {
|
|
61
|
-
return (0, _extends2.default)({}, acc, {
|
|
62
|
-
[prop.key.name]: prop.value
|
|
63
|
-
});
|
|
64
|
-
}, {}) : {};
|
|
65
|
-
const transitionComponent = (_defaultPropsProperti = defaultPropsProperties.find(prop => prop.key.name === 'TransitionComponent')) != null ? _defaultPropsProperti : {};
|
|
66
|
-
const updatedSlots = j.objectExpression(Object.entries((0, _extends2.default)({
|
|
67
|
-
transition: transitionComponent == null ? void 0 : transitionComponent.value
|
|
68
|
-
}, slots)).map(([slot, value]) => {
|
|
69
|
-
return j.objectProperty(j.identifier(slot), value);
|
|
70
|
-
}));
|
|
71
|
-
if (existingSlots) {
|
|
72
|
-
existingSlots.value = updatedSlots;
|
|
73
|
-
path.prune();
|
|
74
|
-
} else {
|
|
75
|
-
path.replace(j.property('init', j.identifier('slots'), j.objectExpression([j.objectProperty(j.identifier('transition'), path.node.value)])));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
19
|
+
componentName: 'Backdrop',
|
|
20
|
+
propName: 'TransitionComponent',
|
|
21
|
+
slotName: 'transition'
|
|
78
22
|
});
|
|
79
23
|
return root.toSource(printOptions);
|
|
80
24
|
}
|
|
@@ -15,17 +15,18 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
15
15
|
TransitionComponent: CustomTransition,
|
|
16
16
|
slots: {
|
|
17
17
|
root: 'div'
|
|
18
|
-
},
|
|
19
|
-
slotProps: {
|
|
20
|
-
root: {
|
|
21
|
-
className: 'foo'
|
|
22
|
-
}
|
|
23
18
|
}
|
|
24
19
|
});
|
|
25
20
|
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Backdrop, {
|
|
26
21
|
TransitionComponent: CustomTransition,
|
|
27
|
-
slots: (0, _extends2.default)({}, outerSlots)
|
|
28
|
-
|
|
22
|
+
slots: (0, _extends2.default)({}, outerSlots)
|
|
23
|
+
});
|
|
24
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Backdrop.default, {
|
|
25
|
+
TransitionComponent: ComponentTransition,
|
|
26
|
+
slots: {
|
|
27
|
+
root: 'div',
|
|
28
|
+
transition: SlotTransition
|
|
29
|
+
}
|
|
29
30
|
});
|
|
30
31
|
// should skip non MUI components
|
|
31
32
|
/*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiBackdrop, {
|
|
@@ -19,18 +19,18 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
19
19
|
slots: {
|
|
20
20
|
root: 'div',
|
|
21
21
|
transition: CustomTransition
|
|
22
|
-
},
|
|
23
|
-
slotProps: {
|
|
24
|
-
root: {
|
|
25
|
-
className: 'foo'
|
|
26
|
-
}
|
|
27
22
|
}
|
|
28
23
|
});
|
|
29
24
|
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Backdrop, {
|
|
30
25
|
slots: (0, _extends2.default)({}, outerSlots, {
|
|
31
26
|
transition: CustomTransition
|
|
32
|
-
})
|
|
33
|
-
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_Backdrop.default, {
|
|
30
|
+
slots: {
|
|
31
|
+
root: 'div',
|
|
32
|
+
transition: SlotTransition
|
|
33
|
+
}
|
|
34
34
|
});
|
|
35
35
|
// should skip non MUI components
|
|
36
36
|
/*#__PURE__*/(0, _jsxRuntime.jsx)(NonMuiBackdrop, {
|
|
@@ -13,8 +13,18 @@ fn({
|
|
|
13
13
|
MuiBackdrop: {
|
|
14
14
|
defaultProps: {
|
|
15
15
|
slots: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
root: 'div',
|
|
17
|
+
transition: CustomTransition
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
fn({
|
|
23
|
+
MuiBackdrop: {
|
|
24
|
+
defaultProps: {
|
|
25
|
+
slots: {
|
|
26
|
+
root: 'div',
|
|
27
|
+
transition: SlotTransition
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
30
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = transformer;
|
|
8
|
+
var _replaceComponentsWithSlots = _interopRequireDefault(require("../utils/replaceComponentsWithSlots"));
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
11
|
+
* @param {import('jscodeshift').API} api
|
|
12
|
+
*/
|
|
13
|
+
function transformer(file, api, options) {
|
|
14
|
+
const j = api.jscodeshift;
|
|
15
|
+
const root = j(file.source);
|
|
16
|
+
const printOptions = options.printOptions;
|
|
17
|
+
(0, _replaceComponentsWithSlots.default)(j, {
|
|
18
|
+
root,
|
|
19
|
+
componentName: 'Badge'
|
|
20
|
+
});
|
|
21
|
+
return root.toSource(printOptions);
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _badgeProps.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _badgeProps = _interopRequireDefault(require("./badge-props"));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _material = require("@mui/material");
|
|
4
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
6
|
+
components: {
|
|
7
|
+
root: ComponentsRoot
|
|
8
|
+
},
|
|
9
|
+
componentsProps: {
|
|
10
|
+
root: componentsRootProps
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
14
|
+
slots: {
|
|
15
|
+
badge: SlotsBadge
|
|
16
|
+
},
|
|
17
|
+
components: {
|
|
18
|
+
root: ComponentsRoot
|
|
19
|
+
},
|
|
20
|
+
slotProps: {
|
|
21
|
+
badge: slotsBadgeProps
|
|
22
|
+
},
|
|
23
|
+
componentsProps: {
|
|
24
|
+
root: componentsRootProps
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
28
|
+
slots: {
|
|
29
|
+
root: SlotsRoot,
|
|
30
|
+
badge: SlotsBadge
|
|
31
|
+
},
|
|
32
|
+
components: {
|
|
33
|
+
root: ComponentsRoot
|
|
34
|
+
},
|
|
35
|
+
slotProps: {
|
|
36
|
+
root: slotsRootProps,
|
|
37
|
+
badge: slotsBadgeProps
|
|
38
|
+
},
|
|
39
|
+
componentsProps: {
|
|
40
|
+
root: componentsRootProps
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
44
|
+
slots: {
|
|
45
|
+
root: SlotsRoot,
|
|
46
|
+
badge: SlotsBadge
|
|
47
|
+
},
|
|
48
|
+
components: {
|
|
49
|
+
root: ComponentsRoot
|
|
50
|
+
},
|
|
51
|
+
slotProps: {
|
|
52
|
+
root: slotsRootProps,
|
|
53
|
+
badge: slotsBadgeProps
|
|
54
|
+
},
|
|
55
|
+
componentsProps: {
|
|
56
|
+
root: componentsRootProps,
|
|
57
|
+
badge: componentsBadgeProps
|
|
58
|
+
}
|
|
59
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
var _material = require("@mui/material");
|
|
6
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
8
|
+
slots: {
|
|
9
|
+
root: ComponentsRoot
|
|
10
|
+
},
|
|
11
|
+
slotProps: {
|
|
12
|
+
root: componentsRootProps
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
16
|
+
slots: {
|
|
17
|
+
badge: SlotsBadge,
|
|
18
|
+
root: ComponentsRoot
|
|
19
|
+
},
|
|
20
|
+
slotProps: {
|
|
21
|
+
badge: slotsBadgeProps,
|
|
22
|
+
root: componentsRootProps
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
26
|
+
slots: {
|
|
27
|
+
root: SlotsRoot,
|
|
28
|
+
badge: SlotsBadge
|
|
29
|
+
},
|
|
30
|
+
slotProps: {
|
|
31
|
+
badge: slotsBadgeProps,
|
|
32
|
+
root: (0, _extends2.default)({}, componentsRootProps, slotsRootProps)
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Badge, {
|
|
36
|
+
slots: {
|
|
37
|
+
root: SlotsRoot,
|
|
38
|
+
badge: SlotsBadge
|
|
39
|
+
},
|
|
40
|
+
slotProps: {
|
|
41
|
+
root: (0, _extends2.default)({}, componentsRootProps, slotsRootProps),
|
|
42
|
+
badge: (0, _extends2.default)({}, componentsBadgeProps, slotsBadgeProps)
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
fn({
|
|
4
|
+
MuiBadge: {
|
|
5
|
+
defaultProps: {
|
|
6
|
+
components: {
|
|
7
|
+
root: ComponentsRoot
|
|
8
|
+
},
|
|
9
|
+
componentsProps: {
|
|
10
|
+
root: componentsRootProps
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
fn({
|
|
16
|
+
MuiBadge: {
|
|
17
|
+
defaultProps: {
|
|
18
|
+
components: {
|
|
19
|
+
root: ComponentsRoot
|
|
20
|
+
},
|
|
21
|
+
slots: {
|
|
22
|
+
badge: SlotsBadge
|
|
23
|
+
},
|
|
24
|
+
componentsProps: {
|
|
25
|
+
root: componentsRootProps
|
|
26
|
+
},
|
|
27
|
+
slotProps: {
|
|
28
|
+
badge: slotsBadgeProps
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
fn({
|
|
34
|
+
MuiBadge: {
|
|
35
|
+
defaultProps: {
|
|
36
|
+
components: {
|
|
37
|
+
root: ComponentsRoot
|
|
38
|
+
},
|
|
39
|
+
slots: {
|
|
40
|
+
badge: SlotsBadge,
|
|
41
|
+
root: SlotsRoot
|
|
42
|
+
},
|
|
43
|
+
componentsProps: {
|
|
44
|
+
root: componentsRootProps
|
|
45
|
+
},
|
|
46
|
+
slotProps: {
|
|
47
|
+
root: slotsRootProps,
|
|
48
|
+
badge: slotsBadgeProps
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
fn({
|
|
54
|
+
MuiBadge: {
|
|
55
|
+
defaultProps: {
|
|
56
|
+
components: {
|
|
57
|
+
root: ComponentsRoot
|
|
58
|
+
},
|
|
59
|
+
slots: {
|
|
60
|
+
badge: SlotsBadge,
|
|
61
|
+
root: SlotsRoot
|
|
62
|
+
},
|
|
63
|
+
componentsProps: {
|
|
64
|
+
root: componentsRootProps,
|
|
65
|
+
badge: componentsBadgeProps
|
|
66
|
+
},
|
|
67
|
+
slotProps: {
|
|
68
|
+
badge: slotsBadgeProps,
|
|
69
|
+
root: slotsRootProps
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
5
|
+
fn({
|
|
6
|
+
MuiBadge: {
|
|
7
|
+
defaultProps: {
|
|
8
|
+
slots: {
|
|
9
|
+
root: ComponentsRoot
|
|
10
|
+
},
|
|
11
|
+
slotProps: {
|
|
12
|
+
root: componentsRootProps
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
fn({
|
|
18
|
+
MuiBadge: {
|
|
19
|
+
defaultProps: {
|
|
20
|
+
slots: {
|
|
21
|
+
root: ComponentsRoot,
|
|
22
|
+
badge: SlotsBadge
|
|
23
|
+
},
|
|
24
|
+
slotProps: {
|
|
25
|
+
root: componentsRootProps,
|
|
26
|
+
badge: slotsBadgeProps
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
fn({
|
|
32
|
+
MuiBadge: {
|
|
33
|
+
defaultProps: {
|
|
34
|
+
slots: {
|
|
35
|
+
root: SlotsRoot,
|
|
36
|
+
badge: SlotsBadge
|
|
37
|
+
},
|
|
38
|
+
slotProps: {
|
|
39
|
+
root: (0, _extends2.default)({}, componentsRootProps, slotsRootProps),
|
|
40
|
+
badge: slotsBadgeProps
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
fn({
|
|
46
|
+
MuiBadge: {
|
|
47
|
+
defaultProps: {
|
|
48
|
+
slots: {
|
|
49
|
+
root: SlotsRoot,
|
|
50
|
+
badge: SlotsBadge
|
|
51
|
+
},
|
|
52
|
+
slotProps: {
|
|
53
|
+
root: (0, _extends2.default)({}, componentsRootProps, slotsRootProps),
|
|
54
|
+
badge: (0, _extends2.default)({}, componentsBadgeProps, slotsBadgeProps)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _stepConnectorClasses.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _stepConnectorClasses = _interopRequireDefault(require("./step-connector-classes"));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const classes = [{
|
|
4
|
+
deprecatedClass: ' .MuiStepConnector-lineHorizontal',
|
|
5
|
+
replacementSelector: '.MuiStepConnector-horizontal > .MuiStepConnector-line'
|
|
6
|
+
}, {
|
|
7
|
+
deprecatedClass: ' .MuiStepConnector-lineVertical',
|
|
8
|
+
replacementSelector: '.MuiStepConnector-vertical > .MuiStepConnector-line'
|
|
9
|
+
}];
|
|
10
|
+
const plugin = () => {
|
|
11
|
+
return {
|
|
12
|
+
postcssPlugin: `Replace deperecated StepConnector classes with new classes`,
|
|
13
|
+
Rule(rule) {
|
|
14
|
+
const {
|
|
15
|
+
selector
|
|
16
|
+
} = rule;
|
|
17
|
+
classes.forEach(({
|
|
18
|
+
deprecatedClass,
|
|
19
|
+
replacementSelector
|
|
20
|
+
}) => {
|
|
21
|
+
const selectorRegex = new RegExp(`${deprecatedClass}$`);
|
|
22
|
+
if (selector.match(selectorRegex)) {
|
|
23
|
+
rule.selector = selector.replace(selectorRegex, replacementSelector);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
plugin.postcss = true;
|
|
30
|
+
module.exports = {
|
|
31
|
+
plugin,
|
|
32
|
+
classes
|
|
33
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
var _postcssPlugin = require("./postcss-plugin");
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
10
|
+
* @param {import('jscodeshift').API} api
|
|
11
|
+
*/
|
|
12
|
+
function transformer(file, api, options) {
|
|
13
|
+
const j = api.jscodeshift;
|
|
14
|
+
const root = j(file.source);
|
|
15
|
+
const printOptions = options.printOptions;
|
|
16
|
+
_postcssPlugin.classes.forEach(({
|
|
17
|
+
deprecatedClass,
|
|
18
|
+
replacementSelector
|
|
19
|
+
}) => {
|
|
20
|
+
const replacementSelectorPrefix = '&';
|
|
21
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value.match(/^@mui\/material\/StepConnector$/)).forEach(path => {
|
|
22
|
+
path.node.specifiers.forEach(specifier => {
|
|
23
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'stepConnectorClasses') {
|
|
24
|
+
const deprecatedAtomicClass = deprecatedClass.replace(`${deprecatedClass.split('-')[0]}-`, '');
|
|
25
|
+
root.find(j.MemberExpression, {
|
|
26
|
+
object: {
|
|
27
|
+
name: specifier.local.name
|
|
28
|
+
},
|
|
29
|
+
property: {
|
|
30
|
+
name: deprecatedAtomicClass
|
|
31
|
+
}
|
|
32
|
+
}).forEach(memberExpression => {
|
|
33
|
+
const parent = memberExpression.parentPath.parentPath.value;
|
|
34
|
+
if (parent.type === j.TemplateLiteral.name) {
|
|
35
|
+
const memberExpressionIndex = parent.expressions.findIndex(expression => expression === memberExpression.value);
|
|
36
|
+
const precedingTemplateElement = parent.quasis[memberExpressionIndex];
|
|
37
|
+
const atomicClasses = replacementSelector.replaceAll('MuiStepConnector-', '').replaceAll(replacementSelectorPrefix, '').replaceAll(' > ', '').split('.').filter(Boolean);
|
|
38
|
+
if (precedingTemplateElement.value.raw.endsWith(deprecatedClass.startsWith(' ') ? `${replacementSelectorPrefix} .` : `${replacementSelectorPrefix}.`)) {
|
|
39
|
+
const atomicClassesArgs = [memberExpressionIndex, 1, ...atomicClasses.map(atomicClass => j.memberExpression(memberExpression.value.object, j.identifier(atomicClass)))];
|
|
40
|
+
parent.expressions.splice(...atomicClassesArgs);
|
|
41
|
+
if (replacementSelector.includes(' > ')) {
|
|
42
|
+
const quasisArgs = [memberExpressionIndex, 1, j.templateElement({
|
|
43
|
+
raw: precedingTemplateElement.value.raw.replace(' ', ''),
|
|
44
|
+
cooked: precedingTemplateElement.value.cooked.replace(' ', '')
|
|
45
|
+
}, false), j.templateElement({
|
|
46
|
+
raw: ' > .',
|
|
47
|
+
cooked: ' > .'
|
|
48
|
+
}, false)];
|
|
49
|
+
if (atomicClasses.length === 3) {
|
|
50
|
+
quasisArgs.splice(3, 0, j.templateElement({
|
|
51
|
+
raw: '.',
|
|
52
|
+
cooked: '.'
|
|
53
|
+
}, false));
|
|
54
|
+
}
|
|
55
|
+
parent.quasis.splice(...quasisArgs);
|
|
56
|
+
} else {
|
|
57
|
+
parent.quasis.splice(memberExpressionIndex, 1, j.templateElement({
|
|
58
|
+
raw: precedingTemplateElement.value.raw,
|
|
59
|
+
cooked: precedingTemplateElement.value.cooked
|
|
60
|
+
}, false), j.templateElement({
|
|
61
|
+
raw: '.',
|
|
62
|
+
cooked: '.'
|
|
63
|
+
}, false));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}$`);
|
|
72
|
+
root.find(j.Literal, literal => typeof literal.value === 'string' && literal.value.match(selectorRegex)).forEach(path => {
|
|
73
|
+
path.replace(j.literal(path.value.value.replace(selectorRegex, `${replacementSelectorPrefix}${replacementSelector}`)));
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return root.toSource(printOptions);
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _StepConnector = require("@mui/material/StepConnector");
|
|
4
|
+
'& .MuiStepConnector-lineHorizontal';
|
|
5
|
+
'& .MuiStepConnector-lineVertical';
|
|
6
|
+
`& .${_StepConnector.stepConnectorClasses.lineHorizontal}`;
|
|
7
|
+
`& .${_StepConnector.stepConnectorClasses.lineVertical}`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _StepConnector = require("@mui/material/StepConnector");
|
|
4
|
+
"&.MuiStepConnector-horizontal > .MuiStepConnector-line";
|
|
5
|
+
"&.MuiStepConnector-vertical > .MuiStepConnector-line";
|
|
6
|
+
`&.${_StepConnector.stepConnectorClasses.horizontal} > .${_StepConnector.stepConnectorClasses.line}`;
|
|
7
|
+
`&.${_StepConnector.stepConnectorClasses.vertical} > .${_StepConnector.stepConnectorClasses.line}`;
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = transformer;
|
|
8
8
|
var _replaceComponentsWithSlots = _interopRequireDefault(require("../utils/replaceComponentsWithSlots"));
|
|
9
|
+
var _movePropIntoSlots = _interopRequireDefault(require("../utils/movePropIntoSlots"));
|
|
10
|
+
var _movePropIntoSlotProps = _interopRequireDefault(require("../utils/movePropIntoSlotProps"));
|
|
9
11
|
/**
|
|
10
12
|
* @param {import('jscodeshift').FileInfo} file
|
|
11
13
|
* @param {import('jscodeshift').API} api
|
|
@@ -18,5 +20,17 @@ function transformer(file, api, options) {
|
|
|
18
20
|
root,
|
|
19
21
|
componentName: 'StepLabel'
|
|
20
22
|
});
|
|
23
|
+
(0, _movePropIntoSlots.default)(j, {
|
|
24
|
+
root,
|
|
25
|
+
componentName: 'StepLabel',
|
|
26
|
+
propName: 'StepIconComponent',
|
|
27
|
+
slotName: 'stepIcon'
|
|
28
|
+
});
|
|
29
|
+
(0, _movePropIntoSlotProps.default)(j, {
|
|
30
|
+
root,
|
|
31
|
+
componentName: 'StepLabel',
|
|
32
|
+
propName: 'StepIconProps',
|
|
33
|
+
slotName: 'stepIcon'
|
|
34
|
+
});
|
|
21
35
|
return root.toSource(printOptions);
|
|
22
36
|
}
|
|
@@ -18,4 +18,27 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
componentsProps: {
|
|
19
19
|
label: componentsLabelProps
|
|
20
20
|
}
|
|
21
|
+
});
|
|
22
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
23
|
+
componentsProps: {
|
|
24
|
+
label: componentsLabelProps
|
|
25
|
+
},
|
|
26
|
+
StepIconProps: StepIconProps
|
|
27
|
+
});
|
|
28
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
29
|
+
slots: {
|
|
30
|
+
label: SlotsLabel
|
|
31
|
+
},
|
|
32
|
+
slotProps: {
|
|
33
|
+
label: slotLabelProps
|
|
34
|
+
},
|
|
35
|
+
componentsProps: {
|
|
36
|
+
label: componentsLabelProps
|
|
37
|
+
},
|
|
38
|
+
StepIconComponent: StepIconComponent,
|
|
39
|
+
StepIconProps: StepIconProps
|
|
40
|
+
});
|
|
41
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
42
|
+
StepIconComponent: StepIconComponent,
|
|
43
|
+
StepIconProps: StepIconProps
|
|
21
44
|
});
|
|
@@ -16,4 +16,28 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
16
16
|
slotProps: {
|
|
17
17
|
label: (0, _extends2.default)({}, componentsLabelProps, slotLabelProps)
|
|
18
18
|
}
|
|
19
|
+
});
|
|
20
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
21
|
+
slotProps: {
|
|
22
|
+
label: componentsLabelProps,
|
|
23
|
+
stepIcon: StepIconProps
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
27
|
+
slots: {
|
|
28
|
+
label: SlotsLabel,
|
|
29
|
+
stepIcon: StepIconComponent
|
|
30
|
+
},
|
|
31
|
+
slotProps: {
|
|
32
|
+
label: (0, _extends2.default)({}, componentsLabelProps, slotLabelProps),
|
|
33
|
+
stepIcon: StepIconProps
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
/*#__PURE__*/(0, _jsxRuntime.jsx)(_StepLabel.default, {
|
|
37
|
+
slots: {
|
|
38
|
+
stepIcon: StepIconComponent
|
|
39
|
+
},
|
|
40
|
+
slotProps: {
|
|
41
|
+
stepIcon: StepIconProps
|
|
42
|
+
}
|
|
19
43
|
});
|