@mui/system 5.14.11 → 5.14.13

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 (50) hide show
  1. package/Box/Box.d.ts +12 -0
  2. package/Box/Box.js +1 -2
  3. package/CHANGELOG.md +147 -0
  4. package/Container/Container.js +1 -2
  5. package/Container/containerClasses.js +1 -2
  6. package/GlobalStyles/GlobalStyles.js +1 -2
  7. package/Stack/Stack.js +1 -2
  8. package/Stack/stackClasses.js +1 -2
  9. package/ThemeProvider/ThemeProvider.js +1 -2
  10. package/Unstable_Grid/Grid.js +1 -2
  11. package/Unstable_Grid/gridClasses.js +1 -2
  12. package/borders.js +11 -22
  13. package/breakpoints.js +3 -4
  14. package/compose.js +1 -2
  15. package/createStyled.js +100 -37
  16. package/createTheme/createBreakpoints.js +1 -2
  17. package/createTheme/createTheme.js +1 -2
  18. package/createTheme/shape.js +1 -2
  19. package/cssGrid.js +10 -20
  20. package/cssVars/createCssVarsProvider.js +1 -2
  21. package/cssVars/createCssVarsTheme.js +1 -2
  22. package/cssVars/getInitColorSchemeScript.js +3 -6
  23. package/cssVars/prepareCssVars.js +1 -2
  24. package/display.js +7 -14
  25. package/esm/createStyled.js +100 -36
  26. package/esm/style.js +5 -0
  27. package/flexbox.js +14 -28
  28. package/getThemeValue.js +3 -6
  29. package/index.js +1 -1
  30. package/legacy/createStyled.js +106 -41
  31. package/legacy/index.js +1 -1
  32. package/legacy/style.js +6 -0
  33. package/merge.js +1 -2
  34. package/modern/createStyled.js +99 -35
  35. package/modern/index.js +1 -1
  36. package/modern/style.js +5 -0
  37. package/package.json +6 -6
  38. package/palette.js +4 -8
  39. package/positions.js +7 -14
  40. package/responsivePropType.js +1 -2
  41. package/shadows.js +1 -2
  42. package/sizing.js +9 -18
  43. package/spacing.js +3 -6
  44. package/style.js +6 -2
  45. package/styleFunctionSx/defaultSxConfig.js +1 -2
  46. package/styleFunctionSx/styleFunctionSx.js +1 -2
  47. package/styled.js +1 -2
  48. package/typography.js +10 -20
  49. package/useTheme.js +2 -4
  50. package/useThemeWithoutDefault.js +1 -2
@@ -20,5 +20,4 @@ function createCssVarsTheme(theme) {
20
20
  shouldSkipGeneratingVar
21
21
  }));
22
22
  }
23
- var _default = createCssVarsTheme;
24
- exports.default = _default;
23
+ var _default = exports.default = createCssVarsTheme;
@@ -9,12 +9,9 @@ var React = _interopRequireWildcard(require("react"));
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  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); }
11
11
  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; }
