@mui/system 5.13.1 → 5.13.5

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 (81) hide show
  1. package/CHANGELOG.md +184 -4
  2. package/Container/createContainer.js +35 -41
  3. package/GlobalStyles/GlobalStyles.d.ts +2 -2
  4. package/Stack/createStack.js +26 -24
  5. package/ThemeProvider/ThemeProvider.js +5 -9
  6. package/Unstable_Grid/createGrid.js +23 -21
  7. package/Unstable_Grid/gridGenerator.d.ts +1 -6
  8. package/Unstable_Grid/gridGenerator.js +26 -71
  9. package/Unstable_Grid/index.d.ts +1 -0
  10. package/Unstable_Grid/index.js +9 -1
  11. package/Unstable_Grid/traverseBreakpoints.d.ts +7 -0
  12. package/Unstable_Grid/traverseBreakpoints.js +50 -0
  13. package/breakpoints.js +6 -7
  14. package/createBox.js +12 -9
  15. package/createStyled.js +32 -40
  16. package/createTheme/createBreakpoints.js +26 -24
  17. package/createTheme/createTheme.js +14 -18
  18. package/cssVars/createCssVarsProvider.js +26 -21
  19. package/cssVars/createCssVarsTheme.js +10 -10
  20. package/cssVars/getInitColorSchemeScript.d.ts +2 -2
  21. package/cssVars/prepareCssVars.js +12 -13
  22. package/cssVars/useCurrentColorScheme.js +11 -17
  23. package/esm/Container/createContainer.js +35 -41
  24. package/esm/Stack/createStack.js +26 -24
  25. package/esm/ThemeProvider/ThemeProvider.js +5 -9
  26. package/esm/Unstable_Grid/createGrid.js +23 -21
  27. package/esm/Unstable_Grid/gridGenerator.js +18 -62
  28. package/esm/Unstable_Grid/index.js +2 -1
  29. package/esm/Unstable_Grid/traverseBreakpoints.js +42 -0
  30. package/esm/breakpoints.js +6 -7
  31. package/esm/createBox.js +12 -9
  32. package/esm/createStyled.js +31 -38
  33. package/esm/createTheme/createBreakpoints.js +25 -24
  34. package/esm/createTheme/createTheme.js +14 -18
  35. package/esm/cssVars/createCssVarsProvider.js +26 -21
  36. package/esm/cssVars/createCssVarsTheme.js +10 -10
  37. package/esm/cssVars/prepareCssVars.js +12 -13
  38. package/esm/cssVars/useCurrentColorScheme.js +10 -17
  39. package/esm/propsToClassKey.js +5 -3
  40. package/esm/styleFunctionSx/extendSxProp.js +10 -14
  41. package/index.js +1 -1
  42. package/legacy/Container/createContainer.js +6 -7
  43. package/legacy/Stack/createStack.js +5 -6
  44. package/legacy/ThemeProvider/ThemeProvider.js +3 -4
  45. package/legacy/Unstable_Grid/createGrid.js +4 -6
  46. package/legacy/Unstable_Grid/gridGenerator.js +7 -54
  47. package/legacy/Unstable_Grid/index.js +2 -1
  48. package/legacy/Unstable_Grid/traverseBreakpoints.js +48 -0
  49. package/legacy/breakpoints.js +3 -5
  50. package/legacy/createBox.js +2 -4
  51. package/legacy/createStyled.js +11 -13
  52. package/legacy/createTheme/createBreakpoints.js +3 -4
  53. package/legacy/createTheme/createTheme.js +4 -6
  54. package/legacy/cssVars/createCssVarsProvider.js +5 -6
  55. package/legacy/cssVars/createCssVarsTheme.js +2 -4
  56. package/legacy/cssVars/prepareCssVars.js +3 -5
  57. package/legacy/cssVars/useCurrentColorScheme.js +7 -9
  58. package/legacy/index.js +1 -1
  59. package/legacy/styleFunctionSx/extendSxProp.js +4 -6
  60. package/modern/Container/createContainer.js +35 -41
  61. package/modern/Stack/createStack.js +26 -24
  62. package/modern/ThemeProvider/ThemeProvider.js +5 -9
  63. package/modern/Unstable_Grid/createGrid.js +23 -21
  64. package/modern/Unstable_Grid/gridGenerator.js +18 -62
  65. package/modern/Unstable_Grid/index.js +2 -1
  66. package/modern/Unstable_Grid/traverseBreakpoints.js +42 -0
  67. package/modern/breakpoints.js +6 -7
  68. package/modern/createBox.js +12 -9
  69. package/modern/createStyled.js +31 -38
  70. package/modern/createTheme/createBreakpoints.js +25 -24
  71. package/modern/createTheme/createTheme.js +14 -18
  72. package/modern/cssVars/createCssVarsProvider.js +26 -21
  73. package/modern/cssVars/createCssVarsTheme.js +10 -10
  74. package/modern/cssVars/prepareCssVars.js +12 -13
  75. package/modern/cssVars/useCurrentColorScheme.js +10 -17
  76. package/modern/index.js +1 -1
  77. package/modern/propsToClassKey.js +5 -3
  78. package/modern/styleFunctionSx/extendSxProp.js +10 -14
  79. package/package.json +2 -2
  80. package/propsToClassKey.js +6 -3
  81. package/styleFunctionSx/extendSxProp.js +10 -14
