@mui/system 5.10.8 → 5.10.9

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 (48) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +117 -0
  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/Stack/Stack.d.ts +13 -13
  8. package/Stack/StackProps.d.ts +42 -42
  9. package/Stack/createStack.d.ts +21 -21
  10. package/Stack/index.d.ts +5 -5
  11. package/Stack/stackClasses.d.ts +8 -8
  12. package/Unstable_Grid/Grid.d.ts +12 -12
  13. package/Unstable_Grid/GridProps.d.ts +162 -162
  14. package/Unstable_Grid/createGrid.d.ts +11 -11
  15. package/Unstable_Grid/createGrid.js +1 -1
  16. package/Unstable_Grid/gridClasses.d.ts +20 -20
  17. package/Unstable_Grid/gridGenerator.d.ts +28 -26
  18. package/Unstable_Grid/gridGenerator.js +16 -2
  19. package/Unstable_Grid/index.d.ts +5 -5
  20. package/createBox.spec.d.ts +1 -1
  21. package/createTheme/createSpacing.d.ts +10 -10
  22. package/cssVars/createCssVarsProvider.d.ts +0 -5
  23. package/cssVars/createCssVarsProvider.js +45 -44
  24. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  25. package/cssVars/createGetCssVar.d.ts +5 -5
  26. package/cssVars/cssVarsParser.d.ts +65 -65
  27. package/cssVars/getInitColorSchemeScript.d.ts +42 -47
  28. package/cssVars/getInitColorSchemeScript.js +0 -4
  29. package/cssVars/index.d.ts +3 -3
  30. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  31. package/esm/Unstable_Grid/createGrid.js +2 -2
  32. package/esm/Unstable_Grid/gridGenerator.js +11 -0
  33. package/esm/cssVars/createCssVarsProvider.js +47 -45
  34. package/esm/cssVars/getInitColorSchemeScript.js +0 -4
  35. package/index.js +1 -1
  36. package/index.spec.d.ts +1 -1
  37. package/legacy/Unstable_Grid/createGrid.js +2 -2
  38. package/legacy/Unstable_Grid/gridGenerator.js +17 -0
  39. package/legacy/cssVars/createCssVarsProvider.js +45 -47
  40. package/legacy/cssVars/getInitColorSchemeScript.js +1 -3
  41. package/legacy/index.js +1 -1
  42. package/modern/Unstable_Grid/createGrid.js +2 -2
  43. package/modern/Unstable_Grid/gridGenerator.js +11 -0
  44. package/modern/cssVars/createCssVarsProvider.js +47 -45
  45. package/modern/cssVars/getInitColorSchemeScript.js +0 -4
  46. package/modern/index.js +1 -1
  47. package/package.json +3 -3
  48. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -45,10 +45,9 @@ function createCssVarsProvider(options) {
45
45
  attribute: defaultAttribute = _getInitColorSchemeScript.DEFAULT_ATTRIBUTE,
46
46
  modeStorageKey: defaultModeStorageKey = _getInitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
47
47
  colorSchemeStorageKey: defaultColorSchemeStorageKey = _getInitColorSchemeScript.DEFAULT_COLOR_SCHEME_STORAGE_KEY,
48
- defaultMode: desisgnSystemMode = 'light',
48
+ defaultMode: designSystemMode = 'light',
49
49
  defaultColorScheme: designSystemColorScheme,
50
50
  disableTransitionOnChange: designSystemTransitionOnChange = false,
51
- enableColorScheme: designSystemEnableColorScheme = true,
52
51
  shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
53
52
  resolveTheme,
54
53
  excludeVariablesFromRoot
@@ -76,10 +75,9 @@ function createCssVarsProvider(options) {
76
75
  modeStorageKey = defaultModeStorageKey,
77
76
  colorSchemeStorageKey = defaultColorSchemeStorageKey,
78
77
  attribute = defaultAttribute,
79
- defaultMode = desisgnSystemMode,
78
+ defaultMode = designSystemMode,
80
79
  defaultColorScheme = designSystemColorScheme,
81
80
  disableTransitionOnChange = designSystemTransitionOnChange,
82
- enableColorScheme = designSystemEnableColorScheme,
83
81
  storageWindow = typeof window === 'undefined' ? undefined : window,
84
82
  documentNode = typeof document === 'undefined' ? undefined : document,
85
83
  colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
@@ -95,7 +93,8 @@ function createCssVarsProvider(options) {
95
93
  restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded);
96
94
  const allColorSchemes = Object.keys(colorSchemes);
97
95
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
98
- const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
96
+ const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark; // 1. Get the data about the `mode`, `colorScheme`, and setter functions.
97
+
99
98
  const {
100
99
  mode,
101
100
  setMode,
@@ -114,36 +113,53 @@ function createCssVarsProvider(options) {
114
113
  storageWindow
115
114
  });
116
115
 
117
- const resolvedColorScheme = (() => {
116
+ const calculatedMode = (() => {
117
+ if (!mode) {
118
+ // This scope occurs on the server
119
+ if (defaultMode === 'system') {
120
+ return designSystemMode;
121
+ }
122
+
123
+ return defaultMode;
124
+ }
125
+
126
+ return mode;
127
+ })();
128
+
129
+ const calculatedColorScheme = (() => {
118
130
  if (!colorScheme) {
119
131
  // This scope occurs on the server
120
- if (defaultMode === 'dark') {
132
+ if (calculatedMode === 'dark') {
121
133
  return defaultDarkColorScheme;
122
- } // use light color scheme, if default mode is 'light' | 'auto'
134
+ } // use light color scheme, if default mode is 'light' | 'system'
123
135
 
124
136
 
125
137
  return defaultLightColorScheme;
126
138
  }
127
139
 
128
140
  return colorScheme;
129
- })();
141
+ })(); // 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
142
+
130
143
 
131
- let theme = restThemeProp;
132
144
  const {
133
145
  css: rootCss,
134
146
  vars: rootVars,
135
147
  parsedTheme
136
- } = (0, _cssVarsParser.default)(theme, {
148
+ } = (0, _cssVarsParser.default)(restThemeProp, {
137
149
  prefix: cssVarPrefix,
138
150
  shouldSkipGeneratingVar
139
- });
140
- theme = (0, _extends2.default)({}, parsedTheme, {
151
+ }); // 3. Start composing the theme object
152
+
153
+ let theme = (0, _extends2.default)({}, parsedTheme, {
141
154
  components,
142
155
  colorSchemes,
143
156
  cssVarPrefix,
144
157
  vars: rootVars,
145
158
  getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
146
- });
159
+ }); // 4. Create color CSS variables and store them in objects (to be generated in stylesheets in the final step)
160
+ // The default color scheme stylesheet is constructed to have the least CSS specificity.
161
+ // 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
+
147
163
  const defaultColorSchemeStyleSheet = {};
148
164
  const otherColorSchemesStyleSheet = {};
149
165
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
@@ -157,13 +173,12 @@ function createCssVarsProvider(options) {
157
173
  });
