@mui/system 5.8.0 → 5.8.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.
Files changed (37) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +203 -6
  3. package/Container/Container.d.ts +13 -13
  4. package/Container/ContainerProps.d.ts +40 -40
  5. package/Container/containerClasses.d.ts +22 -22
  6. package/Container/createContainer.d.ts +18 -18
  7. package/createBox.spec.d.ts +1 -1
  8. package/createTheme/createSpacing.d.ts +10 -10
  9. package/cssVars/createCssVarsProvider.d.ts +15 -15
  10. package/cssVars/createCssVarsProvider.js +23 -9
  11. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  12. package/cssVars/createGetCssVar.d.ts +5 -5
  13. package/cssVars/cssVarsParser.d.ts +70 -70
  14. package/cssVars/getInitColorSchemeScript.d.ts +40 -40
  15. package/cssVars/getInitColorSchemeScript.js +3 -3
  16. package/cssVars/index.d.ts +2 -2
  17. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  18. package/esm/cssVars/createCssVarsProvider.js +23 -9
  19. package/esm/cssVars/getInitColorSchemeScript.js +3 -3
  20. package/esm/spacing.js +1 -1
  21. package/esm/style.js +2 -2
  22. package/index.js +1 -1
  23. package/index.spec.d.ts +1 -1
  24. package/legacy/cssVars/createCssVarsProvider.js +30 -9
  25. package/legacy/cssVars/getInitColorSchemeScript.js +3 -3
  26. package/legacy/index.js +1 -1
  27. package/legacy/spacing.js +1 -1
  28. package/legacy/style.js +3 -1
  29. package/modern/cssVars/createCssVarsProvider.js +23 -9
  30. package/modern/cssVars/getInitColorSchemeScript.js +3 -3
  31. package/modern/index.js +1 -1
  32. package/modern/spacing.js +1 -1
  33. package/modern/style.js +2 -2
  34. package/package.json +2 -2
  35. package/spacing.js +1 -1
  36. package/style.js +2 -2
  37. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -1,70 +1,70 @@
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: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, 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
- * basePrefix?: string,
41
- * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
- * }} options.
43
- * `basePrefix`: defined by design system.
44
- * `prefix`: defined by application
45
- *
46
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
- *
48
- * @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.
49
- *
50
- * @example
51
- * const { css, vars, parsedTheme } = parser({
52
- * fontSize: 12,
53
- * lineHeight: 1.2,
54
- * palette: { primary: { 500: 'var(--color)' } }
55
- * }, { prefix: 'foo' })
56
- *
57
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
- */
61
- export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
- prefix?: string;
63
- basePrefix?: string;
64
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
- }): {
66
- css: NestedRecord<string>;
67
- vars: NestedRecord<string>;
68
- parsedTheme: T;
69
- };
70
- 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: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, 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
+ * basePrefix?: string,
41
+ * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
+ * }} options.
43
+ * `basePrefix`: defined by design system.
44
+ * `prefix`: defined by application
45
+ *
46
+ * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
+ *
48
+ * @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.
49
+ *
50
+ * @example
51
+ * const { css, vars, parsedTheme } = parser({
52
+ * fontSize: 12,
53
+ * lineHeight: 1.2,
54
+ * palette: { primary: { 500: 'var(--color)' } }
55
+ * }, { prefix: 'foo' })
56
+ *
57
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
+ * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
+ */
61
+ export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
+ prefix?: string;
63
+ basePrefix?: string;
64
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
+ }): {
66
+ css: NestedRecord<string>;
67
+ vars: NestedRecord<string>;
68
+ parsedTheme: T;
69
+ };
70
+ export {};
@@ -1,40 +1,40 @@
1
- /// <reference types="react" />
2
- export declare const DEFAULT_MODE_STORAGE_KEY = "mui-mode";
3
- export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "mui-color-scheme";
4
- export declare const DEFAULT_ATTRIBUTE = "data-mui-color-scheme";
5
- export interface GetInitColorSchemeScriptOptions {
6
- /**
7
- * If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
8
- * @default false
9
- */
10
- enableSystem?: boolean;
11
- /**
12
- * The default color scheme to be used on the light mode
13
- */
14
- defaultLightColorScheme?: string;
15
- /**
16
- * The default color scheme to be used on the dark mode
17
- */
18
- defaultDarkColorScheme?: string;
19
- /**
20
- * The node (provided as string) used to attach the color-scheme attribute
21
- * @default 'document.documentElement'
22
- */
23
- colorSchemeNode?: string;
24
- /**
25
- * localStorage key used to store `mode`
26
- * @default 'mui-mode'
27
- */
28
- modeStorageKey?: string;
29
- /**
30
- * localStorage key used to store `colorScheme`
31
- * @default 'mui-color-scheme'
32
- */
33
- colorSchemeStorageKey?: string;
34
- /**
35
- * DOM attribute for applying color scheme
36
- * @default 'data-mui-color-scheme'
37
- */
38
- attribute?: string;
39
- }
40
- 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
+ * If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
8
+ * @default false
9
+ */
10
+ enableSystem?: boolean;
11
+ /**
12
+ * The default color scheme to be used on the light mode
13
+ */
14
+ defaultLightColorScheme?: string;
15
+ /**
16
+ * The default color scheme to be used on the dark mode
17
+ */
18
+ defaultDarkColorScheme?: string;
19
+ /**
20
+ * The node (provided as string) used to attach the color-scheme attribute
21
+ * @default 'document.documentElement'
22
+ */
23
+ colorSchemeNode?: string;
24
+ /**
25
+ * localStorage key used to store `mode`
26
+ * @default 'mode'
27
+ */
28
+ modeStorageKey?: string;
29
+ /**
30
+ * localStorage key used to store `colorScheme`
31
+ * @default 'color-scheme'
32
+ */
33
+ colorSchemeStorageKey?: string;
34
+ /**
35
+ * DOM attribute for applying color scheme
36
+ * @default 'data-color-scheme'
37
+ */
38
+ attribute?: string;
39
+ }
40
+ export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
@@ -14,11 +14,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
14
14
 