@@ -1,3 +1,5 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { traverseBreakpoints } from './traverseBreakpoints';
1
3
  function appendLevel(level) {
2
4
  if (!level) {
3
5
  return '';
@@ -26,48 +28,6 @@ function getParentColumns(ownerState) {
26
28
  }
27
29
  return `var(--Grid-columns${appendLevel(ownerState.unstable_level - 1)})`;
28
30
  }
29
- export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
30
- export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
31
- const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
32
-
33
- if (Array.isArray(responsive)) {
34
- responsive.forEach((breakpointValue, index) => {
35
- iterator((responsiveStyles, style) => {
36
- if (index <= breakpoints.keys.length - 1) {
37
- if (index === 0) {
38
- Object.assign(responsiveStyles, style);
39
- } else {
40
- responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
41
- }
42
- }
43
- }, breakpointValue);
44
- });
45
- } else if (responsive && typeof responsive === 'object') {
46
- // prevent null
47
- // responsive could be a very big object, pick the smallest responsive values
48
-
49
- const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
50
- keys.forEach(key => {
51
- if (breakpoints.keys.indexOf(key) !== -1) {
52
- // @ts-ignore already checked that responsive is an object
53
- const breakpointValue = responsive[key];
54
- if (breakpointValue !== undefined) {
55
- iterator((responsiveStyles, style) => {
56
- if (smallestBreakpoint === key) {
57
- Object.assign(responsiveStyles, style);
58
- } else {
59
- responsiveStyles[breakpoints.up(key)] = style;
60
- }
61
- }, breakpointValue);
62
- }
63
- }
64
- });
65
- } else if (typeof responsive === 'number' || typeof responsive === 'string') {
66
- iterator((responsiveStyles, style) => {
67
- Object.assign(responsiveStyles, style);
68
- }, responsive);
69
- }
70
- };
71
31
  export const generateGridSizeStyles = ({
72
32
  theme,
73
33
  ownerState
@@ -205,27 +165,23 @@ export const generateGridStyles = ({
205
165
  }) => {
206
166
  const getSelfSpacing = createGetSelfSpacing(ownerState);
207
167
  const getParentSpacing = createGetParentSpacing(ownerState);
208
- return {
168
+ return _extends({
209
169
  minWidth: 0,
210
- boxSizing: 'border-box',
211
- ...(ownerState.container && {
212
- display: 'flex',
213
- flexWrap: 'wrap',
214
- ...(ownerState.wrap && ownerState.wrap !== 'wrap' && {
215
- flexWrap: ownerState.wrap
216
- }),
217
- margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`,
218
- ...(ownerState.disableEqualOverflow && {
219
- margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
220
- })
221
- }),
222
- ...((!ownerState.container || isNestedContainer(ownerState)) && {
223
- padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`,
224
- ...((ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
225
- padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
226
- })
227
- })
228
- };
170
+ boxSizing: 'border-box'
171
+ }, ownerState.container && _extends({
172
+ display: 'flex',
173
+ flexWrap: 'wrap'
174
+ }, ownerState.wrap && ownerState.wrap !== 'wrap' && {
175
+ flexWrap: ownerState.wrap
176
+ }, {
177
+ margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`
178
+ }, ownerState.disableEqualOverflow && {
179
+ margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
180
+ }), (!ownerState.container || isNestedContainer(ownerState)) && _extends({
181
+ padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`
182
+ }, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
183
+ padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
184
+ }));
229
185
  };
230
186
  export const generateSizeClassNames = gridSize => {
231
187
  const classNames = [];
@@ -2,4 +2,5 @@ export { default } from './Grid';
2
2
  export { default as createGrid } from './createGrid';
3
3
  export * from './GridProps';
4
4
  export { default as gridClasses } from './gridClasses';
5
- export * from './gridClasses';
5
+ export * from './gridClasses';
6
+ export { traverseBreakpoints as unstable_traverseBreakpoints } from './traverseBreakpoints';
@@ -0,0 +1,42 @@
1
+ export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
2
+ export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
3
+ const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
4
+
5
+ if (Array.isArray(responsive)) {
6
+ responsive.forEach((breakpointValue, index) => {
7
+ iterator((responsiveStyles, style) => {
8
+ if (index <= breakpoints.keys.length - 1) {
9
+ if (index === 0) {
10
+ Object.assign(responsiveStyles, style);
11
+ } else {
12
+ responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
13
+ }
14
+ }
15
+ }, breakpointValue);
16
+ });
17
+ } else if (responsive && typeof responsive === 'object') {
18
+ // prevent null
19
+ // responsive could be a very big object, pick the smallest responsive values
20
+
21
+ const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
22
+ keys.forEach(key => {
23
+ if (breakpoints.keys.indexOf(key) !== -1) {
24
+ // @ts-ignore already checked that responsive is an object
25
+ const breakpointValue = responsive[key];
26
+ if (breakpointValue !== undefined) {
27
+ iterator((responsiveStyles, style) => {
28
+ if (smallestBreakpoint === key) {
29
+ Object.assign(responsiveStyles, style);
30
+ } else {
31
+ responsiveStyles[breakpoints.up(key)] = style;
32
+ }
33
+ }, breakpointValue);
34
+ }
35
+ }
36
+ });
37
+ } else if (typeof responsive === 'number' || typeof responsive === 'string') {
38
+ iterator((responsiveStyles, style) => {
39
+ Object.assign(responsiveStyles, style);
40
+ }, responsive);
41
+ }
42
+ };
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import PropTypes from 'prop-types';
2
3
  import { deepmerge } from '@mui/utils';
3
4
  import merge from './merge';
@@ -58,23 +59,21 @@ function breakpoints(styleFunction) {
58
59
  const extended = themeBreakpoints.keys.reduce((acc, key) => {
59
60
  if (props[key]) {
60
61
  acc = acc || {};
61
- acc[themeBreakpoints.up(key)] = styleFunction({
62
- theme,
63
- ...props[key]
64
- });
62
+ acc[themeBreakpoints.up(key)] = styleFunction(_extends({
63
+ theme
64
+ }, props[key]));
65
65
  }
66
66
  return acc;
67
67
  }, null);
68
68
  return merge(base, extended);
69
69
  };
70
- newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? {
71
- ...styleFunction.propTypes,
70
+ newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? _extends({}, styleFunction.propTypes, {
72
71
  xs: PropTypes.object,
73
72
  sm: PropTypes.object,
74
73
  md: PropTypes.object,
75
74
  lg: PropTypes.object,
76
75
  xl: PropTypes.object
77
- } : {};
76
+ }) : {};
78
77
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
79
78
  return newStyleFunction;
80
79
  }
