@mui/system 6.0.0-alpha.5 → 6.0.0-alpha.8

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 (59) hide show
  1. package/CHANGELOG.md +131 -1
  2. package/Container/createContainer.js +41 -35
  3. package/RtlProvider/index.js +8 -11
  4. package/Stack/createStack.js +24 -26
  5. package/ThemeProvider/ThemeProvider.js +9 -5
  6. package/Unstable_Grid/createGrid.js +21 -23
  7. package/Unstable_Grid/gridGenerator.js +20 -17
  8. package/breakpoints/breakpoints.js +7 -6
  9. package/createBox/createBox.js +9 -12
  10. package/createStyled/createStyled.js +59 -51
  11. package/createTheme/createBreakpoints.js +24 -25
  12. package/createTheme/createTheme.js +18 -14
  13. package/cssContainerQueries/cssContainerQueries.js +6 -4
  14. package/cssVars/createCssVarsProvider.js +17 -16
  15. package/cssVars/createCssVarsTheme.js +3 -3
  16. package/cssVars/prepareCssVars.js +30 -25
  17. package/cssVars/useCurrentColorScheme.js +18 -11
  18. package/index.js +1 -1
  19. package/modern/Container/createContainer.js +41 -35
  20. package/modern/RtlProvider/index.js +8 -11
  21. package/modern/Stack/createStack.js +24 -26
  22. package/modern/ThemeProvider/ThemeProvider.js +9 -5
  23. package/modern/Unstable_Grid/createGrid.js +21 -23
  24. package/modern/Unstable_Grid/gridGenerator.js +20 -17
  25. package/modern/breakpoints/breakpoints.js +7 -6
  26. package/modern/createBox/createBox.js +9 -12
  27. package/modern/createStyled/createStyled.js +59 -51
  28. package/modern/createTheme/createBreakpoints.js +24 -25
  29. package/modern/createTheme/createTheme.js +18 -14
  30. package/modern/cssContainerQueries/cssContainerQueries.js +6 -4
  31. package/modern/cssVars/createCssVarsProvider.js +17 -16
  32. package/modern/cssVars/createCssVarsTheme.js +3 -3
  33. package/modern/cssVars/prepareCssVars.js +30 -25
  34. package/modern/cssVars/useCurrentColorScheme.js +18 -11
  35. package/modern/index.js +1 -1
  36. package/modern/propsToClassKey/propsToClassKey.js +3 -5
  37. package/modern/styleFunctionSx/extendSxProp.js +14 -10
  38. package/node/Container/createContainer.js +41 -35
  39. package/node/RtlProvider/index.js +8 -11
  40. package/node/Stack/createStack.js +24 -26
  41. package/node/ThemeProvider/ThemeProvider.js +9 -5
  42. package/node/Unstable_Grid/createGrid.js +21 -23
  43. package/node/Unstable_Grid/gridGenerator.js +20 -18
  44. package/node/breakpoints/breakpoints.js +7 -6
  45. package/node/createBox/createBox.js +9 -12
  46. package/node/createStyled/createStyled.js +61 -52
  47. package/node/createTheme/createBreakpoints.js +24 -26
  48. package/node/createTheme/createTheme.js +18 -14
  49. package/node/cssContainerQueries/cssContainerQueries.js +6 -4
  50. package/node/cssVars/createCssVarsProvider.js +17 -16
  51. package/node/cssVars/createCssVarsTheme.js +3 -3
  52. package/node/cssVars/prepareCssVars.js +30 -25
  53. package/node/cssVars/useCurrentColorScheme.js +18 -12
  54. package/node/index.js +1 -1
  55. package/node/propsToClassKey/propsToClassKey.js +3 -5
  56. package/node/styleFunctionSx/extendSxProp.js +14 -10
  57. package/package.json +5 -5
  58. package/propsToClassKey/propsToClassKey.js +3 -5
  59. package/styleFunctionSx/extendSxProp.js +14 -10
@@ -1,8 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["ownerState"],
4
- _excluded2 = ["variants"],
5
- _excluded3 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
6
1
  /* eslint-disable no-underscore-dangle */
7
2
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
8
3
  import { isPlainObject } from '@mui/utils/deepmerge';
@@ -47,31 +42,34 @@ function defaultOverridesResolver(slot) {
47
42
  }
48
43
  return (props, styles) => styles[slot];
49
44
  }