15
15
  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; }
16
16
 
17
- const DEFAULT_MODE_STORAGE_KEY = 'mui-mode';
17
+ const DEFAULT_MODE_STORAGE_KEY = 'mode';
18
18
  exports.DEFAULT_MODE_STORAGE_KEY = DEFAULT_MODE_STORAGE_KEY;
19
- const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
19
+ const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
20
20
  exports.DEFAULT_COLOR_SCHEME_STORAGE_KEY = DEFAULT_COLOR_SCHEME_STORAGE_KEY;
21
- const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
21
+ const DEFAULT_ATTRIBUTE = 'data-color-scheme';
22
22
  exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
23
23
 
24
24
  function getInitColorSchemeScript(options) {
@@ -1,2 +1,2 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult } from './createCssVarsProvider';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult } from './createCssVarsProvider';
@@ -1,53 +1,53 @@
1
- export declare type Mode = 'light' | 'dark' | 'system';
2
- export declare type SystemMode = Exclude<Mode, 'system'>;
3
- export interface State<SupportedColorScheme extends string> {
4
- /**
5
- * User selected mode.
6
- * Note: on the server, mode is always undefined
7
- */
8
- mode: Mode | undefined;
9
- /**
10
- * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
- */
12
- systemMode: SystemMode | undefined;
13
- /**
14
- * The color scheme for the light mode.
15
- */
16
- lightColorScheme: SupportedColorScheme;
17
- /**
18
- * The color scheme for the dark mode.
19
- */
20
- darkColorScheme: SupportedColorScheme;
21
- }
22
- export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
- /**
24
- * The current application color scheme. It is always `undefined` on the server.
25
- */
26
- colorScheme: SupportedColorScheme | undefined;
27
- /**
28
- * `mode` is saved to internal state and localStorage
29
- * If `mode` is null, it will be reset to the defaultMode
30
- */
31
- setMode: (mode: Mode | null) => void;
32
- /**
33
- * `colorScheme` is saved to internal state and localStorage
34
- * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
- */
36
- setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
- light: SupportedColorScheme | null;
38
- dark: SupportedColorScheme | null;
39
- }> | null) => void;
40
- };
41
- export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
- export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
- interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
44
- defaultLightColorScheme: SupportedColorScheme;
45
- defaultDarkColorScheme: SupportedColorScheme;
46
- supportedColorSchemes: Array<SupportedColorScheme>;
47
- defaultMode?: Mode;
48
- modeStorageKey?: string;
49
- colorSchemeStorageKey?: string;
50
- storageWindow?: Window | null;
51
- }
52
- export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
53
- export {};
1
+ export declare type Mode = 'light' | 'dark' | 'system';
2
+ export declare type SystemMode = Exclude<Mode, 'system'>;
3
+ export interface State<SupportedColorScheme extends string> {
4
+ /**
5
+ * User selected mode.
6
+ * Note: on the server, mode is always undefined
7
+ */
8
+ mode: Mode | undefined;
9
+ /**
10
+ * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
+ */
12
+ systemMode: SystemMode | undefined;
13
+ /**
14
+ * The color scheme for the light mode.
15
+ */
16
+ lightColorScheme: SupportedColorScheme;
17
+ /**
18
+ * The color scheme for the dark mode.
19
+ */
20
+ darkColorScheme: SupportedColorScheme;
21
+ }
22
+ export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
+ /**
24
+ * The current application color scheme. It is always `undefined` on the server.
25
+ */
26
+ colorScheme: SupportedColorScheme | undefined;
27
+ /**
28
+ * `mode` is saved to internal state and localStorage
29
+ * If `mode` is null, it will be reset to the defaultMode
30
+ */
31
+ setMode: (mode: Mode | null) => void;
32
+ /**
33
+ * `colorScheme` is saved to internal state and localStorage
34
+ * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
+ */
36
+ setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
+ light: SupportedColorScheme | null;
38
+ dark: SupportedColorScheme | null;
39
+ }> | null) => void;
40
+ };
41
+ export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
+ export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
+ interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
44
+ defaultLightColorScheme: SupportedColorScheme;
45
+ defaultDarkColorScheme: SupportedColorScheme;
46
+ supportedColorSchemes: Array<SupportedColorScheme>;
47
+ defaultMode?: Mode;
48
+ modeStorageKey?: string;
49
+ colorSchemeStorageKey?: string;
50
+ storageWindow?: Window | null;
51
+ }
52
+ export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
53
+ export {};
@@ -8,7 +8,7 @@ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui
8
8
  import { GlobalStyles } from '@mui/styled-engine';
