@mui/system 5.8.7 → 5.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +200 -4
  2. package/Unstable_Grid/Grid.d.ts +12 -0
  3. package/Unstable_Grid/Grid.js +195 -0
  4. package/Unstable_Grid/GridProps.d.ts +162 -0
  5. package/Unstable_Grid/GridProps.js +5 -0
  6. package/Unstable_Grid/createGrid.d.ts +11 -0
  7. package/Unstable_Grid/createGrid.js +199 -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 +275 -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/breakpoints.js +1 -1
  16. package/{grid.js → cssGrid.js} +0 -0
  17. package/cssVars/useCurrentColorScheme.js +1 -1
  18. package/esm/Unstable_Grid/Grid.js +184 -0
  19. package/esm/Unstable_Grid/GridProps.js +1 -0
  20. package/esm/Unstable_Grid/createGrid.js +177 -0
  21. package/esm/Unstable_Grid/gridClasses.js +14 -0
  22. package/esm/Unstable_Grid/gridGenerator.js +236 -0
  23. package/esm/Unstable_Grid/index.js +5 -0
  24. package/esm/breakpoints.js +1 -1
  25. package/esm/{grid.js → cssGrid.js} +0 -0
  26. package/esm/cssVars/useCurrentColorScheme.js +1 -1
  27. package/esm/getThemeValue.js +1 -1
  28. package/esm/index.js +9 -3
  29. package/getThemeValue.js +3 -3
  30. package/index.d.ts +3 -0
  31. package/index.js +30 -7
  32. package/legacy/Unstable_Grid/Grid.js +184 -0
  33. package/legacy/Unstable_Grid/GridProps.js +1 -0
  34. package/legacy/Unstable_Grid/createGrid.js +191 -0
  35. package/legacy/Unstable_Grid/gridClasses.js +27 -0
  36. package/legacy/Unstable_Grid/gridGenerator.js +245 -0
  37. package/legacy/Unstable_Grid/index.js +5 -0
  38. package/legacy/breakpoints.js +1 -1
  39. package/legacy/{grid.js → cssGrid.js} +0 -0
  40. package/legacy/cssVars/useCurrentColorScheme.js +1 -1
  41. package/legacy/getThemeValue.js +1 -1
  42. package/legacy/index.js +10 -4
  43. package/modern/Unstable_Grid/Grid.js +184 -0
  44. package/modern/Unstable_Grid/GridProps.js +1 -0
  45. package/modern/Unstable_Grid/createGrid.js +175 -0
  46. package/modern/Unstable_Grid/gridClasses.js +14 -0
  47. package/modern/Unstable_Grid/gridGenerator.js +232 -0
  48. package/modern/Unstable_Grid/index.js +5 -0
  49. package/modern/breakpoints.js +1 -1
  50. package/modern/{grid.js → cssGrid.js} +0 -0
  51. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  52. package/modern/getThemeValue.js +1 -1
  53. package/modern/index.js +10 -4
  54. 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
