@mui/system 5.10.13 → 5.10.14
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/Box/Box.js +1 -10
- package/Box/Box.spec.d.ts +1 -1
- package/Box/index.js +0 -2
- package/CHANGELOG.md +70 -2
- package/Container/Container.d.ts +13 -13
- package/Container/Container.js +2 -17
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/containerClasses.js +0 -3
- package/Container/createContainer.d.ts +18 -18
- package/Container/createContainer.js +15 -37
- package/Container/index.js +0 -6
- package/Stack/Stack.d.ts +13 -13
- package/Stack/Stack.js +1 -12
- package/Stack/StackProps.d.ts +42 -42
- package/Stack/createStack.d.ts +21 -21
- package/Stack/createStack.js +10 -48
- package/Stack/index.d.ts +5 -5
- package/Stack/index.js +0 -9
- package/Stack/stackClasses.d.ts +8 -8
- package/Stack/stackClasses.js +0 -3
- package/ThemeProvider/ThemeProvider.js +2 -22
- package/ThemeProvider/index.js +0 -2
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/Grid.js +6 -42
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +19 -49
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridClasses.js +8 -7
- package/Unstable_Grid/gridGenerator.d.ts +29 -28
- package/Unstable_Grid/gridGenerator.js +22 -63
- package/Unstable_Grid/index.d.ts +5 -5
- package/Unstable_Grid/index.js +0 -9
- package/borders.js +0 -14
- package/breakpoints.js +3 -32
- package/colorManipulator.js +13 -55
- package/compose.js +0 -7
- package/createBox.js +5 -20
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +27 -71
- package/createTheme/createBreakpoints.js +22 -37
- package/createTheme/createSpacing.d.ts +10 -10
- package/createTheme/createSpacing.js +4 -8
- package/createTheme/createTheme.js +6 -16
- package/createTheme/index.js +0 -2
- package/cssGrid.js +0 -21
- package/cssVars/createCssVarsProvider.js +24 -72
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/createGetCssVar.js +2 -7
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/cssVarsParser.js +3 -15
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/getInitColorSchemeScript.js +0 -6
- package/cssVars/index.d.ts +3 -3
- package/cssVars/index.js +0 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/cssVars/useCurrentColorScheme.js +20 -49
- package/display.js +0 -6
- package/esm/Box/Box.js +1 -6
- package/esm/Container/Container.js +3 -14
- package/esm/Container/createContainer.js +15 -25
- package/esm/Stack/Stack.js +1 -9
- package/esm/Stack/createStack.js +10 -29
- package/esm/ThemeProvider/ThemeProvider.js +2 -11
- package/esm/Unstable_Grid/Grid.js +6 -39
- package/esm/Unstable_Grid/createGrid.js +18 -35
- package/esm/Unstable_Grid/gridClasses.js +8 -4
- package/esm/Unstable_Grid/gridGenerator.js +20 -38
- package/esm/borders.js +0 -6
- package/esm/breakpoints.js +7 -22
- package/esm/colorManipulator.js +13 -43
- package/esm/compose.js +0 -5
- package/esm/createBox.js +5 -7
- package/esm/createStyled.js +27 -64
- package/esm/createTheme/createBreakpoints.js +22 -34
- package/esm/createTheme/createSpacing.js +4 -7
- package/esm/createTheme/createTheme.js +6 -9
- package/esm/cssGrid.js +0 -9
- package/esm/cssVars/createCssVarsProvider.js +24 -58
- package/esm/cssVars/createGetCssVar.js +2 -6
- package/esm/cssVars/cssVarsParser.js +3 -11
- package/esm/cssVars/useCurrentColorScheme.js +20 -44
- package/esm/getThemeValue.js +0 -2
- package/esm/index.js +1 -2
- package/esm/memoize.js +0 -1
- package/esm/merge.js +0 -3
- package/esm/palette.js +0 -3
- package/esm/propsToClassKey.js +4 -7
- package/esm/sizing.js +0 -5
- package/esm/spacing.js +3 -23
- package/esm/style.js +2 -19
- package/esm/styleFunctionSx/extendSxProp.js +3 -10
- package/esm/styleFunctionSx/styleFunctionSx.js +3 -16
- package/esm/sx/sx.js +0 -2
- package/esm/useTheme.js +0 -2
- package/esm/useThemeProps/getThemeProps.js +0 -2
- package/esm/useThemeWithoutDefault.js +0 -3
- package/flexbox.js +0 -4
- package/getThemeValue.js +0 -14
- package/index.js +1 -55
- package/index.spec.d.ts +1 -1
- package/legacy/Box/Box.js +1 -6
- package/legacy/Container/Container.js +3 -14
- package/legacy/Container/createContainer.js +29 -39
- package/legacy/Stack/Stack.js +1 -9
- package/legacy/Stack/createStack.js +17 -37
- package/legacy/ThemeProvider/ThemeProvider.js +3 -12
- package/legacy/Unstable_Grid/Grid.js +6 -39
- package/legacy/Unstable_Grid/createGrid.js +34 -53
- package/legacy/Unstable_Grid/gridGenerator.js +36 -58
- package/legacy/borders.js +0 -6
- package/legacy/breakpoints.js +9 -28
- package/legacy/colorManipulator.js +16 -48
- package/legacy/compose.js +0 -6
- package/legacy/createBox.js +9 -11
- package/legacy/createStyled.js +27 -68
- package/legacy/createTheme/createBreakpoints.js +20 -33
- package/legacy/createTheme/createSpacing.js +4 -9
- package/legacy/createTheme/createTheme.js +7 -13
- package/legacy/cssGrid.js +0 -9
- package/legacy/cssVars/createCssVarsProvider.js +90 -129
- package/legacy/cssVars/createGetCssVar.js +2 -10
- package/legacy/cssVars/cssVarsParser.js +7 -20
- package/legacy/cssVars/getInitColorSchemeScript.js +14 -15
- package/legacy/cssVars/useCurrentColorScheme.js +43 -69
- package/legacy/getThemeValue.js +0 -3
- package/legacy/index.js +2 -3
- package/legacy/memoize.js +0 -1
- package/legacy/merge.js +0 -3
- package/legacy/palette.js +0 -3
- package/legacy/propsToClassKey.js +2 -5
- package/legacy/sizing.js +0 -5
- package/legacy/spacing.js +6 -27
- package/legacy/style.js +6 -24
- package/legacy/styleFunctionSx/extendSxProp.js +3 -11
- package/legacy/styleFunctionSx/styleFunctionSx.js +6 -21
- package/legacy/sx/sx.js +0 -2
- package/legacy/useTheme.js +0 -2
- package/legacy/useThemeProps/getThemeProps.js +2 -4
- package/legacy/useThemeProps/useThemeProps.js +2 -2
- package/legacy/useThemeWithoutDefault.js +0 -3
- package/memoize.js +0 -2
- package/merge.js +0 -5
- package/modern/Box/Box.js +1 -6
- package/modern/Container/Container.js +3 -14
- package/modern/Container/createContainer.js +15 -25
- package/modern/Stack/Stack.js +1 -9
- package/modern/Stack/createStack.js +10 -29
- package/modern/ThemeProvider/ThemeProvider.js +2 -11
- package/modern/Unstable_Grid/Grid.js +6 -39
- package/modern/Unstable_Grid/createGrid.js +18 -34
- package/modern/Unstable_Grid/gridClasses.js +8 -4
- package/modern/Unstable_Grid/gridGenerator.js +20 -36
- package/modern/borders.js +0 -6
- package/modern/breakpoints.js +7 -21
- package/modern/colorManipulator.js +13 -43
- package/modern/compose.js +0 -5
- package/modern/createBox.js +5 -7
- package/modern/createStyled.js +27 -63
- package/modern/createTheme/createBreakpoints.js +22 -34
- package/modern/createTheme/createSpacing.js +4 -7
- package/modern/createTheme/createTheme.js +6 -9
- package/modern/cssGrid.js +0 -9
- package/modern/cssVars/createCssVarsProvider.js +24 -58
- package/modern/cssVars/createGetCssVar.js +2 -6
- package/modern/cssVars/cssVarsParser.js +3 -11
- package/modern/cssVars/useCurrentColorScheme.js +20 -44
- package/modern/getThemeValue.js +0 -2
- package/modern/index.js +2 -3
- package/modern/memoize.js +0 -1
- package/modern/merge.js +0 -3
- package/modern/palette.js +0 -3
- package/modern/propsToClassKey.js +4 -7
- package/modern/sizing.js +0 -4
- package/modern/spacing.js +3 -22
- package/modern/style.js +2 -19
- package/modern/styleFunctionSx/extendSxProp.js +3 -10
- package/modern/styleFunctionSx/styleFunctionSx.js +3 -16
- package/modern/sx/sx.js +0 -2
- package/modern/useTheme.js +0 -2
- package/modern/useThemeProps/getThemeProps.js +0 -2
- package/modern/useThemeWithoutDefault.js +0 -3
- package/package.json +6 -6
- package/palette.js +0 -6
- package/positions.js +0 -6
- package/propsToClassKey.js +4 -10
- package/responsivePropType.js +0 -3
- package/shadows.js +0 -3
- package/sizing.js +0 -11
- package/spacing.js +3 -37
- package/style.js +2 -24
- package/styleFunctionSx/extendSxProp.js +3 -15
- package/styleFunctionSx/index.js +0 -5
- package/styleFunctionSx/styleFunctionSx.js +3 -21
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
- package/styled.js +0 -3
- package/sx/index.js +0 -2
- package/sx/sx.js +0 -4
- package/typography.js +0 -4
- package/useTheme.js +0 -6
- package/useThemeProps/getThemeProps.js +0 -4
- package/useThemeProps/index.js +0 -3
- package/useThemeProps/useThemeProps.js +0 -4
- package/useThemeWithoutDefault.js +0 -4
|
@@ -1,44 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DISABLE_CSS_TRANSITION = void 0;
|
|
9
8
|
exports.default = createCssVarsProvider;
|
|
10
|
-
|
|
11
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
|
|
13
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
14
|
-
|
|
15
11
|
var _utils = require("@mui/utils");
|
|
16
|
-
|
|
17
12
|
var React = _interopRequireWildcard(require("react"));
|
|
18
|
-
|
|
19
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
|
-
|
|
21
14
|
var _styledEngine = require("@mui/styled-engine");
|
|
22
|
-
|
|
23
15
|
var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
|
|
24
|
-
|
|
25
16
|
var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
|
|
26
|
-
|
|
27
17
|
var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorSchemeScript"));
|
|
28
|
-
|
|
29
18
|
var _useCurrentColorScheme = _interopRequireDefault(require("./useCurrentColorScheme"));
|
|
30
|
-
|
|
31
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
|
-
|
|
33
20
|
const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
|
|
34
|
-
|
|
35
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
36
|
-
|
|
37
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
38
|
-
|
|
39
23
|
const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
40
24
|
exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
|
|
41
|
-
|
|
42
25
|
function createCssVarsProvider(options) {
|
|
43
26
|
const {
|
|
44
27
|
theme: defaultTheme = {},
|
|
@@ -52,23 +35,17 @@ function createCssVarsProvider(options) {
|
|
|
52
35
|
resolveTheme,
|
|
53
36
|
excludeVariablesFromRoot
|
|
54
37
|
} = options;
|
|
55
|
-
|
|
56
38
|
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
|
|
57
39
|
console.error(`MUI: \`${designSystemColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
58
40
|
}
|
|
59
|
-
|
|
60
41
|
const ColorSchemeContext = /*#__PURE__*/React.createContext(undefined);
|
|
61
|
-
|
|
62
42
|
const useColorScheme = () => {
|
|
63
43
|
const value = React.useContext(ColorSchemeContext);
|
|
64
|
-
|
|
65
44
|
if (!value) {
|
|
66
45
|
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: \`useColorScheme\` must be called under <CssVarsProvider />` : (0, _utils.formatMuiErrorMessage)(19));
|
|
67
46
|
}
|
|
68
|
-
|
|
69
47
|
return value;
|
|
70
48
|
};
|
|
71
|
-
|
|
72
49
|
function CssVarsProvider({
|
|
73
50
|
children,
|
|
74
51
|
theme: themeProp = defaultTheme,
|
|
@@ -86,15 +63,16 @@ function createCssVarsProvider(options) {
|
|
|
86
63
|
}) {
|
|
87
64
|
const hasMounted = React.useRef(false);
|
|
88
65
|
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
66
|
+
colorSchemes = {},
|
|
67
|
+
components = {},
|
|
68
|
+
cssVarPrefix
|
|
69
|
+
} = themeProp,
|
|
70
|
+
restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded);
|
|
94
71
|
const allColorSchemes = Object.keys(colorSchemes);
|
|
95
72
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
96
|
-
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
73
|
+
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
97
74
|
|
|
75
|
+
// 1. Get the data about the `mode`, `colorScheme`, and setter functions.
|
|
98
76
|
const {
|
|
99
77
|
mode,
|
|
100
78
|
setMode,
|
|
@@ -112,35 +90,29 @@ function createCssVarsProvider(options) {
|
|
|
112
90
|
defaultMode,
|
|
113
91
|
storageWindow
|
|
114
92
|
});
|
|
115
|
-
|
|
116
93
|
const calculatedMode = (() => {
|
|
117
94
|
if (!mode) {
|
|
118
95
|
// This scope occurs on the server
|
|
119
96
|
if (defaultMode === 'system') {
|
|
120
97
|
return designSystemMode;
|
|
121
98
|
}
|
|
122
|
-
|
|
123
99
|
return defaultMode;
|
|
124
100
|
}
|
|
125
|
-
|
|
126
101
|
return mode;
|
|
127
102
|
})();
|
|
128
|
-
|
|
129
103
|
const calculatedColorScheme = (() => {
|
|
130
104
|
if (!colorScheme) {
|
|
131
105
|
// This scope occurs on the server
|
|
132
106
|
if (calculatedMode === 'dark') {
|
|
133
107
|
return defaultDarkColorScheme;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
108
|
+
}
|
|
109
|
+
// use light color scheme, if default mode is 'light' | 'system'
|
|
137
110
|
return defaultLightColorScheme;
|
|
138
111
|
}
|
|
139
|
-
|
|
140
112
|
return colorScheme;
|
|
141
|
-
})();
|
|
142
|
-
|
|
113
|
+
})();
|
|
143
114
|
|
|
115
|
+
// 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
144
116
|
const {
|
|
145
117
|
css: rootCss,
|
|
146
118
|
vars: rootVars,
|
|
@@ -148,18 +120,20 @@ function createCssVarsProvider(options) {
|
|
|
148
120
|
} = (0, _cssVarsParser.default)(restThemeProp, {
|
|
149
121
|
prefix: cssVarPrefix,
|
|
150
122
|
shouldSkipGeneratingVar
|
|
151
|
-
});
|
|
123
|
+
});
|
|
152
124
|
|
|
125
|
+
// 3. Start composing the theme object
|
|
153
126
|
let theme = (0, _extends2.default)({}, parsedTheme, {
|
|
154
127
|
components,
|
|
155
128
|
colorSchemes,
|
|
156
129
|
cssVarPrefix,
|
|
157
130
|
vars: rootVars,
|
|
158
131
|
getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
|
|
159
|
-
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// 4. Create color CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
160
135
|
// The default color scheme stylesheet is constructed to have the least CSS specificity.
|
|
161
136
|
// The other color schemes uses selector, default as data attribute, to increase the CSS specificity so that they can override the default color scheme stylesheet.
|
|
162
|
-
|
|
163
137
|
const defaultColorSchemeStyleSheet = {};
|
|
164
138
|
const otherColorSchemesStyleSheet = {};
|
|
165
139
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
@@ -172,28 +146,22 @@ function createCssVarsProvider(options) {
|
|
|
172
146
|
shouldSkipGeneratingVar
|
|
173
147
|
});
|
|
174
148
|
theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
|
|
175
|
-
|
|
176
149
|
if (key === calculatedColorScheme) {
|
|
177
150
|
// 4.1 Merge the selected color scheme to the theme
|
|
178
151
|
theme = (0, _extends2.default)({}, theme, parsedScheme);
|
|
179
|
-
|
|
180
152
|
if (theme.palette) {
|
|
181
153
|
theme.palette.colorScheme = key;
|
|
182
154
|
}
|
|
183
155
|
}
|
|
184
|
-
|
|
185
156
|
const resolvedDefaultColorScheme = (() => {
|
|
186
157
|
if (typeof defaultColorScheme === 'string') {
|
|
187
158
|
return defaultColorScheme;
|
|
188
159
|
}
|
|
189
|
-
|
|
190
160
|
if (defaultMode === 'dark') {
|
|
191
161
|
return defaultColorScheme.dark;
|
|
192
162
|
}
|
|
193
|
-
|
|
194
163
|
return defaultColorScheme.light;
|
|
195
164
|
})();
|
|
196
|
-
|
|
197
165
|
if (key === resolvedDefaultColorScheme) {
|
|
198
166
|
if (excludeVariablesFromRoot) {
|
|
199
167
|
const excludedVariables = {};
|
|
@@ -203,37 +171,36 @@ function createCssVarsProvider(options) {
|
|
|
203
171
|
});
|
|
204
172
|
defaultColorSchemeStyleSheet[`[${attribute}="${key}"]`] = excludedVariables;
|
|
205
173
|
}
|
|
206
|
-
|
|
207
174
|
defaultColorSchemeStyleSheet[`${colorSchemeSelector}, [${attribute}="${key}"]`] = css;
|
|
208
175
|
} else {
|
|
209
176
|
otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
|
|
210
177
|
}
|
|
211
|
-
});
|
|
212
|
-
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
|
|
178
|
+
});
|
|
213
179
|
|
|
180
|
+
// 5. Declaring effects
|
|
181
|
+
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
|
|
214
182
|
React.useEffect(() => {
|
|
215
183
|
if (colorScheme && colorSchemeNode) {
|
|
216
184
|
// attaches attribute to <html> because the css variables are attached to :root (html)
|
|
217
185
|
colorSchemeNode.setAttribute(attribute, colorScheme);
|
|
218
186
|
}
|
|
219
|
-
}, [colorScheme, attribute, colorSchemeNode]);
|
|
220
|
-
// credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
|
|
187
|
+
}, [colorScheme, attribute, colorSchemeNode]);
|
|
221
188
|
|
|
189
|
+
// 5.2 Remove the CSS transition when color scheme changes to create instant experience.
|
|
190
|
+
// credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
|
|
222
191
|
React.useEffect(() => {
|
|
223
192
|
let timer;
|
|
224
|
-
|
|
225
193
|
if (disableTransitionOnChange && hasMounted.current && documentNode) {
|
|
226
194
|
const css = documentNode.createElement('style');
|
|
227
195
|
css.appendChild(documentNode.createTextNode(DISABLE_CSS_TRANSITION));
|
|
228
|
-
documentNode.head.appendChild(css);
|
|
196
|
+
documentNode.head.appendChild(css);
|
|
229
197
|
|
|
198
|
+
// Force browser repaint
|
|
230
199
|
(() => window.getComputedStyle(documentNode.body))();
|
|
231
|
-
|
|
232
200
|
timer = setTimeout(() => {
|
|
233
201
|
documentNode.head.removeChild(css);
|
|
234
202
|
}, 1);
|
|
235
203
|
}
|
|
236
|
-
|
|
237
204
|
return () => {
|
|
238
205
|
clearTimeout(timer);
|
|
239
206
|
};
|
|
@@ -270,69 +237,56 @@ function createCssVarsProvider(options) {
|
|
|
270
237
|
})]
|
|
271
238
|
});
|
|
272
239
|
}
|
|
273
|
-
|
|
274
240
|
process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
|
|
275
241
|
/**
|
|
276
242
|
* The body attribute name to attach colorScheme.
|
|
277
243
|
*/
|
|
278
244
|
attribute: _propTypes.default.string,
|
|
279
|
-
|
|
280
245
|
/**
|
|
281
246
|
* The component tree.
|
|
282
247
|
*/
|
|
283
248
|
children: _propTypes.default.node,
|
|
284
|
-
|
|
285
249
|
/**
|
|
286
250
|
* The node used to attach the color-scheme attribute
|
|
287
251
|
*/
|
|
288
252
|
colorSchemeNode: _propTypes.default.any,
|
|
289
|
-
|
|
290
253
|
/**
|
|
291
254
|
* The CSS selector for attaching the generated custom properties
|
|
292
255
|
*/
|
|
293
256
|
colorSchemeSelector: _propTypes.default.string,
|
|
294
|
-
|
|
295
257
|
/**
|
|
296
258
|
* localStorage key used to store `colorScheme`
|
|
297
259
|
*/
|
|
298
260
|
colorSchemeStorageKey: _propTypes.default.string,
|
|
299
|
-
|
|
300
261
|
/**
|
|
301
262
|
* The initial color scheme used.
|
|
302
263
|
*/
|
|
303
264
|
defaultColorScheme: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]),
|
|
304
|
-
|
|
305
265
|
/**
|
|
306
266
|
* The initial mode used.
|
|
307
267
|
*/
|
|
308
268
|
defaultMode: _propTypes.default.string,
|
|
309
|
-
|
|
310
269
|
/**
|
|
311
270
|
* Disable CSS transitions when switching between modes or color schemes
|
|
312
271
|
*/
|
|
313
272
|
disableTransitionOnChange: _propTypes.default.bool,
|
|
314
|
-
|
|
315
273
|
/**
|
|
316
274
|
* The document to attach the attribute to
|
|
317
275
|
*/
|
|
318
276
|
documentNode: _propTypes.default.any,
|
|
319
|
-
|
|
320
277
|
/**
|
|
321
278
|
* The key in the local storage used to store current color scheme.
|
|
322
279
|
*/
|
|
323
280
|
modeStorageKey: _propTypes.default.string,
|
|
324
|
-
|
|
325
281
|
/**
|
|
326
282
|
* A function to determine if the key, value should be attached as CSS Variable
|
|
327
283
|
*/
|
|
328
284
|
shouldSkipGeneratingVar: _propTypes.default.func,
|
|
329
|
-
|
|
330
285
|
/**
|
|
331
286
|
* The window that attaches the 'storage' event listener
|
|
332
287
|
* @default window
|
|
333
288
|
*/
|
|
334
289
|
storageWindow: _propTypes.default.any,
|
|
335
|
-
|
|
336
290
|
/**
|
|
337
291
|
* The calculated theme object that will be passed through context.
|
|
338
292
|
*/
|
|
@@ -340,7 +294,6 @@ function createCssVarsProvider(options) {
|
|
|
340
294
|
} : void 0;
|
|
341
295
|
const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
|
|
342
296
|
const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
|
|
343
|
-
|
|
344
297
|
const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)((0, _extends2.default)({
|
|
345
298
|
attribute: defaultAttribute,
|
|
346
299
|
colorSchemeStorageKey: defaultColorSchemeStorageKey,
|
|
@@ -349,7 +302,6 @@ function createCssVarsProvider(options) {
|
|
|
349
302
|
defaultDarkColorScheme,
|
|
350
303
|
modeStorageKey: defaultModeStorageKey
|
|
351
304
|
}, params));
|
|
352
|
-
|
|
353
305
|
return {
|
|
354
306
|
CssVarsProvider,
|
|
355
307
|
useColorScheme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
3
|
-
* and they does not need to remember the prefix (defined once).
|
|
4
|
-
*/
|
|
5
|
-
export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...fallbacks: (T | AdditionalVars)[]) => string;
|
|
1
|
+
/**
|
|
2
|
+
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
3
|
+
* and they does not need to remember the prefix (defined once).
|
|
4
|
+
*/
|
|
5
|
+
export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...fallbacks: (T | AdditionalVars)[]) => string;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = createGetCssVar;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
10
9
|
* and they does not need to remember the prefix (defined once).
|
|
@@ -14,20 +13,16 @@ function createGetCssVar(prefix = '') {
|
|
|
14
13
|
if (!vars.length) {
|
|
15
14
|
return '';
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
const value = vars[0];
|
|
19
|
-
|
|
20
17
|
if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
|
|
21
18
|
return `, var(--${prefix ? `${prefix}-` : ''}${value}${appendVar(...vars.slice(1))})`;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
return `, ${value}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
21
|
+
}
|
|
27
22
|
|
|
23
|
+
// AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
|
|
28
24
|
const getCssVar = (field, ...fallbacks) => {
|
|
29
25
|
return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...fallbacks)})`;
|
|
30
26
|
};
|
|
31
|
-
|
|
32
27
|
return getCssVar;
|
|
33
28
|
}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
declare type NestedRecord<V = any> = {
|
|
2
|
-
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* This function create an object from keys, value and then assign to target
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} obj : the target object to be assigned
|
|
8
|
-
* @param {string[]} keys
|
|
9
|
-
* @param {string | number} value
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const source = {}
|
|
13
|
-
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
-
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
-
*/
|
|
21
|
-
export declare const assignNestedKeys: <T extends string | Record<string, any> | null | undefined = NestedRecord<any>, Value = any>(obj: T, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Object} obj : source object
|
|
25
|
-
* @param {Function} callback : a function that will be called when
|
|
26
|
-
* - the deepest key in source object is reached
|
|
27
|
-
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
-
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
-
*/
|
|
33
|
-
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
-
/**
|
|
35
|
-
* a function that parse theme and return { css, vars }
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} theme
|
|
38
|
-
* @param {{
|
|
39
|
-
* prefix?: string,
|
|
40
|
-
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
-
* }} options.
|
|
42
|
-
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
-
*
|
|
44
|
-
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const { css, vars, parsedTheme } = parser({
|
|
48
|
-
* fontSize: 12,
|
|
49
|
-
* lineHeight: 1.2,
|
|
50
|
-
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
-
* }, { prefix: 'foo' })
|
|
52
|
-
*
|
|
53
|
-
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
-
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
-
*/
|
|
57
|
-
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
-
prefix?: string;
|
|
59
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
-
}): {
|
|
61
|
-
css: Record<string, string | number>;
|
|
62
|
-
vars: NestedRecord<string>;
|
|
63
|
-
parsedTheme: T;
|
|
64
|
-
};
|
|
65
|
-
export {};
|
|
1
|
+
declare type NestedRecord<V = any> = {
|
|
2
|
+
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* This function create an object from keys, value and then assign to target
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} obj : the target object to be assigned
|
|
8
|
+
* @param {string[]} keys
|
|
9
|
+
* @param {string | number} value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const source = {}
|
|
13
|
+
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
+
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
+
*/
|
|
21
|
+
export declare const assignNestedKeys: <T extends string | Record<string, any> | null | undefined = NestedRecord<any>, Value = any>(obj: T, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} obj : source object
|
|
25
|
+
* @param {Function} callback : a function that will be called when
|
|
26
|
+
* - the deepest key in source object is reached
|
|
27
|
+
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
+
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
+
*/
|
|
33
|
+
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
+
/**
|
|
35
|
+
* a function that parse theme and return { css, vars }
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} theme
|
|
38
|
+
* @param {{
|
|
39
|
+
* prefix?: string,
|
|
40
|
+
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
+
* }} options.
|
|
42
|
+
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
+
*
|
|
44
|
+
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const { css, vars, parsedTheme } = parser({
|
|
48
|
+
* fontSize: 12,
|
|
49
|
+
* lineHeight: 1.2,
|
|
50
|
+
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
+
* }, { prefix: 'foo' })
|
|
52
|
+
*
|
|
53
|
+
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
+
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
+
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
+
*/
|
|
57
|
+
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
+
prefix?: string;
|
|
59
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
+
}): {
|
|
61
|
+
css: Record<string, string | number>;
|
|
62
|
+
vars: NestedRecord<string>;
|
|
63
|
+
parsedTheme: T;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
package/cssVars/cssVarsParser.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.assignNestedKeys = void 0;
|
|
7
7
|
exports.default = cssVarsParser;
|
|
8
8
|
exports.walkObjectDeep = void 0;
|
|
9
|
-
|
|
10
9
|
/**
|
|
11
10
|
* This function create an object from keys, value and then assign to target
|
|
12
11
|
*
|
|
@@ -37,11 +36,11 @@ const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
|
|
|
37
36
|
if (!temp[k]) {
|
|
38
37
|
temp[k] = arrayKeys.includes(k) ? [] : {};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
temp = temp[k];
|
|
42
40
|
}
|
|
43
41
|
});
|
|
44
42
|
};
|
|
43
|
+
|
|
45
44
|
/**
|
|
46
45
|
*
|
|
47
46
|
* @param {Object} obj : source object
|
|
@@ -53,10 +52,7 @@ const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
|
|
|
53
52
|
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
54
53
|
* // ['palette', 'primary', 'main'] '#000000'
|
|
55
54
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
55
|
exports.assignNestedKeys = assignNestedKeys;
|
|
59
|
-
|
|
60
56
|
const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
|
|
61
57
|
function recurse(object, parentKeys = [], arrayKeys = []) {
|
|
62
58
|
Object.entries(object).forEach(([key, value]) => {
|
|
@@ -71,31 +67,25 @@ const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
|
|
|
71
67
|
}
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
|
-
|
|
75
70
|
recurse(obj);
|
|
76
71
|
};
|
|
77
|
-
|
|
78
72
|
exports.walkObjectDeep = walkObjectDeep;
|
|
79
|
-
|
|
80
73
|
const getCssValue = (keys, value) => {
|
|
81
74
|
if (typeof value === 'number') {
|
|
82
75
|
if (['lineHeight', 'fontWeight', 'opacity', 'zIndex'].some(prop => keys.includes(prop))) {
|
|
83
76
|
// CSS property that are unitless
|
|
84
77
|
return value;
|
|
85
78
|
}
|
|
86
|
-
|
|
87
79
|
const lastKey = keys[keys.length - 1];
|
|
88
|
-
|
|
89
80
|
if (lastKey.toLowerCase().indexOf('opacity') >= 0) {
|
|
90
81
|
// opacity values are unitless
|
|
91
82
|
return value;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
return `${value}px`;
|
|
95
85
|
}
|
|
96
|
-
|
|
97
86
|
return value;
|
|
98
87
|
};
|
|
88
|
+
|
|
99
89
|
/**
|
|
100
90
|
* a function that parse theme and return { css, vars }
|
|
101
91
|
*
|
|
@@ -119,8 +109,6 @@ const getCssValue = (keys, value) => {
|
|
|
119
109
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
120
110
|
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
121
111
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
112
|
function cssVarsParser(theme, options) {
|
|
125
113
|
const {
|
|
126
114
|
prefix,
|
|
@@ -140,10 +128,10 @@ function cssVarsParser(theme, options) {
|
|
|
140
128
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
141
129
|
}
|
|
142
130
|
}
|
|
143
|
-
|
|
144
131
|
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
145
132
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
|
146
133
|
);
|
|
134
|
+
|
|
147
135
|
return {
|
|
148
136
|
css,
|
|
149
137
|
vars,
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
|
-
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
|
-
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
5
|
-
export interface GetInitColorSchemeScriptOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The mode to be used for the first visit
|
|
8
|
-
* @default 'light'
|
|
9
|
-
*/
|
|
10
|
-
defaultMode?: 'light' | 'dark' | 'system';
|
|
11
|
-
/**
|
|
12
|
-
* The default color scheme to be used on the light mode
|
|
13
|
-
* @default 'light'
|
|
14
|
-
*/
|
|
15
|
-
defaultLightColorScheme?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The default color scheme to be used on the dark mode
|
|
18
|
-
* * @default 'dark'
|
|
19
|
-
*/
|
|
20
|
-
defaultDarkColorScheme?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The node (provided as string) used to attach the color-scheme attribute
|
|
23
|
-
* @default 'document.documentElement'
|
|
24
|
-
*/
|
|
25
|
-
colorSchemeNode?: string;
|
|
26
|
-
/**
|
|
27
|
-
* localStorage key used to store `mode`
|
|
28
|
-
* @default 'mode'
|
|
29
|
-
*/
|
|
30
|
-
modeStorageKey?: string;
|
|
31
|
-
/**
|
|
32
|
-
* localStorage key used to store `colorScheme`
|
|
33
|
-
* @default 'color-scheme'
|
|
34
|
-
*/
|
|
35
|
-
colorSchemeStorageKey?: string;
|
|
36
|
-
/**
|
|
37
|
-
* DOM attribute for applying color scheme
|
|
38
|
-
* @default 'data-color-scheme'
|
|
39
|
-
*/
|
|
40
|
-
attribute?: string;
|
|
41
|
-
}
|
|
42
|
-
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
|
+
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
|
+
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
5
|
+
export interface GetInitColorSchemeScriptOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The mode to be used for the first visit
|
|
8
|
+
* @default 'light'
|
|
9
|
+
*/
|
|
10
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
11
|
+
/**
|
|
12
|
+
* The default color scheme to be used on the light mode
|
|
13
|
+
* @default 'light'
|
|
14
|
+
*/
|
|
15
|
+
defaultLightColorScheme?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The default color scheme to be used on the dark mode
|
|
18
|
+
* * @default 'dark'
|
|
19
|
+
*/
|
|
20
|
+
defaultDarkColorScheme?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The node (provided as string) used to attach the color-scheme attribute
|
|
23
|
+
* @default 'document.documentElement'
|
|
24
|
+
*/
|
|
25
|
+
colorSchemeNode?: string;
|
|
26
|
+
/**
|
|
27
|
+
* localStorage key used to store `mode`
|
|
28
|
+
* @default 'mode'
|
|
29
|
+
*/
|
|
30
|
+
modeStorageKey?: string;
|
|
31
|
+
/**
|
|
32
|
+
* localStorage key used to store `colorScheme`
|
|
33
|
+
* @default 'color-scheme'
|
|
34
|
+
*/
|
|
35
|
+
colorSchemeStorageKey?: string;
|
|
36
|
+
/**
|
|
37
|
+
* DOM attribute for applying color scheme
|
|
38
|
+
* @default 'data-color-scheme'
|
|
39
|
+
*/
|
|
40
|
+
attribute?: string;
|
|
41
|
+
}
|
|
42
|
+
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
|