158
174
  theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
159
175
 
160
- if (key === resolvedColorScheme) {
176
+ if (key === calculatedColorScheme) {
177
+ // 4.1 Merge the selected color scheme to the theme
161
178
  theme = (0, _extends2.default)({}, theme, parsedScheme);
162
179
 
163
180
  if (theme.palette) {
164
- // assign runtime mode & colorScheme
165
- theme.palette.mode = mode;
166
- theme.palette.colorScheme = resolvedColorScheme;
181
+ theme.palette.colorScheme = key;
167
182
  }
168
183
  }
169
184
 
@@ -193,35 +208,21 @@ function createCssVarsProvider(options) {
193
208
  } else {
194
209
  otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
195
210
  }
196
- });
211
+ }); // 5. Declaring effects
212
+ // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
213
+
197
214
  React.useEffect(() => {
198
215
  if (colorScheme && colorSchemeNode) {
199
216
  // attaches attribute to <html> because the css variables are attached to :root (html)
200
217
  colorSchemeNode.setAttribute(attribute, colorScheme);
201
218
  }
202
- }, [colorScheme, attribute, colorSchemeNode]);
203
- (0, _utils.unstable_useEnhancedEffect)(() => {
204
- if (!mode || !enableColorScheme || !colorSchemeNode) {
205
- return undefined;
206
- }
219
+ }, [colorScheme, attribute, colorSchemeNode]); // 5.2 Remove the CSS transition when color scheme changes to create instant experience.
220
+ // credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
207
221
 
