@mui/system 6.1.9 → 6.1.10

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 6.1.10
4
+
5
+ <!-- generated comparing v6.1.9..master -->
6
+
7
+ _Dec 3, 2024_
8
+
9
+ A big thanks to the 10 contributors who made this release possible.
10
+
11
+ ### `@mui/material@6.1.10`
12
+
13
+ - [Avatar] Fix `slotProps.img` not spread to hook (#44536) @siriwatknp
14
+ - [FilledInput] Use `slotProps` instead of `componentsProps` (#44552) @siriwatknp
15
+ - [Grid2] Fix theme scoping error (#44599) @siriwatknp
16
+ - [Grid2] Add container styles from styleOverrides (#44598) @sai6855
17
+ - Skip `tonalOffset` from setting color channel (#44585) @siriwatknp
18
+ - Remove few more React.ReactElement<any> types (#44290) @sai6855
19
+ - [Tabs] Fix `ScrollbarSize` ref being overriden (#44593) @DiegoAndai
20
+ - [Select][TextField] Fix screen reader from saying `&ZeroWidthSpace` (#44631) @arishoham
21
+
22
+ ### `@mui/system@6.1.10`
23
+
24
+ - [ThemeProvider] Optimize `theme` changes when enabling CSS theme variables (#44588) @siriwatknp
25
+
26
+ ### Docs
27
+
28
+ - Notification for the MUI X v8 alpha zero announcement blog post (#44629) @joserodolfofreitas
29
+ - Bump React Router to ^7.0.1 (#44531) @oliviertassinari
30
+ - [material-ui] Replace testid with id in migration guide (#44636) @sai6855
31
+ - [material-ui][TextField] Update usage of `InputLabelProps` in docs (#44634) @sai6855
32
+ - [material-ui][ListItem] Add missing diffs in migration guide (#44638) @sai6855
33
+ - [examples] Use Next.js 14 on examples (#44486) @DiegoAndai
34
+ - Update links and sidebar nav for Base UI components in Material UI (#44581) @samuelsycamore
35
+
36
+ ### Core
37
+
38
+ - Remove `getSlotOwnerState` from `useSlot` util (#44403) @ZeeshanTamboli
39
+ - Extract useRippleHandler outside of ButtonBase (#44591) @albarv340
40
+ - Update eslint config (#44586) @MBilalShafi
41
+ - [core-infra] Remove useless fragments (#44516) @oliviertassinari
42
+ - [docs-infra] Fix Banner CLS (#44632) @oliviertassinari
43
+ - [docs-infra] Change CSS vars generation to be extracted from Enum (#44587) @mnajdova
44
+ - [docs-infra] Automatically hide Black Friday banner (#44630) @oliviertassinari
45
+ - [docs-infra] Fix TOC RTL padding regression (#44535) @oliviertassinari
46
+ - [test-utils] Remove leftover React.ReactElement<any> from describeConformance.tsx (#44639) @sai6855
47
+
48
+ All contributors of this release in alphabetical order: @albarv340, @arishoham, @DiegoAndai, @joserodolfofreitas, @MBilalShafi, @mnajdova, @oliviertassinari, @renovate[bot], @sai6855, @samuelsycamore, @siriwatknp, @ZeeshanTamboli
49
+
3
50
  ## 6.1.9
4
51
 
5
52
  <!-- generated comparing v6.1.8..master -->
@@ -1,11 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { OverridableComponent } from '@mui/types';
3
+ import useThemeSystem from '../useTheme';
3
4
  import { GridTypeMap } from './GridProps';
4
5
  declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
5
6
  declare function useThemePropsDefault<T extends {}>(props: T): T;
6
7
  export default function createGrid(options?: {
7
8
  createStyledComponent?: typeof defaultCreateStyledComponent;
8
9
  useThemeProps?: typeof useThemePropsDefault;
10
+ useTheme?: typeof useThemeSystem;
9
11
  componentName?: string;
10
12
  }): OverridableComponent<GridTypeMap<{}, "div">>;
11
13
  export {};
@@ -39,6 +39,7 @@ function createGrid(options = {}) {
39
39
  // This will allow adding custom styled fn (for example for custom sx style function)
40
40
  createStyledComponent = defaultCreateStyledComponent,
41
41
  useThemeProps = useThemePropsDefault,
42
+ useTheme = _useTheme.default,
42
43
  componentName = 'MuiGrid'
43
44
  } = options;
44
45
  const useUtilityClasses = (ownerState, theme) => {
@@ -79,7 +80,7 @@ function createGrid(options = {}) {
79
80
  }
80
81
  const GridRoot = createStyledComponent(_gridGenerator.generateGridColumnsStyles, _gridGenerator.generateGridColumnSpacingStyles, _gridGenerator.generateGridRowSpacingStyles, _gridGenerator.generateGridSizeStyles, _gridGenerator.generateGridDirectionStyles, _gridGenerator.generateGridStyles, _gridGenerator.generateGridOffsetStyles);
81
82
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
82
- const theme = (0, _useTheme.default)();
83
+ const theme = useTheme();
83
84
  const themeProps = useThemeProps(inProps);
84
85
  const props = (0, _styleFunctionSx.extendSxProp)(themeProps); // `color` type conflicts with html color attribute.
85
86
  const {
@@ -47,6 +47,8 @@ function createCssVarsProvider(options) {
47
47
  ColorSchemeContext.displayName = 'ColorSchemeContext';
48
48
  }
49
49
  const useColorScheme = () => React.useContext(ColorSchemeContext) || defaultContext;
50
+ const defaultColorSchemes = {};
51
+ const defaultComponents = {};
50
52
  function CssVarsProvider(props) {
51
53
  const {
52
54
  children,
@@ -73,12 +75,12 @@ function createCssVarsProvider(options) {
73
75
  return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
74
76
  }, [themeProp]);
75
77
  const scopedTheme = initialTheme[themeId];
78
+ const restThemeProp = scopedTheme || initialTheme;
76
79
  const {
77
- colorSchemes = {},
78
- components = {},
79
- cssVarPrefix,
80
- ...restThemeProp
81
- } = scopedTheme || initialTheme;
80
+ colorSchemes = defaultColorSchemes,
81
+ components = defaultComponents,
82
+ cssVarPrefix
83
+ } = restThemeProp;
82
84
  const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
83
85
  const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
84
86
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
@@ -110,43 +112,45 @@ function createCssVarsProvider(options) {
110
112
  mode = ctx.mode;
111
113
  colorScheme = ctx.colorScheme;
112
114
  }
115
+ const memoTheme = React.useMemo(() => {
116
+ // `colorScheme` is undefined on the server and hydration phase
117
+ const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
113
118
 
114
- // `colorScheme` is undefined on the server and hydration phase
115
- const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
119
+ // 2. get the `vars` object that refers to the CSS custom properties
120
+ const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
116
121
 
117
- // 2. get the `vars` object that refers to the CSS custom properties
118
- const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
119
-
120
- // 3. Start composing the theme object
121
- const theme = {
122
- ...restThemeProp,
123
- components,
124
- colorSchemes,
125
- cssVarPrefix,
126
- vars: themeVars
127
- };
128
- if (typeof theme.generateSpacing === 'function') {
129
- theme.spacing = theme.generateSpacing();
130
- }
122
+ // 3. Start composing the theme object
123
+ const theme = {
124
+ ...restThemeProp,
125
+ components,
126
+ colorSchemes,
127
+ cssVarPrefix,
128
+ vars: themeVars
129
+ };
130
+ if (typeof theme.generateSpacing === 'function') {
131
+ theme.spacing = theme.generateSpacing();
132
+ }
131
133
 
132
- // 4. Resolve the color scheme and merge it to the theme
133
- if (calculatedColorScheme) {
134
- const scheme = colorSchemes[calculatedColorScheme];
135
- if (scheme && typeof scheme === 'object') {
136
- // 4.1 Merge the selected color scheme to the theme
137
- Object.keys(scheme).forEach(schemeKey => {
138
- if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
139
- // shallow merge the 1st level structure of the theme.
140
- theme[schemeKey] = {
141
- ...theme[schemeKey],
142
- ...scheme[schemeKey]
143
- };
144
- } else {
145
- theme[schemeKey] = scheme[schemeKey];
146
- }
147
- });
134
+ // 4. Resolve the color scheme and merge it to the theme
135
+ if (calculatedColorScheme) {
136
+ const scheme = colorSchemes[calculatedColorScheme];
137
+ if (scheme && typeof scheme === 'object') {
138
+ // 4.1 Merge the selected color scheme to the theme
139
+ Object.keys(scheme).forEach(schemeKey => {
140
+ if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
141
+ // shallow merge the 1st level structure of the theme.
142
+ theme[schemeKey] = {
143
+ ...theme[schemeKey],
144
+ ...scheme[schemeKey]
145
+ };
146
+ } else {
147
+ theme[schemeKey] = scheme[schemeKey];
148
+ }
149
+ });
150
+ }
148
151
  }
149
- }
152
+ return resolveTheme ? resolveTheme(theme) : theme;
153
+ }, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
150
154
 
151
155
  // 5. Declaring effects
152
156
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -220,13 +224,13 @@ function createCssVarsProvider(options) {
220
224
  mode,
221
225
  setColorScheme,
222
226
  setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
223
- if (theme.colorSchemeSelector === 'media') {
227
+ if (memoTheme.colorSchemeSelector === 'media') {
224
228
  console.error(['MUI: The `setMode` function has no effect if `colorSchemeSelector` is `media` (`media` is the default value).', 'To toggle the mode manually, please configure `colorSchemeSelector` to use a class or data attribute.', 'To learn more, visit https://mui.com/material-ui/customization/css-theme-variables/configuration/#toggling-dark-mode-manually'].join('\n'));
225
229
  }
226
230
  setMode(newMode);
227
231
  },
228
232
  systemMode
229
- }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, theme.colorSchemeSelector]);
233
+ }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
230
234
  let shouldGenerateStyleSheet = true;
231
235
  if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
232
236
  shouldGenerateStyleSheet = false;
@@ -234,10 +238,10 @@ function createCssVarsProvider(options) {
234
238
  const element = /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
235
239
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
236
240
  themeId: scopedTheme ? themeId : undefined,
237
- theme: resolveTheme ? resolveTheme(theme) : theme,
241
+ theme: memoTheme,
238
242
  children: children
239
243
  }), shouldGenerateStyleSheet && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
240
- styles: theme.generateStyleSheets?.() || []
244
+ styles: memoTheme.generateStyleSheets?.() || []
241
245
  })]
242
246
  });
243
247
  if (nested) {
@@ -6,7 +6,7 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
7
  import systemStyled from "../styled/index.js";
8
8
  import useThemePropsSystem from "../useThemeProps/index.js";
9
- import useTheme from "../useTheme/index.js";
9
+ import useThemeSystem from "../useTheme/index.js";
10
10
  import { extendSxProp } from "../styleFunctionSx/index.js";
11
11
  import createTheme from "../createTheme/index.js";
12
12
  import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames, generateDirectionClasses } from "./gridGenerator.js";
@@ -31,6 +31,7 @@ export default function createGrid(options = {}) {
31
31
  // This will allow adding custom styled fn (for example for custom sx style function)
32
32
  createStyledComponent = defaultCreateStyledComponent,
33
33
  useThemeProps = useThemePropsDefault,
34
+ useTheme = useThemeSystem,
34
35
  componentName = 'MuiGrid'
35
36
  } = options;
36
37
  const useUtilityClasses = (ownerState, theme) => {
@@ -38,6 +38,8 @@ export default function createCssVarsProvider(options) {
38
38
  ColorSchemeContext.displayName = 'ColorSchemeContext';
39
39
  }
40
40
  const useColorScheme = () => React.useContext(ColorSchemeContext) || defaultContext;
41
+ const defaultColorSchemes = {};
42
+ const defaultComponents = {};
41
43
  function CssVarsProvider(props) {
42
44
  const {
43
45
  children,
@@ -64,12 +66,12 @@ export default function createCssVarsProvider(options) {
64
66
  return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
65
67
  }, [themeProp]);
66
68
  const scopedTheme = initialTheme[themeId];
69
+ const restThemeProp = scopedTheme || initialTheme;
67
70
  const {
68
- colorSchemes = {},
69
- components = {},
70
- cssVarPrefix,
71
- ...restThemeProp
72
- } = scopedTheme || initialTheme;
71
+ colorSchemes = defaultColorSchemes,
72
+ components = defaultComponents,
73
+ cssVarPrefix
74
+ } = restThemeProp;
73
75
  const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
74
76
  const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
75
77
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
@@ -101,43 +103,45 @@ export default function createCssVarsProvider(options) {
101
103
  mode = ctx.mode;
102
104
  colorScheme = ctx.colorScheme;
103
105
  }
106
+ const memoTheme = React.useMemo(() => {
107
+ // `colorScheme` is undefined on the server and hydration phase
108
+ const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
104
109
 
105
- // `colorScheme` is undefined on the server and hydration phase
106
- const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
110
+ // 2. get the `vars` object that refers to the CSS custom properties
111
+ const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
107
112
 
108
- // 2. get the `vars` object that refers to the CSS custom properties
109
- const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
110
-
111
- // 3. Start composing the theme object
112
- const theme = {
113
- ...restThemeProp,
114
- components,
115
- colorSchemes,
116
- cssVarPrefix,
117
- vars: themeVars
118
- };
119
- if (typeof theme.generateSpacing === 'function') {
120
- theme.spacing = theme.generateSpacing();
121
- }
113
+ // 3. Start composing the theme object
114
+ const theme = {
115
+ ...restThemeProp,
116
+ components,
117
+ colorSchemes,
118
+ cssVarPrefix,
119
+ vars: themeVars
120
+ };
121
+ if (typeof theme.generateSpacing === 'function') {
122
+ theme.spacing = theme.generateSpacing();
123
+ }
122
124
 
123
- // 4. Resolve the color scheme and merge it to the theme
124
- if (calculatedColorScheme) {
125
- const scheme = colorSchemes[calculatedColorScheme];
126
- if (scheme && typeof scheme === 'object') {
127
- // 4.1 Merge the selected color scheme to the theme
128
- Object.keys(scheme).forEach(schemeKey => {
129
- if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
130
- // shallow merge the 1st level structure of the theme.
131
- theme[schemeKey] = {
132
- ...theme[schemeKey],
133
- ...scheme[schemeKey]
134
- };
135
- } else {
136
- theme[schemeKey] = scheme[schemeKey];
137
- }
138
- });
125
+ // 4. Resolve the color scheme and merge it to the theme
126
+ if (calculatedColorScheme) {
127
+ const scheme = colorSchemes[calculatedColorScheme];
128
+ if (scheme && typeof scheme === 'object') {
129
+ // 4.1 Merge the selected color scheme to the theme
130
+ Object.keys(scheme).forEach(schemeKey => {
131
+ if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
132
+ // shallow merge the 1st level structure of the theme.
133
+ theme[schemeKey] = {
134
+ ...theme[schemeKey],
135
+ ...scheme[schemeKey]
136
+ };
137
+ } else {
138
+ theme[schemeKey] = scheme[schemeKey];
139
+ }
140
+ });
141
+ }
139
142
  }
140
- }
143
+ return resolveTheme ? resolveTheme(theme) : theme;
144
+ }, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
141
145
 
142
146
  // 5. Declaring effects
143
147
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -211,13 +215,13 @@ export default function createCssVarsProvider(options) {
211
215
  mode,
212
216
  setColorScheme,
213
217
  setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
214
- if (theme.colorSchemeSelector === 'media') {
218
+ if (memoTheme.colorSchemeSelector === 'media') {
215
219
  console.error(['MUI: The `setMode` function has no effect if `colorSchemeSelector` is `media` (`media` is the default value).', 'To toggle the mode manually, please configure `colorSchemeSelector` to use a class or data attribute.', 'To learn more, visit https://mui.com/material-ui/customization/css-theme-variables/configuration/#toggling-dark-mode-manually'].join('\n'));
216
220
  }
217
221
  setMode(newMode);
218
222
  },
219
223
  systemMode
220
- }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, theme.colorSchemeSelector]);
224
+ }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
221
225
  let shouldGenerateStyleSheet = true;
222
226
  if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
223
227
  shouldGenerateStyleSheet = false;
@@ -225,10 +229,10 @@ export default function createCssVarsProvider(options) {
225
229
  const element = /*#__PURE__*/_jsxs(React.Fragment, {
226
230
  children: [/*#__PURE__*/_jsx(ThemeProvider, {
227
231
  themeId: scopedTheme ? themeId : undefined,
228
- theme: resolveTheme ? resolveTheme(theme) : theme,
232
+ theme: memoTheme,
229
233
  children: children
230
234
  }), shouldGenerateStyleSheet && /*#__PURE__*/_jsx(GlobalStyles, {
231
- styles: theme.generateStyleSheets?.() || []
235
+ styles: memoTheme.generateStyleSheets?.() || []
232
236
  })]
233
237
  });
234
238
  if (nested) {
@@ -1,6 +1,6 @@
1
- export const version = "6.1.9";
1
+ export const version = "6.1.10";
2
2
  export const major = Number("6");
3
3
  export const minor = Number("1");
4
- export const patch = Number("9");
4
+ export const patch = Number("10");
5
5
  export const prerelease = undefined;
6
6
  export default version;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.1.9
2
+ * @mui/system v6.1.10
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -6,7 +6,7 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
6
6
  import composeClasses from '@mui/utils/composeClasses';
7
7
  import systemStyled from "../styled/index.js";
8
8
  import useThemePropsSystem from "../useThemeProps/index.js";
9
- import useTheme from "../useTheme/index.js";
9
+ import useThemeSystem from "../useTheme/index.js";
10
10
  import { extendSxProp } from "../styleFunctionSx/index.js";
11
11
  import createTheme from "../createTheme/index.js";
12
12
  import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames, generateDirectionClasses } from "./gridGenerator.js";
@@ -31,6 +31,7 @@ export default function createGrid(options = {}) {
31
31
  // This will allow adding custom styled fn (for example for custom sx style function)
32
32
  createStyledComponent = defaultCreateStyledComponent,
33
33
  useThemeProps = useThemePropsDefault,
34
+ useTheme = useThemeSystem,
34
35
  componentName = 'MuiGrid'
35
36
  } = options;
36
37
  const useUtilityClasses = (ownerState, theme) => {
@@ -38,6 +38,8 @@ export default function createCssVarsProvider(options) {
38
38
  ColorSchemeContext.displayName = 'ColorSchemeContext';
39
39
  }
40
40
  const useColorScheme = () => React.useContext(ColorSchemeContext) || defaultContext;
41
+ const defaultColorSchemes = {};
42
+ const defaultComponents = {};
41
43
  function CssVarsProvider(props) {
42
44
  const {
43
45
  children,
@@ -64,12 +66,12 @@ export default function createCssVarsProvider(options) {
64
66
  return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
65
67
  }, [themeProp]);
66
68
  const scopedTheme = initialTheme[themeId];
69
+ const restThemeProp = scopedTheme || initialTheme;
67
70
  const {
68
- colorSchemes = {},
69
- components = {},
70
- cssVarPrefix,
71
- ...restThemeProp
72
- } = scopedTheme || initialTheme;
71
+ colorSchemes = defaultColorSchemes,
72
+ components = defaultComponents,
73
+ cssVarPrefix
74
+ } = restThemeProp;
73
75
  const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
74
76
  const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
75
77
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
@@ -101,43 +103,45 @@ export default function createCssVarsProvider(options) {
101
103
  mode = ctx.mode;
102
104
  colorScheme = ctx.colorScheme;
103
105
  }
106
+ const memoTheme = React.useMemo(() => {
107
+ // `colorScheme` is undefined on the server and hydration phase
108
+ const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
104
109
 
105
- // `colorScheme` is undefined on the server and hydration phase
106
- const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
110
+ // 2. get the `vars` object that refers to the CSS custom properties
111
+ const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
107
112
 
108
- // 2. get the `vars` object that refers to the CSS custom properties
109
- const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
110
-
111
- // 3. Start composing the theme object
112
- const theme = {
113
- ...restThemeProp,
114
- components,
115
- colorSchemes,
116
- cssVarPrefix,
117
- vars: themeVars
118
- };
119
- if (typeof theme.generateSpacing === 'function') {
120
- theme.spacing = theme.generateSpacing();
121
- }
113
+ // 3. Start composing the theme object
114
+ const theme = {
115
+ ...restThemeProp,
116
+ components,
117
+ colorSchemes,
118
+ cssVarPrefix,
119
+ vars: themeVars
120
+ };
121
+ if (typeof theme.generateSpacing === 'function') {
122
+ theme.spacing = theme.generateSpacing();
123
+ }
122
124
 
123
- // 4. Resolve the color scheme and merge it to the theme
124
- if (calculatedColorScheme) {
125
- const scheme = colorSchemes[calculatedColorScheme];
126
- if (scheme && typeof scheme === 'object') {
127
- // 4.1 Merge the selected color scheme to the theme
128
- Object.keys(scheme).forEach(schemeKey => {
129
- if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
130
- // shallow merge the 1st level structure of the theme.
131
- theme[schemeKey] = {
132
- ...theme[schemeKey],
133
- ...scheme[schemeKey]
134
- };
135
- } else {
136
- theme[schemeKey] = scheme[schemeKey];
137
- }
138
- });
125
+ // 4. Resolve the color scheme and merge it to the theme
126
+ if (calculatedColorScheme) {
127
+ const scheme = colorSchemes[calculatedColorScheme];
128
+ if (scheme && typeof scheme === 'object') {
129
+ // 4.1 Merge the selected color scheme to the theme
130
+ Object.keys(scheme).forEach(schemeKey => {
131
+ if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
132
+ // shallow merge the 1st level structure of the theme.
133
+ theme[schemeKey] = {
134
+ ...theme[schemeKey],
135
+ ...scheme[schemeKey]
136
+ };
137
+ } else {
138
+ theme[schemeKey] = scheme[schemeKey];
139
+ }
140
+ });
141
+ }
139
142
  }
140
- }
143
+ return resolveTheme ? resolveTheme(theme) : theme;
144
+ }, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
141
145
 
142
146
  // 5. Declaring effects
143
147
  // 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
@@ -211,13 +215,13 @@ export default function createCssVarsProvider(options) {
211
215
  mode,
212
216
  setColorScheme,
213
217
  setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
214
- if (theme.colorSchemeSelector === 'media') {
218
+ if (memoTheme.colorSchemeSelector === 'media') {
215
219
  console.error(['MUI: The `setMode` function has no effect if `colorSchemeSelector` is `media` (`media` is the default value).', 'To toggle the mode manually, please configure `colorSchemeSelector` to use a class or data attribute.', 'To learn more, visit https://mui.com/material-ui/customization/css-theme-variables/configuration/#toggling-dark-mode-manually'].join('\n'));
216
220
  }
217
221
  setMode(newMode);
218
222
  },
219
223
  systemMode
220
- }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, theme.colorSchemeSelector]);
224
+ }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
221
225
  let shouldGenerateStyleSheet = true;
222
226
  if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
223
227
  shouldGenerateStyleSheet = false;
@@ -225,10 +229,10 @@ export default function createCssVarsProvider(options) {
225
229
  const element = /*#__PURE__*/_jsxs(React.Fragment, {
226
230
  children: [/*#__PURE__*/_jsx(ThemeProvider, {
227
231
  themeId: scopedTheme ? themeId : undefined,
228
- theme: resolveTheme ? resolveTheme(theme) : theme,
232
+ theme: memoTheme,
229
233
  children: children
230
234
  }), shouldGenerateStyleSheet && /*#__PURE__*/_jsx(GlobalStyles, {
231
- styles: theme.generateStyleSheets?.() || []
235
+ styles: memoTheme.generateStyleSheets?.() || []
232
236
  })]
233
237
  });
234
238
  if (nested) {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.1.9
2
+ * @mui/system v6.1.10
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,6 @@
1
- export const version = "6.1.9";
1
+ export const version = "6.1.10";
2
2
  export const major = Number("6");
3
3
  export const minor = Number("1");
4
- export const patch = Number("9");
4
+ export const patch = Number("10");
5
5
  export const prerelease = undefined;
6
6
  export default version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "6.1.9",
3
+ "version": "6.1.10",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
@@ -30,10 +30,10 @@
30
30
  "clsx": "^2.1.1",
31
31
  "csstype": "^3.1.3",
32
32
  "prop-types": "^15.8.1",
33
- "@mui/private-theming": "^6.1.9",
33
+ "@mui/styled-engine": "^6.1.10",
34
+ "@mui/private-theming": "^6.1.10",
34
35
  "@mui/types": "^7.2.19",
35
- "@mui/styled-engine": "^6.1.9",
36
- "@mui/utils": "^6.1.9"
36
+ "@mui/utils": "^6.1.10"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@emotion/react": "^11.5.0",
package/version/index.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = exports.prerelease = exports.patch = exports.minor = exports.major = exports.default = void 0;
7
- const version = exports.version = "6.1.9";
7
+ const version = exports.version = "6.1.10";
8
8
  const major = exports.major = Number("6");
9
9
  const minor = exports.minor = Number("1");
10
- const patch = exports.patch = Number("9");
10
+ const patch = exports.patch = Number("10");
11
11
  const prerelease = exports.prerelease = undefined;
12
12
  var _default = exports.default = version;