50
- function processStyleArg(callableStyle, _ref) {
51
- let {
52
- ownerState
53
- } = _ref,
54
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
55
- const resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle(_extends({
56
- ownerState
57
- }, props)) : callableStyle;
45
+ function processStyleArg(callableStyle, {
46
+ ownerState,
47
+ ...props
48
+ }) {
49
+ const resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle({
50
+ ownerState,
51
+ ...props
52
+ }) : callableStyle;
58
53
  if (Array.isArray(resolvedStylesArg)) {
59
- return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle, _extends({
60
- ownerState
61
- }, props)));
54
+ return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle, {
55
+ ownerState,
56
+ ...props
57
+ }));
62
58
  }
63
59
  if (!!resolvedStylesArg && typeof resolvedStylesArg === 'object' && Array.isArray(resolvedStylesArg.variants)) {
64
60
  const {
65
- variants = []
66
- } = resolvedStylesArg,
67
- otherStyles = _objectWithoutPropertiesLoose(resolvedStylesArg, _excluded2);
61
+ variants = [],
62
+ ...otherStyles
63
+ } = resolvedStylesArg;
68
64
  let result = otherStyles;
69
65
  variants.forEach(variant => {
70
66
  let isMatch = true;
71
67
  if (typeof variant.props === 'function') {
72
- isMatch = variant.props(_extends({
73
- ownerState
74
- }, props, ownerState));
68
+ isMatch = variant.props({
69
+ ownerState,
70
+ ...props,
71
+ ...ownerState
72
+ });
75
73
  } else {
76
74
  Object.keys(variant.props).forEach(key => {
77
75
  if (ownerState?.[key] !== variant.props[key] && props[key] !== variant.props[key]) {
@@ -83,9 +81,11 @@ function processStyleArg(callableStyle, _ref) {
83
81
  if (!Array.isArray(result)) {
84
82
  result = [result];
85
83
  }
86
- result.push(typeof variant.style === 'function' ? variant.style(_extends({
87
- ownerState
88
- }, props, ownerState)) : variant.style);
84
+ result.push(typeof variant.style === 'function' ? variant.style({
85
+ ownerState,
86
+ ...props,
87
+ ...ownerState
88
+ }) : variant.style);
89
89
  }
90
90
  });
91
91
  return result;
@@ -100,27 +100,29 @@ export default function createStyled(input = {}) {
100
100
  slotShouldForwardProp = shouldForwardProp
101
101
  } = input;
102
102
  const systemSx = props => {
103
- return styleFunctionSx(_extends({}, props, {
104
- theme: resolveTheme(_extends({}, props, {
103
+ return styleFunctionSx({
104
+ ...props,
105
+ theme: resolveTheme({
106
+ ...props,
105
107
  defaultTheme,
106
108
  themeId
107
- }))
108
- }));
109
+ })
110
+ });
109
111
  };
110
112
  systemSx.__mui_systemSx = true;
111
113
  return (tag, inputOptions = {}) => {
112
114
  // Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
113
115
  processStyles(tag, styles => styles.filter(style => !style?.__mui_systemSx));
114
116
  const {
115
- name: componentName,
116
- slot: componentSlot,
117
- skipVariantsResolver: inputSkipVariantsResolver,
118
- skipSx: inputSkipSx,
119
- // TODO v6: remove `lowercaseFirstLetter()` in the next major release
120
- // For more details: https://github.com/mui/material-ui/pull/37908
121
- overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot))
122
- } = inputOptions,
123
- options = _objectWithoutPropertiesLoose(inputOptions, _excluded3);
117
+ name: componentName,
118
+ slot: componentSlot,
119
+ skipVariantsResolver: inputSkipVariantsResolver,
120
+ skipSx: inputSkipSx,
121
+ // TODO v6: remove `lowercaseFirstLetter()` in the next major release
122
+ // For more details: https://github.com/mui/material-ui/pull/37908
123
+ overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot)),
124
+ ...options
125
+ } = inputOptions;
124
126
 
125
127
  // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
126
128
  const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
@@ -149,22 +151,24 @@ export default function createStyled(input = {}) {
149
151
  // for string (html) tag, preserve the behavior in emotion & styled-components.
150
152
  shouldForwardPropOption = undefined;
151
153
  }
