@mui/system 5.11.16 → 5.12.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 (91) hide show
  1. package/CHANGELOG.md +147 -22
  2. package/Container/Container.d.ts +13 -13
  3. package/Container/ContainerProps.d.ts +40 -40
  4. package/Container/containerClasses.d.ts +22 -22
  5. package/Container/createContainer.d.ts +18 -18
  6. package/GlobalStyles/GlobalStyles.d.ts +13 -0
  7. package/GlobalStyles/GlobalStyles.js +45 -0
  8. package/GlobalStyles/index.d.ts +2 -0
  9. package/GlobalStyles/index.js +26 -0
  10. package/GlobalStyles/package.json +6 -0
  11. package/Stack/Stack.d.ts +14 -13
  12. package/Stack/Stack.js +2 -1
  13. package/Stack/StackProps.d.ts +53 -53
  14. package/Stack/createStack.d.ts +21 -21
  15. package/Stack/index.d.ts +5 -5
  16. package/Stack/stackClasses.d.ts +8 -8
  17. package/ThemeProvider/ThemeProvider.d.ts +4 -0
  18. package/ThemeProvider/ThemeProvider.js +43 -17
  19. package/Unstable_Grid/Grid.d.ts +12 -12
  20. package/Unstable_Grid/GridProps.d.ts +185 -173
  21. package/Unstable_Grid/createGrid.d.ts +11 -11
  22. package/Unstable_Grid/createGrid.js +18 -11
  23. package/Unstable_Grid/gridClasses.d.ts +20 -20
  24. package/Unstable_Grid/gridGenerator.d.ts +38 -38
  25. package/Unstable_Grid/gridGenerator.js +12 -12
  26. package/Unstable_Grid/index.d.ts +5 -5
  27. package/createBox.d.ts +1 -0
  28. package/createBox.js +2 -1
  29. package/createStyled.d.ts +1 -0
  30. package/createStyled.js +37 -24
  31. package/createTheme/createSpacing.d.ts +10 -10
  32. package/cssVars/createCssVarsProvider.d.ts +22 -7
  33. package/cssVars/createCssVarsProvider.js +7 -3
  34. package/cssVars/createCssVarsTheme.d.ts +15 -13
  35. package/cssVars/createGetCssVar.d.ts +5 -5
  36. package/cssVars/cssVarsParser.d.ts +64 -64
  37. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  38. package/cssVars/index.d.ts +5 -5
  39. package/cssVars/prepareCssVars.d.ts +16 -14
  40. package/cssVars/prepareCssVars.js +6 -2
  41. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  42. package/esm/GlobalStyles/GlobalStyles.js +35 -0
  43. package/esm/GlobalStyles/index.js +2 -0
  44. package/esm/Stack/Stack.js +2 -1
  45. package/esm/ThemeProvider/ThemeProvider.js +44 -18
  46. package/esm/Unstable_Grid/createGrid.js +19 -12
  47. package/esm/Unstable_Grid/gridGenerator.js +12 -12
  48. package/esm/createBox.js +2 -1
  49. package/esm/createStyled.js +37 -24
  50. package/esm/cssVars/createCssVarsProvider.js +7 -3
  51. package/esm/cssVars/prepareCssVars.js +6 -2
  52. package/esm/index.js +2 -1
  53. package/esm/useThemeProps/useThemeProps.js +6 -2
  54. package/esm/useThemeWithoutDefault.js +3 -2
  55. package/index.d.ts +2 -2
  56. package/index.js +4 -3
  57. package/legacy/GlobalStyles/GlobalStyles.js +35 -0
  58. package/legacy/GlobalStyles/index.js +2 -0
  59. package/legacy/Stack/Stack.js +2 -1
  60. package/legacy/ThemeProvider/ThemeProvider.js +44 -19
  61. package/legacy/Unstable_Grid/createGrid.js +19 -11
  62. package/legacy/Unstable_Grid/gridGenerator.js +12 -12
  63. package/legacy/createBox.js +3 -2
  64. package/legacy/createStyled.js +37 -17
  65. package/legacy/cssVars/createCssVarsProvider.js +18 -14
  66. package/legacy/cssVars/prepareCssVars.js +6 -2
  67. package/legacy/index.js +3 -2
  68. package/legacy/useThemeProps/useThemeProps.js +5 -1
  69. package/legacy/useThemeWithoutDefault.js +3 -2
  70. package/modern/GlobalStyles/GlobalStyles.js +35 -0
  71. package/modern/GlobalStyles/index.js +2 -0
  72. package/modern/Stack/Stack.js +2 -1
  73. package/modern/ThemeProvider/ThemeProvider.js +44 -18
  74. package/modern/Unstable_Grid/createGrid.js +18 -12
  75. package/modern/Unstable_Grid/gridGenerator.js +12 -12
  76. package/modern/createBox.js +2 -1
  77. package/modern/createStyled.js +37 -24
  78. package/modern/cssVars/createCssVarsProvider.js +7 -3
  79. package/modern/cssVars/prepareCssVars.js +6 -2
  80. package/modern/index.js +3 -2
  81. package/modern/useThemeProps/useThemeProps.js +6 -2
  82. package/modern/useThemeWithoutDefault.js +3 -2
  83. package/package.json +5 -5
  84. package/useThemeProps/useThemeProps.d.ts +6 -1
  85. package/useThemeProps/useThemeProps.js +6 -2
  86. package/useThemeWithoutDefault.js +5 -2
  87. package/Box/Box.spec.d.ts +0 -1
  88. package/createBox.spec.d.ts +0 -1
  89. package/cssVars/createCssVarsProvider.spec.d.ts +0 -1
  90. package/index.spec.d.ts +0 -1
  91. package/styleFunctionSx/styleFunctionSx.spec.d.ts +0 -1