9
9
  import cssVarsParser from './cssVarsParser';
10
10
  import ThemeProvider from '../ThemeProvider';
11
- import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
11
+ import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
12
12
  import useCurrentColorScheme from './useCurrentColorScheme';
13
13
  import createGetCssVar from './createGetCssVar';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,6 +17,9 @@ export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-
17
17
  export default function createCssVarsProvider(options) {
18
18
  const {
19
19
  theme: defaultTheme = {},
20
+ attribute: defaultAttribute = DEFAULT_ATTRIBUTE,
21
+ modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
22
+ colorSchemeStorageKey: defaultColorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
20
23
  defaultMode: desisgnSystemMode = 'light',
21
24
  defaultColorScheme: designSystemColorScheme,
22
25
  disableTransitionOnChange: designSystemTransitionOnChange = false,
@@ -46,9 +49,9 @@ export default function createCssVarsProvider(options) {
46
49
  children,
47
50
  theme: themeProp = defaultTheme,
48
51
  prefix = designSystemPrefix,
49
- modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
50
- colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
51
- attribute = DEFAULT_ATTRIBUTE,
52
+ modeStorageKey = defaultModeStorageKey,
53
+ colorSchemeStorageKey = defaultColorSchemeStorageKey,
54
+ attribute = defaultAttribute,
52
55
  defaultMode = desisgnSystemMode,
53
56
  defaultColorScheme = designSystemColorScheme,
54
57
  disableTransitionOnChange = designSystemTransitionOnChange,
@@ -116,9 +119,11 @@ export default function createCssVarsProvider(options) {
116
119
  colorSchemes,
117
120
  prefix,
118
121
  vars: rootVars,
119
- getCssVar: createGetCssVar(prefix)
122
+ getCssVar: createGetCssVar(prefix),
123
+ getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
120
124
  });
121
- const styleSheet = {};
125
+ const defaultColorSchemeStyleSheet = {};
126
+ const otherColorSchemesStyleSheet = {};
122
127
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
123
128
  const {
124
129
  css,
@@ -154,9 +159,9 @@ export default function createCssVarsProvider(options) {
154
159
  })();
155
160
 
156
161
  if (key === resolvedDefaultColorScheme) {
157
- styleSheet[colorSchemeSelector] = css;
162
+ defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
158
163
  } else {
159
- styleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
164
+ otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
160
165
  }
161
166
  });
