@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/Unstable_Grid/Grid.d.ts +12 -0
  3. package/Unstable_Grid/Grid.js +190 -0
  4. package/Unstable_Grid/GridProps.d.ts +158 -0
  5. package/Unstable_Grid/GridProps.js +5 -0
  6. package/Unstable_Grid/createGrid.d.ts +11 -0
  7. package/Unstable_Grid/createGrid.js +174 -0
  8. package/Unstable_Grid/gridClasses.d.ts +20 -0
  9. package/Unstable_Grid/gridClasses.js +25 -0
  10. package/Unstable_Grid/gridGenerator.d.ts +26 -0
  11. package/Unstable_Grid/gridGenerator.js +269 -0
  12. package/Unstable_Grid/index.d.ts +5 -0
  13. package/Unstable_Grid/index.js +65 -0
  14. package/Unstable_Grid/package.json +6 -0
  15. package/{grid.js → cssGrid.js} +0 -0
  16. package/cssVars/useCurrentColorScheme.js +1 -1
  17. package/esm/Unstable_Grid/Grid.js +179 -0
  18. package/esm/Unstable_Grid/GridProps.js +1 -0
  19. package/esm/Unstable_Grid/createGrid.js +152 -0
  20. package/esm/Unstable_Grid/gridClasses.js +14 -0
  21. package/esm/Unstable_Grid/gridGenerator.js +230 -0
  22. package/esm/Unstable_Grid/index.js +5 -0
  23. package/esm/{grid.js → cssGrid.js} +0 -0
  24. package/esm/cssVars/useCurrentColorScheme.js +1 -1
  25. package/esm/getThemeValue.js +1 -1
  26. package/esm/index.js +9 -3
  27. package/getThemeValue.js +3 -3
  28. package/index.d.ts +3 -0
  29. package/index.js +30 -7
  30. package/legacy/Unstable_Grid/Grid.js +179 -0
  31. package/legacy/Unstable_Grid/GridProps.js +1 -0
  32. package/legacy/Unstable_Grid/createGrid.js +166 -0
  33. package/legacy/Unstable_Grid/gridClasses.js +27 -0
  34. package/legacy/Unstable_Grid/gridGenerator.js +239 -0
  35. package/legacy/Unstable_Grid/index.js +5 -0
  36. package/legacy/{grid.js → cssGrid.js} +0 -0
  37. package/legacy/cssVars/useCurrentColorScheme.js +1 -1
  38. package/legacy/getThemeValue.js +1 -1
  39. package/legacy/index.js +10 -4
  40. package/modern/Unstable_Grid/Grid.js +179 -0
  41. package/modern/Unstable_Grid/GridProps.js +1 -0
  42. package/modern/Unstable_Grid/createGrid.js +150 -0
  43. package/modern/Unstable_Grid/gridClasses.js +14 -0
  44. package/modern/Unstable_Grid/gridGenerator.js +226 -0
  45. package/modern/Unstable_Grid/index.js +5 -0
  46. package/modern/{grid.js → cssGrid.js} +0 -0
  47. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  48. package/modern/getThemeValue.js +1 -1
  49. package/modern/index.js +10 -4
  50. 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
