@mui/system 5.10.16 → 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/CHANGELOG.md +148 -0
- package/borders.js +12 -7
- package/breakpoints.js +2 -0
- package/colorManipulator.d.ts +10 -0
- package/colorManipulator.js +57 -1
- package/compose.js +3 -0
- package/createBox.d.ts +0 -2
- package/createBox.js +2 -3
- package/createStyled.js +2 -3
- package/createTheme/createTheme.d.ts +5 -0
- package/createTheme/createTheme.js +9 -0
- package/cssGrid.js +8 -0
- package/cssVars/createCssVarsProvider.d.ts +54 -1
- package/cssVars/createCssVarsProvider.js +47 -13
- package/esm/borders.js +9 -6
- package/esm/breakpoints.js +2 -0
- package/esm/colorManipulator.js +50 -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/cssVars/createCssVarsProvider.js +47 -13
- 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/legacy/borders.js +9 -6
- package/legacy/breakpoints.js +2 -0
- package/legacy/colorManipulator.js +50 -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/cssVars/createCssVarsProvider.js +47 -11
- 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/colorManipulator.js +50 -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/cssVars/createCssVarsProvider.js +47 -13
- 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/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
|
@@ -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,15 @@ 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
7
|
const result = {
|
|
8
8
|
systemProps: {},
|
|
9
9
|
otherProps: {}
|
|
10
10
|
};
|
|
11
|
+
const config = props?.theme?.unstable_sxConfig ?? defaultSxConfig;
|
|
11
12
|
Object.keys(props).forEach(prop => {
|
|
12
|
-
if (
|
|
13
|
+
if (config[prop]) {
|
|
13
14
|
result.systemProps[prop] = props[prop];
|
|
14
15
|
} else {
|
|
15
16
|
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,22 +13,45 @@ 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) {
|
|
32
57
|
const {
|
|
@@ -37,6 +62,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
37
62
|
return null; // Emotion & styled-components will neglect null
|
|
38
63
|
}
|
|
39
64
|
|
|
65
|
+
const config = theme.unstable_sxConfig ?? defaultSxConfig;
|
|
66
|
+
|
|
40
67
|
/*
|
|
41
68
|
* Receive `sxInput` as object or callback
|
|
42
69
|
* and then recursively check keys & values to create media query object styles.
|
|
@@ -60,8 +87,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
60
87
|
const value = callIfFn(sxObject[styleKey], theme);
|
|
61
88
|
if (value !== null && value !== undefined) {
|
|
62
89
|
if (typeof value === 'object') {
|
|
63
|
-
if (
|
|
64
|
-
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
90
|
+
if (config[styleKey]) {
|
|
91
|
+
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
|
65
92
|
} else {
|
|
66
93
|
const breakpointsValues = handleBreakpoints({
|
|
67
94
|
theme
|
|
@@ -78,7 +105,7 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
78
105
|
}
|
|
79
106
|
}
|
|
80
107
|
} else {
|
|
81
|
-
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
108
|
+
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
|
82
109
|
}
|
|
83
110
|
}
|
|
84
111
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@babel/runtime": "^7.20.
|
|
47
|
-
"@mui/private-theming": "^5.
|
|
48
|
-
"@mui/styled-engine": "^5.
|
|
49
|
-
"@mui/types": "^7.2.
|
|
50
|
-
"@mui/utils": "^5.
|
|
46
|
+
"@babel/runtime": "^7.20.6",
|
|
47
|
+
"@mui/private-theming": "^5.11.0",
|
|
48
|
+
"@mui/styled-engine": "^5.11.0",
|
|
49
|
+
"@mui/types": "^7.2.3",
|
|
50
|
+
"@mui/utils": "^5.11.0",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.1",
|
|
53
53
|
"prop-types": "^15.8.1"
|
package/palette.js
CHANGED
|
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.color = exports.bgcolor = exports.backgroundColor = void 0;
|
|
8
|
+
exports.paletteTransform = paletteTransform;
|
|
8
9
|
var _style = _interopRequireDefault(require("./style"));
|
|
9
10
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
10
|
-
function
|
|
11
|
+
function paletteTransform(value, userValue) {
|
|
11
12
|
if (userValue === 'grey') {
|
|
12
13
|
return userValue;
|
|
13
14
|
}
|
|
@@ -16,20 +17,20 @@ function transform(value, userValue) {
|
|
|
16
17
|
const color = (0, _style.default)({
|
|
17
18
|
prop: 'color',
|
|
18
19
|
themeKey: 'palette',
|
|
19
|
-
transform
|
|
20
|
+
transform: paletteTransform
|
|
20
21
|
});
|
|
21
22
|
exports.color = color;
|
|
22
23
|
const bgcolor = (0, _style.default)({
|
|
23
24
|
prop: 'bgcolor',
|
|
24
25
|
cssProperty: 'backgroundColor',
|
|
25
26
|
themeKey: 'palette',
|
|
26
|
-
transform
|
|
27
|
+
transform: paletteTransform
|
|
27
28
|
});
|
|
28
29
|
exports.bgcolor = bgcolor;
|
|
29
30
|
const backgroundColor = (0, _style.default)({
|
|
30
31
|
prop: 'backgroundColor',
|
|
31
32
|
themeKey: 'palette',
|
|
32
|
-
transform
|
|
33
|
+
transform: paletteTransform
|
|
33
34
|
});
|
|
34
35
|
exports.backgroundColor = backgroundColor;
|
|
35
36
|
const palette = (0, _compose.default)(color, bgcolor, backgroundColor);
|
package/sizing.js
CHANGED
|
@@ -4,16 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.sizeWidth = exports.sizeHeight = exports.minWidth = exports.minHeight = exports.maxWidth = exports.maxHeight = exports.height = exports.default = exports.boxSizing = void 0;
|
|
8
|
+
exports.sizingTransform = sizingTransform;
|
|
9
|
+
exports.width = void 0;
|
|
8
10
|
var _style = _interopRequireDefault(require("./style"));
|
|
9
11
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
10
12
|
var _breakpoints = require("./breakpoints");
|
|
11
|
-
function
|
|
13
|
+
function sizingTransform(value) {
|
|
12
14
|
return value <= 1 && value !== 0 ? `${value * 100}%` : value;
|
|
13
15
|
}
|
|
14
16
|
const width = (0, _style.default)({
|
|
15
17
|
prop: 'width',
|
|
16
|
-
transform
|
|
18
|
+
transform: sizingTransform
|
|
17
19
|
});
|
|
18
20
|
exports.width = width;
|
|
19
21
|
const maxWidth = props => {
|
|
@@ -22,7 +24,7 @@ const maxWidth = props => {
|
|
|
22
24
|
var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
|
|
23
25
|
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]) || _breakpoints.values[propValue];
|
|
24
26
|
return {
|
|
25
|
-
maxWidth: breakpoint ||
|
|
27
|
+
maxWidth: breakpoint || sizingTransform(propValue)
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
30
|
return (0, _breakpoints.handleBreakpoints)(props, props.maxWidth, styleFromPropValue);
|
|
@@ -33,34 +35,34 @@ exports.maxWidth = maxWidth;
|
|
|
33
35
|
maxWidth.filterProps = ['maxWidth'];
|
|
34
36
|
const minWidth = (0, _style.default)({
|
|
35
37
|
prop: 'minWidth',
|
|
36
|
-
transform
|
|
38
|
+
transform: sizingTransform
|
|
37
39
|
});
|
|
38
40
|
exports.minWidth = minWidth;
|
|
39
41
|
const height = (0, _style.default)({
|
|
40
42
|
prop: 'height',
|
|
41
|
-
transform
|
|
43
|
+
transform: sizingTransform
|
|
42
44
|
});
|
|
43
45
|
exports.height = height;
|
|
44
46
|
const maxHeight = (0, _style.default)({
|
|
45
47
|
prop: 'maxHeight',
|
|
46
|
-
transform
|
|
48
|
+
transform: sizingTransform
|
|
47
49
|
});
|
|
48
50
|
exports.maxHeight = maxHeight;
|
|
49
51
|
const minHeight = (0, _style.default)({
|
|
50
52
|
prop: 'minHeight',
|
|
51
|
-
transform
|
|
53
|
+
transform: sizingTransform
|
|
52
54
|
});
|
|
53
55
|
exports.minHeight = minHeight;
|
|
54
56
|
const sizeWidth = (0, _style.default)({
|
|
55
57
|
prop: 'size',
|
|
56
58
|
cssProperty: 'width',
|
|
57
|
-
transform
|
|
59
|
+
transform: sizingTransform
|
|
58
60
|
});
|
|
59
61
|
exports.sizeWidth = sizeWidth;
|
|
60
62
|
const sizeHeight = (0, _style.default)({
|
|
61
63
|
prop: 'size',
|
|
62
64
|
cssProperty: 'height',
|
|
63
|
-
transform
|
|
65
|
+
transform: sizingTransform
|
|
64
66
|
});
|
|
65
67
|
exports.sizeHeight = sizeHeight;
|
|
66
68
|
const boxSizing = (0, _style.default)({
|
package/spacing.js
CHANGED
|
@@ -10,7 +10,9 @@ exports.default = void 0;
|
|
|
10
10
|
exports.getStyleFromPropValue = getStyleFromPropValue;
|
|
11
11
|
exports.getValue = getValue;
|
|
12
12
|
exports.margin = margin;
|
|
13
|
+
exports.marginKeys = void 0;
|
|
13
14
|
exports.padding = padding;
|
|
15
|
+
exports.paddingKeys = void 0;
|
|
14
16
|
var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
|
|
15
17
|
var _breakpoints = require("./breakpoints");
|
|
16
18
|
var _style = require("./style");
|
|
@@ -53,7 +55,9 @@ const getCssProperties = (0, _memoize.default)(prop => {
|
|
|
53
55
|
return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
|
|
54
56
|
});
|
|
55
57
|
const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
|
|
58
|
+
exports.marginKeys = marginKeys;
|
|
56
59
|
const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
60
|
+
exports.paddingKeys = paddingKeys;
|
|
57
61
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
58
62
|
function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
59
63
|
var _getPath;
|
package/style.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { CSSObject } from '@mui/styled-engine';
|
|
2
2
|
import { StyleFunction } from './Box';
|
|
3
3
|
|
|
4
|
+
export type TransformFunction = (
|
|
5
|
+
cssValue: unknown,
|
|
6
|
+
userValue: unknown,
|
|
7
|
+
) => number | string | React.CSSProperties | CSSObject;
|
|
8
|
+
|
|
4
9
|
export interface StyleOptions<PropKey> {
|
|
5
10
|
cssProperty?: PropKey | keyof React.CSSProperties | false;
|
|
6
11
|
prop: PropKey;
|
|
@@ -8,18 +13,15 @@ export interface StyleOptions<PropKey> {
|
|
|
8
13
|
* dot access in `Theme`
|
|
9
14
|
*/
|
|
10
15
|
themeKey?: string;
|
|
11
|
-
transform?:
|
|
12
|
-
cssValue: unknown,
|
|
13
|
-
userValue: unknown,
|
|
14
|
-
) => number | string | React.CSSProperties | CSSObject;
|
|
16
|
+
transform?: TransformFunction;
|
|
15
17
|
}
|
|
16
18
|
export function style<PropKey extends string, Theme extends object>(
|
|
17
19
|
options: StyleOptions<PropKey>,
|
|
18
20
|
): StyleFunction<{ [K in PropKey]?: unknown } & { theme?: Theme }> & { filterProps: string[] };
|
|
19
21
|
export function getPath<T>(obj: T, path: string | undefined, checkVars?: boolean): null | unknown;
|
|
20
22
|
export function getStyleValue(
|
|
21
|
-
themeMapping: object | ((
|
|
22
|
-
transform
|
|
23
|
-
propValueFinal
|
|
24
|
-
userValue?:
|
|
23
|
+
themeMapping: object | ((arg: any) => any),
|
|
24
|
+
transform: TransformFunction | null,
|
|
25
|
+
propValueFinal: unknown,
|
|
26
|
+
userValue?: unknown,
|
|
25
27
|
): any;
|
package/style.js
CHANGED
|
@@ -39,7 +39,7 @@ function getStyleValue(themeMapping, transform, propValueFinal, userValue = prop
|
|
|
39
39
|
value = getPath(themeMapping, propValueFinal) || userValue;
|
|
40
40
|
}
|
|
41
41
|
if (transform) {
|
|
42
|
-
value = transform(value, userValue);
|
|
42
|
+
value = transform(value, userValue, themeMapping);
|
|
43
43
|
}
|
|
44
44
|
return value;
|
|
45
45
|
}
|
|
@@ -50,6 +50,9 @@ function style(options) {
|
|
|
50
50
|
themeKey,
|
|
51
51
|
transform
|
|
52
52
|
} = options;
|
|
53
|
+
|
|
54
|
+
// false positive
|
|
55
|
+
// eslint-disable-next-line react/function-component-definition
|
|
53
56
|
const fn = props => {
|
|
54
57
|
if (props[prop] == null) {
|
|
55
58
|
return null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleFunction } from '../Box';
|
|
2
|
+
import { TransformFunction } from '../style';
|
|
3
|
+
|
|
4
|
+
type SimpleStyleFunction<PropKey extends keyof any> = StyleFunction<Partial<Record<PropKey, any>>>;
|
|
5
|
+
|
|
6
|
+
export interface SxConfigRecord {
|
|
7
|
+
cssProperty?: keyof React.CSSProperties | false;
|
|
8
|
+
/**
|
|
9
|
+
* dot access in `Theme`
|
|
10
|
+
*/
|
|
11
|
+
themeKey?: string;
|
|
12
|
+
transform?: TransformFunction;
|
|
13
|
+
style?: SimpleStyleFunction<any>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type SxConfig = Record<string, SxConfigRecord>;
|
|
17
|
+
|
|
18
|
+
declare const defaultSxConfig: SxConfig;
|
|
19
|
+
|
|
20
|
+
export default defaultSxConfig;
|