@mui/system 5.12.3 → 5.13.1

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 (93) hide show
  1. package/CHANGELOG.md +124 -0
  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/Container/createContainer.js +41 -35
  7. package/GlobalStyles/GlobalStyles.d.ts +13 -13
  8. package/GlobalStyles/index.d.ts +2 -2
  9. package/Stack/Stack.d.ts +14 -14
  10. package/Stack/StackProps.d.ts +53 -53
  11. package/Stack/createStack.d.ts +21 -21
  12. package/Stack/createStack.js +24 -26
  13. package/Stack/index.d.ts +5 -5
  14. package/Stack/stackClasses.d.ts +8 -8
  15. package/ThemeProvider/ThemeProvider.js +9 -5
  16. package/Unstable_Grid/Grid.d.ts +12 -12
  17. package/Unstable_Grid/GridProps.d.ts +185 -185
  18. package/Unstable_Grid/createGrid.d.ts +11 -11
  19. package/Unstable_Grid/createGrid.js +21 -23
  20. package/Unstable_Grid/gridClasses.d.ts +20 -20
  21. package/Unstable_Grid/gridGenerator.d.ts +38 -38
  22. package/Unstable_Grid/gridGenerator.js +20 -18
  23. package/Unstable_Grid/index.d.ts +5 -5
  24. package/breakpoints.js +7 -6
  25. package/createBox.js +9 -12
  26. package/createStyled.js +40 -32
  27. package/createTheme/createBreakpoints.js +24 -26
  28. package/createTheme/createSpacing.d.ts +10 -10
  29. package/createTheme/createTheme.js +18 -14
  30. package/cssVars/createCssVarsProvider.js +21 -20
  31. package/cssVars/createCssVarsTheme.d.ts +15 -15
  32. package/cssVars/createCssVarsTheme.js +10 -10
  33. package/cssVars/createGetCssVar.d.ts +5 -5
  34. package/cssVars/cssVarsParser.d.ts +64 -64
  35. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  36. package/cssVars/index.d.ts +5 -5
  37. package/cssVars/prepareCssVars.d.ts +16 -16
  38. package/cssVars/prepareCssVars.js +13 -12
  39. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  40. package/cssVars/useCurrentColorScheme.js +17 -11
  41. package/esm/Container/createContainer.js +41 -35
  42. package/esm/Stack/createStack.js +24 -26
  43. package/esm/ThemeProvider/ThemeProvider.js +9 -5
  44. package/esm/Unstable_Grid/createGrid.js +21 -23
  45. package/esm/Unstable_Grid/gridGenerator.js +20 -17
  46. package/esm/breakpoints.js +7 -6
  47. package/esm/createBox.js +9 -12
  48. package/esm/createStyled.js +38 -31
  49. package/esm/createTheme/createBreakpoints.js +24 -25
  50. package/esm/createTheme/createTheme.js +18 -14
  51. package/esm/cssVars/createCssVarsProvider.js +21 -20
  52. package/esm/cssVars/createCssVarsTheme.js +10 -10
  53. package/esm/cssVars/prepareCssVars.js +13 -12
  54. package/esm/cssVars/useCurrentColorScheme.js +17 -10
  55. package/esm/propsToClassKey.js +3 -5
  56. package/esm/styleFunctionSx/extendSxProp.js +14 -10
  57. package/index.js +1 -1
  58. package/legacy/Container/createContainer.js +7 -6
  59. package/legacy/Stack/createStack.js +6 -5
  60. package/legacy/ThemeProvider/ThemeProvider.js +4 -3
  61. package/legacy/Unstable_Grid/createGrid.js +6 -4
  62. package/legacy/Unstable_Grid/gridGenerator.js +6 -4
  63. package/legacy/breakpoints.js +5 -3
  64. package/legacy/createBox.js +4 -2
  65. package/legacy/createStyled.js +13 -11
  66. package/legacy/createTheme/createBreakpoints.js +4 -3
  67. package/legacy/createTheme/createTheme.js +6 -4
  68. package/legacy/cssVars/createCssVarsProvider.js +6 -5
  69. package/legacy/cssVars/createCssVarsTheme.js +4 -2
  70. package/legacy/cssVars/prepareCssVars.js +5 -3
  71. package/legacy/cssVars/useCurrentColorScheme.js +9 -7
  72. package/legacy/index.js +1 -1
  73. package/legacy/styleFunctionSx/extendSxProp.js +6 -4
  74. package/modern/Container/createContainer.js +41 -35
  75. package/modern/Stack/createStack.js +24 -26
  76. package/modern/ThemeProvider/ThemeProvider.js +9 -5
  77. package/modern/Unstable_Grid/createGrid.js +21 -23
  78. package/modern/Unstable_Grid/gridGenerator.js +20 -17
  79. package/modern/breakpoints.js +7 -6
  80. package/modern/createBox.js +9 -12
  81. package/modern/createStyled.js +38 -31
  82. package/modern/createTheme/createBreakpoints.js +24 -25
  83. package/modern/createTheme/createTheme.js +18 -14
  84. package/modern/cssVars/createCssVarsProvider.js +21 -20
  85. package/modern/cssVars/createCssVarsTheme.js +10 -10
  86. package/modern/cssVars/prepareCssVars.js +13 -12
  87. package/modern/cssVars/useCurrentColorScheme.js +17 -10
  88. package/modern/index.js +1 -1
  89. package/modern/propsToClassKey.js +3 -5
  90. package/modern/styleFunctionSx/extendSxProp.js +14 -10
  91. package/package.json +3 -3
  92. package/propsToClassKey.js +3 -6
  93. package/styleFunctionSx/extendSxProp.js +14 -10
