@mui/system 6.0.0-alpha.0 → 6.0.0-alpha.3

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 (141) hide show
  1. package/CHANGELOG.md +243 -4
  2. package/Container/Container.d.ts +1 -1
  3. package/Stack/Stack.d.ts +1 -1
  4. package/Stack/createStack.d.ts +1 -1
  5. package/Unstable_Grid/Grid.d.ts +1 -1
  6. package/Unstable_Grid/createGrid.d.ts +1 -1
  7. package/breakpoints/breakpoints.js +19 -1
  8. package/createTheme/createSpacing.d.ts +2 -2
  9. package/createTheme/createSpacing.js +7 -8
  10. package/createTheme/createTheme.d.ts +2 -1
  11. package/createTheme/createTheme.js +2 -0
  12. package/cssContainerQueries/cssContainerQueries.d.ts +24 -0
  13. package/cssContainerQueries/cssContainerQueries.js +68 -0
  14. package/cssContainerQueries/index.d.ts +3 -0
  15. package/cssContainerQueries/index.js +2 -0
  16. package/cssContainerQueries/package.json +6 -0
  17. package/cssVars/createCssVarsProvider.js +3 -0
  18. package/cssVars/cssVarsParser.d.ts +1 -1
  19. package/cssVars/cssVarsParser.js +3 -2
  20. package/index.d.ts +2 -0
  21. package/index.js +2 -1
  22. package/modern/breakpoints/breakpoints.js +19 -1
  23. package/modern/createTheme/createSpacing.js +7 -8
  24. package/modern/createTheme/createTheme.js +2 -0
  25. package/modern/cssContainerQueries/cssContainerQueries.js +68 -0
  26. package/modern/cssContainerQueries/index.js +2 -0
  27. package/modern/cssVars/createCssVarsProvider.js +3 -0
  28. package/modern/cssVars/cssVarsParser.js +3 -2
  29. package/modern/index.js +2 -1
  30. package/modern/spacing/spacing.js +24 -21
  31. package/modern/styleFunctionSx/styleFunctionSx.js +2 -1
  32. package/node/breakpoints/breakpoints.js +19 -1
  33. package/node/createTheme/createSpacing.js +7 -8
  34. package/node/createTheme/createTheme.js +2 -0
  35. package/node/cssContainerQueries/cssContainerQueries.js +79 -0
  36. package/node/cssContainerQueries/index.js +32 -0
  37. package/node/cssVars/createCssVarsProvider.js +3 -0
  38. package/node/cssVars/cssVarsParser.js +3 -2
  39. package/node/index.js +9 -1
  40. package/node/spacing/spacing.js +24 -21
  41. package/node/styleFunctionSx/styleFunctionSx.js +2 -1
  42. package/package.json +5 -5
  43. package/spacing/spacing.js +24 -21
  44. package/styleFunctionSx/styleFunctionSx.js +2 -1
  45. package/legacy/Box/Box.js +0 -30
  46. package/legacy/Box/boxClasses.js +0 -3
  47. package/legacy/Box/index.js +0 -5
  48. package/legacy/Container/Container.js +0 -61
  49. package/legacy/Container/ContainerProps.js +0 -1
  50. package/legacy/Container/containerClasses.js +0 -7
  51. package/legacy/Container/createContainer.js +0 -140
  52. package/legacy/Container/index.js +0 -5
  53. package/legacy/GlobalStyles/GlobalStyles.js +0 -37
  54. package/legacy/GlobalStyles/index.js +0 -4
  55. package/legacy/RtlProvider/index.js +0 -22
  56. package/legacy/Stack/Stack.js +0 -62
  57. package/legacy/Stack/StackProps.js +0 -1
  58. package/legacy/Stack/createStack.js +0 -180
  59. package/legacy/Stack/index.js +0 -7
  60. package/legacy/Stack/stackClasses.js +0 -7
  61. package/legacy/ThemeProvider/ThemeProvider.js +0 -87
  62. package/legacy/ThemeProvider/index.js +0 -3
  63. package/legacy/Unstable_Grid/Grid.js +0 -177
  64. package/legacy/Unstable_Grid/GridProps.js +0 -1
  65. package/legacy/Unstable_Grid/createGrid.js +0 -184
  66. package/legacy/Unstable_Grid/gridClasses.js +0 -28
  67. package/legacy/Unstable_Grid/gridGenerator.js +0 -216
  68. package/legacy/Unstable_Grid/index.js +0 -8
  69. package/legacy/Unstable_Grid/traverseBreakpoints.js +0 -48
  70. package/legacy/borders/borders.js +0 -51
  71. package/legacy/borders/index.js +0 -4
  72. package/legacy/breakpoints/breakpoints.js +0 -162
  73. package/legacy/breakpoints/index.js +0 -4
  74. package/legacy/colorManipulator/colorManipulator.js +0 -356
  75. package/legacy/colorManipulator/index.js +0 -3
  76. package/legacy/compose/compose.js +0 -32
  77. package/legacy/compose/index.js +0 -3
  78. package/legacy/createBox/createBox.js +0 -38
  79. package/legacy/createBox/index.js +0 -3
  80. package/legacy/createStyled/createStyled.js +0 -250
  81. package/legacy/createStyled/index.js +0 -4
  82. package/legacy/createTheme/applyStyles.js +0 -73
  83. package/legacy/createTheme/createBreakpoints.js +0 -83
  84. package/legacy/createTheme/createSpacing.js +0 -36
  85. package/legacy/createTheme/createTheme.js +0 -49
  86. package/legacy/createTheme/index.js +0 -3
  87. package/legacy/createTheme/shape.js +0 -4
  88. package/legacy/cssGrid/cssGrid.js +0 -91
  89. package/legacy/cssGrid/index.js +0 -4
  90. package/legacy/cssVars/createCssVarsProvider.js +0 -335
  91. package/legacy/cssVars/createCssVarsTheme.js +0 -13
  92. package/legacy/cssVars/createGetCssVar.js +0 -30
  93. package/legacy/cssVars/cssVarsParser.js +0 -140
  94. package/legacy/cssVars/getInitColorSchemeScript.js +0 -28
  95. package/legacy/cssVars/index.js +0 -6
  96. package/legacy/cssVars/prepareCssVars.js +0 -92
  97. package/legacy/cssVars/useCurrentColorScheme.js +0 -237
  98. package/legacy/display/display.js +0 -29
  99. package/legacy/display/index.js +0 -4
  100. package/legacy/flexbox/flexbox.js +0 -43
  101. package/legacy/flexbox/index.js +0 -4
  102. package/legacy/getThemeValue/getThemeValue.js +0 -47
  103. package/legacy/getThemeValue/index.js +0 -4
  104. package/legacy/index.js +0 -72
  105. package/legacy/memoize/index.js +0 -3
  106. package/legacy/memoize/memoize.js +0 -9
  107. package/legacy/merge/index.js +0 -3
  108. package/legacy/merge/merge.js +0 -10
  109. package/legacy/palette/index.js +0 -4
  110. package/legacy/palette/palette.js +0 -26
  111. package/legacy/positions/index.js +0 -4
  112. package/legacy/positions/positions.js +0 -22
  113. package/legacy/propsToClassKey/index.js +0 -3
  114. package/legacy/propsToClassKey/propsToClassKey.js +0 -24
  115. package/legacy/responsivePropType/index.js +0 -3
  116. package/legacy/responsivePropType/responsivePropType.js +0 -3
  117. package/legacy/shadows/index.js +0 -3
  118. package/legacy/shadows/shadows.js +0 -6
  119. package/legacy/sizing/index.js +0 -4
  120. package/legacy/sizing/sizing.js +0 -65
  121. package/legacy/spacing/index.js +0 -4
  122. package/legacy/spacing/spacing.js +0 -158
  123. package/legacy/style/index.js +0 -4
  124. package/legacy/style/style.js +0 -73
  125. package/legacy/styleFunctionSx/defaultSxConfig.js +0 -293
  126. package/legacy/styleFunctionSx/extendSxProp.js +0 -45
  127. package/legacy/styleFunctionSx/index.js +0 -4
  128. package/legacy/styleFunctionSx/styleFunctionSx.js +0 -126
  129. package/legacy/styled/index.js +0 -3
  130. package/legacy/styled/styled.js +0 -3
  131. package/legacy/typography/index.js +0 -4
  132. package/legacy/typography/typography.js +0 -37
  133. package/legacy/useMediaQuery/index.js +0 -2
  134. package/legacy/useMediaQuery/useMediaQuery.js +0 -145
  135. package/legacy/useTheme/index.js +0 -4
  136. package/legacy/useTheme/useTheme.js +0 -10
  137. package/legacy/useThemeProps/getThemeProps.js +0 -10
  138. package/legacy/useThemeProps/index.js +0 -4
  139. package/legacy/useThemeProps/useThemeProps.js +0 -20
  140. package/legacy/useThemeWithoutDefault/index.js +0 -3
  141. package/legacy/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -13