package/esm/createBox.js CHANGED
@@ -1,3 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["className", "component"];
1
4
  import * as React from 'react';
2
5
  import clsx from 'clsx';
3
6
  import styled from '@mui/styled-engine';
@@ -16,18 +19,18 @@ export default function createBox(options = {}) {
16
19
  })(styleFunctionSx);
17
20
  const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
18
21
  const theme = useTheme(defaultTheme);
19
- const {
20
- className,
21
- component = 'div',
22
- ...other
23
- } = extendSxProp(inProps);
24
- return /*#__PURE__*/_jsx(BoxRoot, {
22
+ const _extendSxProp = extendSxProp(inProps),
23
+ {
24
+ className,
25
+ component = 'div'
26
+ } = _extendSxProp,
27
+ other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded);
28
+ return /*#__PURE__*/_jsx(BoxRoot, _extends({
25
29
  as: component,
26
30
  ref: ref,
27
31
  className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
28
- theme: themeId ? theme[themeId] || theme : theme,
29
- ...other
30
- });
32
+ theme: themeId ? theme[themeId] || theme : theme
33
+ }, other));
31
34
  });
32
35
  return Box;
33
36
  }
@@ -1,3 +1,6 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
1
4
  /* eslint-disable no-underscore-dangle */
2
5
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
3
6
  import { getDisplayName } from '@mui/utils';