152
- const defaultStyledResolver = styledEngineStyled(tag, _extends({
154
+ const defaultStyledResolver = styledEngineStyled(tag, {
153
155
  shouldForwardProp: shouldForwardPropOption,
154
- label
155
- }, options));
156
+ label,
157
+ ...options
158
+ });
156
159
  const transformStyleArg = stylesArg => {
157
160
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
158
161
  // component stays as a function. This condition makes sure that we do not interpolate functions
159
162
  // which are basically components used as a selectors.
160
163
  if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || isPlainObject(stylesArg)) {
161
- return props => processStyleArg(stylesArg, _extends({}, props, {
164
+ return props => processStyleArg(stylesArg, {
165
+ ...props,
162
166
  theme: resolveTheme({
163
167
  theme: props.theme,
164
168
  defaultTheme,
165
169
  themeId
166
170
  })
167
- }));
171
+ });
168
172
  }
169
173
  return stylesArg;
170
174
  };
@@ -173,10 +177,11 @@ export default function createStyled(input = {}) {
173
177
  const expressionsWithDefaultTheme = expressions ? expressions.map(transformStyleArg) : [];
174
178
  if (componentName && overridesResolver) {
175
179
  expressionsWithDefaultTheme.push(props => {
176
- const theme = resolveTheme(_extends({}, props, {
180
+ const theme = resolveTheme({
181
+ ...props,
177
182
  defaultTheme,
178
183
  themeId
179
- }));
184
+ });
180
185
  if (!theme.components || !theme.components[componentName] || !theme.components[componentName].styleOverrides) {
181
186
  return null;
182
187
  }
@@ -184,25 +189,28 @@ export default function createStyled(input = {}) {
184
189
  const resolvedStyleOverrides = {};
185
190
  // TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
186
191
  Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
187
- resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, _extends({}, props, {
192
+ resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, {
193
+ ...props,
188
194
  theme
189
- }));
195
+ });
190
196
  });
191
197
  return overridesResolver(props, resolvedStyleOverrides);
192
198
  });
193
199
  }
194
200
  if (componentName && !skipVariantsResolver) {
195
201
  expressionsWithDefaultTheme.push(props => {
196
- const theme = resolveTheme(_extends({}, props, {
202
+ const theme = resolveTheme({
203
+ ...props,
197
204
  defaultTheme,
198
205
  themeId
199
- }));
206
+ });
200
207
  const themeVariants = theme?.components?.[componentName]?.variants;
201
208
  return processStyleArg({
202
209
  variants: themeVariants
203
- }, _extends({}, props, {
210
+ }, {
211
+ ...props,
204
212
  theme
205
- }));
213
+ });
206
214
  });
207
215
  }
208
216
  if (!skipSx) {
@@ -1,6 +1,3 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["values", "unit", "step"];
4
1
  // Sorted ASC by size. That's important.
5
2
  // It can't be configured as it's used statically for propTypes.
6
3
  export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
@@ -12,32 +9,33 @@ const sortBreakpointsValues = values => {
12
9
  // Sort in ascending order
13
10
  breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
14
11
  return breakpointsAsArray.reduce((acc, obj) => {
15
- return _extends({}, acc, {
12
+ return {
13
+ ...acc,
16
14
  [obj.key]: obj.val
17
- });
15
+ };
18
16
  }, {});
19
17
  };
20
18
 
21
19
  // Keep in mind that @media is inclusive by the CSS specification.
22
20
  export default function createBreakpoints(breakpoints) {
23
21
  const {
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
- },
37
- unit = 'px',
38
- step = 5
39
- } = breakpoints,
40
- other = _objectWithoutPropertiesLoose(breakpoints, _excluded);
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
+ },
35
+ unit = 'px',
36
+ step = 5,
37
+ ...other
38
+ } = breakpoints;
41
39
  const sortedValues = sortBreakpointsValues(values);
42
40
  const keys = Object.keys(sortedValues);
43
41
  function up(key) {
@@ -69,7 +67,7 @@ export default function createBreakpoints(breakpoints) {
69
67
  }
70
68
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
71
69
  }
72
- return _extends({
70
+ return {
73
71
  keys,
74
72
  values: sortedValues,
75
73
  up,
@@ -77,6 +75,7 @@ export default function createBreakpoints(breakpoints) {
77
75
  between,
78
76
  only,
79
77
  not,
80
- unit
81
- }, other);
78
+ unit,
79
+ ...other
80
+ };
82
81
  }
@@ -1,6 +1,3 @@
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"];
4
1
  import deepmerge from '@mui/utils/deepmerge';
5
2
  import createBreakpoints from './createBreakpoints';
6
3
  import cssContainerQueries from '../cssContainerQueries';
