@mui/system 5.10.2 → 5.10.3
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/Box/Box.d.ts +10 -10
- package/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +62 -0
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/Stack/Stack.d.ts +12 -12
- package/Stack/StackProps.d.ts +42 -42
- package/Stack/createStack.d.ts +21 -21
- package/Stack/index.d.ts +5 -5
- package/Stack/stackClasses.d.ts +8 -8
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +26 -26
- package/Unstable_Grid/index.d.ts +5 -5
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/getInitColorSchemeScript.d.ts +45 -45
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/cssVars/useCurrentColorScheme.js +53 -52
- package/esm/cssVars/useCurrentColorScheme.js +54 -51
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/cssVars/useCurrentColorScheme.js +54 -51
- package/legacy/index.js +1 -1
- package/modern/cssVars/useCurrentColorScheme.js +54 -51
- package/modern/index.js +1 -1
- package/package.json +6 -6
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -41,7 +41,7 @@ export function getColorScheme(state) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function initializeValue(key, defaultValue) {
|
|
45
45
|
if (typeof window === 'undefined') {
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
@@ -50,6 +50,11 @@ function resolveValue(key, defaultValue) {
|
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
52
|
value = localStorage.getItem(key) || undefined;
|
|
53
|
+
|
|
54
|
+
if (!value) {
|
|
55
|
+
// the first time that user enters the site.
|
|
56
|
+
localStorage.setItem(key, defaultValue);
|
|
57
|
+
}
|
|
53
58
|
} catch (e) {// Unsupported
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -72,12 +77,14 @@ export default function useCurrentColorScheme(options) {
|
|
|
72
77
|
var joinedColorSchemes = supportedColorSchemes.join(',');
|
|
73
78
|
|
|
74
79
|
var _React$useState = React.useState(function () {
|
|
75
|
-
var initialMode =
|
|
80
|
+
var initialMode = initializeValue(modeStorageKey, defaultMode);
|
|
81
|
+
var lightColorScheme = initializeValue("".concat(colorSchemeStorageKey, "-light"), defaultLightColorScheme);
|
|
82
|
+
var darkColorScheme = initializeValue("".concat(colorSchemeStorageKey, "-dark"), defaultDarkColorScheme);
|
|
76
83
|
return {
|
|
77
84
|
mode: initialMode,
|
|
78
85
|
systemMode: getSystemMode(initialMode),
|
|
79
|
-
lightColorScheme:
|
|
80
|
-
darkColorScheme:
|
|
86
|
+
lightColorScheme: lightColorScheme,
|
|
87
|
+
darkColorScheme: darkColorScheme
|
|
81
88
|
};
|
|
82
89
|
}),
|
|
83
90
|
state = _React$useState[0],
|
|
@@ -86,12 +93,13 @@ export default function useCurrentColorScheme(options) {
|
|
|
86
93
|
var colorScheme = getColorScheme(state);
|
|
87
94
|
var setMode = React.useCallback(function (mode) {
|
|
88
95
|
setState(function (currentState) {
|
|
89
|
-
var newMode = !mode ? defaultMode : mode;
|
|
90
|
-
|
|
91
96
|
if (mode === currentState.mode) {
|
|
97
|
+
// do nothing if mode does not change
|
|
92
98
|
return currentState;
|
|
93
99
|
}
|
|
94
100
|
|
|
101
|
+
var newMode = !mode ? defaultMode : mode;
|
|
102
|
+
|
|
95
103
|
try {
|
|
96
104
|
localStorage.setItem(modeStorageKey, newMode);
|
|
97
105
|
} catch (e) {// Unsupported
|
|
@@ -104,20 +112,26 @@ export default function useCurrentColorScheme(options) {
|
|
|
104
112
|
});
|
|
105
113
|
}, [modeStorageKey, defaultMode]);
|
|
106
114
|
var setColorScheme = React.useCallback(function (value) {
|
|
107
|
-
if (!value
|
|
115
|
+
if (!value) {
|
|
116
|
+
setState(function (currentState) {
|
|
117
|
+
try {
|
|
118
|
+
localStorage.setItem("".concat(colorSchemeStorageKey, "-light"), defaultLightColorScheme);
|
|
119
|
+
localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), defaultDarkColorScheme);
|
|
120
|
+
} catch (e) {// Unsupported
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return _extends({}, currentState, {
|
|
124
|
+
lightColorScheme: defaultLightColorScheme,
|
|
125
|
+
darkColorScheme: defaultDarkColorScheme
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
} else if (typeof value === 'string') {
|
|
108
129
|
if (value && !joinedColorSchemes.includes(value)) {
|
|
109
130
|
console.error("`".concat(value, "` does not exist in `theme.colorSchemes`."));
|
|
110
131
|
} else {
|
|
111
132
|
setState(function (currentState) {
|
|
112
133
|
var newState = _extends({}, currentState);
|
|
113
134
|
|
|
114
|
-
if (!value) {
|
|
115
|
-
// reset to default color scheme
|
|
116
|
-
newState.lightColorScheme = defaultLightColorScheme;
|
|
117
|
-
newState.darkColorScheme = defaultDarkColorScheme;
|
|
118
|
-
return newState;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
135
|
processState(currentState, function (mode) {
|
|
122
136
|
try {
|
|
123
137
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-").concat(mode), value);
|
|
@@ -135,33 +149,41 @@ export default function useCurrentColorScheme(options) {
|
|
|
135
149
|
return newState;
|
|
136
150
|
});
|
|
137
151
|
}
|
|
138
|
-
} else if (value.light && !joinedColorSchemes.includes(value.light) || value.dark && !joinedColorSchemes.includes(value.dark)) {
|
|
139
|
-
console.error("`".concat(value, "` does not exist in `theme.colorSchemes`."));
|
|
140
152
|
} else {
|
|
141
153
|
setState(function (currentState) {
|
|
142
154
|
var newState = _extends({}, currentState);
|
|
143
155
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
156
|
+
var newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
157
|
+
var newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
147
158
|
|
|
148
|
-
if (
|
|
149
|
-
|
|
159
|
+
if (newLightColorScheme) {
|
|
160
|
+
if (!joinedColorSchemes.includes(newLightColorScheme)) {
|
|
161
|
+
console.error("`".concat(newLightColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
162
|
+
} else {
|
|
163
|
+
newState.lightColorScheme = newLightColorScheme;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
localStorage.setItem("".concat(colorSchemeStorageKey, "-light"), newLightColorScheme);
|
|
167
|
+
} catch (error) {// Unsupported
|
|
168
|
+
}
|
|
169
|
+
}
|
|
150
170
|
}
|
|
151
171
|
|
|
152
|
-
|
|
153
|
-
|
|
172
|
+
if (newDarkColorScheme) {
|
|
173
|
+
if (!joinedColorSchemes.includes(newDarkColorScheme)) {
|
|
174
|
+
console.error("`".concat(newDarkColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
175
|
+
} else {
|
|
176
|
+
newState.darkColorScheme = newDarkColorScheme;
|
|
154
177
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
178
|
+
try {
|
|
179
|
+
localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), newDarkColorScheme);
|
|
180
|
+
} catch (error) {// Unsupported
|
|
181
|
+
}
|
|
182
|
+
}
|
|
158
183
|
}
|
|
159
184
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
} catch (e) {// Unsupported
|
|
164
|
-
}
|
|
185
|
+
return newState;
|
|
186
|
+
});
|
|
165
187
|
}
|
|
166
188
|
}, [joinedColorSchemes, colorSchemeStorageKey, defaultLightColorScheme, defaultDarkColorScheme]);
|
|
167
189
|
var handleMediaQuery = React.useCallback(function (e) {
|
|
@@ -189,26 +211,7 @@ export default function useCurrentColorScheme(options) {
|
|
|
189
211
|
return function () {
|
|
190
212
|
return media.removeListener(handler);
|
|
191
213
|
};
|
|
192
|
-
}, []); //
|
|
193
|
-
|
|
194
|
-
React.useEffect(function () {
|
|
195
|
-
try {
|
|
196
|
-
if (state.mode) {
|
|
197
|
-
localStorage.setItem(modeStorageKey, state.mode);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
processState(state, function (mode) {
|
|
201
|
-
if (mode === 'light') {
|
|
202
|
-
localStorage.setItem("".concat(colorSchemeStorageKey, "-light"), state.lightColorScheme);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (mode === 'dark') {
|
|
206
|
-
localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), state.darkColorScheme);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
} catch (e) {// Unsupported
|
|
210
|
-
}
|
|
211
|
-
}, [state, colorSchemeStorageKey, modeStorageKey]); // Handle when localStorage has changed
|
|
214
|
+
}, []); // Handle when localStorage has changed
|
|
212
215
|
|
|
213
216
|
React.useEffect(function () {
|
|
214
217
|
var handleStorage = function handleStorage(event) {
|
package/legacy/index.js
CHANGED
|
@@ -41,7 +41,7 @@ export function getColorScheme(state) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
function initializeValue(key, defaultValue) {
|
|
45
45
|
if (typeof window === 'undefined') {
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
|
@@ -50,6 +50,11 @@ function resolveValue(key, defaultValue) {
|
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
52
|
value = localStorage.getItem(key) || undefined;
|
|
53
|
+
|
|
54
|
+
if (!value) {
|
|
55
|
+
// the first time that user enters the site.
|
|
56
|
+
localStorage.setItem(key, defaultValue);
|
|
57
|
+
}
|
|
53
58
|
} catch (e) {// Unsupported
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -68,23 +73,26 @@ export default function useCurrentColorScheme(options) {
|
|
|
68
73
|
} = options;
|
|
69
74
|
const joinedColorSchemes = supportedColorSchemes.join(',');
|
|
70
75
|
const [state, setState] = React.useState(() => {
|
|
71
|
-
const initialMode =
|
|
76
|
+
const initialMode = initializeValue(modeStorageKey, defaultMode);
|
|
77
|
+
const lightColorScheme = initializeValue(`${colorSchemeStorageKey}-light`, defaultLightColorScheme);
|
|
78
|
+
const darkColorScheme = initializeValue(`${colorSchemeStorageKey}-dark`, defaultDarkColorScheme);
|
|
72
79
|
return {
|
|
73
80
|
mode: initialMode,
|
|
74
81
|
systemMode: getSystemMode(initialMode),
|
|
75
|
-
lightColorScheme
|
|
76
|
-
darkColorScheme
|
|
82
|
+
lightColorScheme,
|
|
83
|
+
darkColorScheme
|
|
77
84
|
};
|
|
78
85
|
});
|
|
79
86
|
const colorScheme = getColorScheme(state);
|
|
80
87
|
const setMode = React.useCallback(mode => {
|
|
81
88
|
setState(currentState => {
|
|
82
|
-
const newMode = !mode ? defaultMode : mode;
|
|
83
|
-
|
|
84
89
|
if (mode === currentState.mode) {
|
|
90
|
+
// do nothing if mode does not change
|
|
85
91
|
return currentState;
|
|
86
92
|
}
|
|
87
93
|
|
|
94
|
+
const newMode = !mode ? defaultMode : mode;
|
|
95
|
+
|
|
88
96
|
try {
|
|
89
97
|
localStorage.setItem(modeStorageKey, newMode);
|
|
90
98
|
} catch (e) {// Unsupported
|
|
@@ -97,20 +105,26 @@ export default function useCurrentColorScheme(options) {
|
|
|
97
105
|
});
|
|
98
106
|
}, [modeStorageKey, defaultMode]);
|
|
99
107
|
const setColorScheme = React.useCallback(value => {
|
|
100
|
-
if (!value
|
|
108
|
+
if (!value) {
|
|
109
|
+
setState(currentState => {
|
|
110
|
+
try {
|
|
111
|
+
localStorage.setItem(`${colorSchemeStorageKey}-light`, defaultLightColorScheme);
|
|
112
|
+
localStorage.setItem(`${colorSchemeStorageKey}-dark`, defaultDarkColorScheme);
|
|
113
|
+
} catch (e) {// Unsupported
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return _extends({}, currentState, {
|
|
117
|
+
lightColorScheme: defaultLightColorScheme,
|
|
118
|
+
darkColorScheme: defaultDarkColorScheme
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
} else if (typeof value === 'string') {
|
|
101
122
|
if (value && !joinedColorSchemes.includes(value)) {
|
|
102
123
|
console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
|
|
103
124
|
} else {
|
|
104
125
|
setState(currentState => {
|
|
105
126
|
const newState = _extends({}, currentState);
|
|
106
127
|
|
|
107
|
-
if (!value) {
|
|
108
|
-
// reset to default color scheme
|
|
109
|
-
newState.lightColorScheme = defaultLightColorScheme;
|
|
110
|
-
newState.darkColorScheme = defaultDarkColorScheme;
|
|
111
|
-
return newState;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
128
|
processState(currentState, mode => {
|
|
115
129
|
try {
|
|
116
130
|
localStorage.setItem(`${colorSchemeStorageKey}-${mode}`, value);
|
|
@@ -128,33 +142,41 @@ export default function useCurrentColorScheme(options) {
|
|
|
128
142
|
return newState;
|
|
129
143
|
});
|
|
130
144
|
}
|
|
131
|
-
} else if (value.light && !joinedColorSchemes.includes(value.light) || value.dark && !joinedColorSchemes.includes(value.dark)) {
|
|
132
|
-
console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
|
|
133
145
|
} else {
|
|
134
146
|
setState(currentState => {
|
|
135
147
|
const newState = _extends({}, currentState);
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
150
|
+
const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
151
|
+
|
|
152
|
+
if (newLightColorScheme) {
|
|
153
|
+
if (!joinedColorSchemes.includes(newLightColorScheme)) {
|
|
154
|
+
console.error(`\`${newLightColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
155
|
+
} else {
|
|
156
|
+
newState.lightColorScheme = newLightColorScheme;
|
|
140
157
|
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
try {
|
|
159
|
+
localStorage.setItem(`${colorSchemeStorageKey}-light`, newLightColorScheme);
|
|
160
|
+
} catch (error) {// Unsupported
|
|
161
|
+
}
|
|
162
|
+
}
|
|
143
163
|
}
|
|
144
164
|
|
|
145
|
-
|
|
146
|
-
|
|
165
|
+
if (newDarkColorScheme) {
|
|
166
|
+
if (!joinedColorSchemes.includes(newDarkColorScheme)) {
|
|
167
|
+
console.error(`\`${newDarkColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
168
|
+
} else {
|
|
169
|
+
newState.darkColorScheme = newDarkColorScheme;
|
|
147
170
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
171
|
+
try {
|
|
172
|
+
localStorage.setItem(`${colorSchemeStorageKey}-dark`, newDarkColorScheme);
|
|
173
|
+
} catch (error) {// Unsupported
|
|
174
|
+
}
|
|
175
|
+
}
|
|
151
176
|
}
|
|
152
177
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
} catch (e) {// Unsupported
|
|
157
|
-
}
|
|
178
|
+
return newState;
|
|
179
|
+
});
|
|
158
180
|
}
|
|
159
181
|
}, [joinedColorSchemes, colorSchemeStorageKey, defaultLightColorScheme, defaultDarkColorScheme]);
|
|
160
182
|
const handleMediaQuery = React.useCallback(e => {
|
|
@@ -176,26 +198,7 @@ export default function useCurrentColorScheme(options) {
|
|
|
176
198
|
media.addListener(handler);
|
|
177
199
|
handler(media);
|
|
178
200
|
return () => media.removeListener(handler);
|
|
179
|
-
}, []); //
|
|
180
|
-
|
|
181
|
-
React.useEffect(() => {
|
|
182
|
-
try {
|
|
183
|
-
if (state.mode) {
|
|
184
|
-
localStorage.setItem(modeStorageKey, state.mode);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
processState(state, mode => {
|
|
188
|
-
if (mode === 'light') {
|
|
189
|
-
localStorage.setItem(`${colorSchemeStorageKey}-light`, state.lightColorScheme);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (mode === 'dark') {
|
|
193
|
-
localStorage.setItem(`${colorSchemeStorageKey}-dark`, state.darkColorScheme);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
} catch (e) {// Unsupported
|
|
197
|
-
}
|
|
198
|
-
}, [state, colorSchemeStorageKey, modeStorageKey]); // Handle when localStorage has changed
|
|
201
|
+
}, []); // Handle when localStorage has changed
|
|
199
202
|
|
|
200
203
|
React.useEffect(() => {
|
|
201
204
|
const handleStorage = event => {
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@babel/runtime": "^7.
|
|
47
|
-
"@mui/private-theming": "^5.
|
|
48
|
-
"@mui/styled-engine": "^5.10.
|
|
49
|
-
"@mui/types": "^7.
|
|
50
|
-
"@mui/utils": "^5.
|
|
46
|
+
"@babel/runtime": "^7.18.9",
|
|
47
|
+
"@mui/private-theming": "^5.10.3",
|
|
48
|
+
"@mui/styled-engine": "^5.10.3",
|
|
49
|
+
"@mui/types": "^7.2.0",
|
|
50
|
+
"@mui/utils": "^5.10.3",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.0",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|