162
167
  React.useEffect(() => {
@@ -223,7 +228,9 @@ export default function createCssVarsProvider(options) {
223
228
  [colorSchemeSelector]: rootCss
224
229
  }
225
230
  }), /*#__PURE__*/_jsx(GlobalStyles, {
226
- styles: styleSheet
231
+ styles: defaultColorSchemeStyleSheet
232
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
233
+ styles: otherColorSchemesStyleSheet
227
234
  }), /*#__PURE__*/_jsx(ThemeProvider, {
228
235
  theme: resolveTheme ? resolveTheme(theme) : theme,
229
236
  children: children
@@ -303,6 +310,13 @@ export default function createCssVarsProvider(options) {
303
310
  */
304
311
  theme: PropTypes.object
305
312
  } : void 0;
313
+
314
+ const getInitColorSchemeScript = params => systemGetInitColorSchemeScript(_extends({
315
+ attribute: defaultAttribute,
316
+ colorSchemeStorageKey: defaultColorSchemeStorageKey,
317
+ modeStorageKey: defaultModeStorageKey
318
+ }, params));
319
+
306
320
  return {
307
321
  CssVarsProvider,
308
322
  useColorScheme,
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export const DEFAULT_MODE_STORAGE_KEY = 'mui-mode';
4
- export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
- export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
3
+ export const DEFAULT_MODE_STORAGE_KEY = 'mode';
4
+ export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
5
+ export const DEFAULT_ATTRIBUTE = 'data-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  const {
8
8
  enableSystem = false,
package/esm/spacing.js CHANGED
@@ -45,7 +45,7 @@ const spacingKeys = [...marginKeys, ...paddingKeys];
45
45
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
46
46
  var _getPath;
47
47
 
48
- const themeSpacing = (_getPath = getPath(theme, themeKey)) != null ? _getPath : defaultValue;
48
+ const themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
49
49
 
50
50
  if (typeof themeSpacing === 'number') {
51
51
  return abs => {
package/esm/style.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { unstable_capitalize as capitalize } from '@mui/utils';
2
2
  import responsivePropType from './responsivePropType';
3
3
  import { handleBreakpoints } from './breakpoints';
4
- export function getPath(obj, path) {
4
+ export function getPath(obj, path, checkVars = true) {
5
5
  if (!path || typeof path !== 'string') {
6
6
  return null;
7
7
  } // Check if CSS variables are used
8
8
 
9
9
 
10
- if (obj && obj.vars) {
10
+ if (obj && obj.vars && checkVars) {
11
11
  const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
12
12
 
13
13
  if (val != null) {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.8.0
1
+ /** @license MUI v5.8.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -10,7 +10,7 @@ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui
10
10
  import { GlobalStyles } from '@mui/styled-engine';
11
11
  import cssVarsParser from './cssVarsParser';
12
12
  import ThemeProvider from '../ThemeProvider';
13
- import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
13
+ import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
14
14
  import useCurrentColorScheme from './useCurrentColorScheme';
15
15
  import createGetCssVar from './createGetCssVar';
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -19,6 +19,12 @@ export var DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-tr
19
19
  export default function createCssVarsProvider(options) {
20
20
  var _options$theme = options.theme,
21
21
  defaultTheme = _options$theme === void 0 ? {} : _options$theme,
22
+ _options$attribute = options.attribute,
23
+ defaultAttribute = _options$attribute === void 0 ? DEFAULT_ATTRIBUTE : _options$attribute,
24
+ _options$modeStorageK = options.modeStorageKey,
25
+ defaultModeStorageKey = _options$modeStorageK === void 0 ? DEFAULT_MODE_STORAGE_KEY : _options$modeStorageK,
26
+ _options$colorSchemeS = options.colorSchemeStorageKey,
27
+ defaultColorSchemeStorageKey = _options$colorSchemeS === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _options$colorSchemeS,
22
28
  _options$defaultMode = options.defaultMode,
23
29
  desisgnSystemMode = _options$defaultMode === void 0 ? 'light' : _options$defaultMode,
24
30
  designSystemColorScheme = options.defaultColorScheme,
@@ -54,11 +60,11 @@ export default function createCssVarsProvider(options) {
54
60
  _ref$prefix = _ref.prefix,
55
61
  prefix = _ref$prefix === void 0 ? designSystemPrefix : _ref$prefix,
56
62
  _ref$modeStorageKey = _ref.modeStorageKey,
57
- modeStorageKey = _ref$modeStorageKey === void 0 ? DEFAULT_MODE_STORAGE_KEY : _ref$modeStorageKey,
63
+ modeStorageKey = _ref$modeStorageKey === void 0 ? defaultModeStorageKey : _ref$modeStorageKey,
58
64
  _ref$colorSchemeStora = _ref.colorSchemeStorageKey,
59
- colorSchemeStorageKey = _ref$colorSchemeStora === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _ref$colorSchemeStora,
65
+ colorSchemeStorageKey = _ref$colorSchemeStora === void 0 ? defaultColorSchemeStorageKey : _ref$colorSchemeStora,
60
66
  _ref$attribute = _ref.attribute,
61
- attribute = _ref$attribute === void 0 ? DEFAULT_ATTRIBUTE : _ref$attribute,
67
+ attribute = _ref$attribute === void 0 ? defaultAttribute : _ref$attribute,
62
68
  _ref$defaultMode = _ref.defaultMode,
63
69
  defaultMode = _ref$defaultMode === void 0 ? desisgnSystemMode : _ref$defaultMode,
64
70
  _ref$defaultColorSche = _ref.defaultColorScheme,
@@ -134,9 +140,13 @@ export default function createCssVarsProvider(options) {
134
140
  colorSchemes: colorSchemes,
135
141
  prefix: prefix,
136
142
  vars: rootVars,
137
- getCssVar: createGetCssVar(prefix)
143
+ getCssVar: createGetCssVar(prefix),
144
+ getColorSchemeSelector: function getColorSchemeSelector(targetColorScheme) {
145
+ return "[".concat(attribute, "=\"").concat(targetColorScheme, "\"] &");
146
+ }
138
147
  });
139
- var styleSheet = {};
148
+ var defaultColorSchemeStyleSheet = {};
149
+ var otherColorSchemesStyleSheet = {};
140
150
  Object.entries(colorSchemes).forEach(function (_ref2) {
141
151
  var _ref3 = _slicedToArray(_ref2, 2),
142
152
  key = _ref3[0],
@@ -176,9 +186,9 @@ export default function createCssVarsProvider(options) {
176
186
  }();
177
187
 
178
188
  if (key === resolvedDefaultColorScheme) {
179
- styleSheet[colorSchemeSelector] = css;
189
+ defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
180
190
  } else {
181
- styleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
191
+ otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
182
192
  }
183
193
  });
184
194
  React.useEffect(function () {
@@ -245,7 +255,9 @@ export default function createCssVarsProvider(options) {
245
255
  children: [/*#__PURE__*/_jsx(GlobalStyles, {
246
256
  styles: _defineProperty({}, colorSchemeSelector, rootCss)
247
257
  }), /*#__PURE__*/_jsx(GlobalStyles, {
248
- styles: styleSheet
258
+ styles: defaultColorSchemeStyleSheet
259
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
260
+ styles: otherColorSchemesStyleSheet
249
261
  }), /*#__PURE__*/_jsx(ThemeProvider, {
250
262
  theme: resolveTheme ? resolveTheme(theme) : theme,
251
263
  children: children
@@ -325,6 +337,15 @@ export default function createCssVarsProvider(options) {
325
337
  */
326
338
  theme: PropTypes.object
327
339
  } : void 0;
340
+
341
+ var getInitColorSchemeScript = function getInitColorSchemeScript(params) {
342
+ return systemGetInitColorSchemeScript(_extends({
343
+ attribute: defaultAttribute,
344
+ colorSchemeStorageKey: defaultColorSchemeStorageKey,
345
+ modeStorageKey: defaultModeStorageKey
346
+ }, params));
347
+ };
348
+
328
349
  return {
329
350
  CssVarsProvider: CssVarsProvider,
330
351
  useColorScheme: useColorScheme,
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export var DEFAULT_MODE_STORAGE_KEY = 'mui-mode';
4
- export var DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
- export var DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
3
+ export var DEFAULT_MODE_STORAGE_KEY = 'mode';
4
+ export var DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
5
+ export var DEFAULT_ATTRIBUTE = 'data-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  var _ref = options || {},
8
8
  _ref$enableSystem = _ref.enableSystem,
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.8.0
1
+ /** @license MUI v5.8.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/legacy/spacing.js CHANGED
@@ -52,7 +52,7 @@ var spacingKeys = [].concat(marginKeys, paddingKeys);
52
52
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
53
53
  var _getPath;
54
54
 
55
- var themeSpacing = (_getPath = getPath(theme, themeKey)) != null ? _getPath : defaultValue;
55
+ var themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
56
56
 
57
57
  if (typeof themeSpacing === 'number') {
58
58
  return function (abs) {
package/legacy/style.js CHANGED
@@ -3,12 +3,14 @@ import { unstable_capitalize as capitalize } from '@mui/utils';
3
3
  import responsivePropType from './responsivePropType';
4
4
  import { handleBreakpoints } from './breakpoints';
5
5
  export function getPath(obj, path) {
6
+ var checkVars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7
+
6
8
  if (!path || typeof path !== 'string') {
7
9
  return null;
8
10
  } // Check if CSS variables are used
9
11
 
10
12
 
11
- if (obj && obj.vars) {
13
+ if (obj && obj.vars && checkVars) {
12
14
  var val = "vars.".concat(path).split('.').reduce(function (acc, item) {
13
15
  return acc && acc[item] ? acc[item] : null;
14
16
  }, obj);