@mui/system 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +37 -2
- package/Container/createContainer.js +41 -35
- package/RtlProvider/index.js +8 -11
- package/Stack/createStack.js +24 -26
- package/ThemeProvider/ThemeProvider.js +9 -5
- package/Unstable_Grid/createGrid.js +21 -23
- package/Unstable_Grid/gridGenerator.js +20 -17
- package/breakpoints/breakpoints.js +7 -6
- package/createBox/createBox.js +9 -12
- package/createStyled/createStyled.js +59 -51
- package/createTheme/createBreakpoints.js +24 -25
- package/createTheme/createTheme.js +18 -14
- package/cssContainerQueries/cssContainerQueries.js +6 -4
- package/cssVars/createCssVarsProvider.js +17 -16
- package/cssVars/createCssVarsTheme.js +3 -3
- package/cssVars/prepareCssVars.js +30 -25
- package/cssVars/useCurrentColorScheme.js +18 -11
- package/index.js +1 -1
- package/modern/Container/createContainer.js +41 -35
- package/modern/RtlProvider/index.js +8 -11
- package/modern/Stack/createStack.js +24 -26
- package/modern/ThemeProvider/ThemeProvider.js +9 -5
- package/modern/Unstable_Grid/createGrid.js +21 -23
- package/modern/Unstable_Grid/gridGenerator.js +20 -17
- package/modern/breakpoints/breakpoints.js +7 -6
- package/modern/createBox/createBox.js +9 -12
- package/modern/createStyled/createStyled.js +59 -51
- package/modern/createTheme/createBreakpoints.js +24 -25
- package/modern/createTheme/createTheme.js +18 -14
- package/modern/cssContainerQueries/cssContainerQueries.js +6 -4
- package/modern/cssVars/createCssVarsProvider.js +17 -16
- package/modern/cssVars/createCssVarsTheme.js +3 -3
- package/modern/cssVars/prepareCssVars.js +30 -25
- package/modern/cssVars/useCurrentColorScheme.js +18 -11
- package/modern/index.js +1 -1
- package/modern/propsToClassKey/propsToClassKey.js +3 -5
- package/modern/styleFunctionSx/extendSxProp.js +14 -10
- package/node/Container/createContainer.js +41 -35
- package/node/RtlProvider/index.js +8 -11
- package/node/Stack/createStack.js +24 -26
- package/node/ThemeProvider/ThemeProvider.js +9 -5
- package/node/Unstable_Grid/createGrid.js +21 -23
- package/node/Unstable_Grid/gridGenerator.js +20 -18
- package/node/breakpoints/breakpoints.js +7 -6
- package/node/createBox/createBox.js +9 -12
- package/node/createStyled/createStyled.js +61 -52
- package/node/createTheme/createBreakpoints.js +24 -26
- package/node/createTheme/createTheme.js +18 -14
- package/node/cssContainerQueries/cssContainerQueries.js +6 -4
- package/node/cssVars/createCssVarsProvider.js +17 -16
- package/node/cssVars/createCssVarsTheme.js +3 -3
- package/node/cssVars/prepareCssVars.js +30 -25
- package/node/cssVars/useCurrentColorScheme.js +18 -12
- package/node/index.js +1 -1
- package/node/propsToClassKey/propsToClassKey.js +3 -5
- package/node/styleFunctionSx/extendSxProp.js +14 -10
- package/package.json +5 -5
- package/propsToClassKey/propsToClassKey.js +3 -5
- package/styleFunctionSx/extendSxProp.js +14 -10
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["className", "component", "disableGutters", "fixed", "maxWidth", "classes"];
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import PropTypes from 'prop-types';
|
|
6
3
|
import clsx from 'clsx';
|
|
@@ -52,20 +49,22 @@ export default function createContainer(options = {}) {
|
|
|
52
49
|
const ContainerRoot = createStyledComponent(({
|
|
53
50
|
theme,
|
|
54
51
|
ownerState
|
|
55
|
-
}) =>
|
|
52
|
+
}) => ({
|
|
56
53
|
width: '100%',
|
|
57
54
|
marginLeft: 'auto',
|
|
58
55
|
boxSizing: 'border-box',
|
|
59
56
|
marginRight: 'auto',
|
|
60
|
-
display: 'block'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
display: 'block',
|
|
58
|
+
// Fix IE11 layout when used with main.
|
|
59
|
+
...(!ownerState.disableGutters && {
|
|
60
|
+
paddingLeft: theme.spacing(2),
|
|
61
|
+
paddingRight: theme.spacing(2),
|
|
62
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
63
|
+
[theme.breakpoints.up('sm')]: {
|
|
64
|
+
paddingLeft: theme.spacing(3),
|
|
65
|
+
paddingRight: theme.spacing(3)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
69
68
|
}), ({
|
|
70
69
|
theme,
|
|
71
70
|
ownerState
|
|
@@ -82,51 +81,58 @@ export default function createContainer(options = {}) {
|
|
|
82
81
|
}, {}), ({
|
|
83
82
|
theme,
|
|
84
83
|
ownerState
|
|
85
|
-
}) =>
|
|
84
|
+
}) => ({
|
|
86
85
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
87
|
-
|
|
86
|
+
...(ownerState.maxWidth === 'xs' && {
|
|
88
87
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
[theme.breakpoints.up('xs')]: {
|
|
89
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
90
|
+
maxWidth: Math.max(theme.breakpoints.values.xs, 444)
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
...(ownerState.maxWidth &&
|
|
94
94
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
95
|
-
|
|
95
|
+
ownerState.maxWidth !== 'xs' && {
|
|
96
96
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
[theme.breakpoints.up(ownerState.maxWidth)]: {
|
|
98
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
99
|
+
maxWidth: `${theme.breakpoints.values[ownerState.maxWidth]}${theme.breakpoints.unit}`
|
|
100
|
+
}
|
|
101
|
+
})
|
|
99
102
|
}));
|
|
100
103
|
const Container = /*#__PURE__*/React.forwardRef(function Container(inProps, ref) {
|
|
101
104
|
const props = useThemeProps(inProps);
|
|
102
105
|
const {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
other
|
|
110
|
-
|
|
106
|
+
className,
|
|
107
|
+
component = 'div',
|
|
108
|
+
disableGutters = false,
|
|
109
|
+
fixed = false,
|
|
110
|
+
maxWidth = 'lg',
|
|
111
|
+
classes: classesProp,
|
|
112
|
+
...other
|
|
113
|
+
} = props;
|
|
114
|
+
const ownerState = {
|
|
115
|
+
...props,
|
|
111
116
|
component,
|
|
112
117
|
disableGutters,
|
|
113
118
|
fixed,
|
|
114
119
|
maxWidth
|
|
115
|
-
}
|
|
120
|
+
};
|
|
116
121
|
|
|
117
122
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
118
123
|
const classes = useUtilityClasses(ownerState, componentName);
|
|
119
124
|
return (
|
|
120
125
|
/*#__PURE__*/
|
|
121
126
|
// @ts-ignore theme is injected by the styled util
|
|
122
|
-
_jsx(ContainerRoot,
|
|
127
|
+
_jsx(ContainerRoot, {
|
|
123
128
|
as: component
|
|
124
129
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
125
130
|
,
|
|
126
131
|
ownerState: ownerState,
|
|
127
132
|
className: clsx(classes.root, className),
|
|
128
|
-
ref: ref
|
|
129
|
-
|
|
133
|
+
ref: ref,
|
|
134
|
+
...other
|
|
135
|
+
})
|
|
130
136
|
);
|
|
131
137
|
});
|
|
132
138
|
process.env.NODE_ENV !== "production" ? Container.propTypes /* remove-proptypes */ = {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["value"];
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import PropTypes from 'prop-types';
|
|
6
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
4
|
const RtlContext = /*#__PURE__*/React.createContext();
|
|
8
|
-
function RtlProvider(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
5
|
+
function RtlProvider({
|
|
6
|
+
value,
|
|
7
|
+
...props
|
|
8
|
+
}) {
|
|
9
|
+
return /*#__PURE__*/_jsx(RtlContext.Provider, {
|
|
10
|
+
value: value ?? true,
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
16
13
|
}
|
|
17
14
|
process.env.NODE_ENV !== "production" ? RtlProvider.propTypes = {
|
|
18
15
|
children: PropTypes.node,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["component", "direction", "spacing", "divider", "children", "className", "useFlexGap"];
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import PropTypes from 'prop-types';
|
|
6
3
|
import clsx from 'clsx';
|
|
@@ -60,17 +57,18 @@ export const style = ({
|
|
|
60
57
|
ownerState,
|
|
61
58
|
theme
|
|
62
59
|
}) => {
|
|
63
|
-
let styles =
|
|
60
|
+
let styles = {
|
|
64
61
|
display: 'flex',
|
|
65
|
-
flexDirection: 'column'
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
flexDirection: 'column',
|
|
63
|
+
...handleBreakpoints({
|
|
64
|
+
theme
|
|
65
|
+
}, resolveBreakpointValues({
|
|
66
|
+
values: ownerState.direction,
|
|
67
|
+
breakpoints: theme.breakpoints.values
|
|
68
|
+
}), propValue => ({
|
|
69
|
+
flexDirection: propValue
|
|
70
|
+
}))
|
|
71
|
+
};
|
|
74
72
|
if (ownerState.spacing) {
|
|
75
73
|
const transformer = createUnarySpacing(theme);
|
|
76
74
|
const base = Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
|
|
@@ -138,29 +136,29 @@ export default function createStack(options = {}) {
|
|
|
138
136
|
const themeProps = useThemeProps(inProps);
|
|
139
137
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
140
138
|
const {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
component = 'div',
|
|
140
|
+
direction = 'column',
|
|
141
|
+
spacing = 0,
|
|
142
|
+
divider,
|
|
143
|
+
children,
|
|
144
|
+
className,
|
|
145
|
+
useFlexGap = false,
|
|
146
|
+
...other
|
|
147
|
+
} = props;
|
|
150
148
|
const ownerState = {
|
|
151
149
|
direction,
|
|
152
150
|
spacing,
|
|
153
151
|
useFlexGap
|
|
154
152
|
};
|
|
155
153
|
const classes = useUtilityClasses();
|
|
156
|
-
return /*#__PURE__*/_jsx(StackRoot,
|
|
154
|
+
return /*#__PURE__*/_jsx(StackRoot, {
|
|
157
155
|
as: component,
|
|
158
156
|
ownerState: ownerState,
|
|
159
157
|
ref: ref,
|
|
160
|
-
className: clsx(classes.root, className)
|
|
161
|
-
|
|
158
|
+
className: clsx(classes.root, className),
|
|
159
|
+
...other,
|
|
162
160
|
children: divider ? joinChildren(children, divider) : children
|
|
163
|
-
})
|
|
161
|
+
});
|
|
164
162
|
});
|
|
165
163
|
process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
|
|
166
164
|
children: PropTypes.node,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
|
|
@@ -15,9 +14,10 @@ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
|
|
|
15
14
|
const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
|
|
16
15
|
if (typeof localTheme === 'function') {
|
|
17
16
|
const mergedTheme = localTheme(resolvedTheme);
|
|
18
|
-
const result = themeId ?
|
|
17
|
+
const result = themeId ? {
|
|
18
|
+
...upperTheme,
|
|
19
19
|
[themeId]: mergedTheme
|
|
20
|
-
}
|
|
20
|
+
} : mergedTheme;
|
|
21
21
|
// must return a function for the private theme to NOT merge with the upper theme.
|
|
22
22
|
// see the test case "use provided theme from a callback" in ThemeProvider.test.js
|
|
23
23
|
if (isPrivate) {
|
|
@@ -25,9 +25,13 @@ function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
|
|
|
25
25
|
}
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
|
-
return themeId ?
|
|
28
|
+
return themeId ? {
|
|
29
|
+
...upperTheme,
|
|
29
30
|
[themeId]: localTheme
|
|
30
|
-
}
|
|
31
|
+
} : {
|
|
32
|
+
...upperTheme,
|
|
33
|
+
...localTheme
|
|
34
|
+
};
|
|
31
35
|
}, [themeId, upperTheme, localTheme, isPrivate]);
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className", "children", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow", "unstable_level"];
|
|
4
1
|
import * as React from 'react';
|
|
5
2
|
import PropTypes from 'prop-types';
|
|
6
3
|
import clsx from 'clsx';
|
|
@@ -60,20 +57,20 @@ export default function createGrid(options = {}) {
|
|
|
60
57
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
61
58
|
const overflow = React.useContext(GridOverflowContext);
|
|
62
59
|
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
className,
|
|
61
|
+
children,
|
|
62
|
+
columns: columnsProp = 12,
|
|
63
|
+
container = false,
|
|
64
|
+
component = 'div',
|
|
65
|
+
direction = 'row',
|
|
66
|
+
wrap = 'wrap',
|
|
67
|
+
spacing: spacingProp = 0,
|
|
68
|
+
rowSpacing: rowSpacingProp = spacingProp,
|
|
69
|
+
columnSpacing: columnSpacingProp = spacingProp,
|
|
70
|
+
disableEqualOverflow: themeDisableEqualOverflow,
|
|
71
|
+
unstable_level: level = 0,
|
|
72
|
+
...rest
|
|
73
|
+
} = props;
|
|
77
74
|
// Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
78
75
|
let disableEqualOverflow = themeDisableEqualOverflow;
|
|
79
76
|
if (level && themeDisableEqualOverflow !== undefined) {
|
|
@@ -96,7 +93,8 @@ export default function createGrid(options = {}) {
|
|
|
96
93
|
const spacing = inProps.spacing ?? (level ? undefined : spacingProp);
|
|
97
94
|
const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (level ? undefined : rowSpacingProp);
|
|
98
95
|
const columnSpacing = inProps.columnSpacing ?? inProps.spacing ?? (level ? undefined : columnSpacingProp);
|
|
99
|
-
const ownerState =
|
|
96
|
+
const ownerState = {
|
|
97
|
+
...props,
|
|
100
98
|
level,
|
|
101
99
|
columns,
|
|
102
100
|
container,
|
|
@@ -110,14 +108,14 @@ export default function createGrid(options = {}) {
|
|
|
110
108
|
disableEqualOverflow: disableEqualOverflow ?? overflow ?? false,
|
|
111
109
|
// use context value if exists.
|
|
112
110
|
parentDisableEqualOverflow: overflow // for nested grid
|
|
113
|
-
}
|
|
111
|
+
};
|
|
114
112
|
const classes = useUtilityClasses(ownerState, theme);
|
|
115
|
-
let result = /*#__PURE__*/_jsx(GridRoot,
|
|
113
|
+
let result = /*#__PURE__*/_jsx(GridRoot, {
|
|
116
114
|
ref: ref,
|
|
117
115
|
as: component,
|
|
118
116
|
ownerState: ownerState,
|
|
119
|
-
className: clsx(classes.root, className)
|
|
120
|
-
|
|
117
|
+
className: clsx(classes.root, className),
|
|
118
|
+
...other,
|
|
121
119
|
children: React.Children.map(children, child => {
|
|
122
120
|
if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
|
|
123
121
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
@@ -126,7 +124,7 @@ export default function createGrid(options = {}) {
|
|
|
126
124
|
}
|
|
127
125
|
return child;
|
|
128
126
|
})
|
|
129
|
-
})
|
|
127
|
+
});
|
|
130
128
|
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow ?? false)) {
|
|
131
129
|
// There are 2 possibilities that should wrap with the GridOverflowContext to communicate with the nested grids:
|
|
132
130
|
// 1. It is the root grid with `disableEqualOverflow`.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import { traverseBreakpoints } from './traverseBreakpoints';
|
|
3
2
|
function appendLevel(level) {
|
|
4
3
|
if (!level) {
|
|
@@ -163,23 +162,27 @@ export const generateGridStyles = ({
|
|
|
163
162
|
}) => {
|
|
164
163
|
const getSelfSpacing = createGetSelfSpacing(ownerState);
|
|
165
164
|
const getParentSpacing = createGetParentSpacing(ownerState);
|
|
166
|
-
return
|
|
165
|
+
return {
|
|
167
166
|
minWidth: 0,
|
|
168
|
-
boxSizing: 'border-box'
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
boxSizing: 'border-box',
|
|
168
|
+
...(ownerState.container && {
|
|
169
|
+
display: 'flex',
|
|
170
|
+
flexWrap: 'wrap',
|
|
171
|
+
...(ownerState.wrap && ownerState.wrap !== 'wrap' && {
|
|
172
|
+
flexWrap: ownerState.wrap
|
|
173
|
+
}),
|
|
174
|
+
margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`,
|
|
175
|
+
...(ownerState.disableEqualOverflow && {
|
|
176
|
+
margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
...((!ownerState.container || isNestedContainer(ownerState)) && {
|
|
180
|
+
padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`,
|
|
181
|
+
...((ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
182
|
+
padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
};
|
|
183
186
|
};
|
|
184
187
|
export const generateSizeClassNames = gridSize => {
|
|
185
188
|
const classNames = [];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import deepmerge from '@mui/utils/deepmerge';
|
|
4
3
|
import merge from '../merge';
|
|
@@ -76,21 +75,23 @@ function breakpoints(styleFunction) {
|
|
|
76
75
|
const extended = themeBreakpoints.keys.reduce((acc, key) => {
|
|
77
76
|
if (props[key]) {
|
|
78
77
|
acc = acc || {};
|
|
79
|
-
acc[themeBreakpoints.up(key)] = styleFunction(
|
|
80
|
-
theme
|
|
81
|
-
|
|
78
|
+
acc[themeBreakpoints.up(key)] = styleFunction({
|
|
79
|
+
theme,
|
|
80
|
+
...props[key]
|
|
81
|
+
});
|
|
82
82
|
}
|
|
83
83
|
return acc;
|
|
84
84
|
}, null);
|
|
85
85
|
return merge(base, extended);
|
|
86
86
|
};
|
|
87
|
-
newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ?
|
|
87
|
+
newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
88
|
+
...styleFunction.propTypes,
|
|
88
89
|
xs: PropTypes.object,
|
|
89
90
|
sm: PropTypes.object,
|
|
90
91
|
md: PropTypes.object,
|
|
91
92
|
lg: PropTypes.object,
|
|
92
93
|
xl: PropTypes.object
|
|
93
|
-
}
|
|
94
|
+
} : {};
|
|
94
95
|
newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
|
|
95
96
|
return newStyleFunction;
|
|
96
97
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["className", "component"];
|
|
6
3
|
import * as React from 'react';
|
|
7
4
|
import clsx from 'clsx';
|
|
8
5
|
import styled from '@mui/styled-engine';
|
|
@@ -21,18 +18,18 @@ export default function createBox(options = {}) {
|
|
|
21
18
|
})(styleFunctionSx);
|
|
22
19
|
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
23
20
|
const theme = useTheme(defaultTheme);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return /*#__PURE__*/_jsx(BoxRoot, _extends({
|
|
21
|
+
const {
|
|
22
|
+
className,
|
|
23
|
+
component = 'div',
|
|
24
|
+
...other
|
|
25
|
+
} = extendSxProp(inProps);
|
|
26
|
+
return /*#__PURE__*/_jsx(BoxRoot, {
|
|
31
27
|
as: component,
|
|
32
28
|
ref: ref,
|
|
33
29
|
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
34
|
-
theme: themeId ? theme[themeId] || theme : theme
|
|
35
|
-
|
|
30
|
+
theme: themeId ? theme[themeId] || theme : theme,
|
|
31
|
+
...other
|
|
32
|
+
});
|
|
36
33
|
});
|
|
37
34
|
return Box;
|
|
38
35
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ownerState"],
|
|
4
|
-
_excluded2 = ["variants"],
|
|
5
|
-
_excluded3 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
6
1
|
/* eslint-disable no-underscore-dangle */
|
|
7
2
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
8
3
|
import { isPlainObject } from '@mui/utils/deepmerge';
|
|
@@ -47,31 +42,34 @@ function defaultOverridesResolver(slot) {
|
|
|
47
42
|
}
|
|
48
43
|
return (props, styles) => styles[slot];
|
|
49
44
|
}
|
|
50
|
-
function processStyleArg(callableStyle,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
45
|
+
function processStyleArg(callableStyle, {
|
|
46
|
+
ownerState,
|
|
47
|
+
...props
|
|
48
|
+
}) {
|
|
49
|
+
const resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle({
|
|
50
|
+
ownerState,
|
|
51
|
+
...props
|
|
52
|
+
}) : callableStyle;
|
|
58
53
|
if (Array.isArray(resolvedStylesArg)) {
|
|
59
|
-
return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle,
|
|
60
|
-
ownerState
|
|
61
|
-
|
|
54
|
+
return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle, {
|
|
55
|
+
ownerState,
|
|
56
|
+
...props
|
|
57
|
+
}));
|
|
62
58
|
}
|
|
63
59
|
if (!!resolvedStylesArg && typeof resolvedStylesArg === 'object' && Array.isArray(resolvedStylesArg.variants)) {
|
|
64
60
|
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
variants = [],
|
|
62
|
+
...otherStyles
|
|
63
|
+
} = resolvedStylesArg;
|
|
68
64
|
let result = otherStyles;
|
|
69
65
|
variants.forEach(variant => {
|
|
70
66
|
let isMatch = true;
|
|
71
67
|
if (typeof variant.props === 'function') {
|
|
72
|
-
isMatch = variant.props(
|
|
73
|
-
ownerState
|
|
74
|
-
|
|
68
|
+
isMatch = variant.props({
|
|
69
|
+
ownerState,
|
|
70
|
+
...props,
|
|
71
|
+
...ownerState
|
|
72
|
+
});
|
|
75
73
|
} else {
|
|
76
74
|
Object.keys(variant.props).forEach(key => {
|
|
77
75
|
if (ownerState?.[key] !== variant.props[key] && props[key] !== variant.props[key]) {
|
|
@@ -83,9 +81,11 @@ function processStyleArg(callableStyle, _ref) {
|
|
|
83
81
|
if (!Array.isArray(result)) {
|
|
84
82
|
result = [result];
|
|
85
83
|
}
|
|
86
|
-
result.push(typeof variant.style === 'function' ? variant.style(
|
|
87
|
-
ownerState
|
|
88
|
-
|
|
84
|
+
result.push(typeof variant.style === 'function' ? variant.style({
|
|
85
|
+
ownerState,
|
|
86
|
+
...props,
|
|
87
|
+
...ownerState
|
|
88
|
+
}) : variant.style);
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
return result;
|
|
@@ -100,27 +100,29 @@ export default function createStyled(input = {}) {
|
|
|
100
100
|
slotShouldForwardProp = shouldForwardProp
|
|
101
101
|
} = input;
|
|
102
102
|
const systemSx = props => {
|
|
103
|
-
return styleFunctionSx(
|
|
104
|
-
|
|
103
|
+
return styleFunctionSx({
|
|
104
|
+
...props,
|
|
105
|
+
theme: resolveTheme({
|
|
106
|
+
...props,
|
|
105
107
|
defaultTheme,
|
|
106
108
|
themeId
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
+
})
|
|
110
|
+
});
|
|
109
111
|
};
|
|
110
112
|
systemSx.__mui_systemSx = true;
|
|
111
113
|
return (tag, inputOptions = {}) => {
|
|
112
114
|
// Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
|
|
113
115
|
processStyles(tag, styles => styles.filter(style => !style?.__mui_systemSx));
|
|
114
116
|
const {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
name: componentName,
|
|
118
|
+
slot: componentSlot,
|
|
119
|
+
skipVariantsResolver: inputSkipVariantsResolver,
|
|
120
|
+
skipSx: inputSkipSx,
|
|
121
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
122
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
123
|
+
overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot)),
|
|
124
|
+
...options
|
|
125
|
+
} = inputOptions;
|
|
124
126
|
|
|
125
127
|
// if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
126
128
|
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
@@ -149,22 +151,24 @@ export default function createStyled(input = {}) {
|
|
|
149
151
|
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
150
152
|
shouldForwardPropOption = undefined;
|
|
151
153
|
}
|
|
152
|
-
const defaultStyledResolver = styledEngineStyled(tag,
|
|
154
|
+
const defaultStyledResolver = styledEngineStyled(tag, {
|
|
153
155
|
shouldForwardProp: shouldForwardPropOption,
|
|
154
|
-
label
|
|
155
|
-
|
|
156
|
+
label,
|
|
157
|
+
...options
|
|
158
|
+
});
|
|
156
159
|
const transformStyleArg = stylesArg => {
|
|
157
160
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
158
161
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
159
162
|
// which are basically components used as a selectors.
|
|
160
163
|
if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || isPlainObject(stylesArg)) {
|
|
161
|
-
return props => processStyleArg(stylesArg,
|
|
164
|
+
return props => processStyleArg(stylesArg, {
|
|
165
|
+
...props,
|
|
162
166
|
theme: resolveTheme({
|
|
163
167
|
theme: props.theme,
|
|
164
168
|
defaultTheme,
|
|
165
169
|
themeId
|
|
166
170
|
})
|
|
167
|
-
})
|
|
171
|
+
});
|
|
168
172
|
}
|
|
169
173
|
return stylesArg;
|
|
170
174
|
};
|
|
@@ -173,10 +177,11 @@ export default function createStyled(input = {}) {
|
|
|
173
177
|
const expressionsWithDefaultTheme = expressions ? expressions.map(transformStyleArg) : [];
|
|
174
178
|
if (componentName && overridesResolver) {
|
|
175
179
|
expressionsWithDefaultTheme.push(props => {
|
|
176
|
-
const theme = resolveTheme(
|
|
180
|
+
const theme = resolveTheme({
|
|
181
|
+
...props,
|
|
177
182
|
defaultTheme,
|
|
178
183
|
themeId
|
|
179
|
-
})
|
|
184
|
+
});
|
|
180
185
|
if (!theme.components || !theme.components[componentName] || !theme.components[componentName].styleOverrides) {
|
|
181
186
|
return null;
|
|
182
187
|
}
|
|
@@ -184,25 +189,28 @@ export default function createStyled(input = {}) {
|
|
|
184
189
|
const resolvedStyleOverrides = {};
|
|
185
190
|
// TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
|
|
186
191
|
Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
|
|
187
|
-
resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle,
|
|
192
|
+
resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, {
|
|
193
|
+
...props,
|
|
188
194
|
theme
|
|
189
|
-
})
|
|
195
|
+
});
|
|
190
196
|
});
|
|
191
197
|
return overridesResolver(props, resolvedStyleOverrides);
|
|
192
198
|
});
|
|
193
199
|
}
|
|
194
200
|
if (componentName && !skipVariantsResolver) {
|
|
195
201
|
expressionsWithDefaultTheme.push(props => {
|
|
196
|
-
const theme = resolveTheme(
|
|
202
|
+
const theme = resolveTheme({
|
|
203
|
+
...props,
|
|
197
204
|
defaultTheme,
|
|
198
205
|
themeId
|
|
199
|
-
})
|
|
206
|
+
});
|
|
200
207
|
const themeVariants = theme?.components?.[componentName]?.variants;
|
|
201
208
|
return processStyleArg({
|
|
202
209
|
variants: themeVariants
|
|
203
|
-
},
|
|
210
|
+
}, {
|
|
211
|
+
...props,
|
|
204
212
|
theme
|
|
205
|
-
})
|
|
213
|
+
});
|
|
206
214
|
});
|
|
207
215
|
}
|
|
208
216
|
if (!skipSx) {
|