@mui/system 5.13.1 → 5.13.5
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 +184 -4
- package/Container/createContainer.js +35 -41
- package/GlobalStyles/GlobalStyles.d.ts +2 -2
- package/Stack/createStack.js +26 -24
- package/ThemeProvider/ThemeProvider.js +5 -9
- package/Unstable_Grid/createGrid.js +23 -21
- package/Unstable_Grid/gridGenerator.d.ts +1 -6
- package/Unstable_Grid/gridGenerator.js +26 -71
- package/Unstable_Grid/index.d.ts +1 -0
- package/Unstable_Grid/index.js +9 -1
- package/Unstable_Grid/traverseBreakpoints.d.ts +7 -0
- package/Unstable_Grid/traverseBreakpoints.js +50 -0
- package/breakpoints.js +6 -7
- package/createBox.js +12 -9
- package/createStyled.js +32 -40
- package/createTheme/createBreakpoints.js +26 -24
- package/createTheme/createTheme.js +14 -18
- package/cssVars/createCssVarsProvider.js +26 -21
- package/cssVars/createCssVarsTheme.js +10 -10
- package/cssVars/getInitColorSchemeScript.d.ts +2 -2
- package/cssVars/prepareCssVars.js +12 -13
- package/cssVars/useCurrentColorScheme.js +11 -17
- package/esm/Container/createContainer.js +35 -41
- package/esm/Stack/createStack.js +26 -24
- package/esm/ThemeProvider/ThemeProvider.js +5 -9
- package/esm/Unstable_Grid/createGrid.js +23 -21
- package/esm/Unstable_Grid/gridGenerator.js +18 -62
- package/esm/Unstable_Grid/index.js +2 -1
- package/esm/Unstable_Grid/traverseBreakpoints.js +42 -0
- package/esm/breakpoints.js +6 -7
- package/esm/createBox.js +12 -9
- package/esm/createStyled.js +31 -38
- package/esm/createTheme/createBreakpoints.js +25 -24
- package/esm/createTheme/createTheme.js +14 -18
- package/esm/cssVars/createCssVarsProvider.js +26 -21
- package/esm/cssVars/createCssVarsTheme.js +10 -10
- package/esm/cssVars/prepareCssVars.js +12 -13
- package/esm/cssVars/useCurrentColorScheme.js +10 -17
- package/esm/propsToClassKey.js +5 -3
- package/esm/styleFunctionSx/extendSxProp.js +10 -14
- package/index.js +1 -1
- package/legacy/Container/createContainer.js +6 -7
- package/legacy/Stack/createStack.js +5 -6
- package/legacy/ThemeProvider/ThemeProvider.js +3 -4
- package/legacy/Unstable_Grid/createGrid.js +4 -6
- package/legacy/Unstable_Grid/gridGenerator.js +7 -54
- package/legacy/Unstable_Grid/index.js +2 -1
- package/legacy/Unstable_Grid/traverseBreakpoints.js +48 -0
- package/legacy/breakpoints.js +3 -5
- package/legacy/createBox.js +2 -4
- package/legacy/createStyled.js +11 -13
- package/legacy/createTheme/createBreakpoints.js +3 -4
- package/legacy/createTheme/createTheme.js +4 -6
- package/legacy/cssVars/createCssVarsProvider.js +5 -6
- package/legacy/cssVars/createCssVarsTheme.js +2 -4
- package/legacy/cssVars/prepareCssVars.js +3 -5
- package/legacy/cssVars/useCurrentColorScheme.js +7 -9
- package/legacy/index.js +1 -1
- package/legacy/styleFunctionSx/extendSxProp.js +4 -6
- package/modern/Container/createContainer.js +35 -41
- package/modern/Stack/createStack.js +26 -24
- package/modern/ThemeProvider/ThemeProvider.js +5 -9
- package/modern/Unstable_Grid/createGrid.js +23 -21
- package/modern/Unstable_Grid/gridGenerator.js +18 -62
- package/modern/Unstable_Grid/index.js +2 -1
- package/modern/Unstable_Grid/traverseBreakpoints.js +42 -0
- package/modern/breakpoints.js +6 -7
- package/modern/createBox.js +12 -9
- package/modern/createStyled.js +31 -38
- package/modern/createTheme/createBreakpoints.js +25 -24
- package/modern/createTheme/createTheme.js +14 -18
- package/modern/cssVars/createCssVarsProvider.js +26 -21
- package/modern/cssVars/createCssVarsTheme.js +10 -10
- package/modern/cssVars/prepareCssVars.js +12 -13
- package/modern/cssVars/useCurrentColorScheme.js +10 -17
- package/modern/index.js +1 -1
- package/modern/propsToClassKey.js +5 -3
- package/modern/styleFunctionSx/extendSxProp.js +10 -14
- package/package.json +2 -2
- package/propsToClassKey.js +6 -3
- package/styleFunctionSx/extendSxProp.js +10 -14
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.DISABLE_CSS_TRANSITION = void 0;
|
|
8
8
|
exports.default = createCssVarsProvider;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
11
|
var _utils = require("@mui/utils");
|
|
10
12
|
var React = _interopRequireWildcard(require("react"));
|
|
11
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -15,6 +17,7 @@ var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
|
|
|
15
17
|
var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorSchemeScript"));
|
|
16
18
|
var _useCurrentColorScheme = _interopRequireDefault(require("./useCurrentColorScheme"));
|
|
17
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
|
|
18
21
|
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
22
|
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; }
|
|
20
23
|
const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
@@ -22,6 +25,12 @@ exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
|
|
|
22
25
|
function createCssVarsProvider(options) {
|
|
23
26
|
const {
|
|
24
27
|
themeId,
|
|
28
|
+
/**
|
|
29
|
+
* This `theme` object needs to follow a certain structure to
|
|
30
|
+
* be used correctly by the finel `CssVarsProvider`. It should have a
|
|
31
|
+
* `colorSchemes` key with the light and dark (and any other) palette.
|
|
32
|
+
* It should also ideally have a vars object created using `prepareCssVars`.
|
|
33
|
+
*/
|
|
25
34
|
theme: defaultTheme = {},
|
|
26
35
|
attribute: defaultAttribute = _getInitColorSchemeScript.DEFAULT_ATTRIBUTE,
|
|
27
36
|
modeStorageKey: defaultModeStorageKey = _getInitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
|
|
@@ -64,16 +73,17 @@ function createCssVarsProvider(options) {
|
|
|
64
73
|
const ctx = React.useContext(ColorSchemeContext);
|
|
65
74
|
const nested = !!ctx && !disableNestedContext;
|
|
66
75
|
const scopedTheme = themeProp[themeId];
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
const _ref = scopedTheme || themeProp,
|
|
77
|
+
{
|
|
78
|
+
colorSchemes = {},
|
|
79
|
+
components = {},
|
|
80
|
+
generateCssVars = () => ({
|
|
81
|
+
vars: {},
|
|
82
|
+
css: {}
|
|
83
|
+
}),
|
|
84
|
+
cssVarPrefix
|
|
85
|
+
} = _ref,
|
|
86
|
+
restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
77
87
|
const allColorSchemes = Object.keys(colorSchemes);
|
|
78
88
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
79
89
|
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
@@ -131,14 +141,13 @@ function createCssVarsProvider(options) {
|
|
|
131
141
|
} = generateCssVars();
|
|
132
142
|
|
|
133
143
|
// 3. Start composing the theme object
|
|
134
|
-
const theme = {
|
|
135
|
-
...restThemeProp,
|
|
144
|
+
const theme = (0, _extends2.default)({}, restThemeProp, {
|
|
136
145
|
components,
|
|
137
146
|
colorSchemes,
|
|
138
147
|
cssVarPrefix,
|
|
139
148
|
vars: rootVars,
|
|
140
149
|
getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
|
|
141
|
-
};
|
|
150
|
+
});
|
|
142
151
|
|
|
143
152
|
// 4. Create color CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
144
153
|
// The default color scheme stylesheet is constructed to have the least CSS specificity.
|
|
@@ -156,10 +165,7 @@ function createCssVarsProvider(options) {
|
|
|
156
165
|
Object.keys(scheme).forEach(schemeKey => {
|
|
157
166
|
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
158
167
|
// shallow merge the 1st level structure of the theme.
|
|
159
|
-
theme[schemeKey] = {
|
|
160
|
-
...theme[schemeKey],
|
|
161
|
-
...scheme[schemeKey]
|
|
162
|
-
};
|
|
168
|
+
theme[schemeKey] = (0, _extends2.default)({}, theme[schemeKey], scheme[schemeKey]);
|
|
163
169
|
} else {
|
|
164
170
|
theme[schemeKey] = scheme[schemeKey];
|
|
165
171
|
}
|
|
@@ -329,15 +335,14 @@ function createCssVarsProvider(options) {
|
|
|
329
335
|
} : void 0;
|
|
330
336
|
const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
|
|
331
337
|
const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
|
|
332
|
-
const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)({
|
|
338
|
+
const getInitColorSchemeScript = params => (0, _getInitColorSchemeScript.default)((0, _extends2.default)({
|
|
333
339
|
attribute: defaultAttribute,
|
|
334
340
|
colorSchemeStorageKey: defaultColorSchemeStorageKey,
|
|
335
341
|
defaultMode: designSystemMode,
|
|
336
342
|
defaultLightColorScheme,
|
|
337
343
|
defaultDarkColorScheme,
|
|
338
|
-
modeStorageKey: defaultModeStorageKey
|
|
339
|
-
|
|
340
|
-
});
|
|
344
|
+
modeStorageKey: defaultModeStorageKey
|
|
345
|
+
}, params));
|
|
341
346
|
return {
|
|
342
347
|
CssVarsProvider,
|
|
343
348
|
useColorScheme,
|
|
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
10
|
var _prepareCssVars = _interopRequireDefault(require("./prepareCssVars"));
|
|
11
|
+
const _excluded = ["cssVarPrefix", "shouldSkipGeneratingVar"];
|
|
9
12
|
function createCssVarsTheme(theme) {
|
|
10
13
|
const {
|
|
11
|
-
|
|
12
|
-
shouldSkipGeneratingVar,
|
|
13
|
-
...otherTheme
|
|
14
|
-
} = theme;
|
|
15
|
-
return {
|
|
16
|
-
...theme,
|
|
17
|
-
...(0, _prepareCssVars.default)(otherTheme, {
|
|
18
|
-
prefix: cssVarPrefix,
|
|
14
|
+
cssVarPrefix,
|
|
19
15
|
shouldSkipGeneratingVar
|
|
20
|
-
}
|
|
21
|
-
|
|
16
|
+
} = theme,
|
|
17
|
+
otherTheme = (0, _objectWithoutPropertiesLoose2.default)(theme, _excluded);
|
|
18
|
+
return (0, _extends2.default)({}, theme, (0, _prepareCssVars.default)(otherTheme, {
|
|
19
|
+
prefix: cssVarPrefix,
|
|
20
|
+
shouldSkipGeneratingVar
|
|
21
|
+
}));
|
|
22
22
|
}
|
|
23
23
|
var _default = createCssVarsTheme;
|
|
24
24
|
exports.default = _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
3
|
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
4
|
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
@@ -39,4 +39,4 @@ export interface GetInitColorSchemeScriptOptions {
|
|
|
39
39
|
*/
|
|
40
40
|
attribute?: string;
|
|
41
41
|
}
|
|
42
|
-
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
|
|
42
|
+
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): React.JSX.Element;
|
|
@@ -5,15 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
10
|
var _utils = require("@mui/utils");
|
|
9
11
|
var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
|
|
12
|
+
const _excluded = ["colorSchemes", "components"],
|
|
13
|
+
_excluded2 = ["light"];
|
|
10
14
|
function prepareCssVars(theme, parserConfig) {
|
|
11
15
|
// @ts-ignore - ignore components do not exist
|
|
12
16
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = theme;
|
|
17
|
+
colorSchemes = {}
|
|
18
|
+
} = theme,
|
|
19
|
+
otherTheme = (0, _objectWithoutPropertiesLoose2.default)(theme, _excluded);
|
|
17
20
|
const {
|
|
18
21
|
vars: rootVars,
|
|
19
22
|
css: rootCss,
|
|
@@ -22,9 +25,9 @@ function prepareCssVars(theme, parserConfig) {
|
|
|
22
25
|
let themeVars = rootVarsWithDefaults;
|
|
23
26
|
const colorSchemesMap = {};
|
|
24
27
|
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
light
|
|
29
|
+
} = colorSchemes,
|
|
30
|
+
otherColorSchemes = (0, _objectWithoutPropertiesLoose2.default)(colorSchemes, _excluded2);
|
|
28
31
|
Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
|
|
29
32
|
const {
|
|
30
33
|
vars,
|
|
@@ -53,16 +56,12 @@ function prepareCssVars(theme, parserConfig) {
|
|
|
53
56
|
const generateCssVars = colorScheme => {
|
|
54
57
|
if (!colorScheme) {
|
|
55
58
|
return {
|
|
56
|
-
css: {
|
|
57
|
-
...rootCss
|
|
58
|
-
},
|
|
59
|
+
css: (0, _extends2.default)({}, rootCss),
|
|
59
60
|
vars: rootVars
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
return {
|
|
63
|
-
css: {
|
|
64
|
-
...colorSchemesMap[colorScheme].css
|
|
65
|
-
},
|
|
64
|
+
css: (0, _extends2.default)({}, colorSchemesMap[colorScheme].css),
|
|
66
65
|
vars: colorSchemesMap[colorScheme].vars
|
|
67
66
|
};
|
|
68
67
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = useCurrentColorScheme;
|
|
7
8
|
exports.getColorScheme = getColorScheme;
|
|
8
9
|
exports.getSystemMode = getSystemMode;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
11
|
var React = _interopRequireWildcard(require("react"));
|
|
10
12
|
var _getInitColorSchemeScript = require("./getInitColorSchemeScript");
|
|
11
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); }
|
|
@@ -91,11 +93,10 @@ function useCurrentColorScheme(options) {
|
|
|
91
93
|
} catch (e) {
|
|
92
94
|
// Unsupported
|
|
93
95
|
}
|
|
94
|
-
return {
|
|
95
|
-
...currentState,
|
|
96
|
+
return (0, _extends2.default)({}, currentState, {
|
|
96
97
|
mode: newMode,
|
|
97
98
|
systemMode: getSystemMode(newMode)
|
|
98
|
-
};
|
|
99
|
+
});
|
|
99
100
|
});
|
|
100
101
|
}, [modeStorageKey, defaultMode]);
|
|
101
102
|
const setColorScheme = React.useCallback(value => {
|
|
@@ -107,20 +108,17 @@ function useCurrentColorScheme(options) {
|
|
|
107
108
|
} catch (e) {
|
|
108
109
|
// Unsupported
|
|
109
110
|
}
|
|
110
|
-
return {
|
|
111
|
-
...currentState,
|
|
111
|
+
return (0, _extends2.default)({}, currentState, {
|
|
112
112
|
lightColorScheme: defaultLightColorScheme,
|
|
113
113
|
darkColorScheme: defaultDarkColorScheme
|
|
114
|
-
};
|
|
114
|
+
});
|
|
115
115
|
});
|
|
116
116
|
} else if (typeof value === 'string') {
|
|
117
117
|
if (value && !joinedColorSchemes.includes(value)) {
|
|
118
118
|
console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
|
|
119
119
|
} else {
|
|
120
120
|
setState(currentState => {
|
|
121
|
-
const newState = {
|
|
122
|
-
...currentState
|
|
123
|
-
};
|
|
121
|
+
const newState = (0, _extends2.default)({}, currentState);
|
|
124
122
|
processState(currentState, mode => {
|
|
125
123
|
try {
|
|
126
124
|
localStorage.setItem(`${colorSchemeStorageKey}-${mode}`, value);
|
|
@@ -139,9 +137,7 @@ function useCurrentColorScheme(options) {
|
|
|
139
137
|
}
|
|
140
138
|
} else {
|
|
141
139
|
setState(currentState => {
|
|
142
|
-
const newState = {
|
|
143
|
-
...currentState
|
|
144
|
-
};
|
|
140
|
+
const newState = (0, _extends2.default)({}, currentState);
|
|
145
141
|
const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
146
142
|
const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
147
143
|
if (newLightColorScheme) {
|
|
@@ -174,8 +170,7 @@ function useCurrentColorScheme(options) {
|
|
|
174
170
|
}, [joinedColorSchemes, colorSchemeStorageKey, defaultLightColorScheme, defaultDarkColorScheme]);
|
|
175
171
|
const handleMediaQuery = React.useCallback(e => {
|
|
176
172
|
if (state.mode === 'system') {
|
|
177
|
-
setState(currentState => ({
|
|
178
|
-
...currentState,
|
|
173
|
+
setState(currentState => (0, _extends2.default)({}, currentState, {
|
|
179
174
|
systemMode: e != null && e.matches ? 'dark' : 'light'
|
|
180
175
|
}));
|
|
181
176
|
}
|
|
@@ -224,10 +219,9 @@ function useCurrentColorScheme(options) {
|
|
|
224
219
|
}
|
|
225
220
|
return undefined;
|
|
226
221
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
|
|
227
|
-
return {
|
|
228
|
-
...state,
|
|
222
|
+
return (0, _extends2.default)({}, state, {
|
|
229
223
|
colorScheme,
|
|
230
224
|
setMode,
|
|
231
225
|
setColorScheme
|
|
232
|
-
};
|
|
226
|
+
});
|
|
233
227
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["className", "component", "disableGutters", "fixed", "maxWidth", "classes"];
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import clsx from 'clsx';
|
|
@@ -47,22 +50,20 @@ export default function createContainer(options = {}) {
|
|
|
47
50
|
const ContainerRoot = createStyledComponent(({
|
|
48
51
|
theme,
|
|
49
52
|
ownerState
|
|
50
|
-
}) => ({
|
|
53
|
+
}) => _extends({
|
|
51
54
|
width: '100%',
|
|
52
55
|
marginLeft: 'auto',
|
|
53
56
|
boxSizing: 'border-box',
|
|
54
57
|
marginRight: 'auto',
|
|
55
|
-
display: 'block'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
})
|
|
58
|
+
display: 'block'
|
|
59
|
+
}, !ownerState.disableGutters && {
|
|
60
|
+
paddingLeft: theme.spacing(2),
|
|
61
|
+
paddingRight: theme.spacing(2),
|
|
62
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
63
|
+
[theme.breakpoints.up('sm')]: {
|
|
64
|
+
paddingLeft: theme.spacing(3),
|
|
65
|
+
paddingRight: theme.spacing(3)
|
|
66
|
+
}
|
|
66
67
|
}), ({
|
|
67
68
|
theme,
|
|
68
69
|
ownerState
|
|
@@ -79,58 +80,51 @@ export default function createContainer(options = {}) {
|
|
|
79
80
|
}, {}), ({
|
|
80
81
|
theme,
|
|
81
82
|
ownerState
|
|
82
|
-
}) => ({
|
|
83
|
+
}) => _extends({}, ownerState.maxWidth === 'xs' && {
|
|
83
84
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
84
|
-
|
|
85
|
+
[theme.breakpoints.up('xs')]: {
|
|
85
86
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
...(ownerState.maxWidth &&
|
|
87
|
+
maxWidth: Math.max(theme.breakpoints.values.xs, 444)
|
|
88
|
+
}
|
|
89
|
+
}, ownerState.maxWidth &&
|
|
90
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
91
|
+
ownerState.maxWidth !== 'xs' && {
|
|
92
92
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
93
|
-
ownerState.maxWidth
|
|
93
|
+
[theme.breakpoints.up(ownerState.maxWidth)]: {
|
|
94
94
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
maxWidth: `${theme.breakpoints.values[ownerState.maxWidth]}${theme.breakpoints.unit}`
|
|
98
|
-
}
|
|
99
|
-
})
|
|
95
|
+
maxWidth: `${theme.breakpoints.values[ownerState.maxWidth]}${theme.breakpoints.unit}`
|
|
96
|
+
}
|
|
100
97
|
}));
|
|
101
98
|
const Container = /*#__PURE__*/React.forwardRef(function Container(inProps, ref) {
|
|
102
99
|
const props = useThemeProps(inProps);
|
|
103
100
|
const {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const ownerState = {
|
|
113
|
-
...props,
|
|
101
|
+
className,
|
|
102
|
+
component = 'div',
|
|
103
|
+
disableGutters = false,
|
|
104
|
+
fixed = false,
|
|
105
|
+
maxWidth = 'lg'
|
|
106
|
+
} = props,
|
|
107
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
108
|
+
const ownerState = _extends({}, props, {
|
|
114
109
|
component,
|
|
115
110
|
disableGutters,
|
|
116
111
|
fixed,
|
|
117
112
|
maxWidth
|
|
118
|
-
};
|
|
113
|
+
});
|
|
119
114
|
|
|
120
115
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
121
116
|
const classes = useUtilityClasses(ownerState, componentName);
|
|
122
117
|
return (
|
|
123
118
|
/*#__PURE__*/
|
|
124
119
|
// @ts-ignore theme is injected by the styled util
|
|
125
|
-
_jsx(ContainerRoot, {
|
|
120
|
+
_jsx(ContainerRoot, _extends({
|
|
126
121
|
as: component
|
|
127
122
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
128
123
|
,
|
|
129
124
|
ownerState: ownerState,
|
|
130
125
|
className: clsx(classes.root, className),
|
|
131
|
-
ref: ref
|
|
132
|
-
|
|
133
|
-
})
|
|
126
|
+
ref: ref
|
|
127
|
+
}, other))
|
|
134
128
|
);
|
|
135
129
|
});
|
|
136
130
|
process.env.NODE_ENV !== "production" ? Container.propTypes /* remove-proptypes */ = {
|
package/esm/Stack/createStack.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["component", "direction", "spacing", "divider", "children", "className", "useFlexGap"];
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import clsx from 'clsx';
|
|
@@ -55,18 +58,17 @@ export const style = ({
|
|
|
55
58
|
ownerState,
|
|
56
59
|
theme
|
|
57
60
|
}) => {
|
|
58
|
-
let styles = {
|
|
61
|
+
let styles = _extends({
|
|
59
62
|
display: 'flex',
|
|
60
|
-
flexDirection: 'column'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
63
|
+
flexDirection: 'column'
|
|
64
|
+
}, handleBreakpoints({
|
|
65
|
+
theme
|
|
66
|
+
}, resolveBreakpointValues({
|
|
67
|
+
values: ownerState.direction,
|
|
68
|
+
breakpoints: theme.breakpoints.values
|
|
69
|
+
}), propValue => ({
|
|
70
|
+
flexDirection: propValue
|
|
71
|
+
})));
|
|
70
72
|
if (ownerState.spacing) {
|
|
71
73
|
const transformer = createUnarySpacing(theme);
|
|
72
74
|
const base = Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
|
|
@@ -130,29 +132,29 @@ export default function createStack(options = {}) {
|
|
|
130
132
|
const themeProps = useThemeProps(inProps);
|
|
131
133
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
132
134
|
const {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
component = 'div',
|
|
136
|
+
direction = 'column',
|
|
137
|
+
spacing = 0,
|
|
138
|
+
divider,
|
|
139
|
+
children,
|
|
140
|
+
className,
|
|
141
|
+
useFlexGap = false
|
|
142
|
+
} = props,
|
|
143
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
142
144
|
const ownerState = {
|
|
143
145
|
direction,
|
|
144
146
|
spacing,
|
|
145
147
|
useFlexGap
|
|
146
148
|
};
|
|
147
149
|
const classes = useUtilityClasses();
|
|
148
|
-
return /*#__PURE__*/_jsx(StackRoot, {
|
|
150
|
+
return /*#__PURE__*/_jsx(StackRoot, _extends({
|
|
149
151
|
as: component,
|
|
150
152
|
ownerState: ownerState,
|
|
151
153
|
ref: ref,
|
|
152
|
-
className: clsx(classes.root, className)
|
|
153
|
-
|
|
154
|
+
className: clsx(classes.root, className)
|
|
155
|
+
}, other, {
|
|
154
156
|
children: divider ? joinChildren(children, divider) : children
|
|
155
|
-
});
|
|
157
|
+
}));
|
|
156
158
|
});
|
|
157
159
|
process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
|
|
158
160
|
children: PropTypes.node,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
|
|
@@ -11,10 +12,9 @@ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
|
|
|
11
12
|
const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
|
|
12
13
|
if (typeof localTheme === 'function') {
|
|
13
14
|
const mergedTheme = localTheme(resolvedTheme);
|
|
14
|
-
const result = themeId ? {
|
|
15
|
-
...upperTheme,
|
|
15
|
+
const result = themeId ? _extends({}, upperTheme, {
|
|
16
16
|
[themeId]: mergedTheme
|
|
17
|
-
} : mergedTheme;
|
|
17
|
+
}) : mergedTheme;
|
|
18
18
|
// must return a function for the private theme to NOT merge with the upper theme.
|
|
19
19
|
// see the test case "use provided theme from a callback" in ThemeProvider.test.js
|
|
20
20
|
if (isPrivate) {
|
|
@@ -22,13 +22,9 @@ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
|
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
|
-
return themeId ? {
|
|
26
|
-
...upperTheme,
|
|
25
|
+
return themeId ? _extends({}, upperTheme, {
|
|
27
26
|
[themeId]: localTheme
|
|
28
|
-
} : {
|
|
29
|
-
...upperTheme,
|
|
30
|
-
...localTheme
|
|
31
|
-
};
|
|
27
|
+
}) : _extends({}, upperTheme, localTheme);
|
|
32
28
|
}, [themeId, upperTheme, localTheme, isPrivate]);
|
|
33
29
|
}
|
|
34
30
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["className", "children", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow", "unstable_level"];
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import clsx from 'clsx';
|
|
@@ -53,20 +56,20 @@ export default function createGrid(options = {}) {
|
|
|
53
56
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
54
57
|
const overflow = React.useContext(OverflowContext);
|
|
55
58
|
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
className,
|
|
60
|
+
children,
|
|
61
|
+
columns: columnsProp = 12,
|
|
62
|
+
container = false,
|
|
63
|
+
component = 'div',
|
|
64
|
+
direction = 'row',
|
|
65
|
+
wrap = 'wrap',
|
|
66
|
+
spacing: spacingProp = 0,
|
|
67
|
+
rowSpacing: rowSpacingProp = spacingProp,
|
|
68
|
+
columnSpacing: columnSpacingProp = spacingProp,
|
|
69
|
+
disableEqualOverflow: themeDisableEqualOverflow,
|
|
70
|
+
unstable_level: level = 0
|
|
71
|
+
} = props,
|
|
72
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
70
73
|
// Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
71
74
|
let disableEqualOverflow = themeDisableEqualOverflow;
|
|
72
75
|
if (level && themeDisableEqualOverflow !== undefined) {
|
|
@@ -89,8 +92,7 @@ export default function createGrid(options = {}) {
|
|
|
89
92
|
const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : level ? undefined : spacingProp;
|
|
90
93
|
const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : level ? undefined : rowSpacingProp;
|
|
91
94
|
const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : level ? undefined : columnSpacingProp;
|
|
92
|
-
const ownerState = {
|
|
93
|
-
...props,
|
|
95
|
+
const ownerState = _extends({}, props, {
|
|
94
96
|
level,
|
|
95
97
|
columns,
|
|
96
98
|
container,
|
|
@@ -104,15 +106,15 @@ export default function createGrid(options = {}) {
|
|
|
104
106
|
disableEqualOverflow: (_ref3 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref3 : false,
|
|
105
107
|
// use context value if exists.
|
|
106
108
|
parentDisableEqualOverflow: overflow // for nested grid
|
|
107
|
-
};
|
|
109
|
+
});
|
|
108
110
|
|
|
109
111
|
const classes = useUtilityClasses(ownerState, theme);
|
|
110
|
-
let result = /*#__PURE__*/_jsx(GridRoot, {
|
|
112
|
+
let result = /*#__PURE__*/_jsx(GridRoot, _extends({
|
|
111
113
|
ref: ref,
|
|
112
114
|
as: component,
|
|
113
115
|
ownerState: ownerState,
|
|
114
|
-
className: clsx(classes.root, className)
|
|
115
|
-
|
|
116
|
+
className: clsx(classes.root, className)
|
|
117
|
+
}, other, {
|
|
116
118
|
children: React.Children.map(children, child => {
|
|
117
119
|
if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
|
|
118
120
|
var _child$props$unstable;
|
|
@@ -122,7 +124,7 @@ export default function createGrid(options = {}) {
|
|
|
122
124
|
}
|
|
123
125
|
return child;
|
|
124
126
|
})
|
|
125
|
-
});
|
|
127
|
+
}));
|
|
126
128
|
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
|
|
127
129
|
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
128
130
|
// 1. It is the root grid with `disableEqualOverflow`.
|