@mui/system 5.10.13 → 5.10.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.
- package/Box/Box.js +1 -10
- package/Box/index.js +0 -2
- package/CHANGELOG.md +132 -2
- package/Container/Container.js +2 -17
- package/Container/containerClasses.js +0 -3
- package/Container/createContainer.js +15 -37
- package/Container/index.js +0 -6
- package/Stack/Stack.js +1 -12
- package/Stack/createStack.js +10 -48
- package/Stack/index.js +0 -9
- package/Stack/stackClasses.js +0 -3
- package/ThemeProvider/ThemeProvider.js +2 -22
- package/ThemeProvider/index.js +0 -2
- package/Unstable_Grid/Grid.js +6 -42
- package/Unstable_Grid/createGrid.js +19 -49
- package/Unstable_Grid/gridClasses.js +8 -7
- package/Unstable_Grid/gridGenerator.d.ts +4 -3
- package/Unstable_Grid/gridGenerator.js +22 -63
- package/Unstable_Grid/index.js +0 -9
- package/borders.js +0 -14
- package/breakpoints.js +3 -32
- package/colorManipulator.js +13 -55
- package/compose.js +0 -7
- package/createBox.js +5 -20
- package/createStyled.js +27 -71
- package/createTheme/createBreakpoints.js +22 -37
- package/createTheme/createSpacing.js +4 -8
- package/createTheme/createTheme.js +6 -16
- package/createTheme/index.js +0 -2
- package/cssGrid.js +0 -21
- package/cssVars/createCssVarsProvider.js +33 -74
- package/cssVars/createGetCssVar.js +2 -7
- package/cssVars/cssVarsParser.js +3 -15
- package/cssVars/getInitColorSchemeScript.js +0 -6
- package/cssVars/index.js +0 -3
- package/cssVars/useCurrentColorScheme.js +20 -49
- package/display.js +0 -6
- package/esm/Box/Box.js +1 -6
- package/esm/Container/Container.js +3 -14
- package/esm/Container/createContainer.js +15 -25
- package/esm/Stack/Stack.js +1 -9
- package/esm/Stack/createStack.js +10 -29
- package/esm/ThemeProvider/ThemeProvider.js +2 -11
- package/esm/Unstable_Grid/Grid.js +6 -39
- package/esm/Unstable_Grid/createGrid.js +18 -35
- package/esm/Unstable_Grid/gridClasses.js +8 -4
- package/esm/Unstable_Grid/gridGenerator.js +20 -38
- package/esm/borders.js +0 -6
- package/esm/breakpoints.js +7 -22
- package/esm/colorManipulator.js +13 -43
- package/esm/compose.js +0 -5
- package/esm/createBox.js +5 -7
- package/esm/createStyled.js +27 -64
- package/esm/createTheme/createBreakpoints.js +22 -34
- package/esm/createTheme/createSpacing.js +4 -7
- package/esm/createTheme/createTheme.js +6 -9
- package/esm/cssGrid.js +0 -9
- package/esm/cssVars/createCssVarsProvider.js +33 -60
- package/esm/cssVars/createGetCssVar.js +2 -6
- package/esm/cssVars/cssVarsParser.js +3 -11
- package/esm/cssVars/useCurrentColorScheme.js +20 -44
- package/esm/getThemeValue.js +0 -2
- package/esm/index.js +3 -3
- package/esm/memoize.js +0 -1
- package/esm/merge.js +0 -3
- package/esm/palette.js +0 -3
- package/esm/propsToClassKey.js +4 -7
- package/esm/sizing.js +0 -5
- package/esm/spacing.js +3 -23
- package/esm/style.js +5 -22
- package/esm/styleFunctionSx/extendSxProp.js +3 -10
- package/esm/styleFunctionSx/styleFunctionSx.js +3 -16
- package/esm/sx/sx.js +0 -2
- package/esm/useTheme.js +0 -2
- package/esm/useThemeProps/getThemeProps.js +0 -2
- package/esm/useThemeWithoutDefault.js +0 -3
- package/flexbox.js +0 -4
- package/getThemeValue.js +0 -14
- package/index.d.ts +2 -0
- package/index.js +16 -55
- package/legacy/Box/Box.js +1 -6
- package/legacy/Container/Container.js +3 -14
- package/legacy/Container/createContainer.js +29 -39
- package/legacy/Stack/Stack.js +1 -9
- package/legacy/Stack/createStack.js +17 -37
- package/legacy/ThemeProvider/ThemeProvider.js +3 -12
- package/legacy/Unstable_Grid/Grid.js +6 -39
- package/legacy/Unstable_Grid/createGrid.js +34 -53
- package/legacy/Unstable_Grid/gridGenerator.js +36 -58
- package/legacy/borders.js +0 -6
- package/legacy/breakpoints.js +9 -28
- package/legacy/colorManipulator.js +16 -48
- package/legacy/compose.js +0 -6
- package/legacy/createBox.js +9 -11
- package/legacy/createStyled.js +27 -68
- package/legacy/createTheme/createBreakpoints.js +20 -33
- package/legacy/createTheme/createSpacing.js +4 -9
- package/legacy/createTheme/createTheme.js +7 -13
- package/legacy/cssGrid.js +0 -9
- package/legacy/cssVars/createCssVarsProvider.js +98 -130
- package/legacy/cssVars/createGetCssVar.js +2 -10
- package/legacy/cssVars/cssVarsParser.js +7 -20
- package/legacy/cssVars/getInitColorSchemeScript.js +14 -15
- package/legacy/cssVars/useCurrentColorScheme.js +43 -69
- package/legacy/getThemeValue.js +0 -3
- package/legacy/index.js +4 -4
- package/legacy/memoize.js +0 -1
- package/legacy/merge.js +0 -3
- package/legacy/palette.js +0 -3
- package/legacy/propsToClassKey.js +2 -5
- package/legacy/sizing.js +0 -5
- package/legacy/spacing.js +6 -27
- package/legacy/style.js +9 -27
- package/legacy/styleFunctionSx/extendSxProp.js +3 -11
- package/legacy/styleFunctionSx/styleFunctionSx.js +6 -21
- package/legacy/sx/sx.js +0 -2
- package/legacy/useTheme.js +0 -2
- package/legacy/useThemeProps/getThemeProps.js +2 -4
- package/legacy/useThemeProps/useThemeProps.js +2 -2
- package/legacy/useThemeWithoutDefault.js +0 -3
- package/memoize.js +0 -2
- package/merge.js +0 -5
- package/modern/Box/Box.js +1 -6
- package/modern/Container/Container.js +3 -14
- package/modern/Container/createContainer.js +15 -25
- package/modern/Stack/Stack.js +1 -9
- package/modern/Stack/createStack.js +10 -29
- package/modern/ThemeProvider/ThemeProvider.js +2 -11
- package/modern/Unstable_Grid/Grid.js +6 -39
- package/modern/Unstable_Grid/createGrid.js +18 -34
- package/modern/Unstable_Grid/gridClasses.js +8 -4
- package/modern/Unstable_Grid/gridGenerator.js +20 -36
- package/modern/borders.js +0 -6
- package/modern/breakpoints.js +7 -21
- package/modern/colorManipulator.js +13 -43
- package/modern/compose.js +0 -5
- package/modern/createBox.js +5 -7
- package/modern/createStyled.js +27 -63
- package/modern/createTheme/createBreakpoints.js +22 -34
- package/modern/createTheme/createSpacing.js +4 -7
- package/modern/createTheme/createTheme.js +6 -9
- package/modern/cssGrid.js +0 -9
- package/modern/cssVars/createCssVarsProvider.js +33 -60
- package/modern/cssVars/createGetCssVar.js +2 -6
- package/modern/cssVars/cssVarsParser.js +3 -11
- package/modern/cssVars/useCurrentColorScheme.js +20 -44
- package/modern/getThemeValue.js +0 -2
- package/modern/index.js +4 -4
- package/modern/memoize.js +0 -1
- package/modern/merge.js +0 -3
- package/modern/palette.js +0 -3
- package/modern/propsToClassKey.js +4 -7
- package/modern/sizing.js +0 -4
- package/modern/spacing.js +3 -22
- package/modern/style.js +5 -22
- package/modern/styleFunctionSx/extendSxProp.js +3 -10
- package/modern/styleFunctionSx/styleFunctionSx.js +3 -16
- package/modern/sx/sx.js +0 -2
- package/modern/useTheme.js +0 -2
- package/modern/useThemeProps/getThemeProps.js +0 -2
- package/modern/useThemeWithoutDefault.js +0 -3
- package/package.json +6 -6
- package/palette.js +0 -6
- package/positions.js +0 -6
- package/propsToClassKey.js +4 -10
- package/responsivePropType.d.ts +3 -0
- package/responsivePropType.js +0 -3
- package/shadows.js +0 -3
- package/sizing.js +0 -11
- package/spacing.d.ts +14 -0
- package/spacing.js +3 -37
- package/style.d.ts +6 -0
- package/style.js +6 -27
- package/styleFunctionSx/extendSxProp.js +3 -15
- package/styleFunctionSx/index.js +0 -5
- package/styleFunctionSx/styleFunctionSx.js +3 -21
- package/styled.js +0 -3
- package/sx/index.js +0 -2
- package/sx/sx.js +0 -4
- package/typography.js +0 -4
- package/useTheme.js +0 -6
- package/useThemeProps/getThemeProps.js +0 -4
- package/useThemeProps/index.js +0 -3
- package/useThemeProps/useThemeProps.js +0 -4
- package/useThemeWithoutDefault.js +0 -4
|
@@ -4,92 +4,76 @@ import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from './ge
|
|
|
4
4
|
export function getSystemMode(mode) {
|
|
5
5
|
if (typeof window !== 'undefined' && mode === 'system') {
|
|
6
6
|
var mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
7
|
-
|
|
8
7
|
if (mql.matches) {
|
|
9
8
|
return 'dark';
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
return 'light';
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
return undefined;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function processState(state, callback) {
|
|
19
15
|
if (state.mode === 'light' || state.mode === 'system' && state.systemMode === 'light') {
|
|
20
16
|
return callback('light');
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
if (state.mode === 'dark' || state.mode === 'system' && state.systemMode === 'dark') {
|
|
24
19
|
return callback('dark');
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
return undefined;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
export function getColorScheme(state) {
|
|
31
24
|
return processState(state, function (mode) {
|
|
32
25
|
if (mode === 'light') {
|
|
33
26
|
return state.lightColorScheme;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
if (mode === 'dark') {
|
|
37
29
|
return state.darkColorScheme;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
return undefined;
|
|
41
32
|
});
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
function initializeValue(key, defaultValue) {
|
|
45
35
|
if (typeof window === 'undefined') {
|
|
46
36
|
return undefined;
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
var value;
|
|
50
|
-
|
|
51
39
|
try {
|
|
52
40
|
value = localStorage.getItem(key) || undefined;
|
|
53
|
-
|
|
54
41
|
if (!value) {
|
|
55
42
|
// the first time that user enters the site.
|
|
56
43
|
localStorage.setItem(key, defaultValue);
|
|
57
44
|
}
|
|
58
|
-
} catch (e) {
|
|
45
|
+
} catch (e) {
|
|
46
|
+
// Unsupported
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
return value || defaultValue;
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
export default function useCurrentColorScheme(options) {
|
|
65
51
|
var _options$defaultMode = options.defaultMode,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
defaultMode = _options$defaultMode === void 0 ? 'light' : _options$defaultMode,
|
|
53
|
+
defaultLightColorScheme = options.defaultLightColorScheme,
|
|
54
|
+
defaultDarkColorScheme = options.defaultDarkColorScheme,
|
|
55
|
+
_options$supportedCol = options.supportedColorSchemes,
|
|
56
|
+
supportedColorSchemes = _options$supportedCol === void 0 ? [] : _options$supportedCol,
|
|
57
|
+
_options$modeStorageK = options.modeStorageKey,
|
|
58
|
+
modeStorageKey = _options$modeStorageK === void 0 ? DEFAULT_MODE_STORAGE_KEY : _options$modeStorageK,
|
|
59
|
+
_options$colorSchemeS = options.colorSchemeStorageKey,
|
|
60
|
+
colorSchemeStorageKey = _options$colorSchemeS === void 0 ? DEFAULT_COLOR_SCHEME_STORAGE_KEY : _options$colorSchemeS,
|
|
61
|
+
_options$storageWindo = options.storageWindow,
|
|
62
|
+
storageWindow = _options$storageWindo === void 0 ? typeof window === 'undefined' ? undefined : window : _options$storageWindo;
|
|
77
63
|
var joinedColorSchemes = supportedColorSchemes.join(',');
|
|
78
|
-
|
|
79
64
|
var _React$useState = React.useState(function () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
65
|
+
var initialMode = initializeValue(modeStorageKey, defaultMode);
|
|
66
|
+
var lightColorScheme = initializeValue("".concat(colorSchemeStorageKey, "-light"), defaultLightColorScheme);
|
|
67
|
+
var darkColorScheme = initializeValue("".concat(colorSchemeStorageKey, "-dark"), defaultDarkColorScheme);
|
|
68
|
+
return {
|
|
69
|
+
mode: initialMode,
|
|
70
|
+
systemMode: getSystemMode(initialMode),
|
|
71
|
+
lightColorScheme: lightColorScheme,
|
|
72
|
+
darkColorScheme: darkColorScheme
|
|
73
|
+
};
|
|
74
|
+
}),
|
|
75
|
+
state = _React$useState[0],
|
|
76
|
+
setState = _React$useState[1];
|
|
93
77
|
var colorScheme = getColorScheme(state);
|
|
94
78
|
var setMode = React.useCallback(function (mode) {
|
|
95
79
|
setState(function (currentState) {
|
|
@@ -97,14 +81,12 @@ export default function useCurrentColorScheme(options) {
|
|
|
97
81
|
// do nothing if mode does not change
|
|
98
82
|
return currentState;
|
|
99
83
|
}
|
|
100
|
-
|
|
101
84
|
var newMode = !mode ? defaultMode : mode;
|
|
102
|
-
|
|
103
85
|
try {
|
|
104
86
|
localStorage.setItem(modeStorageKey, newMode);
|
|
105
|
-
} catch (e) {
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// Unsupported
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
return _extends({}, currentState, {
|
|
109
91
|
mode: newMode,
|
|
110
92
|
systemMode: getSystemMode(newMode)
|
|
@@ -117,9 +99,9 @@ export default function useCurrentColorScheme(options) {
|
|
|
117
99
|
try {
|
|
118
100
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-light"), defaultLightColorScheme);
|
|
119
101
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), defaultDarkColorScheme);
|
|
120
|
-
} catch (e) {
|
|
102
|
+
} catch (e) {
|
|
103
|
+
// Unsupported
|
|
121
104
|
}
|
|
122
|
-
|
|
123
105
|
return _extends({}, currentState, {
|
|
124
106
|
lightColorScheme: defaultLightColorScheme,
|
|
125
107
|
darkColorScheme: defaultDarkColorScheme
|
|
@@ -131,17 +113,15 @@ export default function useCurrentColorScheme(options) {
|
|
|
131
113
|
} else {
|
|
132
114
|
setState(function (currentState) {
|
|
133
115
|
var newState = _extends({}, currentState);
|
|
134
|
-
|
|
135
116
|
processState(currentState, function (mode) {
|
|
136
117
|
try {
|
|
137
118
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-").concat(mode), value);
|
|
138
|
-
} catch (e) {
|
|
119
|
+
} catch (e) {
|
|
120
|
+
// Unsupported
|
|
139
121
|
}
|
|
140
|
-
|
|
141
122
|
if (mode === 'light') {
|
|
142
123
|
newState.lightColorScheme = value;
|
|
143
124
|
}
|
|
144
|
-
|
|
145
125
|
if (mode === 'dark') {
|
|
146
126
|
newState.darkColorScheme = value;
|
|
147
127
|
}
|
|
@@ -152,36 +132,32 @@ export default function useCurrentColorScheme(options) {
|
|
|
152
132
|
} else {
|
|
153
133
|
setState(function (currentState) {
|
|
154
134
|
var newState = _extends({}, currentState);
|
|
155
|
-
|
|
156
135
|
var newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
157
136
|
var newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
158
|
-
|
|
159
137
|
if (newLightColorScheme) {
|
|
160
138
|
if (!joinedColorSchemes.includes(newLightColorScheme)) {
|
|
161
139
|
console.error("`".concat(newLightColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
162
140
|
} else {
|
|
163
141
|
newState.lightColorScheme = newLightColorScheme;
|
|
164
|
-
|
|
165
142
|
try {
|
|
166
143
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-light"), newLightColorScheme);
|
|
167
|
-
} catch (error) {
|
|
144
|
+
} catch (error) {
|
|
145
|
+
// Unsupported
|
|
168
146
|
}
|
|
169
147
|
}
|
|
170
148
|
}
|
|
171
|
-
|
|
172
149
|
if (newDarkColorScheme) {
|
|
173
150
|
if (!joinedColorSchemes.includes(newDarkColorScheme)) {
|
|
174
151
|
console.error("`".concat(newDarkColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
175
152
|
} else {
|
|
176
153
|
newState.darkColorScheme = newDarkColorScheme;
|
|
177
|
-
|
|
178
154
|
try {
|
|
179
155
|
localStorage.setItem("".concat(colorSchemeStorageKey, "-dark"), newDarkColorScheme);
|
|
180
|
-
} catch (error) {
|
|
156
|
+
} catch (error) {
|
|
157
|
+
// Unsupported
|
|
181
158
|
}
|
|
182
159
|
}
|
|
183
160
|
}
|
|
184
|
-
|
|
185
161
|
return newState;
|
|
186
162
|
});
|
|
187
163
|
}
|
|
@@ -194,29 +170,31 @@ export default function useCurrentColorScheme(options) {
|
|
|
194
170
|
});
|
|
195
171
|
});
|
|
196
172
|
}
|
|
197
|
-
}, [state.mode]);
|
|
173
|
+
}, [state.mode]);
|
|
198
174
|
|
|
175
|
+
// Ref hack to avoid adding handleMediaQuery as a dep
|
|
199
176
|
var mediaListener = React.useRef(handleMediaQuery);
|
|
200
177
|
mediaListener.current = handleMediaQuery;
|
|
201
178
|
React.useEffect(function () {
|
|
202
179
|
var handler = function handler() {
|
|
203
180
|
return mediaListener.current.apply(mediaListener, arguments);
|
|
204
|
-
};
|
|
205
|
-
|
|
181
|
+
};
|
|
206
182
|
|
|
207
|
-
|
|
183
|
+
// Always listen to System preference
|
|
184
|
+
var media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
208
185
|
|
|
186
|
+
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
209
187
|
media.addListener(handler);
|
|
210
188
|
handler(media);
|
|
211
189
|
return function () {
|
|
212
190
|
return media.removeListener(handler);
|
|
213
191
|
};
|
|
214
|
-
}, []);
|
|
192
|
+
}, []);
|
|
215
193
|
|
|
194
|
+
// Handle when localStorage has changed
|
|
216
195
|
React.useEffect(function () {
|
|
217
196
|
var handleStorage = function handleStorage(event) {
|
|
218
197
|
var value = event.newValue;
|
|
219
|
-
|
|
220
198
|
if (typeof event.key === 'string' && event.key.startsWith(colorSchemeStorageKey) && (!value || joinedColorSchemes.match(value))) {
|
|
221
199
|
// If the key is deleted, value will be null then reset color scheme to the default one.
|
|
222
200
|
if (event.key.endsWith('light')) {
|
|
@@ -224,19 +202,16 @@ export default function useCurrentColorScheme(options) {
|
|
|
224
202
|
light: value
|
|
225
203
|
});
|
|
226
204
|
}
|
|
227
|
-
|
|
228
205
|
if (event.key.endsWith('dark')) {
|
|
229
206
|
setColorScheme({
|
|
230
207
|
dark: value
|
|
231
208
|
});
|
|
232
209
|
}
|
|
233
210
|
}
|
|
234
|
-
|
|
235
211
|
if (event.key === modeStorageKey && (!value || ['light', 'dark', 'system'].includes(value))) {
|
|
236
212
|
setMode(value || defaultMode);
|
|
237
213
|
}
|
|
238
214
|
};
|
|
239
|
-
|
|
240
215
|
if (storageWindow) {
|
|
241
216
|
// For syncing color-scheme changes between iframes
|
|
242
217
|
storageWindow.addEventListener('storage', handleStorage);
|
|
@@ -244,7 +219,6 @@ export default function useCurrentColorScheme(options) {
|
|
|
244
219
|
return storageWindow.removeEventListener('storage', handleStorage);
|
|
245
220
|
};
|
|
246
221
|
}
|
|
247
|
-
|
|
248
222
|
return undefined;
|
|
249
223
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
|
|
250
224
|
return _extends({}, state, {
|
package/legacy/getThemeValue.js
CHANGED
|
@@ -39,13 +39,10 @@ export var propToStyleFunction = Object.keys(filterPropsMapping).reduce(function
|
|
|
39
39
|
});
|
|
40
40
|
return acc;
|
|
41
41
|
}, {});
|
|
42
|
-
|
|
43
42
|
function getThemeValue(prop, value, theme) {
|
|
44
43
|
var _inputProps;
|
|
45
|
-
|
|
46
44
|
var inputProps = (_inputProps = {}, _defineProperty(_inputProps, prop, value), _defineProperty(_inputProps, "theme", theme), _inputProps);
|
|
47
45
|
var styleFunction = propToStyleFunction[prop];
|
|
48
46
|
return styleFunction ? styleFunction(inputProps) : _defineProperty({}, prop, value);
|
|
49
47
|
}
|
|
50
|
-
|
|
51
48
|
export default getThemeValue;
|
package/legacy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.10.
|
|
1
|
+
/** @license MUI v5.10.15
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -23,7 +23,7 @@ export { default as sizing } from './sizing';
|
|
|
23
23
|
export * from './sizing';
|
|
24
24
|
export { default as spacing } from './spacing';
|
|
25
25
|
export * from './spacing';
|
|
26
|
-
export { default as style, getPath } from './style';
|
|
26
|
+
export { default as style, getPath, getStyleValue } from './style';
|
|
27
27
|
export { default as typography } from './typography';
|
|
28
28
|
export * from './typography';
|
|
29
29
|
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
@@ -45,10 +45,10 @@ export * from './colorManipulator';
|
|
|
45
45
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
46
46
|
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
47
47
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
48
|
-
|
|
48
|
+
export { default as responsivePropType } from './responsivePropType';
|
|
49
49
|
|
|
50
|
+
/** ----------------- */
|
|
50
51
|
/** Layout components */
|
|
51
|
-
|
|
52
52
|
export { default as createContainer } from './Container/createContainer';
|
|
53
53
|
export { default as Container } from './Container';
|
|
54
54
|
export * from './Container';
|
package/legacy/memoize.js
CHANGED
package/legacy/merge.js
CHANGED
package/legacy/palette.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
|
-
|
|
4
3
|
function transform(value, userValue) {
|
|
5
4
|
if (userValue === 'grey') {
|
|
6
5
|
return userValue;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
return value;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
export var color = style({
|
|
13
10
|
prop: 'color',
|
|
14
11
|
themeKey: 'palette',
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import { unstable_capitalize as capitalize } from '@mui/utils';
|
|
3
|
-
|
|
4
3
|
function isEmpty(string) {
|
|
5
4
|
return string.length === 0;
|
|
6
5
|
}
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* Generates string classKey based on the properties provided. It starts with the
|
|
9
9
|
* variant if defined, and then it appends all other properties in alphabetical order.
|
|
10
10
|
* @param {object} props - the properties for which the classKey should be created.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
12
|
export default function propsToClassKey(props) {
|
|
15
13
|
var variant = props.variant,
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
other = _objectWithoutProperties(props, ["variant"]);
|
|
18
15
|
var classKey = variant || '';
|
|
19
16
|
Object.keys(other).sort().forEach(function (key) {
|
|
20
17
|
if (key === 'color') {
|
package/legacy/sizing.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
3
|
import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
|
|
4
|
-
|
|
5
4
|
function transform(value) {
|
|
6
5
|
return value <= 1 && value !== 0 ? "".concat(value * 100, "%") : value;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
export var width = style({
|
|
10
8
|
prop: 'width',
|
|
11
9
|
transform: transform
|
|
@@ -14,16 +12,13 @@ export var maxWidth = function maxWidth(props) {
|
|
|
14
12
|
if (props.maxWidth !== undefined && props.maxWidth !== null) {
|
|
15
13
|
var styleFromPropValue = function styleFromPropValue(propValue) {
|
|
16
14
|
var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
|
|
17
|
-
|
|
18
15
|
var breakpoint = ((_props$theme = props.theme) == null ? void 0 : (_props$theme$breakpoi = _props$theme.breakpoints) == null ? void 0 : (_props$theme$breakpoi2 = _props$theme$breakpoi.values) == null ? void 0 : _props$theme$breakpoi2[propValue]) || breakpointsValues[propValue];
|
|
19
16
|
return {
|
|
20
17
|
maxWidth: breakpoint || transform(propValue)
|
|
21
18
|
};
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
return null;
|
|
28
23
|
};
|
|
29
24
|
maxWidth.filterProps = ['maxWidth'];
|
package/legacy/spacing.js
CHANGED
|
@@ -21,10 +21,11 @@ var aliases = {
|
|
|
21
21
|
marginY: 'my',
|
|
22
22
|
paddingX: 'px',
|
|
23
23
|
paddingY: 'py'
|
|
24
|
-
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// memoize() impact:
|
|
25
27
|
// From 300,000 ops/sec
|
|
26
28
|
// To 350,000 ops/sec
|
|
27
|
-
|
|
28
29
|
var getCssProperties = memoize(function (prop) {
|
|
29
30
|
// It's not a shorthand notation.
|
|
30
31
|
if (prop.length > 2) {
|
|
@@ -34,12 +35,10 @@ var getCssProperties = memoize(function (prop) {
|
|
|
34
35
|
return [prop];
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
|
|
38
38
|
var _prop$split = prop.split(''),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
_prop$split2 = _slicedToArray(_prop$split, 2),
|
|
40
|
+
a = _prop$split2[0],
|
|
41
|
+
b = _prop$split2[1];
|
|
43
42
|
var property = properties[a];
|
|
44
43
|
var direction = directions[b] || '';
|
|
45
44
|
return Array.isArray(direction) ? direction.map(function (dir) {
|
|
@@ -51,31 +50,25 @@ var paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingT
|
|
|
51
50
|
var spacingKeys = [].concat(marginKeys, paddingKeys);
|
|
52
51
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
53
52
|
var _getPath;
|
|
54
|
-
|
|
55
53
|
var themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
|
|
56
|
-
|
|
57
54
|
if (typeof themeSpacing === 'number') {
|
|
58
55
|
return function (abs) {
|
|
59
56
|
if (typeof abs === 'string') {
|
|
60
57
|
return abs;
|
|
61
58
|
}
|
|
62
|
-
|
|
63
59
|
if (process.env.NODE_ENV !== 'production') {
|
|
64
60
|
if (typeof abs !== 'number') {
|
|
65
61
|
console.error("MUI: Expected ".concat(propName, " argument to be a number or a string, got ").concat(abs, "."));
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
|
|
69
64
|
return themeSpacing * abs;
|
|
70
65
|
};
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
if (Array.isArray(themeSpacing)) {
|
|
74
68
|
return function (abs) {
|
|
75
69
|
if (typeof abs === 'string') {
|
|
76
70
|
return abs;
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
if (process.env.NODE_ENV !== 'production') {
|
|
80
73
|
if (!Number.isInteger(abs)) {
|
|
81
74
|
console.error(["MUI: The `theme.".concat(themeKey, "` array type cannot be combined with non integer values.") + "You should either use an integer value that can be used as index, or define the `theme.".concat(themeKey, "` as a number.")].join('\n'));
|
|
@@ -83,19 +76,15 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
83
76
|
console.error(["MUI: The value provided (".concat(abs, ") overflows."), "The supported values are: ".concat(JSON.stringify(themeSpacing), "."), "".concat(abs, " > ").concat(themeSpacing.length - 1, ", you need to add the missing values.")].join('\n'));
|
|
84
77
|
}
|
|
85
78
|
}
|
|
86
|
-
|
|
87
79
|
return themeSpacing[abs];
|
|
88
80
|
};
|
|
89
81
|
}
|
|
90
|
-
|
|
91
82
|
if (typeof themeSpacing === 'function') {
|
|
92
83
|
return themeSpacing;
|
|
93
84
|
}
|
|
94
|
-
|
|
95
85
|
if (process.env.NODE_ENV !== 'production') {
|
|
96
86
|
console.error(["MUI: The `theme.".concat(themeKey, "` value (").concat(themeSpacing, ") is invalid."), 'It should be a number, an array or a function.'].join('\n'));
|
|
97
87
|
}
|
|
98
|
-
|
|
99
88
|
return function () {
|
|
100
89
|
return undefined;
|
|
101
90
|
};
|
|
@@ -107,18 +96,14 @@ export function getValue(transformer, propValue) {
|
|
|
107
96
|
if (typeof propValue === 'string' || propValue == null) {
|
|
108
97
|
return propValue;
|
|
109
98
|
}
|
|
110
|
-
|
|
111
99
|
var abs = Math.abs(propValue);
|
|
112
100
|
var transformed = transformer(abs);
|
|
113
|
-
|
|
114
101
|
if (propValue >= 0) {
|
|
115
102
|
return transformed;
|
|
116
103
|
}
|
|
117
|
-
|
|
118
104
|
if (typeof transformed === 'number') {
|
|
119
105
|
return -transformed;
|
|
120
106
|
}
|
|
121
|
-
|
|
122
107
|
return "-".concat(transformed);
|
|
123
108
|
}
|
|
124
109
|
export function getStyleFromPropValue(cssProperties, transformer) {
|
|
@@ -129,27 +114,23 @@ export function getStyleFromPropValue(cssProperties, transformer) {
|
|
|
129
114
|
}, {});
|
|
130
115
|
};
|
|
131
116
|
}
|
|
132
|
-
|
|
133
117
|
function resolveCssProperty(props, keys, prop, transformer) {
|
|
134
118
|
// Using a hash computation over an array iteration could be faster, but with only 28 items,
|
|
135
119
|
// it's doesn't worth the bundle size.
|
|
136
120
|
if (keys.indexOf(prop) === -1) {
|
|
137
121
|
return null;
|
|
138
122
|
}
|
|
139
|
-
|
|
140
123
|
var cssProperties = getCssProperties(prop);
|
|
141
124
|
var styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
|
|
142
125
|
var propValue = props[prop];
|
|
143
126
|
return handleBreakpoints(props, propValue, styleFromPropValue);
|
|
144
127
|
}
|
|
145
|
-
|
|
146
128
|
function style(props, keys) {
|
|
147
129
|
var transformer = createUnarySpacing(props.theme);
|
|
148
130
|
return Object.keys(props).map(function (prop) {
|
|
149
131
|
return resolveCssProperty(props, keys, prop, transformer);
|
|
150
132
|
}).reduce(merge, {});
|
|
151
133
|
}
|
|
152
|
-
|
|
153
134
|
export function margin(props) {
|
|
154
135
|
return style(props, marginKeys);
|
|
155
136
|
}
|
|
@@ -166,11 +147,9 @@ padding.propTypes = process.env.NODE_ENV !== 'production' ? paddingKeys.reduce(f
|
|
|
166
147
|
return obj;
|
|
167
148
|
}, {}) : {};
|
|
168
149
|
padding.filterProps = paddingKeys;
|
|
169
|
-
|
|
170
150
|
function spacing(props) {
|
|
171
151
|
return style(props, spacingKeys);
|
|
172
152
|
}
|
|
173
|
-
|
|
174
153
|
spacing.propTypes = process.env.NODE_ENV !== 'production' ? spacingKeys.reduce(function (obj, key) {
|
|
175
154
|
obj[key] = responsivePropType;
|
|
176
155
|
return obj;
|
package/legacy/style.js
CHANGED
|
@@ -4,35 +4,29 @@ import responsivePropType from './responsivePropType';
|
|
|
4
4
|
import { handleBreakpoints } from './breakpoints';
|
|
5
5
|
export function getPath(obj, path) {
|
|
6
6
|
var checkVars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
7
|
-
|
|
8
7
|
if (!path || typeof path !== 'string') {
|
|
9
8
|
return null;
|
|
10
|
-
}
|
|
11
|
-
|
|
9
|
+
}
|
|
12
10
|
|
|
11
|
+
// Check if CSS variables are used
|
|
13
12
|
if (obj && obj.vars && checkVars) {
|
|
14
13
|
var val = "vars.".concat(path).split('.').reduce(function (acc, item) {
|
|
15
14
|
return acc && acc[item] ? acc[item] : null;
|
|
16
15
|
}, obj);
|
|
17
|
-
|
|
18
16
|
if (val != null) {
|
|
19
17
|
return val;
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
return path.split('.').reduce(function (acc, item) {
|
|
24
21
|
if (acc && acc[item] != null) {
|
|
25
22
|
return acc[item];
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return null;
|
|
29
25
|
}, obj);
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
function getValue(themeMapping, transform, propValueFinal) {
|
|
27
|
+
export function getStyleValue(themeMapping, transform, propValueFinal) {
|
|
33
28
|
var userValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : propValueFinal;
|
|
34
29
|
var value;
|
|
35
|
-
|
|
36
30
|
if (typeof themeMapping === 'function') {
|
|
37
31
|
value = themeMapping(propValueFinal);
|
|
38
32
|
} else if (Array.isArray(themeMapping)) {
|
|
@@ -40,51 +34,39 @@ function getValue(themeMapping, transform, propValueFinal) {
|
|
|
40
34
|
} else {
|
|
41
35
|
value = getPath(themeMapping, propValueFinal) || userValue;
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
if (transform) {
|
|
45
38
|
value = transform(value, userValue);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
return value;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
function style(options) {
|
|
52
43
|
var prop = options.prop,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
_options$cssProperty = options.cssProperty,
|
|
45
|
+
cssProperty = _options$cssProperty === void 0 ? options.prop : _options$cssProperty,
|
|
46
|
+
themeKey = options.themeKey,
|
|
47
|
+
transform = options.transform;
|
|
58
48
|
var fn = function fn(props) {
|
|
59
49
|
if (props[prop] == null) {
|
|
60
50
|
return null;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
var propValue = props[prop];
|
|
64
53
|
var theme = props.theme;
|
|
65
54
|
var themeMapping = getPath(theme, themeKey) || {};
|
|
66
|
-
|
|
67
55
|
var styleFromPropValue = function styleFromPropValue(propValueFinal) {
|
|
68
|
-
var value =
|
|
69
|
-
|
|
56
|
+
var value = getStyleValue(themeMapping, transform, propValueFinal);
|
|
70
57
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
71
58
|
// Haven't found value
|
|
72
|
-
value =
|
|
59
|
+
value = getStyleValue(themeMapping, transform, "".concat(prop).concat(propValueFinal === 'default' ? '' : capitalize(propValueFinal)), propValueFinal);
|
|
73
60
|
}
|
|
74
|
-
|
|
75
61
|
if (cssProperty === false) {
|
|
76
62
|
return value;
|
|
77
63
|
}
|
|
78
|
-
|
|
79
64
|
return _defineProperty({}, cssProperty, value);
|
|
80
65
|
};
|
|
81
|
-
|
|
82
66
|
return handleBreakpoints(props, propValue, styleFromPropValue);
|
|
83
67
|
};
|
|
84
|
-
|
|
85
68
|
fn.propTypes = process.env.NODE_ENV !== 'production' ? _defineProperty({}, prop, responsivePropType) : {};
|
|
86
69
|
fn.filterProps = [prop];
|
|
87
70
|
return fn;
|
|
88
71
|
}
|
|
89
|
-
|
|
90
72
|
export default style;
|