@mui/system 5.13.2 → 5.13.5

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 (46) hide show
  1. package/CHANGELOG.md +143 -4
  2. package/Container/Container.d.ts +13 -13
  3. package/Container/ContainerProps.d.ts +40 -40
  4. package/Container/containerClasses.d.ts +22 -22
  5. package/Container/createContainer.d.ts +18 -18
  6. package/GlobalStyles/GlobalStyles.d.ts +13 -13
  7. package/GlobalStyles/index.d.ts +2 -2
  8. package/Stack/Stack.d.ts +14 -14
  9. package/Stack/StackProps.d.ts +53 -53
  10. package/Stack/createStack.d.ts +21 -21
  11. package/Stack/index.d.ts +5 -5
  12. package/Stack/stackClasses.d.ts +8 -8
  13. package/Unstable_Grid/Grid.d.ts +12 -12
  14. package/Unstable_Grid/GridProps.d.ts +185 -185
  15. package/Unstable_Grid/createGrid.d.ts +11 -11
  16. package/Unstable_Grid/gridClasses.d.ts +20 -20
  17. package/Unstable_Grid/gridGenerator.d.ts +33 -38
  18. package/Unstable_Grid/gridGenerator.js +8 -51
  19. package/Unstable_Grid/index.d.ts +6 -5
  20. package/Unstable_Grid/index.js +9 -1
  21. package/Unstable_Grid/traverseBreakpoints.d.ts +7 -0
  22. package/Unstable_Grid/traverseBreakpoints.js +50 -0
  23. package/createTheme/createSpacing.d.ts +10 -10
  24. package/cssVars/createCssVarsProvider.js +6 -0
  25. package/cssVars/createCssVarsTheme.d.ts +15 -15
  26. package/cssVars/createGetCssVar.d.ts +5 -5
  27. package/cssVars/cssVarsParser.d.ts +64 -64
  28. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  29. package/cssVars/index.d.ts +5 -5
  30. package/cssVars/prepareCssVars.d.ts +16 -16
  31. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  32. package/esm/Unstable_Grid/gridGenerator.js +1 -42
  33. package/esm/Unstable_Grid/index.js +2 -1
  34. package/esm/Unstable_Grid/traverseBreakpoints.js +42 -0
  35. package/esm/cssVars/createCssVarsProvider.js +6 -0
  36. package/index.js +1 -1
  37. package/legacy/Unstable_Grid/gridGenerator.js +3 -48
  38. package/legacy/Unstable_Grid/index.js +2 -1
  39. package/legacy/Unstable_Grid/traverseBreakpoints.js +48 -0
  40. package/legacy/index.js +1 -1
  41. package/modern/Unstable_Grid/gridGenerator.js +1 -42
  42. package/modern/Unstable_Grid/index.js +2 -1
  43. package/modern/Unstable_Grid/traverseBreakpoints.js +42 -0
  44. package/modern/cssVars/createCssVarsProvider.js +6 -0
  45. package/modern/index.js +1 -1
  46. package/package.json +1 -1
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  var _exportNames = {
8
8
  createGrid: true,
9
- gridClasses: true
9
+ gridClasses: true,
10
+ unstable_traverseBreakpoints: true
10
11
  };
11
12
  Object.defineProperty(exports, "createGrid", {
12
13
  enumerable: true,
@@ -26,6 +27,12 @@ Object.defineProperty(exports, "gridClasses", {
26
27
  return _gridClasses.default;
27
28
  }
28
29
  });
30
+ Object.defineProperty(exports, "unstable_traverseBreakpoints", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _traverseBreakpoints.traverseBreakpoints;
34
+ }
35
+ });
29
36
  var _Grid = _interopRequireDefault(require("./Grid"));
30
37
  var _createGrid = _interopRequireDefault(require("./createGrid"));
31
38
  var _GridProps = require("./GridProps");
@@ -52,5 +59,6 @@ Object.keys(_gridClasses).forEach(function (key) {
52
59
  }
53
60
  });
54
61
  });
62
+ var _traverseBreakpoints = require("./traverseBreakpoints");
55
63
  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); }
56
64
  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; }