@@ -5,23 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
8
  var _utils = require("@mui/utils");
11
9
  var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
12
10
  var _shape = _interopRequireDefault(require("./shape"));
13
11
  var _createSpacing = _interopRequireDefault(require("./createSpacing"));
14
12
  var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx/styleFunctionSx"));
15
13
  var _defaultSxConfig = _interopRequireDefault(require("../styleFunctionSx/defaultSxConfig"));
16
- const _excluded = ["breakpoints", "palette", "spacing", "shape"];
17
14
  function createTheme(options = {}, ...args) {
18
15
  const {
19
- breakpoints: breakpointsInput = {},
20
- palette: paletteInput = {},
21
- spacing: spacingInput,
22
- shape: shapeInput = {}
23
- } = options,
24
- other = (0, _objectWithoutPropertiesLoose2.default)(options, _excluded);
16
+ breakpoints: breakpointsInput = {},
17
+ palette: paletteInput = {},
18
+ spacing: spacingInput,
19
+ shape: shapeInput = {},
20
+ ...other
21
+ } = options;
25
22
  const breakpoints = (0, _createBreakpoints.default)(breakpointsInput);
26
23
  const spacing = (0, _createSpacing.default)(spacingInput);
27
24
  let muiTheme = (0, _utils.deepmerge)({
@@ -29,14 +26,21 @@ function createTheme(options = {}, ...args) {
29
26
  direction: 'ltr',
30
27
  components: {},
31
28
  // Inject component definitions.
32
- palette: (0, _extends2.default)({
33
- mode: 'light'
34
- }, paletteInput),
29
+ palette: {
30
+ mode: 'light',
31
+ ...paletteInput
32
+ },
35
33
  spacing,
36
- shape: (0, _extends2.default)({}, _shape.default, shapeInput)
34
+ shape: {
35
+ ..._shape.default,
36
+ ...shapeInput
37
+ }
37
38
  }, other);
38
39
  muiTheme = args.reduce((acc, argument) => (0, _utils.deepmerge)(acc, argument), muiTheme);
39
- muiTheme.unstable_sxConfig = (0, _extends2.default)({}, _defaultSxConfig.default, other == null ? void 0 : other.unstable_sxConfig);
40
+ muiTheme.unstable_sxConfig = {
41
+ ..._defaultSxConfig.default,
42
+ ...(other == null ? void 0 : other.unstable_sxConfig)
43
+ };
40
44
  muiTheme.unstable_sx = function sx(props) {
41
45
  return (0, _styleFunctionSx.default)({
42
46
  sx: props,
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.DISABLE_CSS_TRANSITION = void 0;
8
8
  exports.default = createCssVarsProvider;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
9
  var _utils = require("@mui/utils");
12
10
  var React = _interopRequireWildcard(require("react"));
13
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -17,7 +15,6 @@ var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
17
15
  var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorSchemeScript"));
18
16
  var _useCurrentColorScheme = _interopRequireDefault(require("./useCurrentColorScheme"));
19
17
  var _jsxRuntime = require("react/jsx-runtime");
20
- const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
21
18
  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); }
22
19
  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; }
23
20
  const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
@@ -67,17 +64,16 @@ function createCssVarsProvider(options) {
67
64
  const ctx = React.useContext(ColorSchemeContext);
68
65
  const nested = !!ctx && !disableNestedContext;
69
66
  const scopedTheme = themeProp[themeId];
70
- const _ref = scopedTheme || themeProp,
71
- {
72
- colorSchemes = {},
73
- components = {},
74
- generateCssVars = () => ({
75
- vars: {},
76
- css: {}
77
- }),
78
- cssVarPrefix
79
- } = _ref,
80
- restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
67
+ const {
68
+ colorSchemes = {},
69
+ components = {},
70
+ generateCssVars = () => ({
71
+ vars: {},
72
+ css: {}
73
+ }),
74
+ cssVarPrefix,
75
+ ...restThemeProp
76
+ } = scopedTheme || themeProp;
81
77
  const allColorSchemes = Object.keys(colorSchemes);
82
78
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
83
79
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -135,13 +131,14 @@ function createCssVarsProvider(options) {
135
131
  } = generateCssVars();
136
132
 
137
133
  // 3. Start composing the theme object
138
- const theme = (0, _extends2.default)({}, restThemeProp, {
134
+ const theme = {
135
+ ...restThemeProp,
139
136
  components,
140
137
  colorSchemes,
141
138
  cssVarPrefix,
142
139
  vars: rootVars,
143
140
  getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
144
- });
141
+ };
145
142
 
146
143
  // 4. Create color CSS variables and store them in objects (to be generated in stylesheets in the final step)
147
144
  // The default color scheme stylesheet is constructed to have the least CSS specificity.
@@ -159,7 +156,10 @@ function createCssVarsProvider(options) {
159
156
  Object.keys(scheme).forEach(schemeKey => {
160
157
  if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
161
158
  // shallow merge the 1st level structure of the theme.
162
- theme[schemeKey] = (0, _extends2.default)({}, theme[schemeKey], scheme[schemeKey]);
159
+ theme[schemeKey] = {
160
+ ...theme[schemeKey],
161
+ ...scheme[schemeKey]
162
+ };
163
163
  } else {
164
164
  theme[schemeKey] = scheme[schemeKey];
165
165
  }
@@ -329,14 +329,15 @@ function createCssVarsProvider(options) {
329
329
  } : void 0;
330
330
  const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
331
331
  const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
332
- const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)((0, _extends2.default)({
332
+ const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)({
333
333
  attribute: defaultAttribute,
334
334
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
335
335
  defaultMode: designSystemMode,
336
336
  defaultLightColorScheme,
337
337
  defaultDarkColorScheme,
338
- modeStorageKey: defaultModeStorageKey
339
- }, params));
338
+ modeStorageKey: defaultModeStorageKey,
339
+ ...params
340
+ });
340
341
  return {
341
342
  CssVarsProvider,
342
343
  useColorScheme,
@@ -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;
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
8
  var _prepareCssVars = _interopRequireDefault(require("./prepareCssVars"));
11
- const _excluded = ["cssVarPrefix", "shouldSkipGeneratingVar"];
12
9
  function createCssVarsTheme(theme) {
13
10
  const {
14
- cssVarPrefix,
11
+ cssVarPrefix,
12
+ shouldSkipGeneratingVar,
13
+ ...otherTheme
14
+ } = theme;
15
+ return {
16
+ ...theme,
17
+ ...(0, _prepareCssVars.default)(otherTheme, {
18
+ prefix: cssVarPrefix,
15
19
  shouldSkipGeneratingVar
16
- } = theme,
17
- otherTheme = (0, _objectWithoutPropertiesLoose2.default)(theme, _excluded);
18
- return (0, _extends2.default)({}, theme, (0, _prepareCssVars.default)(otherTheme, {
19
- prefix: cssVarPrefix,
20
- shouldSkipGeneratingVar
21
- }));
20
+ })
21
+ };
22
22
  }
23
23
  var _default = createCssVarsTheme;
24
24
  exports.default = _default;
@@ -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
- /// <reference types="react" />
2
- export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
3
- export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
4
- export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
5
- export interface GetInitColorSchemeScriptOptions {
6
- /**
7
- * The mode to be used for the first visit
8
- * @default 'light'
9
- */
10
- defaultMode?: 'light' | 'dark' | 'system';
11
- /**
12
- * The default color scheme to be used on the light mode
13
- * @default 'light'
14
- */
15
- defaultLightColorScheme?: string;
16
- /**
17
- * The default color scheme to be used on the dark mode
18
- * * @default 'dark'
19
- */
20
- defaultDarkColorScheme?: string;
21
- /**
22
- * The node (provided as string) used to attach the color-scheme attribute
23
- * @default 'document.documentElement'
24
- */
25
- colorSchemeNode?: string;
26
- /**
27
- * localStorage key used to store `mode`
28
- * @default 'mode'
29
- */
30
- modeStorageKey?: string;
31
- /**
32
- * localStorage key used to store `colorScheme`
33
- * @default 'color-scheme'
34
- */
35
- colorSchemeStorageKey?: string;
36
- /**
37
- * DOM attribute for applying color scheme
38
- * @default 'data-color-scheme'
39
- */
40
- attribute?: string;
41
- }
42
- export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
3
+ export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
4
+ export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
5
+ export interface GetInitColorSchemeScriptOptions {
6
+ /**
7
+ * The mode to be used for the first visit
8
+ * @default 'light'
9
+ */
10
+ defaultMode?: 'light' | 'dark' | 'system';
11
+ /**
12
+ * The default color scheme to be used on the light mode
13
+ * @default 'light'
14
+ */
15
+ defaultLightColorScheme?: string;
16
+ /**
17
+ * The default color scheme to be used on the dark mode
18
+ * * @default 'dark'
19
+ */
20
+ defaultDarkColorScheme?: string;
21
+ /**
22
+ * The node (provided as string) used to attach the color-scheme attribute
23
+ * @default 'document.documentElement'
24
+ */
25
+ colorSchemeNode?: string;
26
+ /**
27
+ * localStorage key used to store `mode`
28
+ * @default 'mode'
29
+ */
30
+ modeStorageKey?: string;
31
+ /**
32
+ * localStorage key used to store `colorScheme`
33
+ * @default 'color-scheme'
34
+ */
35
+ colorSchemeStorageKey?: string;
36
+ /**
37
+ * DOM attribute for applying color scheme
38
+ * @default 'data-color-scheme'
39
+ */
40
+ attribute?: string;
41
+ }
42
+ export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
@@ -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;
@@ -5,18 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
8
  var _utils = require("@mui/utils");
11
9
  var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
12
- const _excluded = ["colorSchemes", "components"],
13
- _excluded2 = ["light"];
14
10
  function prepareCssVars(theme, parserConfig) {
15
11
  // @ts-ignore - ignore components do not exist
16
12
  const {
17
- colorSchemes = {}
18
- } = theme,
19
- otherTheme = (0, _objectWithoutPropertiesLoose2.default)(theme, _excluded);
13
+ colorSchemes = {},
14
+ components,
15
+ ...otherTheme
16
+ } = theme;
20
17
  const {
21
18
  vars: rootVars,
22
19
  css: rootCss,
@@ -25,9 +22,9 @@ function prepareCssVars(theme, parserConfig) {
25
22
  let themeVars = rootVarsWithDefaults;
26
23
  const colorSchemesMap = {};
27
24
  const {
28
- light
29
- } = colorSchemes,
30
- otherColorSchemes = (0, _objectWithoutPropertiesLoose2.default)(colorSchemes, _excluded2);
25
+ light,
26
+ ...otherColorSchemes
27
+ } = colorSchemes;
31
28
  Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
32
29
  const {
33
30
  vars,
@@ -56,12 +53,16 @@ function prepareCssVars(theme, parserConfig) {
56
53
  const generateCssVars = colorScheme => {
57
54
  if (!colorScheme) {
58
55
  return {
59
- css: (0, _extends2.default)({}, rootCss),
56
+ css: {
57
+ ...rootCss
58
+ },
60
59
  vars: rootVars
61
60
  };
62
61
  }
63
62
  return {
64
- css: (0, _extends2.default)({}, colorSchemesMap[colorScheme].css),
63
+ css: {
64
+ ...colorSchemesMap[colorScheme].css
65
+ },
65
66
  vars: colorSchemesMap[colorScheme].vars
66
67
  };
67
68
  };
@@ -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 {};