@mui/material 6.0.0-beta.2 → 6.0.0-beta.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/CHANGELOG.md +427 -33
- package/Fade/Fade.js +2 -1
- package/Grow/Grow.js +2 -1
- package/Paper/Paper.js +1 -1
- package/Rating/Rating.d.ts +1 -1
- package/Rating/Rating.js +2 -2
- package/Select/selectClasses.d.ts +2 -0
- package/Slide/Slide.js +2 -1
- package/Tooltip/Tooltip.js +2 -1
- package/Typography/Typography.d.ts +1 -0
- package/Typography/Typography.js +1 -0
- package/Typography/typographyClasses.d.ts +4 -1
- package/Zoom/Zoom.js +2 -1
- package/index.js +1 -1
- package/modern/Fade/Fade.js +2 -1
- package/modern/Grow/Grow.js +2 -1
- package/modern/Paper/Paper.js +1 -1
- package/modern/Rating/Rating.js +2 -2
- package/modern/Slide/Slide.js +2 -1
- package/modern/Tooltip/Tooltip.js +2 -1
- package/modern/Typography/Typography.js +1 -0
- package/modern/Zoom/Zoom.js +2 -1
- package/modern/index.js +1 -1
- package/modern/styles/CssVarsProvider.js +0 -1
- package/modern/styles/createGetSelector.js +36 -7
- package/modern/styles/excludeVariablesFromRoot.js +1 -1
- package/modern/styles/extendTheme.js +105 -65
- package/modern/styles/shouldSkipGeneratingVar.js +1 -1
- package/modern/utils/getChildRef.js +9 -0
- package/node/Fade/Fade.js +2 -1
- package/node/Grow/Grow.js +2 -1
- package/node/Paper/Paper.js +2 -2
- package/node/Rating/Rating.js +2 -2
- package/node/Slide/Slide.js +2 -1
- package/node/Tooltip/Tooltip.js +2 -1
- package/node/Typography/Typography.js +1 -0
- package/node/Zoom/Zoom.js +2 -1
- package/node/index.js +1 -1
- package/node/styles/CssVarsProvider.js +0 -1
- package/node/styles/createGetSelector.js +36 -7
- package/node/styles/excludeVariablesFromRoot.js +1 -1
- package/node/styles/extendTheme.js +105 -65
- package/node/styles/shouldSkipGeneratingVar.js +1 -1
- package/node/utils/getChildRef.js +17 -0
- package/package.json +6 -6
- package/styles/CssVarsProvider.d.ts +2 -1
- package/styles/CssVarsProvider.js +0 -1
- package/styles/createGetSelector.d.ts +6 -2
- package/styles/createGetSelector.js +36 -7
- package/styles/excludeVariablesFromRoot.d.ts +1 -1
- package/styles/excludeVariablesFromRoot.js +1 -1
- package/styles/extendTheme.d.ts +21 -16
- package/styles/extendTheme.js +105 -65
- package/styles/shouldSkipGeneratingVar.js +1 -1
- package/utils/getChildRef.d.ts +1 -0
- package/utils/getChildRef.js +9 -0
package/Fade/Fade.js
CHANGED
|
@@ -7,6 +7,7 @@ import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
|
|
7
7
|
import { useTheme } from '../zero-styled';
|
|
8
8
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
9
9
|
import useForkRef from '../utils/useForkRef';
|
|
10
|
+
import getChildRef from '../utils/getChildRef';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const styles = {
|
|
12
13
|
entering: {
|
|
@@ -47,7 +48,7 @@ const Fade = /*#__PURE__*/React.forwardRef(function Fade(props, ref) {
|
|
|
47
48
|
} = props;
|
|
48
49
|
const enableStrictModeCompat = true;
|
|
49
50
|
const nodeRef = React.useRef(null);
|
|
50
|
-
const handleRef = useForkRef(nodeRef, children
|
|
51
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
51
52
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
52
53
|
if (callback) {
|
|
53
54
|
const node = nodeRef.current;
|
package/Grow/Grow.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Transition } from 'react-transition-group';
|
|
|
8
8
|
import { useTheme } from '../zero-styled';
|
|
9
9
|
import { getTransitionProps, reflow } from '../transitions/utils';
|
|
10
10
|
import useForkRef from '../utils/useForkRef';
|
|
11
|
+
import getChildRef from '../utils/getChildRef';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
function getScale(value) {
|
|
13
14
|
return `scale(${value}, ${value ** 2})`;
|
|
@@ -57,7 +58,7 @@ const Grow = /*#__PURE__*/React.forwardRef(function Grow(props, ref) {
|
|
|
57
58
|
const autoTimeout = React.useRef();
|
|
58
59
|
const theme = useTheme();
|
|
59
60
|
const nodeRef = React.useRef(null);
|
|
60
|
-
const handleRef = useForkRef(nodeRef, children
|
|
61
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
61
62
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
62
63
|
if (callback) {
|
|
63
64
|
const node = nodeRef.current;
|
package/Paper/Paper.js
CHANGED
|
@@ -100,7 +100,7 @@ const Paper = /*#__PURE__*/React.forwardRef(function Paper(inProps, ref) {
|
|
|
100
100
|
...(variant === 'elevation' && {
|
|
101
101
|
'--Paper-shadow': (theme.vars || theme).shadows[elevation],
|
|
102
102
|
...(theme.vars && {
|
|
103
|
-
'--Paper-overlay': theme.overlays?.[elevation]
|
|
103
|
+
'--Paper-overlay': theme.vars.overlays?.[elevation]
|
|
104
104
|
}),
|
|
105
105
|
...(!theme.vars && theme.palette.mode === 'dark' && {
|
|
106
106
|
'--Paper-overlay': `linear-gradient(${alpha('#fff', getOverlayAlpha(elevation))}, ${alpha('#fff', getOverlayAlpha(elevation))})`
|
package/Rating/Rating.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface RatingProps
|
|
|
44
44
|
* @param {number} value The rating label's value to format.
|
|
45
45
|
* @returns {string}
|
|
46
46
|
* @default function defaultLabelText(value) {
|
|
47
|
-
* return `${value} Star${value !== 1 ? 's' : ''}`;
|
|
47
|
+
* return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
|
|
48
48
|
* }
|
|
49
49
|
*/
|
|
50
50
|
getLabelText?: (value: number) => string;
|
package/Rating/Rating.js
CHANGED
|
@@ -303,7 +303,7 @@ const defaultEmptyIcon = /*#__PURE__*/_jsx(StarBorder, {
|
|
|
303
303
|
fontSize: "inherit"
|
|
304
304
|
});
|
|
305
305
|
function defaultLabelText(value) {
|
|
306
|
-
return `${value} Star${value !== 1 ? 's' : ''}`;
|
|
306
|
+
return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
|
|
307
307
|
}
|
|
308
308
|
const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
|
|
309
309
|
const props = useDefaultProps({
|
|
@@ -588,7 +588,7 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
|
|
|
588
588
|
* @param {number} value The rating label's value to format.
|
|
589
589
|
* @returns {string}
|
|
590
590
|
* @default function defaultLabelText(value) {
|
|
591
|
-
* return `${value} Star${value !== 1 ? 's' : ''}`;
|
|
591
|
+
* return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
|
|
592
592
|
* }
|
|
593
593
|
*/
|
|
594
594
|
getLabelText: PropTypes.func,
|
|
@@ -7,6 +7,8 @@ export interface SelectClasses {
|
|
|
7
7
|
multiple: string;
|
|
8
8
|
/** Styles applied to the select component if `variant="filled"`. */
|
|
9
9
|
filled: string;
|
|
10
|
+
/** Styles applied to the select component if it is focused. */
|
|
11
|
+
focused: string;
|
|
10
12
|
/** Styles applied to the select component if `variant="outlined"`. */
|
|
11
13
|
outlined: string;
|
|
12
14
|
/** Styles applied to the select component if `variant="standard"`. */
|
package/Slide/Slide.js
CHANGED
|
@@ -11,6 +11,7 @@ import useForkRef from '../utils/useForkRef';
|
|
|
11
11
|
import { useTheme } from '../zero-styled';
|
|
12
12
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
13
13
|
import { ownerWindow } from '../utils';
|
|
14
|
+
import getChildRef from '../utils/getChildRef';
|
|
14
15
|
|
|
15
16
|
// Translate the node so it can't be seen on the screen.
|
|
16
17
|
// Later, we're going to translate the node back to its original location with `none`.
|
|
@@ -105,7 +106,7 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
105
106
|
...other
|
|
106
107
|
} = props;
|
|
107
108
|
const childrenRef = React.useRef(null);
|
|
108
|
-
const handleRef = useForkRef(children
|
|
109
|
+
const handleRef = useForkRef(getChildRef(children), childrenRef, ref);
|
|
109
110
|
const normalizedTransitionCallback = callback => isAppearing => {
|
|
110
111
|
if (callback) {
|
|
111
112
|
// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
|
package/Tooltip/Tooltip.js
CHANGED
|
@@ -20,6 +20,7 @@ import useForkRef from '../utils/useForkRef';
|
|
|
20
20
|
import useId from '../utils/useId';
|
|
21
21
|
import useControlled from '../utils/useControlled';
|
|
22
22
|
import tooltipClasses, { getTooltipUtilityClass } from './tooltipClasses';
|
|
23
|
+
import getChildRef from '../utils/getChildRef';
|
|
23
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
25
|
function round(value) {
|
|
25
26
|
return Math.round(value * 1e5) / 1e5;
|
|
@@ -510,7 +511,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(inProps, ref) {
|
|
|
510
511
|
document.removeEventListener('keydown', handleKeyDown);
|
|
511
512
|
};
|
|
512
513
|
}, [handleClose, open]);
|
|
513
|
-
const handleRef = useForkRef(children
|
|
514
|
+
const handleRef = useForkRef(getChildRef(children), setChildNode, ref);
|
|
514
515
|
|
|
515
516
|
// There is no point in displaying an empty tooltip.
|
|
516
517
|
// So we exclude all falsy values, except 0, which is valid.
|
|
@@ -38,6 +38,7 @@ export interface TypographyOwnProps extends SystemProps<Theme> {
|
|
|
38
38
|
/**
|
|
39
39
|
* If `true`, the element will be a paragraph element.
|
|
40
40
|
* @default false
|
|
41
|
+
* @deprecated Use the `component` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
41
42
|
*/
|
|
42
43
|
paragraph?: boolean;
|
|
43
44
|
/**
|
package/Typography/Typography.js
CHANGED
|
@@ -214,6 +214,7 @@ process.env.NODE_ENV !== "production" ? Typography.propTypes /* remove-proptypes
|
|
|
214
214
|
/**
|
|
215
215
|
* If `true`, the element will be a paragraph element.
|
|
216
216
|
* @default false
|
|
217
|
+
* @deprecated Use the `component` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
217
218
|
*/
|
|
218
219
|
paragraph: PropTypes.bool,
|
|
219
220
|
/**
|
|
@@ -41,7 +41,10 @@ export interface TypographyClasses {
|
|
|
41
41
|
noWrap: string;
|
|
42
42
|
/** Styles applied to the root element if `gutterBottom={true}`. */
|
|
43
43
|
gutterBottom: string;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Styles applied to the root element if `paragraph={true}`.
|
|
46
|
+
* @deprecated
|
|
47
|
+
*/
|
|
45
48
|
paragraph: string;
|
|
46
49
|
}
|
|
47
50
|
export type TypographyClassKey = keyof TypographyClasses;
|
package/Zoom/Zoom.js
CHANGED
|
@@ -7,6 +7,7 @@ import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
|
|
7
7
|
import { useTheme } from '../zero-styled';
|
|
8
8
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
9
9
|
import useForkRef from '../utils/useForkRef';
|
|
10
|
+
import getChildRef from '../utils/getChildRef';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const styles = {
|
|
12
13
|
entering: {
|
|
@@ -47,7 +48,7 @@ const Zoom = /*#__PURE__*/React.forwardRef(function Zoom(props, ref) {
|
|
|
47
48
|
...other
|
|
48
49
|
} = props;
|
|
49
50
|
const nodeRef = React.useRef(null);
|
|
50
|
-
const handleRef = useForkRef(nodeRef, children
|
|
51
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
51
52
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
52
53
|
if (callback) {
|
|
53
54
|
const node = nodeRef.current;
|
package/index.js
CHANGED
package/modern/Fade/Fade.js
CHANGED
|
@@ -7,6 +7,7 @@ import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
|
|
7
7
|
import { useTheme } from '../zero-styled';
|
|
8
8
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
9
9
|
import useForkRef from '../utils/useForkRef';
|
|
10
|
+
import getChildRef from '../utils/getChildRef';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const styles = {
|
|
12
13
|
entering: {
|
|
@@ -47,7 +48,7 @@ const Fade = /*#__PURE__*/React.forwardRef(function Fade(props, ref) {
|
|
|
47
48
|
} = props;
|
|
48
49
|
const enableStrictModeCompat = true;
|
|
49
50
|
const nodeRef = React.useRef(null);
|
|
50
|
-
const handleRef = useForkRef(nodeRef, children
|
|
51
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
51
52
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
52
53
|
if (callback) {
|
|
53
54
|
const node = nodeRef.current;
|
package/modern/Grow/Grow.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Transition } from 'react-transition-group';
|
|
|
8
8
|
import { useTheme } from '../zero-styled';
|
|
9
9
|
import { getTransitionProps, reflow } from '../transitions/utils';
|
|
10
10
|
import useForkRef from '../utils/useForkRef';
|
|
11
|
+
import getChildRef from '../utils/getChildRef';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
function getScale(value) {
|
|
13
14
|
return `scale(${value}, ${value ** 2})`;
|
|
@@ -57,7 +58,7 @@ const Grow = /*#__PURE__*/React.forwardRef(function Grow(props, ref) {
|
|
|
57
58
|
const autoTimeout = React.useRef();
|
|
58
59
|
const theme = useTheme();
|
|
59
60
|
const nodeRef = React.useRef(null);
|
|
60
|
-
const handleRef = useForkRef(nodeRef, children
|
|
61
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
61
62
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
62
63
|
if (callback) {
|
|
63
64
|
const node = nodeRef.current;
|
package/modern/Paper/Paper.js
CHANGED
|
@@ -100,7 +100,7 @@ const Paper = /*#__PURE__*/React.forwardRef(function Paper(inProps, ref) {
|
|
|
100
100
|
...(variant === 'elevation' && {
|
|
101
101
|
'--Paper-shadow': (theme.vars || theme).shadows[elevation],
|
|
102
102
|
...(theme.vars && {
|
|
103
|
-
'--Paper-overlay': theme.overlays?.[elevation]
|
|
103
|
+
'--Paper-overlay': theme.vars.overlays?.[elevation]
|
|
104
104
|
}),
|
|
105
105
|
...(!theme.vars && theme.palette.mode === 'dark' && {
|
|
106
106
|
'--Paper-overlay': `linear-gradient(${alpha('#fff', getOverlayAlpha(elevation))}, ${alpha('#fff', getOverlayAlpha(elevation))})`
|
package/modern/Rating/Rating.js
CHANGED
|
@@ -303,7 +303,7 @@ const defaultEmptyIcon = /*#__PURE__*/_jsx(StarBorder, {
|
|
|
303
303
|
fontSize: "inherit"
|
|
304
304
|
});
|
|
305
305
|
function defaultLabelText(value) {
|
|
306
|
-
return `${value} Star${value !== 1 ? 's' : ''}`;
|
|
306
|
+
return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
|
|
307
307
|
}
|
|
308
308
|
const Rating = /*#__PURE__*/React.forwardRef(function Rating(inProps, ref) {
|
|
309
309
|
const props = useDefaultProps({
|
|
@@ -588,7 +588,7 @@ process.env.NODE_ENV !== "production" ? Rating.propTypes /* remove-proptypes */
|
|
|
588
588
|
* @param {number} value The rating label's value to format.
|
|
589
589
|
* @returns {string}
|
|
590
590
|
* @default function defaultLabelText(value) {
|
|
591
|
-
* return `${value} Star${value !== 1 ? 's' : ''}`;
|
|
591
|
+
* return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
|
|
592
592
|
* }
|
|
593
593
|
*/
|
|
594
594
|
getLabelText: PropTypes.func,
|
package/modern/Slide/Slide.js
CHANGED
|
@@ -11,6 +11,7 @@ import useForkRef from '../utils/useForkRef';
|
|
|
11
11
|
import { useTheme } from '../zero-styled';
|
|
12
12
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
13
13
|
import { ownerWindow } from '../utils';
|
|
14
|
+
import getChildRef from '../utils/getChildRef';
|
|
14
15
|
|
|
15
16
|
// Translate the node so it can't be seen on the screen.
|
|
16
17
|
// Later, we're going to translate the node back to its original location with `none`.
|
|
@@ -105,7 +106,7 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
105
106
|
...other
|
|
106
107
|
} = props;
|
|
107
108
|
const childrenRef = React.useRef(null);
|
|
108
|
-
const handleRef = useForkRef(children
|
|
109
|
+
const handleRef = useForkRef(getChildRef(children), childrenRef, ref);
|
|
109
110
|
const normalizedTransitionCallback = callback => isAppearing => {
|
|
110
111
|
if (callback) {
|
|
111
112
|
// onEnterXxx and onExitXxx callbacks have a different arguments.length value.
|
|
@@ -20,6 +20,7 @@ import useForkRef from '../utils/useForkRef';
|
|
|
20
20
|
import useId from '../utils/useId';
|
|
21
21
|
import useControlled from '../utils/useControlled';
|
|
22
22
|
import tooltipClasses, { getTooltipUtilityClass } from './tooltipClasses';
|
|
23
|
+
import getChildRef from '../utils/getChildRef';
|
|
23
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
25
|
function round(value) {
|
|
25
26
|
return Math.round(value * 1e5) / 1e5;
|
|
@@ -510,7 +511,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(inProps, ref) {
|
|
|
510
511
|
document.removeEventListener('keydown', handleKeyDown);
|
|
511
512
|
};
|
|
512
513
|
}, [handleClose, open]);
|
|
513
|
-
const handleRef = useForkRef(children
|
|
514
|
+
const handleRef = useForkRef(getChildRef(children), setChildNode, ref);
|
|
514
515
|
|
|
515
516
|
// There is no point in displaying an empty tooltip.
|
|
516
517
|
// So we exclude all falsy values, except 0, which is valid.
|
|
@@ -214,6 +214,7 @@ process.env.NODE_ENV !== "production" ? Typography.propTypes /* remove-proptypes
|
|
|
214
214
|
/**
|
|
215
215
|
* If `true`, the element will be a paragraph element.
|
|
216
216
|
* @default false
|
|
217
|
+
* @deprecated Use the `component` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
217
218
|
*/
|
|
218
219
|
paragraph: PropTypes.bool,
|
|
219
220
|
/**
|
package/modern/Zoom/Zoom.js
CHANGED
|
@@ -7,6 +7,7 @@ import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
|
|
|
7
7
|
import { useTheme } from '../zero-styled';
|
|
8
8
|
import { reflow, getTransitionProps } from '../transitions/utils';
|
|
9
9
|
import useForkRef from '../utils/useForkRef';
|
|
10
|
+
import getChildRef from '../utils/getChildRef';
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
const styles = {
|
|
12
13
|
entering: {
|
|
@@ -47,7 +48,7 @@ const Zoom = /*#__PURE__*/React.forwardRef(function Zoom(props, ref) {
|
|
|
47
48
|
...other
|
|
48
49
|
} = props;
|
|
49
50
|
const nodeRef = React.useRef(null);
|
|
50
|
-
const handleRef = useForkRef(nodeRef, children
|
|
51
|
+
const handleRef = useForkRef(nodeRef, getChildRef(children), ref);
|
|
51
52
|
const normalizedTransitionCallback = callback => maybeIsAppearing => {
|
|
52
53
|
if (callback) {
|
|
53
54
|
const node = nodeRef.current;
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import excludeVariablesFromRoot from './excludeVariablesFromRoot';
|
|
2
2
|
export default (theme => (colorScheme, css) => {
|
|
3
|
+
const selector = theme.colorSchemeSelector;
|
|
4
|
+
let rule = selector;
|
|
5
|
+
if (selector === 'class') {
|
|
6
|
+
rule = '.%s';
|
|
7
|
+
}
|
|
8
|
+
if (selector === 'data') {
|
|
9
|
+
rule = '[data-%s]';
|
|
10
|
+
}
|
|
11
|
+
if (selector?.startsWith('data-') && !selector.includes('%s')) {
|
|
12
|
+
// 'data-mui-color-scheme' -> '[data-mui-color-scheme="%s"]'
|
|
13
|
+
rule = `[${selector}="%s"]`;
|
|
14
|
+
}
|
|
3
15
|
if (theme.defaultColorScheme === colorScheme) {
|
|
4
16
|
if (colorScheme === 'dark') {
|
|
5
17
|
const excludedVariables = {};
|
|
@@ -7,15 +19,32 @@ export default (theme => (colorScheme, css) => {
|
|
|
7
19
|
excludedVariables[cssVar] = css[cssVar];
|
|
8
20
|
delete css[cssVar];
|
|
9
21
|
});
|
|
22
|
+
if (rule === 'media') {
|
|
23
|
+
return {
|
|
24
|
+
':root': css,
|
|
25
|
+
'@media (prefers-color-scheme: dark) { :root': excludedVariables
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (rule) {
|
|
29
|
+
return {
|
|
30
|
+
[rule.replace('%s', colorScheme)]: excludedVariables,
|
|
31
|
+
':root': css
|
|
32
|
+
};
|
|
33
|
+
}
|
|
10
34
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
':root': {
|
|
36
|
+
...css,
|
|
37
|
+
...excludedVariables
|
|
38
|
+
}
|
|
13
39
|
};
|
|
14
40
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
} else if (colorScheme) {
|
|
42
|
+
if (rule === 'media') {
|
|
43
|
+
return `@media (prefers-color-scheme: ${String(colorScheme)}) { :root`;
|
|
44
|
+
}
|
|
45
|
+
if (rule) {
|
|
46
|
+
return rule.replace('%s', String(colorScheme));
|
|
47
|
+
}
|
|
19
48
|
}
|
|
20
|
-
return
|
|
49
|
+
return ':root';
|
|
21
50
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @internal These variables should not appear in the :root stylesheet when the `
|
|
2
|
+
* @internal These variables should not appear in the :root stylesheet when the `defaultColorScheme="dark"`
|
|
3
3
|
*/
|
|
4
4
|
const excludeVariablesFromRoot = cssVarPrefix => [...[...Array(24)].map((_, index) => `--${cssVarPrefix ? `${cssVarPrefix}-` : ''}overlays-${index + 1}`), `--${cssVarPrefix ? `${cssVarPrefix}-` : ''}palette-AppBar-darkBg`, `--${cssVarPrefix ? `${cssVarPrefix}-` : ''}palette-AppBar-darkColor`];
|
|
5
5
|
export default excludeVariablesFromRoot;
|