@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
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 transform(value, userValue) {
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.width = exports.sizeWidth = exports.sizeHeight = exports.minWidth = exports.minHeight = exports.maxWidth = exports.maxHeight = exports.height = exports.default = exports.boxSizing = void 0;
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 transform(value) {
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 || transform(propValue)
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 | ((val: any) => any),
22
- transform?: (val: any, userVal: any) => any,
23
- propValueFinal?: any,
24
- userValue?: any,
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;
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _spacing = require("../spacing");
8
+ var _borders = require("../borders");
9
+ var _cssGrid = require("../cssGrid");
10
+ var _palette = require("../palette");
11
+ var _sizing = require("../sizing");
12
+ const defaultSxConfig = {
13
+ // borders
14
+ border: {
15
+ themeKey: 'borders',
16
+ transform: _borders.borderTransform
17
+ },
18
+ borderTop: {
19
+ themeKey: 'borders',
20
+ transform: _borders.borderTransform
21
+ },
22
+ borderRight: {
23
+ themeKey: 'borders',
24
+ transform: _borders.borderTransform
25
+ },
26
+ borderBottom: {
27
+ themeKey: 'borders',
28
+ transform: _borders.borderTransform
29
+ },
30
+ borderLeft: {
31
+ themeKey: 'borders',
32
+ transform: _borders.borderTransform
33
+ },
34
+ borderColor: {
35
+ themeKey: 'palette'
36
+ },
37
+ borderTopColor: {
38
+ themeKey: 'palette'
39
+ },
40
+ borderRightColor: {
41
+ themeKey: 'palette'
42
+ },
43
+ borderBottomColor: {
44
+ themeKey: 'palette'
45
+ },
46
+ borderLeftColor: {
47
+ themeKey: 'palette'
48
+ },
49
+ borderRadius: {
50
+ themeKey: 'shape.borderRadius',
51
+ style: _borders.borderRadius
52
+ },
53
+ // palette
54
+ color: {
55
+ themeKey: 'palette',
56
+ transform: _palette.paletteTransform
57
+ },
58
+ bgcolor: {
59
+ themeKey: 'palette',
60
+ cssProperty: 'backgroundColor',
61
+ transform: _palette.paletteTransform
62
+ },
63
+ backgroundColor: {
64
+ themeKey: 'palette',
65
+ transform: _palette.paletteTransform
66
+ },
67
+ // spacing
68
+ p: {
69
+ style: _spacing.padding
70
+ },
71
+ pt: {
72
+ style: _spacing.padding
73
+ },
74
+ pr: {
75
+ style: _spacing.padding
76
+ },
77
+ pb: {
78
+ style: _spacing.padding
79
+ },
80
+ pl: {
81
+ style: _spacing.padding
82
+ },
83
+ px: {
84
+ style: _spacing.padding
85
+ },
86
+ py: {
87
+ style: _spacing.padding
88
+ },
89
+ padding: {
90
+ style: _spacing.padding
91
+ },
92
+ paddingTop: {
93
+ style: _spacing.padding
94
+ },
95
+ paddingRight: {
96
+ style: _spacing.padding
97
+ },
98
+ paddingBottom: {
99
+ style: _spacing.padding
100
+ },
101
+ paddingLeft: {
102
+ style: _spacing.padding
103
+ },
104
+ paddingX: {
105
+ style: _spacing.padding
106
+ },
107
+ paddingY: {
108
+ style: _spacing.padding
109
+ },
110
+ paddingInline: {
111
+ style: _spacing.padding
112
+ },
113
+ paddingInlineStart: {
114
+ style: _spacing.padding
115
+ },
116
+ paddingInlineEnd: {
117
+ style: _spacing.padding
118
+ },
119
+ paddingBlock: {
120
+ style: _spacing.padding
121
+ },
122
+ paddingBlockStart: {
123
+ style: _spacing.padding
124
+ },
125
+ paddingBlockEnd: {
126
+ style: _spacing.padding
127
+ },
128
+ m: {
129
+ style: _spacing.margin
130
+ },
131
+ mt: {
132
+ style: _spacing.margin
133
+ },
134
+ mr: {
135
+ style: _spacing.margin
136
+ },
137
+ mb: {
138
+ style: _spacing.margin
139
+ },
140
+ ml: {
141
+ style: _spacing.margin
142
+ },
143
+ mx: {
144
+ style: _spacing.margin
145
+ },
146
+ my: {
147
+ style: _spacing.margin
148
+ },
149
+ margin: {
150
+ style: _spacing.margin
151
+ },
152
+ marginTop: {
153
+ style: _spacing.margin
154
+ },
155
+ marginRight: {
156
+ style: _spacing.margin
157
+ },
158
+ marginBottom: {
159
+ style: _spacing.margin
160
+ },
161
+ marginLeft: {
162
+ style: _spacing.margin
163
+ },
164
+ marginX: {
165
+ style: _spacing.margin
166
+ },
167
+ marginY: {
168
+ style: _spacing.margin
169
+ },
170
+ marginInline: {
171
+ style: _spacing.margin
172
+ },
173
+ marginInlineStart: {
174
+ style: _spacing.margin
175
+ },
176
+ marginInlineEnd: {
177
+ style: _spacing.margin
178
+ },
179
+ marginBlock: {
180
+ style: _spacing.margin
181
+ },
182
+ marginBlockStart: {
183
+ style: _spacing.margin
184
+ },
185
+ marginBlockEnd: {
186
+ style: _spacing.margin
187
+ },
188
+ // display
189
+ displayPrint: {
190
+ cssProperty: false,
191
+ transform: value => ({
192
+ '@media print': {
193
+ display: value
194
+ }
195
+ })
196
+ },
197
+ display: {},
198
+ overflow: {},
199
+ textOverflow: {},
200
+ visibility: {},
201
+ whiteSpace: {},
202
+ // flexbox
203
+ flexBasis: {},
204
+ flexDirection: {},
205
+ flexWrap: {},
206
+ justifyContent: {},
207
+ alignItems: {},
208
+ alignContent: {},
209
+ order: {},
210
+ flex: {},
211
+ flexGrow: {},
212
+ flexShrink: {},
213
+ alignSelf: {},
214
+ justifyItems: {},
215
+ justifySelf: {},
216
+ // grid
217
+ gap: {
218
+ style: _cssGrid.gap
219
+ },
220
+ rowGap: {
221
+ style: _cssGrid.rowGap
222
+ },
223
+ columnGap: {
224
+ style: _cssGrid.columnGap
225
+ },
226
+ gridColumn: {},
227
+ gridRow: {},
228
+ gridAutoFlow: {},
229
+ gridAutoColumns: {},
230
+ gridAutoRows: {},
231
+ gridTemplateColumns: {},
232
+ gridTemplateRows: {},
233
+ gridTemplateAreas: {},
234
+ gridArea: {},
235
+ // positions
236
+ position: {},
237
+ zIndex: {
238
+ themeKey: 'zIndex'
239
+ },
240
+ top: {},
241
+ right: {},
242
+ bottom: {},
243
+ left: {},
244
+ // shadows
245
+ boxShadow: {
246
+ themeKey: 'shadows'
247
+ },
248
+ // sizing
249
+ width: {
250
+ transform: _sizing.sizingTransform
251
+ },
252
+ maxWidth: {
253
+ style: _sizing.maxWidth
254
+ },
255
+ minWidth: {
256
+ transform: _sizing.sizingTransform
257
+ },
258
+ height: {
259
+ transform: _sizing.sizingTransform
260
+ },
261
+ maxHeight: {
262
+ transform: _sizing.sizingTransform
263
+ },
264
+ minHeight: {
265
+ transform: _sizing.sizingTransform
266
+ },
267
+ boxSizing: {},
268
+ // typography
269
+ fontFamily: {
270
+ themeKey: 'typography'
271
+ },
272
+ fontSize: {
273
+ themeKey: 'typography'
274
+ },
275
+ fontStyle: {
276
+ themeKey: 'typography'
277
+ },
278
+ fontWeight: {
279
+ themeKey: 'typography'
280
+ },
281
+ letterSpacing: {},
282
+ textTransform: {},
283
+ lineHeight: {},
284
+ textAlign: {},
285
+ typography: {
286
+ cssProperty: false,
287
+ themeKey: 'typography'
288
+ }
289
+ };
290
+ var _default = defaultSxConfig;
291
+ exports.default = _default;
@@ -8,15 +8,17 @@ exports.default = extendSxProp;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var _utils = require("@mui/utils");
11
- var _getThemeValue = require("../getThemeValue");
11
+ var _defaultSxConfig = _interopRequireDefault(require("./defaultSxConfig"));
12
12
  const _excluded = ["sx"];
13
13
  const splitProps = props => {
14
+ var _props$theme$unstable, _props$theme;
14
15
  const result = {
15
16
  systemProps: {},
16
17
  otherProps: {}
17
18
  };
19
+ 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.default;
18
20
  Object.keys(props).forEach(prop => {
19
- if (_getThemeValue.propToStyleFunction[prop]) {
21
+ if (config[prop]) {
20
22
  result.systemProps[prop] = props[prop];
21
23
  } else {
22
24
  result.otherProps[prop] = props[prop];
@@ -6,4 +6,8 @@ export * from './OverwriteCSSProperties';
6
6
  export * from './StandardCssProperties';
7
7
 
8
8
  export { default as extendSxProp } from './extendSxProp';
9
+
10
+ export { default as unstable_defaultSxConfig } from './defaultSxConfig';
11
+ export * from './defaultSxConfig';
12
+
9
13
  export * from './extendSxProp';
@@ -22,7 +22,14 @@ Object.defineProperty(exports, "unstable_createStyleFunctionSx", {
22
22
  return _styleFunctionSx.unstable_createStyleFunctionSx;
23
23
  }
24
24
  });
25
+ Object.defineProperty(exports, "unstable_defaultSxConfig", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _defaultSxConfig.default;
29
+ }
30
+ });
25
31
  var _styleFunctionSx = _interopRequireWildcard(require("./styleFunctionSx"));
26
32
  var _extendSxProp = _interopRequireDefault(require("./extendSxProp"));
33
+ var _defaultSxConfig = _interopRequireDefault(require("./defaultSxConfig"));
27
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
35
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -1,4 +1,5 @@
1
1
  import * as CSS from 'csstype';
2
+ import { CSSObject } from '@mui/styled-engine';
2
3
  import { StandardCSSProperties } from './StandardCssProperties';
3
4
  import { AliasesCSSProperties } from './AliasesCSSProperties';
4
5
  import { OverwriteCSSProperties } from './OverwriteCSSProperties';
@@ -74,7 +75,7 @@ export type SxProps<Theme extends object = {}> =
74
75
  >;
75
76
 
76
77
  export interface StyleFunctionSx {
77
- (props: object): object;
78
+ (props: object): CSSObject;
78
79
  filterProps?: string[];
79
80
  }
80
81
 
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  exports.unstable_createStyleFunctionSx = unstable_createStyleFunctionSx;
9
+ var _utils = require("@mui/utils");
9
10
  var _merge = _interopRequireDefault(require("../merge"));
10
- var _getThemeValue = require("../getThemeValue");
11
+ var _style = require("../style");
11
12
  var _breakpoints = require("../breakpoints");
13
+ var _defaultSxConfig = _interopRequireDefault(require("./defaultSxConfig"));
12
14
  function objectsHaveSameKeys(...objects) {
13
15
  const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
14
16
  const union = new Set(allKeys);
@@ -19,24 +21,48 @@ function callIfFn(maybeFn, arg) {
19
21
  }
20
22
 
21
23
  // eslint-disable-next-line @typescript-eslint/naming-convention
22
- function unstable_createStyleFunctionSx(styleFunctionMapping = _getThemeValue.styleFunctionMapping) {
23
- const propToStyleFunction = Object.keys(styleFunctionMapping).reduce((acc, styleFnName) => {
24
- styleFunctionMapping[styleFnName].filterProps.forEach(propName => {
25
- acc[propName] = styleFunctionMapping[styleFnName];
26
- });
27
- return acc;
28
- }, {});
29
- function getThemeValue(prop, value, theme) {
30
- const inputProps = {
31
- [prop]: value,
24
+ function unstable_createStyleFunctionSx() {
25
+ function getThemeValue(prop, val, theme, config) {
26
+ const props = {
27
+ [prop]: val,
32
28
  theme
33
29
  };
34
- const styleFunction = propToStyleFunction[prop];
35
- return styleFunction ? styleFunction(inputProps) : {
36
- [prop]: value
30
+ const options = config[prop];
31
+ if (!options) {
32
+ return {
33
+ [prop]: val
34
+ };
35
+ }
36
+ const {
37
+ cssProperty = prop,
38
+ themeKey,
39
+ transform,
40
+ style
41
+ } = options;
42
+ if (val == null) {
43
+ return null;
44
+ }
45
+ const themeMapping = (0, _style.getPath)(theme, themeKey) || {};
46
+ if (style) {
47
+ return style(props);
48
+ }
49
+ const styleFromPropValue = propValueFinal => {
50
+ let value = (0, _style.getStyleValue)(themeMapping, transform, propValueFinal);
51
+ if (propValueFinal === value && typeof propValueFinal === 'string') {
52
+ // Haven't found value
53
+ value = (0, _style.getStyleValue)(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : (0, _utils.unstable_capitalize)(propValueFinal)}`, propValueFinal);
54
+ }
55
+ if (cssProperty === false) {
56
+ return value;
57
+ }
58
+ return {
59
+ [cssProperty]: value
60
+ };
37
61
  };
62
+ return (0, _breakpoints.handleBreakpoints)(props, val, styleFromPropValue);
38
63
  }
39
64
  function styleFunctionSx(props) {
65
+ var _theme$unstable_sxCon;
40
66
  const {
41
67
  sx,
42
68
  theme = {}
@@ -45,6 +71,8 @@ function unstable_createStyleFunctionSx(styleFunctionMapping = _getThemeValue.st
45
71
  return null; // Emotion & styled-components will neglect null
46
72
  }
47
73
 
74
+ const config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : _defaultSxConfig.default;
75
+
48
76
  /*
49
77
  * Receive `sxInput` as object or callback
50
78
  * and then recursively check keys & values to create media query object styles.
@@ -68,8 +96,8 @@ function unstable_createStyleFunctionSx(styleFunctionMapping = _getThemeValue.st
68
96
  const value = callIfFn(sxObject[styleKey], theme);
69
97
  if (value !== null && value !== undefined) {
70
98
  if (typeof value === 'object') {
71
- if (propToStyleFunction[styleKey]) {
72
- css = (0, _merge.default)(css, getThemeValue(styleKey, value, theme));
99
+ if (config[styleKey]) {
100
+ css = (0, _merge.default)(css, getThemeValue(styleKey, value, theme, config));
73
101
  } else {
74
102
  const breakpointsValues = (0, _breakpoints.handleBreakpoints)({
75
103
  theme
@@ -86,7 +114,7 @@ function unstable_createStyleFunctionSx(styleFunctionMapping = _getThemeValue.st
86
114
  }
87
115
  }
88
116
  } else {
89
- css = (0, _merge.default)(css, getThemeValue(styleKey, value, theme));
117
+ css = (0, _merge.default)(css, getThemeValue(styleKey, value, theme, config));
90
118
  }
91
119
  }
92
120
  });
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/esm/sx/index.js DELETED
@@ -1 +0,0 @@
1
- export { default } from './sx';
package/esm/sx/sx.js DELETED
@@ -1,10 +0,0 @@
1
- import styleFunctionSx from '../styleFunctionSx';
2
- function sx(styles) {
3
- return ({
4
- theme
5
- }) => styleFunctionSx({
6
- sx: styles,
7
- theme
8
- });
9
- }
10
- export default sx;
@@ -1 +0,0 @@
1
- export { default } from './sx';