+ 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 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,166 @@
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
+
44
+ var useUtilityClasses = function useUtilityClasses(ownerState, theme) {
45
+ var container = ownerState.container,
46
+ direction = ownerState.direction,
47
+ spacing = ownerState.spacing,
48
+ wrap = ownerState.wrap,
49
+ gridSize = ownerState.gridSize;
50
+ var slots = {
51
+ 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]) : []))
52
+ };
53
+ return composeClasses(slots, function (slot) {
54
+ return generateUtilityClass(componentName, slot);
55
+ }, {});
56
+ };
57
+
58
+ var GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
59
+ var Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
60
+ var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin;
61
+
62
+ var theme = useTheme();
63
+ var themeProps = useThemeProps(inProps);
64
+ var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
65
+
66
+ var nested = React.useContext(NestedContext);
67
+
68
+ var className = props.className,
69
+ _props$columns = props.columns,
70
+ columnsProp = _props$columns === void 0 ? 12 : _props$columns,
71
+ _props$container = props.container,
72
+ container = _props$container === void 0 ? false : _props$container,
73
+ _props$component = props.component,
74
+ component = _props$component === void 0 ? 'div' : _props$component,
75
+ _props$direction = props.direction,
76
+ direction = _props$direction === void 0 ? 'row' : _props$direction,
77
+ _props$wrap = props.wrap,
78
+ wrap = _props$wrap === void 0 ? 'wrap' : _props$wrap,
79
+ _props$spacing = props.spacing,
80
+ spacingProp = _props$spacing === void 0 ? 0 : _props$spacing,
81
+ _props$rowSpacing = props.rowSpacing,
82
+ rowSpacingProp = _props$rowSpacing === void 0 ? spacingProp : _props$rowSpacing,
83
+ _props$columnSpacing = props.columnSpacing,
84
+ columnSpacingProp = _props$columnSpacing === void 0 ? spacingProp : _props$columnSpacing,
85
+ rest = _objectWithoutProperties(props, ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"]); // collect breakpoints related props because they can be custom from the theme.
86
+
87
+
88
+ var gridSize = {};
89
+ var gridOffset = {};
90
+ var other = {};
91
+ Object.entries(rest).forEach(function (_ref) {
92
+ var _ref2 = _slicedToArray(_ref, 2),
93
+ key = _ref2[0],
94
+ val = _ref2[1];
95
+
96
+ if (theme.breakpoints.values[key] !== undefined) {
97
+ gridSize[key] = val;
98
+ } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
99
+ gridOffset[key.replace('Offset', '')] = val;
100
+ } else {
101
+ other[key] = val;
102
+ }
103
+ });
104
+ var columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : nested ? undefined : columnsProp;
105
+ var spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : nested ? undefined : spacingProp;
106
+ var rowSpacing = (_ref3 = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref3 : nested ? undefined : rowSpacingProp;
107
+ var columnSpacing = (_ref4 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref4 : nested ? undefined : columnSpacingProp;
108
+
109
+ var ownerState = _extends({}, props, {
110
+ nested: nested,
111
+ columns: columns,
112
+ container: container,
113
+ direction: direction,
114
+ wrap: wrap,
115
+ spacing: spacing,
116
+ rowSpacing: rowSpacing,
117
+ columnSpacing: columnSpacing,
118
+ gridSize: gridSize,
119
+ gridOffset: gridOffset
120
+ });
121
+
122
+ var classes = useUtilityClasses(ownerState, theme);
123
+
124
+ var result = /*#__PURE__*/_jsx(GridRoot, _extends({
125
+ ref: ref,
126
+ as: component,
127
+ ownerState: ownerState,
128
+ className: clsx(classes.root, className)
129
+ }, other));
130
+
131
+ if (!nested) {
132
+ result = /*#__PURE__*/_jsx(NestedContext.Provider, {
133
+ value: true,
134
+ children: result
135
+ });
136
+ }
137
+
138
+ return result;
139
+ });
140
+ process.env.NODE_ENV !== "production" ? Grid.propTypes
141
+ /* remove-proptypes */
142
+ = {
143
+ children: PropTypes.node,
144
+ className: PropTypes.string,
145
+ columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
146
+ columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
147
+ component: PropTypes.elementType,
148
+ container: PropTypes.bool,
149
+ direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
150
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
151
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
152
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
153
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
154
+ rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
155
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
156
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
157
+ spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
158
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
159
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
160
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
161
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
162
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
163
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
164
+ } : void 0;
165
+ return Grid;
166
+ }
@@ -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,239 @@
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.nested ? {
188
+ padding: "calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)"
189
+ } : {
190
+ '--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
191
+ '--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
192
+ }) : {
193
+ padding: "calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)"
194
+ });
195
+ };
196
+ export var generateSizeClassNames = function generateSizeClassNames(gridSize) {
197
+ var classNames = [];
198
+ Object.entries(gridSize).forEach(function (_ref8) {
199
+ var _ref9 = _slicedToArray(_ref8, 2),
200
+ key = _ref9[0],
201
+ value = _ref9[1];
202
+
203
+ if (value !== false && value !== undefined) {
204
+ classNames.push("grid-".concat(key, "-").concat(String(value)));
205
+ }
206
+ });
207
+ return classNames;
208
+ };
209
+ export var generateSpacingClassNames = function generateSpacingClassNames(spacing) {
210
+ var smallestBreakpoint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'xs';
211
+
212
+ function isValidSpacing(val) {
213
+ if (val === undefined) {
214
+ return false;
215
+ }
216
+
217
+ return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
218
+ }
219
+
220
+ if (isValidSpacing(spacing)) {
221
+ return ["spacing-".concat(smallestBreakpoint, "-").concat(String(spacing))];
222
+ }
223
+
224
+ if (_typeof(spacing) === 'object' && !Array.isArray(spacing)) {
225
+ var classNames = [];
226
+ Object.entries(spacing).forEach(function (_ref10) {
227
+ var _ref11 = _slicedToArray(_ref10, 2),
228
+ key = _ref11[0],
229
+ value = _ref11[1];
230
+
231
+ if (isValidSpacing(value)) {
232
+ classNames.push("spacing-".concat(key, "-").concat(String(value)));
233
+ }
234
+ });
235
+ return classNames;
236
+ }
237
+
238
+ return [];
239
+ };
@@ -0,0 +1,5 @@
1
+ export { default } from './Grid';
2
+ export { default as createGrid } from './createGrid';
3
+ export * from './GridProps';
4
+ export { default as gridClasses } from './gridClasses';
5
+ export * from './gridClasses';
File without changes
@@ -161,7 +161,7 @@ export default function useCurrentColorScheme(options) {
161
161
  if (state.mode === 'system') {
162
162
  setState(function (currentState) {
163
163
  return _extends({}, currentState, {
164
- systemMode: e.matches ? 'dark' : 'light'
164
+ systemMode: e != null && e.matches ? 'dark' : 'light'
165
165
  });
166
166
  });
167
167
  }
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import borders from './borders';
3
3
  import display from './display';
4
4
  import flexbox from './flexbox';
5
- import grid from './grid';
5
+ import grid from './cssGrid';
6
6
  import positions from './positions';
7
7
  import palette from './palette';
8
8
  import shadows from './shadows';
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.8.7
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 './grid';
16
- export * from './grid';
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';