@mui/system 5.8.0 → 5.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +203 -6
  3. package/Container/Container.d.ts +13 -13
  4. package/Container/ContainerProps.d.ts +40 -40
  5. package/Container/containerClasses.d.ts +22 -22
  6. package/Container/createContainer.d.ts +18 -18
  7. package/createBox.spec.d.ts +1 -1
  8. package/createTheme/createSpacing.d.ts +10 -10
  9. package/cssVars/createCssVarsProvider.d.ts +15 -15
  10. package/cssVars/createCssVarsProvider.js +23 -9
  11. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  12. package/cssVars/createGetCssVar.d.ts +5 -5
  13. package/cssVars/cssVarsParser.d.ts +70 -70
  14. package/cssVars/getInitColorSchemeScript.d.ts +40 -40
  15. package/cssVars/getInitColorSchemeScript.js +3 -3
  16. package/cssVars/index.d.ts +2 -2
  17. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  18. package/esm/cssVars/createCssVarsProvider.js +23 -9
  19. package/esm/cssVars/getInitColorSchemeScript.js +3 -3
  20. package/esm/spacing.js +1 -1
  21. package/esm/style.js +2 -2
  22. package/index.js +1 -1
  23. package/index.spec.d.ts +1 -1
  24. package/legacy/cssVars/createCssVarsProvider.js +30 -9
  25. package/legacy/cssVars/getInitColorSchemeScript.js +3 -3
  26. package/legacy/index.js +1 -1
  27. package/legacy/spacing.js +1 -1
  28. package/legacy/style.js +3 -1
  29. package/modern/cssVars/createCssVarsProvider.js +23 -9
  30. package/modern/cssVars/getInitColorSchemeScript.js +3 -3
  31. package/modern/index.js +1 -1
  32. package/modern/spacing.js +1 -1
  33. package/modern/style.js +2 -2
  34. package/package.json +2 -2
  35. package/spacing.js +1 -1
  36. package/style.js +2 -2
  37. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -8,7 +8,7 @@ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui
8
8
  import { GlobalStyles } from '@mui/styled-engine';
9
9
  import cssVarsParser from './cssVarsParser';
10
10
  import ThemeProvider from '../ThemeProvider';
11
- import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
11
+ import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
12
12
  import useCurrentColorScheme from './useCurrentColorScheme';
13
13
  import createGetCssVar from './createGetCssVar';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,6 +17,9 @@ export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-
17
17
  export default function createCssVarsProvider(options) {
18
18
  const {
19
19
  theme: defaultTheme = {},
20
+ attribute: defaultAttribute = DEFAULT_ATTRIBUTE,
21
+ modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
22
+ colorSchemeStorageKey: defaultColorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
20
23
  defaultMode: desisgnSystemMode = 'light',
21
24
  defaultColorScheme: designSystemColorScheme,
22
25
  disableTransitionOnChange: designSystemTransitionOnChange = false,
@@ -46,9 +49,9 @@ export default function createCssVarsProvider(options) {
46
49
  children,
47
50
  theme: themeProp = defaultTheme,
48
51
  prefix = designSystemPrefix,
49
- modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
50
- colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
51
- attribute = DEFAULT_ATTRIBUTE,
52
+ modeStorageKey = defaultModeStorageKey,
53
+ colorSchemeStorageKey = defaultColorSchemeStorageKey,
54
+ attribute = defaultAttribute,
52
55
  defaultMode = desisgnSystemMode,
53
56
  defaultColorScheme = designSystemColorScheme,
54
57
  disableTransitionOnChange = designSystemTransitionOnChange,
@@ -116,9 +119,11 @@ export default function createCssVarsProvider(options) {
116
119
  colorSchemes,
117
120
  prefix,
118
121
  vars: rootVars,
119
- getCssVar: createGetCssVar(prefix)
122
+ getCssVar: createGetCssVar(prefix),
123
+ getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
120
124
  });
121
- const styleSheet = {};
125
+ const defaultColorSchemeStyleSheet = {};
126
+ const otherColorSchemesStyleSheet = {};
122
127
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
123
128
  const {
124
129
  css,
@@ -154,9 +159,9 @@ export default function createCssVarsProvider(options) {
154
159
  })();
155
160
 
156
161
  if (key === resolvedDefaultColorScheme) {
157
- styleSheet[colorSchemeSelector] = css;
162
+ defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
158
163
  } else {
159
- styleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
164
+ otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
160
165
  }
161
166
  });