@@ -11,12 +8,12 @@ import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
11
8
  import applyStyles from './applyStyles';
12
9
  function createTheme(options = {}, ...args) {
13
10
  const {
14
- breakpoints: breakpointsInput = {},
15
- palette: paletteInput = {},
16
- spacing: spacingInput,
17
- shape: shapeInput = {}
18
- } = options,
19
- other = _objectWithoutPropertiesLoose(options, _excluded);
11
+ breakpoints: breakpointsInput = {},
12
+ palette: paletteInput = {},
13
+ spacing: spacingInput,
14
+ shape: shapeInput = {},
15
+ ...other
16
+ } = options;
20
17
  const breakpoints = createBreakpoints(breakpointsInput);
21
18
  const spacing = createSpacing(spacingInput);
22
19
  let muiTheme = deepmerge({
@@ -24,16 +21,23 @@ function createTheme(options = {}, ...args) {
24
21
  direction: 'ltr',
25
22
  components: {},
26
23
  // Inject component definitions.
27
- palette: _extends({
28
- mode: 'light'
29
- }, paletteInput),
24
+ palette: {
25
+ mode: 'light',
26
+ ...paletteInput
27
+ },
30
28
  spacing,
31
- shape: _extends({}, shape, shapeInput)
29
+ shape: {
30
+ ...shape,
31
+ ...shapeInput
32
+ }
32
33
  }, other);
33
34
  muiTheme = cssContainerQueries(muiTheme);
34
35
  muiTheme.applyStyles = applyStyles;
35
36
  muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
36
- muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
37
+ muiTheme.unstable_sxConfig = {
38
+ ...defaultSxConfig,
39
+ ...other?.unstable_sxConfig
40
+ };
37
41
  muiTheme.unstable_sx = function sx(props) {
38
42
  return styleFunctionSx({
39
43
  sx: props,
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
3
2
  /**
4
3
  * For using in `sx` prop to sort the breakpoint from low to high.
@@ -22,7 +21,9 @@ export function sortContainerQueries(theme, css) {
22
21
  delete acc[key];
23
22
  acc[key] = value;
24
23
  return acc;
25
- }, _extends({}, css));
24
+ }, {
25
+ ...css
26
+ });
26
27
  }
27
28
  export function isCqShorthand(breakpointKeys, value) {
28
29
  return value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
@@ -62,7 +63,8 @@ export default function cssContainerQueries(themeInput) {
62
63
  return node;
63
64
  };
64
65
  attachCq(containerQueries);
65
- return _extends({}, themeInput, {
66
+ return {
67
+ ...themeInput,
66
68
  containerQueries
67
- });
69
+ };
68
70
  }
@@ -1,7 +1,4 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
1
  import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
4
- const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
5
2
  import * as React from 'react';
6
3
  import PropTypes from 'prop-types';
7
4
  import { GlobalStyles } from '@mui/styled-engine';
@@ -65,13 +62,12 @@ export default function createCssVarsProvider(options) {
65
62
  const ctx = React.useContext(ColorSchemeContext);
66
63
  const nested = !!ctx && !disableNestedContext;
67
64
  const scopedTheme = themeProp[themeId];
68
- const _ref = scopedTheme || themeProp,
69
- {
70
- colorSchemes = {},
71
- components = {},
72
- cssVarPrefix
73
- } = _ref,
74
- restThemeProp = _objectWithoutPropertiesLoose(_ref, _excluded);
65
+ const {
66
+ colorSchemes = {},
67
+ components = {},
68
+ cssVarPrefix,
69
+ ...restThemeProp
70
+ } = scopedTheme || themeProp;
75
71
  const allColorSchemes = Object.keys(colorSchemes);
76
72
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
77
73
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -126,12 +122,13 @@ export default function createCssVarsProvider(options) {
126
122
  const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
127
123
 
128
124
  // 3. Start composing the theme object
129
- const theme = _extends({}, restThemeProp, {
125
+ const theme = {
126
+ ...restThemeProp,
130
127
  components,
131
128
  colorSchemes,
132
129
  cssVarPrefix,
133
130
  vars: themeVars
134
- });
131
+ };
135
132
  if (typeof theme.generateSpacing === 'function') {
136
133
  theme.spacing = theme.generateSpacing();
137
134
  }
@@ -143,7 +140,10 @@ export default function createCssVarsProvider(options) {
143
140
  Object.keys(scheme).forEach(schemeKey => {
144
141
  if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
145
142
  // shallow merge the 1st level structure of the theme.
146
- theme[schemeKey] = _extends({}, theme[schemeKey], scheme[schemeKey]);
143
+ theme[schemeKey] = {
144
+ ...theme[schemeKey],
145
+ ...scheme[schemeKey]
146
+ };
147
147
  } else {
148
148
  theme[schemeKey] = scheme[schemeKey];
149
149
  }
@@ -299,14 +299,15 @@ export default function createCssVarsProvider(options) {
299
299
  } : void 0;
300
300
  const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
301
301
  const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
302
- const getInitColorSchemeScript = params => systemGetInitColorSchemeScript(_extends({
302
+ const getInitColorSchemeScript = params => systemGetInitColorSchemeScript({
303
303
  attribute: defaultAttribute,
304
304
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
305
305
  defaultMode: designSystemMode,
306
306
  defaultLightColorScheme,
307
307
  defaultDarkColorScheme,
308
- modeStorageKey: defaultModeStorageKey
309
- }, params));
308
+ modeStorageKey: defaultModeStorageKey,
309
+ ...params
310
+ });
310
311
  return {
311
312
  CssVarsProvider,
312
313
  useColorScheme,
@@ -1,10 +1,10 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
1
  import prepareCssVars from './prepareCssVars';
3
2
  function createCssVarsTheme(theme) {
4
3
  const output = theme;
5
- const result = prepareCssVars(output, _extends({}, theme, {
4
+ const result = prepareCssVars(output, {
5
+ ...theme,
6
6
  prefix: theme.cssVarPrefix
7
- }));
7
+ });
8
8
  output.vars = result.vars;
9
9
  output.generateThemeVars = result.generateThemeVars;
10
10
  output.generateStyleSheets = result.generateStyleSheets;
@@ -1,21 +1,16 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
3
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- const _excluded = ["getSelector"],
5
- _excluded2 = ["colorSchemes", "components", "defaultColorScheme"];
6
1
  import deepmerge from '@mui/utils/deepmerge';
7
2
  import cssVarsParser from './cssVarsParser';
8
- function prepareCssVars(theme, _ref = {}) {
9
- let {
10
- getSelector
11
- } = _ref,
12
- parserConfig = _objectWithoutPropertiesLoose(_ref, _excluded);
3
+ function prepareCssVars(theme, {
4
+ getSelector,
5
+ ...parserConfig
6
+ } = {}) {
13
7
  // @ts-ignore - ignore components do not exist
14
8
  const {
15
- colorSchemes = {},
16
- defaultColorScheme = 'light'
17
- } = theme,
18
- otherTheme = _objectWithoutPropertiesLoose(theme, _excluded2);
9
+ colorSchemes = {},
10
+ components,
11
+ defaultColorScheme = 'light',
12
+ ...otherTheme
13
+ } = theme;
19
14
  const {
20
15
  vars: rootVars,
21
16
  css: rootCss,
@@ -24,9 +19,9 @@ function prepareCssVars(theme, _ref = {}) {
24
19
  let themeVars = rootVarsWithDefaults;
25
20
  const colorSchemesMap = {};
26
21
  const {
27
- [defaultColorScheme]: defaultScheme
28
- } = colorSchemes,
29
- otherColorSchemes = _objectWithoutPropertiesLoose(colorSchemes, [defaultColorScheme].map(_toPropertyKey));
22
+ [defaultColorScheme]: defaultScheme,
23
+ ...otherColorSchemes
24
+ } = colorSchemes;
30
25
  Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
31
26
  const {
32
27
  vars,
@@ -53,7 +48,9 @@ function prepareCssVars(theme, _ref = {}) {
53
48
  };
54
49
  }
55
50
  const generateThemeVars = () => {
56
- let vars = _extends({}, rootVars);
51
+ let vars = {
52
+ ...rootVars
53
+ };
57
54
  Object.entries(colorSchemesMap).forEach(([, {
58
55
  vars: schemeVars
59
56
  }]) => {
@@ -67,26 +64,34 @@ function prepareCssVars(theme, _ref = {}) {
67
64
  function insertStyleSheet(selector, css) {
68
65
  if (Object.keys(css).length) {
69
66
  stylesheets.push(typeof selector === 'string' ? {
70
- [selector]: _extends({}, css)
67
+ [selector]: {
68
+ ...css
69
+ }
71
70
  } : selector);
72
71
  }
73
72
  }
74
- insertStyleSheet(getSelector?.(undefined, _extends({}, rootCss)) || ':root', rootCss);
73
+ insertStyleSheet(getSelector?.(undefined, {
74
+ ...rootCss
75
+ }) || ':root', rootCss);
75
76
  const {
76
- [colorScheme]: defaultSchemeVal
77
- } = colorSchemesMap,
78
- rest = _objectWithoutPropertiesLoose(colorSchemesMap, [colorScheme].map(_toPropertyKey));
77
+ [colorScheme]: defaultSchemeVal,
78
+ ...rest
79
+ } = colorSchemesMap;
79
80
  if (defaultSchemeVal) {
80
81
  // default color scheme has to come before other color schemes
81
82
  const {
82
83
  css
83
84
  } = defaultSchemeVal;
84
- insertStyleSheet(getSelector?.(colorScheme, _extends({}, css)) || `[${theme.attribute || 'data-color-scheme'}="${colorScheme}"]`, css);
85
+ insertStyleSheet(getSelector?.(colorScheme, {
86
+ ...css
87
+ }) || `[${theme.attribute || 'data-color-scheme'}="${colorScheme}"]`, css);
85
88
  }
86
89
  Object.entries(rest).forEach(([key, {
87
90
  css
88
91
  }]) => {
89
- insertStyleSheet(getSelector?.(key, _extends({}, css)) || `[${theme.attribute || 'data-color-scheme'}="${key}"]`, css);
92
+ insertStyleSheet(getSelector?.(key, {
93
+ ...css
94
+ }) || `[${theme.attribute || 'data-color-scheme'}="${key}"]`, css);
90
95
  });
91
96
  return stylesheets;
92
97
  };
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
3
  import * as React from 'react';
5
4
  import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from './getInitColorSchemeScript';
6
5
  export function getSystemMode(mode) {
@@ -84,10 +83,11 @@ export default function useCurrentColorScheme(options) {
84
83
  } catch (e) {
85
84
  // Unsupported
86
85
  }
87
- return _extends({}, currentState, {
86
+ return {
87
+ ...currentState,
88
88
  mode: newMode,
89
89
  systemMode: getSystemMode(newMode)
90
- });
90
+ };
91
91
  });
92
92
  }, [modeStorageKey, defaultMode]);
93
93
  const setColorScheme = React.useCallback(value => {
@@ -99,17 +99,20 @@ export default function useCurrentColorScheme(options) {
99
99
  } catch (e) {
100
100
  // Unsupported
101
101
  }
102
- return _extends({}, currentState, {
102
+ return {
103
+ ...currentState,
103
104
  lightColorScheme: defaultLightColorScheme,
104
105
  darkColorScheme: defaultDarkColorScheme
105
- });
106
+ };
106
107
  });
107
108
  } else if (typeof value === 'string') {
108
109
  if (value && !joinedColorSchemes.includes(value)) {
109
110
  console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
110
111
  } else {
111
112
  setState(currentState => {
112
- const newState = _extends({}, currentState);
113
+ const newState = {
114
+ ...currentState
115
+ };
113
116
  processState(currentState, mode => {
114
117
  try {
115
118
  localStorage.setItem(`${colorSchemeStorageKey}-${mode}`, value);
@@ -128,7 +131,9 @@ export default function useCurrentColorScheme(options) {
128
131
  }
129
132
  } else {
130
133
  setState(currentState => {
131
- const newState = _extends({}, currentState);
134
+ const newState = {
135
+ ...currentState
136
+ };
132
137
  const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
133
138
  const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
134
139
  if (newLightColorScheme) {
@@ -168,9 +173,10 @@ export default function useCurrentColorScheme(options) {
168
173
  if (currentState.systemMode === systemMode) {
169
174
  return currentState;
170
175
  }
171
- return _extends({}, currentState, {
176
+ return {
177
+ ...currentState,
172
178
  systemMode
173
- });
179
+ };
174
180
  });
175
181
  }
176
182
  }, [state.mode]);
@@ -222,9 +228,10 @@ export default function useCurrentColorScheme(options) {
222
228
  }
223
229
  return undefined;
224
230
  }, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
225
- return _extends({}, state, {
231
+ return {
232
+ ...state,
226
233
  colorScheme,
227
234
  setMode,
228
235
  setColorScheme
229
- });
236
+ };
230
237
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.5
2
+ * @mui/system v6.0.0-alpha.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the