@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/borders.js +12 -7
  3. package/breakpoints.js +2 -0
  4. package/colorManipulator.d.ts +10 -0
  5. package/colorManipulator.js +57 -1
  6. package/compose.js +3 -0
  7. package/createBox.d.ts +0 -2
  8. package/createBox.js +2 -3
  9. package/createStyled.js +2 -3
  10. package/createTheme/createTheme.d.ts +5 -0
  11. package/createTheme/createTheme.js +9 -0
  12. package/cssGrid.js +8 -0
  13. package/cssVars/createCssVarsProvider.d.ts +54 -1
  14. package/cssVars/createCssVarsProvider.js +47 -13
  15. package/esm/borders.js +9 -6
  16. package/esm/breakpoints.js +2 -0
  17. package/esm/colorManipulator.js +50 -0
  18. package/esm/compose.js +3 -0
  19. package/esm/createBox.js +2 -3
  20. package/esm/createStyled.js +2 -3
  21. package/esm/createTheme/createTheme.js +9 -0
  22. package/esm/cssGrid.js +9 -0
  23. package/esm/cssVars/createCssVarsProvider.js +47 -13
  24. package/esm/index.js +1 -2
  25. package/esm/palette.js +4 -4
  26. package/esm/sizing.js +9 -9
  27. package/esm/spacing.js +2 -2
  28. package/esm/style.js +4 -1
  29. package/esm/styleFunctionSx/defaultSxConfig.js +284 -0
  30. package/esm/styleFunctionSx/extendSxProp.js +4 -2
  31. package/esm/styleFunctionSx/index.js +2 -1
  32. package/esm/styleFunctionSx/styleFunctionSx.js +45 -17
  33. package/index.d.ts +1 -2
  34. package/index.js +8 -9
  35. package/legacy/borders.js +9 -6
  36. package/legacy/breakpoints.js +2 -0
  37. package/legacy/colorManipulator.js +50 -0
  38. package/legacy/compose.js +3 -0
  39. package/legacy/createBox.js +2 -4
  40. package/legacy/createStyled.js +2 -4
  41. package/legacy/createTheme/createTheme.js +9 -0
  42. package/legacy/cssGrid.js +9 -0
  43. package/legacy/cssVars/createCssVarsProvider.js +47 -11
  44. package/legacy/index.js +2 -3
  45. package/legacy/palette.js +4 -4
  46. package/legacy/sizing.js +9 -9
  47. package/legacy/spacing.js +2 -2
  48. package/legacy/style.js +3 -2
  49. package/legacy/styleFunctionSx/defaultSxConfig.js +286 -0
  50. package/legacy/styleFunctionSx/extendSxProp.js +4 -2
  51. package/legacy/styleFunctionSx/index.js +2 -1
  52. package/legacy/styleFunctionSx/styleFunctionSx.js +44 -20
  53. package/modern/borders.js +9 -6
  54. package/modern/breakpoints.js +2 -0
  55. package/modern/colorManipulator.js +50 -0
  56. package/modern/compose.js +3 -0
  57. package/modern/createBox.js +2 -3
  58. package/modern/createStyled.js +2 -3
  59. package/modern/createTheme/createTheme.js +9 -0
  60. package/modern/cssGrid.js +9 -0
  61. package/modern/cssVars/createCssVarsProvider.js +47 -13
  62. package/modern/index.js +2 -3
  63. package/modern/palette.js +4 -4
  64. package/modern/sizing.js +9 -9
  65. package/modern/spacing.js +2 -2
  66. package/modern/style.js +4 -1
  67. package/modern/styleFunctionSx/defaultSxConfig.js +284 -0
  68. package/modern/styleFunctionSx/extendSxProp.js +3 -2
  69. package/modern/styleFunctionSx/index.js +2 -1
  70. package/modern/styleFunctionSx/styleFunctionSx.js +44 -17
  71. package/package.json +6 -6
  72. package/palette.js +5 -4
  73. package/sizing.js +12 -10
  74. package/spacing.js +4 -0
  75. package/style.d.ts +10 -8
  76. package/style.js +4 -1
  77. package/styleFunctionSx/defaultSxConfig.d.ts +20 -0
  78. package/styleFunctionSx/defaultSxConfig.js +291 -0
  79. package/styleFunctionSx/extendSxProp.js +4 -2
  80. package/styleFunctionSx/index.d.ts +4 -0
  81. package/styleFunctionSx/index.js +7 -0
  82. package/styleFunctionSx/styleFunctionSx.d.ts +2 -1
  83. package/styleFunctionSx/styleFunctionSx.js +45 -17
  84. package/esm/sx/index.js +0 -1
  85. package/esm/sx/sx.js +0 -10
  86. package/legacy/sx/index.js +0 -1
  87. package/legacy/sx/sx.js +0 -11
  88. package/modern/sx/index.js +0 -1
  89. package/modern/sx/sx.js +0 -10
  90. package/sx/index.d.ts +0 -1
  91. package/sx/index.js +0 -13
  92. package/sx/package.json +0 -6
  93. package/sx/sx.d.ts +0 -4
  94. package/sx/sx.js +0 -18
