@mui/system 5.11.9 → 5.11.12

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 (64) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +279 -1
  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/Stack.js +5 -0
  9. package/Stack/StackProps.d.ts +42 -42
  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 +173 -173
  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 -33
  18. package/Unstable_Grid/index.d.ts +5 -5
  19. package/createBox.spec.d.ts +1 -1
  20. package/createTheme/createSpacing.d.ts +10 -10
  21. package/cssVars/createCssVarsProvider.d.ts +0 -8
  22. package/cssVars/createCssVarsProvider.js +8 -16
  23. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  24. package/cssVars/createCssVarsTheme.d.ts +10 -0
  25. package/cssVars/createCssVarsTheme.js +24 -0
  26. package/cssVars/createGetCssVar.d.ts +5 -5
  27. package/cssVars/createGetCssVar.js +1 -1
  28. package/cssVars/cssVarsParser.d.ts +64 -63
  29. package/cssVars/cssVarsParser.js +4 -1
  30. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  31. package/cssVars/index.d.ts +5 -3
  32. package/cssVars/index.js +15 -1
  33. package/cssVars/prepareCssVars.d.ts +11 -0
  34. package/cssVars/prepareCssVars.js +70 -0
  35. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  36. package/esm/Stack/Stack.js +5 -0
  37. package/esm/cssVars/createCssVarsProvider.js +8 -16
  38. package/esm/cssVars/createCssVarsTheme.js +16 -0
  39. package/esm/cssVars/createGetCssVar.js +1 -1
  40. package/esm/cssVars/cssVarsParser.js +4 -1
  41. package/esm/cssVars/index.js +3 -1
  42. package/esm/cssVars/prepareCssVars.js +62 -0
  43. package/esm/index.js +3 -0
  44. package/index.d.ts +3 -0
  45. package/index.js +25 -1
  46. package/index.spec.d.ts +1 -1
  47. package/legacy/Stack/Stack.js +5 -0
  48. package/legacy/cssVars/createCssVarsProvider.js +15 -21
  49. package/legacy/cssVars/createCssVarsTheme.js +13 -0
  50. package/legacy/cssVars/createGetCssVar.js +1 -1
  51. package/legacy/cssVars/cssVarsParser.js +4 -1
  52. package/legacy/cssVars/index.js +3 -1
  53. package/legacy/cssVars/prepareCssVars.js +59 -0
  54. package/legacy/index.js +4 -1
  55. package/modern/Stack/Stack.js +5 -0
  56. package/modern/cssVars/createCssVarsProvider.js +8 -16
  57. package/modern/cssVars/createCssVarsTheme.js +16 -0
  58. package/modern/cssVars/createGetCssVar.js +1 -1
  59. package/modern/cssVars/cssVarsParser.js +4 -1
  60. package/modern/cssVars/index.js +3 -1
  61. package/modern/cssVars/prepareCssVars.js +62 -0
  62. package/modern/index.js +4 -1
  63. package/package.json +5 -5
  64. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -1,13 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
4
- const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
4
+ const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { deepmerge } from '@mui/utils';
8
8
  import { GlobalStyles } from '@mui/styled-engine';
9
9
  import { useTheme as muiUseTheme } from '@mui/private-theming';
10
- import cssVarsParser from './cssVarsParser';
11
10
  import ThemeProvider from '../ThemeProvider';
12
11
  import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
13
12
  import useCurrentColorScheme from './useCurrentColorScheme';
@@ -23,7 +22,6 @@ export default function createCssVarsProvider(options) {
23
22
  defaultMode: designSystemMode = 'light',
24
23
  defaultColorScheme: designSystemColorScheme,
25
24
  disableTransitionOnChange: designSystemTransitionOnChange = false,
26
- shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
27
25
  resolveTheme,
28
26
  excludeVariablesFromRoot
29
27
  } = options;
