@mui/system 5.6.4 → 5.8.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 (67) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +241 -0
  3. package/Container/Container.d.ts +13 -0
  4. package/Container/Container.js +81 -0
  5. package/Container/ContainerProps.d.ts +40 -0
  6. package/Container/ContainerProps.js +5 -0
  7. package/Container/containerClasses.d.ts +22 -0
  8. package/Container/containerClasses.js +17 -0
  9. package/Container/createContainer.d.ts +18 -0
  10. package/Container/createContainer.js +172 -0
  11. package/Container/index.d.ts +5 -0
  12. package/Container/index.js +42 -0
  13. package/Container/package.json +6 -0
  14. package/ThemeProvider/ThemeProvider.d.ts +1 -1
  15. package/createBox.spec.d.ts +1 -1
  16. package/createTheme/createBreakpoints.d.ts +5 -0
  17. package/createTheme/createSpacing.d.ts +10 -10
  18. package/cssVars/createCssVarsProvider.d.ts +25 -0
  19. package/cssVars/createCssVarsProvider.js +59 -23
  20. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  21. package/cssVars/createGetCssVar.d.ts +5 -5
  22. package/cssVars/cssVarsParser.d.ts +70 -70
  23. package/cssVars/getInitColorSchemeScript.d.ts +40 -12
  24. package/cssVars/getInitColorSchemeScript.js +4 -3
  25. package/cssVars/index.d.ts +2 -2
  26. package/cssVars/useCurrentColorScheme.d.ts +53 -50
  27. package/cssVars/useCurrentColorScheme.js +17 -7
  28. package/esm/Container/Container.js +70 -0
  29. package/esm/Container/ContainerProps.js +1 -0
  30. package/esm/Container/containerClasses.js +6 -0
  31. package/esm/Container/createContainer.js +151 -0
  32. package/esm/Container/index.js +3 -0
  33. package/esm/cssVars/createCssVarsProvider.js +60 -24
  34. package/esm/cssVars/getInitColorSchemeScript.js +4 -3
  35. package/esm/cssVars/useCurrentColorScheme.js +17 -7
  36. package/esm/index.js +4 -1
  37. package/esm/spacing.js +1 -1
  38. package/esm/style.js +2 -2
  39. package/index.d.ts +6 -0
  40. package/index.js +32 -2
  41. package/index.spec.d.ts +1 -1
  42. package/legacy/Container/Container.js +70 -0
  43. package/legacy/Container/ContainerProps.js +1 -0
  44. package/legacy/Container/containerClasses.js +6 -0
  45. package/legacy/Container/createContainer.js +148 -0
  46. package/legacy/Container/index.js +3 -0
  47. package/legacy/cssVars/createCssVarsProvider.js +66 -26
  48. package/legacy/cssVars/getInitColorSchemeScript.js +6 -3
  49. package/legacy/cssVars/useCurrentColorScheme.js +20 -9
  50. package/legacy/index.js +5 -2
  51. package/legacy/spacing.js +1 -1
  52. package/legacy/style.js +3 -1
  53. package/modern/Container/Container.js +70 -0
  54. package/modern/Container/ContainerProps.js +1 -0
  55. package/modern/Container/containerClasses.js +6 -0
  56. package/modern/Container/createContainer.js +151 -0
  57. package/modern/Container/index.js +3 -0
  58. package/modern/cssVars/createCssVarsProvider.js +60 -24
  59. package/modern/cssVars/getInitColorSchemeScript.js +4 -3
  60. package/modern/cssVars/useCurrentColorScheme.js +17 -7
  61. package/modern/index.js +5 -2
  62. package/modern/spacing.js +1 -1
  63. package/modern/style.js +2 -2
  64. package/package.json +5 -5
  65. package/spacing.js +1 -1
  66. package/style.js +2 -2
  67. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.4