@@ -1,14 +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: Record<string, string | number>;
11
- vars: ThemeVars;
12
- };
13
- };
14
- 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,6 +5,7 @@ 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"));
8
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
10
  var _utils = require("@mui/utils");
10
11
  var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
@@ -55,11 +56,14 @@ function prepareCssVars(theme, parserConfig) {
55
56
  const generateCssVars = colorScheme => {
56
57
  if (!colorScheme) {
57
58
  return {
58
- css: rootCss,
59
+ css: (0, _extends2.default)({}, rootCss),
59
60
  vars: rootVars
60
61
  };
61
62
  }
62
- return colorSchemesMap[colorScheme];
63
+ return {
64
+ css: (0, _extends2.default)({}, colorSchemesMap[colorScheme].css),
65
+ vars: colorSchemesMap[colorScheme].vars
66
+ };
63
67
  };
64
68
  return {
65
69
  vars: themeVars,
@@ -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 {};
@@ -0,0 +1,35 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { GlobalStyles as MuiGlobalStyles } from '@mui/styled-engine';
4
+ import useTheme from '../useTheme';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ function GlobalStyles({
7
+ styles,
8
+ themeId,
9
+ defaultTheme = {}
10
+ }) {
11
+ const upperTheme = useTheme(defaultTheme);
12
+ const globalStyles = typeof styles === 'function' ? styles(themeId ? upperTheme[themeId] || upperTheme : upperTheme) : styles;
13
+ return /*#__PURE__*/_jsx(MuiGlobalStyles, {
14
+ styles: globalStyles
15
+ });
16
+ }
17
+ process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
18
+ // ----------------------------- Warning --------------------------------
19
+ // | These PropTypes are generated from the TypeScript type definitions |
20
+ // | To update them edit TypeScript types and run "yarn proptypes" |
21
+ // ----------------------------------------------------------------------
22
+ /**
23
+ * @ignore
24
+ */
25
+ defaultTheme: PropTypes.object,
26
+ /**
27
+ * @ignore
28
+ */
29
+ styles: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.array, PropTypes.func, PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
30
+ /**
31
+ * @ignore
32
+ */
33
+ themeId: PropTypes.string
34
+ } : void 0;
35
+ export default GlobalStyles;
@@ -0,0 +1,2 @@
1
+ export { default } from './GlobalStyles';
2
+ export * from './GlobalStyles';
@@ -4,6 +4,7 @@ import createStack from './createStack';
4
4
  *
5
5
  * Demos:
6
6
  *
7
+ * - [Stack (Joy UI)](https://mui.com/joy/react-stack/)
7
8
  * - [Stack (Material UI)](https://mui.com/material-ui/react-stack/)
8
9
  * - [Stack (MUI System)](https://mui.com/system/react-stack/)
9
10
  *
@@ -48,7 +49,7 @@ process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ =
48
49
  /**
49
50
  * If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
50
51
  *
51
- * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack#limitations),
52
+ * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
52
53
  * it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
53
54
  *
54
55
  * To enable this flag globally, follow the theme's default props configuration.
@@ -1,37 +1,59 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import PropTypes from 'prop-types';
3
- import { ThemeProvider as MuiThemeProvider } from '@mui/private-theming';
4
+ import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
4
5
  import { exactProp } from '@mui/utils';
5
6
  import { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';
6
- import useTheme from '../useTheme';
7
+ import useThemeWithoutDefault from '../useThemeWithoutDefault';
7
8
  import { jsx as _jsx } from "react/jsx-runtime";
8
9
  const EMPTY_THEME = {};
9
- function InnerThemeProvider(props) {
10
- const theme = useTheme();
11
- return /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {
12
- value: typeof theme === 'object' ? theme : EMPTY_THEME,
13
- children: props.children
14
- });
10
+ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
11
+ return React.useMemo(() => {
12
+ const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
13
+ if (typeof localTheme === 'function') {
14
+ const mergedTheme = localTheme(resolvedTheme);
15
+ const result = themeId ? _extends({}, upperTheme, {
16
+ [themeId]: mergedTheme
17
+ }) : mergedTheme;
18
+ // must return a function for the private theme to NOT merge with the upper theme.
19
+ // see the test case "use provided theme from a callback" in ThemeProvider.test.js
20
+ if (isPrivate) {
21
+ return () => result;
22
+ }
23
+ return result;
24
+ }
25
+ return themeId ? _extends({}, upperTheme, {
26
+ [themeId]: localTheme
27
+ }) : _extends({}, upperTheme, localTheme);
28
+ }, [themeId, upperTheme, localTheme, isPrivate]);
15
29
  }
16
- process.env.NODE_ENV !== "production" ? InnerThemeProvider.propTypes = {
17
- /**
18
- * Your component tree.
19
- */
20
- children: PropTypes.node
21
- } : void 0;
22
30
 
23
31
  /**
24
32
  * This component makes the `theme` available down the React tree.
25
33
  * It should preferably be used at **the root of your component tree**.
34
+ *
35
+ * <ThemeProvider theme={theme}> // existing use case
36
+ * <ThemeProvider theme={{ id: theme }}> // theme scoping
26
37
  */
27
38
  function ThemeProvider(props) {
28
39
  const {
29
40
  children,
30
- theme: localTheme
41
+ theme: localTheme,
42
+ themeId
31
43
  } = props;
44
+ const upperTheme = useThemeWithoutDefault(EMPTY_THEME);
45
+ const upperPrivateTheme = usePrivateTheme() || EMPTY_THEME;
46
+ if (process.env.NODE_ENV !== 'production') {
47
+ if (upperTheme === null && typeof localTheme === 'function' || themeId && upperTheme && !upperTheme[themeId] && typeof localTheme === 'function') {
48
+ console.error(['MUI: You are providing a theme function prop to the ThemeProvider component:', '<ThemeProvider theme={outerTheme => outerTheme} />', '', 'However, no outer theme is present.', 'Make sure a theme is already injected higher in the React tree ' + 'or provide a theme object.'].join('\n'));
49
+ }
50
+ }
51
+ const engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
52
+ const privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
32
53
  return /*#__PURE__*/_jsx(MuiThemeProvider, {
33
- theme: localTheme,
34
- children: /*#__PURE__*/_jsx(InnerThemeProvider, {
54
+ theme: privateTheme,
55
+ children: /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {
56
+ value: engineTheme,
35
57
  children: children
36
58
  })
37
59
  });
@@ -48,7 +70,11 @@ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes /* remove-propty
48
70
  /**
49
71
  * A theme object. You can provide a function to extend the outer theme.
50
72
  */
51
- theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
73
+ theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
74
+ /**
75
+ * The design system's unique id for getting the corresponded theme when there are multiple design systems.
76
+ */
77
+ themeId: PropTypes.string
52
78
  } : void 0;
53
79
  if (process.env.NODE_ENV !== 'production') {
54
80
  process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes) : void 0;
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
3
+ const _excluded = ["className", "children", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow", "unstable_level"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
- import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
7
+ import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_isMuiElement as isMuiElement } from '@mui/utils';
8
8
  import systemStyled from '../styled';
9
9
  import useThemePropsSystem from '../useThemeProps';
10
10
  import useTheme from '../useTheme';
@@ -34,7 +34,6 @@ export default function createGrid(options = {}) {
34
34
  useThemeProps = useThemePropsDefault,
35
35
  componentName = 'MuiGrid'
36
36
  } = options;
37
- const NestedContext = /*#__PURE__*/React.createContext(0);
38
37
  const OverflowContext = /*#__PURE__*/React.createContext(undefined);
39
38
  const useUtilityClasses = (ownerState, theme) => {
40
39
  const {
@@ -55,10 +54,10 @@ export default function createGrid(options = {}) {
55
54
  const theme = useTheme();
56
55
  const themeProps = useThemeProps(inProps);
57
56
  const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
58
- const level = React.useContext(NestedContext);
59
57
  const overflow = React.useContext(OverflowContext);
60
58
  const {
61
59
  className,
60
+ children,
62
61
  columns: columnsProp = 12,
63
62
  container = false,
64
63
  component = 'div',
@@ -67,7 +66,8 @@ export default function createGrid(options = {}) {
67
66
  spacing: spacingProp = 0,
68
67
  rowSpacing: rowSpacingProp = spacingProp,
69
68
  columnSpacing: columnSpacingProp = spacingProp,
70
- disableEqualOverflow: themeDisableEqualOverflow
69
+ disableEqualOverflow: themeDisableEqualOverflow,
70
+ unstable_level: level = 0
71
71
  } = props,
72
72
  rest = _objectWithoutPropertiesLoose(props, _excluded);
73
73
  // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
@@ -114,13 +114,17 @@ export default function createGrid(options = {}) {
114
114
  as: component,
115
115
  ownerState: ownerState,
116
116
  className: clsx(classes.root, className)
117
- }, other));
118
- if (container) {
119
- result = /*#__PURE__*/_jsx(NestedContext.Provider, {
120
- value: level + 1,
121
- children: result
122
- });
123
- }
117
+ }, other, {
118
+ children: React.Children.map(children, child => {
119
+ if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
120
+ var _child$props$unstable;
121
+ return /*#__PURE__*/React.cloneElement(child, {
122
+ unstable_level: (_child$props$unstable = child.props.unstable_level) != null ? _child$props$unstable : level + 1
123
+ });
124
+ }
125
+ return child;
126
+ })
127
+ }));
124
128
  if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
125
129
  // There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
126
130
  // 1. It is the root grid with `disableEqualOverflow`.
@@ -156,5 +160,8 @@ export default function createGrid(options = {}) {
156
160
  xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
157
161
  xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
158
162
  } : void 0;
163
+
164
+ // @ts-ignore internal logic for nested grid
165
+ Grid.muiName = 'Grid';
159
166
  return Grid;
160
167
  }
@@ -6,26 +6,26 @@ function appendLevel(level) {
6
6
  return `Level${level}`;
7
7
  }
8
8
  function isNestedContainer(ownerState) {
9
- return ownerState.level > 0 && ownerState.container;
9
+ return ownerState.unstable_level > 0 && ownerState.container;
10
10
  }
11
11
  function createGetSelfSpacing(ownerState) {
12
12
  return function getSelfSpacing(axis) {
13
- return `var(--Grid-${axis}Spacing${appendLevel(ownerState.level)})`;
13
+ return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level)})`;
14
14
  };
15
15
  }
16
16
  function createGetParentSpacing(ownerState) {
17
17
  return function getParentSpacing(axis) {
18
- if (ownerState.level === 0) {
18
+ if (ownerState.unstable_level === 0) {
19
19
  return `var(--Grid-${axis}Spacing)`;
20
20
  }
21
- return `var(--Grid-${axis}Spacing${appendLevel(ownerState.level - 1)})`;
21
+ return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level - 1)})`;
22
22
  };