208
- const priorColorScheme = colorSchemeNode.style.getPropertyValue('color-scheme'); // `color-scheme` tells browser to render built-in elements according to its value: `light` or `dark`
209
-
210
- if (mode === 'system') {
211
- colorSchemeNode.style.setProperty('color-scheme', systemMode);
212
- } else {
213
- colorSchemeNode.style.setProperty('color-scheme', mode);
214
- }
215
-
216
- return () => {
217
- colorSchemeNode.style.setProperty('color-scheme', priorColorScheme);
218
- };
219
- }, [mode, systemMode, enableColorScheme, colorSchemeNode]);
220
222
  React.useEffect(() => {
221
223
  let timer;
222
224
 
223
225
  if (disableTransitionOnChange && hasMounted.current && documentNode) {
224
- // credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
225
226
  const css = documentNode.createElement('style');
226
227
  css.appendChild(documentNode.createTextNode(DISABLE_CSS_TRANSITION));
227
228
  documentNode.head.appendChild(css); // Force browser repaint
@@ -246,6 +247,7 @@ function createCssVarsProvider(options) {
246
247
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ColorSchemeContext.Provider, {
247
248
  value: {
248
249
  mode,
250
+ systemMode,
249
251
  setMode,
250
252
  lightColorScheme,
251
253
  darkColorScheme,
@@ -314,11 +316,6 @@ function createCssVarsProvider(options) {
314
316
  */
315
317
  documentNode: _propTypes.default.any,
316
318
 
317
- /**
318
- * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
319
- */
320
- enableColorScheme: _propTypes.default.bool,
321
-
322
319
  /**
323
320
  * The key in the local storage used to store current color scheme.
324
321
  */
@@ -340,12 +337,16 @@ function createCssVarsProvider(options) {
340
337
  */
341
338
  theme: _propTypes.default.object
342
339
  } : void 0;
340
+ const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
341
+ const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
343
342
 
344
343
  const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)((0, _extends2.default)({
345
344
  attribute: defaultAttribute,
346
345
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
347
- modeStorageKey: defaultModeStorageKey,
348
- enableColorScheme: designSystemEnableColorScheme
346
+ defaultMode: designSystemMode,
347
+ defaultLightColorScheme,
348
+ defaultDarkColorScheme,
349
+ modeStorageKey: defaultModeStorageKey
349
350
  }, params));
350
351
 
351
352
  return {
@@ -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;
@@ -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 {};
@@ -1,47 +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
- * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
8
- * @default true
9
- */
10
- enableColorScheme?: boolean;
11
- /**
12
- * The mode to be used for the first visit
13
- * @default 'light'
14
- */
15
- defaultMode?: 'light' | 'dark' | 'system';
16
- /**
17
- * The default color scheme to be used on the light mode
18
- * @default 'light'
19
- */
20
- defaultLightColorScheme?: string;
21
- /**
22
- * The default color scheme to be used on the dark mode
23
- * * @default 'dark'
24
- */
25
- defaultDarkColorScheme?: string;
26
- /**
27
- * The node (provided as string) used to attach the color-scheme attribute
28
- * @default 'document.documentElement'
29
- */
30
- colorSchemeNode?: string;
31
- /**
32
- * localStorage key used to store `mode`
33
- * @default 'mode'
34
- */
35
- modeStorageKey?: string;
36
- /**
37
- * localStorage key used to store `colorScheme`
38
- * @default 'color-scheme'
39
- */
40
- colorSchemeStorageKey?: string;
41
- /**
42
- * DOM attribute for applying color scheme
43
- * @default 'data-color-scheme'
44
- */
45
- attribute?: string;
46
- }
47
- 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;
@@ -23,7 +23,6 @@ exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
23
23
 
24
24
  function getInitColorSchemeScript(options) {
25
25
  const {
26
- enableColorScheme = true,
27
26
  defaultMode = 'light',
28
27
  defaultLightColorScheme = 'light',
29
28
  defaultDarkColorScheme = 'dark',
@@ -59,9 +58,6 @@ function getInitColorSchemeScript(options) {
59
58
  if (colorScheme) {
60
59
  ${colorSchemeNode}.setAttribute('${attribute}', colorScheme);
61
60
  }
62
- if (${enableColorScheme} && !!cssColorScheme) {
63
- ${colorSchemeNode}.style.setProperty('color-scheme', cssColorScheme);
64
- }
65
61
  } catch (e) {} })();`
66
62
  }
67
63
  });
@@ -1,3 +1,3 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
@@ -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 {};
@@ -10,7 +10,7 @@ import useThemePropsSystem from '../useThemeProps';
10
10
  import useTheme from '../useTheme';
11
11
  import { extendSxProp } from '../styleFunctionSx';
12
12
  import createTheme from '../createTheme';
13
- import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames } from './gridGenerator';
13
+ import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames, generateDirectionClasses } from './gridGenerator';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  const defaultTheme = createTheme(); // widening Theme to any so that the consumer can own the theme structure.
16
16
 
@@ -47,7 +47,7 @@ export default function createGrid(options = {}) {
47
47
  gridSize
48
48
  } = ownerState;
49
49
  const slots = {
50
- root: ['root', container && 'container', direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
50
+ root: ['root', container && 'container', wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateDirectionClasses(direction), ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
51
51
  };
52
52
  return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
53
53
  };
@@ -233,4 +233,15 @@ export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') =>
233
233
  }
234
234
 
235
235
  return [];
236
+ };
237
+ export const generateDirectionClasses = direction => {
238
+ if (direction === undefined) {
239
+ return [];
240
+ }
241
+
242
+ if (typeof direction === 'object') {
243
+ return Object.entries(direction).map(([key, value]) => `direction-${key}-${value}`);
244
+ }
245
+
246
+ return [`direction-xs-${String(direction)}`];
236
247
  };