@mui/system 5.10.17 → 5.11.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/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +74 -0
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/Stack/Stack.d.ts +13 -13
- package/Stack/StackProps.d.ts +42 -42
- package/Stack/createStack.d.ts +21 -21
- package/Stack/index.d.ts +5 -5
- package/Stack/stackClasses.d.ts +8 -8
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +29 -29
- package/Unstable_Grid/index.d.ts +5 -5
- package/borders.js +12 -7
- package/breakpoints.js +2 -0
- package/compose.js +3 -0
- package/createBox.d.ts +0 -2
- package/createBox.js +2 -3
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +2 -3
- package/createTheme/createSpacing.d.ts +10 -10
- package/createTheme/createTheme.d.ts +5 -0
- package/createTheme/createTheme.js +9 -0
- package/cssGrid.js +8 -0
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +63 -63
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/borders.js +9 -6
- package/esm/breakpoints.js +2 -0
- package/esm/compose.js +3 -0
- package/esm/createBox.js +2 -3
- package/esm/createStyled.js +2 -3
- package/esm/createTheme/createTheme.js +9 -0
- package/esm/cssGrid.js +9 -0
- package/esm/index.js +1 -2
- package/esm/palette.js +4 -4
- package/esm/sizing.js +9 -9
- package/esm/spacing.js +2 -2
- package/esm/style.js +4 -1
- package/esm/styleFunctionSx/defaultSxConfig.js +284 -0
- package/esm/styleFunctionSx/extendSxProp.js +4 -2
- package/esm/styleFunctionSx/index.js +2 -1
- package/esm/styleFunctionSx/styleFunctionSx.js +45 -17
- package/index.d.ts +1 -2
- package/index.js +8 -9
- package/index.spec.d.ts +1 -1
- package/legacy/borders.js +9 -6
- package/legacy/breakpoints.js +2 -0
- package/legacy/compose.js +3 -0
- package/legacy/createBox.js +2 -4
- package/legacy/createStyled.js +2 -4
- package/legacy/createTheme/createTheme.js +9 -0
- package/legacy/cssGrid.js +9 -0
- package/legacy/index.js +2 -3
- package/legacy/palette.js +4 -4
- package/legacy/sizing.js +9 -9
- package/legacy/spacing.js +2 -2
- package/legacy/style.js +3 -2
- package/legacy/styleFunctionSx/defaultSxConfig.js +286 -0
- package/legacy/styleFunctionSx/extendSxProp.js +4 -2
- package/legacy/styleFunctionSx/index.js +2 -1
- package/legacy/styleFunctionSx/styleFunctionSx.js +44 -20
- package/modern/borders.js +9 -6
- package/modern/breakpoints.js +2 -0
- package/modern/compose.js +3 -0
- package/modern/createBox.js +2 -3
- package/modern/createStyled.js +2 -3
- package/modern/createTheme/createTheme.js +9 -0
- package/modern/cssGrid.js +9 -0
- package/modern/index.js +2 -3
- package/modern/palette.js +4 -4
- package/modern/sizing.js +9 -9
- package/modern/spacing.js +2 -2
- package/modern/style.js +4 -1
- package/modern/styleFunctionSx/defaultSxConfig.js +284 -0
- package/modern/styleFunctionSx/extendSxProp.js +3 -2
- package/modern/styleFunctionSx/index.js +2 -1
- package/modern/styleFunctionSx/styleFunctionSx.js +44 -17
- package/package.json +6 -6
- package/palette.js +5 -4
- package/sizing.js +12 -10
- package/spacing.js +4 -0
- package/style.d.ts +10 -8
- package/style.js +4 -1
- package/styleFunctionSx/defaultSxConfig.d.ts +20 -0
- package/styleFunctionSx/defaultSxConfig.js +291 -0
- package/styleFunctionSx/extendSxProp.js +4 -2
- package/styleFunctionSx/index.d.ts +4 -0
- package/styleFunctionSx/index.js +7 -0
- package/styleFunctionSx/styleFunctionSx.d.ts +2 -1
- package/styleFunctionSx/styleFunctionSx.js +45 -17
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
- package/esm/sx/index.js +0 -1
- package/esm/sx/sx.js +0 -10
- package/legacy/sx/index.js +0 -1
- package/legacy/sx/sx.js +0 -11
- package/modern/sx/index.js +0 -1
- package/modern/sx/sx.js +0 -10
- package/sx/index.d.ts +0 -1
- package/sx/index.js +0 -13
- package/sx/package.json +0 -6
- package/sx/sx.d.ts +0 -4
- package/sx/sx.js +0 -18
package/esm/sizing.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
3
|
import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
|
|
4
|
-
function
|
|
4
|
+
export function sizingTransform(value) {
|
|
5
5
|
return value <= 1 && value !== 0 ? `${value * 100}%` : value;
|
|
6
6
|
}
|
|
7
7
|
export const width = style({
|
|
8
8
|
prop: 'width',
|
|
9
|
-
transform
|
|
9
|
+
transform: sizingTransform
|
|
10
10
|
});
|
|
11
11
|
export const maxWidth = props => {
|
|
12
12
|
if (props.maxWidth !== undefined && props.maxWidth !== null) {
|
|
@@ -14,7 +14,7 @@ export const maxWidth = props => {
|
|
|
14
14
|
var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
|
|
15
15
|
const breakpoint = ((_props$theme = props.theme) == null ? void 0 : (_props$theme$breakpoi = _props$theme.breakpoints) == null ? void 0 : (_props$theme$breakpoi2 = _props$theme$breakpoi.values) == null ? void 0 : _props$theme$breakpoi2[propValue]) || breakpointsValues[propValue];
|
|
16
16
|
return {
|
|
17
|
-
maxWidth: breakpoint ||
|
|
17
|
+
maxWidth: breakpoint || sizingTransform(propValue)
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
|
|
@@ -24,29 +24,29 @@ export const maxWidth = props => {
|
|
|
24
24
|
maxWidth.filterProps = ['maxWidth'];
|
|
25
25
|
export const minWidth = style({
|
|
26
26
|
prop: 'minWidth',
|
|
27
|
-
transform
|
|
27
|
+
transform: sizingTransform
|
|
28
28
|
});
|
|
29
29
|
export const height = style({
|
|
30
30
|
prop: 'height',
|
|
31
|
-
transform
|
|
31
|
+
transform: sizingTransform
|
|
32
32
|
});
|
|
33
33
|
export const maxHeight = style({
|
|
34
34
|
prop: 'maxHeight',
|
|
35
|
-
transform
|
|
35
|
+
transform: sizingTransform
|
|
36
36
|
});
|
|
37
37
|
export const minHeight = style({
|
|
38
38
|
prop: 'minHeight',
|
|
39
|
-
transform
|
|
39
|
+
transform: sizingTransform
|
|
40
40
|
});
|
|
41
41
|
export const sizeWidth = style({
|
|
42
42
|
prop: 'size',
|
|
43
43
|
cssProperty: 'width',
|
|
44
|
-
transform
|
|
44
|
+
transform: sizingTransform
|
|
45
45
|
});
|
|
46
46
|
export const sizeHeight = style({
|
|
47
47
|
prop: 'size',
|
|
48
48
|
cssProperty: 'height',
|
|
49
|
-
transform
|
|
49
|
+
transform: sizingTransform
|
|
50
50
|
});
|
|
51
51
|
export const boxSizing = style({
|
|
52
52
|
prop: 'boxSizing'
|
package/esm/spacing.js
CHANGED
|
@@ -39,8 +39,8 @@ const getCssProperties = memoize(prop => {
|
|
|
39
39
|
const direction = directions[b] || '';
|
|
40
40
|
return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
|
|
41
41
|
});
|
|
42
|
-
const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
|
|
43
|
-
const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
42
|
+
export const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
|
|
43
|
+
export const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
44
44
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
45
45
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
46
46
|
var _getPath;
|
package/esm/style.js
CHANGED
|
@@ -30,7 +30,7 @@ export function getStyleValue(themeMapping, transform, propValueFinal, userValue
|
|
|
30
30
|
value = getPath(themeMapping, propValueFinal) || userValue;
|
|
31
31
|
}
|
|
32
32
|
if (transform) {
|
|
33
|
-
value = transform(value, userValue);
|
|
33
|
+
value = transform(value, userValue, themeMapping);
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
@@ -41,6 +41,9 @@ function style(options) {
|
|
|
41
41
|
themeKey,
|
|
42
42
|
transform
|
|
43
43
|
} = options;
|
|
44
|
+
|
|
45
|
+
// false positive
|
|
46
|
+
// eslint-disable-next-line react/function-component-definition
|
|
44
47
|
const fn = props => {
|
|
45
48
|
if (props[prop] == null) {
|
|
46
49
|
return null;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { padding, margin } from '../spacing';
|
|
2
|
+
import { borderRadius, borderTransform } from '../borders';
|
|
3
|
+
import { gap, rowGap, columnGap } from '../cssGrid';
|
|
4
|
+
import { paletteTransform } from '../palette';
|
|
5
|
+
import { maxWidth, sizingTransform } from '../sizing';
|
|
6
|
+
const defaultSxConfig = {
|
|
7
|
+
// borders
|
|
8
|
+
border: {
|
|
9
|
+
themeKey: 'borders',
|
|
10
|
+
transform: borderTransform
|
|
11
|
+
},
|
|
12
|
+
borderTop: {
|
|
13
|
+
themeKey: 'borders',
|
|
14
|
+
transform: borderTransform
|
|
15
|
+
},
|
|
16
|
+
borderRight: {
|
|
17
|
+
themeKey: 'borders',
|
|
18
|
+
transform: borderTransform
|
|
19
|
+
},
|
|
20
|
+
borderBottom: {
|
|
21
|
+
themeKey: 'borders',
|
|
22
|
+
transform: borderTransform
|
|
23
|
+
},
|
|
24
|
+
borderLeft: {
|
|
25
|
+
themeKey: 'borders',
|
|
26
|
+
transform: borderTransform
|
|
27
|
+
},
|
|
28
|
+
borderColor: {
|
|
29
|
+
themeKey: 'palette'
|
|
30
|
+
},
|
|
31
|
+
borderTopColor: {
|
|
32
|
+
themeKey: 'palette'
|
|
33
|
+
},
|
|
34
|
+
borderRightColor: {
|
|
35
|
+
themeKey: 'palette'
|
|
36
|
+
},
|
|
37
|
+
borderBottomColor: {
|
|
38
|
+
themeKey: 'palette'
|
|
39
|
+
},
|
|
40
|
+
borderLeftColor: {
|
|
41
|
+
themeKey: 'palette'
|
|
42
|
+
},
|
|
43
|
+
borderRadius: {
|
|
44
|
+
themeKey: 'shape.borderRadius',
|
|
45
|
+
style: borderRadius
|
|
46
|
+
},
|
|
47
|
+
// palette
|
|
48
|
+
color: {
|
|
49
|
+
themeKey: 'palette',
|
|
50
|
+
transform: paletteTransform
|
|
51
|
+
},
|
|
52
|
+
bgcolor: {
|
|
53
|
+
themeKey: 'palette',
|
|
54
|
+
cssProperty: 'backgroundColor',
|
|
55
|
+
transform: paletteTransform
|
|
56
|
+
},
|
|
57
|
+
backgroundColor: {
|
|
58
|
+
themeKey: 'palette',
|
|
59
|
+
transform: paletteTransform
|
|
60
|
+
},
|
|
61
|
+
// spacing
|
|
62
|
+
p: {
|
|
63
|
+
style: padding
|
|
64
|
+
},
|
|
65
|
+
pt: {
|
|
66
|
+
style: padding
|
|
67
|
+
},
|
|
68
|
+
pr: {
|
|
69
|
+
style: padding
|
|
70
|
+
},
|
|
71
|
+
pb: {
|
|
72
|
+
style: padding
|
|
73
|
+
},
|
|
74
|
+
pl: {
|
|
75
|
+
style: padding
|
|
76
|
+
},
|
|
77
|
+
px: {
|
|
78
|
+
style: padding
|
|
79
|
+
},
|
|
80
|
+
py: {
|
|
81
|
+
style: padding
|
|
82
|
+
},
|
|
83
|
+
padding: {
|
|
84
|
+
style: padding
|
|
85
|
+
},
|
|
86
|
+
paddingTop: {
|
|
87
|
+
style: padding
|
|
88
|
+
},
|
|
89
|
+
paddingRight: {
|
|
90
|
+
style: padding
|
|
91
|
+
},
|
|
92
|
+
paddingBottom: {
|
|
93
|
+
style: padding
|
|
94
|
+
},
|
|
95
|
+
paddingLeft: {
|
|
96
|
+
style: padding
|
|
97
|
+
},
|
|
98
|
+
paddingX: {
|
|
99
|
+
style: padding
|
|
100
|
+
},
|
|
101
|
+
paddingY: {
|
|
102
|
+
style: padding
|
|
103
|
+
},
|
|
104
|
+
paddingInline: {
|
|
105
|
+
style: padding
|
|
106
|
+
},
|
|
107
|
+
paddingInlineStart: {
|
|
108
|
+
style: padding
|
|
109
|
+
},
|
|
110
|
+
paddingInlineEnd: {
|
|
111
|
+
style: padding
|
|
112
|
+
},
|
|
113
|
+
paddingBlock: {
|
|
114
|
+
style: padding
|
|
115
|
+
},
|
|
116
|
+
paddingBlockStart: {
|
|
117
|
+
style: padding
|
|
118
|
+
},
|
|
119
|
+
paddingBlockEnd: {
|
|
120
|
+
style: padding
|
|
121
|
+
},
|
|
122
|
+
m: {
|
|
123
|
+
style: margin
|
|
124
|
+
},
|
|
125
|
+
mt: {
|
|
126
|
+
style: margin
|
|
127
|
+
},
|
|
128
|
+
mr: {
|
|
129
|
+
style: margin
|
|
130
|
+
},
|
|
131
|
+
mb: {
|
|
132
|
+
style: margin
|
|
133
|
+
},
|
|
134
|
+
ml: {
|
|
135
|
+
style: margin
|
|
136
|
+
},
|
|
137
|
+
mx: {
|
|
138
|
+
style: margin
|
|
139
|
+
},
|
|
140
|
+
my: {
|
|
141
|
+
style: margin
|
|
142
|
+
},
|
|
143
|
+
margin: {
|
|
144
|
+
style: margin
|
|
145
|
+
},
|
|
146
|
+
marginTop: {
|
|
147
|
+
style: margin
|
|
148
|
+
},
|
|
149
|
+
marginRight: {
|
|
150
|
+
style: margin
|
|
151
|
+
},
|
|
152
|
+
marginBottom: {
|
|
153
|
+
style: margin
|
|
154
|
+
},
|
|
155
|
+
marginLeft: {
|
|
156
|
+
style: margin
|
|
157
|
+
},
|
|
158
|
+
marginX: {
|
|
159
|
+
style: margin
|
|
160
|
+
},
|
|
161
|
+
marginY: {
|
|
162
|
+
style: margin
|
|
163
|
+
},
|
|
164
|
+
marginInline: {
|
|
165
|
+
style: margin
|
|
166
|
+
},
|
|
167
|
+
marginInlineStart: {
|
|
168
|
+
style: margin
|
|
169
|
+
},
|
|
170
|
+
marginInlineEnd: {
|
|
171
|
+
style: margin
|
|
172
|
+
},
|
|
173
|
+
marginBlock: {
|
|
174
|
+
style: margin
|
|
175
|
+
},
|
|
176
|
+
marginBlockStart: {
|
|
177
|
+
style: margin
|
|
178
|
+
},
|
|
179
|
+
marginBlockEnd: {
|
|
180
|
+
style: margin
|
|
181
|
+
},
|
|
182
|
+
// display
|
|
183
|
+
displayPrint: {
|
|
184
|
+
cssProperty: false,
|
|
185
|
+
transform: value => ({
|
|
186
|
+
'@media print': {
|
|
187
|
+
display: value
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
},
|
|
191
|
+
display: {},
|
|
192
|
+
overflow: {},
|
|
193
|
+
textOverflow: {},
|
|
194
|
+
visibility: {},
|
|
195
|
+
whiteSpace: {},
|
|
196
|
+
// flexbox
|
|
197
|
+
flexBasis: {},
|
|
198
|
+
flexDirection: {},
|
|
199
|
+
flexWrap: {},
|
|
200
|
+
justifyContent: {},
|
|
201
|
+
alignItems: {},
|
|
202
|
+
alignContent: {},
|
|
203
|
+
order: {},
|
|
204
|
+
flex: {},
|
|
205
|
+
flexGrow: {},
|
|
206
|
+
flexShrink: {},
|
|
207
|
+
alignSelf: {},
|
|
208
|
+
justifyItems: {},
|
|
209
|
+
justifySelf: {},
|
|
210
|
+
// grid
|
|
211
|
+
gap: {
|
|
212
|
+
style: gap
|
|
213
|
+
},
|
|
214
|
+
rowGap: {
|
|
215
|
+
style: rowGap
|
|
216
|
+
},
|
|
217
|
+
columnGap: {
|
|
218
|
+
style: columnGap
|
|
219
|
+
},
|
|
220
|
+
gridColumn: {},
|
|
221
|
+
gridRow: {},
|
|
222
|
+
gridAutoFlow: {},
|
|
223
|
+
gridAutoColumns: {},
|
|
224
|
+
gridAutoRows: {},
|
|
225
|
+
gridTemplateColumns: {},
|
|
226
|
+
gridTemplateRows: {},
|
|
227
|
+
gridTemplateAreas: {},
|
|
228
|
+
gridArea: {},
|
|
229
|
+
// positions
|
|
230
|
+
position: {},
|
|
231
|
+
zIndex: {
|
|
232
|
+
themeKey: 'zIndex'
|
|
233
|
+
},
|
|
234
|
+
top: {},
|
|
235
|
+
right: {},
|
|
236
|
+
bottom: {},
|
|
237
|
+
left: {},
|
|
238
|
+
// shadows
|
|
239
|
+
boxShadow: {
|
|
240
|
+
themeKey: 'shadows'
|
|
241
|
+
},
|
|
242
|
+
// sizing
|
|
243
|
+
width: {
|
|
244
|
+
transform: sizingTransform
|
|
245
|
+
},
|
|
246
|
+
maxWidth: {
|
|
247
|
+
style: maxWidth
|
|
248
|
+
},
|
|
249
|
+
minWidth: {
|
|
250
|
+
transform: sizingTransform
|
|
251
|
+
},
|
|
252
|
+
height: {
|
|
253
|
+
transform: sizingTransform
|
|
254
|
+
},
|
|
255
|
+
maxHeight: {
|
|
256
|
+
transform: sizingTransform
|
|
257
|
+
},
|
|
258
|
+
minHeight: {
|
|
259
|
+
transform: sizingTransform
|
|
260
|
+
},
|
|
261
|
+
boxSizing: {},
|
|
262
|
+
// typography
|
|
263
|
+
fontFamily: {
|
|
264
|
+
themeKey: 'typography'
|
|
265
|
+
},
|
|
266
|
+
fontSize: {
|
|
267
|
+
themeKey: 'typography'
|
|
268
|
+
},
|
|
269
|
+
fontStyle: {
|
|
270
|
+
themeKey: 'typography'
|
|
271
|
+
},
|
|
272
|
+
fontWeight: {
|
|
273
|
+
themeKey: 'typography'
|
|
274
|
+
},
|
|
275
|
+
letterSpacing: {},
|
|
276
|
+
textTransform: {},
|
|
277
|
+
lineHeight: {},
|
|
278
|
+
textAlign: {},
|
|
279
|
+
typography: {
|
|
280
|
+
cssProperty: false,
|
|
281
|
+
themeKey: 'typography'
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
export default defaultSxConfig;
|
|
@@ -2,14 +2,16 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["sx"];
|
|
4
4
|
import { isPlainObject } from '@mui/utils';
|
|
5
|
-
import
|
|
5
|
+
import defaultSxConfig from './defaultSxConfig';
|
|
6
6
|
const splitProps = props => {
|
|
7
|
+
var _props$theme$unstable, _props$theme;
|
|
7
8
|
const result = {
|
|
8
9
|
systemProps: {},
|
|
9
10
|
otherProps: {}
|
|
10
11
|
};
|
|
12
|
+
const config = (_props$theme$unstable = props == null ? void 0 : (_props$theme = props.theme) == null ? void 0 : _props$theme.unstable_sxConfig) != null ? _props$theme$unstable : defaultSxConfig;
|
|
11
13
|
Object.keys(props).forEach(prop => {
|
|
12
|
-
if (
|
|
14
|
+
if (config[prop]) {
|
|
13
15
|
result.systemProps[prop] = props[prop];
|
|
14
16
|
} else {
|
|
15
17
|
result.otherProps[prop] = props[prop];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default } from './styleFunctionSx';
|
|
2
2
|
export { unstable_createStyleFunctionSx } from './styleFunctionSx';
|
|
3
|
-
export { default as extendSxProp } from './extendSxProp';
|
|
3
|
+
export { default as extendSxProp } from './extendSxProp';
|
|
4
|
+
export { default as unstable_defaultSxConfig } from './defaultSxConfig';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { unstable_capitalize as capitalize } from '@mui/utils';
|
|
1
2
|
import merge from '../merge';
|
|
2
|
-
import {
|
|
3
|
+
import { getPath, getStyleValue as getValue } from '../style';
|
|
3
4
|
import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
|
|
5
|
+
import defaultSxConfig from './defaultSxConfig';
|
|
4
6
|
function objectsHaveSameKeys(...objects) {
|
|
5
7
|
const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
|
|
6
8
|
const union = new Set(allKeys);
|
|
@@ -11,24 +13,48 @@ function callIfFn(maybeFn, arg) {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
|
-
export function unstable_createStyleFunctionSx(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
return acc;
|
|
20
|
-
}, {});
|
|
21
|
-
function getThemeValue(prop, value, theme) {
|
|
22
|
-
const inputProps = {
|
|
23
|
-
[prop]: value,
|
|
16
|
+
export function unstable_createStyleFunctionSx() {
|
|
17
|
+
function getThemeValue(prop, val, theme, config) {
|
|
18
|
+
const props = {
|
|
19
|
+
[prop]: val,
|
|
24
20
|
theme
|
|
25
21
|
};
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const options = config[prop];
|
|
23
|
+
if (!options) {
|
|
24
|
+
return {
|
|
25
|
+
[prop]: val
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
cssProperty = prop,
|
|
30
|
+
themeKey,
|
|
31
|
+
transform,
|
|
32
|
+
style
|
|
33
|
+
} = options;
|
|
34
|
+
if (val == null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const themeMapping = getPath(theme, themeKey) || {};
|
|
38
|
+
if (style) {
|
|
39
|
+
return style(props);
|
|
40
|
+
}
|
|
41
|
+
const styleFromPropValue = propValueFinal => {
|
|
42
|
+
let value = getValue(themeMapping, transform, propValueFinal);
|
|
43
|
+
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
44
|
+
// Haven't found value
|
|
45
|
+
value = getValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
|
|
46
|
+
}
|
|
47
|
+
if (cssProperty === false) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
[cssProperty]: value
|
|
52
|
+
};
|
|
29
53
|
};
|
|
54
|
+
return handleBreakpoints(props, val, styleFromPropValue);
|
|
30
55
|
}
|
|
31
56
|
function styleFunctionSx(props) {
|
|
57
|
+
var _theme$unstable_sxCon;
|
|
32
58
|
const {
|
|
33
59
|
sx,
|
|
34
60
|
theme = {}
|
|
@@ -37,6 +63,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
37
63
|
return null; // Emotion & styled-components will neglect null
|
|
38
64
|
}
|
|
39
65
|
|
|
66
|
+
const config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : defaultSxConfig;
|
|
67
|
+
|
|
40
68
|
/*
|
|
41
69
|
* Receive `sxInput` as object or callback
|
|
42
70
|
* and then recursively check keys & values to create media query object styles.
|
|
@@ -60,8 +88,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
60
88
|
const value = callIfFn(sxObject[styleKey], theme);
|
|
61
89
|
if (value !== null && value !== undefined) {
|
|
62
90
|
if (typeof value === 'object') {
|
|
63
|
-
if (
|
|
64
|
-
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
91
|
+
if (config[styleKey]) {
|
|
92
|
+
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
|
65
93
|
} else {
|
|
66
94
|
const breakpointsValues = handleBreakpoints({
|
|
67
95
|
theme
|
|
@@ -78,7 +106,7 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
78
106
|
}
|
|
79
107
|
}
|
|
80
108
|
} else {
|
|
81
|
-
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
109
|
+
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
|
82
110
|
}
|
|
83
111
|
}
|
|
84
112
|
});
|
package/index.d.ts
CHANGED
|
@@ -119,11 +119,10 @@ export {
|
|
|
119
119
|
default as unstable_styleFunctionSx,
|
|
120
120
|
unstable_createStyleFunctionSx,
|
|
121
121
|
extendSxProp as unstable_extendSxProp,
|
|
122
|
+
unstable_defaultSxConfig,
|
|
122
123
|
} from './styleFunctionSx';
|
|
123
124
|
export * from './styleFunctionSx';
|
|
124
125
|
|
|
125
|
-
export { default as experimental_sx } from './sx';
|
|
126
|
-
|
|
127
126
|
export { default as Box } from './Box';
|
|
128
127
|
export * from './Box';
|
|
129
128
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.11.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.
|
|
@@ -35,7 +35,7 @@ var _exportNames = {
|
|
|
35
35
|
unstable_styleFunctionSx: true,
|
|
36
36
|
unstable_createStyleFunctionSx: true,
|
|
37
37
|
unstable_extendSxProp: true,
|
|
38
|
-
|
|
38
|
+
unstable_defaultSxConfig: true,
|
|
39
39
|
unstable_getThemeValue: true,
|
|
40
40
|
Box: true,
|
|
41
41
|
createBox: true,
|
|
@@ -166,12 +166,6 @@ Object.defineProperty(exports, "display", {
|
|
|
166
166
|
return _display.default;
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
|
-
Object.defineProperty(exports, "experimental_sx", {
|
|
170
|
-
enumerable: true,
|
|
171
|
-
get: function () {
|
|
172
|
-
return _sx.default;
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
169
|
Object.defineProperty(exports, "flexbox", {
|
|
176
170
|
enumerable: true,
|
|
177
171
|
get: function () {
|
|
@@ -298,6 +292,12 @@ Object.defineProperty(exports, "unstable_createStyleFunctionSx", {
|
|
|
298
292
|
return _styleFunctionSx.unstable_createStyleFunctionSx;
|
|
299
293
|
}
|
|
300
294
|
});
|
|
295
|
+
Object.defineProperty(exports, "unstable_defaultSxConfig", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
get: function () {
|
|
298
|
+
return _styleFunctionSx.unstable_defaultSxConfig;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
301
|
Object.defineProperty(exports, "unstable_extendSxProp", {
|
|
302
302
|
enumerable: true,
|
|
303
303
|
get: function () {
|
|
@@ -443,7 +443,6 @@ Object.keys(_typography).forEach(function (key) {
|
|
|
443
443
|
});
|
|
444
444
|
});
|
|
445
445
|
var _styleFunctionSx = _interopRequireWildcard(require("./styleFunctionSx"));
|
|
446
|
-
var _sx = _interopRequireDefault(require("./sx"));
|
|
447
446
|
var _getThemeValue = _interopRequireDefault(require("./getThemeValue"));
|
|
448
447
|
var _Box = _interopRequireDefault(require("./Box"));
|
|
449
448
|
var _createBox = _interopRequireDefault(require("./createBox"));
|
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/legacy/borders.js
CHANGED
|
@@ -3,7 +3,7 @@ import style from './style';
|
|
|
3
3
|
import compose from './compose';
|
|
4
4
|
import { createUnaryUnit, getValue } from './spacing';
|
|
5
5
|
import { handleBreakpoints } from './breakpoints';
|
|
6
|
-
function
|
|
6
|
+
export function borderTransform(value) {
|
|
7
7
|
if (typeof value !== 'number') {
|
|
8
8
|
return value;
|
|
9
9
|
}
|
|
@@ -12,27 +12,27 @@ function getBorder(value) {
|
|
|
12
12
|
export var border = style({
|
|
13
13
|
prop: 'border',
|
|
14
14
|
themeKey: 'borders',
|
|
15
|
-
transform:
|
|
15
|
+
transform: borderTransform
|
|
16
16
|
});
|
|
17
17
|
export var borderTop = style({
|
|
18
18
|
prop: 'borderTop',
|
|
19
19
|
themeKey: 'borders',
|
|
20
|
-
transform:
|
|
20
|
+
transform: borderTransform
|
|
21
21
|
});
|
|
22
22
|
export var borderRight = style({
|
|
23
23
|
prop: 'borderRight',
|
|
24
24
|
themeKey: 'borders',
|
|
25
|
-
transform:
|
|
25
|
+
transform: borderTransform
|
|
26
26
|
});
|
|
27
27
|
export var borderBottom = style({
|
|
28
28
|
prop: 'borderBottom',
|
|
29
29
|
themeKey: 'borders',
|
|
30
|
-
transform:
|
|
30
|
+
transform: borderTransform
|
|
31
31
|
});
|
|
32
32
|
export var borderLeft = style({
|
|
33
33
|
prop: 'borderLeft',
|
|
34
34
|
themeKey: 'borders',
|
|
35
|
-
transform:
|
|
35
|
+
transform: borderTransform
|
|
36
36
|
});
|
|
37
37
|
export var borderColor = style({
|
|
38
38
|
prop: 'borderColor',
|
|
@@ -54,6 +54,9 @@ export var borderLeftColor = style({
|
|
|
54
54
|
prop: 'borderLeftColor',
|
|
55
55
|
themeKey: 'palette'
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
// false positive
|
|
59
|
+
// eslint-disable-next-line react/function-component-definition
|
|
57
60
|
export var borderRadius = function borderRadius(props) {
|
|
58
61
|
if (props.borderRadius !== undefined && props.borderRadius !== null) {
|
|
59
62
|
var transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius');
|
package/legacy/breakpoints.js
CHANGED
|
@@ -54,6 +54,8 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
|
|
|
54
54
|
return output;
|
|
55
55
|
}
|
|
56
56
|
function breakpoints(styleFunction) {
|
|
57
|
+
// false positive
|
|
58
|
+
// eslint-disable-next-line react/function-component-definition
|
|
57
59
|
var newStyleFunction = function newStyleFunction(props) {
|
|
58
60
|
var theme = props.theme || {};
|
|
59
61
|
var base = styleFunction(props);
|
package/legacy/compose.js
CHANGED
|
@@ -10,6 +10,9 @@ function compose() {
|
|
|
10
10
|
});
|
|
11
11
|
return acc;
|
|
12
12
|
}, {});
|
|
13
|
+
|
|
14
|
+
// false positive
|
|
15
|
+
// eslint-disable-next-line react/function-component-definition
|
|
13
16
|
var fn = function fn(props) {
|
|
14
17
|
return Object.keys(props).reduce(function (acc, prop) {
|
|
15
18
|
if (handlers[prop]) {
|
package/legacy/createBox.js
CHANGED
|
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import styled from '@mui/styled-engine';
|
|
6
|
-
import
|
|
6
|
+
import styleFunctionSx, { extendSxProp } from './styleFunctionSx';
|
|
7
7
|
import useTheme from './useTheme';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export default function createBox() {
|
|
@@ -11,9 +11,7 @@ export default function createBox() {
|
|
|
11
11
|
var defaultTheme = options.defaultTheme,
|
|
12
12
|
_options$defaultClass = options.defaultClassName,
|
|
13
13
|
defaultClassName = _options$defaultClass === void 0 ? 'MuiBox-root' : _options$defaultClass,
|
|
14
|
-
generateClassName = options.generateClassName
|
|
15
|
-
_options$styleFunctio = options.styleFunctionSx,
|
|
16
|
-
styleFunctionSx = _options$styleFunctio === void 0 ? defaultStyleFunctionSx : _options$styleFunctio;
|
|
14
|
+
generateClassName = options.generateClassName;
|
|
17
15
|
var BoxRoot = styled('div', {
|
|
18
16
|
shouldForwardProp: function shouldForwardProp(prop) {
|
|
19
17
|
return prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
package/legacy/createStyled.js
CHANGED
|
@@ -7,7 +7,7 @@ import styledEngineStyled, { internal_processStyles as processStyles } from '@mu
|
|
|
7
7
|
import { getDisplayName } from '@mui/utils';
|
|
8
8
|
import createTheme from './createTheme';
|
|
9
9
|
import propsToClassKey from './propsToClassKey';
|
|
10
|
-
import
|
|
10
|
+
import styleFunctionSx from './styleFunctionSx';
|
|
11
11
|
function isEmpty(obj) {
|
|
12
12
|
return Object.keys(obj).length === 0;
|
|
13
13
|
}
|
|
@@ -75,9 +75,7 @@ export default function createStyled() {
|
|
|
75
75
|
_input$rootShouldForw = input.rootShouldForwardProp,
|
|
76
76
|
rootShouldForwardProp = _input$rootShouldForw === void 0 ? shouldForwardProp : _input$rootShouldForw,
|
|
77
77
|
_input$slotShouldForw = input.slotShouldForwardProp,
|
|
78
|
-
slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw
|
|
79
|
-
_input$styleFunctionS = input.styleFunctionSx,
|
|
80
|
-
styleFunctionSx = _input$styleFunctionS === void 0 ? defaultStyleFunctionSx : _input$styleFunctionS;
|
|
78
|
+
slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw;
|
|
81
79
|
var systemSx = function systemSx(props) {
|
|
82
80
|
var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
83
81
|
return styleFunctionSx(_extends({}, props, {
|