+ 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 `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,177 @@
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", "disableEqualOverflow"];
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
+ const OverflowContext = /*#__PURE__*/React.createContext(undefined);
40
+
41
+ const useUtilityClasses = (ownerState, theme) => {
42
+ const {
43
+ container,
44
+ direction,
45
+ spacing,
46
+ wrap,
47
+ gridSize
48
+ } = ownerState;
49
+ const slots = {
50
+ 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]) : [])]
51
+ };
52
+ return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
53
+ };
54
+
55
+ const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
56
+ const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
57
+ var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin, _ref3, _disableEqualOverflow;
58
+
59
+ const theme = useTheme();
60
+ const themeProps = useThemeProps(inProps);
61
+ const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
62
+
63
+ const nested = React.useContext(NestedContext);
64
+ const overflow = React.useContext(OverflowContext);
65
+
66
+ const {
67
+ className,
68
+ columns: columnsProp = 12,
69
+ container = false,
70
+ component = 'div',
71
+ direction = 'row',
72
+ wrap = 'wrap',
73
+ spacing: spacingProp = 0,
74
+ rowSpacing: rowSpacingProp = spacingProp,
75
+ columnSpacing: columnSpacingProp = spacingProp,
76
+ disableEqualOverflow: themeDisableEqualOverflow
77
+ } = props,
78
+ rest = _objectWithoutPropertiesLoose(props, _excluded); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
79
+
80
+
81
+ let disableEqualOverflow = themeDisableEqualOverflow;
82
+
83
+ if (nested && themeDisableEqualOverflow !== undefined) {
84
+ disableEqualOverflow = inProps.disableEqualOverflow;
85
+ } // collect breakpoints related props because they can be customized from the theme.
86
+
87
+
88
+ const gridSize = {};
89
+ const gridOffset = {};
90
+ const other = {};
91
+ Object.entries(rest).forEach(([key, val]) => {
92
+ if (theme.breakpoints.values[key] !== undefined) {
93
+ gridSize[key] = val;
94
+ } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
95
+ gridOffset[key.replace('Offset', '')] = val;
96
+ } else {
97
+ other[key] = val;
98
+ }
99
+ });
100
+ const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : nested ? undefined : columnsProp;
101
+ const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : nested ? undefined : spacingProp;
102
+ const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : nested ? undefined : rowSpacingProp;
103
+ const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : nested ? undefined : columnSpacingProp;
104
+
105
+ const ownerState = _extends({}, props, {
106
+ nested,
107
+ columns,
108
+ container,
109
+ direction,
110
+ wrap,
111
+ spacing,
112
+ rowSpacing,
113
+ columnSpacing,
114
+ gridSize,
115
+ gridOffset,
116
+ disableEqualOverflow: (_ref3 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref3 : false,
117
+ // use context value if exists.
118
+ parentDisableEqualOverflow: overflow // for nested grid
119
+
120
+ });
121
+
122
+ const classes = useUtilityClasses(ownerState, theme);
123
+
124
+ let 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
+ if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
139
+ // There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
140
+ // 1. It is the root grid with `disableEqualOverflow`.
141
+ // 2. It is a nested grid with different `disableEqualOverflow` from the context.
142
+ result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
143
+ value: disableEqualOverflow,
144
+ children: result
145
+ });
146
+ }
147
+
148
+ return result;
149
+ });
150
+ process.env.NODE_ENV !== "production" ? Grid.propTypes
151
+ /* remove-proptypes */
152
+ = {
153
+ children: PropTypes.node,
154
+ className: PropTypes.string,
155
+ columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
156
+ columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
157
+ component: PropTypes.elementType,
158
+ container: PropTypes.bool,
159
+ direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
160
+ disableEqualOverflow: PropTypes.bool,
161
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
162
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
163
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
164
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
165
+ rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
166
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
167
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
168
+ spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
169
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
170
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
171
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
172
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
173
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
174
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
175
+ } : void 0;
176
+ return Grid;
177
+ }
@@ -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,236 @@
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
+ 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 const generateGridColumnSpacingStyles = ({
142
+ theme,
143
+ ownerState
144
+ }) => {
145
+ if (!ownerState.container) {
146
+ return {};
147
+ }
148
+
149
+ const styles = {};
150
+ traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (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 const generateGridDirectionStyles = ({
160
+ theme,
161
+ ownerState
162
+ }) => {
163
+ if (!ownerState.container) {
164
+ return {};
165
+ }
166
+
167
+ const styles = {};
168
+ traverseBreakpoints(theme.breakpoints, ownerState.direction, (appendStyle, value) => {
169
+ appendStyle(styles, {
170
+ flexDirection: value
171
+ });
172
+ });
173
+ return styles;
174
+ };
175
+ export const generateGridStyles = ({
176
+ ownerState
177
+ }) => {
178
+ return _extends({
179
+ minWidth: 0,
180
+ boxSizing: 'border-box'
181
+ }, ownerState.container ? _extends({
182
+ display: 'flex',
183
+ flexWrap: 'wrap'
184
+ }, ownerState.wrap && ownerState.wrap !== 'wrap' && {
185
+ flexWrap: ownerState.wrap
186
+ }, {
187
+ margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
188
+ }, ownerState.disableEqualOverflow && {
189
+ margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
190
+ }, ownerState.nested ? _extends({
191
+ padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
192
+ }, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
193
+ padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
194
+ }) : {
195
+ '--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
196
+ '--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
197
+ }) : _extends({
198
+ padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
199
+ }, ownerState.disableEqualOverflow && {
200
+ padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
201
+ }));
202
+ };
203
+ export const generateSizeClassNames = gridSize => {
204
+ const classNames = [];
205
+ Object.entries(gridSize).forEach(([key, value]) => {
206
+ if (value !== false && value !== undefined) {
207
+ classNames.push(`grid-${key}-${String(value)}`);
208
+ }
209
+ });
210
+ return classNames;
211
+ };
212
+ export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') => {
213
+ function isValidSpacing(val) {
214
+ if (val === undefined) {
215
+ return false;
216
+ }
217
+
218
+ return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
219
+ }
220
+
221
+ if (isValidSpacing(spacing)) {
222
+ return [`spacing-${smallestBreakpoint}-${String(spacing)}`];
223
+ }
224
+
225
+ if (typeof spacing === 'object' && !Array.isArray(spacing)) {
226
+ const classNames = [];
227
+ Object.entries(spacing).forEach(([key, value]) => {
228
+ if (isValidSpacing(value)) {
229
+ classNames.push(`spacing-${key}-${String(value)}`);
230
+ }
231
+ });
232
+ return classNames;
233
+ }
234
+
235
+ return [];
236
+ };
@@ -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';
@@ -85,7 +85,7 @@ function breakpoints(styleFunction) {
85
85
  export function createEmptyBreakpointObject(breakpointsInput = {}) {
86
86
  var _breakpointsInput$key;
87
87
 
88
- const breakpointsInOrder = breakpointsInput == null ? void 0 : (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
88
+ const breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
89
89
  const breakpointStyleKey = breakpointsInput.up(key);
90
90
  acc[breakpointStyleKey] = {};
91
91
  return acc;
File without changes
@@ -153,7 +153,7 @@ export default function useCurrentColorScheme(options) {
153
153
  const handleMediaQuery = React.useCallback(e => {
154
154
  if (state.mode === 'system') {
155
155
  setState(currentState => _extends({}, currentState, {
156
- systemMode: e.matches ? 'dark' : 'light'
156
+ systemMode: e != null && e.matches ? 'dark' : 'light'
157
157
  }));
158
158
  }
159
159
  }, [state.mode]); // Ref hack to avoid adding handleMediaQuery as a dep
@@ -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 './grid';
4
+ import grid from './cssGrid';
5
5
  import positions from './positions';
6
6
  import palette from './palette';
7
7
  import shadows from './shadows';
package/esm/index.js CHANGED
@@ -7,8 +7,8 @@ export { default as compose } from './compose';
7
7
  export { default as display } from './display';
8
8
  export { default as flexbox } from './flexbox';
9
9
  export * from './flexbox';
10
- export { default as grid } from './grid';
11
- export * from './grid';
10
+ export { default as grid } from './cssGrid';
11
+ export * from './cssGrid';
12
12
  export { default as palette } from './palette';
13
13
  export * from './palette';
14
14
  export { default as positions } from './positions';
@@ -40,6 +40,12 @@ export * from './colorManipulator';
40
40
  export { default as ThemeProvider } from './ThemeProvider';
41
41
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
42
42
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
43
+ /** ----------------- */
44
+
45
+ /** Layout components */
46
+
43
47
  export { default as createContainer } from './Container/createContainer';
44
48
  export { default as Container } from './Container';
45
- export * from './Container';
49
+ export * from './Container';
50
+ export { default as Unstable_Grid } from './Unstable_Grid/Grid';
51
+ export * from './Unstable_Grid';