@@ -51,7 +49,6 @@ export default function createCssVarsProvider(options) {
51
49
  documentNode = typeof document === 'undefined' ? undefined : document,
52
50
  colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
53
51
  colorSchemeSelector = ':root',
54
- shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar,
55
52
  disableNestedContext = false,
56
53
  disableStyleSheetGeneration = false
57
54
  }) {
@@ -62,6 +59,10 @@ export default function createCssVarsProvider(options) {
62
59
  const {
63
60
  colorSchemes = {},
64
61
  components = {},
62
+ generateCssVars = () => ({
63
+ vars: {},
64
+ css: {}
65
+ }),
65
66
  cssVarPrefix
66
67
  } = themeProp,
67
68
  restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
@@ -119,10 +120,7 @@ export default function createCssVarsProvider(options) {
119
120
  const {
120
121
  css: rootCss,
121
122
  vars: rootVars
122
- } = cssVarsParser(restThemeProp, {
123
- prefix: cssVarPrefix,
124
- shouldSkipGeneratingVar
125
- });
123
+ } = generateCssVars();
126
124
 
127
125
  // 3. Start composing the theme object
128
126
  const theme = _extends({}, restThemeProp, {
@@ -142,10 +140,7 @@ export default function createCssVarsProvider(options) {
142
140
  const {
143
141
  css,
144
142
  vars
145
- } = cssVarsParser(scheme, {
146
- prefix: cssVarPrefix,
147
- shouldSkipGeneratingVar
148
- });
143
+ } = generateCssVars(key);
149
144
  theme.vars = deepmerge(theme.vars, vars);
150
145
  if (key === calculatedColorScheme) {
151
146
  // 4.1 Merge the selected color scheme to the theme
@@ -184,6 +179,7 @@ export default function createCssVarsProvider(options) {
184
179
  otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
185
180
  }
186
181
  });
182
+ theme.vars = deepmerge(theme.vars, rootVars);
187
183
 
188
184
  // 5. Declaring effects
189
185
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -308,10 +304,6 @@ export default function createCssVarsProvider(options) {
308
304
  * The key in the local storage used to store current color scheme.
309
305
  */
310
306
  modeStorageKey: PropTypes.string,
311
- /**
312
- * A function to determine if the key, value should be attached as CSS Variable
313
- */
314
- shouldSkipGeneratingVar: PropTypes.func,
315
307
  /**
316
308
  * The window that attaches the 'storage' event listener
317
309
  * @default window
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["cssVarPrefix", "shouldSkipGeneratingVar"];
4
+ import prepareCssVars from './prepareCssVars';
5
+ function createCssVarsTheme(theme) {
6
+ const {
7
+ cssVarPrefix,
8
+ shouldSkipGeneratingVar
9
+ } = theme,
10
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
11
+ return _extends({}, theme, prepareCssVars(otherTheme, {
12
+ prefix: cssVarPrefix,
13
+ shouldSkipGeneratingVar
14
+ }));
15
+ }
16
+ export default createCssVarsTheme;
@@ -8,7 +8,7 @@ export default function createGetCssVar(prefix = '') {
8
8
  return '';
9
9
  }
10
10
  const value = vars[0];
11
- if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
11
+ if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)) {
12
12
  return `, var(--${prefix ? `${prefix}-` : ''}${value}${appendVar(...vars.slice(1))})`;
13
13
  }
14
14
  return `, ${value}`;
@@ -105,6 +105,7 @@ export default function cssVarsParser(theme, options) {
105
105
  } = options || {};
106
106
  const css = {};
107
107
  const vars = {};
108
+ const varsWithDefaults = {};
108
109
  walkObjectDeep(theme, (keys, value, arrayKeys) => {
109
110
  if (typeof value === 'string' || typeof value === 'number') {
110
111
  if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
@@ -114,6 +115,7 @@ export default function cssVarsParser(theme, options) {
114
115
  [cssVar]: getCssValue(keys, value)
115
116
  });
116
117
  assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
118
+ assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${value})`, arrayKeys);
117
119
  }
118
120
  }
119
121
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
@@ -121,6 +123,7 @@ export default function cssVarsParser(theme, options) {
121
123
 
122
124
  return {
123
125
  css,
124
- vars
126
+ vars,
127
+ varsWithDefaults
125
128
  };
126
129
  }
@@ -1,2 +1,4 @@
1
1
  export { default } from './createCssVarsProvider';
2
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
2
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
3
+ export { default as prepareCssVars } from './prepareCssVars';
4
+ export { default as createCssVarsTheme } from './createCssVarsTheme';
@@ -0,0 +1,62 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ const _excluded = ["colorSchemes", "components"],
3
+ _excluded2 = ["light"];
4
+ import { deepmerge } from '@mui/utils';
5
+ import cssVarsParser from './cssVarsParser';
6
+ function prepareCssVars(theme, parserConfig) {
7
+ // @ts-ignore - ignore components do not exist
8
+ const {
9
+ colorSchemes = {}
10
+ } = theme,
11
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
12
+ const {
13
+ vars: rootVars,
14
+ css: rootCss,
15
+ varsWithDefaults: rootVarsWithDefaults
16
+ } = cssVarsParser(otherTheme, parserConfig);
17
+ let themeVars = rootVarsWithDefaults;
18
+ const colorSchemesMap = {};
19
+ const {
20
+ light
21
+ } = colorSchemes,
22
+ otherColorSchemes = _objectWithoutPropertiesLoose(colorSchemes, _excluded2);
23
+ Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
24
+ const {
25
+ vars,
26
+ css,
27
+ varsWithDefaults
28
+ } = cssVarsParser(scheme, parserConfig);
29
+ themeVars = deepmerge(themeVars, varsWithDefaults);
30
+ colorSchemesMap[key] = {
31
+ css,
32
+ vars
33
+ };
34
+ });
35
+ if (light) {
36
+ // light color scheme vars should be merged last to set as default
37
+ const {
38
+ css,
39
+ vars,
40
+ varsWithDefaults
41
+ } = cssVarsParser(light, parserConfig);
42
+ themeVars = deepmerge(themeVars, varsWithDefaults);
43
+ colorSchemesMap.light = {
44
+ css,
45
+ vars
46
+ };
47
+ }
48
+ const generateCssVars = colorScheme => {
49
+ if (!colorScheme) {
50
+ return {
51
+ css: rootCss,
52
+ vars: rootVars
53
+ };
54
+ }
55
+ return colorSchemesMap[colorScheme];
56
+ };
57
+ return {
58
+ vars: themeVars,
59
+ generateCssVars
60
+ };
61
+ }
62
+ export default prepareCssVars;
package/esm/index.js CHANGED
@@ -45,6 +45,9 @@ export * from './colorManipulator';
45
45
  export { default as ThemeProvider } from './ThemeProvider';
46
46
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
47
47
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
48
+ export { default as unstable_cssVarsParser } from './cssVars/cssVarsParser';
49
+ export { default as unstable_prepareCssVars } from './cssVars/prepareCssVars';
50
+ export { default as unstable_createCssVarsTheme } from './cssVars/createCssVarsTheme';
48
51
  export { default as responsivePropType } from './responsivePropType';
49
52
 
50
53
  /** ----------------- */
package/index.d.ts CHANGED
@@ -166,6 +166,9 @@ export * from './ThemeProvider';
166
166
 
167
167
  export { default as unstable_createCssVarsProvider, CreateCssVarsProviderResult } from './cssVars';
168
168
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
169
+ export { default as unstable_cssVarsParser } from './cssVars/cssVarsParser';
170
+ export { default as unstable_prepareCssVars } from './cssVars/prepareCssVars';
171
+ export { default as unstable_createCssVarsTheme } from './cssVars/createCssVarsTheme';
169
172
  export * from './cssVars';
170
173
 
171
174
  export { default as responsivePropType } from './responsivePropType';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.11.9
2
+ * @mui/system v5.11.12
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -55,6 +55,9 @@ var _exportNames = {
55
55
  ThemeProvider: true,
56
56
  unstable_createCssVarsProvider: true,
57
57
  unstable_createGetCssVar: true,
58
+ unstable_cssVarsParser: true,
59
+ unstable_prepareCssVars: true,
60
+ unstable_createCssVarsTheme: true,
58
61
  responsivePropType: true,
59
62
  createContainer: true,
60
63
  Container: true,
@@ -284,6 +287,12 @@ Object.defineProperty(exports, "unstable_createCssVarsProvider", {
284
287
  return _createCssVarsProvider.default;
285
288
  }
286
289
  });
290
+ Object.defineProperty(exports, "unstable_createCssVarsTheme", {
291
+ enumerable: true,
292
+ get: function () {
293
+ return _createCssVarsTheme.default;
294
+ }
295
+ });
287
296
  Object.defineProperty(exports, "unstable_createGetCssVar", {
288
297
  enumerable: true,
289
298
  get: function () {
@@ -296,6 +305,12 @@ Object.defineProperty(exports, "unstable_createStyleFunctionSx", {
296
305
  return _styleFunctionSx.unstable_createStyleFunctionSx;
297
306
  }
298
307
  });
308
+ Object.defineProperty(exports, "unstable_cssVarsParser", {
309
+ enumerable: true,
310
+ get: function () {
311
+ return _cssVarsParser.default;
312
+ }
313
+ });
299
314
  Object.defineProperty(exports, "unstable_defaultSxConfig", {
300
315
  enumerable: true,
301
316
  get: function () {
@@ -314,6 +329,12 @@ Object.defineProperty(exports, "unstable_getThemeValue", {
314
329
  return _getThemeValue.default;
315
330
  }
316
331
  });
332
+ Object.defineProperty(exports, "unstable_prepareCssVars", {
333
+ enumerable: true,
334
+ get: function () {
335
+ return _prepareCssVars.default;
336
+ }
337
+ });
317
338
  Object.defineProperty(exports, "unstable_resolveBreakpointValues", {
318
339
  enumerable: true,
319
340
  get: function () {
@@ -486,6 +507,9 @@ Object.keys(_colorManipulator).forEach(function (key) {
486
507
  var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
487
508
  var _createCssVarsProvider = _interopRequireDefault(require("./cssVars/createCssVarsProvider"));
488
509
  var _createGetCssVar = _interopRequireDefault(require("./cssVars/createGetCssVar"));
510
+ var _cssVarsParser = _interopRequireDefault(require("./cssVars/cssVarsParser"));
511
+ var _prepareCssVars = _interopRequireDefault(require("./cssVars/prepareCssVars"));
512
+ var _createCssVarsTheme = _interopRequireDefault(require("./cssVars/createCssVarsTheme"));
489
513
  var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
490
514
  var _createContainer = _interopRequireDefault(require("./Container/createContainer"));
491
515
  var _Container = _interopRequireWildcard(require("./Container"));
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -21,6 +21,11 @@ process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ =
21
21
  * The content of the component.
22
22
  */
23
23
  children: PropTypes.node,
24
+ /**
25
+ * The component used for the root node.
26
+ * Either a string to use a HTML element or a component.
27
+ */
28
+ component: PropTypes.elementType,
24
29
  /**
25
30
  * Defines the `flex-direction` style property.
26
31
  * It is applied for all screen sizes.
@@ -9,7 +9,6 @@ import PropTypes from 'prop-types';
9
9
  import { deepmerge } from '@mui/utils';
10
10
  import { GlobalStyles } from '@mui/styled-engine';
11
11
  import { useTheme as muiUseTheme } from '@mui/private-theming';
12
- import cssVarsParser from './cssVarsParser';
13
12
  import ThemeProvider from '../ThemeProvider';
14
13
  import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
15
14
  import useCurrentColorScheme from './useCurrentColorScheme';
@@ -30,7 +29,6 @@ export default function createCssVarsProvider(options) {
30
29
  designSystemColorScheme = options.defaultColorScheme,
31
30
  _options$disableTrans = options.disableTransitionOnChange,
32
31
  designSystemTransitionOnChange = _options$disableTrans === void 0 ? false : _options$disableTrans,
33
- designSystemShouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
34
32
  resolveTheme = options.resolveTheme,
35
33
  excludeVariablesFromRoot = options.excludeVariablesFromRoot;
36
34
  if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
@@ -68,8 +66,6 @@ export default function createCssVarsProvider(options) {
68
66
  colorSchemeNode = _ref$colorSchemeNode === void 0 ? typeof document === 'undefined' ? undefined : document.documentElement : _ref$colorSchemeNode,
69
67
  _ref$colorSchemeSelec = _ref.colorSchemeSelector,
70
68
  colorSchemeSelector = _ref$colorSchemeSelec === void 0 ? ':root' : _ref$colorSchemeSelec,
71
- _ref$shouldSkipGenera = _ref.shouldSkipGeneratingVar,
72
- shouldSkipGeneratingVar = _ref$shouldSkipGenera === void 0 ? designSystemShouldSkipGeneratingVar : _ref$shouldSkipGenera,
73
69
  _ref$disableNestedCon = _ref.disableNestedContext,
74
70
  disableNestedContext = _ref$disableNestedCon === void 0 ? false : _ref$disableNestedCon,
75
71
  _ref$disableStyleShee = _ref.disableStyleSheetGeneration,
@@ -82,8 +78,15 @@ export default function createCssVarsProvider(options) {
82
78
  colorSchemes = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
83
79
  _themeProp$components = themeProp.components,
84
80
  components = _themeProp$components === void 0 ? {} : _themeProp$components,
81
+ _themeProp$generateCs = themeProp.generateCssVars,
82
+ generateCssVars = _themeProp$generateCs === void 0 ? function () {
83
+ return {
84
+ vars: {},
85
+ css: {}
86
+ };
87
+ } : _themeProp$generateCs,
85
88
  cssVarPrefix = themeProp.cssVarPrefix,
86
- restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components", "cssVarPrefix"]);
89
+ restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"]);
87
90
  var allColorSchemes = Object.keys(colorSchemes);
88
91
  var defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
89
92
  var defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -134,12 +137,9 @@ export default function createCssVarsProvider(options) {
134
137
  }();
135
138
 
136
139
  // 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
137
- var _cssVarsParser = cssVarsParser(restThemeProp, {
138
- prefix: cssVarPrefix,
139
- shouldSkipGeneratingVar: shouldSkipGeneratingVar
140
- }),
141
- rootCss = _cssVarsParser.css,
142
- rootVars = _cssVarsParser.vars; // 3. Start composing the theme object
140
+ var _generateCssVars = generateCssVars(),
141
+ rootCss = _generateCssVars.css,
142
+ rootVars = _generateCssVars.vars; // 3. Start composing the theme object
143
143
  var theme = _extends({}, restThemeProp, {
144
144
  components: components,
145
145
  colorSchemes: colorSchemes,
@@ -159,12 +159,9 @@ export default function createCssVarsProvider(options) {
159
159
  var _ref3 = _slicedToArray(_ref2, 2),
160
160
  key = _ref3[0],
161
161
  scheme = _ref3[1];
162
- var _cssVarsParser2 = cssVarsParser(scheme, {
163
- prefix: cssVarPrefix,
164
- shouldSkipGeneratingVar: shouldSkipGeneratingVar
165
- }),
166
- css = _cssVarsParser2.css,
167
- vars = _cssVarsParser2.vars;
162
+ var _generateCssVars2 = generateCssVars(key),
163
+ css = _generateCssVars2.css,
164
+ vars = _generateCssVars2.vars;
168
165
  theme.vars = deepmerge(theme.vars, vars);
169
166
  if (key === calculatedColorScheme) {
170
167
  // 4.1 Merge the selected color scheme to the theme
@@ -203,6 +200,7 @@ export default function createCssVarsProvider(options) {
203
200
  otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
204
201
  }
205
202
  });
203
+ theme.vars = deepmerge(theme.vars, rootVars);
206
204
 
207
205
  // 5. Declaring effects
208
206
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -329,10 +327,6 @@ export default function createCssVarsProvider(options) {
329
327
  * The key in the local storage used to store current color scheme.
330
328
  */
331
329
  modeStorageKey: PropTypes.string,
332
- /**
333
- * A function to determine if the key, value should be attached as CSS Variable
334
- */
335
- shouldSkipGeneratingVar: PropTypes.func,
336
330
  /**
337
331
  * The window that attaches the 'storage' event listener
338
332
  * @default window
@@ -0,0 +1,13 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import prepareCssVars from './prepareCssVars';
4
+ function createCssVarsTheme(theme) {
5
+ var cssVarPrefix = theme.cssVarPrefix,
6
+ shouldSkipGeneratingVar = theme.shouldSkipGeneratingVar,
7
+ otherTheme = _objectWithoutProperties(theme, ["cssVarPrefix", "shouldSkipGeneratingVar"]);
8
+ return _extends({}, theme, prepareCssVars(otherTheme, {
9
+ prefix: cssVarPrefix,
10
+ shouldSkipGeneratingVar: shouldSkipGeneratingVar
11
+ }));
12
+ }
13
+ export default createCssVarsTheme;
@@ -13,7 +13,7 @@ export default function createGetCssVar() {
13
13
  return '';
14
14
  }
15
15
  var value = vars[0];
16
- if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
16
+ if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)) {
17
17
  return ", var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(value).concat(appendVar.apply(void 0, _toConsumableArray(vars.slice(1))), ")");
18
18
  }
19
19
  return ", ".concat(value);
@@ -117,6 +117,7 @@ export default function cssVarsParser(theme, options) {
117
117
  shouldSkipGeneratingVar = _ref3.shouldSkipGeneratingVar;
118
118
  var css = {};
119
119
  var vars = {};
120
+ var varsWithDefaults = {};
120
121
  walkObjectDeep(theme, function (keys, value, arrayKeys) {
121
122
  if (typeof value === 'string' || typeof value === 'number') {
122
123
  if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
@@ -124,6 +125,7 @@ export default function cssVarsParser(theme, options) {
124
125
  var cssVar = "--".concat(prefix ? "".concat(prefix, "-") : '').concat(keys.join('-'));
125
126
  _extends(css, _defineProperty({}, cssVar, getCssValue(keys, value)));
126
127
  assignNestedKeys(vars, keys, "var(".concat(cssVar, ")"), arrayKeys);
128
+ assignNestedKeys(varsWithDefaults, keys, "var(".concat(cssVar, ", ").concat(value, ")"), arrayKeys);
127
129
  }
128
130
  }
129
131
  }, function (keys) {
@@ -133,6 +135,7 @@ export default function cssVarsParser(theme, options) {
133
135
 
134
136
  return {
135
137
  css: css,
136
- vars: vars
138
+ vars: vars,
139
+ varsWithDefaults: varsWithDefaults
137
140
  };
138
141
  }
@@ -1,2 +1,4 @@
1
1
  export { default } from './createCssVarsProvider';
2
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
2
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
3
+ export { default as prepareCssVars } from './prepareCssVars';
4
+ export { default as createCssVarsTheme } from './createCssVarsTheme';
@@ -0,0 +1,59 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import { deepmerge } from '@mui/utils';
4
+ import cssVarsParser from './cssVarsParser';
5
+ function prepareCssVars(theme, parserConfig) {
6
+ // @ts-ignore - ignore components do not exist
7
+ var _theme$colorSchemes = theme.colorSchemes,
8
+ colorSchemes = _theme$colorSchemes === void 0 ? {} : _theme$colorSchemes,
9
+ components = theme.components,
10
+ otherTheme = _objectWithoutProperties(theme, ["colorSchemes", "components"]);
11
+ var _cssVarsParser = cssVarsParser(otherTheme, parserConfig),
12
+ rootVars = _cssVarsParser.vars,
13
+ rootCss = _cssVarsParser.css,
14
+ rootVarsWithDefaults = _cssVarsParser.varsWithDefaults;
15
+ var themeVars = rootVarsWithDefaults;
16
+ var colorSchemesMap = {};
17
+ var light = colorSchemes.light,
18
+ otherColorSchemes = _objectWithoutProperties(colorSchemes, ["light"]);
19
+ Object.entries(otherColorSchemes || {}).forEach(function (_ref) {
20
+ var _ref2 = _slicedToArray(_ref, 2),
21
+ key = _ref2[0],
22
+ scheme = _ref2[1];
23
+ var _cssVarsParser2 = cssVarsParser(scheme, parserConfig),
24
+ vars = _cssVarsParser2.vars,
25
+ css = _cssVarsParser2.css,
26
+ varsWithDefaults = _cssVarsParser2.varsWithDefaults;
27
+ themeVars = deepmerge(themeVars, varsWithDefaults);
28
+ colorSchemesMap[key] = {
29
+ css: css,
30
+ vars: vars
31
+ };
32
+ });
33
+ if (light) {
34
+ // light color scheme vars should be merged last to set as default
35
+ var _cssVarsParser3 = cssVarsParser(light, parserConfig),
36
+ css = _cssVarsParser3.css,
37
+ vars = _cssVarsParser3.vars,
38
+ varsWithDefaults = _cssVarsParser3.varsWithDefaults;
39
+ themeVars = deepmerge(themeVars, varsWithDefaults);
40
+ colorSchemesMap.light = {
41
+ css: css,
42
+ vars: vars
43
+ };
44
+ }
45
+ var generateCssVars = function generateCssVars(colorScheme) {
46
+ if (!colorScheme) {
47
+ return {
48
+ css: rootCss,
49
+ vars: rootVars
50
+ };
51
+ }
52
+ return colorSchemesMap[colorScheme];
53
+ };
54
+ return {
55
+ vars: themeVars,
56
+ generateCssVars: generateCssVars
57
+ };
58
+ }
59
+ export default prepareCssVars;
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.11.9
2
+ * @mui/system v5.11.12
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,6 +52,9 @@ export * from './colorManipulator';
52
52
  export { default as ThemeProvider } from './ThemeProvider';
53
53
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
54
54
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
55
+ export { default as unstable_cssVarsParser } from './cssVars/cssVarsParser';
56
+ export { default as unstable_prepareCssVars } from './cssVars/prepareCssVars';
57
+ export { default as unstable_createCssVarsTheme } from './cssVars/createCssVarsTheme';
55
58
  export { default as responsivePropType } from './responsivePropType';
56
59
 
57
60
  /** ----------------- */
@@ -21,6 +21,11 @@ process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ =
21
21
  * The content of the component.
22
22
  */
23
23
  children: PropTypes.node,
24
+ /**
25
+ * The component used for the root node.
26
+ * Either a string to use a HTML element or a component.
27
+ */
28
+ component: PropTypes.elementType,
24
29
  /**
25
30
  * Defines the `flex-direction` style property.
26
31
  * It is applied for all screen sizes.
@@ -1,13 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
4
- const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
4
+ const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { deepmerge } from '@mui/utils';
8
8
  import { GlobalStyles } from '@mui/styled-engine';
9
9
  import { useTheme as muiUseTheme } from '@mui/private-theming';
10
- import cssVarsParser from './cssVarsParser';
11
10
  import ThemeProvider from '../ThemeProvider';
12
11
  import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
13
12
  import useCurrentColorScheme from './useCurrentColorScheme';
@@ -23,7 +22,6 @@ export default function createCssVarsProvider(options) {
23
22
  defaultMode: designSystemMode = 'light',
24
23
  defaultColorScheme: designSystemColorScheme,
25
24
  disableTransitionOnChange: designSystemTransitionOnChange = false,
26
- shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
27
25
  resolveTheme,
28
26
  excludeVariablesFromRoot
29
27
  } = options;
@@ -51,7 +49,6 @@ export default function createCssVarsProvider(options) {
51
49
  documentNode = typeof document === 'undefined' ? undefined : document,
52
50
  colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
53
51
  colorSchemeSelector = ':root',
54
- shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar,
55
52
  disableNestedContext = false,
56
53
  disableStyleSheetGeneration = false
57
54
  }) {
@@ -62,6 +59,10 @@ export default function createCssVarsProvider(options) {
62
59
  const {
63
60
  colorSchemes = {},
64
61
  components = {},
62
+ generateCssVars = () => ({
63
+ vars: {},
64
+ css: {}
65
+ }),
65
66
  cssVarPrefix
66
67
  } = themeProp,
67
68
  restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
@@ -119,10 +120,7 @@ export default function createCssVarsProvider(options) {
119
120
  const {
120
121
  css: rootCss,
121
122
  vars: rootVars
122
- } = cssVarsParser(restThemeProp, {
123
- prefix: cssVarPrefix,
124
- shouldSkipGeneratingVar
125
- });
123
+ } = generateCssVars();
126
124
 
127
125
  // 3. Start composing the theme object
128
126
  const theme = _extends({}, restThemeProp, {
@@ -142,10 +140,7 @@ export default function createCssVarsProvider(options) {
142
140
  const {
143
141
  css,
144
142
  vars
145
- } = cssVarsParser(scheme, {
146
- prefix: cssVarPrefix,
147
- shouldSkipGeneratingVar
148
- });
143
+ } = generateCssVars(key);
149
144
  theme.vars = deepmerge(theme.vars, vars);
150
145
  if (key === calculatedColorScheme) {
151
146
  // 4.1 Merge the selected color scheme to the theme
@@ -184,6 +179,7 @@ export default function createCssVarsProvider(options) {
184
179
  otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
185
180
  }
186
181
  });
182
+ theme.vars = deepmerge(theme.vars, rootVars);
187
183
 
188
184
  // 5. Declaring effects
189
185
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -308,10 +304,6 @@ export default function createCssVarsProvider(options) {
308
304
  * The key in the local storage used to store current color scheme.
309
305
  */
310
306
  modeStorageKey: PropTypes.string,
311
- /**
312
- * A function to determine if the key, value should be attached as CSS Variable
313
- */
314
- shouldSkipGeneratingVar: PropTypes.func,
315
307
  /**
316
308
  * The window that attaches the 'storage' event listener
317
309
  * @default window
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["cssVarPrefix", "shouldSkipGeneratingVar"];
4
+ import prepareCssVars from './prepareCssVars';
5
+ function createCssVarsTheme(theme) {
6
+ const {
7
+ cssVarPrefix,
8
+ shouldSkipGeneratingVar
9
+ } = theme,
10
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
11
+ return _extends({}, theme, prepareCssVars(otherTheme, {
12
+ prefix: cssVarPrefix,
13
+ shouldSkipGeneratingVar
14
+ }));
15
+ }
16
+ export default createCssVarsTheme;
@@ -8,7 +8,7 @@ export default function createGetCssVar(prefix = '') {
8
8
  return '';
9
9
  }
10
10
  const value = vars[0];
11
- if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
11
+ if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)) {
12
12
  return `, var(--${prefix ? `${prefix}-` : ''}${value}${appendVar(...vars.slice(1))})`;
13
13
  }
14
14
  return `, ${value}`;