@mui/system 5.15.13 → 5.15.15

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.
@@ -78,7 +78,7 @@ export default function useCurrentColorScheme(options) {
78
78
  // do nothing if mode does not change
79
79
  return currentState;
80
80
  }
81
- const newMode = !mode ? defaultMode : mode;
81
+ const newMode = mode ?? defaultMode;
82
82
  try {
83
83
  localStorage.setItem(modeStorageKey, newMode);
84
84
  } catch (e) {
@@ -159,11 +159,19 @@ export default function useCurrentColorScheme(options) {
159
159
  });
160
160
  }
161
161
  }, [joinedColorSchemes, colorSchemeStorageKey, defaultLightColorScheme, defaultDarkColorScheme]);
162
- const handleMediaQuery = React.useCallback(e => {
162
+ const handleMediaQuery = React.useCallback(event => {
163
163
  if (state.mode === 'system') {
164
- setState(currentState => _extends({}, currentState, {
165
- systemMode: e?.matches ? 'dark' : 'light'
166
- }));
164
+ setState(currentState => {
165
+ const systemMode = event?.matches ? 'dark' : 'light';
166
+
167
+ // Early exit, nothing changed.
168
+ if (currentState.systemMode === systemMode) {
169
+ return currentState;
170
+ }
171
+ return _extends({}, currentState, {
172
+ systemMode
173
+ });
174
+ });
167
175
  }
168
176
  }, [state.mode]);
169
177
 
@@ -179,34 +187,38 @@ export default function useCurrentColorScheme(options) {
179
187
  // Intentionally use deprecated listener methods to support iOS & old browsers
180
188
  media.addListener(handler);
181
189
  handler(media);
182
- return () => media.removeListener(handler);
190
+ return () => {
191
+ media.removeListener(handler);
192
+ };
183
193
  }, []);
184
194
 
185
195
  // Handle when localStorage has changed
186
196
  React.useEffect(() => {
187
- const handleStorage = event => {
188
- const value = event.newValue;
189
- if (typeof event.key === 'string' && event.key.startsWith(colorSchemeStorageKey) && (!value || joinedColorSchemes.match(value))) {
190
- // If the key is deleted, value will be null then reset color scheme to the default one.
191
- if (event.key.endsWith('light')) {
192
- setColorScheme({
193
- light: value
194
- });
197
+ if (storageWindow) {
198
+ const handleStorage = event => {
199
+ const value = event.newValue;
200
+ if (typeof event.key === 'string' && event.key.startsWith(colorSchemeStorageKey) && (!value || joinedColorSchemes.match(value))) {
201
+ // If the key is deleted, value will be null then reset color scheme to the default one.
202
+ if (event.key.endsWith('light')) {
203
+ setColorScheme({
204
+ light: value
205
+ });
206
+ }
207
+ if (event.key.endsWith('dark')) {
208
+ setColorScheme({
209
+ dark: value
210
+ });
211
+ }
195
212
  }
196
- if (event.key.endsWith('dark')) {
197
- setColorScheme({
198
- dark: value
199
- });
213
+ if (event.key === modeStorageKey && (!value || ['light', 'dark', 'system'].includes(value))) {
214
+ setMode(value || defaultMode);
200
215
  }
201
- }
202
- if (event.key === modeStorageKey && (!value || ['light', 'dark', 'system'].includes(value))) {
203
- setMode(value || defaultMode);
204
- }
205
- };
206
- if (storageWindow) {
216
+ };
207
217
  // For syncing color-scheme changes between iframes
208
218
  storageWindow.addEventListener('storage', handleStorage);
209
- return () => storageWindow.removeEventListener('storage', handleStorage);
219
+ return () => {
220
+ storageWindow.removeEventListener('storage', handleStorage);
221
+ };
210
222
  }
211
223
  return undefined;
212
224
  }, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.15.13
2
+ * @mui/system v5.15.15
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.15.13",
3
+ "version": "5.15.15",
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.0",
31
31
  "csstype": "^3.1.3",
32
32
  "prop-types": "^15.8.1",
33
- "@mui/private-theming": "^5.15.13",
34
- "@mui/types": "^7.2.13",
35
- "@mui/utils": "^5.15.13",
36
- "@mui/styled-engine": "^5.15.11"
33
+ "@mui/utils": "^5.15.14",
34
+ "@mui/private-theming": "^5.15.14",
35
+ "@mui/types": "^7.2.14",
36
+ "@mui/styled-engine": "^5.15.14"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@emotion/react": "^11.5.0",