@mui/system 6.1.8 → 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 +95 -2
- package/Grid/createGrid.d.ts +2 -0
- package/Grid/createGrid.js +2 -1
- package/cssVars/createCssVarsProvider.js +55 -44
- package/cssVars/useCurrentColorScheme.d.ts +1 -0
- package/cssVars/useCurrentColorScheme.js +8 -12
- package/esm/Grid/createGrid.js +2 -1
- package/esm/cssVars/createCssVarsProvider.js +55 -44
- package/esm/cssVars/useCurrentColorScheme.js +8 -12
- package/esm/version/index.js +2 -2
- package/index.js +1 -1
- package/modern/Grid/createGrid.js +2 -1
- package/modern/cssVars/createCssVarsProvider.js +55 -44
- package/modern/cssVars/useCurrentColorScheme.js +8 -12
- package/modern/index.js +1 -1
- package/modern/version/index.js +2 -2
- package/package.json +4 -4
- package/version/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,100 @@
|
|
|
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
|
+
|
|
50
|
+
## 6.1.9
|
|
51
|
+
|
|
52
|
+
<!-- generated comparing v6.1.8..master -->
|
|
53
|
+
|
|
54
|
+
_Nov 27, 2024_
|
|
55
|
+
|
|
56
|
+
A big thanks to the 8 contributors who made this release possible.
|
|
57
|
+
|
|
58
|
+
### `@mui/material@6.1.9`
|
|
59
|
+
|
|
60
|
+
- [Select] Omit `placeholder` from props (#44502) @Juneezee
|
|
61
|
+
- [Grid2] Add container class to `Grid2Classes` (#44562) @sai6855
|
|
62
|
+
|
|
63
|
+
### `@mui/system@6.1.9`
|
|
64
|
+
|
|
65
|
+
- Add ThemeProvider `noSsr` to prevent double rendering (#44451) @siriwatknp
|
|
66
|
+
|
|
67
|
+
### `@mui/codemod@6.1.9`
|
|
68
|
+
|
|
69
|
+
- [codemod] Fix handling of computed `paragraph` props (#44195) @joshkel
|
|
70
|
+
|
|
71
|
+
### `@mui/material-pigment-css@6.1.9`
|
|
72
|
+
|
|
73
|
+
- Make @pigment-css/react as peer dependency (#44498) @brijeshb42
|
|
74
|
+
|
|
75
|
+
### Docs
|
|
76
|
+
|
|
77
|
+
- [material-ui] Add missing required dependencies in dashboard template README (#44476) @mesqueeb
|
|
78
|
+
- [material-ui] Add missing Roboto import to Next.js integration docs (#44462) @StaceyD22
|
|
79
|
+
- [material-ui][Dialog] Fix padding in SimpleDialog demo (#44467) @oliviertassinari
|
|
80
|
+
- Fix template page issues (#44466) @oliviertassinari
|
|
81
|
+
- [examples] Add dark mode example for Material UI + Pigment CSS (#44480) @mnajdova
|
|
82
|
+
|
|
83
|
+
### Core
|
|
84
|
+
|
|
85
|
+
- Remove TODO line in the changelog (#44484) @mnajdova
|
|
86
|
+
- Polish image display (418e888) @oliviertassinari
|
|
87
|
+
- [core-infra] Add no-relative-packages (#44489) @oliviertassinari
|
|
88
|
+
- [docs-infra] Support CSS variables API info (#44559) @mnajdova
|
|
89
|
+
- [docs-infra] Fix display when ad-block triggers (#44567) @oliviertassinari
|
|
90
|
+
- [docs-infra] Improve locator finding using visible option (#44541) @siriwatknp
|
|
91
|
+
- [docs-infra] Correctly flatten the pages tree (#44514) @oliviertassinari
|
|
92
|
+
- [docs-infra] Fix Sponsor design regression (#44515) @oliviertassinari
|
|
93
|
+
- [test] Remove React.ReactElement<any> from describeConformance.tsx (#44318) @sai6855
|
|
94
|
+
- [test] Do not enforce the presence of `ownerState.className` in `describeConformance` (#44479) @flaviendelangle
|
|
95
|
+
|
|
96
|
+
All contributors of this release in alphabetical order: @brijeshb42, @flaviendelangle, @joshkel, @Juneezee, @mesqueeb, @mnajdova, @oliviertassinari, @sai6855, @siriwatknp, @StaceyD22
|
|
97
|
+
|
|
3
98
|
## v6.1.8
|
|
4
99
|
|
|
5
100
|
<!-- generated comparing v6.1.7..master -->
|
|
@@ -8,8 +103,6 @@ _Nov 20, 2024_
|
|
|
8
103
|
|
|
9
104
|
A big thanks to the 10 contributors who made this release possible.
|
|
10
105
|
|
|
11
|
-
TODO INSERT HIGHLIGHTS
|
|
12
|
-
|
|
13
106
|
### `@mui/material@6.1.8`
|
|
14
107
|
|
|
15
108
|
- [Autocomplete] Use `ul` element for the listbox (#44422) @DiegoAndai
|
package/Grid/createGrid.d.ts
CHANGED
|
@@ -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 {};
|
package/Grid/createGrid.js
CHANGED
|
@@ -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 = (
|
|
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,
|
|
@@ -59,7 +61,8 @@ function createCssVarsProvider(options) {
|
|
|
59
61
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
60
62
|
disableNestedContext = false,
|
|
61
63
|
disableStyleSheetGeneration = false,
|
|
62
|
-
defaultMode: initialMode = 'system'
|
|
64
|
+
defaultMode: initialMode = 'system',
|
|
65
|
+
noSsr
|
|
63
66
|
} = props;
|
|
64
67
|
const hasMounted = React.useRef(false);
|
|
65
68
|
const upperTheme = (0, _privateTheming.useTheme)();
|
|
@@ -72,12 +75,12 @@ function createCssVarsProvider(options) {
|
|
|
72
75
|
return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
|
|
73
76
|
}, [themeProp]);
|
|
74
77
|
const scopedTheme = initialTheme[themeId];
|
|
78
|
+
const restThemeProp = scopedTheme || initialTheme;
|
|
75
79
|
const {
|
|
76
|
-
colorSchemes =
|
|
77
|
-
components =
|
|
78
|
-
cssVarPrefix
|
|
79
|
-
|
|
80
|
-
} = scopedTheme || initialTheme;
|
|
80
|
+
colorSchemes = defaultColorSchemes,
|
|
81
|
+
components = defaultComponents,
|
|
82
|
+
cssVarPrefix
|
|
83
|
+
} = restThemeProp;
|
|
81
84
|
const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
|
|
82
85
|
const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
|
|
83
86
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
@@ -100,7 +103,8 @@ function createCssVarsProvider(options) {
|
|
|
100
103
|
modeStorageKey,
|
|
101
104
|
colorSchemeStorageKey,
|
|
102
105
|
defaultMode,
|
|
103
|
-
storageWindow
|
|
106
|
+
storageWindow,
|
|
107
|
+
noSsr
|
|
104
108
|
});
|
|
105
109
|
let mode = stateMode;
|
|
106
110
|
let colorScheme = stateColorScheme;
|
|
@@ -108,43 +112,45 @@ function createCssVarsProvider(options) {
|
|
|
108
112
|
mode = ctx.mode;
|
|
109
113
|
colorScheme = ctx.colorScheme;
|
|
110
114
|
}
|
|
115
|
+
const memoTheme = React.useMemo(() => {
|
|
116
|
+
// `colorScheme` is undefined on the server and hydration phase
|
|
117
|
+
const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
// 2. get the `vars` object that refers to the CSS custom properties
|
|
120
|
+
const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
|
|
114
121
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (typeof theme.generateSpacing === 'function') {
|
|
127
|
-
theme.spacing = theme.generateSpacing();
|
|
128
|
-
}
|
|
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
|
+
}
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
}
|
|
146
151
|
}
|
|
147
|
-
|
|
152
|
+
return resolveTheme ? resolveTheme(theme) : theme;
|
|
153
|
+
}, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
|
|
148
154
|
|
|
149
155
|
// 5. Declaring effects
|
|
150
156
|
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
|
|
@@ -218,13 +224,13 @@ function createCssVarsProvider(options) {
|
|
|
218
224
|
mode,
|
|
219
225
|
setColorScheme,
|
|
220
226
|
setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
|
|
221
|
-
if (
|
|
227
|
+
if (memoTheme.colorSchemeSelector === 'media') {
|
|
222
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'));
|
|
223
229
|
}
|
|
224
230
|
setMode(newMode);
|
|
225
231
|
},
|
|
226
232
|
systemMode
|
|
227
|
-
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode,
|
|
233
|
+
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
|
|
228
234
|
let shouldGenerateStyleSheet = true;
|
|
229
235
|
if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
|
|
230
236
|
shouldGenerateStyleSheet = false;
|
|
@@ -232,10 +238,10 @@ function createCssVarsProvider(options) {
|
|
|
232
238
|
const element = /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
233
239
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
|
|
234
240
|
themeId: scopedTheme ? themeId : undefined,
|
|
235
|
-
theme:
|
|
241
|
+
theme: memoTheme,
|
|
236
242
|
children: children
|
|
237
243
|
}), shouldGenerateStyleSheet && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
|
|
238
|
-
styles:
|
|
244
|
+
styles: memoTheme.generateStyleSheets?.() || []
|
|
239
245
|
})]
|
|
240
246
|
});
|
|
241
247
|
if (nested) {
|
|
@@ -286,6 +292,11 @@ function createCssVarsProvider(options) {
|
|
|
286
292
|
* The key in the local storage used to store current color scheme.
|
|
287
293
|
*/
|
|
288
294
|
modeStorageKey: _propTypes.default.string,
|
|
295
|
+
/**
|
|
296
|
+
* If `true`, the mode will be the same value as the storage without an extra rerendering after the hydration.
|
|
297
|
+
* You should use this option in conjuction with `InitColorSchemeScript` component.
|
|
298
|
+
*/
|
|
299
|
+
noSsr: _propTypes.default.bool,
|
|
289
300
|
/**
|
|
290
301
|
* The window that attaches the 'storage' event listener.
|
|
291
302
|
* @default window
|
|
@@ -48,6 +48,7 @@ interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
|
|
|
48
48
|
modeStorageKey?: string;
|
|
49
49
|
colorSchemeStorageKey?: string;
|
|
50
50
|
storageWindow?: Window | null;
|
|
51
|
+
noSsr?: boolean;
|
|
51
52
|
}
|
|
52
53
|
export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
|
|
53
54
|
export {};
|
|
@@ -64,7 +64,8 @@ function useCurrentColorScheme(options) {
|
|
|
64
64
|
supportedColorSchemes = [],
|
|
65
65
|
modeStorageKey = _InitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
|
|
66
66
|
colorSchemeStorageKey = _InitColorSchemeScript.DEFAULT_COLOR_SCHEME_STORAGE_KEY,
|
|
67
|
-
storageWindow = typeof window === 'undefined' ? undefined : window
|
|
67
|
+
storageWindow = typeof window === 'undefined' ? undefined : window,
|
|
68
|
+
noSsr = false
|
|
68
69
|
} = options;
|
|
69
70
|
const joinedColorSchemes = supportedColorSchemes.join(',');
|
|
70
71
|
const isMultiSchemes = supportedColorSchemes.length > 1;
|
|
@@ -79,15 +80,10 @@ function useCurrentColorScheme(options) {
|
|
|
79
80
|
darkColorScheme
|
|
80
81
|
};
|
|
81
82
|
});
|
|
82
|
-
|
|
83
|
-
const [, setHasMounted] = React.useState(false);
|
|
84
|
-
const hasMounted = React.useRef(false);
|
|
83
|
+
const [isClient, setIsClient] = React.useState(noSsr || !isMultiSchemes);
|
|
85
84
|
React.useEffect(() => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
hasMounted.current = true;
|
|
90
|
-
}, [isMultiSchemes]);
|
|
85
|
+
setIsClient(true); // to rerender the component after hydration
|
|
86
|
+
}, []);
|
|
91
87
|
const colorScheme = getColorScheme(state);
|
|
92
88
|
const setMode = React.useCallback(mode => {
|
|
93
89
|
setState(currentState => {
|
|
@@ -251,9 +247,9 @@ function useCurrentColorScheme(options) {
|
|
|
251
247
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow, isMultiSchemes]);
|
|
252
248
|
return {
|
|
253
249
|
...state,
|
|
254
|
-
mode:
|
|
255
|
-
systemMode:
|
|
256
|
-
colorScheme:
|
|
250
|
+
mode: isClient ? state.mode : undefined,
|
|
251
|
+
systemMode: isClient ? state.systemMode : undefined,
|
|
252
|
+
colorScheme: isClient ? colorScheme : undefined,
|
|
257
253
|
setMode,
|
|
258
254
|
setColorScheme
|
|
259
255
|
};
|
package/esm/Grid/createGrid.js
CHANGED
|
@@ -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
|
|
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,
|
|
@@ -50,7 +52,8 @@ export default function createCssVarsProvider(options) {
|
|
|
50
52
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
51
53
|
disableNestedContext = false,
|
|
52
54
|
disableStyleSheetGeneration = false,
|
|
53
|
-
defaultMode: initialMode = 'system'
|
|
55
|
+
defaultMode: initialMode = 'system',
|
|
56
|
+
noSsr
|
|
54
57
|
} = props;
|
|
55
58
|
const hasMounted = React.useRef(false);
|
|
56
59
|
const upperTheme = muiUseTheme();
|
|
@@ -63,12 +66,12 @@ export default function createCssVarsProvider(options) {
|
|
|
63
66
|
return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
|
|
64
67
|
}, [themeProp]);
|
|
65
68
|
const scopedTheme = initialTheme[themeId];
|
|
69
|
+
const restThemeProp = scopedTheme || initialTheme;
|
|
66
70
|
const {
|
|
67
|
-
colorSchemes =
|
|
68
|
-
components =
|
|
69
|
-
cssVarPrefix
|
|
70
|
-
|
|
71
|
-
} = scopedTheme || initialTheme;
|
|
71
|
+
colorSchemes = defaultColorSchemes,
|
|
72
|
+
components = defaultComponents,
|
|
73
|
+
cssVarPrefix
|
|
74
|
+
} = restThemeProp;
|
|
72
75
|
const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
|
|
73
76
|
const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
|
|
74
77
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
@@ -91,7 +94,8 @@ export default function createCssVarsProvider(options) {
|
|
|
91
94
|
modeStorageKey,
|
|
92
95
|
colorSchemeStorageKey,
|
|
93
96
|
defaultMode,
|
|
94
|
-
storageWindow
|
|
97
|
+
storageWindow,
|
|
98
|
+
noSsr
|
|
95
99
|
});
|
|
96
100
|
let mode = stateMode;
|
|
97
101
|
let colorScheme = stateColorScheme;
|
|
@@ -99,43 +103,45 @@ export default function createCssVarsProvider(options) {
|
|
|
99
103
|
mode = ctx.mode;
|
|
100
104
|
colorScheme = ctx.colorScheme;
|
|
101
105
|
}
|
|
106
|
+
const memoTheme = React.useMemo(() => {
|
|
107
|
+
// `colorScheme` is undefined on the server and hydration phase
|
|
108
|
+
const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
// 2. get the `vars` object that refers to the CSS custom properties
|
|
111
|
+
const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (typeof theme.generateSpacing === 'function') {
|
|
118
|
-
theme.spacing = theme.generateSpacing();
|
|
119
|
-
}
|
|
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
|
+
}
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
+
}
|
|
137
142
|
}
|
|
138
|
-
|
|
143
|
+
return resolveTheme ? resolveTheme(theme) : theme;
|
|
144
|
+
}, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
|
|
139
145
|
|
|
140
146
|
// 5. Declaring effects
|
|
141
147
|
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
|
|
@@ -209,13 +215,13 @@ export default function createCssVarsProvider(options) {
|
|
|
209
215
|
mode,
|
|
210
216
|
setColorScheme,
|
|
211
217
|
setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
|
|
212
|
-
if (
|
|
218
|
+
if (memoTheme.colorSchemeSelector === 'media') {
|
|
213
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'));
|
|
214
220
|
}
|
|
215
221
|
setMode(newMode);
|
|
216
222
|
},
|
|
217
223
|
systemMode
|
|
218
|
-
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode,
|
|
224
|
+
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
|
|
219
225
|
let shouldGenerateStyleSheet = true;
|
|
220
226
|
if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
|
|
221
227
|
shouldGenerateStyleSheet = false;
|
|
@@ -223,10 +229,10 @@ export default function createCssVarsProvider(options) {
|
|
|
223
229
|
const element = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
224
230
|
children: [/*#__PURE__*/_jsx(ThemeProvider, {
|
|
225
231
|
themeId: scopedTheme ? themeId : undefined,
|
|
226
|
-
theme:
|
|
232
|
+
theme: memoTheme,
|
|
227
233
|
children: children
|
|
228
234
|
}), shouldGenerateStyleSheet && /*#__PURE__*/_jsx(GlobalStyles, {
|
|
229
|
-
styles:
|
|
235
|
+
styles: memoTheme.generateStyleSheets?.() || []
|
|
230
236
|
})]
|
|
231
237
|
});
|
|
232
238
|
if (nested) {
|
|
@@ -277,6 +283,11 @@ export default function createCssVarsProvider(options) {
|
|
|
277
283
|
* The key in the local storage used to store current color scheme.
|
|
278
284
|
*/
|
|
279
285
|
modeStorageKey: PropTypes.string,
|
|
286
|
+
/**
|
|
287
|
+
* If `true`, the mode will be the same value as the storage without an extra rerendering after the hydration.
|
|
288
|
+
* You should use this option in conjuction with `InitColorSchemeScript` component.
|
|
289
|
+
*/
|
|
290
|
+
noSsr: PropTypes.bool,
|
|
280
291
|
/**
|
|
281
292
|
* The window that attaches the 'storage' event listener.
|
|
282
293
|
* @default window
|
|
@@ -56,7 +56,8 @@ export default function useCurrentColorScheme(options) {
|
|
|
56
56
|
supportedColorSchemes = [],
|
|
57
57
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
58
58
|
colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
|
|
59
|
-
storageWindow = typeof window === 'undefined' ? undefined : window
|
|
59
|
+
storageWindow = typeof window === 'undefined' ? undefined : window,
|
|
60
|
+
noSsr = false
|
|
60
61
|
} = options;
|
|
61
62
|
const joinedColorSchemes = supportedColorSchemes.join(',');
|
|
62
63
|
const isMultiSchemes = supportedColorSchemes.length > 1;
|
|
@@ -71,15 +72,10 @@ export default function useCurrentColorScheme(options) {
|
|
|
71
72
|
darkColorScheme
|
|
72
73
|
};
|
|
73
74
|
});
|
|
74
|
-
|
|
75
|
-
const [, setHasMounted] = React.useState(false);
|
|
76
|
-
const hasMounted = React.useRef(false);
|
|
75
|
+
const [isClient, setIsClient] = React.useState(noSsr || !isMultiSchemes);
|
|
77
76
|
React.useEffect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
hasMounted.current = true;
|
|
82
|
-
}, [isMultiSchemes]);
|
|
77
|
+
setIsClient(true); // to rerender the component after hydration
|
|
78
|
+
}, []);
|
|
83
79
|
const colorScheme = getColorScheme(state);
|
|
84
80
|
const setMode = React.useCallback(mode => {
|
|
85
81
|
setState(currentState => {
|
|
@@ -243,9 +239,9 @@ export default function useCurrentColorScheme(options) {
|
|
|
243
239
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow, isMultiSchemes]);
|
|
244
240
|
return {
|
|
245
241
|
...state,
|
|
246
|
-
mode:
|
|
247
|
-
systemMode:
|
|
248
|
-
colorScheme:
|
|
242
|
+
mode: isClient ? state.mode : undefined,
|
|
243
|
+
systemMode: isClient ? state.systemMode : undefined,
|
|
244
|
+
colorScheme: isClient ? colorScheme : undefined,
|
|
249
245
|
setMode,
|
|
250
246
|
setColorScheme
|
|
251
247
|
};
|
package/esm/version/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const version = "6.1.
|
|
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("
|
|
4
|
+
export const patch = Number("10");
|
|
5
5
|
export const prerelease = undefined;
|
|
6
6
|
export default version;
|
package/index.js
CHANGED
|
@@ -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
|
|
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,
|
|
@@ -50,7 +52,8 @@ export default function createCssVarsProvider(options) {
|
|
|
50
52
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
51
53
|
disableNestedContext = false,
|
|
52
54
|
disableStyleSheetGeneration = false,
|
|
53
|
-
defaultMode: initialMode = 'system'
|
|
55
|
+
defaultMode: initialMode = 'system',
|
|
56
|
+
noSsr
|
|
54
57
|
} = props;
|
|
55
58
|
const hasMounted = React.useRef(false);
|
|
56
59
|
const upperTheme = muiUseTheme();
|
|
@@ -63,12 +66,12 @@ export default function createCssVarsProvider(options) {
|
|
|
63
66
|
return typeof defaultTheme === 'function' ? defaultTheme() : defaultTheme;
|
|
64
67
|
}, [themeProp]);
|
|
65
68
|
const scopedTheme = initialTheme[themeId];
|
|
69
|
+
const restThemeProp = scopedTheme || initialTheme;
|
|
66
70
|
const {
|
|
67
|
-
colorSchemes =
|
|
68
|
-
components =
|
|
69
|
-
cssVarPrefix
|
|
70
|
-
|
|
71
|
-
} = scopedTheme || initialTheme;
|
|
71
|
+
colorSchemes = defaultColorSchemes,
|
|
72
|
+
components = defaultComponents,
|
|
73
|
+
cssVarPrefix
|
|
74
|
+
} = restThemeProp;
|
|
72
75
|
const joinedColorSchemes = Object.keys(colorSchemes).filter(k => !!colorSchemes[k]).join(',');
|
|
73
76
|
const allColorSchemes = React.useMemo(() => joinedColorSchemes.split(','), [joinedColorSchemes]);
|
|
74
77
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
@@ -91,7 +94,8 @@ export default function createCssVarsProvider(options) {
|
|
|
91
94
|
modeStorageKey,
|
|
92
95
|
colorSchemeStorageKey,
|
|
93
96
|
defaultMode,
|
|
94
|
-
storageWindow
|
|
97
|
+
storageWindow,
|
|
98
|
+
noSsr
|
|
95
99
|
});
|
|
96
100
|
let mode = stateMode;
|
|
97
101
|
let colorScheme = stateColorScheme;
|
|
@@ -99,43 +103,45 @@ export default function createCssVarsProvider(options) {
|
|
|
99
103
|
mode = ctx.mode;
|
|
100
104
|
colorScheme = ctx.colorScheme;
|
|
101
105
|
}
|
|
106
|
+
const memoTheme = React.useMemo(() => {
|
|
107
|
+
// `colorScheme` is undefined on the server and hydration phase
|
|
108
|
+
const calculatedColorScheme = colorScheme || restThemeProp.defaultColorScheme;
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
// 2. get the `vars` object that refers to the CSS custom properties
|
|
111
|
+
const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (typeof theme.generateSpacing === 'function') {
|
|
118
|
-
theme.spacing = theme.generateSpacing();
|
|
119
|
-
}
|
|
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
|
+
}
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
+
}
|
|
137
142
|
}
|
|
138
|
-
|
|
143
|
+
return resolveTheme ? resolveTheme(theme) : theme;
|
|
144
|
+
}, [restThemeProp, colorScheme, components, colorSchemes, cssVarPrefix]);
|
|
139
145
|
|
|
140
146
|
// 5. Declaring effects
|
|
141
147
|
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
|
|
@@ -209,13 +215,13 @@ export default function createCssVarsProvider(options) {
|
|
|
209
215
|
mode,
|
|
210
216
|
setColorScheme,
|
|
211
217
|
setMode: process.env.NODE_ENV === 'production' ? setMode : newMode => {
|
|
212
|
-
if (
|
|
218
|
+
if (memoTheme.colorSchemeSelector === 'media') {
|
|
213
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'));
|
|
214
220
|
}
|
|
215
221
|
setMode(newMode);
|
|
216
222
|
},
|
|
217
223
|
systemMode
|
|
218
|
-
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode,
|
|
224
|
+
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode, memoTheme.colorSchemeSelector]);
|
|
219
225
|
let shouldGenerateStyleSheet = true;
|
|
220
226
|
if (disableStyleSheetGeneration || restThemeProp.cssVariables === false || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
|
|
221
227
|
shouldGenerateStyleSheet = false;
|
|
@@ -223,10 +229,10 @@ export default function createCssVarsProvider(options) {
|
|
|
223
229
|
const element = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
224
230
|
children: [/*#__PURE__*/_jsx(ThemeProvider, {
|
|
225
231
|
themeId: scopedTheme ? themeId : undefined,
|
|
226
|
-
theme:
|
|
232
|
+
theme: memoTheme,
|
|
227
233
|
children: children
|
|
228
234
|
}), shouldGenerateStyleSheet && /*#__PURE__*/_jsx(GlobalStyles, {
|
|
229
|
-
styles:
|
|
235
|
+
styles: memoTheme.generateStyleSheets?.() || []
|
|
230
236
|
})]
|
|
231
237
|
});
|
|
232
238
|
if (nested) {
|
|
@@ -277,6 +283,11 @@ export default function createCssVarsProvider(options) {
|
|
|
277
283
|
* The key in the local storage used to store current color scheme.
|
|
278
284
|
*/
|
|
279
285
|
modeStorageKey: PropTypes.string,
|
|
286
|
+
/**
|
|
287
|
+
* If `true`, the mode will be the same value as the storage without an extra rerendering after the hydration.
|
|
288
|
+
* You should use this option in conjuction with `InitColorSchemeScript` component.
|
|
289
|
+
*/
|
|
290
|
+
noSsr: PropTypes.bool,
|
|
280
291
|
/**
|
|
281
292
|
* The window that attaches the 'storage' event listener.
|
|
282
293
|
* @default window
|
|
@@ -56,7 +56,8 @@ export default function useCurrentColorScheme(options) {
|
|
|
56
56
|
supportedColorSchemes = [],
|
|
57
57
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
58
58
|
colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
|
|
59
|
-
storageWindow = typeof window === 'undefined' ? undefined : window
|
|
59
|
+
storageWindow = typeof window === 'undefined' ? undefined : window,
|
|
60
|
+
noSsr = false
|
|
60
61
|
} = options;
|
|
61
62
|
const joinedColorSchemes = supportedColorSchemes.join(',');
|
|
62
63
|
const isMultiSchemes = supportedColorSchemes.length > 1;
|
|
@@ -71,15 +72,10 @@ export default function useCurrentColorScheme(options) {
|
|
|
71
72
|
darkColorScheme
|
|
72
73
|
};
|
|
73
74
|
});
|
|
74
|
-
|
|
75
|
-
const [, setHasMounted] = React.useState(false);
|
|
76
|
-
const hasMounted = React.useRef(false);
|
|
75
|
+
const [isClient, setIsClient] = React.useState(noSsr || !isMultiSchemes);
|
|
77
76
|
React.useEffect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
hasMounted.current = true;
|
|
82
|
-
}, [isMultiSchemes]);
|
|
77
|
+
setIsClient(true); // to rerender the component after hydration
|
|
78
|
+
}, []);
|
|
83
79
|
const colorScheme = getColorScheme(state);
|
|
84
80
|
const setMode = React.useCallback(mode => {
|
|
85
81
|
setState(currentState => {
|
|
@@ -243,9 +239,9 @@ export default function useCurrentColorScheme(options) {
|
|
|
243
239
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow, isMultiSchemes]);
|
|
244
240
|
return {
|
|
245
241
|
...state,
|
|
246
|
-
mode:
|
|
247
|
-
systemMode:
|
|
248
|
-
colorScheme:
|
|
242
|
+
mode: isClient ? state.mode : undefined,
|
|
243
|
+
systemMode: isClient ? state.systemMode : undefined,
|
|
244
|
+
colorScheme: isClient ? colorScheme : undefined,
|
|
249
245
|
setMode,
|
|
250
246
|
setColorScheme
|
|
251
247
|
};
|
package/modern/index.js
CHANGED
package/modern/version/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const version = "6.1.
|
|
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("
|
|
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.
|
|
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/
|
|
33
|
+
"@mui/styled-engine": "^6.1.10",
|
|
34
|
+
"@mui/private-theming": "^6.1.10",
|
|
34
35
|
"@mui/types": "^7.2.19",
|
|
35
|
-
"@mui/utils": "^6.1.
|
|
36
|
-
"@mui/styled-engine": "^6.1.8"
|
|
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.
|
|
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("
|
|
10
|
+
const patch = exports.patch = Number("10");
|
|
11
11
|
const prerelease = exports.prerelease = undefined;
|
|
12
12
|
var _default = exports.default = version;
|