@mui/system 5.11.16 → 5.12.0

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 (52) hide show
  1. package/CHANGELOG.md +73 -22
  2. package/GlobalStyles/GlobalStyles.d.ts +13 -0
  3. package/GlobalStyles/GlobalStyles.js +45 -0
  4. package/GlobalStyles/index.d.ts +2 -0
  5. package/GlobalStyles/index.js +26 -0
  6. package/GlobalStyles/package.json +6 -0
  7. package/ThemeProvider/ThemeProvider.d.ts +4 -0
  8. package/ThemeProvider/ThemeProvider.js +43 -17
  9. package/createBox.d.ts +1 -0
  10. package/createBox.js +2 -1
  11. package/createStyled.d.ts +1 -0
  12. package/createStyled.js +34 -24
  13. package/cssVars/createCssVarsProvider.d.ts +22 -7
  14. package/cssVars/createCssVarsProvider.js +7 -3
  15. package/esm/GlobalStyles/GlobalStyles.js +35 -0
  16. package/esm/GlobalStyles/index.js +2 -0
  17. package/esm/ThemeProvider/ThemeProvider.js +44 -18
  18. package/esm/createBox.js +2 -1
  19. package/esm/createStyled.js +34 -24
  20. package/esm/cssVars/createCssVarsProvider.js +7 -3
  21. package/esm/index.js +2 -1
  22. package/esm/useThemeProps/useThemeProps.js +6 -2
  23. package/esm/useThemeWithoutDefault.js +3 -2
  24. package/index.d.ts +2 -2
  25. package/index.js +4 -3
  26. package/legacy/GlobalStyles/GlobalStyles.js +35 -0
  27. package/legacy/GlobalStyles/index.js +2 -0
  28. package/legacy/ThemeProvider/ThemeProvider.js +44 -19
  29. package/legacy/createBox.js +3 -2
  30. package/legacy/createStyled.js +34 -17
  31. package/legacy/cssVars/createCssVarsProvider.js +18 -14
  32. package/legacy/index.js +3 -2
  33. package/legacy/useThemeProps/useThemeProps.js +5 -1
  34. package/legacy/useThemeWithoutDefault.js +3 -2
  35. package/modern/GlobalStyles/GlobalStyles.js +35 -0
  36. package/modern/GlobalStyles/index.js +2 -0
  37. package/modern/ThemeProvider/ThemeProvider.js +44 -18
  38. package/modern/createBox.js +2 -1
  39. package/modern/createStyled.js +34 -24
  40. package/modern/cssVars/createCssVarsProvider.js +7 -3
  41. package/modern/index.js +3 -2
  42. package/modern/useThemeProps/useThemeProps.js +6 -2
  43. package/modern/useThemeWithoutDefault.js +3 -2
  44. package/package.json +5 -5
  45. package/useThemeProps/useThemeProps.d.ts +6 -1
  46. package/useThemeProps/useThemeProps.js +6 -2
  47. package/useThemeWithoutDefault.js +5 -2
  48. package/Box/Box.spec.d.ts +0 -1
  49. package/createBox.spec.d.ts +0 -1
  50. package/cssVars/createCssVarsProvider.spec.d.ts +0 -1
  51. package/index.spec.d.ts +0 -1
  52. package/styleFunctionSx/styleFunctionSx.spec.d.ts +0 -1
@@ -68,18 +68,27 @@ export var systemDefaultTheme = createTheme();
68
68
  var lowercaseFirstLetter = function lowercaseFirstLetter(string) {
69
69
  return string.charAt(0).toLowerCase() + string.slice(1);
70
70
  };