package/legacy/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 var gap = function gap(props) {
7
10
  if (props.gap !== undefined && props.gap !== null) {
8
11
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'gap');
@@ -19,6 +22,9 @@ gap.propTypes = process.env.NODE_ENV !== 'production' ? {
19
22
  gap: responsivePropType
20
23
  } : {};
21
24
  gap.filterProps = ['gap'];
25
+
26
+ // false positive
27
+ // eslint-disable-next-line react/function-component-definition
22
28
  export var columnGap = function columnGap(props) {
23
29
  if (props.columnGap !== undefined && props.columnGap !== null) {
24
30
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'columnGap');
@@ -35,6 +41,9 @@ columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
35
41
  columnGap: responsivePropType
36
42
  } : {};
37
43
  columnGap.filterProps = ['columnGap'];
44
+
45
+ // false positive
46
+ // eslint-disable-next-line react/function-component-definition
38
47
  export var rowGap = function rowGap(props) {
39
48
  if (props.rowGap !== undefined && props.rowGap !== null) {
40
49
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'rowGap');
@@ -8,6 +8,7 @@ import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { deepmerge } from '@mui/utils';
10
10
  import { GlobalStyles } from '@mui/styled-engine';
11
+ import { useTheme as muiUseTheme } from '@mui/private-theming';
11
12
  import cssVarsParser from './cssVarsParser';
12
13
  import ThemeProvider from '../ThemeProvider';
13
14
  import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
@@ -68,8 +69,15 @@ export default function createCssVarsProvider(options) {
68
69
  _ref$colorSchemeSelec = _ref.colorSchemeSelector,
69
70
  colorSchemeSelector = _ref$colorSchemeSelec === void 0 ? ':root' : _ref$colorSchemeSelec,
70
71
  _ref$shouldSkipGenera = _ref.shouldSkipGeneratingVar,
71
- shouldSkipGeneratingVar = _ref$shouldSkipGenera === void 0 ? designSystemShouldSkipGeneratingVar : _ref$shouldSkipGenera;
72
+ shouldSkipGeneratingVar = _ref$shouldSkipGenera === void 0 ? designSystemShouldSkipGeneratingVar : _ref$shouldSkipGenera,
73
+ _ref$disableNestedCon = _ref.disableNestedContext,
74
+ disableNestedContext = _ref$disableNestedCon === void 0 ? false : _ref$disableNestedCon,
75
+ _ref$disableStyleShee = _ref.disableStyleSheetGeneration,
76
+ disableStyleSheetGeneration = _ref$disableStyleShee === void 0 ? false : _ref$disableStyleShee;
72
77
  var hasMounted = React.useRef(false);
78
+ var upperTheme = muiUseTheme();
79
+ var ctx = React.useContext(ColorSchemeContext);
80
+ var nested = !!ctx && !disableNestedContext;
73
81
  var _themeProp$colorSchem = themeProp.colorSchemes,
74
82
  colorSchemes = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
75
83
  _themeProp$components = themeProp.components,
@@ -90,13 +98,19 @@ export default function createCssVarsProvider(options) {
90
98
  defaultMode: defaultMode,
91
99
  storageWindow: storageWindow
92
100
  }),
93
- mode = _useCurrentColorSchem.mode,
101
+ stateMode = _useCurrentColorSchem.mode,
94
102
  setMode = _useCurrentColorSchem.setMode,
95
103
  systemMode = _useCurrentColorSchem.systemMode,
96
104
  lightColorScheme = _useCurrentColorSchem.lightColorScheme,
97
105
  darkColorScheme = _useCurrentColorSchem.darkColorScheme,
98
- colorScheme = _useCurrentColorSchem.colorScheme,
106
+ stateColorScheme = _useCurrentColorSchem.colorScheme,
99
107
  setColorScheme = _useCurrentColorSchem.setColorScheme;
108
+ var mode = stateMode;
109
+ var colorScheme = stateColorScheme;
110
+ if (nested) {
111
+ mode = ctx.mode;
112
+ colorScheme = ctx.colorScheme;
113
+ }
100
114
  var calculatedMode = function () {
101
115
  if (!mode) {
102
116
  // This scope occurs on the server
@@ -238,19 +252,31 @@ export default function createCssVarsProvider(options) {
238
252
  allColorSchemes: allColorSchemes
239
253
  };
240
254
  }, [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode]);
241
- return /*#__PURE__*/_jsxs(ColorSchemeContext.Provider, {
242
- value: contextValue,
243
- children: [/*#__PURE__*/_jsx(GlobalStyles, {
244
- styles: _defineProperty({}, colorSchemeSelector, rootCss)
245
- }), /*#__PURE__*/_jsx(GlobalStyles, {
246
- styles: defaultColorSchemeStyleSheet
247
- }), /*#__PURE__*/_jsx(GlobalStyles, {
248
- styles: otherColorSchemesStyleSheet
255
+ var shouldGenerateStyleSheet = true;
256
+ if (disableStyleSheetGeneration || nested && (upperTheme == null ? void 0 : upperTheme.cssVarPrefix) === cssVarPrefix) {
257
+ shouldGenerateStyleSheet = false;
258
+ }
259
+ var element = /*#__PURE__*/_jsxs(React.Fragment, {
260
+ children: [shouldGenerateStyleSheet && /*#__PURE__*/_jsxs(React.Fragment, {
261
+ children: [/*#__PURE__*/_jsx(GlobalStyles, {
262
+ styles: _defineProperty({}, colorSchemeSelector, rootCss)
263
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
264
+ styles: defaultColorSchemeStyleSheet
265
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
266
+ styles: otherColorSchemesStyleSheet
267
+ })]
249
268
  }), /*#__PURE__*/_jsx(ThemeProvider, {
250
269
  theme: resolveTheme ? resolveTheme(theme) : theme,
251
270
  children: children
252
271
  })]
253
272
  });
273
+ if (nested) {
274
+ return element;
275
+ }
276
+ return /*#__PURE__*/_jsx(ColorSchemeContext.Provider, {
277
+ value: contextValue,
278
+ children: element
279
+ });
254
280
  }
255
281
  process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
256
282
  /**
@@ -281,6 +307,16 @@ export default function createCssVarsProvider(options) {
281
307
  * The initial mode used.
282
308
  */
283
309
  defaultMode: PropTypes.string,
310
+ /**
311
+ * If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
312
+ */
313
+ disableNestedContext: PropTypes.bool,
314
+ /**
315
+ * If `true`, the style sheet won't be generated.
316
+ *
317
+ * This is useful for controlling nested CssVarsProvider behavior.
318
+ */
319
+ disableStyleSheetGeneration: PropTypes.bool,
284
320
  /**
285
321
  * Disable CSS transitions when switching between modes or color schemes
286
322
  */
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.10.16
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/legacy/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 var color = style({
10
10
  prop: 'color',
11
11
  themeKey: 'palette',
12
- transform: transform
12
+ transform: paletteTransform
13
13
  });
14
14
  export var bgcolor = style({
15
15
  prop: 'bgcolor',
16
16
  cssProperty: 'backgroundColor',
17
17
  themeKey: 'palette',
18
- transform: transform
18
+ transform: paletteTransform
19
19
  });
20
20
  export var backgroundColor = style({
21
21
  prop: 'backgroundColor',
22
22
  themeKey: 'palette',
23
- transform: transform
23
+ transform: paletteTransform
24
24
  });
25
25
  var palette = compose(color, bgcolor, backgroundColor);
26
26
  export default palette;
package/legacy/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 transform(value) {
4
+ export function sizingTransform(value) {
5
5
  return value <= 1 && value !== 0 ? "".concat(value * 100, "%") : value;
6
6
  }
7
7
  export var width = style({
8
8
  prop: 'width',
9
- transform: transform
9
+ transform: sizingTransform
10
10
  });
11
11
  export var maxWidth = function maxWidth(props) {
12
12
  if (props.maxWidth !== undefined && props.maxWidth !== null) {
@@ -14,7 +14,7 @@ export var maxWidth = function maxWidth(props) {
14
14
  var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
15
15
  var 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 || transform(propValue)
17
+ maxWidth: breakpoint || sizingTransform(propValue)
18
18
  };
19
19
  };
20
20
  return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
@@ -24,29 +24,29 @@ export var maxWidth = function maxWidth(props) {
24
24
  maxWidth.filterProps = ['maxWidth'];
25
25
  export var minWidth = style({
26
26
  prop: 'minWidth',
27
- transform: transform
27
+ transform: sizingTransform
28
28
  });
29
29
  export var height = style({
30
30
  prop: 'height',
31
- transform: transform
31
+ transform: sizingTransform
32
32
  });
33
33
  export var maxHeight = style({
34
34
  prop: 'maxHeight',
35
- transform: transform
35
+ transform: sizingTransform
36
36
  });
37
37
  export var minHeight = style({
38
38
  prop: 'minHeight',
39
- transform: transform
39
+ transform: sizingTransform
40
40
  });
41
41
  export var sizeWidth = style({
42
42
  prop: 'size',
43
43
  cssProperty: 'width',
44
- transform: transform
44
+ transform: sizingTransform
45
45
  });
46
46
  export var sizeHeight = style({
47
47
  prop: 'size',
48
48
  cssProperty: 'height',
49
- transform: transform
49
+ transform: sizingTransform
50
50
  });
51
51
  export var boxSizing = style({
52
52
  prop: 'boxSizing'
package/legacy/spacing.js CHANGED
@@ -45,8 +45,8 @@ var getCssProperties = memoize(function (prop) {
45
45
  return property + dir;
46
46
  }) : [property + direction];
47
47
  });
48
- var marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
49
- var paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
48
+ export var marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
49
+ export var paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
50
50
  var spacingKeys = [].concat(marginKeys, paddingKeys);
51
51
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
52
52
  var _getPath;
package/legacy/style.js CHANGED
@@ -35,7 +35,7 @@ export function getStyleValue(themeMapping, transform, propValueFinal) {
35
35
  value = getPath(themeMapping, propValueFinal) || userValue;
36
36
  }
37
37
  if (transform) {
38
- value = transform(value, userValue);
38
+ value = transform(value, userValue, themeMapping);
39
39
  }
40
40
  return value;
41
41
  }
@@ -44,7 +44,8 @@ function style(options) {
44
44
  _options$cssProperty = options.cssProperty,
45
45
  cssProperty = _options$cssProperty === void 0 ? options.prop : _options$cssProperty,
46
46
  themeKey = options.themeKey,
47
- transform = options.transform;
47
+ transform = options.transform; // false positive
48
+ // eslint-disable-next-line react/function-component-definition
48
49
  var fn = function fn(props) {
49
50
  if (props[prop] == null) {
50
51
  return null;
@@ -0,0 +1,286 @@
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
+ var 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: function transform(value) {
186
+ return {
187
+ '@media print': {
188
+ display: value
189
+ }
190
+ };
191
+ }
192
+ },
193
+ display: {},
194
+ overflow: {},
195
+ textOverflow: {},
196
+ visibility: {},
197
+ whiteSpace: {},
198
+ // flexbox
199
+ flexBasis: {},
200
+ flexDirection: {},
201
+ flexWrap: {},
202
+ justifyContent: {},
203
+ alignItems: {},
204
+ alignContent: {},
205
+ order: {},
206
+ flex: {},
207
+ flexGrow: {},
208
+ flexShrink: {},
209
+ alignSelf: {},
210
+ justifyItems: {},
211
+ justifySelf: {},
212
+ // grid
213
+ gap: {
214
+ style: gap
215
+ },
216
+ rowGap: {
217
+ style: rowGap
218
+ },
219
+ columnGap: {
220
+ style: columnGap
221
+ },
222
+ gridColumn: {},
223
+ gridRow: {},
224
+ gridAutoFlow: {},
225
+ gridAutoColumns: {},
226
+ gridAutoRows: {},
227
+ gridTemplateColumns: {},
228
+ gridTemplateRows: {},
229
+ gridTemplateAreas: {},
230
+ gridArea: {},
231
+ // positions
232
+ position: {},
233
+ zIndex: {
234
+ themeKey: 'zIndex'
235
+ },
236
+ top: {},
237
+ right: {},
238
+ bottom: {},
239
+ left: {},
240
+ // shadows
241
+ boxShadow: {
242
+ themeKey: 'shadows'
243
+ },
244
+ // sizing
245
+ width: {
246
+ transform: sizingTransform
247
+ },
248
+ maxWidth: {
249
+ style: maxWidth
250
+ },
251
+ minWidth: {
252
+ transform: sizingTransform
253
+ },
254
+ height: {
255
+ transform: sizingTransform
256
+ },
257
+ maxHeight: {
258
+ transform: sizingTransform
259
+ },
260
+ minHeight: {
261
+ transform: sizingTransform
262
+ },
263
+ boxSizing: {},
264
+ // typography
265
+ fontFamily: {
266
+ themeKey: 'typography'
267
+ },
268
+ fontSize: {
269
+ themeKey: 'typography'
270
+ },
271
+ fontStyle: {
272
+ themeKey: 'typography'
273
+ },
274
+ fontWeight: {
275
+ themeKey: 'typography'
276
+ },
277
+ letterSpacing: {},
278
+ textTransform: {},
279
+ lineHeight: {},
280
+ textAlign: {},
281
+ typography: {
282
+ cssProperty: false,
283
+ themeKey: 'typography'
284
+ }
285
+ };
286
+ export default defaultSxConfig;
@@ -2,14 +2,16 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  import { isPlainObject } from '@mui/utils';
5
- import { propToStyleFunction } from '../getThemeValue';
5
+ import defaultSxConfig from './defaultSxConfig';
6
6
  var splitProps = function splitProps(props) {
7
+ var _props$theme$unstable, _props$theme;
7
8
  var result = {
8
9
  systemProps: {},
9
10
  otherProps: {}
10
11
  };
12
+ var 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(function (prop) {
12
- if (propToStyleFunction[prop]) {
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,8 +1,10 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import { unstable_capitalize as capitalize } from '@mui/utils';
3
4
  import merge from '../merge';
4
- import { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
5
+ import { getPath, getStyleValue as getValue } from '../style';
5
6
  import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
7
+ import defaultSxConfig from './defaultSxConfig';
6
8
  function objectsHaveSameKeys() {
7
9
  for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
8
10
  objects[_key] = arguments[_key];
@@ -21,28 +23,50 @@ function callIfFn(maybeFn, arg) {
21
23
 
22
24
  // eslint-disable-next-line @typescript-eslint/naming-convention
23
25
  export function unstable_createStyleFunctionSx() {
24
- var styleFunctionMapping = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultStyleFunctionMapping;
25
- var propToStyleFunction = Object.keys(styleFunctionMapping).reduce(function (acc, styleFnName) {
26
- styleFunctionMapping[styleFnName].filterProps.forEach(function (propName) {
27
- acc[propName] = styleFunctionMapping[styleFnName];
28
- });
29
- return acc;
30
- }, {});
31
- function getThemeValue(prop, value, theme) {
32
- var _inputProps;
33
- var inputProps = (_inputProps = {}, _defineProperty(_inputProps, prop, value), _defineProperty(_inputProps, "theme", theme), _inputProps);
34
- var styleFunction = propToStyleFunction[prop];
35
- return styleFunction ? styleFunction(inputProps) : _defineProperty({}, prop, value);
26
+ function getThemeValue(prop, val, theme, config) {
27
+ var _props;
28
+ var props = (_props = {}, _defineProperty(_props, prop, val), _defineProperty(_props, "theme", theme), _props);
29
+ var options = config[prop];
30
+ if (!options) {
31
+ return _defineProperty({}, prop, val);
32
+ }
33
+ var _options$cssProperty = options.cssProperty,
34
+ cssProperty = _options$cssProperty === void 0 ? prop : _options$cssProperty,
35
+ themeKey = options.themeKey,
36
+ transform = options.transform,
37
+ style = options.style;
38
+ if (val == null) {
39
+ return null;
40
+ }
41
+ var themeMapping = getPath(theme, themeKey) || {};
42
+ if (style) {
43
+ return style(props);
44
+ }
45
+ var styleFromPropValue = function styleFromPropValue(propValueFinal) {
46
+ var value = getValue(themeMapping, transform, propValueFinal);
47
+ if (propValueFinal === value && typeof propValueFinal === 'string') {
48
+ // Haven't found value
49
+ value = getValue(themeMapping, transform, "".concat(prop).concat(propValueFinal === 'default' ? '' : capitalize(propValueFinal)), propValueFinal);
50
+ }
51
+ if (cssProperty === false) {
52
+ return value;
53
+ }
54
+ return _defineProperty({}, cssProperty, value);
55
+ };
56
+ return handleBreakpoints(props, val, styleFromPropValue);
36
57
  }
37
58
  function styleFunctionSx(props) {
38
- var _ref2 = props || {},
39
- sx = _ref2.sx,
40
- _ref2$theme = _ref2.theme,
41
- theme = _ref2$theme === void 0 ? {} : _ref2$theme;
59
+ var _theme$unstable_sxCon;
60
+ var _ref3 = props || {},
61
+ sx = _ref3.sx,
62
+ _ref3$theme = _ref3.theme,
63
+ theme = _ref3$theme === void 0 ? {} : _ref3$theme;
42
64
  if (!sx) {
43
65
  return null; // Emotion & styled-components will neglect null
44
66
  }
45
67
 
68
+ var config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : defaultSxConfig;
69
+
46
70
  /*
47
71
  * Receive `sxInput` as object or callback
48
72
  * and then recursively check keys & values to create media query object styles.
@@ -66,8 +90,8 @@ export function unstable_createStyleFunctionSx() {
66
90
  var value = callIfFn(sxObject[styleKey], theme);
67
91
  if (value !== null && value !== undefined) {
68
92
  if (_typeof(value) === 'object') {
69
- if (propToStyleFunction[styleKey]) {
70
- css = merge(css, getThemeValue(styleKey, value, theme));
93
+ if (config[styleKey]) {
94
+ css = merge(css, getThemeValue(styleKey, value, theme, config));
71
95
  } else {
72
96
  var breakpointsValues = handleBreakpoints({
73
97
  theme: theme
@@ -84,7 +108,7 @@ export function unstable_createStyleFunctionSx() {
84
108
  }
85
109
  }
86
110
  } else {
87
- css = merge(css, getThemeValue(styleKey, value, theme));
111
+ css = merge(css, getThemeValue(styleKey, value, theme, config));
88
112
  }
89
113
  }
90
114
  });