@mui/system 5.9.0 → 5.9.1
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.spec.d.ts +1 -1
- package/CHANGELOG.md +61 -1
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/Grid.js +5 -0
- package/Unstable_Grid/GridProps.d.ts +162 -158
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +30 -5
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +26 -26
- package/Unstable_Grid/gridGenerator.js +10 -4
- package/Unstable_Grid/index.d.ts +5 -5
- package/breakpoints.js +1 -1
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/getInitColorSchemeScript.d.ts +45 -45
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/Unstable_Grid/Grid.js +5 -0
- package/esm/Unstable_Grid/createGrid.js +30 -5
- package/esm/Unstable_Grid/gridGenerator.js +10 -4
- package/esm/breakpoints.js +1 -1
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/Unstable_Grid/Grid.js +5 -0
- package/legacy/Unstable_Grid/createGrid.js +28 -3
- package/legacy/Unstable_Grid/gridGenerator.js +10 -4
- package/legacy/breakpoints.js +1 -1
- package/legacy/index.js +1 -1
- package/modern/Unstable_Grid/Grid.js +5 -0
- package/modern/Unstable_Grid/createGrid.js +29 -4
- package/modern/Unstable_Grid/gridGenerator.js +10 -4
- package/modern/breakpoints.js +1 -1
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -57,6 +57,11 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
|
57
57
|
/* @typescript-to-proptypes-ignore */
|
|
58
58
|
.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
|
|
62
|
+
*/
|
|
63
|
+
disableEqualOverflow: PropTypes.bool,
|
|
64
|
+
|
|
60
65
|
/**
|
|
61
66
|
* If a number, it sets the number of columns the grid item uses.
|
|
62
67
|
* It can't be greater than the total number of columns of the container (12 by default).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"];
|
|
3
|
+
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -36,6 +36,7 @@ export default function createGrid(options = {}) {
|
|
|
36
36
|
componentName = 'MuiGrid'
|
|
37
37
|
} = options;
|
|
38
38
|
const NestedContext = /*#__PURE__*/React.createContext(false);
|
|
39
|
+
const OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
39
40
|
|
|
40
41
|
const useUtilityClasses = (ownerState, theme) => {
|
|
41
42
|
const {
|
|
@@ -53,13 +54,14 @@ export default function createGrid(options = {}) {
|
|
|
53
54
|
|
|
54
55
|
const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
|
|
55
56
|
const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
56
|
-
var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin;
|
|
57
|
+
var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin, _ref3, _disableEqualOverflow;
|
|
57
58
|
|
|
58
59
|
const theme = useTheme();
|
|
59
60
|
const themeProps = useThemeProps(inProps);
|
|
60
61
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
61
62
|
|
|
62
63
|
const nested = React.useContext(NestedContext);
|
|
64
|
+
const overflow = React.useContext(OverflowContext);
|
|
63
65
|
|
|
64
66
|
const {
|
|
65
67
|
className,
|
|
@@ -70,9 +72,17 @@ export default function createGrid(options = {}) {
|
|
|
70
72
|
wrap = 'wrap',
|
|
71
73
|
spacing: spacingProp = 0,
|
|
72
74
|
rowSpacing: rowSpacingProp = spacingProp,
|
|
73
|
-
columnSpacing: columnSpacingProp = spacingProp
|
|
75
|
+
columnSpacing: columnSpacingProp = spacingProp,
|
|
76
|
+
disableEqualOverflow: themeDisableEqualOverflow
|
|
74
77
|
} = props,
|
|
75
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded); //
|
|
78
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
let disableEqualOverflow = themeDisableEqualOverflow;
|
|
82
|
+
|
|
83
|
+
if (nested && themeDisableEqualOverflow !== undefined) {
|
|
84
|
+
disableEqualOverflow = inProps.disableEqualOverflow;
|
|
85
|
+
} // collect breakpoints related props because they can be customized from the theme.
|
|
76
86
|
|
|
77
87
|
|
|
78
88
|
const gridSize = {};
|
|
@@ -102,7 +112,11 @@ export default function createGrid(options = {}) {
|
|
|
102
112
|
rowSpacing,
|
|
103
113
|
columnSpacing,
|
|
104
114
|
gridSize,
|
|
105
|
-
gridOffset
|
|
115
|
+
gridOffset,
|
|
116
|
+
disableEqualOverflow: (_ref3 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref3 : false,
|
|
117
|
+
// use context value if exists.
|
|
118
|
+
parentDisableEqualOverflow: overflow // for nested grid
|
|
119
|
+
|
|
106
120
|
});
|
|
107
121
|
|
|
108
122
|
const classes = useUtilityClasses(ownerState, theme);
|
|
@@ -121,6 +135,16 @@ export default function createGrid(options = {}) {
|
|
|
121
135
|
});
|
|
122
136
|
}
|
|
123
137
|
|
|
138
|
+
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
|
|
139
|
+
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
140
|
+
// 1. It is the root grid with `disableEqualOverflow`.
|
|
141
|
+
// 2. It is a nested grid with different `disableEqualOverflow` from the context.
|
|
142
|
+
result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
|
|
143
|
+
value: disableEqualOverflow,
|
|
144
|
+
children: result
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
124
148
|
return result;
|
|
125
149
|
});
|
|
126
150
|
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
@@ -133,6 +157,7 @@ export default function createGrid(options = {}) {
|
|
|
133
157
|
component: PropTypes.elementType,
|
|
134
158
|
container: PropTypes.bool,
|
|
135
159
|
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
160
|
+
disableEqualOverflow: PropTypes.bool,
|
|
136
161
|
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
137
162
|
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
138
163
|
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
@@ -185,14 +185,20 @@ export const generateGridStyles = ({
|
|
|
185
185
|
flexWrap: ownerState.wrap
|
|
186
186
|
}, {
|
|
187
187
|
margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
|
|
188
|
-
}, ownerState.
|
|
188
|
+
}, ownerState.disableEqualOverflow && {
|
|
189
|
+
margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
|
|
190
|
+
}, ownerState.nested ? _extends({
|
|
189
191
|
padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
|
|
190
|
-
}
|
|
192
|
+
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
193
|
+
padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
|
|
194
|
+
}) : {
|
|
191
195
|
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
192
196
|
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
193
|
-
}) : {
|
|
197
|
+
}) : _extends({
|
|
194
198
|
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
195
|
-
}
|
|
199
|
+
}, ownerState.disableEqualOverflow && {
|
|
200
|
+
padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
|
|
201
|
+
}));
|
|
196
202
|
};
|
|
197
203
|
export const generateSizeClassNames = gridSize => {
|
|
198
204
|
const classNames = [];
|
package/esm/breakpoints.js
CHANGED
|
@@ -85,7 +85,7 @@ function breakpoints(styleFunction) {
|
|
|
85
85
|
export function createEmptyBreakpointObject(breakpointsInput = {}) {
|
|
86
86
|
var _breakpointsInput$key;
|
|
87
87
|
|
|
88
|
-
const breakpointsInOrder =
|
|
88
|
+
const breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
|
|
89
89
|
const breakpointStyleKey = breakpointsInput.up(key);
|
|
90
90
|
acc[breakpointStyleKey] = {};
|
|
91
91
|
return acc;
|
package/index.js
CHANGED
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -57,6 +57,11 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
|
57
57
|
/* @typescript-to-proptypes-ignore */
|
|
58
58
|
.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
|
|
62
|
+
*/
|
|
63
|
+
disableEqualOverflow: PropTypes.bool,
|
|
64
|
+
|
|
60
65
|
/**
|
|
61
66
|
* If a number, it sets the number of columns the grid item uses.
|
|
62
67
|
* It can't be greater than the total number of columns of the container (12 by default).
|
|
@@ -40,6 +40,7 @@ export default function createGrid() {
|
|
|
40
40
|
_options$componentNam = options.componentName,
|
|
41
41
|
componentName = _options$componentNam === void 0 ? 'MuiGrid' : _options$componentNam;
|
|
42
42
|
var NestedContext = /*#__PURE__*/React.createContext(false);
|
|
43
|
+
var OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
43
44
|
|
|
44
45
|
var useUtilityClasses = function useUtilityClasses(ownerState, theme) {
|
|
45
46
|
var container = ownerState.container,
|
|
@@ -57,13 +58,14 @@ export default function createGrid() {
|
|
|
57
58
|
|
|
58
59
|
var GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
|
|
59
60
|
var Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
60
|
-
var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin;
|
|
61
|
+
var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin, _ref5, _disableEqualOverflow;
|
|
61
62
|
|
|
62
63
|
var theme = useTheme();
|
|
63
64
|
var themeProps = useThemeProps(inProps);
|
|
64
65
|
var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
65
66
|
|
|
66
67
|
var nested = React.useContext(NestedContext);
|
|
68
|
+
var overflow = React.useContext(OverflowContext);
|
|
67
69
|
|
|
68
70
|
var className = props.className,
|
|
69
71
|
_props$columns = props.columns,
|
|
@@ -82,7 +84,15 @@ export default function createGrid() {
|
|
|
82
84
|
rowSpacingProp = _props$rowSpacing === void 0 ? spacingProp : _props$rowSpacing,
|
|
83
85
|
_props$columnSpacing = props.columnSpacing,
|
|
84
86
|
columnSpacingProp = _props$columnSpacing === void 0 ? spacingProp : _props$columnSpacing,
|
|
85
|
-
|
|
87
|
+
themeDisableEqualOverflow = props.disableEqualOverflow,
|
|
88
|
+
rest = _objectWithoutProperties(props, ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"]); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var disableEqualOverflow = themeDisableEqualOverflow;
|
|
92
|
+
|
|
93
|
+
if (nested && themeDisableEqualOverflow !== undefined) {
|
|
94
|
+
disableEqualOverflow = inProps.disableEqualOverflow;
|
|
95
|
+
} // collect breakpoints related props because they can be customized from the theme.
|
|
86
96
|
|
|
87
97
|
|
|
88
98
|
var gridSize = {};
|
|
@@ -116,7 +126,11 @@ export default function createGrid() {
|
|
|
116
126
|
rowSpacing: rowSpacing,
|
|
117
127
|
columnSpacing: columnSpacing,
|
|
118
128
|
gridSize: gridSize,
|
|
119
|
-
gridOffset: gridOffset
|
|
129
|
+
gridOffset: gridOffset,
|
|
130
|
+
disableEqualOverflow: (_ref5 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref5 : false,
|
|
131
|
+
// use context value if exists.
|
|
132
|
+
parentDisableEqualOverflow: overflow // for nested grid
|
|
133
|
+
|
|
120
134
|
});
|
|
121
135
|
|
|
122
136
|
var classes = useUtilityClasses(ownerState, theme);
|
|
@@ -135,6 +149,16 @@ export default function createGrid() {
|
|
|
135
149
|
});
|
|
136
150
|
}
|
|
137
151
|
|
|
152
|
+
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
|
|
153
|
+
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
154
|
+
// 1. It is the root grid with `disableEqualOverflow`.
|
|
155
|
+
// 2. It is a nested grid with different `disableEqualOverflow` from the context.
|
|
156
|
+
result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
|
|
157
|
+
value: disableEqualOverflow,
|
|
158
|
+
children: result
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
138
162
|
return result;
|
|
139
163
|
});
|
|
140
164
|
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
@@ -147,6 +171,7 @@ export default function createGrid() {
|
|
|
147
171
|
component: PropTypes.elementType,
|
|
148
172
|
container: PropTypes.bool,
|
|
149
173
|
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
174
|
+
disableEqualOverflow: PropTypes.bool,
|
|
150
175
|
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
151
176
|
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
152
177
|
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
@@ -184,14 +184,20 @@ export var generateGridStyles = function generateGridStyles(_ref7) {
|
|
|
184
184
|
flexWrap: ownerState.wrap
|
|
185
185
|
}, {
|
|
186
186
|
margin: "calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)"
|
|
187
|
-
}, ownerState.
|
|
187
|
+
}, ownerState.disableEqualOverflow && {
|
|
188
|
+
margin: "calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)"
|
|
189
|
+
}, ownerState.nested ? _extends({
|
|
188
190
|
padding: "calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)"
|
|
189
|
-
}
|
|
191
|
+
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
192
|
+
padding: "calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))"
|
|
193
|
+
}) : {
|
|
190
194
|
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
191
195
|
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
192
|
-
}) : {
|
|
196
|
+
}) : _extends({
|
|
193
197
|
padding: "calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)"
|
|
194
|
-
}
|
|
198
|
+
}, ownerState.disableEqualOverflow && {
|
|
199
|
+
padding: "calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))"
|
|
200
|
+
}));
|
|
195
201
|
};
|
|
196
202
|
export var generateSizeClassNames = function generateSizeClassNames(gridSize) {
|
|
197
203
|
var classNames = [];
|
package/legacy/breakpoints.js
CHANGED
|
@@ -92,7 +92,7 @@ export function createEmptyBreakpointObject() {
|
|
|
92
92
|
var _breakpointsInput$key;
|
|
93
93
|
|
|
94
94
|
var breakpointsInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
95
|
-
var breakpointsInOrder =
|
|
95
|
+
var breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce(function (acc, key) {
|
|
96
96
|
var breakpointStyleKey = breakpointsInput.up(key);
|
|
97
97
|
acc[breakpointStyleKey] = {};
|
|
98
98
|
return acc;
|
package/legacy/index.js
CHANGED
|
@@ -57,6 +57,11 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
|
57
57
|
/* @typescript-to-proptypes-ignore */
|
|
58
58
|
.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
|
|
62
|
+
*/
|
|
63
|
+
disableEqualOverflow: PropTypes.bool,
|
|
64
|
+
|
|
60
65
|
/**
|
|
61
66
|
* If a number, it sets the number of columns the grid item uses.
|
|
62
67
|
* It can't be greater than the total number of columns of the container (12 by default).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"];
|
|
3
|
+
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -36,6 +36,7 @@ export default function createGrid(options = {}) {
|
|
|
36
36
|
componentName = 'MuiGrid'
|
|
37
37
|
} = options;
|
|
38
38
|
const NestedContext = /*#__PURE__*/React.createContext(false);
|
|
39
|
+
const OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
39
40
|
|
|
40
41
|
const useUtilityClasses = (ownerState, theme) => {
|
|
41
42
|
const {
|
|
@@ -58,6 +59,7 @@ export default function createGrid(options = {}) {
|
|
|
58
59
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
59
60
|
|
|
60
61
|
const nested = React.useContext(NestedContext);
|
|
62
|
+
const overflow = React.useContext(OverflowContext);
|
|
61
63
|
|
|
62
64
|
const {
|
|
63
65
|
className,
|
|
@@ -68,9 +70,17 @@ export default function createGrid(options = {}) {
|
|
|
68
70
|
wrap = 'wrap',
|
|
69
71
|
spacing: spacingProp = 0,
|
|
70
72
|
rowSpacing: rowSpacingProp = spacingProp,
|
|
71
|
-
columnSpacing: columnSpacingProp = spacingProp
|
|
73
|
+
columnSpacing: columnSpacingProp = spacingProp,
|
|
74
|
+
disableEqualOverflow: themeDisableEqualOverflow
|
|
72
75
|
} = props,
|
|
73
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded); //
|
|
76
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
let disableEqualOverflow = themeDisableEqualOverflow;
|
|
80
|
+
|
|
81
|
+
if (nested && themeDisableEqualOverflow !== undefined) {
|
|
82
|
+
disableEqualOverflow = inProps.disableEqualOverflow;
|
|
83
|
+
} // collect breakpoints related props because they can be customized from the theme.
|
|
74
84
|
|
|
75
85
|
|
|
76
86
|
const gridSize = {};
|
|
@@ -100,7 +110,11 @@ export default function createGrid(options = {}) {
|
|
|
100
110
|
rowSpacing,
|
|
101
111
|
columnSpacing,
|
|
102
112
|
gridSize,
|
|
103
|
-
gridOffset
|
|
113
|
+
gridOffset,
|
|
114
|
+
disableEqualOverflow: disableEqualOverflow ?? overflow ?? false,
|
|
115
|
+
// use context value if exists.
|
|
116
|
+
parentDisableEqualOverflow: overflow // for nested grid
|
|
117
|
+
|
|
104
118
|
});
|
|
105
119
|
|
|
106
120
|
const classes = useUtilityClasses(ownerState, theme);
|
|
@@ -119,6 +133,16 @@ export default function createGrid(options = {}) {
|
|
|
119
133
|
});
|
|
120
134
|
}
|
|
121
135
|
|
|
136
|
+
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow ?? false)) {
|
|
137
|
+
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
138
|
+
// 1. It is the root grid with `disableEqualOverflow`.
|
|
139
|
+
// 2. It is a nested grid with different `disableEqualOverflow` from the context.
|
|
140
|
+
result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
|
|
141
|
+
value: disableEqualOverflow,
|
|
142
|
+
children: result
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
122
146
|
return result;
|
|
123
147
|
});
|
|
124
148
|
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
@@ -131,6 +155,7 @@ export default function createGrid(options = {}) {
|
|
|
131
155
|
component: PropTypes.elementType,
|
|
132
156
|
container: PropTypes.bool,
|
|
133
157
|
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
158
|
+
disableEqualOverflow: PropTypes.bool,
|
|
134
159
|
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
135
160
|
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
136
161
|
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
@@ -181,14 +181,20 @@ export const generateGridStyles = ({
|
|
|
181
181
|
flexWrap: ownerState.wrap
|
|
182
182
|
}, {
|
|
183
183
|
margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
|
|
184
|
-
}, ownerState.
|
|
184
|
+
}, ownerState.disableEqualOverflow && {
|
|
185
|
+
margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
|
|
186
|
+
}, ownerState.nested ? _extends({
|
|
185
187
|
padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
|
|
186
|
-
}
|
|
188
|
+
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
189
|
+
padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
|
|
190
|
+
}) : {
|
|
187
191
|
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
188
192
|
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
189
|
-
}) : {
|
|
193
|
+
}) : _extends({
|
|
190
194
|
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
191
|
-
}
|
|
195
|
+
}, ownerState.disableEqualOverflow && {
|
|
196
|
+
padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
|
|
197
|
+
}));
|
|
192
198
|
};
|
|
193
199
|
export const generateSizeClassNames = gridSize => {
|
|
194
200
|
const classNames = [];
|
package/modern/breakpoints.js
CHANGED
|
@@ -83,7 +83,7 @@ function breakpoints(styleFunction) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export function createEmptyBreakpointObject(breakpointsInput = {}) {
|
|
86
|
-
const breakpointsInOrder = breakpointsInput
|
|
86
|
+
const breakpointsInOrder = breakpointsInput.keys?.reduce((acc, key) => {
|
|
87
87
|
const breakpointStyleKey = breakpointsInput.up(key);
|
|
88
88
|
acc[breakpointStyleKey] = {};
|
|
89
89
|
return acc;
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.17.2",
|
|
47
|
-
"@mui/private-theming": "^5.9.
|
|
47
|
+
"@mui/private-theming": "^5.9.1",
|
|
48
48
|
"@mui/styled-engine": "^5.8.7",
|
|
49
49
|
"@mui/types": "^7.1.4",
|
|
50
|
-
"@mui/utils": "^5.9.
|
|
50
|
+
"@mui/utils": "^5.9.1",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.0",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|