@mui/codemod 7.2.0 → 7.3.2
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/CHANGELOG.md +897 -0
- package/README.md +42 -1
- package/package.json +8 -16
- package/util/migrateToVariants.js +5 -5
- package/v1.0.0/color-imports.js +1 -1
- package/v5.0.0/jss-to-styled.test/first.actual.js +15 -6
- package/v5.0.0/jss-to-styled.test/first.expected.js +15 -6
- package/v5.0.0/jss-to-styled.test/sixth.actual.js +5 -3
- package/v5.0.0/jss-to-styled.test/sixth.expected.js +5 -3
- package/v5.0.0/path-imports.js +90 -0
- package/v5.0.0/path-imports.test/actual.js +8 -0
- package/v5.0.0/path-imports.test/expected.js +66 -0
- package/v5.0.0/theme-spacing.test/large-actual.js +2 -2
- package/v5.0.0/theme-spacing.test/large-expected.js +2 -2
- package/v5.0.0/top-level-imports.js +1 -1
- package/v5.0.0/top-level-imports.test/actual.js +2 -2
- package/v5.0.0/top-level-imports.test/expected.js +2 -0
- package/v6.0.0/styled/styled-v6.js +1 -1
- package/v6.0.0/theme-v6/theme-v6.js +1 -1
- package/v7.0.0/theme-color-functions/index.js +13 -0
- package/v7.0.0/theme-color-functions/test-cases/actual.js +21 -0
- package/v7.0.0/theme-color-functions/test-cases/darken-basic.actual.js +20 -0
- package/v7.0.0/theme-color-functions/test-cases/darken-basic.expected.js +19 -0
- package/v7.0.0/theme-color-functions/test-cases/expected.js +20 -0
- package/v7.0.0/theme-color-functions/test-cases/lighten-basic.actual.js +13 -0
- package/v7.0.0/theme-color-functions/test-cases/lighten-basic.expected.js +12 -0
- package/v7.0.0/theme-color-functions/test-cases/mixed-functions.actual.js +17 -0
- package/v7.0.0/theme-color-functions/test-cases/mixed-functions.expected.js +16 -0
- package/v7.0.0/theme-color-functions/test-cases/mixed-imports.actual.js +19 -0
- package/v7.0.0/theme-color-functions/test-cases/mixed-imports.expected.js +18 -0
- package/v7.0.0/theme-color-functions/test-cases/mui-material-styles.actual.js +18 -0
- package/v7.0.0/theme-color-functions/test-cases/mui-material-styles.expected.js +17 -0
- package/v7.0.0/theme-color-functions/test-cases/no-import.actual.js +11 -0
- package/v7.0.0/theme-color-functions/test-cases/no-import.expected.js +11 -0
- package/v7.0.0/theme-color-functions/test-cases/opacity-calc.actual.js +57 -0
- package/v7.0.0/theme-color-functions/test-cases/opacity-calc.expected.js +56 -0
- package/v7.0.0/theme-color-functions/test-cases/opacity-var.actual.js +37 -0
- package/v7.0.0/theme-color-functions/test-cases/opacity-var.expected.js +36 -0
- package/v7.0.0/theme-color-functions/theme-color-functions.js +142 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Value = styled('div')(({
|
|
4
|
+
theme
|
|
5
|
+
}) => ({
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
lineHeight: '100%',
|
|
9
|
+
paddingRight: 8,
|
|
10
|
+
fontVariantNumeric: 'tabular-nums',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'flex-end',
|
|
14
|
+
'&.good': {
|
|
15
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.success.main, 0.3)
|
|
16
|
+
},
|
|
17
|
+
'&.bad': {
|
|
18
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.error.main, 0.3)
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
4
|
+
const Component = styled('div')(({
|
|
5
|
+
theme
|
|
6
|
+
}) => ({
|
|
7
|
+
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.main, 0.2),
|
|
8
|
+
color: (0, _colorManipulator.lighten)(theme.palette.text.primary, 0.5),
|
|
9
|
+
border: `1px solid ${(0, _colorManipulator.lighten)(theme.palette.divider, 0.1)}`,
|
|
10
|
+
'&:hover': {
|
|
11
|
+
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.dark, 0.3)
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Component = styled('div')(({
|
|
4
|
+
theme
|
|
5
|
+
}) => ({
|
|
6
|
+
backgroundColor: theme.lighten(theme.palette.primary.main, 0.2),
|
|
7
|
+
color: theme.lighten(theme.palette.text.primary, 0.5),
|
|
8
|
+
border: `1px solid ${theme.lighten(theme.palette.divider, 0.1)}`,
|
|
9
|
+
'&:hover': {
|
|
10
|
+
backgroundColor: theme.lighten(theme.palette.primary.dark, 0.3)
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
4
|
+
const ComplexComponent = styled('div')(({
|
|
5
|
+
theme
|
|
6
|
+
}) => ({
|
|
7
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / 0.1)` : (0, _colorManipulator.alpha)(theme.palette.primary.main, 0.1),
|
|
8
|
+
border: `2px solid ${(0, _colorManipulator.lighten)(theme.palette.primary.main, 0.5)}`,
|
|
9
|
+
'&:hover': {
|
|
10
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / 0.2)` : (0, _colorManipulator.alpha)(theme.palette.primary.main, 0.2),
|
|
11
|
+
borderColor: (0, _colorManipulator.darken)(theme.palette.primary.main, 0.2)
|
|
12
|
+
},
|
|
13
|
+
'&:active': {
|
|
14
|
+
backgroundColor: (0, _colorManipulator.darken)(theme.palette.primary.dark, 0.1),
|
|
15
|
+
color: (0, _colorManipulator.lighten)(theme.palette.primary.contrastText, 0.3)
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const ComplexComponent = styled('div')(({
|
|
4
|
+
theme
|
|
5
|
+
}) => ({
|
|
6
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, 0.1),
|
|
7
|
+
border: `2px solid ${theme.lighten(theme.palette.primary.main, 0.5)}`,
|
|
8
|
+
'&:hover': {
|
|
9
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, 0.2),
|
|
10
|
+
borderColor: theme.darken(theme.palette.primary.main, 0.2)
|
|
11
|
+
},
|
|
12
|
+
'&:active': {
|
|
13
|
+
backgroundColor: theme.darken(theme.palette.primary.dark, 0.1),
|
|
14
|
+
color: theme.lighten(theme.palette.primary.contrastText, 0.3)
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Component = void 0;
|
|
7
|
+
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
8
|
+
var _styles = require("@mui/material/styles");
|
|
9
|
+
const Component = exports.Component = (0, _styles.styled)('div')(({
|
|
10
|
+
theme
|
|
11
|
+
}) => ({
|
|
12
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / 0.5)` : (0, _colorManipulator.alpha)(theme.palette.primary.main, 0.5),
|
|
13
|
+
'&:hover': {
|
|
14
|
+
backgroundColor: (0, _styles.lighten)(theme.palette.primary.main, 0.2)
|
|
15
|
+
},
|
|
16
|
+
'&:active': {
|
|
17
|
+
backgroundColor: (0, _styles.darken)(theme.palette.primary.main, 0.2)
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Component = void 0;
|
|
7
|
+
var _styles = require("@mui/material/styles");
|
|
8
|
+
const Component = exports.Component = (0, _styles.styled)('div')(({
|
|
9
|
+
theme
|
|
10
|
+
}) => ({
|
|
11
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, 0.5),
|
|
12
|
+
'&:hover': {
|
|
13
|
+
backgroundColor: theme.lighten(theme.palette.primary.main, 0.2)
|
|
14
|
+
},
|
|
15
|
+
'&:active': {
|
|
16
|
+
backgroundColor: theme.darken(theme.palette.primary.main, 0.2)
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Component = void 0;
|
|
7
|
+
var _styles = require("@mui/material/styles");
|
|
8
|
+
const Component = exports.Component = styled('div')(({
|
|
9
|
+
theme
|
|
10
|
+
}) => ({
|
|
11
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / 0.5)` : (0, _styles.alpha)(theme.palette.primary.main, 0.5),
|
|
12
|
+
'&:hover': {
|
|
13
|
+
backgroundColor: (0, _styles.lighten)(theme.palette.primary.main, 0.2)
|
|
14
|
+
},
|
|
15
|
+
'&:active': {
|
|
16
|
+
backgroundColor: (0, _styles.darken)(theme.palette.primary.main, 0.2)
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Component = void 0;
|
|
7
|
+
const Component = exports.Component = styled('div')(({
|
|
8
|
+
theme
|
|
9
|
+
}) => ({
|
|
10
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, 0.5),
|
|
11
|
+
'&:hover': {
|
|
12
|
+
backgroundColor: theme.lighten(theme.palette.primary.main, 0.2)
|
|
13
|
+
},
|
|
14
|
+
'&:active': {
|
|
15
|
+
backgroundColor: theme.darken(theme.palette.primary.main, 0.2)
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// This file should not be transformed because it doesn't import from @mui/system/colorManipulator
|
|
4
|
+
|
|
5
|
+
const Component = styled('div')(({
|
|
6
|
+
theme
|
|
7
|
+
}) => ({
|
|
8
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.1),
|
|
9
|
+
color: lighten(theme.palette.text.primary, 0.5),
|
|
10
|
+
border: `1px solid ${darken(theme.palette.divider, 0.2)}`
|
|
11
|
+
}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// This file should not be transformed because it doesn't import from @mui/system/colorManipulator
|
|
4
|
+
|
|
5
|
+
const Component = styled('div')(({
|
|
6
|
+
theme
|
|
7
|
+
}) => ({
|
|
8
|
+
backgroundColor: alpha(theme.palette.primary.main, 0.1),
|
|
9
|
+
color: lighten(theme.palette.text.primary, 0.5),
|
|
10
|
+
border: `1px solid ${darken(theme.palette.divider, 0.2)}`
|
|
11
|
+
}));
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TreeItemContent = void 0;
|
|
7
|
+
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
8
|
+
const TreeItemContent = exports.TreeItemContent = styled('div', {
|
|
9
|
+
name: 'MuiTreeItem',
|
|
10
|
+
slot: 'Content',
|
|
11
|
+
overridesResolver: (props, styles) => styles.content,
|
|
12
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'status'
|
|
13
|
+
}) < {
|
|
14
|
+
status: UseTreeItemStatus
|
|
15
|
+
} > (({
|
|
16
|
+
theme
|
|
17
|
+
}) => ({
|
|
18
|
+
padding: theme.spacing(0.5, 1),
|
|
19
|
+
paddingLeft: `calc(${theme.spacing(1)} + var(--TreeView-itemChildrenIndentation) * var(--TreeView-itemDepth))`,
|
|
20
|
+
borderRadius: theme.shape.borderRadius,
|
|
21
|
+
width: '100%',
|
|
22
|
+
boxSizing: 'border-box',
|
|
23
|
+
// prevent width + padding to overflow
|
|
24
|
+
position: 'relative',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
gap: theme.spacing(1),
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
WebkitTapHighlightColor: 'transparent',
|
|
30
|
+
'&:hover': {
|
|
31
|
+
backgroundColor: (theme.vars || theme).palette.action.hover,
|
|
32
|
+
// Reset on touch devices, it doesn't add specificity
|
|
33
|
+
'@media (hover: none)': {
|
|
34
|
+
backgroundColor: 'transparent'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
'&[data-disabled]': {
|
|
38
|
+
opacity: (theme.vars || theme).palette.action.disabledOpacity,
|
|
39
|
+
backgroundColor: 'transparent'
|
|
40
|
+
},
|
|
41
|
+
'&[data-focused]': {
|
|
42
|
+
backgroundColor: (theme.vars || theme).palette.action.focus
|
|
43
|
+
},
|
|
44
|
+
'&[data-selected]': {
|
|
45
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.selectedOpacity})` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.selectedOpacity),
|
|
46
|
+
'&:hover': {
|
|
47
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.hoverOpacity}))` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity),
|
|
48
|
+
// Reset on touch devices, it doesn't add specificity
|
|
49
|
+
'@media (hover: none)': {
|
|
50
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.selectedOpacity})` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.selectedOpacity)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
'&[data-selected][data-focused]': {
|
|
55
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.focusOpacity}))` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.focusOpacity)
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TreeItemContent = void 0;
|
|
7
|
+
const TreeItemContent = exports.TreeItemContent = styled('div', {
|
|
8
|
+
name: 'MuiTreeItem',
|
|
9
|
+
slot: 'Content',
|
|
10
|
+
overridesResolver: (props, styles) => styles.content,
|
|
11
|
+
shouldForwardProp: prop => shouldForwardProp(prop) && prop !== 'status'
|
|
12
|
+
}) < {
|
|
13
|
+
status: UseTreeItemStatus
|
|
14
|
+
} > (({
|
|
15
|
+
theme
|
|
16
|
+
}) => ({
|
|
17
|
+
padding: theme.spacing(0.5, 1),
|
|
18
|
+
paddingLeft: `calc(${theme.spacing(1)} + var(--TreeView-itemChildrenIndentation) * var(--TreeView-itemDepth))`,
|
|
19
|
+
borderRadius: theme.shape.borderRadius,
|
|
20
|
+
width: '100%',
|
|
21
|
+
boxSizing: 'border-box',
|
|
22
|
+
// prevent width + padding to overflow
|
|
23
|
+
position: 'relative',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
gap: theme.spacing(1),
|
|
27
|
+
cursor: 'pointer',
|
|
28
|
+
WebkitTapHighlightColor: 'transparent',
|
|
29
|
+
'&:hover': {
|
|
30
|
+
backgroundColor: (theme.vars || theme).palette.action.hover,
|
|
31
|
+
// Reset on touch devices, it doesn't add specificity
|
|
32
|
+
'@media (hover: none)': {
|
|
33
|
+
backgroundColor: 'transparent'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
'&[data-disabled]': {
|
|
37
|
+
opacity: (theme.vars || theme).palette.action.disabledOpacity,
|
|
38
|
+
backgroundColor: 'transparent'
|
|
39
|
+
},
|
|
40
|
+
'&[data-focused]': {
|
|
41
|
+
backgroundColor: (theme.vars || theme).palette.action.focus
|
|
42
|
+
},
|
|
43
|
+
'&[data-selected]': {
|
|
44
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, (theme.vars || theme).palette.action.selectedOpacity),
|
|
45
|
+
'&:hover': {
|
|
46
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.hoverOpacity}`),
|
|
47
|
+
// Reset on touch devices, it doesn't add specificity
|
|
48
|
+
'@media (hover: none)': {
|
|
49
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, (theme.vars || theme).palette.action.selectedOpacity)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
'&[data-selected][data-focused]': {
|
|
54
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, `${(theme.vars || theme).palette.action.selectedOpacity} + ${(theme.vars || theme).palette.action.focusOpacity}`)
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DigitalClockItem = void 0;
|
|
7
|
+
var _colorManipulator = require("@mui/system/colorManipulator");
|
|
8
|
+
const DigitalClockItem = exports.DigitalClockItem = styled(MenuItem, {
|
|
9
|
+
name: 'MuiDigitalClock',
|
|
10
|
+
slot: 'Item',
|
|
11
|
+
shouldForwardProp: prop => prop !== 'itemValue' && prop !== 'formattedValue',
|
|
12
|
+
overridesResolver: (props, styles) => styles.item
|
|
13
|
+
})(({
|
|
14
|
+
theme
|
|
15
|
+
}) => ({
|
|
16
|
+
padding: '8px 16px',
|
|
17
|
+
margin: '2px 4px',
|
|
18
|
+
'&:first-of-type': {
|
|
19
|
+
marginTop: 4
|
|
20
|
+
},
|
|
21
|
+
'&:hover': {
|
|
22
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.hoverOpacity})` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.hoverOpacity)
|
|
23
|
+
},
|
|
24
|
+
'&.Mui-selected': {
|
|
25
|
+
backgroundColor: (theme.vars || theme).palette.primary.main,
|
|
26
|
+
color: (theme.vars || theme).palette.primary.contrastText,
|
|
27
|
+
'&:focus-visible, &:hover': {
|
|
28
|
+
backgroundColor: (theme.vars || theme).palette.primary.dark
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
'&.Mui-focusVisible': {
|
|
32
|
+
backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.focusOpacity})` : (0, _colorManipulator.alpha)(theme.palette.primary.main, theme.palette.action.focusOpacity)
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
function transform(t) {
|
|
36
|
+
const backgroundBackdrop = t.vars ? `rgba(${t.vars.palette.background.defaultChannel} / ${t.vars.palette.action.disabledOpacity})` : (0, _colorManipulator.alpha)(t.palette.background.default, t.palette.action.disabledOpacity);
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DigitalClockItem = void 0;
|
|
7
|
+
const DigitalClockItem = exports.DigitalClockItem = styled(MenuItem, {
|
|
8
|
+
name: 'MuiDigitalClock',
|
|
9
|
+
slot: 'Item',
|
|
10
|
+
shouldForwardProp: prop => prop !== 'itemValue' && prop !== 'formattedValue',
|
|
11
|
+
overridesResolver: (props, styles) => styles.item
|
|
12
|
+
})(({
|
|
13
|
+
theme
|
|
14
|
+
}) => ({
|
|
15
|
+
padding: '8px 16px',
|
|
16
|
+
margin: '2px 4px',
|
|
17
|
+
'&:first-of-type': {
|
|
18
|
+
marginTop: 4
|
|
19
|
+
},
|
|
20
|
+
'&:hover': {
|
|
21
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, (theme.vars || theme).palette.action.hoverOpacity)
|
|
22
|
+
},
|
|
23
|
+
'&.Mui-selected': {
|
|
24
|
+
backgroundColor: (theme.vars || theme).palette.primary.main,
|
|
25
|
+
color: (theme.vars || theme).palette.primary.contrastText,
|
|
26
|
+
'&:focus-visible, &:hover': {
|
|
27
|
+
backgroundColor: (theme.vars || theme).palette.primary.dark
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
'&.Mui-focusVisible': {
|
|
31
|
+
backgroundColor: theme.alpha((theme.vars || theme).palette.primary.main, (theme.vars || theme).palette.action.focusOpacity)
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
function transform(t) {
|
|
35
|
+
const backgroundBackdrop = t.alpha((t.vars || t).palette.background.default, (t.vars || t).palette.action.disabledOpacity);
|
|
36
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
if (file.path?.endsWith('.d.ts')) {
|
|
13
|
+
return file.source;
|
|
14
|
+
}
|
|
15
|
+
const j = api.jscodeshift;
|
|
16
|
+
const root = j(file.source);
|
|
17
|
+
const printOptions = options.printOptions;
|
|
18
|
+
|
|
19
|
+
// Check if the file imports alpha, lighten, or darken from @mui/system/colorManipulator or @mui/material/styles
|
|
20
|
+
let hasAlphaImport = false;
|
|
21
|
+
let hasLightenImport = false;
|
|
22
|
+
let hasDarkenImport = false;
|
|
23
|
+
const importSources = ['@mui/system/colorManipulator', '@mui/material/styles', '@mui/material'];
|
|
24
|
+
importSources.forEach(source => {
|
|
25
|
+
root.find(j.ImportDeclaration, {
|
|
26
|
+
source: {
|
|
27
|
+
value: source
|
|
28
|
+
}
|
|
29
|
+
}).forEach(path => {
|
|
30
|
+
path.node.specifiers.forEach(spec => {
|
|
31
|
+
if (spec.type === 'ImportSpecifier') {
|
|
32
|
+
if (spec.imported.name === 'alpha') {
|
|
33
|
+
hasAlphaImport = true;
|
|
34
|
+
}
|
|
35
|
+
if (spec.imported.name === 'lighten') {
|
|
36
|
+
hasLightenImport = true;
|
|
37
|
+
}
|
|
38
|
+
if (spec.imported.name === 'darken') {
|
|
39
|
+
hasDarkenImport = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Skip transformation if none of the functions are imported
|
|
47
|
+
if (!hasAlphaImport && !hasLightenImport && !hasDarkenImport) {
|
|
48
|
+
return file.source;
|
|
49
|
+
}
|
|
50
|
+
function replaceThemeWithVars(node, objectName) {
|
|
51
|
+
if (node.type === 'MemberExpression') {
|
|
52
|
+
let deepnode = node;
|
|
53
|
+
while (deepnode.object && deepnode.object.type === 'MemberExpression') {
|
|
54
|
+
deepnode = deepnode.object;
|
|
55
|
+
}
|
|
56
|
+
deepnode.object = j.logicalExpression('||', j.memberExpression(j.identifier(objectName), j.identifier('vars')), j.identifier(objectName));
|
|
57
|
+
}
|
|
58
|
+
if (node.type === 'BinaryExpression') {
|
|
59
|
+
return j.templateLiteral([j.templateElement({
|
|
60
|
+
raw: '',
|
|
61
|
+
cooked: ''
|
|
62
|
+
}, false), j.templateElement({
|
|
63
|
+
raw: ' + ',
|
|
64
|
+
cooked: ' + '
|
|
65
|
+
}, false), j.templateElement({
|
|
66
|
+
raw: '',
|
|
67
|
+
cooked: ''
|
|
68
|
+
}, true)], [replaceThemeWithVars(node.left, objectName), replaceThemeWithVars(node.right, objectName)]);
|
|
69
|
+
}
|
|
70
|
+
return node;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Transform alpha function
|
|
74
|
+
if (hasAlphaImport) {
|
|
75
|
+
root.find(j.ConditionalExpression).forEach(path => {
|
|
76
|
+
if (path.node.test.type === 'MemberExpression') {
|
|
77
|
+
if (path.node.test.property.name === 'vars') {
|
|
78
|
+
if (path.node.alternate.type === 'CallExpression' && path.node.alternate.callee.name === 'alpha' && path.node.consequent.type === 'TemplateLiteral') {
|
|
79
|
+
path.replace(j.callExpression(j.memberExpression(j.identifier(path.node.test.object.name), j.identifier('alpha')), [replaceThemeWithVars(path.node.alternate.arguments[0], path.node.test.object.name), replaceThemeWithVars(path.node.alternate.arguments[1], path.node.test.object.name)]));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
root.find(j.CallExpression, {
|
|
85
|
+
callee: {
|
|
86
|
+
name: 'alpha'
|
|
87
|
+
}
|
|
88
|
+
}).forEach(path => {
|
|
89
|
+
path.replace(j.callExpression(j.memberExpression(j.identifier('theme'), j.identifier('alpha')), path.node.arguments));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Transform lighten function
|
|
94
|
+
if (hasLightenImport) {
|
|
95
|
+
root.find(j.CallExpression, {
|
|
96
|
+
callee: {
|
|
97
|
+
name: 'lighten'
|
|
98
|
+
}
|
|
99
|
+
}).forEach(path => {
|
|
100
|
+
path.replace(j.callExpression(j.memberExpression(j.identifier('theme'), j.identifier('lighten')), path.node.arguments));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Transform darken function
|
|
105
|
+
if (hasDarkenImport) {
|
|
106
|
+
root.find(j.CallExpression, {
|
|
107
|
+
callee: {
|
|
108
|
+
name: 'darken'
|
|
109
|
+
}
|
|
110
|
+
}).forEach(path => {
|
|
111
|
+
path.replace(j.callExpression(j.memberExpression(j.identifier('theme'), j.identifier('darken')), path.node.arguments));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Remove transformed functions from import statements
|
|
116
|
+
importSources.forEach(source => {
|
|
117
|
+
root.find(j.ImportDeclaration, {
|
|
118
|
+
source: {
|
|
119
|
+
value: source
|
|
120
|
+
}
|
|
121
|
+
}).forEach(path => {
|
|
122
|
+
const specifiers = path.node.specifiers.filter(spec => {
|
|
123
|
+
if (spec.type === 'ImportSpecifier') {
|
|
124
|
+
const name = spec.imported.name;
|
|
125
|
+
// Remove if it was transformed
|
|
126
|
+
if (name === 'alpha' && hasAlphaImport || name === 'lighten' && hasLightenImport || name === 'darken' && hasDarkenImport) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
});
|
|
132
|
+
if (specifiers.length === 0) {
|
|
133
|
+
// Remove the import entirely if no specifiers left
|
|
134
|
+
j(path).remove();
|
|
135
|
+
} else {
|
|
136
|
+
// Update the import with remaining specifiers
|
|
137
|
+
path.node.specifiers = specifiers;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
return root.toSource(printOptions);
|
|
142
|
+
}
|