@@ -80,27 +83,25 @@ export default function createStyled(input = {}) {
80
83
  slotShouldForwardProp = shouldForwardProp
81
84
  } = input;
82
85
  const systemSx = props => {
83
- return styleFunctionSx({
84
- ...props,
85
- theme: resolveTheme({
86
- ...props,
86
+ return styleFunctionSx(_extends({}, props, {
87
+ theme: resolveTheme(_extends({}, props, {
87
88
  defaultTheme,
88
89
  themeId
89
- })
90
- });
90
+ }))
91
+ }));
91
92
  };
92
93
  systemSx.__mui_systemSx = true;
93
94
  return (tag, inputOptions = {}) => {
94
95
  // Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
95
96
  processStyles(tag, styles => styles.filter(style => !(style != null && style.__mui_systemSx)));
96
97
  const {
97
- name: componentName,
98
- slot: componentSlot,
99
- skipVariantsResolver: inputSkipVariantsResolver,
100
- skipSx: inputSkipSx,
101
- overridesResolver,
102
- ...options
103
- } = inputOptions;
98
+ name: componentName,
99
+ slot: componentSlot,
100
+ skipVariantsResolver: inputSkipVariantsResolver,
101
+ skipSx: inputSkipSx,
102
+ overridesResolver
103
+ } = inputOptions,
104
+ options = _objectWithoutPropertiesLoose(inputOptions, _excluded);
104
105
 
105
106
  // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
106
107
  const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver : componentSlot && componentSlot !== 'Root' || false;
@@ -121,43 +122,38 @@ export default function createStyled(input = {}) {
121
122
  // for string (html) tag, preserve the behavior in emotion & styled-components.
122
123
  shouldForwardPropOption = undefined;
123
124
  }
124
- const defaultStyledResolver = styledEngineStyled(tag, {
125
+ const defaultStyledResolver = styledEngineStyled(tag, _extends({
125
126
  shouldForwardProp: shouldForwardPropOption,
126
- label,
127
- ...options
128
- });
127
+ label
128
+ }, options));
129
129
  const muiStyledResolver = (styleArg, ...expressions) => {
130
130
  const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => {
131
131
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
132
132
  // component stays as a function. This condition makes sure that we do not interpolate functions
133
133
  // which are basically components used as a selectors.
134
134
  return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
135
- return stylesArg({
136
- ...props,
137
- theme: resolveTheme({
138
- ...props,
135
+ return stylesArg(_extends({}, props, {
136
+ theme: resolveTheme(_extends({}, props, {
139
137
  defaultTheme,
140
138
  themeId
141
- })
142
- });
139
+ }))
140
+ }));
143
141
  } : stylesArg;
144
142
  }) : [];
145
143
  let transformedStyleArg = styleArg;
146
144
  if (componentName && overridesResolver) {
147
145
  expressionsWithDefaultTheme.push(props => {
148
- const theme = resolveTheme({
149
- ...props,
146
+ const theme = resolveTheme(_extends({}, props, {
150
147
  defaultTheme,
151
148
  themeId
152
- });
149
+ }));
153
150
  const styleOverrides = getStyleOverrides(componentName, theme);
154
151
  if (styleOverrides) {
155
152
  const resolvedStyleOverrides = {};
156
153
  Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
157
- resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle({
158
- ...props,
154
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
159
155
  theme
160
- }) : slotStyle;
156
+ })) : slotStyle;
161
157
  });
