@mui/system 5.8.7 → 5.9.2
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 +200 -4
- package/Unstable_Grid/Grid.d.ts +12 -0
- package/Unstable_Grid/Grid.js +195 -0
- package/Unstable_Grid/GridProps.d.ts +162 -0
- package/Unstable_Grid/GridProps.js +5 -0
- package/Unstable_Grid/createGrid.d.ts +11 -0
- package/Unstable_Grid/createGrid.js +199 -0
- package/Unstable_Grid/gridClasses.d.ts +20 -0
- package/Unstable_Grid/gridClasses.js +25 -0
- package/Unstable_Grid/gridGenerator.d.ts +26 -0
- package/Unstable_Grid/gridGenerator.js +275 -0
- package/Unstable_Grid/index.d.ts +5 -0
- package/Unstable_Grid/index.js +65 -0
- package/Unstable_Grid/package.json +6 -0
- package/breakpoints.js +1 -1
- package/{grid.js → cssGrid.js} +0 -0
- package/cssVars/useCurrentColorScheme.js +1 -1
- package/esm/Unstable_Grid/Grid.js +184 -0
- package/esm/Unstable_Grid/GridProps.js +1 -0
- package/esm/Unstable_Grid/createGrid.js +177 -0
- package/esm/Unstable_Grid/gridClasses.js +14 -0
- package/esm/Unstable_Grid/gridGenerator.js +236 -0
- package/esm/Unstable_Grid/index.js +5 -0
- package/esm/breakpoints.js +1 -1
- package/esm/{grid.js → cssGrid.js} +0 -0
- package/esm/cssVars/useCurrentColorScheme.js +1 -1
- package/esm/getThemeValue.js +1 -1
- package/esm/index.js +9 -3
- package/getThemeValue.js +3 -3
- package/index.d.ts +3 -0
- package/index.js +30 -7
- package/legacy/Unstable_Grid/Grid.js +184 -0
- package/legacy/Unstable_Grid/GridProps.js +1 -0
- package/legacy/Unstable_Grid/createGrid.js +191 -0
- package/legacy/Unstable_Grid/gridClasses.js +27 -0
- package/legacy/Unstable_Grid/gridGenerator.js +245 -0
- package/legacy/Unstable_Grid/index.js +5 -0
- package/legacy/breakpoints.js +1 -1
- package/legacy/{grid.js → cssGrid.js} +0 -0
- package/legacy/cssVars/useCurrentColorScheme.js +1 -1
- package/legacy/getThemeValue.js +1 -1
- package/legacy/index.js +10 -4
- package/modern/Unstable_Grid/Grid.js +184 -0
- package/modern/Unstable_Grid/GridProps.js +1 -0
- package/modern/Unstable_Grid/createGrid.js +175 -0
- package/modern/Unstable_Grid/gridClasses.js +14 -0
- package/modern/Unstable_Grid/gridGenerator.js +232 -0
- package/modern/Unstable_Grid/index.js +5 -0
- package/modern/breakpoints.js +1 -1
- package/modern/{grid.js → cssGrid.js} +0 -0
- package/modern/cssVars/useCurrentColorScheme.js +1 -1
- package/modern/getThemeValue.js +1 -1
- package/modern/index.js +10 -4
- package/package.json +5 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
2
|
+
export function getGridUtilityClass(slot) {
|
|
3
|
+
return generateUtilityClass('MuiGrid', slot);
|
|
4
|
+
}
|
|
5
|
+
const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
6
|
+
const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
|
|
7
|
+
const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
|
|
8
|
+
const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
9
|
+
const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container', 'item', // spacings
|
|
10
|
+
...SPACINGS.map(spacing => `spacing-xs-${spacing}`), // direction values
|
|
11
|
+
...DIRECTIONS.map(direction => `direction-xs-${direction}`), // wrap values
|
|
12
|
+
...WRAPS.map(wrap => `wrap-xs-${wrap}`), // grid sizes for all breakpoints
|
|
13
|
+
...GRID_SIZES.map(size => `grid-xs-${size}`), ...GRID_SIZES.map(size => `grid-sm-${size}`), ...GRID_SIZES.map(size => `grid-md-${size}`), ...GRID_SIZES.map(size => `grid-lg-${size}`), ...GRID_SIZES.map(size => `grid-xl-${size}`)]);
|
|
14
|
+
export default gridClasses;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
export const traverseBreakpoints = (breakpoints, responsize, iterator) => {
|
|
3
|
+
const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
|
|
4
|
+
|
|
5
|
+
if (Array.isArray(responsize)) {
|
|
6
|
+
responsize.forEach((breakpointValue, index) => {
|
|
7
|
+
iterator((responsizeStyles, style) => {
|
|
8
|
+
if (index <= breakpoints.keys.length - 1) {
|
|
9
|
+
if (index === 0) {
|
|
10
|
+
Object.assign(responsizeStyles, style);
|
|
11
|
+
} else {
|
|
12
|
+
responsizeStyles[breakpoints.up(breakpoints.keys[index])] = style;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, breakpointValue);
|
|
16
|
+
});
|
|
17
|
+
} else if (responsize && typeof responsize === 'object') {
|
|
18
|
+
// prevent null
|
|
19
|
+
// responsize could be a very big object, pick the smallest responsive values
|
|
20
|
+
const keys = Object.keys(responsize).length > breakpoints.keys.length ? breakpoints.keys : Object.keys(responsize);
|
|
21
|
+
keys.forEach(key => {
|
|
22
|
+
if (breakpoints.keys.indexOf(key) !== -1) {
|
|
23
|
+
// @ts-ignore already checked that responsize is an object
|
|
24
|
+
const breakpointValue = responsize[key];
|
|
25
|
+
|
|
26
|
+
if (breakpointValue !== undefined) {
|
|
27
|
+
iterator((responsizeStyles, style) => {
|
|
28
|
+
if (smallestBreakpoint === key) {
|
|
29
|
+
Object.assign(responsizeStyles, style);
|
|
30
|
+
} else {
|
|
31
|
+
responsizeStyles[breakpoints.up(key)] = style;
|
|
32
|
+
}
|
|
33
|
+
}, breakpointValue);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
} else if (typeof responsize === 'number' || typeof responsize === 'string') {
|
|
38
|
+
iterator((responsizeStyles, style) => {
|
|
39
|
+
Object.assign(responsizeStyles, style);
|
|
40
|
+
}, responsize);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export const generateGridSizeStyles = ({
|
|
44
|
+
theme,
|
|
45
|
+
ownerState
|
|
46
|
+
}) => {
|
|
47
|
+
const styles = {};
|
|
48
|
+
traverseBreakpoints(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
|
|
49
|
+
let style = {};
|
|
50
|
+
|
|
51
|
+
if (value === true) {
|
|
52
|
+
style = {
|
|
53
|
+
flexBasis: 0,
|
|
54
|
+
flexGrow: 1,
|
|
55
|
+
maxWidth: '100%'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (value === 'auto') {
|
|
60
|
+
style = {
|
|
61
|
+
flexBasis: 'auto',
|
|
62
|
+
flexGrow: 0,
|
|
63
|
+
flexShrink: 0,
|
|
64
|
+
maxWidth: 'none',
|
|
65
|
+
width: 'auto'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof value === 'number') {
|
|
70
|
+
style = {
|
|
71
|
+
flexGrow: 0,
|
|
72
|
+
flexBasis: 'auto',
|
|
73
|
+
width: `calc(100% * ${value} / var(--Grid-columns)${ownerState.nested && ownerState.container ? ` + var(--Grid-columnSpacing)` : ''})`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
appendStyle(styles, style);
|
|
78
|
+
});
|
|
79
|
+
return styles;
|
|
80
|
+
};
|
|
81
|
+
export const generateGridOffsetStyles = ({
|
|
82
|
+
theme,
|
|
83
|
+
ownerState
|
|
84
|
+
}) => {
|
|
85
|
+
const styles = {};
|
|
86
|
+
traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
|
|
87
|
+
let style = {};
|
|
88
|
+
|
|
89
|
+
if (value === 'auto') {
|
|
90
|
+
style = {
|
|
91
|
+
marginLeft: 'auto'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (typeof value === 'number') {
|
|
96
|
+
style = {
|
|
97
|
+
marginLeft: value === 0 ? '0px' : `calc(100% * ${value} / var(--Grid-columns))`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
appendStyle(styles, style);
|
|
102
|
+
});
|
|
103
|
+
return styles;
|
|
104
|
+
};
|
|
105
|
+
export const generateGridColumnsStyles = ({
|
|
106
|
+
theme,
|
|
107
|
+
ownerState
|
|
108
|
+
}) => {
|
|
109
|
+
if (!ownerState.container) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const styles = {
|
|
114
|
+
'--Grid-columns': 12
|
|
115
|
+
};
|
|
116
|
+
traverseBreakpoints(theme.breakpoints, ownerState.columns, (appendStyle, value) => {
|
|
117
|
+
appendStyle(styles, {
|
|
118
|
+
'--Grid-columns': value
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return styles;
|
|
122
|
+
};
|
|
123
|
+
export const generateGridRowSpacingStyles = ({
|
|
124
|
+
theme,
|
|
125
|
+
ownerState
|
|
126
|
+
}) => {
|
|
127
|
+
if (!ownerState.container) {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const styles = {};
|
|
132
|
+
traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
|
|
133
|
+
appendStyle(styles, {
|
|
134
|
+
'--Grid-rowSpacing': typeof value === 'string' ? value : theme.spacing?.(value)
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return styles;
|
|
138
|
+
};
|
|
139
|
+
export const generateGridColumnSpacingStyles = ({
|
|
140
|
+
theme,
|
|
141
|
+
ownerState
|
|
142
|
+
}) => {
|
|
143
|
+
if (!ownerState.container) {
|
|
144
|
+
return {};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const styles = {};
|
|
148
|
+
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
|
|
149
|
+
appendStyle(styles, {
|
|
150
|
+
'--Grid-columnSpacing': typeof value === 'string' ? value : theme.spacing?.(value)
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
return styles;
|
|
154
|
+
};
|
|
155
|
+
export const generateGridDirectionStyles = ({
|
|
156
|
+
theme,
|
|
157
|
+
ownerState
|
|
158
|
+
}) => {
|
|
159
|
+
if (!ownerState.container) {
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const styles = {};
|
|
164
|
+
traverseBreakpoints(theme.breakpoints, ownerState.direction, (appendStyle, value) => {
|
|
165
|
+
appendStyle(styles, {
|
|
166
|
+
flexDirection: value
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
return styles;
|
|
170
|
+
};
|
|
171
|
+
export const generateGridStyles = ({
|
|
172
|
+
ownerState
|
|
173
|
+
}) => {
|
|
174
|
+
return _extends({
|
|
175
|
+
minWidth: 0,
|
|
176
|
+
boxSizing: 'border-box'
|
|
177
|
+
}, ownerState.container ? _extends({
|
|
178
|
+
display: 'flex',
|
|
179
|
+
flexWrap: 'wrap'
|
|
180
|
+
}, ownerState.wrap && ownerState.wrap !== 'wrap' && {
|
|
181
|
+
flexWrap: ownerState.wrap
|
|
182
|
+
}, {
|
|
183
|
+
margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
|
|
184
|
+
}, ownerState.disableEqualOverflow && {
|
|
185
|
+
margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
|
|
186
|
+
}, ownerState.nested ? _extends({
|
|
187
|
+
padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
|
|
188
|
+
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
189
|
+
padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
|
|
190
|
+
}) : {
|
|
191
|
+
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
192
|
+
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
193
|
+
}) : _extends({
|
|
194
|
+
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
195
|
+
}, ownerState.disableEqualOverflow && {
|
|
196
|
+
padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
|
|
197
|
+
}));
|
|
198
|
+
};
|
|
199
|
+
export const generateSizeClassNames = gridSize => {
|
|
200
|
+
const classNames = [];
|
|
201
|
+
Object.entries(gridSize).forEach(([key, value]) => {
|
|
202
|
+
if (value !== false && value !== undefined) {
|
|
203
|
+
classNames.push(`grid-${key}-${String(value)}`);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return classNames;
|
|
207
|
+
};
|
|
208
|
+
export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') => {
|
|
209
|
+
function isValidSpacing(val) {
|
|
210
|
+
if (val === undefined) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (isValidSpacing(spacing)) {
|
|
218
|
+
return [`spacing-${smallestBreakpoint}-${String(spacing)}`];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (typeof spacing === 'object' && !Array.isArray(spacing)) {
|
|
222
|
+
const classNames = [];
|
|
223
|
+
Object.entries(spacing).forEach(([key, value]) => {
|
|
224
|
+
if (isValidSpacing(value)) {
|
|
225
|
+
classNames.push(`spacing-${key}-${String(value)}`);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return classNames;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return [];
|
|
232
|
+
};
|
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;
|
|
File without changes
|
|
@@ -153,7 +153,7 @@ export default function useCurrentColorScheme(options) {
|
|
|
153
153
|
const handleMediaQuery = React.useCallback(e => {
|
|
154
154
|
if (state.mode === 'system') {
|
|
155
155
|
setState(currentState => _extends({}, currentState, {
|
|
156
|
-
systemMode: e
|
|
156
|
+
systemMode: e?.matches ? 'dark' : 'light'
|
|
157
157
|
}));
|
|
158
158
|
}
|
|
159
159
|
}, [state.mode]); // Ref hack to avoid adding handleMediaQuery as a dep
|
package/modern/getThemeValue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import borders from './borders';
|
|
2
2
|
import display from './display';
|
|
3
3
|
import flexbox from './flexbox';
|
|
4
|
-
import grid from './
|
|
4
|
+
import grid from './cssGrid';
|
|
5
5
|
import positions from './positions';
|
|
6
6
|
import palette from './palette';
|
|
7
7
|
import shadows from './shadows';
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.9.2
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,8 +12,8 @@ export { default as compose } from './compose';
|
|
|
12
12
|
export { default as display } from './display';
|
|
13
13
|
export { default as flexbox } from './flexbox';
|
|
14
14
|
export * from './flexbox';
|
|
15
|
-
export { default as grid } from './
|
|
16
|
-
export * from './
|
|
15
|
+
export { default as grid } from './cssGrid';
|
|
16
|
+
export * from './cssGrid';
|
|
17
17
|
export { default as palette } from './palette';
|
|
18
18
|
export * from './palette';
|
|
19
19
|
export { default as positions } from './positions';
|
|
@@ -45,6 +45,12 @@ export * from './colorManipulator';
|
|
|
45
45
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
46
46
|
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
47
47
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
48
|
+
/** ----------------- */
|
|
49
|
+
|
|
50
|
+
/** Layout components */
|
|
51
|
+
|
|
48
52
|
export { default as createContainer } from './Container/createContainer';
|
|
49
53
|
export { default as Container } from './Container';
|
|
50
|
-
export * from './Container';
|
|
54
|
+
export * from './Container';
|
|
55
|
+
export { default as Unstable_Grid } from './Unstable_Grid/Grid';
|
|
56
|
+
export * from './Unstable_Grid';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.17.2",
|
|
47
|
-
"@mui/private-theming": "^5.
|
|
47
|
+
"@mui/private-theming": "^5.9.1",
|
|
48
48
|
"@mui/styled-engine": "^5.8.7",
|
|
49
|
-
"@mui/types": "^7.1.
|
|
50
|
-
"@mui/utils": "^5.
|
|
51
|
-
"clsx": "^1.2.
|
|
49
|
+
"@mui/types": "^7.1.5",
|
|
50
|
+
"@mui/utils": "^5.9.1",
|
|
51
|
+
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.0",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|