@@ -0,0 +1,7 @@
1
+ import { Breakpoints, Breakpoint } from '../createTheme/createBreakpoints';
2
+ export declare const filterBreakpointKeys: (breakpointsKeys: Breakpoint[], responsiveKeys: string[]) => Breakpoint[];
3
+ interface Iterator<T> {
4
+ (appendStyle: (responsiveStyles: Record<string, any>, style: object) => void, value: T): void;
5
+ }
6
+ export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsive: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
7
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.traverseBreakpoints = exports.filterBreakpointKeys = void 0;
7
+ const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
8
+ exports.filterBreakpointKeys = filterBreakpointKeys;
9
+ const traverseBreakpoints = (breakpoints, responsive, iterator) => {
10
+ const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
11
+
12
+ if (Array.isArray(responsive)) {
13
+ responsive.forEach((breakpointValue, index) => {
14
+ iterator((responsiveStyles, style) => {
15
+ if (index <= breakpoints.keys.length - 1) {
16
+ if (index === 0) {
17
+ Object.assign(responsiveStyles, style);
18
+ } else {
19
+ responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
20
+ }
21
+ }
22
+ }, breakpointValue);
23
+ });
24
+ } else if (responsive && typeof responsive === 'object') {
25
+ // prevent null
26
+ // responsive could be a very big object, pick the smallest responsive values
27
+
28
+ const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
29
+ keys.forEach(key => {
30
+ if (breakpoints.keys.indexOf(key) !== -1) {
31
+ // @ts-ignore already checked that responsive is an object
32
+ const breakpointValue = responsive[key];
33
+ if (breakpointValue !== undefined) {
34
+ iterator((responsiveStyles, style) => {
35
+ if (smallestBreakpoint === key) {
36
+ Object.assign(responsiveStyles, style);
37
+ } else {
38
+ responsiveStyles[breakpoints.up(key)] = style;
39
+ }
40
+ }, breakpointValue);
41
+ }
42
+ }
43
+ });
44
+ } else if (typeof responsive === 'number' || typeof responsive === 'string') {
45
+ iterator((responsiveStyles, style) => {
46
+ Object.assign(responsiveStyles, style);
47
+ }, responsive);
48
+ }
49
+ };
50
+ exports.traverseBreakpoints = traverseBreakpoints;
@@ -1,10 +1,10 @@
1
- export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
- export type SpacingArgument = number | string;
3
- export interface Spacing {
4
- (): string;
5
- (value: number): string;
6
- (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
- (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
- (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
- }
10
- export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
1
+ export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
+ export type SpacingArgument = number | string;
3
+ export interface Spacing {
4
+ (): string;
5
+ (value: number): string;
6
+ (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
+ (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
+ (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
+ }
10
+ export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
@@ -25,6 +25,12 @@ exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
25
25
  function createCssVarsProvider(options) {
26
26
  const {
27
27
  themeId,
28
+ /**
29
+ * This `theme` object needs to follow a certain structure to
30
+ * be used correctly by the finel `CssVarsProvider`. It should have a
31
+ * `colorSchemes` key with the light and dark (and any other) palette.
32
+ * It should also ideally have a vars object created using `prepareCssVars`.
33
+ */
28
34
  theme: defaultTheme = {},
29
35
  attribute: defaultAttribute = _getInitColorSchemeScript.DEFAULT_ATTRIBUTE,
30
36
  modeStorageKey: defaultModeStorageKey = _getInitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
@@ -1,15 +1,15 @@
1
- import { DefaultCssVarsTheme } from './prepareCssVars';
2
- interface Theme extends DefaultCssVarsTheme {
3
- cssVarPrefix?: string;
4
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
5
- }
6
- declare function createCssVarsTheme<T extends Theme, ThemeVars extends Record<string, any>>(theme: T): T & {
7
- vars: ThemeVars;
8
- generateCssVars: (colorScheme?: string | undefined) => {
9
- css: {
10
- [x: string]: string | number;
11
- };
12
- vars: ThemeVars;
13
- };
14
- };
15
- export default createCssVarsTheme;
1
+ import { DefaultCssVarsTheme } from './prepareCssVars';
2
+ interface Theme extends DefaultCssVarsTheme {
3
+ cssVarPrefix?: string;
4
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
5
+ }
6
+ declare function createCssVarsTheme<T extends Theme, ThemeVars extends Record<string, any>>(theme: T): T & {
7
+ vars: ThemeVars;
8
+ generateCssVars: (colorScheme?: string | undefined) => {
9
+ css: {
10
+ [x: string]: string | number;
11
+ };
12
+ vars: ThemeVars;
13
+ };
14
+ };
15
+ export default createCssVarsTheme;
@@ -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,64 +1,64 @@
1
- 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 }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
45
- *
46
- * @example
47
- * const { css, vars } = 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
- */
56
- export default function cssVarsParser<T extends Record<string, any>>(theme: Record<string, any>, options?: {
57
- prefix?: string;
58
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
59
- }): {
60
- css: Record<string, string | number>;
61
- vars: T;
62
- varsWithDefaults: {};
63
- };
64
- export {};
1
+ 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 }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
45
+ *
46
+ * @example
47
+ * const { css, vars } = 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
+ */
56
+ export default function cssVarsParser<T extends Record<string, any>>(theme: Record<string, any>, options?: {
57
+ prefix?: string;
58
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
59
+ }): {
60
+ css: Record<string, string | number>;
61
+ vars: T;
62
+ varsWithDefaults: {};
63
+ };
64
+ export {};
@@ -1,42 +1,42 @@
1
- import * as React from '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): React.JSX.Element;
1
+ import * as React from '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): React.JSX.Element;
@@ -1,5 +1,5 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
4
- export { default as prepareCssVars } from './prepareCssVars';
5
- export { default as createCssVarsTheme } from './createCssVarsTheme';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
4
+ export { default as prepareCssVars } from './prepareCssVars';
5
+ export { default as createCssVarsTheme } from './createCssVarsTheme';
@@ -1,16 +1,16 @@
1
- export interface DefaultCssVarsTheme {
2
- colorSchemes: Record<string, any>;
3
- }
4
- declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
5
- prefix?: string;
6
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
7
- }): {
8
- vars: ThemeVars;
9
- generateCssVars: (colorScheme?: string) => {
10
- css: {
11
- [x: string]: string | number;
12
- };
13
- vars: ThemeVars;
14
- };
15
- };
16
- export default prepareCssVars;
1
+ export interface DefaultCssVarsTheme {
2
+ colorSchemes: Record<string, any>;
3
+ }
4
+ declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
5
+ prefix?: string;
6
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
7
+ }): {
8
+ vars: ThemeVars;
9
+ generateCssVars: (colorScheme?: string) => {
10
+ css: {
11
+ [x: string]: string | number;
12
+ };
13
+ vars: ThemeVars;
14
+ };
15
+ };
16
+ export default prepareCssVars;
@@ -1,53 +1,53 @@
1
- export type Mode = 'light' | 'dark' | 'system';
2
- export 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 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 type Mode = 'light' | 'dark' | 'system';
2
+ export 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 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,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { traverseBreakpoints } from './traverseBreakpoints';
2
3
  function appendLevel(level) {
3
4
  if (!level) {
4
5
  return '';
@@ -27,48 +28,6 @@ function getParentColumns(ownerState) {
27
28
  }
28
29
  return `var(--Grid-columns${appendLevel(ownerState.unstable_level - 1)})`;
29
30
  }
30
- export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
31
- export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
32
- const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
33
-
34
- if (Array.isArray(responsive)) {
35
- responsive.forEach((breakpointValue, index) => {
36
- iterator((responsiveStyles, style) => {
37
- if (index <= breakpoints.keys.length - 1) {
38
- if (index === 0) {
39
- Object.assign(responsiveStyles, style);
40
- } else {
41
- responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
42
- }
43
- }
44
- }, breakpointValue);
45
- });
46
- } else if (responsive && typeof responsive === 'object') {
47
- // prevent null
48
- // responsive could be a very big object, pick the smallest responsive values
49
-
50
- const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
51
- keys.forEach(key => {
52
- if (breakpoints.keys.indexOf(key) !== -1) {
53
- // @ts-ignore already checked that responsive is an object
54
- const breakpointValue = responsive[key];
55
- if (breakpointValue !== undefined) {
56
- iterator((responsiveStyles, style) => {
57
- if (smallestBreakpoint === key) {
58
- Object.assign(responsiveStyles, style);
59
- } else {
60
- responsiveStyles[breakpoints.up(key)] = style;
61
- }
62
- }, breakpointValue);
63
- }
64
- }
65
- });
66
- } else if (typeof responsive === 'number' || typeof responsive === 'string') {
67
- iterator((responsiveStyles, style) => {
68
- Object.assign(responsiveStyles, style);
69
- }, responsive);
70
- }
71
- };
72
31
  export const generateGridSizeStyles = ({
73
32
  theme,
74
33
  ownerState
@@ -2,4 +2,5 @@ export { default } from './Grid';
2
2
  export { default as createGrid } from './createGrid';
3
3
  export * from './GridProps';
4
4
  export { default as gridClasses } from './gridClasses';
5
- export * from './gridClasses';
5
+ export * from './gridClasses';
6
+ export { traverseBreakpoints as unstable_traverseBreakpoints } from './traverseBreakpoints';
@@ -0,0 +1,42 @@
1
+ export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
2
+ export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
3
+ const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
4
+
5
+ if (Array.isArray(responsive)) {
6
+ responsive.forEach((breakpointValue, index) => {
7
+ iterator((responsiveStyles, style) => {
8
+ if (index <= breakpoints.keys.length - 1) {
9
+ if (index === 0) {
10
+ Object.assign(responsiveStyles, style);
11
+ } else {
12
+ responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
13
+ }
14
+ }
15
+ }, breakpointValue);
16
+ });
17
+ } else if (responsive && typeof responsive === 'object') {
18
+ // prevent null
19
+ // responsive could be a very big object, pick the smallest responsive values
20
+
21
+ const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
22
+ keys.forEach(key => {
23
+ if (breakpoints.keys.indexOf(key) !== -1) {
24
+ // @ts-ignore already checked that responsive is an object
25
+ const breakpointValue = responsive[key];
26
+ if (breakpointValue !== undefined) {
27
+ iterator((responsiveStyles, style) => {
28
+ if (smallestBreakpoint === key) {
29
+ Object.assign(responsiveStyles, style);
30
+ } else {
31
+ responsiveStyles[breakpoints.up(key)] = style;
32
+ }
33
+ }, breakpointValue);
34
+ }
35
+ }
36
+ });
37
+ } else if (typeof responsive === 'number' || typeof responsive === 'string') {
38
+ iterator((responsiveStyles, style) => {
39
+ Object.assign(responsiveStyles, style);
40
+ }, responsive);
41
+ }
42
+ };