162
158
  return overridesResolver(props, resolvedStyleOverrides);
163
159
  }
@@ -166,11 +162,10 @@ export default function createStyled(input = {}) {
166
162
  }
167
163
  if (componentName && !skipVariantsResolver) {
168
164
  expressionsWithDefaultTheme.push(props => {
169
- const theme = resolveTheme({
170
- ...props,
165
+ const theme = resolveTheme(_extends({}, props, {
171
166
  defaultTheme,
172
167
  themeId
173
- });
168
+ }));
174
169
  return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
175
170
  });
176
171
  }
@@ -189,14 +184,12 @@ export default function createStyled(input = {}) {
189
184
  // which are basically components used as a selectors.
190
185
  styleArg.__emotion_real !== styleArg) {
191
186
  // If the type is function, we need to define the default theme.
192
- transformedStyleArg = props => styleArg({
193
- ...props,
194
- theme: resolveTheme({
195
- ...props,
187
+ transformedStyleArg = props => styleArg(_extends({}, props, {
188
+ theme: resolveTheme(_extends({}, props, {
196
189
  defaultTheme,
197
190
  themeId
198
- })
199
- });
191
+ }))
192
+ }));
200
193
  }
201
194
  const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
202
195
  if (process.env.NODE_ENV !== 'production') {
@@ -1,3 +1,6 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["values", "unit", "step"];
1
4
  // Sorted ASC by size. That's important.
2
5
  // It can't be configured as it's used statically for propTypes.
3
6
  export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
@@ -9,34 +12,33 @@ const sortBreakpointsValues = values => {
9
12
  // Sort in ascending order
10
13
  breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
11
14
  return breakpointsAsArray.reduce((acc, obj) => {
12
- return {
13
- ...acc,
15
+ return _extends({}, acc, {
14
16
  [obj.key]: obj.val
15
- };
17
+ });
16
18
  }, {});
17
19
  };
18
20
 
19
21
  // Keep in mind that @media is inclusive by the CSS specification.
20
22
  export default function createBreakpoints(breakpoints) {
21
23
  const {
22
- // The breakpoint **start** at this value.
23
- // For instance with the first breakpoint xs: [xs, sm).
24
- values = {
25
- xs: 0,
26
- // phone
27
- sm: 600,
28
- // tablet
29
- md: 900,
30
- // small laptop
31
- lg: 1200,
32
- // desktop
33
- xl: 1536 // large screen
34
- },
24
+ // The breakpoint **start** at this value.
25
+ // For instance with the first breakpoint xs: [xs, sm).
26
+ values = {
27
+ xs: 0,
28
+ // phone
29
+ sm: 600,
30
+ // tablet
31
+ md: 900,
32
+ // small laptop
33
+ lg: 1200,
34
+ // desktop
35
+ xl: 1536 // large screen
36
+ },
35
37
 
36
- unit = 'px',
37
- step = 5,
38
- ...other
39
- } = breakpoints;
38
+ unit = 'px',
39
+ step = 5
40
+ } = breakpoints,
41
+ other = _objectWithoutPropertiesLoose(breakpoints, _excluded);
40
42
  const sortedValues = sortBreakpointsValues(values);
41
43
  const keys = Object.keys(sortedValues);
42
44
  function up(key) {
@@ -68,7 +70,7 @@ export default function createBreakpoints(breakpoints) {
68
70
  }
69
71
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
70
72
  }
71
- return {
73
+ return _extends({
72
74
  keys,
73
75
  values: sortedValues,
74
76
  up,
@@ -76,7 +78,6 @@ export default function createBreakpoints(breakpoints) {
76
78
  between,
77
79
  only,
78
80
  not,
79
- unit,
80
- ...other
81
- };
81
+ unit
82
+ }, other);
82
83
  }
@@ -1,3 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["breakpoints", "palette", "spacing", "shape"];
1
4
  import { deepmerge } from '@mui/utils';
2
5
  import createBreakpoints from './createBreakpoints';
3
6
  import shape from './shape';
@@ -6,12 +9,12 @@ import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
6
9
  import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
7
10
  function createTheme(options = {}, ...args) {
8
11
  const {
9
- breakpoints: breakpointsInput = {},
10
- palette: paletteInput = {},
11
- spacing: spacingInput,
12
- shape: shapeInput = {},
13
- ...other
14
- } = options;
12
+ breakpoints: breakpointsInput = {},
13
+ palette: paletteInput = {},
14
+ spacing: spacingInput,
15
+ shape: shapeInput = {}
16
+ } = options,
17
+ other = _objectWithoutPropertiesLoose(options, _excluded);
15
18
  const breakpoints = createBreakpoints(breakpointsInput);
16
19
  const spacing = createSpacing(spacingInput);
17
20
  let muiTheme = deepmerge({
@@ -19,21 +22,14 @@ function createTheme(options = {}, ...args) {
19
22
  direction: 'ltr',
20
23
  components: {},
21
24
  // Inject component definitions.
22
- palette: {
23
- mode: 'light',
24
- ...paletteInput
25
- },
25
+ palette: _extends({
26
+ mode: 'light'
27
+ }, paletteInput),
26
28
  spacing,
27
- shape: {
28
- ...shape,
29
- ...shapeInput
30
- }
29
+ shape: _extends({}, shape, shapeInput)
31
30
  }, other);
32
31
  muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
33
- muiTheme.unstable_sxConfig = {
34
- ...defaultSxConfig,
35
- ...(other == null ? void 0 : other.unstable_sxConfig)
36
- };
32
+ muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other == null ? void 0 : other.unstable_sxConfig);
37
33
  muiTheme.unstable_sx = function sx(props) {
38
34
  return styleFunctionSx({
39
35
  sx: props,
@@ -1,4 +1,7 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
1
3
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
4
+ const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
2
5
  import * as React from 'react';
3
6
  import PropTypes from 'prop-types';
4
7
  import { deepmerge } from '@mui/utils';
@@ -13,6 +16,12 @@ export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-
13
16
  export default function createCssVarsProvider(options) {
14
17
  const {
15
18
  themeId,
19
+ /**
20
+ * This `theme` object needs to follow a certain structure to
21
+ * be used correctly by the finel `CssVarsProvider`. It should have a
22
+ * `colorSchemes` key with the light and dark (and any other) palette.
23
+ * It should also ideally have a vars object created using `prepareCssVars`.
24
+ */
16
25
  theme: defaultTheme = {},
17
26
  attribute: defaultAttribute = DEFAULT_ATTRIBUTE,
18
27
  modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
@@ -55,16 +64,17 @@ export default function createCssVarsProvider(options) {
55
64
  const ctx = React.useContext(ColorSchemeContext);
56
65
  const nested = !!ctx && !disableNestedContext;
57
66
  const scopedTheme = themeProp[themeId];
58
- const {
59
- colorSchemes = {},
60
- components = {},
61
- generateCssVars = () => ({
62
- vars: {},
63
- css: {}
64
- }),
65
- cssVarPrefix,
66
- ...restThemeProp
67
- } = scopedTheme || themeProp;
67
+ const _ref = scopedTheme || themeProp,
68
+ {
69
+ colorSchemes = {},
70
+ components = {},
71
+ generateCssVars = () => ({
72
+ vars: {},
73
+ css: {}
74
+ }),
75
+ cssVarPrefix
76
+ } = _ref,
77
+ restThemeProp = _objectWithoutPropertiesLoose(_ref, _excluded);
68
78
  const allColorSchemes = Object.keys(colorSchemes);
69
79
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
70
80
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -122,14 +132,13 @@ export default function createCssVarsProvider(options) {
122
132
  } = generateCssVars();
123
133
 
124
134
  // 3. Start composing the theme object
125
- const theme = {
126
- ...restThemeProp,
135
+ const theme = _extends({}, restThemeProp, {
127
136
  components,
128
137
  colorSchemes,
129
138
  cssVarPrefix,
130
139
  vars: rootVars,
131
140
  getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
132
- };
141
+ });
133
142
 
134
143
  // 4. Create color CSS variables and store them in objects (to be generated in stylesheets in the final step)
135
144
  // The default color scheme stylesheet is constructed to have the least CSS specificity.
@@ -147,10 +156,7 @@ export default function createCssVarsProvider(options) {
147
156
  Object.keys(scheme).forEach(schemeKey => {
148
157
  if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
149
158
  // shallow merge the 1st level structure of the theme.
150
- theme[schemeKey] = {
151
- ...theme[schemeKey],
152
- ...scheme[schemeKey]
153
- };
159
+ theme[schemeKey] = _extends({}, theme[schemeKey], scheme[schemeKey]);
154
160
  } else {
155
161
  theme[schemeKey] = scheme[schemeKey];
156
162
  }
@@ -320,15 +326,14 @@ export default function createCssVarsProvider(options) {
320
326
  } : void 0;
321
327
  const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
322
328
  const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
323
- const getInitColorSchemeScript = params => systemGetInitColorSchemeScript({
329
+ const getInitColorSchemeScript = params => systemGetInitColorSchemeScript(_extends({
324
330
  attribute: defaultAttribute,
325
331
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
326
332
  defaultMode: designSystemMode,
327
333
  defaultLightColorScheme,
328
334
  defaultDarkColorScheme,
329
- modeStorageKey: defaultModeStorageKey,
330
- ...params
331
- });
335
+ modeStorageKey: defaultModeStorageKey
336
+ }, params));
332
337
  return {
333
338
  CssVarsProvider,
334
339
  useColorScheme,
@@ -1,16 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["cssVarPrefix", "shouldSkipGeneratingVar"];
1
4
  import prepareCssVars from './prepareCssVars';
2
5
  function createCssVarsTheme(theme) {
3
6
  const {
4
- cssVarPrefix,
5
- shouldSkipGeneratingVar,
6
- ...otherTheme
7
- } = theme;
8
- return {
9
- ...theme,
10
- ...prepareCssVars(otherTheme, {
11
- prefix: cssVarPrefix,
7
+ cssVarPrefix,
12
8
  shouldSkipGeneratingVar
13
- })
14
- };
9
+ } = theme,
10
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
11
+ return _extends({}, theme, prepareCssVars(otherTheme, {
12
+ prefix: cssVarPrefix,
13
+ shouldSkipGeneratingVar
14
+ }));
15
15
  }
16
16
  export default createCssVarsTheme;
@@ -1,12 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["colorSchemes", "components"],
4
+ _excluded2 = ["light"];
1
5
  import { deepmerge } from '@mui/utils';
2
6
  import cssVarsParser from './cssVarsParser';
3
7
  function prepareCssVars(theme, parserConfig) {
4
8
  // @ts-ignore - ignore components do not exist
5
9
  const {
6
- colorSchemes = {},
7
- components,
8
- ...otherTheme
9
- } = theme;
10
+ colorSchemes = {}
11
+ } = theme,
12
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
10
13
  const {
11
14
  vars: rootVars,
12
15
  css: rootCss,
@@ -15,9 +18,9 @@ function prepareCssVars(theme, parserConfig) {
15
18
  let themeVars = rootVarsWithDefaults;
16
19
  const colorSchemesMap = {};
17
20
  const {
18
- light,
19
- ...otherColorSchemes
20
- } = colorSchemes;
21
+ light
22
+ } = colorSchemes,
23
+ otherColorSchemes = _objectWithoutPropertiesLoose(colorSchemes, _excluded2);
21
24
  Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
22
25
  const {
23
26
  vars,
@@ -46,16 +49,12 @@ function prepareCssVars(theme, parserConfig) {
46
49
  const generateCssVars = colorScheme => {
47
50
  if (!colorScheme) {
48
51
  return {
49
- css: {
50
- ...rootCss
51
- },
52
+ css: _extends({}, rootCss),
52
53
  vars: rootVars
53
54
  };
54
55
  }
55
56
  return {
56
- css: {
57
- ...colorSchemesMap[colorScheme].css
58
- },
57
+ css: _extends({}, colorSchemesMap[colorScheme].css),
59
58
  vars: colorSchemesMap[colorScheme].vars
60
59
  };
61
60
  };