@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.
Files changed (110) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +74 -0
  3. package/Container/Container.d.ts +13 -13
  4. package/Container/ContainerProps.d.ts +40 -40
  5. package/Container/containerClasses.d.ts +22 -22
  6. package/Container/createContainer.d.ts +18 -18
  7. package/Stack/Stack.d.ts +13 -13
  8. package/Stack/StackProps.d.ts +42 -42
  9. package/Stack/createStack.d.ts +21 -21
  10. package/Stack/index.d.ts +5 -5
  11. package/Stack/stackClasses.d.ts +8 -8
  12. package/Unstable_Grid/Grid.d.ts +12 -12
  13. package/Unstable_Grid/GridProps.d.ts +162 -162
  14. package/Unstable_Grid/createGrid.d.ts +11 -11
  15. package/Unstable_Grid/gridClasses.d.ts +20 -20
  16. package/Unstable_Grid/gridGenerator.d.ts +29 -29
  17. package/Unstable_Grid/index.d.ts +5 -5
  18. package/borders.js +12 -7
  19. package/breakpoints.js +2 -0
  20. package/compose.js +3 -0
  21. package/createBox.d.ts +0 -2
  22. package/createBox.js +2 -3
  23. package/createBox.spec.d.ts +1 -1
  24. package/createStyled.js +2 -3
  25. package/createTheme/createSpacing.d.ts +10 -10
  26. package/createTheme/createTheme.d.ts +5 -0
  27. package/createTheme/createTheme.js +9 -0
  28. package/cssGrid.js +8 -0
  29. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  30. package/cssVars/createGetCssVar.d.ts +5 -5
  31. package/cssVars/cssVarsParser.d.ts +63 -63
  32. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  33. package/cssVars/index.d.ts +3 -3
  34. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  35. package/esm/borders.js +9 -6
  36. package/esm/breakpoints.js +2 -0
  37. package/esm/compose.js +3 -0
  38. package/esm/createBox.js +2 -3
  39. package/esm/createStyled.js +2 -3
  40. package/esm/createTheme/createTheme.js +9 -0
  41. package/esm/cssGrid.js +9 -0
  42. package/esm/index.js +1 -2
  43. package/esm/palette.js +4 -4
  44. package/esm/sizing.js +9 -9
  45. package/esm/spacing.js +2 -2
  46. package/esm/style.js +4 -1
  47. package/esm/styleFunctionSx/defaultSxConfig.js +284 -0
  48. package/esm/styleFunctionSx/extendSxProp.js +4 -2
  49. package/esm/styleFunctionSx/index.js +2 -1
  50. package/esm/styleFunctionSx/styleFunctionSx.js +45 -17
  51. package/index.d.ts +1 -2
  52. package/index.js +8 -9
  53. package/index.spec.d.ts +1 -1
  54. package/legacy/borders.js +9 -6
  55. package/legacy/breakpoints.js +2 -0
  56. package/legacy/compose.js +3 -0
  57. package/legacy/createBox.js +2 -4
  58. package/legacy/createStyled.js +2 -4
  59. package/legacy/createTheme/createTheme.js +9 -0
  60. package/legacy/cssGrid.js +9 -0
  61. package/legacy/index.js +2 -3
  62. package/legacy/palette.js +4 -4
  63. package/legacy/sizing.js +9 -9
  64. package/legacy/spacing.js +2 -2
  65. package/legacy/style.js +3 -2
  66. package/legacy/styleFunctionSx/defaultSxConfig.js +286 -0
  67. package/legacy/styleFunctionSx/extendSxProp.js +4 -2
  68. package/legacy/styleFunctionSx/index.js +2 -1
  69. package/legacy/styleFunctionSx/styleFunctionSx.js +44 -20
  70. package/modern/borders.js +9 -6
  71. package/modern/breakpoints.js +2 -0
  72. package/modern/compose.js +3 -0
  73. package/modern/createBox.js +2 -3
  74. package/modern/createStyled.js +2 -3
  75. package/modern/createTheme/createTheme.js +9 -0
  76. package/modern/cssGrid.js +9 -0
  77. package/modern/index.js +2 -3
  78. package/modern/palette.js +4 -4
  79. package/modern/sizing.js +9 -9
  80. package/modern/spacing.js +2 -2
  81. package/modern/style.js +4 -1
  82. package/modern/styleFunctionSx/defaultSxConfig.js +284 -0
  83. package/modern/styleFunctionSx/extendSxProp.js +3 -2
  84. package/modern/styleFunctionSx/index.js +2 -1
  85. package/modern/styleFunctionSx/styleFunctionSx.js +44 -17
  86. package/package.json +6 -6
  87. package/palette.js +5 -4
  88. package/sizing.js +12 -10
  89. package/spacing.js +4 -0
  90. package/style.d.ts +10 -8
  91. package/style.js +4 -1
  92. package/styleFunctionSx/defaultSxConfig.d.ts +20 -0
  93. package/styleFunctionSx/defaultSxConfig.js +291 -0
  94. package/styleFunctionSx/extendSxProp.js +4 -2
  95. package/styleFunctionSx/index.d.ts +4 -0
  96. package/styleFunctionSx/index.js +7 -0
  97. package/styleFunctionSx/styleFunctionSx.d.ts +2 -1
  98. package/styleFunctionSx/styleFunctionSx.js +45 -17
  99. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
  100. package/esm/sx/index.js +0 -1
  101. package/esm/sx/sx.js +0 -10
  102. package/legacy/sx/index.js +0 -1
  103. package/legacy/sx/sx.js +0 -11
  104. package/modern/sx/index.js +0 -1
  105. package/modern/sx/sx.js +0 -10
  106. package/sx/index.d.ts +0 -1
  107. package/sx/index.js +0 -13
  108. package/sx/package.json +0 -6
  109. package/sx/sx.d.ts +0 -4
  110. package/sx/sx.js +0 -18
