@mui/system 5.8.7 → 5.9.0
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 +74 -0
- package/Unstable_Grid/Grid.d.ts +12 -0
- package/Unstable_Grid/Grid.js +190 -0
- package/Unstable_Grid/GridProps.d.ts +158 -0
- package/Unstable_Grid/GridProps.js +5 -0
- package/Unstable_Grid/createGrid.d.ts +11 -0
- package/Unstable_Grid/createGrid.js +174 -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 +269 -0
- package/Unstable_Grid/index.d.ts +5 -0
- package/Unstable_Grid/index.js +65 -0
- package/Unstable_Grid/package.json +6 -0
- package/{grid.js → cssGrid.js} +0 -0
- package/cssVars/useCurrentColorScheme.js +1 -1
- package/esm/Unstable_Grid/Grid.js +179 -0
- package/esm/Unstable_Grid/GridProps.js +1 -0
- package/esm/Unstable_Grid/createGrid.js +152 -0
- package/esm/Unstable_Grid/gridClasses.js +14 -0
- package/esm/Unstable_Grid/gridGenerator.js +230 -0
- package/esm/Unstable_Grid/index.js +5 -0
- 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 +179 -0
- package/legacy/Unstable_Grid/GridProps.js +1 -0
- package/legacy/Unstable_Grid/createGrid.js +166 -0
- package/legacy/Unstable_Grid/gridClasses.js +27 -0
- package/legacy/Unstable_Grid/gridGenerator.js +239 -0
- package/legacy/Unstable_Grid/index.js +5 -0
- 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 +179 -0
- package/modern/Unstable_Grid/GridProps.js +1 -0
- package/modern/Unstable_Grid/createGrid.js +150 -0
- package/modern/Unstable_Grid/gridClasses.js +14 -0
- package/modern/Unstable_Grid/gridGenerator.js +226 -0
- package/modern/Unstable_Grid/index.js +5 -0
- 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 +4 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import createGrid from './createGrid';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Demos:
|
|
6
|
+
*
|
|
7
|
+
* - [Grid (Material UI)](https://mui.com/material-ui/react-grid/)
|
|
8
|
+
*
|
|
9
|
+
* API:
|
|
10
|
+
*
|
|
11
|
+
* - [Grid API](https://mui.com/system/api/grid/)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Grid = createGrid();
|
|
15
|
+
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
16
|
+
/* remove-proptypes */
|
|
17
|
+
= {
|
|
18
|
+
// ----------------------------- Warning --------------------------------
|
|
19
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
20
|
+
// | To update them edit TypeScript types and run "yarn proptypes" |
|
|
21
|
+
// ----------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The content of the component.
|
|
25
|
+
*/
|
|
26
|
+
children: PropTypes.node,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The number of columns.
|
|
30
|
+
* @default 12
|
|
31
|
+
*/
|
|
32
|
+
columns: PropTypes
|
|
33
|
+
/* @typescript-to-proptypes-ignore */
|
|
34
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Defines the horizontal space between the type `item` components.
|
|
38
|
+
* It overrides the value of the `spacing` prop.
|
|
39
|
+
*/
|
|
40
|
+
columnSpacing: PropTypes
|
|
41
|
+
/* @typescript-to-proptypes-ignore */
|
|
42
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If `true`, the component will have the flex *container* behavior.
|
|
46
|
+
* You should be wrapping *items* with a *container*.
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
container: PropTypes.bool,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Defines the `flex-direction` style property.
|
|
53
|
+
* It is applied for all screen sizes.
|
|
54
|
+
* @default 'row'
|
|
55
|
+
*/
|
|
56
|
+
direction: PropTypes
|
|
57
|
+
/* @typescript-to-proptypes-ignore */
|
|
58
|
+
.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
62
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
63
|
+
* If 'auto', the grid item's width matches its content.
|
|
64
|
+
* If false, the prop is ignored.
|
|
65
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
66
|
+
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
73
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
74
|
+
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
|
75
|
+
*/
|
|
76
|
+
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
80
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
81
|
+
* If 'auto', the grid item's width matches its content.
|
|
82
|
+
* If false, the prop is ignored.
|
|
83
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
84
|
+
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
91
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
92
|
+
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
|
93
|
+
*/
|
|
94
|
+
mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Defines the vertical space between the type `item` components.
|
|
98
|
+
* It overrides the value of the `spacing` prop.
|
|
99
|
+
*/
|
|
100
|
+
rowSpacing: PropTypes
|
|
101
|
+
/* @typescript-to-proptypes-ignore */
|
|
102
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
106
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
107
|
+
* If 'auto', the grid item's width matches its content.
|
|
108
|
+
* If false, the prop is ignored.
|
|
109
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
110
|
+
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
117
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
118
|
+
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
|
119
|
+
*/
|
|
120
|
+
smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Defines the space between the type `item` components.
|
|
124
|
+
* It can only be used on a type `container` component.
|
|
125
|
+
* @default 0
|
|
126
|
+
*/
|
|
127
|
+
spacing: PropTypes
|
|
128
|
+
/* @typescript-to-proptypes-ignore */
|
|
129
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @ignore
|
|
133
|
+
*/
|
|
134
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Defines the `flex-wrap` style property.
|
|
138
|
+
* It's applied for all screen sizes.
|
|
139
|
+
* @default 'wrap'
|
|
140
|
+
*/
|
|
141
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
145
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
146
|
+
* If 'auto', the grid item's width matches its content.
|
|
147
|
+
* If false, the prop is ignored.
|
|
148
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
149
|
+
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
156
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
157
|
+
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
|
158
|
+
*/
|
|
159
|
+
xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
163
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
164
|
+
* If 'auto', the grid item's width matches its content.
|
|
165
|
+
* If false, the prop is ignored.
|
|
166
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
167
|
+
* The value is applied for all the screen sizes with the lowest priority.
|
|
168
|
+
* @default false
|
|
169
|
+
*/
|
|
170
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
174
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
175
|
+
* The value is applied for the `xs` breakpoint and wider screens if not overridden.
|
|
176
|
+
*/
|
|
177
|
+
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
178
|
+
} : void 0;
|
|
179
|
+
export default Grid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
8
|
+
import systemStyled from '../styled';
|
|
9
|
+
import useThemePropsSystem from '../useThemeProps';
|
|
10
|
+
import useTheme from '../useTheme';
|
|
11
|
+
import { extendSxProp } from '../styleFunctionSx';
|
|
12
|
+
import createTheme from '../createTheme';
|
|
13
|
+
import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames } from './gridGenerator';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const defaultTheme = createTheme(); // widening Theme to any so that the consumer can own the theme structure.
|
|
16
|
+
|
|
17
|
+
const defaultCreateStyledComponent = systemStyled('div', {
|
|
18
|
+
name: 'MuiGrid',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function useThemePropsDefault(props) {
|
|
24
|
+
return useThemePropsSystem({
|
|
25
|
+
props,
|
|
26
|
+
name: 'MuiGrid',
|
|
27
|
+
defaultTheme
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function createGrid(options = {}) {
|
|
32
|
+
const {
|
|
33
|
+
// This will allow adding custom styled fn (for example for custom sx style function)
|
|
34
|
+
createStyledComponent = defaultCreateStyledComponent,
|
|
35
|
+
useThemeProps = useThemePropsDefault,
|
|
36
|
+
componentName = 'MuiGrid'
|
|
37
|
+
} = options;
|
|
38
|
+
const NestedContext = /*#__PURE__*/React.createContext(false);
|
|
39
|
+
|
|
40
|
+
const useUtilityClasses = (ownerState, theme) => {
|
|
41
|
+
const {
|
|
42
|
+
container,
|
|
43
|
+
direction,
|
|
44
|
+
spacing,
|
|
45
|
+
wrap,
|
|
46
|
+
gridSize
|
|
47
|
+
} = ownerState;
|
|
48
|
+
const slots = {
|
|
49
|
+
root: ['root', container && 'container', direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
|
|
50
|
+
};
|
|
51
|
+
return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
|
|
55
|
+
const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
const themeProps = useThemeProps(inProps);
|
|
58
|
+
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
59
|
+
|
|
60
|
+
const nested = React.useContext(NestedContext);
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
className,
|
|
64
|
+
columns: columnsProp = 12,
|
|
65
|
+
container = false,
|
|
66
|
+
component = 'div',
|
|
67
|
+
direction = 'row',
|
|
68
|
+
wrap = 'wrap',
|
|
69
|
+
spacing: spacingProp = 0,
|
|
70
|
+
rowSpacing: rowSpacingProp = spacingProp,
|
|
71
|
+
columnSpacing: columnSpacingProp = spacingProp
|
|
72
|
+
} = props,
|
|
73
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded); // collect breakpoints related props because they can be custom from the theme.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const gridSize = {};
|
|
77
|
+
const gridOffset = {};
|
|
78
|
+
const other = {};
|
|
79
|
+
Object.entries(rest).forEach(([key, val]) => {
|
|
80
|
+
if (theme.breakpoints.values[key] !== undefined) {
|
|
81
|
+
gridSize[key] = val;
|
|
82
|
+
} else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
|
|
83
|
+
gridOffset[key.replace('Offset', '')] = val;
|
|
84
|
+
} else {
|
|
85
|
+
other[key] = val;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const columns = inProps.columns ?? (nested ? undefined : columnsProp);
|
|
89
|
+
const spacing = inProps.spacing ?? (nested ? undefined : spacingProp);
|
|
90
|
+
const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (nested ? undefined : rowSpacingProp);
|
|
91
|
+
const columnSpacing = inProps.columnSpacing ?? inProps.spacing ?? (nested ? undefined : columnSpacingProp);
|
|
92
|
+
|
|
93
|
+
const ownerState = _extends({}, props, {
|
|
94
|
+
nested,
|
|
95
|
+
columns,
|
|
96
|
+
container,
|
|
97
|
+
direction,
|
|
98
|
+
wrap,
|
|
99
|
+
spacing,
|
|
100
|
+
rowSpacing,
|
|
101
|
+
columnSpacing,
|
|
102
|
+
gridSize,
|
|
103
|
+
gridOffset
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const classes = useUtilityClasses(ownerState, theme);
|
|
107
|
+
|
|
108
|
+
let result = /*#__PURE__*/_jsx(GridRoot, _extends({
|
|
109
|
+
ref: ref,
|
|
110
|
+
as: component,
|
|
111
|
+
ownerState: ownerState,
|
|
112
|
+
className: clsx(classes.root, className)
|
|
113
|
+
}, other));
|
|
114
|
+
|
|
115
|
+
if (!nested) {
|
|
116
|
+
result = /*#__PURE__*/_jsx(NestedContext.Provider, {
|
|
117
|
+
value: true,
|
|
118
|
+
children: result
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return result;
|
|
123
|
+
});
|
|
124
|
+
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
125
|
+
/* remove-proptypes */
|
|
126
|
+
= {
|
|
127
|
+
children: PropTypes.node,
|
|
128
|
+
className: PropTypes.string,
|
|
129
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
130
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
131
|
+
component: PropTypes.elementType,
|
|
132
|
+
container: PropTypes.bool,
|
|
133
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
134
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
135
|
+
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
136
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
137
|
+
mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
138
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
139
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
140
|
+
smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
141
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
142
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
143
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
144
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
145
|
+
xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
146
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
147
|
+
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
148
|
+
} : void 0;
|
|
149
|
+
return Grid;
|
|
150
|
+
}
|
|
@@ -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,226 @@
|
|
|
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.nested ? {
|
|
185
|
+
padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
|
|
186
|
+
} : {
|
|
187
|
+
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
188
|
+
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
189
|
+
}) : {
|
|
190
|
+
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
export const generateSizeClassNames = gridSize => {
|
|
194
|
+
const classNames = [];
|
|
195
|
+
Object.entries(gridSize).forEach(([key, value]) => {
|
|
196
|
+
if (value !== false && value !== undefined) {
|
|
197
|
+
classNames.push(`grid-${key}-${String(value)}`);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return classNames;
|
|
201
|
+
};
|
|
202
|
+
export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') => {
|
|
203
|
+
function isValidSpacing(val) {
|
|
204
|
+
if (val === undefined) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (isValidSpacing(spacing)) {
|
|
212
|
+
return [`spacing-${smallestBreakpoint}-${String(spacing)}`];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (typeof spacing === 'object' && !Array.isArray(spacing)) {
|
|
216
|
+
const classNames = [];
|
|
217
|
+
Object.entries(spacing).forEach(([key, value]) => {
|
|
218
|
+
if (isValidSpacing(value)) {
|
|
219
|
+
classNames.push(`spacing-${key}-${String(value)}`);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return classNames;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return [];
|
|
226
|
+
};
|
|
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.0
|
|
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.0",
|
|
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.0",
|
|
48
48
|
"@mui/styled-engine": "^5.8.7",
|
|
49
49
|
"@mui/types": "^7.1.4",
|
|
50
|
-
"@mui/utils": "^5.
|
|
51
|
-
"clsx": "^1.2.
|
|
50
|
+
"@mui/utils": "^5.9.0",
|
|
51
|
+
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.0",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|