@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
|
@@ -1,84 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = useCurrentColorScheme;
|
|
9
8
|
exports.getColorScheme = getColorScheme;
|
|
10
9
|
exports.getSystemMode = getSystemMode;
|
|
11
|
-
|
|
12
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
11
|
var React = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
12
|
var _getInitColorSchemeScript = require("./getInitColorSchemeScript");
|
|
17
|
-
|
|
18
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
15
|
function getSystemMode(mode) {
|
|
23
16
|
if (typeof window !== 'undefined' && mode === 'system') {
|
|
24
17
|
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
25
|
-
|
|
26
18
|
if (mql.matches) {
|
|
27
19
|
return 'dark';
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
return 'light';
|
|
31
22
|
}
|
|
32
|
-
|
|
33
23
|
return undefined;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
25
|
function processState(state, callback) {
|
|
37
26
|
if (state.mode === 'light' || state.mode === 'system' && state.systemMode === 'light') {
|
|
38
27
|
return callback('light');
|
|
39
28
|
}
|
|
40
|
-
|
|
41
29
|
if (state.mode === 'dark' || state.mode === 'system' && state.systemMode === 'dark') {
|
|
42
30
|
return callback('dark');
|
|
43
31
|
}
|
|
44
|
-
|
|
45
32
|
return undefined;
|
|
46
33
|
}
|
|
47
|
-
|
|
48
34
|
function getColorScheme(state) {
|
|
49
35
|
return processState(state, mode => {
|
|
50
36
|
if (mode === 'light') {
|
|
51
37
|
return state.lightColorScheme;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
if (mode === 'dark') {
|
|
55
40
|
return state.darkColorScheme;
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
return undefined;
|
|
59
43
|
});
|
|
60
44
|
}
|
|
61
|
-
|
|
62
45
|
function initializeValue(key, defaultValue) {
|
|
63
46
|
if (typeof window === 'undefined') {
|
|
64
47
|
return undefined;
|
|
65
48
|
}
|
|
66
|
-
|
|
67
49
|
let value;
|
|
68
|
-
|
|
69
50
|
try {
|
|
70
51
|
value = localStorage.getItem(key) || undefined;
|
|
71
|
-
|
|
72
52
|
if (!value) {
|
|
73
53
|
// the first time that user enters the site.
|
|
74
54
|
localStorage.setItem(key, defaultValue);
|
|
75
55
|
}
|
|
76
|
-
} catch (e) {
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// Unsupported
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
return value || defaultValue;
|
|
80
60
|
}
|
|
81
|
-
|
|
82
61
|
function useCurrentColorScheme(options) {
|
|
83
62
|
const {
|
|
84
63
|
defaultMode = 'light',
|
|
@@ -108,14 +87,12 @@ function useCurrentColorScheme(options) {
|
|
|
108
87
|
// do nothing if mode does not change
|
|
109
88
|
return currentState;
|
|
110
89
|
}
|
|
111
|
-
|
|
112
90
|
const newMode = !mode ? defaultMode : mode;
|
|
113
|
-
|
|
114
91
|
try {
|
|
115
92
|
localStorage.setItem(modeStorageKey, newMode);
|
|
116
|
-
} catch (e) {
|
|
93
|
+
} catch (e) {
|
|
94
|
+
// Unsupported
|
|
117
95
|
}
|
|
118
|
-
|
|
119
96
|
return (0, _extends2.default)({}, currentState, {
|
|
120
97
|
mode: newMode,
|
|
121
98
|
systemMode: getSystemMode(newMode)
|
|
@@ -128,9 +105,9 @@ function useCurrentColorScheme(options) {
|
|
|
128
105
|
try {
|
|
129
106
|
localStorage.setItem(`${colorSchemeStorageKey}-light`, defaultLightColorScheme);
|
|
130
107
|
localStorage.setItem(`${colorSchemeStorageKey}-dark`, defaultDarkColorScheme);
|
|
131
|
-
} catch (e) {
|
|
108
|
+
} catch (e) {
|
|
109
|
+
// Unsupported
|
|
132
110
|
}
|
|
133
|
-
|
|
134
111
|
return (0, _extends2.default)({}, currentState, {
|
|
135
112
|
lightColorScheme: defaultLightColorScheme,
|
|
136
113
|
darkColorScheme: defaultDarkColorScheme
|
|
@@ -145,13 +122,12 @@ function useCurrentColorScheme(options) {
|
|
|
145
122
|
processState(currentState, mode => {
|
|
146
123
|
try {
|
|
147
124
|
localStorage.setItem(`${colorSchemeStorageKey}-${mode}`, value);
|
|
148
|
-
} catch (e) {
|
|
125
|
+
} catch (e) {
|
|
126
|
+
// Unsupported
|
|
149
127
|
}
|
|
150
|
-
|
|
151
128
|
if (mode === 'light') {
|
|
152
129
|
newState.lightColorScheme = value;
|
|
153
130
|
}
|
|
154
|
-
|
|
155
131
|
if (mode === 'dark') {
|
|
156
132
|
newState.darkColorScheme = value;
|
|
157
133
|
}
|
|
@@ -164,33 +140,30 @@ function useCurrentColorScheme(options) {
|
|
|
164
140
|
const newState = (0, _extends2.default)({}, currentState);
|
|
165
141
|
const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
166
142
|
const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
167
|
-
|
|
168
143
|
if (newLightColorScheme) {
|
|
169
144
|
if (!joinedColorSchemes.includes(newLightColorScheme)) {
|
|
170
145
|
console.error(`\`${newLightColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
171
146
|
} else {
|
|
172
147
|
newState.lightColorScheme = newLightColorScheme;
|
|
173
|
-
|
|
174
148
|
try {
|
|
175
149
|
localStorage.setItem(`${colorSchemeStorageKey}-light`, newLightColorScheme);
|
|
176
|
-
} catch (error) {
|
|
150
|
+
} catch (error) {
|
|
151
|
+
// Unsupported
|
|
177
152
|
}
|
|
178
153
|
}
|
|
179
154
|
}
|
|
180
|
-
|
|
181
155
|
if (newDarkColorScheme) {
|
|
182
156
|
if (!joinedColorSchemes.includes(newDarkColorScheme)) {
|
|
183
157
|
console.error(`\`${newDarkColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
184
158
|
} else {
|
|
185
159
|
newState.darkColorScheme = newDarkColorScheme;
|
|
186
|
-
|
|
187
160
|
try {
|
|
188
161
|
localStorage.setItem(`${colorSchemeStorageKey}-dark`, newDarkColorScheme);
|
|
189
|
-
} catch (error) {
|
|
162
|
+
} catch (error) {
|
|
163
|
+
// Unsupported
|
|
190
164
|
}
|
|
191
165
|
}
|
|
192
166
|
}
|
|
193
|
-
|
|
194
167
|
return newState;
|
|
195
168
|
});
|
|
196
169
|
}
|
|
@@ -201,25 +174,27 @@ function useCurrentColorScheme(options) {
|
|
|
201
174
|
systemMode: e != null && e.matches ? 'dark' : 'light'
|
|
202
175
|
}));
|
|
203
176
|
}
|
|
204
|
-
}, [state.mode]);
|
|
177
|
+
}, [state.mode]);
|
|
205
178
|
|
|
179
|
+
// Ref hack to avoid adding handleMediaQuery as a dep
|
|
206
180
|
const mediaListener = React.useRef(handleMediaQuery);
|
|
207
181
|
mediaListener.current = handleMediaQuery;
|
|
208
182
|
React.useEffect(() => {
|
|
209
|
-
const handler = (...args) => mediaListener.current(...args);
|
|
183
|
+
const handler = (...args) => mediaListener.current(...args);
|
|
210
184
|
|
|
185
|
+
// Always listen to System preference
|
|
186
|
+
const media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
211
187
|
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
214
189
|
media.addListener(handler);
|
|
215
190
|
handler(media);
|
|
216
191
|
return () => media.removeListener(handler);
|
|
217
|
-
}, []);
|
|
192
|
+
}, []);
|
|
218
193
|
|
|
194
|
+
// Handle when localStorage has changed
|
|
219
195
|
React.useEffect(() => {
|
|
220
196
|
const handleStorage = event => {
|
|
221
197
|
const value = event.newValue;
|
|
222
|
-
|
|
223
198
|
if (typeof event.key === 'string' && event.key.startsWith(colorSchemeStorageKey) && (!value || joinedColorSchemes.match(value))) {
|
|
224
199
|
// If the key is deleted, value will be null then reset color scheme to the default one.
|
|
225
200
|
if (event.key.endsWith('light')) {
|
|
@@ -227,25 +202,21 @@ function useCurrentColorScheme(options) {
|
|
|
227
202
|
light: value
|
|
228
203
|
});
|
|
229
204
|
}
|
|
230
|
-
|
|
231
205
|
if (event.key.endsWith('dark')) {
|
|
232
206
|
setColorScheme({
|
|
233
207
|
dark: value
|
|
234
208
|
});
|
|
235
209
|
}
|
|
236
210
|
}
|
|
237
|
-
|
|
238
211
|
if (event.key === modeStorageKey && (!value || ['light', 'dark', 'system'].includes(value))) {
|
|
239
212
|
setMode(value || defaultMode);
|
|
240
213
|
}
|
|
241
214
|
};
|
|
242
|
-
|
|
243
215
|
if (storageWindow) {
|
|
244
216
|
// For syncing color-scheme changes between iframes
|
|
245
217
|
storageWindow.addEventListener('storage', handleStorage);
|
|
246
218
|
return () => storageWindow.removeEventListener('storage', handleStorage);
|
|
247
219
|
}
|
|
248
|
-
|
|
249
220
|
return undefined;
|
|
250
221
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
|
|
251
222
|
return (0, _extends2.default)({}, state, {
|
package/display.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.whiteSpace = exports.visibility = exports.textOverflow = exports.overflow = exports.displayRaw = exports.displayPrint = exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _style = _interopRequireDefault(require("./style"));
|
|
11
|
-
|
|
12
9
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
13
|
-
|
|
14
10
|
const displayPrint = (0, _style.default)({
|
|
15
11
|
prop: 'displayPrint',
|
|
16
12
|
cssProperty: false,
|
|
@@ -41,7 +37,5 @@ const whiteSpace = (0, _style.default)({
|
|
|
41
37
|
prop: 'whiteSpace'
|
|
42
38
|
});
|
|
43
39
|
exports.whiteSpace = whiteSpace;
|
|
44
|
-
|
|
45
40
|
var _default = (0, _compose.default)(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
|
|
46
|
-
|
|
47
41
|
exports.default = _default;
|
package/esm/Box/Box.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import createBox from '../createBox';
|
|
3
3
|
const Box = createBox();
|
|
4
|
-
process.env.NODE_ENV !== "production" ? Box.propTypes
|
|
5
|
-
/* remove-proptypes */
|
|
6
|
-
= {
|
|
4
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes /* remove-proptypes */ = {
|
|
7
5
|
// ----------------------------- Warning --------------------------------
|
|
8
6
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
9
7
|
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
10
8
|
// ----------------------------------------------------------------------
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* @ignore
|
|
14
11
|
*/
|
|
15
12
|
children: PropTypes.node,
|
|
16
|
-
|
|
17
13
|
/**
|
|
18
14
|
* The component used for the root node.
|
|
19
15
|
* Either a string to use a HTML element or a component.
|
|
20
16
|
*/
|
|
21
17
|
component: PropTypes.elementType,
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
19
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
25
20
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import createContainer from './createContainer';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
* Demos:
|
|
@@ -11,38 +12,30 @@ import createContainer from './createContainer';
|
|
|
11
12
|
*
|
|
12
13
|
* - [Container API](https://mui.com/system/api/container/)
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
const Container = createContainer();
|
|
16
|
-
process.env.NODE_ENV !== "production" ? Container.propTypes
|
|
17
|
-
/* remove-proptypes */
|
|
18
|
-
= {
|
|
16
|
+
process.env.NODE_ENV !== "production" ? Container.propTypes /* remove-proptypes */ = {
|
|
19
17
|
// ----------------------------- Warning --------------------------------
|
|
20
18
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
21
19
|
// | To update them edit TypeScript types and run "yarn proptypes" |
|
|
22
20
|
// ----------------------------------------------------------------------
|
|
23
|
-
|
|
24
21
|
/**
|
|
25
22
|
* @ignore
|
|
26
23
|
*/
|
|
27
24
|
children: PropTypes.node,
|
|
28
|
-
|
|
29
25
|
/**
|
|
30
26
|
* Override or extend the styles applied to the component.
|
|
31
27
|
*/
|
|
32
28
|
classes: PropTypes.object,
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* The component used for the root node.
|
|
36
31
|
* Either a string to use a HTML element or a component.
|
|
37
32
|
*/
|
|
38
33
|
component: PropTypes.elementType,
|
|
39
|
-
|
|
40
34
|
/**
|
|
41
35
|
* If `true`, the left and right padding is removed.
|
|
42
36
|
* @default false
|
|
43
37
|
*/
|
|
44
38
|
disableGutters: PropTypes.bool,
|
|
45
|
-
|
|
46
39
|
/**
|
|
47
40
|
* Set the max-width to match the min-width of the current breakpoint.
|
|
48
41
|
* This is useful if you'd prefer to design for a fixed set of sizes
|
|
@@ -51,17 +44,13 @@ process.env.NODE_ENV !== "production" ? Container.propTypes
|
|
|
51
44
|
* @default false
|
|
52
45
|
*/
|
|
53
46
|
fixed: PropTypes.bool,
|
|
54
|
-
|
|
55
47
|
/**
|
|
56
48
|
* Determine the max-width of the container.
|
|
57
49
|
* The container width grows with the size of the screen.
|
|
58
50
|
* Set to `false` to disable `maxWidth`.
|
|
59
51
|
* @default 'lg'
|
|
60
52
|
*/
|
|
61
|
-
maxWidth: PropTypes
|
|
62
|
-
/* @typescript-to-proptypes-ignore */
|
|
63
|
-
.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
|
|
64
|
-
|
|
53
|
+
maxWidth: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
|
|
65
54
|
/**
|
|
66
55
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
67
56
|
*/
|
|
@@ -20,18 +20,15 @@ const defaultCreateStyledComponent = systemStyled('div', {
|
|
|
20
20
|
return [styles.root, styles[`maxWidth${capitalize(String(ownerState.maxWidth))}`], ownerState.fixed && styles.fixed, ownerState.disableGutters && styles.disableGutters];
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
|
|
24
23
|
const useThemePropsDefault = inProps => useThemePropsSystem({
|
|
25
24
|
props: inProps,
|
|
26
25
|
name: 'MuiContainer',
|
|
27
26
|
defaultTheme
|
|
28
27
|
});
|
|
29
|
-
|
|
30
28
|
const useUtilityClasses = (ownerState, componentName) => {
|
|
31
29
|
const getContainerUtilityClass = slot => {
|
|
32
30
|
return generateUtilityClass(componentName, slot);
|
|
33
31
|
};
|
|
34
|
-
|
|
35
32
|
const {
|
|
36
33
|
classes,
|
|
37
34
|
fixed,
|
|
@@ -43,7 +40,6 @@ const useUtilityClasses = (ownerState, componentName) => {
|
|
|
43
40
|
};
|
|
44
41
|
return composeClasses(slots, getContainerUtilityClass, classes);
|
|
45
42
|
};
|
|
46
|
-
|
|
47
43
|
export default function createContainer(options = {}) {
|
|
48
44
|
const {
|
|
49
45
|
// This will allow adding custom styled fn (for example for custom sx style function)
|
|
@@ -74,14 +70,12 @@ export default function createContainer(options = {}) {
|
|
|
74
70
|
}) => ownerState.fixed && Object.keys(theme.breakpoints.values).reduce((acc, breakpointValueKey) => {
|
|
75
71
|
const breakpoint = breakpointValueKey;
|
|
76
72
|
const value = theme.breakpoints.values[breakpoint];
|
|
77
|
-
|
|
78
73
|
if (value !== 0) {
|
|
79
74
|
// @ts-ignore
|
|
80
75
|
acc[theme.breakpoints.up(breakpoint)] = {
|
|
81
76
|
maxWidth: `${value}${theme.breakpoints.unit}`
|
|
82
77
|
};
|
|
83
78
|
}
|
|
84
|
-
|
|
85
79
|
return acc;
|
|
86
80
|
}, {}), ({
|
|
87
81
|
theme,
|
|
@@ -92,7 +86,8 @@ export default function createContainer(options = {}) {
|
|
|
92
86
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
93
87
|
maxWidth: Math.max(theme.breakpoints.values.xs, 444)
|
|
94
88
|
}
|
|
95
|
-
}, ownerState.maxWidth &&
|
|
89
|
+
}, ownerState.maxWidth &&
|
|
90
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
96
91
|
ownerState.maxWidth !== 'xs' && {
|
|
97
92
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
98
93
|
[theme.breakpoints.up(ownerState.maxWidth)]: {
|
|
@@ -102,30 +97,29 @@ export default function createContainer(options = {}) {
|
|
|
102
97
|
}));
|
|
103
98
|
const Container = /*#__PURE__*/React.forwardRef(function Container(inProps, ref) {
|
|
104
99
|
const props = useThemeProps(inProps);
|
|
105
|
-
|
|
106
100
|
const {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
className,
|
|
102
|
+
component = 'div',
|
|
103
|
+
disableGutters = false,
|
|
104
|
+
fixed = false,
|
|
105
|
+
maxWidth = 'lg'
|
|
106
|
+
} = props,
|
|
107
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
115
108
|
const ownerState = _extends({}, props, {
|
|
116
109
|
component,
|
|
117
110
|
disableGutters,
|
|
118
111
|
fixed,
|
|
119
112
|
maxWidth
|
|
120
|
-
});
|
|
121
|
-
|
|
113
|
+
});
|
|
122
114
|
|
|
115
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
123
116
|
const classes = useUtilityClasses(ownerState, componentName);
|
|
124
117
|
return (
|
|
125
118
|
/*#__PURE__*/
|
|
126
119
|
// @ts-ignore theme is injected by the styled util
|
|
127
120
|
_jsx(ContainerRoot, _extends({
|
|
128
|
-
as: component
|
|
121
|
+
as: component
|
|
122
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
129
123
|
,
|
|
130
124
|
ownerState: ownerState,
|
|
131
125
|
className: clsx(classes.root, className),
|
|
@@ -133,18 +127,14 @@ export default function createContainer(options = {}) {
|
|
|
133
127
|
}, other))
|
|
134
128
|
);
|
|
135
129
|
});
|
|
136
|
-
process.env.NODE_ENV !== "production" ? Container.propTypes
|
|
137
|
-
/* remove-proptypes */
|
|
138
|
-
= {
|
|
130
|
+
process.env.NODE_ENV !== "production" ? Container.propTypes /* remove-proptypes */ = {
|
|
139
131
|
children: PropTypes.node,
|
|
140
132
|
classes: PropTypes.object,
|
|
141
133
|
className: PropTypes.string,
|
|
142
134
|
component: PropTypes.elementType,
|
|
143
135
|
disableGutters: PropTypes.bool,
|
|
144
136
|
fixed: PropTypes.bool,
|
|
145
|
-
maxWidth: PropTypes
|
|
146
|
-
/* @typescript-to-proptypes-ignore */
|
|
147
|
-
.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
|
|
137
|
+
maxWidth: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false]), PropTypes.string]),
|
|
148
138
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
149
139
|
} : void 0;
|
|
150
140
|
return Container;
|
package/esm/Stack/Stack.js
CHANGED
|
@@ -11,39 +11,31 @@ import createStack from './createStack';
|
|
|
11
11
|
*
|
|
12
12
|
* - [Stack API](https://mui.com/system/api/stack/)
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
const Stack = createStack();
|
|
16
|
-
process.env.NODE_ENV !== "production" ? Stack.propTypes
|
|
17
|
-
/* remove-proptypes */
|
|
18
|
-
= {
|
|
15
|
+
process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
|
|
19
16
|
// ----------------------------- Warning --------------------------------
|
|
20
17
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
21
18
|
// | To update them edit TypeScript types and run "yarn proptypes" |
|
|
22
19
|
// ----------------------------------------------------------------------
|
|
23
|
-
|
|
24
20
|
/**
|
|
25
21
|
* The content of the component.
|
|
26
22
|
*/
|
|
27
23
|
children: PropTypes.node,
|
|
28
|
-
|
|
29
24
|
/**
|
|
30
25
|
* Defines the `flex-direction` style property.
|
|
31
26
|
* It is applied for all screen sizes.
|
|
32
27
|
* @default 'column'
|
|
33
28
|
*/
|
|
34
29
|
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
35
|
-
|
|
36
30
|
/**
|
|
37
31
|
* Add an element between each child.
|
|
38
32
|
*/
|
|
39
33
|
divider: PropTypes.node,
|
|
40
|
-
|
|
41
34
|
/**
|
|
42
35
|
* Defines the space between immediate children.
|
|
43
36
|
* @default 0
|
|
44
37
|
*/
|
|
45
38
|
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
46
|
-
|
|
47
39
|
/**
|
|
48
40
|
* The system prop, which allows defining system overrides as well as additional CSS styles.
|
|
49
41
|
*/
|
package/esm/Stack/createStack.js
CHANGED
|
@@ -19,7 +19,6 @@ const defaultCreateStyledComponent = systemStyled('div', {
|
|
|
19
19
|
slot: 'Root',
|
|
20
20
|
overridesResolver: (props, styles) => styles.root
|
|
21
21
|
});
|
|
22
|
-
|
|
23
22
|
function useThemePropsDefault(props) {
|
|
24
23
|
return useThemePropsSystem({
|
|
25
24
|
props,
|
|
@@ -27,6 +26,7 @@ function useThemePropsDefault(props) {
|
|
|
27
26
|
defaultTheme
|
|
28
27
|
});
|
|
29
28
|
}
|
|
29
|
+
|
|
30
30
|
/**
|
|
31
31
|
* Return an array with the separator React element interspersed between
|
|
32
32
|
* each React node of the input children.
|
|
@@ -34,23 +34,18 @@ function useThemePropsDefault(props) {
|
|
|
34
34
|
* > joinChildren([1,2,3], 0)
|
|
35
35
|
* [1,0,2,0,3]
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
37
|
function joinChildren(children, separator) {
|
|
40
38
|
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
41
39
|
return childrenArray.reduce((output, child, index) => {
|
|
42
40
|
output.push(child);
|
|
43
|
-
|
|
44
41
|
if (index < childrenArray.length - 1) {
|
|
45
42
|
output.push( /*#__PURE__*/React.cloneElement(separator, {
|
|
46
43
|
key: `separator-${index}`
|
|
47
44
|
}));
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
return output;
|
|
51
47
|
}, []);
|
|
52
48
|
}
|
|
53
|
-
|
|
54
49
|
const getSideFromDirection = direction => {
|
|
55
50
|
return {
|
|
56
51
|
row: 'Left',
|
|
@@ -59,7 +54,6 @@ const getSideFromDirection = direction => {
|
|
|
59
54
|
'column-reverse': 'Bottom'
|
|
60
55
|
}[direction];
|
|
61
56
|
};
|
|
62
|
-
|
|
63
57
|
export const style = ({
|
|
64
58
|
ownerState,
|
|
65
59
|
theme
|
|
@@ -75,14 +69,12 @@ export const style = ({
|
|
|
75
69
|
}), propValue => ({
|
|
76
70
|
flexDirection: propValue
|
|
77
71
|
})));
|
|
78
|
-
|
|
79
72
|
if (ownerState.spacing) {
|
|
80
73
|
const transformer = createUnarySpacing(theme);
|
|
81
74
|
const base = Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
|
|
82
75
|
if (typeof ownerState.spacing === 'object' && ownerState.spacing[breakpoint] != null || typeof ownerState.direction === 'object' && ownerState.direction[breakpoint] != null) {
|
|
83
76
|
acc[breakpoint] = true;
|
|
84
77
|
}
|
|
85
|
-
|
|
86
78
|
return acc;
|
|
87
79
|
}, {});
|
|
88
80
|
const directionValues = resolveBreakpointValues({
|
|
@@ -93,18 +85,15 @@ export const style = ({
|
|
|
93
85
|
values: ownerState.spacing,
|
|
94
86
|
base
|
|
95
87
|
});
|
|
96
|
-
|
|
97
88
|
if (typeof directionValues === 'object') {
|
|
98
89
|
Object.keys(directionValues).forEach((breakpoint, index, breakpoints) => {
|
|
99
90
|
const directionValue = directionValues[breakpoint];
|
|
100
|
-
|
|
101
91
|
if (!directionValue) {
|
|
102
92
|
const previousDirectionValue = index > 0 ? directionValues[breakpoints[index - 1]] : 'column';
|
|
103
93
|
directionValues[breakpoint] = previousDirectionValue;
|
|
104
94
|
}
|
|
105
95
|
});
|
|
106
96
|
}
|
|
107
|
-
|
|
108
97
|
const styleFromPropValue = (propValue, breakpoint) => {
|
|
109
98
|
return {
|
|
110
99
|
'& > :not(style) + :not(style)': {
|
|
@@ -113,12 +102,10 @@ export const style = ({
|
|
|
113
102
|
}
|
|
114
103
|
};
|
|
115
104
|
};
|
|
116
|
-
|
|
117
105
|
styles = deepmerge(styles, handleBreakpoints({
|
|
118
106
|
theme
|
|
119
107
|
}, spacingValues, styleFromPropValue));
|
|
120
108
|
}
|
|
121
|
-
|
|
122
109
|
styles = mergeBreakpointsInOrder(theme.breakpoints, styles);
|
|
123
110
|
return styles;
|
|
124
111
|
};
|
|
@@ -129,29 +116,25 @@ export default function createStack(options = {}) {
|
|
|
129
116
|
useThemeProps = useThemePropsDefault,
|
|
130
117
|
componentName = 'MuiStack'
|
|
131
118
|
} = options;
|
|
132
|
-
|
|
133
119
|
const useUtilityClasses = () => {
|
|
134
120
|
const slots = {
|
|
135
121
|
root: ['root']
|
|
136
122
|
};
|
|
137
123
|
return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
|
|
138
124
|
};
|
|
139
|
-
|
|
140
125
|
const StackRoot = createStyledComponent(style);
|
|
141
126
|
const Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
142
127
|
const themeProps = useThemeProps(inProps);
|
|
143
128
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
144
|
-
|
|
145
129
|
const {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
130
|
+
component = 'div',
|
|
131
|
+
direction = 'column',
|
|
132
|
+
spacing = 0,
|
|
133
|
+
divider,
|
|
134
|
+
children,
|
|
135
|
+
className
|
|
136
|
+
} = props,
|
|
137
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
155
138
|
const ownerState = {
|
|
156
139
|
direction,
|
|
157
140
|
spacing
|
|
@@ -166,9 +149,7 @@ export default function createStack(options = {}) {
|
|
|
166
149
|
children: divider ? joinChildren(children, divider) : children
|
|
167
150
|
}));
|
|
168
151
|
});
|
|
169
|
-
process.env.NODE_ENV !== "production" ? Stack.propTypes
|
|
170
|
-
/* remove-proptypes */
|
|
171
|
-
= {
|
|
152
|
+
process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
|
|
172
153
|
children: PropTypes.node,
|
|
173
154
|
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
174
155
|
divider: PropTypes.node,
|