@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
|
@@ -3,7 +3,6 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
import { isPlainObject } from '@mui/utils';
|
|
5
5
|
import { propToStyleFunction } from '../getThemeValue';
|
|
6
|
-
|
|
7
6
|
var splitProps = function splitProps(props) {
|
|
8
7
|
var result = {
|
|
9
8
|
systemProps: {},
|
|
@@ -18,33 +17,26 @@ var splitProps = function splitProps(props) {
|
|
|
18
17
|
});
|
|
19
18
|
return result;
|
|
20
19
|
};
|
|
21
|
-
|
|
22
20
|
export default function extendSxProp(props) {
|
|
23
21
|
var inSx = props.sx,
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
other = _objectWithoutProperties(props, ["sx"]);
|
|
26
23
|
var _splitProps = splitProps(other),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
systemProps = _splitProps.systemProps,
|
|
25
|
+
otherProps = _splitProps.otherProps;
|
|
30
26
|
var finalSx;
|
|
31
|
-
|
|
32
27
|
if (Array.isArray(inSx)) {
|
|
33
28
|
finalSx = [systemProps].concat(_toConsumableArray(inSx));
|
|
34
29
|
} else if (typeof inSx === 'function') {
|
|
35
30
|
finalSx = function finalSx() {
|
|
36
31
|
var result = inSx.apply(void 0, arguments);
|
|
37
|
-
|
|
38
32
|
if (!isPlainObject(result)) {
|
|
39
33
|
return systemProps;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return _extends({}, systemProps, result);
|
|
43
36
|
};
|
|
44
37
|
} else {
|
|
45
38
|
finalSx = _extends({}, systemProps, inSx);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
return _extends({}, otherProps, {
|
|
49
41
|
sx: finalSx
|
|
50
42
|
});
|
|
@@ -3,12 +3,10 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
import merge from '../merge';
|
|
4
4
|
import { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
|
|
5
5
|
import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
|
|
6
|
-
|
|
7
6
|
function objectsHaveSameKeys() {
|
|
8
7
|
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
8
|
objects[_key] = arguments[_key];
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
var allKeys = objects.reduce(function (keys, object) {
|
|
13
11
|
return keys.concat(Object.keys(object));
|
|
14
12
|
}, []);
|
|
@@ -17,12 +15,11 @@ function objectsHaveSameKeys() {
|
|
|
17
15
|
return union.size === Object.keys(object).length;
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
function callIfFn(maybeFn, arg) {
|
|
22
19
|
return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
|
|
23
|
-
}
|
|
24
|
-
|
|
20
|
+
}
|
|
25
21
|
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
23
|
export function unstable_createStyleFunctionSx() {
|
|
27
24
|
var styleFunctionMapping = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultStyleFunctionMapping;
|
|
28
25
|
var propToStyleFunction = Object.keys(styleFunctionMapping).reduce(function (acc, styleFnName) {
|
|
@@ -31,51 +28,42 @@ export function unstable_createStyleFunctionSx() {
|
|
|
31
28
|
});
|
|
32
29
|
return acc;
|
|
33
30
|
}, {});
|
|
34
|
-
|
|
35
31
|
function getThemeValue(prop, value, theme) {
|
|
36
32
|
var _inputProps;
|
|
37
|
-
|
|
38
33
|
var inputProps = (_inputProps = {}, _defineProperty(_inputProps, prop, value), _defineProperty(_inputProps, "theme", theme), _inputProps);
|
|
39
34
|
var styleFunction = propToStyleFunction[prop];
|
|
40
35
|
return styleFunction ? styleFunction(inputProps) : _defineProperty({}, prop, value);
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
function styleFunctionSx(props) {
|
|
44
38
|
var _ref2 = props || {},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
sx = _ref2.sx,
|
|
40
|
+
_ref2$theme = _ref2.theme,
|
|
41
|
+
theme = _ref2$theme === void 0 ? {} : _ref2$theme;
|
|
49
42
|
if (!sx) {
|
|
50
43
|
return null; // Emotion & styled-components will neglect null
|
|
51
44
|
}
|
|
45
|
+
|
|
52
46
|
/*
|
|
53
47
|
* Receive `sxInput` as object or callback
|
|
54
48
|
* and then recursively check keys & values to create media query object styles.
|
|
55
49
|
* (the result will be used in `styled`)
|
|
56
50
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
51
|
function traverse(sxInput) {
|
|
60
52
|
var sxObject = sxInput;
|
|
61
|
-
|
|
62
53
|
if (typeof sxInput === 'function') {
|
|
63
54
|
sxObject = sxInput(theme);
|
|
64
55
|
} else if (_typeof(sxInput) !== 'object') {
|
|
65
56
|
// value
|
|
66
57
|
return sxInput;
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
if (!sxObject) {
|
|
70
60
|
return null;
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
var emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
|
74
63
|
var breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
75
64
|
var css = emptyBreakpoints;
|
|
76
65
|
Object.keys(sxObject).forEach(function (styleKey) {
|
|
77
66
|
var value = callIfFn(sxObject[styleKey], theme);
|
|
78
|
-
|
|
79
67
|
if (value !== null && value !== undefined) {
|
|
80
68
|
if (_typeof(value) === 'object') {
|
|
81
69
|
if (propToStyleFunction[styleKey]) {
|
|
@@ -86,7 +74,6 @@ export function unstable_createStyleFunctionSx() {
|
|
|
86
74
|
}, value, function (x) {
|
|
87
75
|
return _defineProperty({}, styleKey, x);
|
|
88
76
|
});
|
|
89
|
-
|
|
90
77
|
if (objectsHaveSameKeys(breakpointsValues, value)) {
|
|
91
78
|
css[styleKey] = styleFunctionSx({
|
|
92
79
|
sx: value,
|
|
@@ -103,10 +90,8 @@ export function unstable_createStyleFunctionSx() {
|
|
|
103
90
|
});
|
|
104
91
|
return removeUnusedBreakpoints(breakpointsKeys, css);
|
|
105
92
|
}
|
|
106
|
-
|
|
107
93
|
return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
return styleFunctionSx;
|
|
111
96
|
}
|
|
112
97
|
var styleFunctionSx = unstable_createStyleFunctionSx();
|
package/legacy/sx/sx.js
CHANGED
package/legacy/useTheme.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import createTheme from './createTheme';
|
|
2
2
|
import useThemeWithoutDefault from './useThemeWithoutDefault';
|
|
3
3
|
export var systemDefaultTheme = createTheme();
|
|
4
|
-
|
|
5
4
|
function useTheme() {
|
|
6
5
|
var defaultTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : systemDefaultTheme;
|
|
7
6
|
return useThemeWithoutDefault(defaultTheme);
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
export default useTheme;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { internal_resolveProps as resolveProps } from '@mui/utils';
|
|
2
2
|
export default function getThemeProps(params) {
|
|
3
3
|
var theme = params.theme,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
name = params.name,
|
|
5
|
+
props = params.props;
|
|
7
6
|
if (!theme || !theme.components || !theme.components[name] || !theme.components[name].defaultProps) {
|
|
8
7
|
return props;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
return resolveProps(theme.components[name].defaultProps, props);
|
|
12
10
|
}
|
|
@@ -2,8 +2,8 @@ import getThemeProps from './getThemeProps';
|
|
|
2
2
|
import useTheme from '../useTheme';
|
|
3
3
|
export default function useThemeProps(_ref) {
|
|
4
4
|
var props = _ref.props,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
name = _ref.name,
|
|
6
|
+
defaultTheme = _ref.defaultTheme;
|
|
7
7
|
var theme = useTheme(defaultTheme);
|
|
8
8
|
var mergedProps = getThemeProps({
|
|
9
9
|
theme: theme,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { useTheme as muiUseTheme } from '@mui/private-theming';
|
|
2
|
-
|
|
3
2
|
function isObjectEmpty(obj) {
|
|
4
3
|
return Object.keys(obj).length === 0;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function useTheme() {
|
|
8
6
|
var defaultTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
9
7
|
var contextTheme = muiUseTheme();
|
|
10
8
|
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
export default useTheme;
|
package/memoize.js
CHANGED
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = memoize;
|
|
7
|
-
|
|
8
7
|
function memoize(fn) {
|
|
9
8
|
const cache = {};
|
|
10
9
|
return arg => {
|
|
11
10
|
if (cache[arg] === undefined) {
|
|
12
11
|
cache[arg] = fn(arg);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
return cache[arg];
|
|
16
14
|
};
|
|
17
15
|
}
|
package/merge.js
CHANGED
|
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@mui/utils");
|
|
9
|
-
|
|
10
8
|
function merge(acc, item) {
|
|
11
9
|
if (!item) {
|
|
12
10
|
return acc;
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
return (0, _utils.deepmerge)(acc, item, {
|
|
16
13
|
clone: false // No need to clone deep, it's way faster.
|
|
17
|
-
|
|
18
14
|
});
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
var _default = merge;
|
|
22
17
|
exports.default = _default;
|
package/modern/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/modern/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
|
*/
|
|
@@ -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,
|