@@ -1,158 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import responsivePropType from '../responsivePropType';
3
- import { handleBreakpoints } from '../breakpoints';
4
- import { getPath } from '../style';
5
- import merge from '../merge';
6
- import memoize from '../memoize';
7
- var properties = {
8
- m: 'margin',
9
- p: 'padding'
10
- };
11
- var directions = {
12
- t: 'Top',
13
- r: 'Right',
14
- b: 'Bottom',
15
- l: 'Left',
16
- x: ['Left', 'Right'],
17
- y: ['Top', 'Bottom']
18
- };
19
- var aliases = {
20
- marginX: 'mx',
21
- marginY: 'my',
22
- paddingX: 'px',
23
- paddingY: 'py'
24
- };
25
-
26
- // memoize() impact:
27
- // From 300,000 ops/sec
28
- // To 350,000 ops/sec
29
- var getCssProperties = memoize(function (prop) {
30
- // It's not a shorthand notation.
31
- if (prop.length > 2) {
32
- if (aliases[prop]) {
33
- prop = aliases[prop];
34
- } else {
35
- return [prop];
36
- }
37
- }
38
- var _prop$split = prop.split(''),
39
- _prop$split2 = _slicedToArray(_prop$split, 2),
40
- a = _prop$split2[0],
41
- b = _prop$split2[1];
42
- var property = properties[a];
43
- var direction = directions[b] || '';
44
- return Array.isArray(direction) ? direction.map(function (dir) {
45
- return property + dir;
46
- }) : [property + direction];
47
- });
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
- var spacingKeys = [].concat(marginKeys, paddingKeys);
51
- export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
52
- var _getPath;
53
- var themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
54
- if (typeof themeSpacing === 'number') {
55
- return function (abs) {
56
- if (typeof abs === 'string') {
57
- return abs;
58
- }
59
- if (process.env.NODE_ENV !== 'production') {
60
- if (typeof abs !== 'number') {
61
- console.error("MUI: Expected ".concat(propName, " argument to be a number or a string, got ").concat(abs, "."));
62
- }
63
- }
64
- return themeSpacing * abs;
65
- };
66
- }
67
- if (Array.isArray(themeSpacing)) {
68
- return function (abs) {
69
- if (typeof abs === 'string') {
70
- return abs;
71
- }
72
- if (process.env.NODE_ENV !== 'production') {
73
- if (!Number.isInteger(abs)) {
74
- console.error(["MUI: The `theme.".concat(themeKey, "` array type cannot be combined with non integer values.") + "You should either use an integer value that can be used as index, or define the `theme.".concat(themeKey, "` as a number.")].join('\n'));
75
- } else if (abs > themeSpacing.length - 1) {
76
- console.error(["MUI: The value provided (".concat(abs, ") overflows."), "The supported values are: ".concat(JSON.stringify(themeSpacing), "."), "".concat(abs, " > ").concat(themeSpacing.length - 1, ", you need to add the missing values.")].join('\n'));
77
- }
78
- }
79
- return themeSpacing[abs];
80
- };
81
- }
82
- if (typeof themeSpacing === 'function') {
83
- return themeSpacing;
84
- }
85
- if (process.env.NODE_ENV !== 'production') {
86
- console.error(["MUI: The `theme.".concat(themeKey, "` value (").concat(themeSpacing, ") is invalid."), 'It should be a number, an array or a function.'].join('\n'));
87
- }
88
- return function () {
89
- return undefined;
90
- };
91
- }
92
- export function createUnarySpacing(theme) {
93
- return createUnaryUnit(theme, 'spacing', 8, 'spacing');
94
- }
95
- export function getValue(transformer, propValue) {
96
- if (typeof propValue === 'string' || propValue == null) {
97
- return propValue;
98
- }
99
- var abs = Math.abs(propValue);
100
- var transformed = transformer(abs);
101
- if (propValue >= 0) {
102
- return transformed;
103
- }
104
- if (typeof transformed === 'number') {
105
- return -transformed;
106
- }
107
- return "-".concat(transformed);
108
- }
109
- export function getStyleFromPropValue(cssProperties, transformer) {
110
- return function (propValue) {
111
- return cssProperties.reduce(function (acc, cssProperty) {
112
- acc[cssProperty] = getValue(transformer, propValue);
113
- return acc;
114
- }, {});
115
- };
116
- }
117
- function resolveCssProperty(props, keys, prop, transformer) {
118
- // Using a hash computation over an array iteration could be faster, but with only 28 items,
119
- // it's doesn't worth the bundle size.
120
- if (keys.indexOf(prop) === -1) {
121
- return null;
122
- }
123
- var cssProperties = getCssProperties(prop);
124
- var styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
125
- var propValue = props[prop];
126
- return handleBreakpoints(props, propValue, styleFromPropValue);
127
- }
128
- function style(props, keys) {
129
- var transformer = createUnarySpacing(props.theme);
130
- return Object.keys(props).map(function (prop) {
131
- return resolveCssProperty(props, keys, prop, transformer);
132
- }).reduce(merge, {});
133
- }
134
- export function margin(props) {
135
- return style(props, marginKeys);
136
- }
137
- margin.propTypes = process.env.NODE_ENV !== 'production' ? marginKeys.reduce(function (obj, key) {
138
- obj[key] = responsivePropType;
139
- return obj;
140
- }, {}) : {};
141
- margin.filterProps = marginKeys;
142
- export function padding(props) {
143
- return style(props, paddingKeys);
144
- }
145
- padding.propTypes = process.env.NODE_ENV !== 'production' ? paddingKeys.reduce(function (obj, key) {
146
- obj[key] = responsivePropType;
147
- return obj;
148
- }, {}) : {};
149
- padding.filterProps = paddingKeys;
150
- function spacing(props) {
151
- return style(props, spacingKeys);
152
- }
153
- spacing.propTypes = process.env.NODE_ENV !== 'production' ? spacingKeys.reduce(function (obj, key) {
154
- obj[key] = responsivePropType;
155
- return obj;
156
- }, {}) : {};
157
- spacing.filterProps = spacingKeys;
158
- export default spacing;
@@ -1,4 +0,0 @@
1
- 'use client';
2
-
3
- export { default } from './style';
4
- export * from './style';
@@ -1,73 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import capitalize from '@mui/utils/capitalize';
3
- import responsivePropType from '../responsivePropType';
4
- import { handleBreakpoints } from '../breakpoints';
5
- export function getPath(obj, path) {
6
- var checkVars = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
7
- if (!path || typeof path !== 'string') {
8
- return null;
9
- }
10
-
11
- // Check if CSS variables are used
12
- if (obj && obj.vars && checkVars) {
13
- var val = "vars.".concat(path).split('.').reduce(function (acc, item) {
14
- return acc && acc[item] ? acc[item] : null;
15
- }, obj);
16
- if (val != null) {
17
- return val;
18
- }
19
- }
20
- return path.split('.').reduce(function (acc, item) {
21
- if (acc && acc[item] != null) {
22
- return acc[item];
23
- }
24
- return null;
25
- }, obj);
26
- }
27
- export function getStyleValue(themeMapping, transform, propValueFinal) {
28
- var userValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : propValueFinal;
29
- var value;
30
- if (typeof themeMapping === 'function') {
31
- value = themeMapping(propValueFinal);
32
- } else if (Array.isArray(themeMapping)) {
33
- value = themeMapping[propValueFinal] || userValue;
34
- } else {
35
- value = getPath(themeMapping, propValueFinal) || userValue;
36
- }
37
- if (transform) {
38
- value = transform(value, userValue, themeMapping);
39
- }
40
- return value;
41
- }
42
- function style(options) {
43
- var prop = options.prop,
44
- _options$cssProperty = options.cssProperty,
45
- cssProperty = _options$cssProperty === void 0 ? options.prop : _options$cssProperty,
46
- themeKey = options.themeKey,
47
- transform = options.transform; // false positive
48
- // eslint-disable-next-line react/function-component-definition
49
- var fn = function fn(props) {
50
- if (props[prop] == null) {
51
- return null;
52
- }
53
- var propValue = props[prop];
54
- var theme = props.theme;
55
- var themeMapping = getPath(theme, themeKey) || {};
56
- var styleFromPropValue = function styleFromPropValue(propValueFinal) {
57
- var value = getStyleValue(themeMapping, transform, propValueFinal);
58
- if (propValueFinal === value && typeof propValueFinal === 'string') {
59
- // Haven't found value
60
- value = getStyleValue(themeMapping, transform, "".concat(prop).concat(propValueFinal === 'default' ? '' : capitalize(propValueFinal)), propValueFinal);
61
- }
62
- if (cssProperty === false) {
63
- return value;
64
- }
65
- return _defineProperty({}, cssProperty, value);
66
- };
67
- return handleBreakpoints(props, propValue, styleFromPropValue);
68
- };
69
- fn.propTypes = process.env.NODE_ENV !== 'production' ? _defineProperty({}, prop, responsivePropType) : {};
70
- fn.filterProps = [prop];
71
- return fn;
72
- }
73
- export default style;
@@ -1,293 +0,0 @@
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
- outline: {
44
- themeKey: 'borders',
45
- transform: borderTransform
46
- },
47
- outlineColor: {
48
- themeKey: 'palette'
49
- },
50
- borderRadius: {
51
- themeKey: 'shape.borderRadius',
52
- style: borderRadius
53
- },
54
- // palette
55
- color: {
56
- themeKey: 'palette',
57
- transform: paletteTransform
58
- },
59
- bgcolor: {
60
- themeKey: 'palette',
61
- cssProperty: 'backgroundColor',
62
- transform: paletteTransform
63
- },
64
- backgroundColor: {
65
- themeKey: 'palette',
66
- transform: paletteTransform
67
- },
68
- // spacing
69
- p: {
70
- style: padding
71
- },
72
- pt: {
73
- style: padding
74
- },
75
- pr: {
76
- style: padding
77
- },
78
- pb: {
79
- style: padding
80
- },
81
- pl: {
82
- style: padding
83
- },
84
- px: {
85
- style: padding
86
- },
87
- py: {
88
- style: padding
89
- },
90
- padding: {
91
- style: padding
92
- },
93
- paddingTop: {
94
- style: padding
95
- },
96
- paddingRight: {
97
- style: padding
98
- },
99
- paddingBottom: {
100
- style: padding
101
- },
102
- paddingLeft: {
103
- style: padding
104
- },
105
- paddingX: {
106
- style: padding
107
- },
108
- paddingY: {
109
- style: padding
110
- },
111
- paddingInline: {
112
- style: padding
113
- },
114
- paddingInlineStart: {
115
- style: padding
116
- },
117
- paddingInlineEnd: {
118
- style: padding
119
- },
120
- paddingBlock: {
121
- style: padding
122
- },
123
- paddingBlockStart: {
124
- style: padding
125
- },
126
- paddingBlockEnd: {
127
- style: padding
128
- },
129
- m: {
130
- style: margin
131
- },
132
- mt: {
133
- style: margin
134
- },
135
- mr: {
136
- style: margin
137
- },
138
- mb: {
139
- style: margin
140
- },
141
- ml: {
142
- style: margin
143
- },
144
- mx: {
145
- style: margin
146
- },
147
- my: {
148
- style: margin
149
- },
150
- margin: {
151
- style: margin
152
- },
153
- marginTop: {
154
- style: margin
155
- },
156
- marginRight: {
157
- style: margin
158
- },
159
- marginBottom: {
160
- style: margin
161
- },
162
- marginLeft: {
163
- style: margin
164
- },
165
- marginX: {
166
- style: margin
167
- },
168
- marginY: {
169
- style: margin
170
- },
171
- marginInline: {
172
- style: margin
173
- },
174
- marginInlineStart: {
175
- style: margin
176
- },
177
- marginInlineEnd: {
178
- style: margin
179
- },
180
- marginBlock: {
181
- style: margin
182
- },
183
- marginBlockStart: {
184
- style: margin
185
- },
186
- marginBlockEnd: {
187
- style: margin
188
- },
189
- // display
190
- displayPrint: {
191
- cssProperty: false,
192
- transform: function transform(value) {
193
- return {
194
- '@media print': {
195
- display: value
196
- }
197
- };
198
- }
199
- },
200
- display: {},
201
- overflow: {},
202
- textOverflow: {},
203
- visibility: {},
204
- whiteSpace: {},
205
- // flexbox
206
- flexBasis: {},
207
- flexDirection: {},
208
- flexWrap: {},
209
- justifyContent: {},
210
- alignItems: {},
211
- alignContent: {},
212
- order: {},
213
- flex: {},
214
- flexGrow: {},
215
- flexShrink: {},
216
- alignSelf: {},
217
- justifyItems: {},
218
- justifySelf: {},
219
- // grid
220
- gap: {
221
- style: gap
222
- },
223
- rowGap: {
224
- style: rowGap
225
- },
226
- columnGap: {
227
- style: columnGap
228
- },
229
- gridColumn: {},
230
- gridRow: {},
231
- gridAutoFlow: {},
232
- gridAutoColumns: {},
233
- gridAutoRows: {},
234
- gridTemplateColumns: {},
235
- gridTemplateRows: {},
236
- gridTemplateAreas: {},
237
- gridArea: {},
238
- // positions
239
- position: {},
240
- zIndex: {
241
- themeKey: 'zIndex'
242
- },
243
- top: {},
244
- right: {},
245
- bottom: {},
246
- left: {},
247
- // shadows
248
- boxShadow: {
249
- themeKey: 'shadows'
250
- },
251
- // sizing
252
- width: {
253
- transform: sizingTransform
254
- },
255
- maxWidth: {
256
- style: maxWidth
257
- },
258
- minWidth: {
259
- transform: sizingTransform
260
- },
261
- height: {
262
- transform: sizingTransform
263
- },
264
- maxHeight: {
265
- transform: sizingTransform
266
- },
267
- minHeight: {
268
- transform: sizingTransform
269
- },
270
- boxSizing: {},
271
- // typography
272
- fontFamily: {
273
- themeKey: 'typography'
274
- },
275
- fontSize: {
276
- themeKey: 'typography'
277
- },
278
- fontStyle: {
279
- themeKey: 'typography'
280
- },
281
- fontWeight: {
282
- themeKey: 'typography'
283
- },
284
- letterSpacing: {},
285
- textTransform: {},
286
- lineHeight: {},
287
- textAlign: {},
288
- typography: {
289
- cssProperty: false,
290
- themeKey: 'typography'
291
- }
292
- };
293
- export default defaultSxConfig;
@@ -1,45 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import { isPlainObject } from '@mui/utils/deepmerge';
5
- import defaultSxConfig from './defaultSxConfig';
6
- var splitProps = function splitProps(props) {
7
- var _props$theme$unstable, _props$theme;
8
- var result = {
9
- systemProps: {},
10
- otherProps: {}
11
- };
12
- var config = (_props$theme$unstable = props == null || (_props$theme = props.theme) == null ? void 0 : _props$theme.unstable_sxConfig) != null ? _props$theme$unstable : defaultSxConfig;
13
- Object.keys(props).forEach(function (prop) {
14
- if (config[prop]) {
15
- result.systemProps[prop] = props[prop];
16
- } else {
17
- result.otherProps[prop] = props[prop];
18
- }
19
- });
20
- return result;
21
- };
22
- export default function extendSxProp(props) {
23
- var inSx = props.sx,
24
- other = _objectWithoutProperties(props, ["sx"]);
25
- var _splitProps = splitProps(other),
26
- systemProps = _splitProps.systemProps,
27
- otherProps = _splitProps.otherProps;
28
- var finalSx;
29
- if (Array.isArray(inSx)) {
30
- finalSx = [systemProps].concat(_toConsumableArray(inSx));
31
- } else if (typeof inSx === 'function') {
32
- finalSx = function finalSx() {
33
- var result = inSx.apply(void 0, arguments);
34
- if (!isPlainObject(result)) {
35
- return systemProps;
36
- }
37
- return _extends({}, systemProps, result);
38
- };
39
- } else {
40
- finalSx = _extends({}, systemProps, inSx);
41
- }
42
- return _extends({}, otherProps, {
43
- sx: finalSx
44
- });
45
- }
@@ -1,4 +0,0 @@
1
- export { default } from './styleFunctionSx';
2
- export { unstable_createStyleFunctionSx } from './styleFunctionSx';
3
- export { default as extendSxProp } from './extendSxProp';
4
- export { default as unstable_defaultSxConfig } from './defaultSxConfig';
@@ -1,126 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import capitalize from '@mui/utils/capitalize';
4
- import merge from '../merge';
5
- import { getPath, getStyleValue as getValue } from '../style';
6
- import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
7
- import defaultSxConfig from './defaultSxConfig';
8
- function objectsHaveSameKeys() {
9
- for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
10
- objects[_key] = arguments[_key];
11
- }
12
- var allKeys = objects.reduce(function (keys, object) {
13
- return keys.concat(Object.keys(object));
14
- }, []);
15
- var union = new Set(allKeys);
16
- return objects.every(function (object) {
17
- return union.size === Object.keys(object).length;
18
- });
19
- }
20
- function callIfFn(maybeFn, arg) {
21
- return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
22
- }
23
-
24
- // eslint-disable-next-line @typescript-eslint/naming-convention
25
- export function unstable_createStyleFunctionSx() {
26
- function getThemeValue(prop, val, theme, config) {
27
- var props = _defineProperty(_defineProperty({}, prop, val), "theme", theme);
28
- var options = config[prop];
29
- if (!options) {
30
- return _defineProperty({}, prop, val);
31
- }
32
- var _options$cssProperty = options.cssProperty,
33
- cssProperty = _options$cssProperty === void 0 ? prop : _options$cssProperty,
34
- themeKey = options.themeKey,
35
- transform = options.transform,
36
- style = options.style;
37
- if (val == null) {
38
- return null;
39
- }
40
-
41
- // TODO v6: remove, see https://github.com/mui/material-ui/pull/38123
42
- if (themeKey === 'typography' && val === 'inherit') {
43
- return _defineProperty({}, prop, val);
44
- }
45
- var themeMapping = getPath(theme, themeKey) || {};
46
- if (style) {
47
- return style(props);
48
- }
49
- var styleFromPropValue = function styleFromPropValue(propValueFinal) {
50
- var value = getValue(themeMapping, transform, propValueFinal);
51
- if (propValueFinal === value && typeof propValueFinal === 'string') {
52
- // Haven't found value
53
- value = getValue(themeMapping, transform, "".concat(prop).concat(propValueFinal === 'default' ? '' : capitalize(propValueFinal)), propValueFinal);
54
- }
55
- if (cssProperty === false) {
56
- return value;
57
- }
58
- return _defineProperty({}, cssProperty, value);
59
- };
60
- return handleBreakpoints(props, val, styleFromPropValue);
61
- }
62
- function styleFunctionSx(props) {
63
- var _theme$unstable_sxCon;
64
- var _ref4 = props || {},
65
- sx = _ref4.sx,
66
- _ref4$theme = _ref4.theme,
67
- theme = _ref4$theme === void 0 ? {} : _ref4$theme;
68
- if (!sx) {
69
- return null; // Emotion & styled-components will neglect null
70
- }
71
- var config = (_theme$unstable_sxCon = theme.unstable_sxConfig) != null ? _theme$unstable_sxCon : defaultSxConfig;
72
-
73
- /*
74
- * Receive `sxInput` as object or callback
75
- * and then recursively check keys & values to create media query object styles.
76
- * (the result will be used in `styled`)
77
- */
78
- function traverse(sxInput) {
79
- var sxObject = sxInput;
80
- if (typeof sxInput === 'function') {
81
- sxObject = sxInput(theme);
82
- } else if (_typeof(sxInput) !== 'object') {
83
- // value
84
- return sxInput;
85
- }
86
- if (!sxObject) {
87
- return null;
88
- }
89
- var emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
90
- var breakpointsKeys = Object.keys(emptyBreakpoints);
91
- var css = emptyBreakpoints;
92
- Object.keys(sxObject).forEach(function (styleKey) {
93
- var value = callIfFn(sxObject[styleKey], theme);
94
- if (value !== null && value !== undefined) {
95
- if (_typeof(value) === 'object') {
96
- if (config[styleKey]) {
97
- css = merge(css, getThemeValue(styleKey, value, theme, config));
98
- } else {
99
- var breakpointsValues = handleBreakpoints({
100
- theme: theme
101
- }, value, function (x) {
102
- return _defineProperty({}, styleKey, x);
103
- });
104
- if (objectsHaveSameKeys(breakpointsValues, value)) {
105
- css[styleKey] = styleFunctionSx({
106
- sx: value,
107
- theme: theme
108
- });
109
- } else {
110
- css = merge(css, breakpointsValues);
111
- }
112
- }
113
- } else {
114
- css = merge(css, getThemeValue(styleKey, value, theme, config));
115
- }
116
- }
117
- });
118
- return removeUnusedBreakpoints(breakpointsKeys, css);
119
- }
120
- return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
121
- }
122
- return styleFunctionSx;
123
- }
124
- var styleFunctionSx = unstable_createStyleFunctionSx();
125
- styleFunctionSx.filterProps = ['sx'];
126
- export default styleFunctionSx;