1
+ /** @license MUI v5.8.1
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.
@@ -51,7 +51,9 @@ var _exportNames = {
51
51
  useThemeWithoutDefault: true,
52
52
  ThemeProvider: true,
53
53
  unstable_createCssVarsProvider: true,
54
- unstable_createGetCssVar: true
54
+ unstable_createGetCssVar: true,
55
+ createContainer: true,
56
+ Container: true
55
57
  };
56
58
  Object.defineProperty(exports, "Box", {
57
59
  enumerable: true,
@@ -59,6 +61,12 @@ Object.defineProperty(exports, "Box", {
59
61
  return _Box.default;
60
62
  }
61
63
  });
64
+ Object.defineProperty(exports, "Container", {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _Container.default;
68
+ }
69
+ });
62
70
  Object.defineProperty(exports, "GlobalStyles", {
63
71
  enumerable: true,
64
72
  get: function () {
@@ -107,6 +115,12 @@ Object.defineProperty(exports, "createBreakpoints", {
107
115
  return _createBreakpoints.default;
108
116
  }
109
117
  });
118
+ Object.defineProperty(exports, "createContainer", {
119
+ enumerable: true,
120
+ get: function () {
121
+ return _createContainer.default;
122
+ }
123
+ });
110
124
  Object.defineProperty(exports, "createSpacing", {
111
125
  enumerable: true,
112
126
  get: function () {
@@ -484,6 +498,22 @@ var _createCssVarsProvider = _interopRequireDefault(require("./cssVars/createCss
484
498
 
485
499
  var _createGetCssVar = _interopRequireDefault(require("./cssVars/createGetCssVar"));
486
500
 
501
+ var _createContainer = _interopRequireDefault(require("./Container/createContainer"));
502
+
503
+ var _Container = _interopRequireWildcard(require("./Container"));
504
+
505
+ Object.keys(_Container).forEach(function (key) {
506
+ if (key === "default" || key === "__esModule") return;
507
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
508
+ if (key in exports && exports[key] === _Container[key]) return;
509
+ Object.defineProperty(exports, key, {
510
+ enumerable: true,
511
+ get: function () {
512
+ return _Container[key];
513
+ }
514
+ });
515
+ });
516
+
487
517
  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); }
488
518
 
489
519
  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; }
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -0,0 +1,70 @@
1
+ import PropTypes from 'prop-types';
2
+ import createContainer from './createContainer';
3
+ /**
4
+ *
5
+ * Demos:
6
+ *
7
+ * - [Container (Material UI)](https://mui.com/material-ui/react-container/)
8
+ * - [Container (MUI System)](https://mui.com/system/react-container/)
9
+ *
10
+ * API:
11
+ *
12
+ * - [Container API](https://mui.com/system/api/container/)
13
+ */
14
+
15
+ var Container = createContainer();
16
+ process.env.NODE_ENV !== "production" ? Container.propTypes
17
+ /* remove-proptypes */
18
+ = {
19
+ // ----------------------------- Warning --------------------------------
20
+ // | These PropTypes are generated from the TypeScript type definitions |
21
+ // | To update them edit TypeScript types and run "yarn proptypes" |
22
+ // ----------------------------------------------------------------------
23
+
24
+ /**
25
+ * @ignore
26
+ */
27
+ children: PropTypes.node,
28
+
29
+ /**
30
+ * Override or extend the styles applied to the component.
31
+ */
32
+ classes: PropTypes.object,
33
+
34
+ /**
35
+ * The component used for the root node.
36
+ * Either a string to use a HTML element or a component.
37
+ */
38
+ component: PropTypes.elementType,
39
+
40
+ /**
41
+ * If `true`, the left and right padding is removed.
42
+ * @default false
43
+ */
44
+ disableGutters: PropTypes.bool,
45
+
46
+ /**
47
+ * Set the max-width to match the min-width of the current breakpoint.
48
+ * This is useful if you'd prefer to design for a fixed set of sizes
49
+ * instead of trying to accommodate a fully fluid viewport.
50
+ * It's fluid by default.
51
+ * @default false
52
+ */
53
+ fixed: PropTypes.bool,
54
+
55
+ /**
56
+ * Determine the max-width of the container.
57
+ * The container width grows with the size of the screen.
58
+ * Set to `false` to disable `maxWidth`.
59
+ * @default 'lg'
60
+ */
61
+ maxWidth: PropTypes
62
+ /* @typescript-to-proptypes-ignore */
63
+ .oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
64
+
65
+ /**
66
+ * The system prop that allows defining system overrides as well as additional CSS styles.
67
+ */
68
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
69
+ } : void 0;
70
+ export default Container;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
+ export function getContainerUtilityClass(slot) {
3
+ return generateUtilityClass('MuiContainer', slot);
4
+ }
5
+ var containerClasses = generateUtilityClasses('MuiContainer', ['root', 'disableGutters', 'fixed', 'maxWidthXs', 'maxWidthSm', 'maxWidthMd', 'maxWidthLg', 'maxWidthXl']);
6
+ export default containerClasses;
@@ -0,0 +1,148 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import clsx from 'clsx';
7
+ import { unstable_capitalize as capitalize, unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
8
+ import useThemePropsSystem from '../useThemeProps';
9
+ import systemStyled from '../styled';
10
+ import createTheme from '../createTheme';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ var defaultTheme = createTheme();
13
+ var defaultCreateStyledComponent = systemStyled('div', {
14
+ name: 'MuiContainer',
15
+ slot: 'Root',
16
+ overridesResolver: function overridesResolver(props, styles) {
17
+ var ownerState = props.ownerState;
18
+ return [styles.root, styles["maxWidth".concat(capitalize(String(ownerState.maxWidth)))], ownerState.fixed && styles.fixed, ownerState.disableGutters && styles.disableGutters];
19
+ }
20
+ });
21
+
22
+ var useThemePropsDefault = function useThemePropsDefault(inProps) {
23
+ return useThemePropsSystem({
24
+ props: inProps,
25
+ name: 'MuiContainer',
26
+ defaultTheme: defaultTheme
27
+ });
28
+ };
29
+
30
+ var useUtilityClasses = function useUtilityClasses(ownerState, componentName) {
31
+ var getContainerUtilityClass = function getContainerUtilityClass(slot) {
32
+ return generateUtilityClass(componentName, slot);
33
+ };
34
+
35
+ var classes = ownerState.classes,
36
+ fixed = ownerState.fixed,
37
+ disableGutters = ownerState.disableGutters,
38
+ maxWidth = ownerState.maxWidth;
39
+ var slots = {
40
+ root: ['root', maxWidth && "maxWidth".concat(capitalize(String(maxWidth))), fixed && 'fixed', disableGutters && 'disableGutters']
41
+ };
42
+ return composeClasses(slots, getContainerUtilityClass, classes);
43
+ };
44
+
45
+ export default function createContainer() {
46
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
47
+ var _options$createStyled = options.createStyledComponent,
48
+ createStyledComponent = _options$createStyled === void 0 ? defaultCreateStyledComponent : _options$createStyled,
49
+ _options$useThemeProp = options.useThemeProps,
50
+ useThemeProps = _options$useThemeProp === void 0 ? useThemePropsDefault : _options$useThemeProp,
51
+ _options$componentNam = options.componentName,
52
+ componentName = _options$componentNam === void 0 ? 'MuiContainer' : _options$componentNam;
53
+ var ContainerRoot = createStyledComponent(function (_ref) {
54
+ var theme = _ref.theme,
55
+ ownerState = _ref.ownerState;
56
+ return _extends({
57
+ width: '100%',
58
+ marginLeft: 'auto',
59
+ boxSizing: 'border-box',
60
+ marginRight: 'auto',
61
+ display: 'block'
62
+ }, !ownerState.disableGutters && _defineProperty({
63
+ paddingLeft: theme.spacing(2),
64
+ paddingRight: theme.spacing(2)
65
+ }, theme.breakpoints.up('sm'), {
66
+ paddingLeft: theme.spacing(3),
67
+ paddingRight: theme.spacing(3)
68
+ }));
69
+ }, function (_ref3) {
70
+ var theme = _ref3.theme,
71
+ ownerState = _ref3.ownerState;
72
+ return ownerState.fixed && Object.keys(theme.breakpoints.values).reduce(function (acc, breakpointValueKey) {
73
+ var breakpoint = breakpointValueKey;
74
+ var value = theme.breakpoints.values[breakpoint];
75
+
76
+ if (value !== 0) {
77
+ // @ts-ignore
78
+ acc[theme.breakpoints.up(breakpoint)] = {
79
+ maxWidth: "".concat(value).concat(theme.breakpoints.unit)
80
+ };
81
+ }
82
+
83
+ return acc;
84
+ }, {});
85
+ }, function (_ref4) {
86
+ var theme = _ref4.theme,
87
+ ownerState = _ref4.ownerState;
88
+ return _extends({}, ownerState.maxWidth === 'xs' && _defineProperty({}, theme.breakpoints.up('xs'), {
89
+ // @ts-ignore module augmentation fails if custom breakpoints are used
90
+ maxWidth: Math.max(theme.breakpoints.values.xs, 444)
91
+ }), ownerState.maxWidth && // @ts-ignore module augmentation fails if custom breakpoints are used
92
+ ownerState.maxWidth !== 'xs' && _defineProperty({}, theme.breakpoints.up(ownerState.maxWidth), {
93
+ // @ts-ignore module augmentation fails if custom breakpoints are used
94
+ maxWidth: "".concat(theme.breakpoints.values[ownerState.maxWidth]).concat(theme.breakpoints.unit)
95
+ }));
96
+ });
97
+ var Container = /*#__PURE__*/React.forwardRef(function Container(inProps, ref) {
98
+ var props = useThemeProps(inProps);
99
+
100
+ var className = props.className,
101
+ _props$component = props.component,
102
+ component = _props$component === void 0 ? 'div' : _props$component,
103
+ _props$disableGutters = props.disableGutters,
104
+ disableGutters = _props$disableGutters === void 0 ? false : _props$disableGutters,
105
+ _props$fixed = props.fixed,
106
+ fixed = _props$fixed === void 0 ? false : _props$fixed,
107
+ _props$maxWidth = props.maxWidth,
108
+ maxWidth = _props$maxWidth === void 0 ? 'lg' : _props$maxWidth,
109
+ classesProp = props.classes,
110
+ other = _objectWithoutProperties(props, ["className", "component", "disableGutters", "fixed", "maxWidth", "classes"]);
111
+
112
+ var ownerState = _extends({}, props, {
113
+ component: component,
114
+ disableGutters: disableGutters,
115
+ fixed: fixed,
116
+ maxWidth: maxWidth
117
+ }); // @ts-ignore module augmentation fails if custom breakpoints are used
118
+
119
+
120
+ var classes = useUtilityClasses(ownerState, componentName);
121
+ return (
122
+ /*#__PURE__*/
123
+ // @ts-ignore theme is injected by the styled util
124
+ _jsx(ContainerRoot, _extends({
125
+ as: component // @ts-ignore module augmentation fails if custom breakpoints are used
126
+ ,
127
+ ownerState: ownerState,
128
+ className: clsx(classes.root, className),
129
+ ref: ref
130
+ }, other))
131
+ );
132
+ });
133
+ process.env.NODE_ENV !== "production" ? Container.propTypes
134
+ /* remove-proptypes */
135
+ = {
136
+ children: PropTypes.node,
137
+ classes: PropTypes.object,
138
+ className: PropTypes.string,
139
+ component: PropTypes.elementType,
140
+ disableGutters: PropTypes.bool,
141
+ fixed: PropTypes.bool,
142
+ maxWidth: PropTypes
143
+ /* @typescript-to-proptypes-ignore */
144
+ .oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
145
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
146
+ } : void 0;
147
+ return Container;
148
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './Container';
2
+ export { default as containerClasses } from './containerClasses';
3
+ export * from './containerClasses';
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
@@ -9,7 +10,7 @@ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui
9
10
  import { GlobalStyles } from '@mui/styled-engine';
10
11
  import cssVarsParser from './cssVarsParser';
11
12
  import ThemeProvider from '../ThemeProvider';
12
- import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
13
+ import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
13
14
  import useCurrentColorScheme from './useCurrentColorScheme';
14
15
  import createGetCssVar from './createGetCssVar';
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -54,6 +55,8 @@ export default function createCssVarsProvider(options) {
54
55
  prefix = _ref$prefix === void 0 ? designSystemPrefix : _ref$prefix,
55
56
  _ref$modeStorageKey = _ref.modeStorageKey,
56
57
  modeStorageKey = _ref$modeStorageKey === void 0 ? DEFAULT_MODE_STORAGE_KEY : _ref$modeStorageKey,
58
+ _ref$colorSchemeStora = _ref.colorSchemeStorageKey,
59
+ colorSchemeStorageKey = _ref$colorSchemeStora === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _ref$colorSchemeStora,
57
60
  _ref$attribute = _ref.attribute,
58
61
  attribute = _ref$attribute === void 0 ? DEFAULT_ATTRIBUTE : _ref$attribute,
59
62
  _ref$defaultMode = _ref.defaultMode,
@@ -63,7 +66,15 @@ export default function createCssVarsProvider(options) {
63
66
  _ref$disableTransitio = _ref.disableTransitionOnChange,
64
67
  disableTransitionOnChange = _ref$disableTransitio === void 0 ? designSystemTransitionOnChange : _ref$disableTransitio,
65
68
  _ref$enableColorSchem = _ref.enableColorScheme,
66
- enableColorScheme = _ref$enableColorSchem === void 0 ? designSystemEnableColorScheme : _ref$enableColorSchem;
69
+ enableColorScheme = _ref$enableColorSchem === void 0 ? designSystemEnableColorScheme : _ref$enableColorSchem,
70
+ _ref$storageWindow = _ref.storageWindow,
71
+ storageWindow = _ref$storageWindow === void 0 ? typeof window === 'undefined' ? undefined : window : _ref$storageWindow,
72
+ _ref$documentNode = _ref.documentNode,
73
+ documentNode = _ref$documentNode === void 0 ? typeof document === 'undefined' ? undefined : document : _ref$documentNode,
74
+ _ref$colorSchemeNode = _ref.colorSchemeNode,
75
+ colorSchemeNode = _ref$colorSchemeNode === void 0 ? typeof document === 'undefined' ? undefined : document.documentElement : _ref$colorSchemeNode,
76
+ _ref$colorSchemeSelec = _ref.colorSchemeSelector,
77
+ colorSchemeSelector = _ref$colorSchemeSelec === void 0 ? ':root' : _ref$colorSchemeSelec;
67
78
  var hasMounted = React.useRef(false);
68
79
 
69
80
  var _themeProp$colorSchem = themeProp.colorSchemes,
@@ -81,7 +92,9 @@ export default function createCssVarsProvider(options) {
81
92
  defaultLightColorScheme: defaultLightColorScheme,
82
93
  defaultDarkColorScheme: defaultDarkColorScheme,
83
94
  modeStorageKey: modeStorageKey,
84
- defaultMode: defaultMode
95
+ colorSchemeStorageKey: colorSchemeStorageKey,
96
+ defaultMode: defaultMode,
97
+ storageWindow: storageWindow
85
98
  }),
86
99
  mode = _useCurrentColorSchem.mode,
87
100
  setMode = _useCurrentColorSchem.setMode,
@@ -123,7 +136,8 @@ export default function createCssVarsProvider(options) {
123
136
  vars: rootVars,
124
137
  getCssVar: createGetCssVar(prefix)
125
138
  });
126
- var styleSheet = {};
139
+ var defaultColorSchemeStyleSheet = {};
140
+ var otherColorSchemesStyleSheet = {};
127
141
  Object.entries(colorSchemes).forEach(function (_ref2) {
128
142
  var _ref3 = _slicedToArray(_ref2, 2),
129
143
  key = _ref3[0],
@@ -163,56 +177,56 @@ export default function createCssVarsProvider(options) {
163
177
  }();
164
178
 
165
179
  if (key === resolvedDefaultColorScheme) {
166
- styleSheet[':root'] = css;
180
+ defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
167
181
  } else {
168
- styleSheet["[".concat(attribute, "=\"").concat(key, "\"]")] = css;
182
+ otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
169
183
  }
170
184
  });
171
185
  React.useEffect(function () {
172
- if (colorScheme) {
186
+ if (colorScheme && colorSchemeNode) {
173
187
  // attaches attribute to <html> because the css variables are attached to :root (html)
174
- document.documentElement.setAttribute(attribute, colorScheme);
188
+ colorSchemeNode.setAttribute(attribute, colorScheme);
175
189
  }
176
- }, [colorScheme, attribute]);
190
+ }, [colorScheme, attribute, colorSchemeNode]);
177
191
  useEnhancedEffect(function () {
178
- if (!mode || !enableColorScheme) {
192
+ if (!mode || !enableColorScheme || !colorSchemeNode) {
179
193
  return undefined;
180
194
  }
181
195
 
182
- var priorColorScheme = document.documentElement.style.getPropertyValue('color-scheme'); // `color-scheme` tells browser to render built-in elements according to its value: `light` or `dark`
196
+ var priorColorScheme = colorSchemeNode.style.getPropertyValue('color-scheme'); // `color-scheme` tells browser to render built-in elements according to its value: `light` or `dark`
183
197
 
184
198
  if (mode === 'system') {
185
- document.documentElement.style.setProperty('color-scheme', systemMode);
199
+ colorSchemeNode.style.setProperty('color-scheme', systemMode);
186
200
  } else {
187
- document.documentElement.style.setProperty('color-scheme', mode);
201
+ colorSchemeNode.style.setProperty('color-scheme', mode);
188
202
  }
189
203
 
190
204
  return function () {
191
- document.documentElement.style.setProperty('color-scheme', priorColorScheme);
205
+ colorSchemeNode.style.setProperty('color-scheme', priorColorScheme);
192
206
  };
193
- }, [mode, systemMode, enableColorScheme]);
207
+ }, [mode, systemMode, enableColorScheme, colorSchemeNode]);
194
208
  React.useEffect(function () {
195
209
  var timer;
196
210
 
197
- if (disableTransitionOnChange && hasMounted.current) {
211
+ if (disableTransitionOnChange && hasMounted.current && documentNode) {
198
212
  // credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
199
- var css = document.createElement('style');
200
- css.appendChild(document.createTextNode(DISABLE_CSS_TRANSITION));
201
- document.head.appendChild(css); // Force browser repaint
213
+ var css = documentNode.createElement('style');
214
+ css.appendChild(documentNode.createTextNode(DISABLE_CSS_TRANSITION));
215
+ documentNode.head.appendChild(css); // Force browser repaint
202
216
 
203
217
  (function () {
204
- return window.getComputedStyle(document.body);
218
+ return window.getComputedStyle(documentNode.body);
205
219
  })();
206
220
 
207
221
  timer = setTimeout(function () {
208
- document.head.removeChild(css);
222
+ documentNode.head.removeChild(css);
209
223
  }, 1);
210
224
  }
211
225
 
212
226
  return function () {
213
227
  clearTimeout(timer);
214
228
  };
215
- }, [colorScheme, disableTransitionOnChange]);
229
+ }, [colorScheme, disableTransitionOnChange, documentNode]);
216
230
  React.useEffect(function () {
217
231
  hasMounted.current = true;
218
232
  return function () {
@@ -230,11 +244,11 @@ export default function createCssVarsProvider(options) {
230
244
  allColorSchemes: allColorSchemes
231
245
  },
232
246
  children: [/*#__PURE__*/_jsx(GlobalStyles, {
233
- styles: {
234
- ':root': rootCss
235
- }
247
+ styles: _defineProperty({}, colorSchemeSelector, rootCss)
248
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
249
+ styles: defaultColorSchemeStyleSheet
236
250
  }), /*#__PURE__*/_jsx(GlobalStyles, {
237
- styles: styleSheet
251
+ styles: otherColorSchemesStyleSheet
238
252
  }), /*#__PURE__*/_jsx(ThemeProvider, {
239
253
  theme: resolveTheme ? resolveTheme(theme) : theme,
240
254
  children: children
@@ -253,6 +267,21 @@ export default function createCssVarsProvider(options) {
253
267
  */
254
268
  children: PropTypes.node,
255
269
 
270
+ /**
271
+ * The node used to attach the color-scheme attribute
272
+ */
273
+ colorSchemeNode: PropTypes.any,
274
+
275
+ /**
276
+ * The CSS selector for attaching the generated custom properties
277
+ */
278
+ colorSchemeSelector: PropTypes.string,
279
+
280
+ /**
281
+ * localStorage key used to store `colorScheme`
282
+ */
283
+ colorSchemeStorageKey: PropTypes.string,
284
+
256
285
  /**
257
286
  * The initial color scheme used.
258
287
  */
@@ -268,6 +297,11 @@ export default function createCssVarsProvider(options) {
268
297
  */
269
298
  disableTransitionOnChange: PropTypes.bool,
270
299
 
300
+ /**
301
+ * The document to attach the attribute to
302
+ */
303
+ documentNode: PropTypes.any,
304
+
271
305
  /**
272
306
  * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
273
307
  */
@@ -283,6 +317,12 @@ export default function createCssVarsProvider(options) {
283
317
  */
284
318
  prefix: PropTypes.string,
285
319
 
320
+ /**
321
+ * The window that attaches the 'storage' event listener
322
+ * @default window
323
+ */
324
+ storageWindow: PropTypes.any,
325
+
286
326
  /**
287
327
  * The calculated theme object that will be passed through context.
288
328
  */
@@ -5,7 +5,8 @@ export var DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
5
  export var DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  var _ref = options || {},
8
- enableSystem = _ref.enableSystem,
8
+ _ref$enableSystem = _ref.enableSystem,
9
+ enableSystem = _ref$enableSystem === void 0 ? false : _ref$enableSystem,
9
10
  _ref$defaultLightColo = _ref.defaultLightColorScheme,
10
11
  defaultLightColorScheme = _ref$defaultLightColo === void 0 ? 'light' : _ref$defaultLightColo,
11
12
  _ref$defaultDarkColor = _ref.defaultDarkColorScheme,
@@ -15,12 +16,14 @@ export default function getInitColorSchemeScript(options) {
15
16
  _ref$colorSchemeStora = _ref.colorSchemeStorageKey,
16
17
  colorSchemeStorageKey = _ref$colorSchemeStora === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _ref$colorSchemeStora,
17
18
  _ref$attribute = _ref.attribute,
18
- attribute = _ref$attribute === void 0 ? DEFAULT_ATTRIBUTE : _ref$attribute;
19
+ attribute = _ref$attribute === void 0 ? DEFAULT_ATTRIBUTE : _ref$attribute,
20
+ _ref$colorSchemeNode = _ref.colorSchemeNode,
21
+ colorSchemeNode = _ref$colorSchemeNode === void 0 ? 'document.documentElement' : _ref$colorSchemeNode;
19
22
 
20
23
  return /*#__PURE__*/_jsx("script", {
21
24
  // eslint-disable-next-line react/no-danger
22
25
  dangerouslySetInnerHTML: {
23
- __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var colorScheme = '';\n if (mode === 'system' || (!mode && !!").concat(enableSystem, ")) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n document.documentElement.setAttribute('").concat(attribute, "', colorScheme);\n }\n } catch (e) {} })();")
26
+ __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var colorScheme = '';\n if (mode === 'system' || (!mode && !!").concat(enableSystem, ")) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n ").concat(colorSchemeNode, ".setAttribute('").concat(attribute, "', colorScheme);\n }\n } catch (e) {} })();")
24
27
  }
25
28
  });
26
29
  }
@@ -66,7 +66,9 @@ export default function useCurrentColorScheme(options) {
66
66
  _options$modeStorageK = options.modeStorageKey,
67
67
  modeStorageKey = _options$modeStorageK === void 0 ? DEFAULT_MODE_STORAGE_KEY : _options$modeStorageK,
68
68
  _options$colorSchemeS = options.colorSchemeStorageKey,
69
- colorSchemeStorageKey = _options$colorSchemeS === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _options$colorSchemeS;
69
+ colorSchemeStorageKey = _options$colorSchemeS === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _options$colorSchemeS,
70
+ _options$storageWindo = options.storageWindow,
71
+ storageWindow = _options$storageWindo === void 0 ? typeof window === 'undefined' ? undefined : window : _options$storageWindo;
70
72
  var joinedColorSchemes = supportedColorSchemes.join(',');
71
73
 
72
74
  var _React$useState = React.useState(function () {
@@ -86,6 +88,10 @@ export default function useCurrentColorScheme(options) {
86
88
  setState(function (currentState) {
87
89
  var newMode = !mode ? defaultMode : mode;
88
90
 
91
+ if (mode === currentState.mode) {
92
+ return currentState;
93
+ }
94
+
89
95
  if (typeof localStorage !== 'undefined') {
90
96
  localStorage.setItem(modeStorageKey, newMode);
91
97
  }
@@ -98,7 +104,7 @@ export default function useCurrentColorScheme(options) {
98
104
  }, [modeStorageKey, defaultMode]);
99
105
  var setColorScheme = React.useCallback(function (value) {
100
106
  if (!value || typeof value === 'string') {
101
- if (value && !supportedColorSchemes.includes(value)) {
107
+ if (value && !joinedColorSchemes.includes(value)) {
102
108
  console.error("`".concat(value, "` does not exist in `theme.colorSchemes`."));
103
109
  } else {
104
110
  setState(function (currentState) {
@@ -125,7 +131,7 @@ export default function useCurrentColorScheme(options) {
125
131
  return newState;
126
132
  });
127
133
  }
128
- } else if (value.light && !supportedColorSchemes.includes(value.light) || value.dark && !supportedColorSchemes.includes(value.dark)) {
134
+ } else if (value.light && !joinedColorSchemes.includes(value.light) || value.dark && !joinedColorSchemes.includes(value.dark)) {
129
135
  console.error("`".concat(value, "` does not exist in `theme.colorSchemes`."));
130
136
  } else {
131
137
  setState(function (currentState) {
@@ -150,7 +156,7 @@ export default function useCurrentColorScheme(options) {
150
156
  localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), value.dark);
151
157
  }
152
158
  }
153
- }, [colorSchemeStorageKey, supportedColorSchemes, defaultLightColorScheme, defaultDarkColorScheme]);
159
+ }, [joinedColorSchemes, colorSchemeStorageKey, defaultLightColorScheme, defaultDarkColorScheme]);
154
160
  var handleMediaQuery = React.useCallback(function (e) {
155
161
  if (state.mode === 'system') {
156
162
  setState(function (currentState) {
@@ -218,11 +224,16 @@ export default function useCurrentColorScheme(options) {
218
224
  }
219
225
  };
220
226
 
221
- window.addEventListener('storage', handleStorage);
222
- return function () {
223
- return window.removeEventListener('storage', handleStorage);
224
- };
225
- }, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode]);
227
+ if (storageWindow) {
228
+ // For syncing color-scheme changes between iframes
229
+ storageWindow.addEventListener('storage', handleStorage);
230
+ return function () {
231
+ return storageWindow.removeEventListener('storage', handleStorage);
232
+ };
233
+ }
234
+
235
+ return undefined;
236
+ }, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
226
237
  return _extends({}, state, {
227
238
  colorScheme: colorScheme,
228
239
  setMode: setMode,
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.4
1
+ /** @license MUI v5.8.1
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.
@@ -44,4 +44,7 @@ export { default as useThemeWithoutDefault } from './useThemeWithoutDefault';
44
44
  export * from './colorManipulator';
45
45
  export { default as ThemeProvider } from './ThemeProvider';
46
46
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
47
- export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
47
+ export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
48
+ export { default as createContainer } from './Container/createContainer';
49
+ export { default as Container } from './Container';
50
+ export * from './Container';
package/legacy/spacing.js CHANGED
@@ -52,7 +52,7 @@ var spacingKeys = [].concat(marginKeys, paddingKeys);
52
52
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
53
53
  var _getPath;
54
54
 
55
- var themeSpacing = (_getPath = getPath(theme, themeKey)) != null ? _getPath : defaultValue;
55
+ var themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
56
56
 
57
57
  if (typeof themeSpacing === 'number') {
58
58
  return function (abs) {
package/legacy/style.js CHANGED
@@ -3,12 +3,14 @@ import { unstable_capitalize as capitalize } from '@mui/utils';
3
3
  import responsivePropType from './responsivePropType';
4
4
  import { handleBreakpoints } from './breakpoints';
5
5
  export function getPath(obj, path) {
6
+ var checkVars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7
+
6
8
  if (!path || typeof path !== 'string') {
7
9
  return null;
8
10
  } // Check if CSS variables are used
9
11
 
10
12
 
11
- if (obj && obj.vars) {
13
+ if (obj && obj.vars && checkVars) {
12
14
  var val = "vars.".concat(path).split('.').reduce(function (acc, item) {
13
15
  return acc && acc[item] ? acc[item] : null;
14
16
  }, obj);