23
23
  }
24
24
  function getParentColumns(ownerState) {
25
- if (ownerState.level === 0) {
25
+ if (ownerState.unstable_level === 0) {
26
26
  return `var(--Grid-columns)`;
27
27
  }
28
- return `var(--Grid-columns${appendLevel(ownerState.level - 1)})`;
28
+ return `var(--Grid-columns${appendLevel(ownerState.unstable_level - 1)})`;
29
29
  }
30
30
  export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
31
31
  export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
@@ -133,13 +133,13 @@ export const generateGridColumnsStyles = ({
133
133
  return {};
134
134
  }
135
135
  const styles = isNestedContainer(ownerState) ? {
136
- [`--Grid-columns${appendLevel(ownerState.level)}`]: getParentColumns(ownerState)
136
+ [`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: getParentColumns(ownerState)
137
137
  } : {
138
138
  '--Grid-columns': 12
139
139
  };
140
140
  traverseBreakpoints(theme.breakpoints, ownerState.columns, (appendStyle, value) => {
141
141
  appendStyle(styles, {
142
- [`--Grid-columns${appendLevel(ownerState.level)}`]: value
142
+ [`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: value
143
143
  });
144
144
  });
145
145
  return styles;
@@ -155,12 +155,12 @@ export const generateGridRowSpacingStyles = ({
155
155
  const styles = isNestedContainer(ownerState) ? {
156
156
  // Set the default spacing as its parent spacing.
157
157
  // It will be overridden if spacing props are provided
158
- [`--Grid-rowSpacing${appendLevel(ownerState.level)}`]: getParentSpacing('row')
158
+ [`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('row')
159
159
  } : {};
160
160
  traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
161
161
  var _theme$spacing;
162
162
  appendStyle(styles, {
163
- [`--Grid-rowSpacing${appendLevel(ownerState.level)}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
163
+ [`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
164
164
  });
165
165
  });
166
166
  return styles;
@@ -176,12 +176,12 @@ export const generateGridColumnSpacingStyles = ({
176
176
  const styles = isNestedContainer(ownerState) ? {
177
177
  // Set the default spacing as its parent spacing.
178
178
  // It will be overridden if spacing props are provided
179
- [`--Grid-columnSpacing${appendLevel(ownerState.level)}`]: getParentSpacing('column')
179
+ [`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('column')
180
180
  } : {};
181
181
  traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
182
182
  var _theme$spacing2;
183
183
  appendStyle(styles, {
184
- [`--Grid-columnSpacing${appendLevel(ownerState.level)}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
184
+ [`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
185
185
  });
186
186
  });
187
187
  return styles;
package/esm/createBox.js CHANGED
@@ -9,6 +9,7 @@ import useTheme from './useTheme';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  export default function createBox(options = {}) {
11
11
  const {
12
+ themeId,
12
13
  defaultTheme,
13
14
  defaultClassName = 'MuiBox-root',
14
15
  generateClassName
@@ -28,7 +29,7 @@ export default function createBox(options = {}) {
28
29
  as: component,
29
30
  ref: ref,
30
31
  className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
31
- theme: theme
32
+ theme: themeId ? theme[themeId] || theme : theme
32
33
  }, other));
33
34
  });
34
35
  return Box;
@@ -1,8 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"],
4
- _excluded2 = ["theme"],
5
- _excluded3 = ["theme"];
3
+ const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
6
4
  /* eslint-disable no-underscore-dangle */
7
5
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
8
6
  import { getDisplayName } from '@mui/utils';
@@ -70,16 +68,26 @@ export const systemDefaultTheme = createTheme();
70
68
  const lowercaseFirstLetter = string => {
71
69
  return string.charAt(0).toLowerCase() + string.slice(1);
72
70
  };
71
+ function resolveTheme({
72
+ defaultTheme,
73
+ theme,
74
+ themeId
75
+ }) {
76
+ return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
77
+ }
73
78
  export default function createStyled(input = {}) {
74
79
  const {
80
+ themeId,
75
81
  defaultTheme = systemDefaultTheme,
76
82
  rootShouldForwardProp = shouldForwardProp,
77
83
  slotShouldForwardProp = shouldForwardProp
78
84
  } = input;
79
85
  const systemSx = props => {
80
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
81
86
  return styleFunctionSx(_extends({}, props, {
82
- theme
87
+ theme: resolveTheme(_extends({}, props, {
88
+ defaultTheme,
89
+ themeId
90
+ }))
83
91
  }));
84
92
  };
85
93
  systemSx.__mui_systemSx = true;
@@ -123,20 +131,22 @@ export default function createStyled(input = {}) {
123
131
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
124
132
  // component stays as a function. This condition makes sure that we do not interpolate functions
125
133
  // which are basically components used as a selectors.
126
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? _ref => {
127
- let {
128
- theme: themeInput
129
- } = _ref,
130
- other = _objectWithoutPropertiesLoose(_ref, _excluded2);
131
- return stylesArg(_extends({
132
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
133
- }, other));
134
+ return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
135
+ return stylesArg(_extends({}, props, {
136
+ theme: resolveTheme(_extends({}, props, {
137
+ defaultTheme,
138
+ themeId
139
+ }))
140
+ }));
134
141
  } : stylesArg;
135
142
  }) : [];
136
143
  let transformedStyleArg = styleArg;
137
144
  if (componentName && overridesResolver) {
138
145
  expressionsWithDefaultTheme.push(props => {
139
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
146
+ const theme = resolveTheme(_extends({}, props, {
147
+ defaultTheme,
148
+ themeId
149
+ }));
140
150
  const styleOverrides = getStyleOverrides(componentName, theme);
141
151
  if (styleOverrides) {
142
152
  const resolvedStyleOverrides = {};
@@ -152,7 +162,10 @@ export default function createStyled(input = {}) {
152
162
  }
153
163
  if (componentName && !skipVariantsResolver) {
154
164
  expressionsWithDefaultTheme.push(props => {
155
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
165
+ const theme = resolveTheme(_extends({}, props, {
166
+ defaultTheme,
167
+ themeId
168
+ }));
156
169
  return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
157
170
  });
158
171
  }
@@ -171,15 +184,12 @@ export default function createStyled(input = {}) {
171
184
  // which are basically components used as a selectors.
172
185
  styleArg.__emotion_real !== styleArg) {
173
186
  // If the type is function, we need to define the default theme.
174
- transformedStyleArg = _ref2 => {
175
- let {
176
- theme: themeInput
177
- } = _ref2,
178
- other = _objectWithoutPropertiesLoose(_ref2, _excluded3);
179
- return styleArg(_extends({
180
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
181
- }, other));
182
- };
187
+ transformedStyleArg = props => styleArg(_extends({}, props, {
188
+ theme: resolveTheme(_extends({}, props, {
189
+ defaultTheme,
190
+ themeId
191
+ }))
192
+ }));
183
193
  }
184
194
  const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
185
195
  if (process.env.NODE_ENV !== 'production') {
@@ -192,6 +202,9 @@ export default function createStyled(input = {}) {
192
202
  }
193
203
  Component.displayName = displayName;
194
204
  }
205
+ if (tag.muiName) {
206
+ Component.muiName = tag.muiName;
207
+ }
195
208
  return Component;
196
209
  };
197
210
  if (defaultStyledResolver.withConfig) {
@@ -15,6 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
16
16
  export default function createCssVarsProvider(options) {
17
17
  const {
18
+ themeId,
18
19
  theme: defaultTheme = {},
19
20
  attribute: defaultAttribute = DEFAULT_ATTRIBUTE,
20
21
  modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
@@ -56,7 +57,9 @@ export default function createCssVarsProvider(options) {
56
57
  const upperTheme = muiUseTheme();
57
58
  const ctx = React.useContext(ColorSchemeContext);
58
59
  const nested = !!ctx && !disableNestedContext;
59
- const {
60
+ const scopedTheme = themeProp[themeId];
61
+ const _ref = scopedTheme || themeProp,
62
+ {
60
63
  colorSchemes = {},
61
64
  components = {},
62
65
  generateCssVars = () => ({
@@ -64,8 +67,8 @@ export default function createCssVarsProvider(options) {
64
67
  css: {}
65
68
  }),
66
69
  cssVarPrefix
67
- } = themeProp,
68
- restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
70
+ } = _ref,
71
+ restThemeProp = _objectWithoutPropertiesLoose(_ref, _excluded);
69
72
  const allColorSchemes = Object.keys(colorSchemes);
70
73
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
71
74
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -241,6 +244,7 @@ export default function createCssVarsProvider(options) {
241
244
  styles: otherColorSchemesStyleSheet
242
245
  })]
243
246
  }), /*#__PURE__*/_jsx(ThemeProvider, {
247
+ themeId: scopedTheme ? themeId : undefined,
244
248
  theme: resolveTheme ? resolveTheme(theme) : theme,
245
249
  children: children
246
250
  })]
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
3
  const _excluded = ["colorSchemes", "components"],
3
4
  _excluded2 = ["light"];
@@ -48,11 +49,14 @@ function prepareCssVars(theme, parserConfig) {
48
49
  const generateCssVars = colorScheme => {
49
50
  if (!colorScheme) {
50
51
  return {
51
- css: rootCss,
52
+ css: _extends({}, rootCss),
52
53
  vars: rootVars
53
54
  };
54
55
  }
55
- return colorSchemesMap[colorScheme];
56
+ return {
57
+ css: _extends({}, colorSchemesMap[colorScheme].css),
58
+ vars: colorSchemesMap[colorScheme].vars
59
+ };
56
60
  };
57
61
  return {
58
62
  vars: themeVars,