@mui/material 7.0.0-alpha.2 → 7.0.0-beta.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/CHANGELOG.md +57 -0
- package/Dialog/Dialog.d.ts +0 -5
- package/Dialog/Dialog.js +0 -9
- package/Grid/Grid.d.ts +51 -100
- package/Grid/Grid.js +68 -515
- package/Grid/gridClasses.d.ts +0 -38
- package/Grid/gridClasses.js +1 -1
- package/Grid/index.js +12 -2
- package/GridLegacy/GridLegacy.d.ts +160 -0
- package/GridLegacy/GridLegacy.js +601 -0
- package/{Grid/GridContext.js → GridLegacy/GridLegacyContext.js} +3 -3
- package/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +5 -5
- package/GridLegacy/index.d.ts +4 -0
- package/GridLegacy/index.js +35 -0
- package/Menu/Menu.d.ts +68 -1
- package/Menu/Menu.js +52 -17
- package/Modal/Modal.d.ts +0 -5
- package/Modal/Modal.js +0 -9
- package/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/PigmentGrid/PigmentGrid.js +2 -2
- package/PigmentGrid/index.d.ts +1 -1
- package/PigmentGrid/index.js +4 -4
- package/Rating/Rating.d.ts +52 -1
- package/Rating/Rating.js +132 -46
- package/Select/SelectInput.js +8 -8
- package/StepButton/StepButton.d.ts +0 -5
- package/esm/Dialog/Dialog.d.ts +0 -5
- package/esm/Dialog/Dialog.js +0 -9
- package/esm/Grid/Grid.d.ts +51 -100
- package/esm/Grid/Grid.js +68 -508
- package/esm/Grid/gridClasses.d.ts +0 -38
- package/esm/Grid/gridClasses.js +1 -1
- package/esm/Grid/index.js +1 -0
- package/esm/GridLegacy/GridLegacy.d.ts +160 -0
- package/esm/GridLegacy/GridLegacy.js +588 -0
- package/esm/GridLegacy/GridLegacyContext.js +12 -0
- package/esm/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/esm/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +4 -4
- package/esm/GridLegacy/index.d.ts +4 -0
- package/esm/GridLegacy/index.js +3 -0
- package/esm/Menu/Menu.d.ts +68 -1
- package/esm/Menu/Menu.js +52 -17
- package/esm/Modal/Modal.d.ts +0 -5
- package/esm/Modal/Modal.js +0 -9
- package/esm/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/esm/PigmentGrid/PigmentGrid.js +2 -2
- package/esm/PigmentGrid/index.d.ts +1 -1
- package/esm/PigmentGrid/index.js +1 -1
- package/esm/Rating/Rating.d.ts +52 -1
- package/esm/Rating/Rating.js +131 -45
- package/esm/Select/SelectInput.js +8 -8
- package/esm/StepButton/StepButton.d.ts +0 -5
- package/esm/index.d.ts +3 -8
- package/esm/index.js +3 -3
- package/esm/styles/components.d.ts +5 -5
- package/esm/styles/createTheme.d.ts +0 -1
- package/esm/styles/createTheme.js +0 -1
- package/esm/styles/createThemeNoVars.d.ts +0 -6
- package/esm/styles/createThemeNoVars.js +7 -12
- package/esm/styles/index.d.ts +1 -5
- package/esm/styles/index.js +1 -2
- package/esm/styles/overrides.d.ts +2 -2
- package/esm/styles/props.d.ts +2 -2
- package/esm/utils/createSvgIcon.d.ts +1 -1
- package/esm/utils/createSvgIcon.js +1 -1
- package/esm/version/index.js +2 -2
- package/index.d.ts +3 -8
- package/index.js +9 -9
- package/modern/Dialog/Dialog.d.ts +0 -5
- package/modern/Dialog/Dialog.js +0 -9
- package/modern/Grid/Grid.d.ts +51 -100
- package/modern/Grid/Grid.js +68 -508
- package/modern/Grid/gridClasses.d.ts +0 -38
- package/modern/Grid/gridClasses.js +1 -1
- package/modern/Grid/index.js +1 -0
- package/modern/GridLegacy/GridLegacy.d.ts +160 -0
- package/modern/GridLegacy/GridLegacy.js +588 -0
- package/modern/GridLegacy/GridLegacyContext.js +12 -0
- package/modern/GridLegacy/gridLegacyClasses.d.ts +48 -0
- package/modern/{Grid2/grid2Classes.js → GridLegacy/gridLegacyClasses.js} +4 -4
- package/modern/GridLegacy/index.d.ts +4 -0
- package/modern/GridLegacy/index.js +3 -0
- package/modern/Menu/Menu.d.ts +68 -1
- package/modern/Menu/Menu.js +52 -17
- package/modern/Modal/Modal.d.ts +0 -5
- package/modern/Modal/Modal.js +0 -9
- package/modern/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/modern/PigmentGrid/PigmentGrid.js +2 -2
- package/modern/PigmentGrid/index.d.ts +1 -1
- package/modern/PigmentGrid/index.js +1 -1
- package/modern/Rating/Rating.d.ts +52 -1
- package/modern/Rating/Rating.js +131 -45
- package/modern/Select/SelectInput.js +8 -8
- package/modern/StepButton/StepButton.d.ts +0 -5
- package/modern/index.d.ts +3 -8
- package/modern/index.js +3 -3
- package/modern/styles/components.d.ts +5 -5
- package/modern/styles/createTheme.d.ts +0 -1
- package/modern/styles/createTheme.js +0 -1
- package/modern/styles/createThemeNoVars.d.ts +0 -6
- package/modern/styles/createThemeNoVars.js +7 -12
- package/modern/styles/index.d.ts +1 -5
- package/modern/styles/index.js +1 -2
- package/modern/styles/overrides.d.ts +2 -2
- package/modern/styles/props.d.ts +2 -2
- package/modern/utils/createSvgIcon.d.ts +1 -1
- package/modern/utils/createSvgIcon.js +1 -1
- package/modern/version/index.js +2 -2
- package/package.json +4 -4
- package/styles/components.d.ts +5 -5
- package/styles/createTheme.d.ts +0 -1
- package/styles/createTheme.js +1 -8
- package/styles/createThemeNoVars.d.ts +0 -6
- package/styles/createThemeNoVars.js +7 -13
- package/styles/index.d.ts +1 -5
- package/styles/index.js +1 -15
- package/styles/overrides.d.ts +2 -2
- package/styles/props.d.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/createSvgIcon.d.ts +1 -1
- package/utils/createSvgIcon.js +1 -1
- package/version/index.js +2 -2
- package/Grid2/Grid2.d.ts +0 -111
- package/Grid2/Grid2.js +0 -144
- package/Grid2/grid2Classes.d.ts +0 -10
- package/Grid2/index.d.ts +0 -4
- package/Grid2/index.js +0 -45
- package/StyledEngineProvider/index.d.ts +0 -4
- package/StyledEngineProvider/index.js +0 -12
- package/esm/Grid/GridContext.js +0 -12
- package/esm/Grid2/Grid2.d.ts +0 -111
- package/esm/Grid2/Grid2.js +0 -138
- package/esm/Grid2/grid2Classes.d.ts +0 -10
- package/esm/Grid2/index.d.ts +0 -4
- package/esm/Grid2/index.js +0 -4
- package/esm/StyledEngineProvider/index.d.ts +0 -4
- package/esm/StyledEngineProvider/index.js +0 -1
- package/modern/Grid/GridContext.js +0 -12
- package/modern/Grid2/Grid2.d.ts +0 -111
- package/modern/Grid2/Grid2.js +0 -138
- package/modern/Grid2/grid2Classes.d.ts +0 -10
- package/modern/Grid2/index.d.ts +0 -4
- package/modern/Grid2/index.js +0 -4
- package/modern/StyledEngineProvider/index.d.ts +0 -4
- package/modern/StyledEngineProvider/index.js +0 -1
package/modern/Grid/Grid.js
CHANGED
|
@@ -1,468 +1,58 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
// A grid component using the following libs as inspiration.
|
|
4
|
-
//
|
|
5
|
-
// For the implementation:
|
|
6
|
-
// - https://getbootstrap.com/docs/4.3/layout/grid/
|
|
7
|
-
// - https://github.com/kristoferjoseph/flexboxgrid/blob/master/src/css/flexboxgrid.css
|
|
8
|
-
// - https://github.com/roylee0704/react-flexbox-grid
|
|
9
|
-
// - https://material.angularjs.org/latest/layout/introduction
|
|
10
|
-
//
|
|
11
|
-
// Follow this flexbox Guide to better understand the underlying model:
|
|
12
|
-
// - https://css-tricks.com/snippets/css/a-guide-to-flexbox/
|
|
13
|
-
import * as React from 'react';
|
|
14
3
|
import PropTypes from 'prop-types';
|
|
15
|
-
import
|
|
16
|
-
import { handleBreakpoints, unstable_resolveBreakpointValues as resolveBreakpointValues } from '@mui/system';
|
|
17
|
-
import { extendSxProp } from '@mui/system/styleFunctionSx';
|
|
18
|
-
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
import { createGrid } from '@mui/system/Grid';
|
|
19
5
|
import requirePropFactory from "../utils/requirePropFactory.js";
|
|
20
|
-
import styled from "../styles/
|
|
6
|
+
import { styled } from "../styles/index.js";
|
|
21
7
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
22
8
|
import useTheme from "../styles/useTheme.js";
|
|
23
|
-
import GridContext from "./GridContext.js";
|
|
24
|
-
import gridClasses, { getGridUtilityClass } from "./gridClasses.js";
|
|
25
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
export function generateGrid({
|
|
27
|
-
theme,
|
|
28
|
-
ownerState
|
|
29
|
-
}) {
|
|
30
|
-
let size;
|
|
31
|
-
return theme.breakpoints.keys.reduce((globalStyles, breakpoint) => {
|
|
32
|
-
// Use side effect over immutability for better performance.
|
|
33
|
-
let styles = {};
|
|
34
|
-
if (ownerState[breakpoint]) {
|
|
35
|
-
size = ownerState[breakpoint];
|
|
36
|
-
}
|
|
37
|
-
if (!size) {
|
|
38
|
-
return globalStyles;
|
|
39
|
-
}
|
|
40
|
-
if (size === true) {
|
|
41
|
-
// For the auto layouting
|
|
42
|
-
styles = {
|
|
43
|
-
flexBasis: 0,
|
|
44
|
-
flexGrow: 1,
|
|
45
|
-
maxWidth: '100%'
|
|
46
|
-
};
|
|
47
|
-
} else if (size === 'auto') {
|
|
48
|
-
styles = {
|
|
49
|
-
flexBasis: 'auto',
|
|
50
|
-
flexGrow: 0,
|
|
51
|
-
flexShrink: 0,
|
|
52
|
-
maxWidth: 'none',
|
|
53
|
-
width: 'auto'
|
|
54
|
-
};
|
|
55
|
-
} else {
|
|
56
|
-
const columnsBreakpointValues = resolveBreakpointValues({
|
|
57
|
-
values: ownerState.columns,
|
|
58
|
-
breakpoints: theme.breakpoints.values
|
|
59
|
-
});
|
|
60
|
-
const columnValue = typeof columnsBreakpointValues === 'object' ? columnsBreakpointValues[breakpoint] : columnsBreakpointValues;
|
|
61
|
-
if (columnValue === undefined || columnValue === null) {
|
|
62
|
-
return globalStyles;
|
|
63
|
-
}
|
|
64
|
-
// Keep 7 significant numbers.
|
|
65
|
-
const width = `${Math.round(size / columnValue * 10e7) / 10e5}%`;
|
|
66
|
-
let more = {};
|
|
67
|
-
if (ownerState.container && ownerState.item && ownerState.columnSpacing !== 0) {
|
|
68
|
-
const themeSpacing = theme.spacing(ownerState.columnSpacing);
|
|
69
|
-
if (themeSpacing !== '0px') {
|
|
70
|
-
const fullWidth = `calc(${width} + ${themeSpacing})`;
|
|
71
|
-
more = {
|
|
72
|
-
flexBasis: fullWidth,
|
|
73
|
-
maxWidth: fullWidth
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Close to the bootstrap implementation:
|
|
79
|
-
// https://github.com/twbs/bootstrap/blob/8fccaa2439e97ec72a4b7dc42ccc1f649790adb0/scss/mixins/_grid.scss#L41
|
|
80
|
-
styles = {
|
|
81
|
-
flexBasis: width,
|
|
82
|
-
flexGrow: 0,
|
|
83
|
-
maxWidth: width,
|
|
84
|
-
...more
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// No need for a media query for the first size.
|
|
89
|
-
if (theme.breakpoints.values[breakpoint] === 0) {
|
|
90
|
-
Object.assign(globalStyles, styles);
|
|
91
|
-
} else {
|
|
92
|
-
globalStyles[theme.breakpoints.up(breakpoint)] = styles;
|
|
93
|
-
}
|
|
94
|
-
return globalStyles;
|
|
95
|
-
}, {});
|
|
96
|
-
}
|
|
97
|
-
export function generateDirection({
|
|
98
|
-
theme,
|
|
99
|
-
ownerState
|
|
100
|
-
}) {
|
|
101
|
-
const directionValues = resolveBreakpointValues({
|
|
102
|
-
values: ownerState.direction,
|
|
103
|
-
breakpoints: theme.breakpoints.values
|
|
104
|
-
});
|
|
105
|
-
return handleBreakpoints({
|
|
106
|
-
theme
|
|
107
|
-
}, directionValues, propValue => {
|
|
108
|
-
const output = {
|
|
109
|
-
flexDirection: propValue
|
|
110
|
-
};
|
|
111
|
-
if (propValue.startsWith('column')) {
|
|
112
|
-
output[`& > .${gridClasses.item}`] = {
|
|
113
|
-
maxWidth: 'none'
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return output;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
9
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* Demos:
|
|
12
|
+
*
|
|
13
|
+
* - [Grid](https://next.mui.com/material-ui/react-grid/)
|
|
14
|
+
*
|
|
15
|
+
* API:
|
|
16
|
+
*
|
|
17
|
+
* - [Grid API](https://next.mui.com/material-ui/api/grid/)
|
|
124
18
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (values[key] !== 0) {
|
|
135
|
-
nonZeroKey = key;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
const sortedBreakpointKeysByValue = Object.keys(breakpoints).sort((a, b) => {
|
|
139
|
-
return breakpoints[a] - breakpoints[b];
|
|
140
|
-
});
|
|
141
|
-
return sortedBreakpointKeysByValue.slice(0, sortedBreakpointKeysByValue.indexOf(nonZeroKey));
|
|
142
|
-
}
|
|
143
|
-
export function generateRowGap({
|
|
144
|
-
theme,
|
|
145
|
-
ownerState
|
|
146
|
-
}) {
|
|
147
|
-
const {
|
|
148
|
-
container,
|
|
149
|
-
rowSpacing
|
|
150
|
-
} = ownerState;
|
|
151
|
-
let styles = {};
|
|
152
|
-
if (container && rowSpacing !== 0) {
|
|
153
|
-
const rowSpacingValues = resolveBreakpointValues({
|
|
154
|
-
values: rowSpacing,
|
|
155
|
-
breakpoints: theme.breakpoints.values
|
|
156
|
-
});
|
|
157
|
-
let zeroValueBreakpointKeys;
|
|
158
|
-
if (typeof rowSpacingValues === 'object') {
|
|
159
|
-
zeroValueBreakpointKeys = extractZeroValueBreakpointKeys({
|
|
160
|
-
breakpoints: theme.breakpoints.values,
|
|
161
|
-
values: rowSpacingValues
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
styles = handleBreakpoints({
|
|
165
|
-
theme
|
|
166
|
-
}, rowSpacingValues, (propValue, breakpoint) => {
|
|
167
|
-
const themeSpacing = theme.spacing(propValue);
|
|
168
|
-
if (themeSpacing !== '0px') {
|
|
169
|
-
return {
|
|
170
|
-
marginTop: `calc(-1 * ${themeSpacing})`,
|
|
171
|
-
[`& > .${gridClasses.item}`]: {
|
|
172
|
-
paddingTop: themeSpacing
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
if (zeroValueBreakpointKeys?.includes(breakpoint)) {
|
|
177
|
-
return {};
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
marginTop: 0,
|
|
181
|
-
[`& > .${gridClasses.item}`]: {
|
|
182
|
-
paddingTop: 0
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return styles;
|
|
188
|
-
}
|
|
189
|
-
export function generateColumnGap({
|
|
190
|
-
theme,
|
|
191
|
-
ownerState
|
|
192
|
-
}) {
|
|
193
|
-
const {
|
|
194
|
-
container,
|
|
195
|
-
columnSpacing
|
|
196
|
-
} = ownerState;
|
|
197
|
-
let styles = {};
|
|
198
|
-
if (container && columnSpacing !== 0) {
|
|
199
|
-
const columnSpacingValues = resolveBreakpointValues({
|
|
200
|
-
values: columnSpacing,
|
|
201
|
-
breakpoints: theme.breakpoints.values
|
|
202
|
-
});
|
|
203
|
-
let zeroValueBreakpointKeys;
|
|
204
|
-
if (typeof columnSpacingValues === 'object') {
|
|
205
|
-
zeroValueBreakpointKeys = extractZeroValueBreakpointKeys({
|
|
206
|
-
breakpoints: theme.breakpoints.values,
|
|
207
|
-
values: columnSpacingValues
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
styles = handleBreakpoints({
|
|
211
|
-
theme
|
|
212
|
-
}, columnSpacingValues, (propValue, breakpoint) => {
|
|
213
|
-
const themeSpacing = theme.spacing(propValue);
|
|
214
|
-
if (themeSpacing !== '0px') {
|
|
215
|
-
const negativeValue = `calc(-1 * ${themeSpacing})`;
|
|
216
|
-
return {
|
|
217
|
-
width: `calc(100% + ${themeSpacing})`,
|
|
218
|
-
marginLeft: negativeValue,
|
|
219
|
-
[`& > .${gridClasses.item}`]: {
|
|
220
|
-
paddingLeft: themeSpacing
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
if (zeroValueBreakpointKeys?.includes(breakpoint)) {
|
|
225
|
-
return {};
|
|
226
|
-
}
|
|
227
|
-
return {
|
|
228
|
-
width: '100%',
|
|
229
|
-
marginLeft: 0,
|
|
230
|
-
[`& > .${gridClasses.item}`]: {
|
|
231
|
-
paddingLeft: 0
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
return styles;
|
|
237
|
-
}
|
|
238
|
-
export function resolveSpacingStyles(spacing, breakpoints, styles = {}) {
|
|
239
|
-
// undefined/null or `spacing` <= 0
|
|
240
|
-
if (!spacing || spacing <= 0) {
|
|
241
|
-
return [];
|
|
242
|
-
}
|
|
243
|
-
// in case of string/number `spacing`
|
|
244
|
-
if (typeof spacing === 'string' && !Number.isNaN(Number(spacing)) || typeof spacing === 'number') {
|
|
245
|
-
return [styles[`spacing-xs-${String(spacing)}`]];
|
|
246
|
-
}
|
|
247
|
-
// in case of object `spacing`
|
|
248
|
-
const spacingStyles = [];
|
|
249
|
-
breakpoints.forEach(breakpoint => {
|
|
250
|
-
const value = spacing[breakpoint];
|
|
251
|
-
if (Number(value) > 0) {
|
|
252
|
-
spacingStyles.push(styles[`spacing-${breakpoint}-${String(value)}`]);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
return spacingStyles;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Default CSS values
|
|
259
|
-
// flex: '0 1 auto',
|
|
260
|
-
// flexDirection: 'row',
|
|
261
|
-
// alignItems: 'flex-start',
|
|
262
|
-
// flexWrap: 'nowrap',
|
|
263
|
-
// justifyContent: 'flex-start',
|
|
264
|
-
const GridRoot = styled('div', {
|
|
265
|
-
name: 'MuiGrid',
|
|
266
|
-
slot: 'Root',
|
|
267
|
-
overridesResolver: (props, styles) => {
|
|
268
|
-
const {
|
|
269
|
-
ownerState
|
|
270
|
-
} = props;
|
|
271
|
-
const {
|
|
272
|
-
container,
|
|
273
|
-
direction,
|
|
274
|
-
item,
|
|
275
|
-
spacing,
|
|
276
|
-
wrap,
|
|
277
|
-
zeroMinWidth,
|
|
278
|
-
breakpoints
|
|
279
|
-
} = ownerState;
|
|
280
|
-
let spacingStyles = [];
|
|
281
|
-
|
|
282
|
-
// in case of grid item
|
|
283
|
-
if (container) {
|
|
284
|
-
spacingStyles = resolveSpacingStyles(spacing, breakpoints, styles);
|
|
19
|
+
const Grid = createGrid({
|
|
20
|
+
createStyledComponent: styled('div', {
|
|
21
|
+
name: 'MuiGrid',
|
|
22
|
+
slot: 'Root',
|
|
23
|
+
overridesResolver: (props, styles) => {
|
|
24
|
+
const {
|
|
25
|
+
ownerState
|
|
26
|
+
} = props;
|
|
27
|
+
return [styles.root, ownerState.container && styles.container];
|
|
285
28
|
}
|
|
286
|
-
const breakpointsStyles = [];
|
|
287
|
-
breakpoints.forEach(breakpoint => {
|
|
288
|
-
const value = ownerState[breakpoint];
|
|
289
|
-
if (value) {
|
|
290
|
-
breakpointsStyles.push(styles[`grid-${breakpoint}-${String(value)}`]);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
return [styles.root, container && styles.container, item && styles.item, zeroMinWidth && styles.zeroMinWidth, ...spacingStyles, direction !== 'row' && styles[`direction-xs-${String(direction)}`], wrap !== 'wrap' && styles[`wrap-xs-${String(wrap)}`], ...breakpointsStyles];
|
|
294
|
-
}
|
|
295
|
-
})(
|
|
296
|
-
// FIXME(romgrk): Can't use memoTheme here
|
|
297
|
-
({
|
|
298
|
-
ownerState
|
|
299
|
-
}) => ({
|
|
300
|
-
boxSizing: 'border-box',
|
|
301
|
-
...(ownerState.container && {
|
|
302
|
-
display: 'flex',
|
|
303
|
-
flexWrap: 'wrap',
|
|
304
|
-
width: '100%'
|
|
305
|
-
}),
|
|
306
|
-
...(ownerState.item && {
|
|
307
|
-
margin: 0 // For instance, it's useful when used with a `figure` element.
|
|
308
29
|
}),
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}),
|
|
312
|
-
...(ownerState.wrap !== 'wrap' && {
|
|
313
|
-
flexWrap: ownerState.wrap
|
|
314
|
-
})
|
|
315
|
-
}), generateDirection, generateRowGap, generateColumnGap, generateGrid);
|
|
316
|
-
export function resolveSpacingClasses(spacing, breakpoints) {
|
|
317
|
-
// undefined/null or `spacing` <= 0
|
|
318
|
-
if (!spacing || spacing <= 0) {
|
|
319
|
-
return [];
|
|
320
|
-
}
|
|
321
|
-
// in case of string/number `spacing`
|
|
322
|
-
if (typeof spacing === 'string' && !Number.isNaN(Number(spacing)) || typeof spacing === 'number') {
|
|
323
|
-
return [`spacing-xs-${String(spacing)}`];
|
|
324
|
-
}
|
|
325
|
-
// in case of object `spacing`
|
|
326
|
-
const classes = [];
|
|
327
|
-
breakpoints.forEach(breakpoint => {
|
|
328
|
-
const value = spacing[breakpoint];
|
|
329
|
-
if (Number(value) > 0) {
|
|
330
|
-
const className = `spacing-${breakpoint}-${String(value)}`;
|
|
331
|
-
classes.push(className);
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
return classes;
|
|
335
|
-
}
|
|
336
|
-
const useUtilityClasses = ownerState => {
|
|
337
|
-
const {
|
|
338
|
-
classes,
|
|
339
|
-
container,
|
|
340
|
-
direction,
|
|
341
|
-
item,
|
|
342
|
-
spacing,
|
|
343
|
-
wrap,
|
|
344
|
-
zeroMinWidth,
|
|
345
|
-
breakpoints
|
|
346
|
-
} = ownerState;
|
|
347
|
-
let spacingClasses = [];
|
|
348
|
-
|
|
349
|
-
// in case of grid item
|
|
350
|
-
if (container) {
|
|
351
|
-
spacingClasses = resolveSpacingClasses(spacing, breakpoints);
|
|
352
|
-
}
|
|
353
|
-
const breakpointsClasses = [];
|
|
354
|
-
breakpoints.forEach(breakpoint => {
|
|
355
|
-
const value = ownerState[breakpoint];
|
|
356
|
-
if (value) {
|
|
357
|
-
breakpointsClasses.push(`grid-${breakpoint}-${String(value)}`);
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
const slots = {
|
|
361
|
-
root: ['root', container && 'container', item && 'item', zeroMinWidth && 'zeroMinWidth', ...spacingClasses, direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...breakpointsClasses]
|
|
362
|
-
};
|
|
363
|
-
return composeClasses(slots, getGridUtilityClass, classes);
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* @deprecated Use the [`Grid2`](https://mui.com/material-ui/react-grid2/) component instead.
|
|
368
|
-
*/
|
|
369
|
-
const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
370
|
-
const themeProps = useDefaultProps({
|
|
30
|
+
componentName: 'MuiGrid',
|
|
31
|
+
useThemeProps: inProps => useDefaultProps({
|
|
371
32
|
props: inProps,
|
|
372
33
|
name: 'MuiGrid'
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
breakpoints
|
|
376
|
-
} = useTheme();
|
|
377
|
-
const props = extendSxProp(themeProps);
|
|
378
|
-
const {
|
|
379
|
-
className,
|
|
380
|
-
columns: columnsProp,
|
|
381
|
-
columnSpacing: columnSpacingProp,
|
|
382
|
-
component = 'div',
|
|
383
|
-
container = false,
|
|
384
|
-
direction = 'row',
|
|
385
|
-
item = false,
|
|
386
|
-
rowSpacing: rowSpacingProp,
|
|
387
|
-
spacing = 0,
|
|
388
|
-
wrap = 'wrap',
|
|
389
|
-
zeroMinWidth = false,
|
|
390
|
-
...other
|
|
391
|
-
} = props;
|
|
392
|
-
const rowSpacing = rowSpacingProp || spacing;
|
|
393
|
-
const columnSpacing = columnSpacingProp || spacing;
|
|
394
|
-
const columnsContext = React.useContext(GridContext);
|
|
395
|
-
|
|
396
|
-
// columns set with default breakpoint unit of 12
|
|
397
|
-
const columns = container ? columnsProp || 12 : columnsContext;
|
|
398
|
-
const breakpointsValues = {};
|
|
399
|
-
const otherFiltered = {
|
|
400
|
-
...other
|
|
401
|
-
};
|
|
402
|
-
breakpoints.keys.forEach(breakpoint => {
|
|
403
|
-
if (other[breakpoint] != null) {
|
|
404
|
-
breakpointsValues[breakpoint] = other[breakpoint];
|
|
405
|
-
delete otherFiltered[breakpoint];
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
const ownerState = {
|
|
409
|
-
...props,
|
|
410
|
-
columns,
|
|
411
|
-
container,
|
|
412
|
-
direction,
|
|
413
|
-
item,
|
|
414
|
-
rowSpacing,
|
|
415
|
-
columnSpacing,
|
|
416
|
-
wrap,
|
|
417
|
-
zeroMinWidth,
|
|
418
|
-
spacing,
|
|
419
|
-
...breakpointsValues,
|
|
420
|
-
breakpoints: breakpoints.keys
|
|
421
|
-
};
|
|
422
|
-
const classes = useUtilityClasses(ownerState);
|
|
423
|
-
return /*#__PURE__*/_jsx(GridContext.Provider, {
|
|
424
|
-
value: columns,
|
|
425
|
-
children: /*#__PURE__*/_jsx(GridRoot, {
|
|
426
|
-
ownerState: ownerState,
|
|
427
|
-
className: clsx(classes.root, className),
|
|
428
|
-
as: component,
|
|
429
|
-
ref: ref,
|
|
430
|
-
...otherFiltered
|
|
431
|
-
})
|
|
432
|
-
});
|
|
34
|
+
}),
|
|
35
|
+
useTheme
|
|
433
36
|
});
|
|
434
37
|
process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ = {
|
|
435
38
|
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
436
39
|
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
437
|
-
// │
|
|
40
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
438
41
|
// └─────────────────────────────────────────────────────────────────────┘
|
|
439
42
|
/**
|
|
440
43
|
* The content of the component.
|
|
441
44
|
*/
|
|
442
45
|
children: PropTypes.node,
|
|
443
|
-
/**
|
|
444
|
-
* Override or extend the styles applied to the component.
|
|
445
|
-
*/
|
|
446
|
-
classes: PropTypes.object,
|
|
447
|
-
/**
|
|
448
|
-
* @ignore
|
|
449
|
-
*/
|
|
450
|
-
className: PropTypes.string,
|
|
451
46
|
/**
|
|
452
47
|
* The number of columns.
|
|
453
48
|
* @default 12
|
|
454
49
|
*/
|
|
455
|
-
columns: PropTypes
|
|
50
|
+
columns: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
456
51
|
/**
|
|
457
52
|
* Defines the horizontal space between the type `item` components.
|
|
458
53
|
* It overrides the value of the `spacing` prop.
|
|
459
54
|
*/
|
|
460
|
-
columnSpacing: PropTypes
|
|
461
|
-
/**
|
|
462
|
-
* The component used for the root node.
|
|
463
|
-
* Either a string to use a HTML element or a component.
|
|
464
|
-
*/
|
|
465
|
-
component: PropTypes.elementType,
|
|
55
|
+
columnSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
466
56
|
/**
|
|
467
57
|
* If `true`, the component will have the flex *container* behavior.
|
|
468
58
|
* You should be wrapping *items* with a *container*.
|
|
@@ -474,105 +64,75 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
|
|
|
474
64
|
* It is applied for all screen sizes.
|
|
475
65
|
* @default 'row'
|
|
476
66
|
*/
|
|
477
|
-
direction: PropTypes
|
|
478
|
-
/**
|
|
479
|
-
* If `true`, the component will have the flex *item* behavior.
|
|
480
|
-
* You should be wrapping *items* with a *container*.
|
|
481
|
-
* @default false
|
|
482
|
-
*/
|
|
483
|
-
item: PropTypes.bool,
|
|
67
|
+
direction: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
484
68
|
/**
|
|
485
|
-
*
|
|
486
|
-
* It can't be greater than the total number of columns of the container (12 by default).
|
|
487
|
-
* If 'auto', the grid item's width matches its content.
|
|
488
|
-
* If false, the prop is ignored.
|
|
489
|
-
* If true, the grid item's width grows to use the space available in the grid container.
|
|
490
|
-
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
|
491
|
-
* @default false
|
|
69
|
+
* Defines the offset value for the type `item` components.
|
|
492
70
|
*/
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* If a number, it sets the number of columns the grid item uses.
|
|
496
|
-
* It can't be greater than the total number of columns of the container (12 by default).
|
|
497
|
-
* If 'auto', the grid item's width matches its content.
|
|
498
|
-
* If false, the prop is ignored.
|
|
499
|
-
* If true, the grid item's width grows to use the space available in the grid container.
|
|
500
|
-
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
|
501
|
-
* @default false
|
|
502
|
-
*/
|
|
503
|
-
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
71
|
+
offset: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.object]),
|
|
504
72
|
/**
|
|
505
73
|
* Defines the vertical space between the type `item` components.
|
|
506
74
|
* It overrides the value of the `spacing` prop.
|
|
507
75
|
*/
|
|
508
|
-
rowSpacing: PropTypes
|
|
76
|
+
rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
509
77
|
/**
|
|
510
|
-
*
|
|
511
|
-
* It can't be greater than the total number of columns of the container (12 by default).
|
|
512
|
-
* If 'auto', the grid item's width matches its content.
|
|
513
|
-
* If false, the prop is ignored.
|
|
514
|
-
* If true, the grid item's width grows to use the space available in the grid container.
|
|
515
|
-
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
|
516
|
-
* @default false
|
|
78
|
+
* Defines the size of the the type `item` components.
|
|
517
79
|
*/
|
|
518
|
-
|
|
80
|
+
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number])), PropTypes.object]),
|
|
519
81
|
/**
|
|
520
82
|
* Defines the space between the type `item` components.
|
|
521
83
|
* It can only be used on a type `container` component.
|
|
522
84
|
* @default 0
|
|
523
85
|
*/
|
|
524
|
-
spacing: PropTypes
|
|
86
|
+
spacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
525
87
|
/**
|
|
526
|
-
*
|
|
88
|
+
* @ignore
|
|
527
89
|
*/
|
|
528
90
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
91
|
+
/**
|
|
92
|
+
* @internal
|
|
93
|
+
* The level of the grid starts from `0` and increases when the grid nests
|
|
94
|
+
* inside another grid. Nesting is defined as a container Grid being a direct
|
|
95
|
+
* child of a container Grid.
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* <Grid container> // level 0
|
|
99
|
+
* <Grid container> // level 1
|
|
100
|
+
* <Grid container> // level 2
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* Only consecutive grid is considered nesting. A grid container will start at
|
|
104
|
+
* `0` if there are non-Grid container element above it.
|
|
105
|
+
*
|
|
106
|
+
* ```js
|
|
107
|
+
* <Grid container> // level 0
|
|
108
|
+
* <div>
|
|
109
|
+
* <Grid container> // level 0
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* ```js
|
|
113
|
+
* <Grid container> // level 0
|
|
114
|
+
* <Grid>
|
|
115
|
+
* <Grid container> // level 0
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
unstable_level: PropTypes.number,
|
|
529
119
|
/**
|
|
530
120
|
* Defines the `flex-wrap` style property.
|
|
531
121
|
* It's applied for all screen sizes.
|
|
532
122
|
* @default 'wrap'
|
|
533
123
|
*/
|
|
534
|
-
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
|
|
535
|
-
/**
|
|
536
|
-
* If a number, it sets the number of columns the grid item uses.
|
|
537
|
-
* It can't be greater than the total number of columns of the container (12 by default).
|
|
538
|
-
* If 'auto', the grid item's width matches its content.
|
|
539
|
-
* If false, the prop is ignored.
|
|
540
|
-
* If true, the grid item's width grows to use the space available in the grid container.
|
|
541
|
-
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
|
542
|
-
* @default false
|
|
543
|
-
*/
|
|
544
|
-
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
545
|
-
/**
|
|
546
|
-
* If a number, it sets the number of columns the grid item uses.
|
|
547
|
-
* It can't be greater than the total number of columns of the container (12 by default).
|
|
548
|
-
* If 'auto', the grid item's width matches its content.
|
|
549
|
-
* If false, the prop is ignored.
|
|
550
|
-
* If true, the grid item's width grows to use the space available in the grid container.
|
|
551
|
-
* The value is applied for all the screen sizes with the lowest priority.
|
|
552
|
-
* @default false
|
|
553
|
-
*/
|
|
554
|
-
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
555
|
-
/**
|
|
556
|
-
* If `true`, it sets `min-width: 0` on the item.
|
|
557
|
-
* Refer to the limitations section of the documentation to better understand the use case.
|
|
558
|
-
* @default false
|
|
559
|
-
*/
|
|
560
|
-
zeroMinWidth: PropTypes.bool
|
|
124
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
|
|
561
125
|
} : void 0;
|
|
562
126
|
if (process.env.NODE_ENV !== 'production') {
|
|
563
|
-
const
|
|
127
|
+
const Component = Grid;
|
|
128
|
+
const requireProp = requirePropFactory('Grid', Component);
|
|
564
129
|
// eslint-disable-next-line no-useless-concat
|
|
565
|
-
|
|
130
|
+
Component['propTypes' + ''] = {
|
|
566
131
|
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
567
|
-
...
|
|
132
|
+
...Component.propTypes,
|
|
568
133
|
direction: requireProp('container'),
|
|
569
|
-
lg: requireProp('item'),
|
|
570
|
-
md: requireProp('item'),
|
|
571
|
-
sm: requireProp('item'),
|
|
572
134
|
spacing: requireProp('container'),
|
|
573
|
-
wrap: requireProp('container')
|
|
574
|
-
xs: requireProp('item'),
|
|
575
|
-
zeroMinWidth: requireProp('item')
|
|
135
|
+
wrap: requireProp('container')
|
|
576
136
|
};
|
|
577
137
|
}
|
|
578
138
|
export default Grid;
|
|
@@ -3,44 +3,6 @@ export interface GridClasses {
|
|
|
3
3
|
root: string;
|
|
4
4
|
/** Styles applied to the root element if `container={true}`. */
|
|
5
5
|
container: string;
|
|
6
|
-
/** Styles applied to the root element if `item={true}`. */
|
|
7
|
-
item: string;
|
|
8
|
-
/** Styles applied to the root element if `zeroMinWidth={true}`. */
|
|
9
|
-
zeroMinWidth: string;
|
|
10
|
-
/** Styles applied to the root element if `direction="column"`. */
|
|
11
|
-
'direction-xs-column': string;
|
|
12
|
-
/** Styles applied to the root element if `direction="column-reverse"`. */
|
|
13
|
-
'direction-xs-column-reverse': string;
|
|
14
|
-
/** Styles applied to the root element if `direction="row-reverse"`. */
|
|
15
|
-
'direction-xs-row-reverse': string;
|
|
16
|
-
/** Styles applied to the root element if `wrap="nowrap"`. */
|
|
17
|
-
'wrap-xs-nowrap': string;
|
|
18
|
-
/** Styles applied to the root element if `wrap="reverse"`. */
|
|
19
|
-
'wrap-xs-wrap-reverse': string;
|
|
20
|
-
'spacing-xs-1': string;
|
|
21
|
-
'spacing-xs-2': string;
|
|
22
|
-
'spacing-xs-3': string;
|
|
23
|
-
'spacing-xs-4': string;
|
|
24
|
-
'spacing-xs-5': string;
|
|
25
|
-
'spacing-xs-6': string;
|
|
26
|
-
'spacing-xs-7': string;
|
|
27
|
-
'spacing-xs-8': string;
|
|
28
|
-
'spacing-xs-9': string;
|
|
29
|
-
'spacing-xs-10': string;
|
|
30
|
-
'grid-xs-auto': string;
|
|
31
|
-
'grid-xs-true': string;
|
|
32
|
-
'grid-xs-1': string;
|
|
33
|
-
'grid-xs-2': string;
|
|
34
|
-
'grid-xs-3': string;
|
|
35
|
-
'grid-xs-4': string;
|
|
36
|
-
'grid-xs-5': string;
|
|
37
|
-
'grid-xs-6': string;
|
|
38
|
-
'grid-xs-7': string;
|
|
39
|
-
'grid-xs-8': string;
|
|
40
|
-
'grid-xs-9': string;
|
|
41
|
-
'grid-xs-10': string;
|
|
42
|
-
'grid-xs-11': string;
|
|
43
|
-
'grid-xs-12': string;
|
|
44
6
|
}
|
|
45
7
|
export type GridClassKey = keyof GridClasses;
|
|
46
8
|
export declare function getGridUtilityClass(slot: string): string;
|
|
@@ -7,7 +7,7 @@ const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
|
7
7
|
const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
|
|
8
8
|
const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
|
|
9
9
|
const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
10
|
-
const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container',
|
|
10
|
+
const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container',
|
|
11
11
|
// spacings
|
|
12
12
|
...SPACINGS.map(spacing => `spacing-xs-${spacing}`),
|
|
13
13
|
// direction values
|