@@ -4,15 +4,14 @@ const _excluded = ["className", "component"];
4
4
  import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import styled from '@mui/styled-engine';
7
- import defaultStyleFunctionSx, { extendSxProp } from './styleFunctionSx';
7
+ import styleFunctionSx, { extendSxProp } from './styleFunctionSx';
8
8
  import useTheme from './useTheme';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  export default function createBox(options = {}) {
11
11
  const {
12
12
  defaultTheme,
13
13
  defaultClassName = 'MuiBox-root',
14
- generateClassName,
15
- styleFunctionSx = defaultStyleFunctionSx
14
+ generateClassName
16
15
  } = options;
17
16
  const BoxRoot = styled('div', {
18
17
  shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
@@ -8,7 +8,7 @@ import styledEngineStyled, { internal_processStyles as processStyles } from '@mu
8
8
  import { getDisplayName } from '@mui/utils';
9
9
  import createTheme from './createTheme';
10
10
  import propsToClassKey from './propsToClassKey';
11
- import defaultStyleFunctionSx from './styleFunctionSx';
11
+ import styleFunctionSx from './styleFunctionSx';
12
12
  function isEmpty(obj) {
13
13
  return Object.keys(obj).length === 0;
14
14
  }
@@ -73,8 +73,7 @@ export default function createStyled(input = {}) {
73
73
  const {
74
74
  defaultTheme = systemDefaultTheme,
75
75
  rootShouldForwardProp = shouldForwardProp,
76
- slotShouldForwardProp = shouldForwardProp,
77
- styleFunctionSx = defaultStyleFunctionSx
76
+ slotShouldForwardProp = shouldForwardProp
78
77
  } = input;
79
78
  const systemSx = props => {
80
79
  const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
@@ -5,6 +5,8 @@ import { deepmerge } from '@mui/utils';
5
5
  import createBreakpoints from './createBreakpoints';
6
6
  import shape from './shape';
7
7
  import createSpacing from './createSpacing';
8
+ import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
9
+ import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
8
10
  function createTheme(options = {}, ...args) {
9
11
  const {
10
12
  breakpoints: breakpointsInput = {},
@@ -27,6 +29,13 @@ function createTheme(options = {}, ...args) {
27
29
  shape: _extends({}, shape, shapeInput)
28
30
  }, other);
29
31
  muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
32
+ muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
33
+ muiTheme.unstable_sx = function sx(props) {
34
+ return styleFunctionSx({
35
+ sx: props,
36
+ theme: this
37
+ });
38
+ };
30
39
  return muiTheme;
31
40
  }
32
41
  export default createTheme;
package/modern/cssGrid.js CHANGED
@@ -3,6 +3,9 @@ import compose from './compose';
3
3
  import { createUnaryUnit, getValue } from './spacing';
4
4
  import { handleBreakpoints } from './breakpoints';
5
5
  import responsivePropType from './responsivePropType';
6
+
7
+ // false positive
8
+ // eslint-disable-next-line react/function-component-definition
6
9
  export const gap = props => {
7
10
  if (props.gap !== undefined && props.gap !== null) {
8
11
  const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'gap');
@@ -17,6 +20,9 @@ gap.propTypes = process.env.NODE_ENV !== 'production' ? {
17
20
  gap: responsivePropType
18
21
  } : {};
19
22
  gap.filterProps = ['gap'];
23
+
24
+ // false positive
25
+ // eslint-disable-next-line react/function-component-definition
20
26
  export const columnGap = props => {
21
27
  if (props.columnGap !== undefined && props.columnGap !== null) {
22
28
  const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'columnGap');
@@ -31,6 +37,9 @@ columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
31
37
  columnGap: responsivePropType
32
38
  } : {};
33
39
  columnGap.filterProps = ['columnGap'];
40
+
41
+ // false positive
42
+ // eslint-disable-next-line react/function-component-definition
34
43
  export const rowGap = props => {
35
44
  if (props.rowGap !== undefined && props.rowGap !== null) {
36
45
  const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'rowGap');
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.10.17
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.
@@ -26,8 +26,7 @@ export * from './spacing';
26
26
  export { default as style, getPath, getStyleValue } from './style';
27
27
  export { default as typography } from './typography';
28
28
  export * from './typography';
29
- export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
30
- export { default as experimental_sx } from './sx';
29
+ export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp, unstable_defaultSxConfig } from './styleFunctionSx';
31
30
  export { default as unstable_getThemeValue } from './getThemeValue';
32
31
  export { default as Box } from './Box';
33
32
  export { default as createBox } from './createBox';
package/modern/palette.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import style from './style';
2
2
  import compose from './compose';
3
- function transform(value, userValue) {
3
+ export function paletteTransform(value, userValue) {
4
4
  if (userValue === 'grey') {
5
5
  return userValue;
6
6
  }
@@ -9,18 +9,18 @@ function transform(value, userValue) {
9
9
  export const color = style({
10
10
  prop: 'color',
11
11
  themeKey: 'palette',
12
- transform
12
+ transform: paletteTransform
13
13
  });
14
14
  export const bgcolor = style({
15
15
  prop: 'bgcolor',
16
16
  cssProperty: 'backgroundColor',
17
17
  themeKey: 'palette',
18
- transform
18
+ transform: paletteTransform
19
19
  });
20
20
  export const backgroundColor = style({
21
21
  prop: 'backgroundColor',
22
22
  themeKey: 'palette',
23
- transform
23
+ transform: paletteTransform
24
24
  });
25
25
  const palette = compose(color, bgcolor, backgroundColor);
26
26
  export default palette;
package/modern/sizing.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import style from './style';
2
2
  import compose from './compose';
3
3
  import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
4
- function transform(value) {
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) {
13
13
  const styleFromPropValue = propValue => {
14
14
  const breakpoint = props.theme?.breakpoints?.values?.[propValue] || breakpointsValues[propValue];
15
15
  return {
16
- maxWidth: breakpoint || transform(propValue)
16
+ maxWidth: breakpoint || sizingTransform(propValue)
17
17
  };
18
18
  };
19
19
  return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
@@ -23,29 +23,29 @@ export const maxWidth = props => {
23
23
  maxWidth.filterProps = ['maxWidth'];
24
24
  export const minWidth = style({
25
25
  prop: 'minWidth',
26
- transform
26
+ transform: sizingTransform
27
27
  });
28
28
  export const height = style({
29
29
  prop: 'height',
30
- transform
30
+ transform: sizingTransform
31
31
  });
32
32
  export const maxHeight = style({
33
33
  prop: 'maxHeight',
34
- transform
34
+ transform: sizingTransform
35
35
  });
36
36
  export const minHeight = style({
37
37
  prop: 'minHeight',
38
- transform
38
+ transform: sizingTransform
39
39
  });
40
40
  export const sizeWidth = style({
41
41
  prop: 'size',
42
42
  cssProperty: 'width',
43
- transform
43
+ transform: sizingTransform
44
44
  });
45
45
  export const sizeHeight = style({
46
46
  prop: 'size',
47
47
  cssProperty: 'height',
48
- transform
48
+ transform: sizingTransform
49
49
  });
50
50
  export const boxSizing = style({
51
51
  prop: 'boxSizing'
package/modern/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
  const themeSpacing = getPath(theme, themeKey, false) ?? defaultValue;
package/modern/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,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 { propToStyleFunction } from '../getThemeValue';
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 (propToStyleFunction[prop]) {
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 { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
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(styleFunctionMapping = defaultStyleFunctionMapping) {
15
- const propToStyleFunction = Object.keys(styleFunctionMapping).reduce((acc, styleFnName) => {
16
- styleFunctionMapping[styleFnName].filterProps.forEach(propName => {
17
- acc[propName] = styleFunctionMapping[styleFnName];
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 styleFunction = propToStyleFunction[prop];
27
- return styleFunction ? styleFunction(inputProps) : {
28
- [prop]: value
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 (propToStyleFunction[styleKey]) {
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.10.17",
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.1",
47
- "@mui/private-theming": "^5.10.16",
48
- "@mui/styled-engine": "^5.10.16",
49
- "@mui/types": "^7.2.2",
50
- "@mui/utils": "^5.10.16",
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"