71
+ function resolveTheme(_ref) {
72
+ var defaultTheme = _ref.defaultTheme,
73
+ theme = _ref.theme,
74
+ themeId = _ref.themeId;
75
+ return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
76
+ }
71
77
  export default function createStyled() {
72
78
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
73
- var _input$defaultTheme = input.defaultTheme,
79
+ var themeId = input.themeId,
80
+ _input$defaultTheme = input.defaultTheme,
74
81
  defaultTheme = _input$defaultTheme === void 0 ? systemDefaultTheme : _input$defaultTheme,
75
82
  _input$rootShouldForw = input.rootShouldForwardProp,
76
83
  rootShouldForwardProp = _input$rootShouldForw === void 0 ? shouldForwardProp : _input$rootShouldForw,
77
84
  _input$slotShouldForw = input.slotShouldForwardProp,
78
85
  slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw;
79
86
  var systemSx = function systemSx(props) {
80
- var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
81
87
  return styleFunctionSx(_extends({}, props, {
82
- theme: theme
88
+ theme: resolveTheme(_extends({}, props, {
89
+ defaultTheme: defaultTheme,
90
+ themeId: themeId
91
+ }))
83
92
  }));
84
93
  };
85
94
  systemSx.__mui_systemSx = true;
@@ -127,18 +136,22 @@ export default function createStyled() {
127
136
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
128
137
  // component stays as a function. This condition makes sure that we do not interpolate functions
129
138
  // which are basically components used as a selectors.
130
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (_ref) {
131
- var themeInput = _ref.theme,
132
- other = _objectWithoutProperties(_ref, ["theme"]);
133
- return stylesArg(_extends({
134
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
135
- }, other));
139
+ return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (props) {
140
+ return stylesArg(_extends({}, props, {
141
+ theme: resolveTheme(_extends({}, props, {
142
+ defaultTheme: defaultTheme,
143
+ themeId: themeId
144
+ }))
145
+ }));
136
146
  } : stylesArg;
137
147
  }) : [];
138
148
  var transformedStyleArg = styleArg;
139
149
  if (componentName && overridesResolver) {
140
150
  expressionsWithDefaultTheme.push(function (props) {
141
- var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
151
+ var theme = resolveTheme(_extends({}, props, {
152
+ defaultTheme: defaultTheme,
153
+ themeId: themeId
154
+ }));
142
155
  var styleOverrides = getStyleOverrides(componentName, theme);
143
156
  if (styleOverrides) {
144
157
  var resolvedStyleOverrides = {};
@@ -157,7 +170,10 @@ export default function createStyled() {
157
170
  }
158
171
  if (componentName && !skipVariantsResolver) {
159
172
  expressionsWithDefaultTheme.push(function (props) {
160
- var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
173
+ var theme = resolveTheme(_extends({}, props, {
174
+ defaultTheme: defaultTheme,
175
+ themeId: themeId
176
+ }));
161
177
  return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
162
178
  });
163
179
  }
@@ -176,12 +192,13 @@ export default function createStyled() {
176
192
  // which are basically components used as a selectors.
177
193
  styleArg.__emotion_real !== styleArg) {
178
194
  // If the type is function, we need to define the default theme.
179
- transformedStyleArg = function transformedStyleArg(_ref4) {
180
- var themeInput = _ref4.theme,
181
- other = _objectWithoutProperties(_ref4, ["theme"]);
182
- return styleArg(_extends({
183
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
184
- }, other));
195
+ transformedStyleArg = function transformedStyleArg(props) {
196
+ return styleArg(_extends({}, props, {
197
+ theme: resolveTheme(_extends({}, props, {
198
+ defaultTheme: defaultTheme,
199
+ themeId: themeId
200
+ }))
201
+ }));
185
202
  };
186
203
  }
187
204
  var Component = defaultStyledResolver.apply(void 0, [transformedStyleArg].concat(_toConsumableArray(expressionsWithDefaultTheme)));
@@ -16,7 +16,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
  export var DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
18
18
  export default function createCssVarsProvider(options) {
19
- var _options$theme = options.theme,
19
+ var themeId = options.themeId,
20
+ _options$theme = options.theme,
20
21
  defaultTheme = _options$theme === void 0 ? {} : _options$theme,
21
22
  _options$attribute = options.attribute,
22
23
  defaultAttribute = _options$attribute === void 0 ? DEFAULT_ATTRIBUTE : _options$attribute,
@@ -74,19 +75,21 @@ export default function createCssVarsProvider(options) {
74
75
  var upperTheme = muiUseTheme();
75
76
  var ctx = React.useContext(ColorSchemeContext);
76
77
  var nested = !!ctx && !disableNestedContext;
77
- var _themeProp$colorSchem = themeProp.colorSchemes,
78
- colorSchemes = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
79
- _themeProp$components = themeProp.components,
80
- components = _themeProp$components === void 0 ? {} : _themeProp$components,
81
- _themeProp$generateCs = themeProp.generateCssVars,
82
- generateCssVars = _themeProp$generateCs === void 0 ? function () {
78
+ var scopedTheme = themeProp[themeId];
79
+ var _ref2 = scopedTheme || themeProp,
80
+ _ref2$colorSchemes = _ref2.colorSchemes,
81
+ colorSchemes = _ref2$colorSchemes === void 0 ? {} : _ref2$colorSchemes,
82
+ _ref2$components = _ref2.components,
83
+ components = _ref2$components === void 0 ? {} : _ref2$components,
84
+ _ref2$generateCssVars = _ref2.generateCssVars,
85
+ generateCssVars = _ref2$generateCssVars === void 0 ? function () {
83
86
  return {
84
87
  vars: {},
85
88
  css: {}
86
89
  };
87
- } : _themeProp$generateCs,
88
- cssVarPrefix = themeProp.cssVarPrefix,
89
- restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"]);
90
+ } : _ref2$generateCssVars,
91
+ cssVarPrefix = _ref2.cssVarPrefix,
92
+ restThemeProp = _objectWithoutProperties(_ref2, ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"]);
90
93
  var allColorSchemes = Object.keys(colorSchemes);
91
94
  var defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
92
95
  var defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -155,10 +158,10 @@ export default function createCssVarsProvider(options) {
155
158
  // The other color schemes uses selector, default as data attribute, to increase the CSS specificity so that they can override the default color scheme stylesheet.
156
159
  var defaultColorSchemeStyleSheet = {};
157
160
  var otherColorSchemesStyleSheet = {};
158
- Object.entries(colorSchemes).forEach(function (_ref2) {
159
- var _ref3 = _slicedToArray(_ref2, 2),
160
- key = _ref3[0],
161
- scheme = _ref3[1];
161
+ Object.entries(colorSchemes).forEach(function (_ref3) {
162
+ var _ref4 = _slicedToArray(_ref3, 2),
163
+ key = _ref4[0],
164
+ scheme = _ref4[1];
162
165
  var _generateCssVars2 = generateCssVars(key),
163
166
  css = _generateCssVars2.css,
164
167
  vars = _generateCssVars2.vars;
@@ -264,6 +267,7 @@ export default function createCssVarsProvider(options) {
264
267
  styles: otherColorSchemesStyleSheet
265
268
  })]
266
269
  }), /*#__PURE__*/_jsx(ThemeProvider, {
270
+ themeId: scopedTheme ? themeId : undefined,
267
271
  theme: resolveTheme ? resolveTheme(theme) : theme,
268
272
  children: children
269
273
  })]
package/legacy/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  /**
2
- * @mui/system v5.11.16
2
+ * @mui/system v5.12.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
9
- export { css, keyframes, GlobalStyles, StyledEngineProvider } from '@mui/styled-engine';
9
+ export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
10
+ export { default as GlobalStyles } from './GlobalStyles';
10
11
  export { default as borders } from './borders';
11
12
  export * from './borders';
12
13
  export { default as breakpoints } from './breakpoints';
@@ -3,8 +3,12 @@ import useTheme from '../useTheme';
3
3
  export default function useThemeProps(_ref) {
4
4
  var props = _ref.props,
5
5
  name = _ref.name,
6
- defaultTheme = _ref.defaultTheme;
6
+ defaultTheme = _ref.defaultTheme,
7
+ themeId = _ref.themeId;
7
8
  var theme = useTheme(defaultTheme);
9
+ if (themeId) {
10
+ theme = theme[themeId] || theme;
11
+ }
8
12
  var mergedProps = getThemeProps({
9
13
  theme: theme,
10
14
  name: name,
@@ -1,10 +1,11 @@
1
- import { useTheme as muiUseTheme } from '@mui/private-theming';
1
+ import * as React from 'react';
2
+ import { ThemeContext } from '@mui/styled-engine';
2
3
  function isObjectEmpty(obj) {
3
4
  return Object.keys(obj).length === 0;
4
5
  }
5
6
  function useTheme() {
6
7
  var defaultTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
7
- var contextTheme = muiUseTheme();
8
+ var contextTheme = React.useContext(ThemeContext);
8
9
  return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
9
10
  }
10
11
  export default useTheme;
@@ -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';
@@ -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;
@@ -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';
@@ -69,16 +67,26 @@ export const systemDefaultTheme = createTheme();
69
67
  const lowercaseFirstLetter = string => {
70
68
  return string.charAt(0).toLowerCase() + string.slice(1);
71
69
  };
70
+ function resolveTheme({
71
+ defaultTheme,
72
+ theme,
73
+ themeId
74
+ }) {
75
+ return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
76
+ }
72
77
  export default function createStyled(input = {}) {
73
78
  const {
79
+ themeId,
74
80
  defaultTheme = systemDefaultTheme,
75
81
  rootShouldForwardProp = shouldForwardProp,
76
82
  slotShouldForwardProp = shouldForwardProp
77
83
  } = input;
78
84
  const systemSx = props => {
79
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
80
85
  return styleFunctionSx(_extends({}, props, {
81
- theme
86
+ theme: resolveTheme(_extends({}, props, {
87
+ defaultTheme,
88
+ themeId
89
+ }))
82
90
  }));
83
91
  };
84
92
  systemSx.__mui_systemSx = true;
@@ -122,20 +130,22 @@ export default function createStyled(input = {}) {
122
130
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
123
131
  // component stays as a function. This condition makes sure that we do not interpolate functions
124
132
  // which are basically components used as a selectors.
125
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? _ref => {
126
- let {
127
- theme: themeInput
128
- } = _ref,
129
- other = _objectWithoutPropertiesLoose(_ref, _excluded2);
130
- return stylesArg(_extends({
131
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
132
- }, other));
133
+ return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
134
+ return stylesArg(_extends({}, props, {
135
+ theme: resolveTheme(_extends({}, props, {
136
+ defaultTheme,
137
+ themeId
138
+ }))
139
+ }));
133
140
  } : stylesArg;
134
141
  }) : [];
135
142
  let transformedStyleArg = styleArg;
136
143
  if (componentName && overridesResolver) {
137
144
  expressionsWithDefaultTheme.push(props => {
138
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
145
+ const theme = resolveTheme(_extends({}, props, {
146
+ defaultTheme,
147
+ themeId
148
+ }));
139
149
  const styleOverrides = getStyleOverrides(componentName, theme);
140
150
  if (styleOverrides) {
141
151
  const resolvedStyleOverrides = {};
@@ -151,7 +161,10 @@ export default function createStyled(input = {}) {
151
161
  }
152
162
  if (componentName && !skipVariantsResolver) {
153
163
  expressionsWithDefaultTheme.push(props => {
154
- const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
164
+ const theme = resolveTheme(_extends({}, props, {
165
+ defaultTheme,
166
+ themeId
167
+ }));
155
168
  return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
156
169
  });
157
170
  }
@@ -170,15 +183,12 @@ export default function createStyled(input = {}) {
170
183
  // which are basically components used as a selectors.
171
184
  styleArg.__emotion_real !== styleArg) {
172
185
  // If the type is function, we need to define the default theme.
173
- transformedStyleArg = _ref2 => {
174
- let {
175
- theme: themeInput
176
- } = _ref2,
177
- other = _objectWithoutPropertiesLoose(_ref2, _excluded3);
178
- return styleArg(_extends({
179
- theme: isEmpty(themeInput) ? defaultTheme : themeInput
180
- }, other));
181
- };
186
+ transformedStyleArg = props => styleArg(_extends({}, props, {
187
+ theme: resolveTheme(_extends({}, props, {
188
+ defaultTheme,
189
+ themeId
190
+ }))
191
+ }));
182
192
  }
183
193
  const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
184
194
  if (process.env.NODE_ENV !== 'production') {
@@ -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
  })]
package/modern/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  /**
2
- * @mui/system v5.11.16
2
+ * @mui/system v5.12.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
9
- export { css, keyframes, GlobalStyles, StyledEngineProvider } from '@mui/styled-engine';
9
+ export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
10
+ export { default as GlobalStyles } from './GlobalStyles';
10
11
  export { default as borders } from './borders';
11
12
  export * from './borders';
12
13
  export { default as breakpoints } from './breakpoints';
@@ -3,9 +3,13 @@ import useTheme from '../useTheme';
3
3
  export default function useThemeProps({
4
4
  props,
5
5
  name,
6
- defaultTheme
6
+ defaultTheme,
7
+ themeId
7
8
  }) {
8
- const theme = useTheme(defaultTheme);
9
+ let theme = useTheme(defaultTheme);
10
+ if (themeId) {
11
+ theme = theme[themeId] || theme;
12
+ }
9
13
  const mergedProps = getThemeProps({
10
14
  theme,
11
15
  name,
@@ -1,9 +1,10 @@
1
- import { useTheme as muiUseTheme } from '@mui/private-theming';
1
+ import * as React from 'react';
2
+ import { ThemeContext } from '@mui/styled-engine';
2
3
  function isObjectEmpty(obj) {
3
4
  return Object.keys(obj).length === 0;
4
5
  }
5
6
  function useTheme(defaultTheme = null) {
6
- const contextTheme = muiUseTheme();
7
+ const contextTheme = React.useContext(ThemeContext);
7
8
  return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
8
9
  }
9
10
  export default useTheme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.11.16",
3
+ "version": "5.12.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.21.0",
47
- "@mui/private-theming": "^5.11.13",
48
- "@mui/styled-engine": "^5.11.16",
49
- "@mui/types": "^7.2.3",
50
- "@mui/utils": "^5.11.13",
47
+ "@mui/private-theming": "^5.12.0",
48
+ "@mui/styled-engine": "^5.12.0",
49
+ "@mui/types": "^7.2.4",
50
+ "@mui/utils": "^5.12.0",
51
51
  "clsx": "^1.2.1",
52
52
  "csstype": "^3.1.2",
53
53
  "prop-types": "^15.8.1"
@@ -12,4 +12,9 @@ export default function useThemeProps<
12
12
  Theme extends ThemeWithProps,
13
13
  Props,
14
14
  Name extends keyof any,
15
- >(params: { props: Props; name: Name; defaultTheme?: Theme }): Props & ThemedProps<Theme, Name>;
15
+ >(params: {
16
+ props: Props;
17
+ name: Name;
18
+ defaultTheme?: Theme;
19
+ themeId?: string;
20
+ }): Props & ThemedProps<Theme, Name>;
@@ -10,9 +10,13 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
10
10
  function useThemeProps({
11
11
  props,
12
12
  name,
13
- defaultTheme
13
+ defaultTheme,
14
+ themeId
14
15
  }) {
15
- const theme = (0, _useTheme.default)(defaultTheme);
16
+ let theme = (0, _useTheme.default)(defaultTheme);
17
+ if (themeId) {
18
+ theme = theme[themeId] || theme;
19
+ }
16
20
  const mergedProps = (0, _getThemeProps.default)({
17
21
  theme,
18
22
  name,
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _privateTheming = require("@mui/private-theming");
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _styledEngine = require("@mui/styled-engine");
9
+ 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); }
10
+ 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; }
8
11
  function isObjectEmpty(obj) {
9
12
  return Object.keys(obj).length === 0;
10
13
  }
11
14
  function useTheme(defaultTheme = null) {
12
- const contextTheme = (0, _privateTheming.useTheme)();
15
+ const contextTheme = React.useContext(_styledEngine.ThemeContext);
13
16
  return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
14
17
  }
15
18
  var _default = useTheme;
package/Box/Box.spec.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/index.spec.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};