12
- const DEFAULT_MODE_STORAGE_KEY = 'mode';
13
- exports.DEFAULT_MODE_STORAGE_KEY = DEFAULT_MODE_STORAGE_KEY;
14
- const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
15
- exports.DEFAULT_COLOR_SCHEME_STORAGE_KEY = DEFAULT_COLOR_SCHEME_STORAGE_KEY;
16
- const DEFAULT_ATTRIBUTE = 'data-color-scheme';
17
- exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
12
+ const DEFAULT_MODE_STORAGE_KEY = exports.DEFAULT_MODE_STORAGE_KEY = 'mode';
13
+ const DEFAULT_COLOR_SCHEME_STORAGE_KEY = exports.DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
14
+ const DEFAULT_ATTRIBUTE = exports.DEFAULT_ATTRIBUTE = 'data-color-scheme';
18
15
  function getInitColorSchemeScript(options) {
19
16
  const {
20
17
  defaultMode = 'light',
@@ -70,5 +70,4 @@ function prepareCssVars(theme, parserConfig) {
70
70
  generateCssVars
71
71
  };
72
72
  }
73
- var _default = prepareCssVars;
74
- exports.default = _default;
73
+ var _default = exports.default = prepareCssVars;
package/display.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.whiteSpace = exports.visibility = exports.textOverflow = exports.overflow = exports.displayRaw = exports.displayPrint = exports.default = void 0;
8
8
  var _style = _interopRequireDefault(require("./style"));
9
9
  var _compose = _interopRequireDefault(require("./compose"));
10
- const displayPrint = (0, _style.default)({
10
+ const displayPrint = exports.displayPrint = (0, _style.default)({
11
11
  prop: 'displayPrint',
12
12
  cssProperty: false,
13
13
  transform: value => ({
@@ -16,26 +16,19 @@ const displayPrint = (0, _style.default)({
16
16
  }
17
17
  })
18
18
  });
19
- exports.displayPrint = displayPrint;
20
- const displayRaw = (0, _style.default)({
19
+ const displayRaw = exports.displayRaw = (0, _style.default)({
21
20
  prop: 'display'
22
21
  });
23
- exports.displayRaw = displayRaw;
24
- const overflow = (0, _style.default)({
22
+ const overflow = exports.overflow = (0, _style.default)({
25
23
  prop: 'overflow'
26
24
  });
27
- exports.overflow = overflow;
28
- const textOverflow = (0, _style.default)({
25
+ const textOverflow = exports.textOverflow = (0, _style.default)({
29
26
  prop: 'textOverflow'
30
27
  });
31
- exports.textOverflow = textOverflow;
32
- const visibility = (0, _style.default)({
28
+ const visibility = exports.visibility = (0, _style.default)({
33
29
  prop: 'visibility'
34
30
  });
35
- exports.visibility = visibility;
36
- const whiteSpace = (0, _style.default)({
31
+ const whiteSpace = exports.whiteSpace = (0, _style.default)({
37
32
  prop: 'whiteSpace'
38
33
  });
39
- exports.whiteSpace = whiteSpace;
40
- var _default = (0, _compose.default)(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
41
- exports.default = _default;
34
+ var _default = exports.default = (0, _compose.default)(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
4
4
  /* eslint-disable no-underscore-dangle */
5
5
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
6
- import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
6
+ import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
7
7
  import createTheme from './createTheme';
8
8
  import propsToClassKey from './propsToClassKey';
9
9
  import styleFunctionSx from './styleFunctionSx';
@@ -25,40 +25,48 @@ const getStyleOverrides = (name, theme) => {
25
25
  }
26
26
  return null;
27
27
  };
28
+ const transformVariants = variants => {
29
+ const variantsStyles = {};
30
+ if (variants) {
31
+ variants.forEach(definition => {
32
+ const key = propsToClassKey(definition.props);
33
+ variantsStyles[key] = definition.style;
34
+ });
35
+ }
36
+ return variantsStyles;
37
+ };
28
38
  const getVariantStyles = (name, theme) => {
29
39
  let variants = [];
30
40
  if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
31
41
  variants = theme.components[name].variants;
32
42
  }
33
- const variantsStyles = {};
34
- variants.forEach(definition => {
35
- const key = propsToClassKey(definition.props);
36
- variantsStyles[key] = definition.style;
37
- });
38
- return variantsStyles;
43
+ return transformVariants(variants);
39
44
  };
40
- const variantsResolver = (props, styles, theme, name) => {
41
- var _theme$components;
45
+ const variantsResolver = (props, styles, variants) => {
42
46
  const {
43
47
  ownerState = {}
44
48
  } = props;
45
49
  const variantsStyles = [];
46
- const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
47
- if (themeVariants) {
48
- themeVariants.forEach(themeVariant => {
50
+ if (variants) {
51
+ variants.forEach(variant => {
49
52
  let isMatch = true;
50
- Object.keys(themeVariant.props).forEach(key => {
51
- if (ownerState[key] !== themeVariant.props[key] && props[key] !== themeVariant.props[key]) {
53
+ Object.keys(variant.props).forEach(key => {
54
+ if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
52
55
  isMatch = false;
53
56
  }
54
57
  });
55
58
  if (isMatch) {
56
- variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
59
+ variantsStyles.push(styles[propsToClassKey(variant.props)]);
57
60
  }
58
61
  });
59
62
  }
60
63
  return variantsStyles;
61
64
  };
65
+ const themeVariantsResolver = (props, styles, theme, name) => {
66
+ var _theme$components;
67
+ const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
68
+ return variantsResolver(props, styles, themeVariants);
69
+ };
62
70
 
63
71
  // Update /system/styled/#api in case if this changes
64
72
  export function shouldForwardProp(prop) {
@@ -84,6 +92,29 @@ function defaultOverridesResolver(slot) {
84
92
  }
85
93
  return (props, styles) => styles[slot];
86
94
  }
95
+ const muiStyledFunctionResolver = ({
96
+ styledArg,
97
+ props,
98
+ defaultTheme,
99
+ themeId
100
+ }) => {
101
+ const resolvedStyles = styledArg(_extends({}, props, {
102
+ theme: resolveTheme(_extends({}, props, {
103
+ defaultTheme,
104
+ themeId
105
+ }))
106
+ }));
107
+ let optionalVariants;
108
+ if (resolvedStyles && resolvedStyles.variants) {
109
+ optionalVariants = resolvedStyles.variants;
110
+ delete resolvedStyles.variants;
111
+ }
112
+ if (optionalVariants) {
113
+ const variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
114
+ return [resolvedStyles, ...variantsStyles];
115
+ }
116
+ return resolvedStyles;
117
+ };
87
118
  export default function createStyled(input = {}) {
88
119
  const {
89
120
  themeId,
@@ -150,16 +181,61 @@ export default function createStyled(input = {}) {
150
181
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
151
182
  // component stays as a function. This condition makes sure that we do not interpolate functions
152
183
  // which are basically components used as a selectors.
153
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
154
- return stylesArg(_extends({}, props, {
155
- theme: resolveTheme(_extends({}, props, {
156
- defaultTheme,
157
- themeId
158
- }))
159
- }));
160
- } : stylesArg;
184
+ if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
185
+ return props => muiStyledFunctionResolver({
186
+ styledArg: stylesArg,
187
+ props,
188
+ defaultTheme,
189
+ themeId
190
+ });
191
+ }
192
+ if (isPlainObject(stylesArg)) {
193
+ let transformedStylesArg = stylesArg;
194
+ let styledArgVariants;
195
+ if (stylesArg && stylesArg.variants) {
196
+ styledArgVariants = stylesArg.variants;
197
+ delete transformedStylesArg.variants;
198
+ transformedStylesArg = props => {
199
+ let result = stylesArg;
200
+ const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
201
+ variantStyles.forEach(variantStyle => {
202
+ result = deepmerge(result, variantStyle);
203
+ });
204
+ return result;
205
+ };
206
+ }
207
+ return transformedStylesArg;
208
+ }
209
+ return stylesArg;
161
210
  }) : [];
162
211
  let transformedStyleArg = styleArg;
212
+ if (isPlainObject(styleArg)) {
213
+ let styledArgVariants;
214
+ if (styleArg && styleArg.variants) {
215
+ styledArgVariants = styleArg.variants;
216
+ delete transformedStyleArg.variants;
217
+ transformedStyleArg = props => {
218
+ let result = styleArg;
219
+ const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
220
+ variantStyles.forEach(variantStyle => {
221
+ result = deepmerge(result, variantStyle);
222
+ });
223
+ return result;
224
+ };
225
+ }
226
+ } else if (typeof styleArg === 'function' &&
227
+ // On the server Emotion doesn't use React.forwardRef for creating components, so the created
228
+ // component stays as a function. This condition makes sure that we do not interpolate functions
229
+ // which are basically components used as a selectors.
230
+ styleArg.__emotion_real !== styleArg) {
231
+ // If the type is function, we need to define the default theme.
232
+ transformedStyleArg = props => muiStyledFunctionResolver({
233
+ styledArg: styleArg,
234
+ props,
235
+ defaultTheme,
236
+ themeId
237
+ });
238
+ }
163
239
  if (componentName && overridesResolver) {
164
240
  expressionsWithDefaultTheme.push(props => {
165
241
  const theme = resolveTheme(_extends({}, props, {
@@ -185,7 +261,7 @@ export default function createStyled(input = {}) {
185
261
  defaultTheme,
186
262
  themeId
187
263
  }));
188
- return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
264
+ return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
189
265
  });
190
266
  }
191
267
  if (!skipSx) {
@@ -197,18 +273,6 @@ export default function createStyled(input = {}) {
197
273
  // If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
198
274
  transformedStyleArg = [...styleArg, ...placeholders];
199
275
  transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
200
- } else if (typeof styleArg === 'function' &&
201
- // On the server Emotion doesn't use React.forwardRef for creating components, so the created
202
- // component stays as a function. This condition makes sure that we do not interpolate functions
203
- // which are basically components used as a selectors.
204
- styleArg.__emotion_real !== styleArg) {
205
- // If the type is function, we need to define the default theme.
206
- transformedStyleArg = props => styleArg(_extends({}, props, {
207
- theme: resolveTheme(_extends({}, props, {
208
- defaultTheme,
209
- themeId
210
- }))
211
- }));
212
276
  }
213
277
  const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
214
278
  if (process.env.NODE_ENV !== 'production') {
package/esm/style.js CHANGED
@@ -29,6 +29,11 @@ export function getStyleValue(themeMapping, transform, propValueFinal, userValue
29
29
  } else {
30
30
  value = getPath(themeMapping, propValueFinal) || userValue;
31
31
  }
32
+ if (typeof value === 'object') {
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ console.warn(`MUI: The value found in theme for prop: "${propValueFinal}" is an [Object] instead of string or number. Check if you forgot to add the correct dotted notation, eg, "background.paper" instead of "background".`);
35
+ }
36
+ }
32
37
  if (transform) {
33
38
  value = transform(value, userValue, themeMapping);
34
39
  }
package/flexbox.js CHANGED
@@ -7,58 +7,44 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.order = exports.justifySelf = exports.justifyItems = exports.justifyContent = exports.flexWrap = exports.flexShrink = exports.flexGrow = exports.flexDirection = exports.flexBasis = exports.flex = exports.default = exports.alignSelf = exports.alignItems = exports.alignContent = void 0;
8
8
  var _style = _interopRequireDefault(require("./style"));
9
9
  var _compose = _interopRequireDefault(require("./compose"));
10
- const flexBasis = (0, _style.default)({
10
+ const flexBasis = exports.flexBasis = (0, _style.default)({
11
11
  prop: 'flexBasis'
12
12
  });
13
- exports.flexBasis = flexBasis;
14
- const flexDirection = (0, _style.default)({
13
+ const flexDirection = exports.flexDirection = (0, _style.default)({
15
14
  prop: 'flexDirection'
16
15
  });
17
- exports.flexDirection = flexDirection;
18
- const flexWrap = (0, _style.default)({
16
+ const flexWrap = exports.flexWrap = (0, _style.default)({
19
17
  prop: 'flexWrap'
20
18
  });
21
- exports.flexWrap = flexWrap;
22
- const justifyContent = (0, _style.default)({
19
+ const justifyContent = exports.justifyContent = (0, _style.default)({
23
20
  prop: 'justifyContent'
24
21
  });
25
- exports.justifyContent = justifyContent;
26
- const alignItems = (0, _style.default)({
22
+ const alignItems = exports.alignItems = (0, _style.default)({
27
23
  prop: 'alignItems'
28
24
  });
29
- exports.alignItems = alignItems;
30
- const alignContent = (0, _style.default)({
25
+ const alignContent = exports.alignContent = (0, _style.default)({
31
26
  prop: 'alignContent'
32
27
  });
33
- exports.alignContent = alignContent;
34
- const order = (0, _style.default)({
28
+ const order = exports.order = (0, _style.default)({
35
29
  prop: 'order'
36
30
  });
37
- exports.order = order;
38
- const flex = (0, _style.default)({
31
+ const flex = exports.flex = (0, _style.default)({
39
32
  prop: 'flex'
40
33
  });
41
- exports.flex = flex;
42
- const flexGrow = (0, _style.default)({
34
+ const flexGrow = exports.flexGrow = (0, _style.default)({
43
35
  prop: 'flexGrow'
44
36
  });
45
- exports.flexGrow = flexGrow;
46
- const flexShrink = (0, _style.default)({
37
+ const flexShrink = exports.flexShrink = (0, _style.default)({
47
38
  prop: 'flexShrink'
48
39
  });
49
- exports.flexShrink = flexShrink;
50
- const alignSelf = (0, _style.default)({
40
+ const alignSelf = exports.alignSelf = (0, _style.default)({
51
41
  prop: 'alignSelf'
52
42
  });
53
- exports.alignSelf = alignSelf;
54
- const justifyItems = (0, _style.default)({
43
+ const justifyItems = exports.justifyItems = (0, _style.default)({
55
44
  prop: 'justifyItems'
56
45
  });
57
- exports.justifyItems = justifyItems;
58
- const justifySelf = (0, _style.default)({
46
+ const justifySelf = exports.justifySelf = (0, _style.default)({
59
47
  prop: 'justifySelf'
60
48
  });
61
- exports.justifySelf = justifySelf;
62
49
  const flexbox = (0, _compose.default)(flexBasis, flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf, justifyItems, justifySelf);
63
- var _default = flexbox;
64
- exports.default = _default;
50
+ var _default = exports.default = flexbox;
package/getThemeValue.js CHANGED
@@ -27,7 +27,7 @@ const filterPropsMapping = {
27
27
  spacing: _spacing.default.filterProps,
28
28
  typography: _typography.default.filterProps
29
29
  };
30
- const styleFunctionMapping = {
30
+ const styleFunctionMapping = exports.styleFunctionMapping = {
31
31
  borders: _borders.default,
32
32
  display: _display.default,
33
33
  flexbox: _flexbox.default,
@@ -39,14 +39,12 @@ const styleFunctionMapping = {
39
39
  spacing: _spacing.default,
40
40
  typography: _typography.default
41
41
  };
42
- exports.styleFunctionMapping = styleFunctionMapping;
43
- const propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
42
+ const propToStyleFunction = exports.propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
44
43
  filterPropsMapping[styleFnName].forEach(propName => {
45
44
  acc[propName] = styleFunctionMapping[styleFnName];
46
45
  });
47
46
  return acc;
48
47
  }, {});
49
- exports.propToStyleFunction = propToStyleFunction;
50
48
  function getThemeValue(prop, value, theme) {
51
49
  const inputProps = {
52
50
  [prop]: value,
@@ -57,5 +55,4 @@ function getThemeValue(prop, value, theme) {
57
55
  [prop]: value
58
56
  };
59
57
  }
60
- var _default = getThemeValue;
61
- exports.default = _default;
58
+ var _default = exports.default = getThemeValue;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.14.11
2
+ * @mui/system v5.14.13
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,10 +1,10 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
5
  /* eslint-disable no-underscore-dangle */
6
6
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
7
- import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
7
+ import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
8
8
  import createTheme from './createTheme';
9
9
  import propsToClassKey from './propsToClassKey';
10
10
  import styleFunctionSx from './styleFunctionSx';
@@ -26,39 +26,47 @@ var getStyleOverrides = function getStyleOverrides(name, theme) {
26
26
  }
27
27
  return null;
28
28
  };
29
+ var transformVariants = function transformVariants(variants) {
30
+ var variantsStyles = {};
31
+ if (variants) {
32
+ variants.forEach(function (definition) {
33
+ var key = propsToClassKey(definition.props);
34
+ variantsStyles[key] = definition.style;
35
+ });
36
+ }
37
+ return variantsStyles;
38
+ };
29
39
  var getVariantStyles = function getVariantStyles(name, theme) {
30
40
  var variants = [];
31
41
  if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
32
42
  variants = theme.components[name].variants;
33
43
  }
34
- var variantsStyles = {};
35
- variants.forEach(function (definition) {
36
- var key = propsToClassKey(definition.props);
37
- variantsStyles[key] = definition.style;
38
- });
39
- return variantsStyles;
44
+ return transformVariants(variants);
40
45
  };
41
- var variantsResolver = function variantsResolver(props, styles, theme, name) {
42
- var _theme$components;
46
+ var variantsResolver = function variantsResolver(props, styles, variants) {
43
47
  var _props$ownerState = props.ownerState,
44
48
  ownerState = _props$ownerState === void 0 ? {} : _props$ownerState;
45
49
  var variantsStyles = [];
46
- var themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
47
- if (themeVariants) {
48
- themeVariants.forEach(function (themeVariant) {
50
+ if (variants) {
51
+ variants.forEach(function (variant) {
49
52
  var isMatch = true;
50
- Object.keys(themeVariant.props).forEach(function (key) {
51
- if (ownerState[key] !== themeVariant.props[key] && props[key] !== themeVariant.props[key]) {
53
+ Object.keys(variant.props).forEach(function (key) {
54
+ if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
52
55
  isMatch = false;
53
56
  }
54
57
  });
55
58
  if (isMatch) {
56
- variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
59
+ variantsStyles.push(styles[propsToClassKey(variant.props)]);
57
60
  }
58
61
  });
59
62
  }
60
63
  return variantsStyles;
61
64
  };
65
+ var themeVariantsResolver = function themeVariantsResolver(props, styles, theme, name) {
66
+ var _theme$components;
67
+ var themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
68
+ return variantsResolver(props, styles, themeVariants);
69
+ };
62
70
 
63
71
  // Update /system/styled/#api in case if this changes
64
72
  export function shouldForwardProp(prop) {
@@ -85,6 +93,28 @@ function defaultOverridesResolver(slot) {
85
93
  return styles[slot];
86
94
  };
87
95
  }
96
+ var muiStyledFunctionResolver = function muiStyledFunctionResolver(_ref2) {
97
+ var styledArg = _ref2.styledArg,
98
+ props = _ref2.props,
99
+ defaultTheme = _ref2.defaultTheme,
100
+ themeId = _ref2.themeId;
101
+ var resolvedStyles = styledArg(_extends({}, props, {
102
+ theme: resolveTheme(_extends({}, props, {
103
+ defaultTheme: defaultTheme,
104
+ themeId: themeId
105
+ }))
106
+ }));
107
+ var optionalVariants;
108
+ if (resolvedStyles && resolvedStyles.variants) {
109
+ optionalVariants = resolvedStyles.variants;
110
+ delete resolvedStyles.variants;
111
+ }
112
+ if (optionalVariants) {
113
+ var variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
114
+ return [resolvedStyles].concat(_toConsumableArray(variantsStyles));
115
+ }
116
+ return resolvedStyles;
117
+ };
88
118
  export default function createStyled() {
89
119
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90
120
  var themeId = input.themeId,
@@ -156,16 +186,65 @@ export default function createStyled() {
156
186
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
157
187
  // component stays as a function. This condition makes sure that we do not interpolate functions
158
188
  // which are basically components used as a selectors.
159
- return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (props) {
160
- return stylesArg(_extends({}, props, {
161
- theme: resolveTheme(_extends({}, props, {
189
+ if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
190
+ return function (props) {
191
+ return muiStyledFunctionResolver({
192
+ styledArg: stylesArg,
193
+ props: props,
162
194
  defaultTheme: defaultTheme,
163
195
  themeId: themeId
164
- }))
165
- }));
166
- } : stylesArg;
196
+ });
197
+ };
198
+ }
199
+ if (isPlainObject(stylesArg)) {
200
+ var transformedStylesArg = stylesArg;
201
+ var styledArgVariants;
202
+ if (stylesArg && stylesArg.variants) {
203
+ styledArgVariants = stylesArg.variants;
204
+ delete transformedStylesArg.variants;
205
+ transformedStylesArg = function transformedStylesArg(props) {
206
+ var result = stylesArg;
207
+ var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
208
+ variantStyles.forEach(function (variantStyle) {
209
+ result = deepmerge(result, variantStyle);
210
+ });
211
+ return result;
212
+ };
213
+ }
214
+ return transformedStylesArg;
215
+ }
216
+ return stylesArg;
167
217
  }) : [];
168
218
  var transformedStyleArg = styleArg;
219
+ if (isPlainObject(styleArg)) {
220
+ var styledArgVariants;
221
+ if (styleArg && styleArg.variants) {
222
+ styledArgVariants = styleArg.variants;
223
+ delete transformedStyleArg.variants;
224
+ transformedStyleArg = function transformedStyleArg(props) {
225
+ var result = styleArg;
226
+ var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
227
+ variantStyles.forEach(function (variantStyle) {
228
+ result = deepmerge(result, variantStyle);
229
+ });
230
+ return result;
231
+ };
232
+ }
233
+ } else if (typeof styleArg === 'function' &&
234
+ // On the server Emotion doesn't use React.forwardRef for creating components, so the created
235
+ // component stays as a function. This condition makes sure that we do not interpolate functions
236
+ // which are basically components used as a selectors.
237
+ styleArg.__emotion_real !== styleArg) {
238
+ // If the type is function, we need to define the default theme.
239
+ transformedStyleArg = function transformedStyleArg(props) {
240
+ return muiStyledFunctionResolver({
241
+ styledArg: styleArg,
242
+ props: props,
243
+ defaultTheme: defaultTheme,
244
+ themeId: themeId
245
+ });
246
+ };
247
+ }
169
248
  if (componentName && overridesResolver) {
170
249
  expressionsWithDefaultTheme.push(function (props) {
171
250
  var theme = resolveTheme(_extends({}, props, {
@@ -175,10 +254,10 @@ export default function createStyled() {
175
254
  var styleOverrides = getStyleOverrides(componentName, theme);
176
255
  if (styleOverrides) {
177
256
  var resolvedStyleOverrides = {};
178
- Object.entries(styleOverrides).forEach(function (_ref2) {
179
- var _ref3 = _slicedToArray(_ref2, 2),
180
- slotKey = _ref3[0],
181
- slotStyle = _ref3[1];
257
+ Object.entries(styleOverrides).forEach(function (_ref3) {
258
+ var _ref4 = _slicedToArray(_ref3, 2),
259
+ slotKey = _ref4[0],
260
+ slotStyle = _ref4[1];
182
261
  resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
183
262
  theme: theme
184
263
  })) : slotStyle;
@@ -194,7 +273,7 @@ export default function createStyled() {
194
273
  defaultTheme: defaultTheme,
195
274
  themeId: themeId
196
275
  }));
197
- return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
276
+ return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
198
277
  });
199
278
  }
200
279
  if (!skipSx) {
@@ -206,20 +285,6 @@ export default function createStyled() {
206
285
  // If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
207
286
  transformedStyleArg = [].concat(_toConsumableArray(styleArg), _toConsumableArray(placeholders));
208
287
  transformedStyleArg.raw = [].concat(_toConsumableArray(styleArg.raw), _toConsumableArray(placeholders));
209
- } else if (typeof styleArg === 'function' &&
210
- // On the server Emotion doesn't use React.forwardRef for creating components, so the created
211
- // component stays as a function. This condition makes sure that we do not interpolate functions
212
- // which are basically components used as a selectors.
213
- styleArg.__emotion_real !== styleArg) {
214
- // If the type is function, we need to define the default theme.
215
- transformedStyleArg = function transformedStyleArg(props) {
216
- return styleArg(_extends({}, props, {
217
- theme: resolveTheme(_extends({}, props, {
218
- defaultTheme: defaultTheme,
219
- themeId: themeId
220
- }))
221
- }));
222
- };
223
288
  }
224
289
  var Component = defaultStyledResolver.apply(void 0, [transformedStyleArg].concat(_toConsumableArray(expressionsWithDefaultTheme)));
225
290
  if (process.env.NODE_ENV !== 'production') {
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.14.11
2
+ * @mui/system v5.14.13
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/legacy/style.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
3
  import { unstable_capitalize as capitalize } from '@mui/utils';
3
4
  import responsivePropType from './responsivePropType';
4
5
  import { handleBreakpoints } from './breakpoints';
@@ -34,6 +35,11 @@ export function getStyleValue(themeMapping, transform, propValueFinal) {
34
35
  } else {
35
36
  value = getPath(themeMapping, propValueFinal) || userValue;
36
37
  }
38
+ if (_typeof(value) === 'object') {
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ console.warn("MUI: The value found in theme for prop: \"".concat(propValueFinal, "\" is an [Object] instead of string or number. Check if you forgot to add the correct dotted notation, eg, \"background.paper\" instead of \"background\"."));
41
+ }
42
+ }
37
43
  if (transform) {
38
44
  value = transform(value, userValue, themeMapping);
39
45
  }
package/merge.js CHANGED
@@ -13,5 +13,4 @@ function merge(acc, item) {
13
13
  clone: false // No need to clone deep, it's way faster.
14
14
  });
15
15
  }
16
- var _default = merge;
17
- exports.default = _default;
16
+ var _default = exports.default = merge;