162
167
  React.useEffect(() => {
@@ -223,7 +228,9 @@ export default function createCssVarsProvider(options) {
223
228
  [colorSchemeSelector]: rootCss
224
229
  }
225
230
  }), /*#__PURE__*/_jsx(GlobalStyles, {
226
- styles: styleSheet
231
+ styles: defaultColorSchemeStyleSheet
232
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
233
+ styles: otherColorSchemesStyleSheet
227
234
  }), /*#__PURE__*/_jsx(ThemeProvider, {
228
235
  theme: resolveTheme ? resolveTheme(theme) : theme,
229
236
  children: children
@@ -303,6 +310,13 @@ export default function createCssVarsProvider(options) {
303
310
  */
304
311
  theme: PropTypes.object
305
312
  } : void 0;
313
+
314
+ const getInitColorSchemeScript = params => systemGetInitColorSchemeScript(_extends({
315
+ attribute: defaultAttribute,
316
+ colorSchemeStorageKey: defaultColorSchemeStorageKey,
317
+ modeStorageKey: defaultModeStorageKey
318
+ }, params));
319
+
306
320
  return {
307
321
  CssVarsProvider,
308
322
  useColorScheme,
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export const DEFAULT_MODE_STORAGE_KEY = 'mui-mode';
4
- export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
- export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
3
+ export const DEFAULT_MODE_STORAGE_KEY = 'mode';
4
+ export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
5
+ export const DEFAULT_ATTRIBUTE = 'data-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  const {
8
8
  enableSystem = false,
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.8.0
1
+ /** @license MUI v5.8.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/modern/spacing.js CHANGED
@@ -43,7 +43,7 @@ const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTo
43
43
  const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
44
44
  const spacingKeys = [...marginKeys, ...paddingKeys];
45
45
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
46
- const themeSpacing = getPath(theme, themeKey) ?? defaultValue;
46
+ const themeSpacing = getPath(theme, themeKey, false) ?? defaultValue;
47
47
 
48
48
  if (typeof themeSpacing === 'number') {
49
49
  return abs => {
package/modern/style.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { unstable_capitalize as capitalize } from '@mui/utils';
2
2
  import responsivePropType from './responsivePropType';
3
3
  import { handleBreakpoints } from './breakpoints';
4
- export function getPath(obj, path) {
4
+ export function getPath(obj, path, checkVars = true) {
5
5
  if (!path || typeof path !== 'string') {
6
6
  return null;
7
7
  } // Check if CSS variables are used
8
8
 
9
9
 
10
- if (obj && obj.vars) {
10
+ if (obj && obj.vars && checkVars) {
11
11
  const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
12
12
 
13
13
  if (val != null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.8.0",
3
+ "version": "5.8.3",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -49,7 +49,7 @@
49
49
  "@mui/types": "^7.1.3",
50
50
  "@mui/utils": "^5.8.0",
51
51
  "clsx": "^1.1.1",
52
- "csstype": "^3.0.11",
52
+ "csstype": "^3.1.0",
53
53
  "prop-types": "^15.8.1"
54
54
  },
55
55
  "sideEffects": false,
package/spacing.js CHANGED
@@ -66,7 +66,7 @@ const spacingKeys = [...marginKeys, ...paddingKeys];
66
66
  function createUnaryUnit(theme, themeKey, defaultValue, propName) {
67
67
  var _getPath;
68
68
 
69
- const themeSpacing = (_getPath = (0, _style.getPath)(theme, themeKey)) != null ? _getPath : defaultValue;
69
+ const themeSpacing = (_getPath = (0, _style.getPath)(theme, themeKey, false)) != null ? _getPath : defaultValue;
70
70
 
71
71
  if (typeof themeSpacing === 'number') {
72
72
  return abs => {
package/style.js CHANGED
@@ -14,13 +14,13 @@ var _responsivePropType = _interopRequireDefault(require("./responsivePropType")
14
14
 
15
15
  var _breakpoints = require("./breakpoints");
16
16
 
17
- function getPath(obj, path) {
17
+ function getPath(obj, path, checkVars = true) {
18
18
  if (!path || typeof path !== 'string') {
19
19
  return null;
20
20
  } // Check if CSS variables are used
21
21
 
22
22
 
23
- if (obj && obj.vars) {
23
+ if (obj && obj.vars && checkVars) {
24
24
  const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
25
25
 
26
26
  if (val != null) {
@@ -1 +1 @@
1
- export {};
1
+ export {};