@mui/system 5.8.7 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -0
- package/Unstable_Grid/Grid.d.ts +12 -0
- package/Unstable_Grid/Grid.js +190 -0
- package/Unstable_Grid/GridProps.d.ts +158 -0
- package/Unstable_Grid/GridProps.js +5 -0
- package/Unstable_Grid/createGrid.d.ts +11 -0
- package/Unstable_Grid/createGrid.js +174 -0
- package/Unstable_Grid/gridClasses.d.ts +20 -0
- package/Unstable_Grid/gridClasses.js +25 -0
- package/Unstable_Grid/gridGenerator.d.ts +26 -0
- package/Unstable_Grid/gridGenerator.js +269 -0
- package/Unstable_Grid/index.d.ts +5 -0
- package/Unstable_Grid/index.js +65 -0
- package/Unstable_Grid/package.json +6 -0
- package/{grid.js → cssGrid.js} +0 -0
- package/cssVars/useCurrentColorScheme.js +1 -1
- package/esm/Unstable_Grid/Grid.js +179 -0
- package/esm/Unstable_Grid/GridProps.js +1 -0
- package/esm/Unstable_Grid/createGrid.js +152 -0
- package/esm/Unstable_Grid/gridClasses.js +14 -0
- package/esm/Unstable_Grid/gridGenerator.js +230 -0
- package/esm/Unstable_Grid/index.js +5 -0
- package/esm/{grid.js → cssGrid.js} +0 -0
- package/esm/cssVars/useCurrentColorScheme.js +1 -1
- package/esm/getThemeValue.js +1 -1
- package/esm/index.js +9 -3
- package/getThemeValue.js +3 -3
- package/index.d.ts +3 -0
- package/index.js +30 -7
- package/legacy/Unstable_Grid/Grid.js +179 -0
- package/legacy/Unstable_Grid/GridProps.js +1 -0
- package/legacy/Unstable_Grid/createGrid.js +166 -0
- package/legacy/Unstable_Grid/gridClasses.js +27 -0
- package/legacy/Unstable_Grid/gridGenerator.js +239 -0
- package/legacy/Unstable_Grid/index.js +5 -0
- package/legacy/{grid.js → cssGrid.js} +0 -0
- package/legacy/cssVars/useCurrentColorScheme.js +1 -1
- package/legacy/getThemeValue.js +1 -1
- package/legacy/index.js +10 -4
- package/modern/Unstable_Grid/Grid.js +179 -0
- package/modern/Unstable_Grid/GridProps.js +1 -0
- package/modern/Unstable_Grid/createGrid.js +150 -0
- package/modern/Unstable_Grid/gridClasses.js +14 -0
- package/modern/Unstable_Grid/gridGenerator.js +226 -0
- package/modern/Unstable_Grid/index.js +5 -0
- package/modern/{grid.js → cssGrid.js} +0 -0
- package/modern/cssVars/useCurrentColorScheme.js +1 -1
- package/modern/getThemeValue.js +1 -1
- package/modern/index.js +10 -4
- package/package.json +4 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
8
|
+
import systemStyled from '../styled';
|
|
9
|
+
import useThemePropsSystem from '../useThemeProps';
|
|
10
|
+
import useTheme from '../useTheme';
|
|
11
|
+
import { extendSxProp } from '../styleFunctionSx';
|
|
12
|
+
import createTheme from '../createTheme';
|
|
13
|
+
import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames } from './gridGenerator';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const defaultTheme = createTheme(); // widening Theme to any so that the consumer can own the theme structure.
|
|
16
|
+
|
|
17
|
+
const defaultCreateStyledComponent = systemStyled('div', {
|
|
18
|
+
name: 'MuiGrid',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function useThemePropsDefault(props) {
|
|
24
|
+
return useThemePropsSystem({
|
|
25
|
+
props,
|
|
26
|
+
name: 'MuiGrid',
|
|
27
|
+
defaultTheme
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default function createGrid(options = {}) {
|
|
32
|
+
const {
|
|
33
|
+
// This will allow adding custom styled fn (for example for custom sx style function)
|
|
34
|
+
createStyledComponent = defaultCreateStyledComponent,
|
|
35
|
+
useThemeProps = useThemePropsDefault,
|
|
36
|
+
componentName = 'MuiGrid'
|
|
37
|
+
} = options;
|
|
38
|
+
const NestedContext = /*#__PURE__*/React.createContext(false);
|
|
39
|
+
|
|
40
|
+
const useUtilityClasses = (ownerState, theme) => {
|
|
41
|
+
const {
|
|
42
|
+
container,
|
|
43
|
+
direction,
|
|
44
|
+
spacing,
|
|
45
|
+
wrap,
|
|
46
|
+
gridSize
|
|
47
|
+
} = ownerState;
|
|
48
|
+
const slots = {
|
|
49
|
+
root: ['root', container && 'container', direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
|
|
50
|
+
};
|
|
51
|
+
return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
|
|
55
|
+
const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
56
|
+
var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin;
|
|
57
|
+
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
const themeProps = useThemeProps(inProps);
|
|
60
|
+
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
61
|
+
|
|
62
|
+
const nested = React.useContext(NestedContext);
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
className,
|
|
66
|
+
columns: columnsProp = 12,
|
|
67
|
+
container = false,
|
|
68
|
+
component = 'div',
|
|
69
|
+
direction = 'row',
|
|
70
|
+
wrap = 'wrap',
|
|
71
|
+
spacing: spacingProp = 0,
|
|
72
|
+
rowSpacing: rowSpacingProp = spacingProp,
|
|
73
|
+
columnSpacing: columnSpacingProp = spacingProp
|
|
74
|
+
} = props,
|
|
75
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded); // collect breakpoints related props because they can be custom from the theme.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const gridSize = {};
|
|
79
|
+
const gridOffset = {};
|
|
80
|
+
const other = {};
|
|
81
|
+
Object.entries(rest).forEach(([key, val]) => {
|
|
82
|
+
if (theme.breakpoints.values[key] !== undefined) {
|
|
83
|
+
gridSize[key] = val;
|
|
84
|
+
} else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
|
|
85
|
+
gridOffset[key.replace('Offset', '')] = val;
|
|
86
|
+
} else {
|
|
87
|
+
other[key] = val;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : nested ? undefined : columnsProp;
|
|
91
|
+
const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : nested ? undefined : spacingProp;
|
|
92
|
+
const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : nested ? undefined : rowSpacingProp;
|
|
93
|
+
const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : nested ? undefined : columnSpacingProp;
|
|
94
|
+
|
|
95
|
+
const ownerState = _extends({}, props, {
|
|
96
|
+
nested,
|
|
97
|
+
columns,
|
|
98
|
+
container,
|
|
99
|
+
direction,
|
|
100
|
+
wrap,
|
|
101
|
+
spacing,
|
|
102
|
+
rowSpacing,
|
|
103
|
+
columnSpacing,
|
|
104
|
+
gridSize,
|
|
105
|
+
gridOffset
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const classes = useUtilityClasses(ownerState, theme);
|
|
109
|
+
|
|
110
|
+
let result = /*#__PURE__*/_jsx(GridRoot, _extends({
|
|
111
|
+
ref: ref,
|
|
112
|
+
as: component,
|
|
113
|
+
ownerState: ownerState,
|
|
114
|
+
className: clsx(classes.root, className)
|
|
115
|
+
}, other));
|
|
116
|
+
|
|
117
|
+
if (!nested) {
|
|
118
|
+
result = /*#__PURE__*/_jsx(NestedContext.Provider, {
|
|
119
|
+
value: true,
|
|
120
|
+
children: result
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return result;
|
|
125
|
+
});
|
|
126
|
+
process.env.NODE_ENV !== "production" ? Grid.propTypes
|
|
127
|
+
/* remove-proptypes */
|
|
128
|
+
= {
|
|
129
|
+
children: PropTypes.node,
|
|
130
|
+
className: PropTypes.string,
|
|
131
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
132
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
133
|
+
component: PropTypes.elementType,
|
|
134
|
+
container: PropTypes.bool,
|
|
135
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
136
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
137
|
+
lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
138
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
139
|
+
mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
140
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
141
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
142
|
+
smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
143
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
144
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
145
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
146
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
147
|
+
xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
|
148
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
149
|
+
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
150
|
+
} : void 0;
|
|
151
|
+
return Grid;
|
|
152
|
+
}
|
|
@@ -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,230 @@
|
|
|
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.nested ? {
|
|
189
|
+
padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
|
|
190
|
+
} : {
|
|
191
|
+
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
192
|
+
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
193
|
+
}) : {
|
|
194
|
+
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
export const generateSizeClassNames = gridSize => {
|
|
198
|
+
const classNames = [];
|
|
199
|
+
Object.entries(gridSize).forEach(([key, value]) => {
|
|
200
|
+
if (value !== false && value !== undefined) {
|
|
201
|
+
classNames.push(`grid-${key}-${String(value)}`);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return classNames;
|
|
205
|
+
};
|
|
206
|
+
export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') => {
|
|
207
|
+
function isValidSpacing(val) {
|
|
208
|
+
if (val === undefined) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (isValidSpacing(spacing)) {
|
|
216
|
+
return [`spacing-${smallestBreakpoint}-${String(spacing)}`];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (typeof spacing === 'object' && !Array.isArray(spacing)) {
|
|
220
|
+
const classNames = [];
|
|
221
|
+
Object.entries(spacing).forEach(([key, value]) => {
|
|
222
|
+
if (isValidSpacing(value)) {
|
|
223
|
+
classNames.push(`spacing-${key}-${String(value)}`);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return classNames;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return [];
|
|
230
|
+
};
|
|
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
|
package/esm/getThemeValue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import borders from './borders';
|
|
2
2
|
import display from './display';
|
|
3
3
|
import flexbox from './flexbox';
|
|
4
|
-
import grid from './
|
|
4
|
+
import grid from './cssGrid';
|
|
5
5
|
import positions from './positions';
|
|
6
6
|
import palette from './palette';
|
|
7
7
|
import shadows from './shadows';
|
package/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 './
|
|
11
|
-
export * from './
|
|
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';
|
package/getThemeValue.js
CHANGED
|
@@ -13,7 +13,7 @@ var _display = _interopRequireDefault(require("./display"));
|
|
|
13
13
|
|
|
14
14
|
var _flexbox = _interopRequireDefault(require("./flexbox"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _cssGrid = _interopRequireDefault(require("./cssGrid"));
|
|
17
17
|
|
|
18
18
|
var _positions = _interopRequireDefault(require("./positions"));
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ const filterPropsMapping = {
|
|
|
31
31
|
borders: _borders.default.filterProps,
|
|
32
32
|
display: _display.default.filterProps,
|
|
33
33
|
flexbox: _flexbox.default.filterProps,
|
|
34
|
-
grid:
|
|
34
|
+
grid: _cssGrid.default.filterProps,
|
|
35
35
|
positions: _positions.default.filterProps,
|
|
36
36
|
palette: _palette.default.filterProps,
|
|
37
37
|
shadows: _shadows.default.filterProps,
|
|
@@ -43,7 +43,7 @@ const styleFunctionMapping = {
|
|
|
43
43
|
borders: _borders.default,
|
|
44
44
|
display: _display.default,
|
|
45
45
|
flexbox: _flexbox.default,
|
|
46
|
-
grid:
|
|
46
|
+
grid: _cssGrid.default,
|
|
47
47
|
positions: _positions.default,
|
|
48
48
|
palette: _palette.default,
|
|
49
49
|
shadows: _shadows.default,
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.9.0
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -53,7 +53,8 @@ var _exportNames = {
|
|
|
53
53
|
unstable_createCssVarsProvider: true,
|
|
54
54
|
unstable_createGetCssVar: true,
|
|
55
55
|
createContainer: true,
|
|
56
|
-
Container: true
|
|
56
|
+
Container: true,
|
|
57
|
+
Unstable_Grid: true
|
|
57
58
|
};
|
|
58
59
|
Object.defineProperty(exports, "Box", {
|
|
59
60
|
enumerable: true,
|
|
@@ -85,6 +86,12 @@ Object.defineProperty(exports, "ThemeProvider", {
|
|
|
85
86
|
return _ThemeProvider.default;
|
|
86
87
|
}
|
|
87
88
|
});
|
|
89
|
+
Object.defineProperty(exports, "Unstable_Grid", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return _Grid.default;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
88
95
|
Object.defineProperty(exports, "borders", {
|
|
89
96
|
enumerable: true,
|
|
90
97
|
get: function () {
|
|
@@ -178,7 +185,7 @@ Object.defineProperty(exports, "getThemeProps", {
|
|
|
178
185
|
Object.defineProperty(exports, "grid", {
|
|
179
186
|
enumerable: true,
|
|
180
187
|
get: function () {
|
|
181
|
-
return
|
|
188
|
+
return _cssGrid.default;
|
|
182
189
|
}
|
|
183
190
|
});
|
|
184
191
|
Object.defineProperty(exports, "handleBreakpoints", {
|
|
@@ -350,16 +357,16 @@ Object.keys(_flexbox).forEach(function (key) {
|
|
|
350
357
|
});
|
|
351
358
|
});
|
|
352
359
|
|
|
353
|
-
var
|
|
360
|
+
var _cssGrid = _interopRequireWildcard(require("./cssGrid"));
|
|
354
361
|
|
|
355
|
-
Object.keys(
|
|
362
|
+
Object.keys(_cssGrid).forEach(function (key) {
|
|
356
363
|
if (key === "default" || key === "__esModule") return;
|
|
357
364
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
358
|
-
if (key in exports && exports[key] ===
|
|
365
|
+
if (key in exports && exports[key] === _cssGrid[key]) return;
|
|
359
366
|
Object.defineProperty(exports, key, {
|
|
360
367
|
enumerable: true,
|
|
361
368
|
get: function () {
|
|
362
|
-
return
|
|
369
|
+
return _cssGrid[key];
|
|
363
370
|
}
|
|
364
371
|
});
|
|
365
372
|
});
|
|
@@ -514,6 +521,22 @@ Object.keys(_Container).forEach(function (key) {
|
|
|
514
521
|
});
|
|
515
522
|
});
|
|
516
523
|
|
|
524
|
+
var _Grid = _interopRequireDefault(require("./Unstable_Grid/Grid"));
|
|
525
|
+
|
|
526
|
+
var _Unstable_Grid = require("./Unstable_Grid");
|
|
527
|
+
|
|
528
|
+
Object.keys(_Unstable_Grid).forEach(function (key) {
|
|
529
|
+
if (key === "default" || key === "__esModule") return;
|
|
530
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
531
|
+
if (key in exports && exports[key] === _Unstable_Grid[key]) return;
|
|
532
|
+
Object.defineProperty(exports, key, {
|
|
533
|
+
enumerable: true,
|
|
534
|
+
get: function () {
|
|
535
|
+
return _Unstable_Grid[key];
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
517
540
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
518
541
|
|
|
519
542
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|