@mui/system 5.8.6 → 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/CHANGELOG.md +185 -0
- 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/createCssVarsProvider.d.ts +13 -18
- package/cssVars/createCssVarsProvider.js +11 -16
- package/cssVars/createGetCssVar.d.ts +1 -1
- package/cssVars/createGetCssVar.js +2 -2
- package/cssVars/cssVarsParser.d.ts +4 -9
- package/cssVars/cssVarsParser.js +4 -19
- package/cssVars/index.d.ts +2 -1
- package/cssVars/index.js +9 -1
- 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/createCssVarsProvider.js +11 -15
- package/esm/cssVars/createGetCssVar.js +2 -2
- package/esm/cssVars/cssVarsParser.js +4 -19
- package/esm/cssVars/index.js +2 -1
- 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/createCssVarsProvider.js +11 -16
- package/legacy/cssVars/createGetCssVar.js +3 -3
- package/legacy/cssVars/cssVarsParser.js +4 -20
- package/legacy/cssVars/index.js +2 -1
- 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/createCssVarsProvider.js +11 -15
- package/modern/cssVars/createGetCssVar.js +2 -2
- package/modern/cssVars/cssVarsParser.js +4 -19
- package/modern/cssVars/index.js +2 -1
- 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,184 @@
|
|
|
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
|
+
var 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 `true`, the negative margin and padding are apply only to the top and left sides of the grid.
|
|
62
|
+
*/
|
|
63
|
+
disableEqualOverflow: PropTypes.bool,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
67
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
68
|
+
* If 'auto', the grid item's width matches its content.
|
|
69
|
+
* If false, the prop is ignored.
|
|
70
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
71
|
+
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
78
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
79
|
+
* The value is applied for the `lg` breakpoint and wider screens if not overridden.
|
|
80
|
+
*/
|
|
81
|
+
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
85
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
86
|
+
* If 'auto', the grid item's width matches its content.
|
|
87
|
+
* If false, the prop is ignored.
|
|
88
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
89
|
+
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
96
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
97
|
+
* The value is applied for the `md` breakpoint and wider screens if not overridden.
|
|
98
|
+
*/
|
|
99
|
+
mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Defines the vertical space between the type `item` components.
|
|
103
|
+
* It overrides the value of the `spacing` prop.
|
|
104
|
+
*/
|
|
105
|
+
rowSpacing: PropTypes
|
|
106
|
+
/* @typescript-to-proptypes-ignore */
|
|
107
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
111
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
112
|
+
* If 'auto', the grid item's width matches its content.
|
|
113
|
+
* If false, the prop is ignored.
|
|
114
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
115
|
+
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
122
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
123
|
+
* The value is applied for the `sm` breakpoint and wider screens if not overridden.
|
|
124
|
+
*/
|
|
125
|
+
smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Defines the space between the type `item` components.
|
|
129
|
+
* It can only be used on a type `container` component.
|
|
130
|
+
* @default 0
|
|
131
|
+
*/
|
|
132
|
+
spacing: PropTypes
|
|
133
|
+
/* @typescript-to-proptypes-ignore */
|
|
134
|
+
.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @ignore
|
|
138
|
+
*/
|
|
139
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Defines the `flex-wrap` style property.
|
|
143
|
+
* It's applied for all screen sizes.
|
|
144
|
+
* @default 'wrap'
|
|
145
|
+
*/
|
|
146
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
150
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
151
|
+
* If 'auto', the grid item's width matches its content.
|
|
152
|
+
* If false, the prop is ignored.
|
|
153
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
154
|
+
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
161
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
162
|
+
* The value is applied for the `xl` breakpoint and wider screens if not overridden.
|
|
163
|
+
*/
|
|
164
|
+
xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* If a number, it sets the number of columns the grid item uses.
|
|
168
|
+
* It can't be greater than the total number of columns of the container (12 by default).
|
|
169
|
+
* If 'auto', the grid item's width matches its content.
|
|
170
|
+
* If false, the prop is ignored.
|
|
171
|
+
* If true, the grid item's width grows to use the space available in the grid container.
|
|
172
|
+
* The value is applied for all the screen sizes with the lowest priority.
|
|
173
|
+
* @default false
|
|
174
|
+
*/
|
|
175
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* If a number, it sets the margin-left equals to the number of columns the grid item uses.
|
|
179
|
+
* If 'auto', the grid item push itself to the right-end of the container.
|
|
180
|
+
* The value is applied for the `xs` breakpoint and wider screens if not overridden.
|
|
181
|
+
*/
|
|
182
|
+
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
183
|
+
} : void 0;
|
|
184
|
+
export default Grid;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
9
|
+
import systemStyled from '../styled';
|
|
10
|
+
import useThemePropsSystem from '../useThemeProps';
|
|
11
|
+
import useTheme from '../useTheme';
|
|
12
|
+
import { extendSxProp } from '../styleFunctionSx';
|
|
13
|
+
import createTheme from '../createTheme';
|
|
14
|
+
import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames } from './gridGenerator';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
var defaultTheme = createTheme(); // widening Theme to any so that the consumer can own the theme structure.
|
|
17
|
+
|
|
18
|
+
var defaultCreateStyledComponent = systemStyled('div', {
|
|
19
|
+
name: 'MuiGrid',
|
|
20
|
+
slot: 'Root',
|
|
21
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
22
|
+
return styles.root;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function useThemePropsDefault(props) {
|
|
27
|
+
return useThemePropsSystem({
|
|
28
|
+
props: props,
|
|
29
|
+
name: 'MuiGrid',
|
|
30
|
+
defaultTheme: defaultTheme
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function createGrid() {
|
|
35
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
+
var _options$createStyled = options.createStyledComponent,
|
|
37
|
+
createStyledComponent = _options$createStyled === void 0 ? defaultCreateStyledComponent : _options$createStyled,
|
|
38
|
+
_options$useThemeProp = options.useThemeProps,
|
|
39
|
+
useThemeProps = _options$useThemeProp === void 0 ? useThemePropsDefault : _options$useThemeProp,
|
|
40
|
+
_options$componentNam = options.componentName,
|
|
41
|
+
componentName = _options$componentNam === void 0 ? 'MuiGrid' : _options$componentNam;
|
|
42
|
+
var NestedContext = /*#__PURE__*/React.createContext(false);
|
|
43
|
+
var OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
44
|
+
|
|
45
|
+
var useUtilityClasses = function useUtilityClasses(ownerState, theme) {
|
|
46
|
+
var container = ownerState.container,
|
|
47
|
+
direction = ownerState.direction,
|
|
48
|
+
spacing = ownerState.spacing,
|
|
49
|
+
wrap = ownerState.wrap,
|
|
50
|
+
gridSize = ownerState.gridSize;
|
|
51
|
+
var slots = {
|
|
52
|
+
root: ['root', container && 'container', direction !== 'row' && "direction-xs-".concat(String(direction)), wrap !== 'wrap' && "wrap-xs-".concat(String(wrap))].concat(_toConsumableArray(generateSizeClassNames(gridSize)), _toConsumableArray(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : []))
|
|
53
|
+
};
|
|
54
|
+
return composeClasses(slots, function (slot) {
|
|
55
|
+
return generateUtilityClass(componentName, slot);
|
|
56
|
+
}, {});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
|
|
60
|
+
var Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
61
|
+
var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin, _ref5, _disableEqualOverflow;
|
|
62
|
+
|
|
63
|
+
var theme = useTheme();
|
|
64
|
+
var themeProps = useThemeProps(inProps);
|
|
65
|
+
var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
66
|
+
|
|
67
|
+
var nested = React.useContext(NestedContext);
|
|
68
|
+
var overflow = React.useContext(OverflowContext);
|
|
69
|
+
|
|
70
|
+
var className = props.className,
|
|
71
|
+
_props$columns = props.columns,
|
|
72
|
+
columnsProp = _props$columns === void 0 ? 12 : _props$columns,
|
|
73
|
+
_props$container = props.container,
|
|
74
|
+
container = _props$container === void 0 ? false : _props$container,
|
|
75
|
+
_props$component = props.component,
|
|
76
|
+
component = _props$component === void 0 ? 'div' : _props$component,
|
|
77
|
+
_props$direction = props.direction,
|
|
78
|
+
direction = _props$direction === void 0 ? 'row' : _props$direction,
|
|
79
|
+
_props$wrap = props.wrap,
|
|
80
|
+
wrap = _props$wrap === void 0 ? 'wrap' : _props$wrap,
|
|
81
|
+
_props$spacing = props.spacing,
|
|
82
|
+
spacingProp = _props$spacing === void 0 ? 0 : _props$spacing,
|
|
83
|
+
_props$rowSpacing = props.rowSpacing,
|
|
84
|
+
rowSpacingProp = _props$rowSpacing === void 0 ? spacingProp : _props$rowSpacing,
|
|
85
|
+
_props$columnSpacing = props.columnSpacing,
|
|
86
|
+
columnSpacingProp = _props$columnSpacing === void 0 ? spacingProp : _props$columnSpacing,
|
|
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.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
var gridSize = {};
|
|
99
|
+
var gridOffset = {};
|
|
100
|
+
var other = {};
|
|
101
|
+
Object.entries(rest).forEach(function (_ref) {
|
|
102
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
103
|
+
key = _ref2[0],
|
|
104
|
+
val = _ref2[1];
|
|
105
|
+
|
|
106
|
+
if (theme.breakpoints.values[key] !== undefined) {
|
|
107
|
+
gridSize[key] = val;
|
|
108
|
+
} else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
|
|
109
|
+
gridOffset[key.replace('Offset', '')] = val;
|
|
110
|
+
} else {
|
|
111
|
+
other[key] = val;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : nested ? undefined : columnsProp;
|
|
115
|
+
var spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : nested ? undefined : spacingProp;
|
|
116
|
+
var rowSpacing = (_ref3 = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref3 : nested ? undefined : rowSpacingProp;
|
|
117
|
+
var columnSpacing = (_ref4 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref4 : nested ? undefined : columnSpacingProp;
|
|
118
|
+
|
|
119
|
+
var ownerState = _extends({}, props, {
|
|
120
|
+
nested: nested,
|
|
121
|
+
columns: columns,
|
|
122
|
+
container: container,
|
|
123
|
+
direction: direction,
|
|
124
|
+
wrap: wrap,
|
|
125
|
+
spacing: spacing,
|
|
126
|
+
rowSpacing: rowSpacing,
|
|
127
|
+
columnSpacing: columnSpacing,
|
|
128
|
+
gridSize: gridSize,
|
|
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
|
+
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
var classes = useUtilityClasses(ownerState, theme);
|
|
137
|
+
|
|
138
|
+
var result = /*#__PURE__*/_jsx(GridRoot, _extends({
|
|
139
|
+
ref: ref,
|
|
140
|
+
as: component,
|
|
141
|
+
ownerState: ownerState,
|
|
142
|
+
className: clsx(classes.root, className)
|
|
143
|
+
}, other));
|
|
144
|
+
|
|
145
|
+
if (!nested) {
|
|
146
|
+
result = /*#__PURE__*/_jsx(NestedContext.Provider, {
|
|
147
|
+
value: true,
|
|
148
|
+
children: result
|
|
149
|
+
});
|
|
150
|
+
}
|
|
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
|
+
|
|
162
|
+
return result;
|
|
163
|
+
});
|
|
164
|
+
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
165
|
+
/* remove-proptypes */
|
|
166
|
+
= {
|
|
167
|
+
children: PropTypes.node,
|
|
168
|
+
className: PropTypes.string,
|
|
169
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
170
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
171
|
+
component: PropTypes.elementType,
|
|
172
|
+
container: PropTypes.bool,
|
|
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,
|
|
175
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
176
|
+
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
177
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
178
|
+
mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
179
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
180
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
181
|
+
smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
182
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
183
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
184
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
185
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
186
|
+
xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
187
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
188
|
+
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
189
|
+
} : void 0;
|
|
190
|
+
return Grid;
|
|
191
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
3
|
+
export function getGridUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiGrid', slot);
|
|
5
|
+
}
|
|
6
|
+
var SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
7
|
+
var DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
|
|
8
|
+
var WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
|
|
9
|
+
var GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
10
|
+
var gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container', 'item'].concat(_toConsumableArray(SPACINGS.map(function (spacing) {
|
|
11
|
+
return "spacing-xs-".concat(spacing);
|
|
12
|
+
})), _toConsumableArray(DIRECTIONS.map(function (direction) {
|
|
13
|
+
return "direction-xs-".concat(direction);
|
|
14
|
+
})), _toConsumableArray(WRAPS.map(function (wrap) {
|
|
15
|
+
return "wrap-xs-".concat(wrap);
|
|
16
|
+
})), _toConsumableArray(GRID_SIZES.map(function (size) {
|
|
17
|
+
return "grid-xs-".concat(size);
|
|
18
|
+
})), _toConsumableArray(GRID_SIZES.map(function (size) {
|
|
19
|
+
return "grid-sm-".concat(size);
|
|
20
|
+
})), _toConsumableArray(GRID_SIZES.map(function (size) {
|
|
21
|
+
return "grid-md-".concat(size);
|
|
22
|
+
})), _toConsumableArray(GRID_SIZES.map(function (size) {
|
|
23
|
+
return "grid-lg-".concat(size);
|
|
24
|
+
})), _toConsumableArray(GRID_SIZES.map(function (size) {
|
|
25
|
+
return "grid-xl-".concat(size);
|
|
26
|
+
}))));
|
|
27
|
+
export default gridClasses;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
export var traverseBreakpoints = function traverseBreakpoints(breakpoints, responsize, iterator) {
|
|
5
|
+
var smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
|
|
6
|
+
|
|
7
|
+
if (Array.isArray(responsize)) {
|
|
8
|
+
responsize.forEach(function (breakpointValue, index) {
|
|
9
|
+
iterator(function (responsizeStyles, style) {
|
|
10
|
+
if (index <= breakpoints.keys.length - 1) {
|
|
11
|
+
if (index === 0) {
|
|
12
|
+
_extends(responsizeStyles, style);
|
|
13
|
+
} else {
|
|
14
|
+
responsizeStyles[breakpoints.up(breakpoints.keys[index])] = style;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}, breakpointValue);
|
|
18
|
+
});
|
|
19
|
+
} else if (responsize && _typeof(responsize) === 'object') {
|
|
20
|
+
// prevent null
|
|
21
|
+
// responsize could be a very big object, pick the smallest responsive values
|
|
22
|
+
var keys = Object.keys(responsize).length > breakpoints.keys.length ? breakpoints.keys : Object.keys(responsize);
|
|
23
|
+
keys.forEach(function (key) {
|
|
24
|
+
if (breakpoints.keys.indexOf(key) !== -1) {
|
|
25
|
+
// @ts-ignore already checked that responsize is an object
|
|
26
|
+
var breakpointValue = responsize[key];
|
|
27
|
+
|
|
28
|
+
if (breakpointValue !== undefined) {
|
|
29
|
+
iterator(function (responsizeStyles, style) {
|
|
30
|
+
if (smallestBreakpoint === key) {
|
|
31
|
+
_extends(responsizeStyles, style);
|
|
32
|
+
} else {
|
|
33
|
+
responsizeStyles[breakpoints.up(key)] = style;
|
|
34
|
+
}
|
|
35
|
+
}, breakpointValue);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} else if (typeof responsize === 'number' || typeof responsize === 'string') {
|
|
40
|
+
iterator(function (responsizeStyles, style) {
|
|
41
|
+
_extends(responsizeStyles, style);
|
|
42
|
+
}, responsize);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export var generateGridSizeStyles = function generateGridSizeStyles(_ref) {
|
|
46
|
+
var theme = _ref.theme,
|
|
47
|
+
ownerState = _ref.ownerState;
|
|
48
|
+
var styles = {};
|
|
49
|
+
traverseBreakpoints(theme.breakpoints, ownerState.gridSize, function (appendStyle, value) {
|
|
50
|
+
var style = {};
|
|
51
|
+
|
|
52
|
+
if (value === true) {
|
|
53
|
+
style = {
|
|
54
|
+
flexBasis: 0,
|
|
55
|
+
flexGrow: 1,
|
|
56
|
+
maxWidth: '100%'
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (value === 'auto') {
|
|
61
|
+
style = {
|
|
62
|
+
flexBasis: 'auto',
|
|
63
|
+
flexGrow: 0,
|
|
64
|
+
flexShrink: 0,
|
|
65
|
+
maxWidth: 'none',
|
|
66
|
+
width: 'auto'
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (typeof value === 'number') {
|
|
71
|
+
style = {
|
|
72
|
+
flexGrow: 0,
|
|
73
|
+
flexBasis: 'auto',
|
|
74
|
+
width: "calc(100% * ".concat(value, " / var(--Grid-columns)").concat(ownerState.nested && ownerState.container ? " + var(--Grid-columnSpacing)" : '', ")")
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
appendStyle(styles, style);
|
|
79
|
+
});
|
|
80
|
+
return styles;
|
|
81
|
+
};
|
|
82
|
+
export var generateGridOffsetStyles = function generateGridOffsetStyles(_ref2) {
|
|
83
|
+
var theme = _ref2.theme,
|
|
84
|
+
ownerState = _ref2.ownerState;
|
|
85
|
+
var styles = {};
|
|
86
|
+
traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, function (appendStyle, value) {
|
|
87
|
+
var 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% * ".concat(value, " / var(--Grid-columns))")
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
appendStyle(styles, style);
|
|
102
|
+
});
|
|
103
|
+
return styles;
|
|
104
|
+
};
|
|
105
|
+
export var generateGridColumnsStyles = function generateGridColumnsStyles(_ref3) {
|
|
106
|
+
var theme = _ref3.theme,
|
|
107
|
+
ownerState = _ref3.ownerState;
|
|
108
|
+
|
|
109
|
+
if (!ownerState.container) {
|
|
110
|
+
return {};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var styles = {
|
|
114
|
+
'--Grid-columns': 12
|
|
115
|
+
};
|
|
116
|
+
traverseBreakpoints(theme.breakpoints, ownerState.columns, function (appendStyle, value) {
|
|
117
|
+
appendStyle(styles, {
|
|
118
|
+
'--Grid-columns': value
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return styles;
|
|
122
|
+
};
|
|
123
|
+
export var generateGridRowSpacingStyles = function generateGridRowSpacingStyles(_ref4) {
|
|
124
|
+
var theme = _ref4.theme,
|
|
125
|
+
ownerState = _ref4.ownerState;
|
|
126
|
+
|
|
127
|
+
if (!ownerState.container) {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var styles = {};
|
|
132
|
+
traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, function (appendStyle, value) {
|
|
133
|
+
var _theme$spacing;
|
|
134
|
+
|
|
135
|
+
appendStyle(styles, {
|
|
136
|
+
'--Grid-rowSpacing': typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return styles;
|
|
140
|
+
};
|
|
141
|
+
export var generateGridColumnSpacingStyles = function generateGridColumnSpacingStyles(_ref5) {
|
|
142
|
+
var theme = _ref5.theme,
|
|
143
|
+
ownerState = _ref5.ownerState;
|
|
144
|
+
|
|
145
|
+
if (!ownerState.container) {
|
|
146
|
+
return {};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var styles = {};
|
|
150
|
+
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, function (appendStyle, value) {
|
|
151
|
+
var _theme$spacing2;
|
|
152
|
+
|
|
153
|
+
appendStyle(styles, {
|
|
154
|
+
'--Grid-columnSpacing': typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
return styles;
|
|
158
|
+
};
|
|
159
|
+
export var generateGridDirectionStyles = function generateGridDirectionStyles(_ref6) {
|
|
160
|
+
var theme = _ref6.theme,
|
|
161
|
+
ownerState = _ref6.ownerState;
|
|
162
|
+
|
|
163
|
+
if (!ownerState.container) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
var styles = {};
|
|
168
|
+
traverseBreakpoints(theme.breakpoints, ownerState.direction, function (appendStyle, value) {
|
|
169
|
+
appendStyle(styles, {
|
|
170
|
+
flexDirection: value
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return styles;
|
|
174
|
+
};
|
|
175
|
+
export var generateGridStyles = function generateGridStyles(_ref7) {
|
|
176
|
+
var ownerState = _ref7.ownerState;
|
|
177
|
+
return _extends({
|
|
178
|
+
minWidth: 0,
|
|
179
|
+
boxSizing: 'border-box'
|
|
180
|
+
}, ownerState.container ? _extends({
|
|
181
|
+
display: 'flex',
|
|
182
|
+
flexWrap: 'wrap'
|
|
183
|
+
}, ownerState.wrap && ownerState.wrap !== 'wrap' && {
|
|
184
|
+
flexWrap: ownerState.wrap
|
|
185
|
+
}, {
|
|
186
|
+
margin: "calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)"
|
|
187
|
+
}, ownerState.disableEqualOverflow && {
|
|
188
|
+
margin: "calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)"
|
|
189
|
+
}, ownerState.nested ? _extends({
|
|
190
|
+
padding: "calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)"
|
|
191
|
+
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
192
|
+
padding: "calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))"
|
|
193
|
+
}) : {
|
|
194
|
+
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
195
|
+
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
196
|
+
}) : _extends({
|
|
197
|
+
padding: "calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)"
|
|
198
|
+
}, ownerState.disableEqualOverflow && {
|
|
199
|
+
padding: "calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))"
|
|
200
|
+
}));
|
|
201
|
+
};
|
|
202
|
+
export var generateSizeClassNames = function generateSizeClassNames(gridSize) {
|
|
203
|
+
var classNames = [];
|
|
204
|
+
Object.entries(gridSize).forEach(function (_ref8) {
|
|
205
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
206
|
+
key = _ref9[0],
|
|
207
|
+
value = _ref9[1];
|
|
208
|
+
|
|
209
|
+
if (value !== false && value !== undefined) {
|
|
210
|
+
classNames.push("grid-".concat(key, "-").concat(String(value)));
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return classNames;
|
|
214
|
+
};
|
|
215
|
+
export var generateSpacingClassNames = function generateSpacingClassNames(spacing) {
|
|
216
|
+
var smallestBreakpoint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'xs';
|
|
217
|
+
|
|
218
|
+
function isValidSpacing(val) {
|
|
219
|
+
if (val === undefined) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (isValidSpacing(spacing)) {
|
|
227
|
+
return ["spacing-".concat(smallestBreakpoint, "-").concat(String(spacing))];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (_typeof(spacing) === 'object' && !Array.isArray(spacing)) {
|
|
231
|
+
var classNames = [];
|
|
232
|
+
Object.entries(spacing).forEach(function (_ref10) {
|
|
233
|
+
var _ref11 = _slicedToArray(_ref10, 2),
|
|
234
|
+
key = _ref11[0],
|
|
235
|
+
value = _ref11[1];
|
|
236
|
+
|
|
237
|
+
if (isValidSpacing(value)) {
|
|
238
|
+
classNames.push("spacing-".concat(key, "-").concat(String(value)));
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return classNames;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return [];
|
|
245
|
+
};
|
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;
|
|
File without changes
|