@mui/system 5.10.13 → 5.10.15

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 (185) hide show
  1. package/Box/Box.js +1 -10
  2. package/Box/index.js +0 -2
  3. package/CHANGELOG.md +132 -2
  4. package/Container/Container.js +2 -17
  5. package/Container/containerClasses.js +0 -3
  6. package/Container/createContainer.js +15 -37
  7. package/Container/index.js +0 -6
  8. package/Stack/Stack.js +1 -12
  9. package/Stack/createStack.js +10 -48
  10. package/Stack/index.js +0 -9
  11. package/Stack/stackClasses.js +0 -3
  12. package/ThemeProvider/ThemeProvider.js +2 -22
  13. package/ThemeProvider/index.js +0 -2
  14. package/Unstable_Grid/Grid.js +6 -42
  15. package/Unstable_Grid/createGrid.js +19 -49
  16. package/Unstable_Grid/gridClasses.js +8 -7
  17. package/Unstable_Grid/gridGenerator.d.ts +4 -3
  18. package/Unstable_Grid/gridGenerator.js +22 -63
  19. package/Unstable_Grid/index.js +0 -9
  20. package/borders.js +0 -14
  21. package/breakpoints.js +3 -32
  22. package/colorManipulator.js +13 -55
  23. package/compose.js +0 -7
  24. package/createBox.js +5 -20
  25. package/createStyled.js +27 -71
  26. package/createTheme/createBreakpoints.js +22 -37
  27. package/createTheme/createSpacing.js +4 -8
  28. package/createTheme/createTheme.js +6 -16
  29. package/createTheme/index.js +0 -2
  30. package/cssGrid.js +0 -21
  31. package/cssVars/createCssVarsProvider.js +33 -74
  32. package/cssVars/createGetCssVar.js +2 -7
  33. package/cssVars/cssVarsParser.js +3 -15
  34. package/cssVars/getInitColorSchemeScript.js +0 -6
  35. package/cssVars/index.js +0 -3
  36. package/cssVars/useCurrentColorScheme.js +20 -49
  37. package/display.js +0 -6
  38. package/esm/Box/Box.js +1 -6
  39. package/esm/Container/Container.js +3 -14
  40. package/esm/Container/createContainer.js +15 -25
  41. package/esm/Stack/Stack.js +1 -9
  42. package/esm/Stack/createStack.js +10 -29
  43. package/esm/ThemeProvider/ThemeProvider.js +2 -11
  44. package/esm/Unstable_Grid/Grid.js +6 -39
  45. package/esm/Unstable_Grid/createGrid.js +18 -35
  46. package/esm/Unstable_Grid/gridClasses.js +8 -4
  47. package/esm/Unstable_Grid/gridGenerator.js +20 -38
  48. package/esm/borders.js +0 -6
  49. package/esm/breakpoints.js +7 -22
  50. package/esm/colorManipulator.js +13 -43
  51. package/esm/compose.js +0 -5
  52. package/esm/createBox.js +5 -7
  53. package/esm/createStyled.js +27 -64
  54. package/esm/createTheme/createBreakpoints.js +22 -34
  55. package/esm/createTheme/createSpacing.js +4 -7
  56. package/esm/createTheme/createTheme.js +6 -9
  57. package/esm/cssGrid.js +0 -9
  58. package/esm/cssVars/createCssVarsProvider.js +33 -60
  59. package/esm/cssVars/createGetCssVar.js +2 -6
  60. package/esm/cssVars/cssVarsParser.js +3 -11
  61. package/esm/cssVars/useCurrentColorScheme.js +20 -44
  62. package/esm/getThemeValue.js +0 -2
  63. package/esm/index.js +3 -3
  64. package/esm/memoize.js +0 -1
  65. package/esm/merge.js +0 -3
  66. package/esm/palette.js +0 -3
  67. package/esm/propsToClassKey.js +4 -7
  68. package/esm/sizing.js +0 -5
  69. package/esm/spacing.js +3 -23
  70. package/esm/style.js +5 -22
  71. package/esm/styleFunctionSx/extendSxProp.js +3 -10
  72. package/esm/styleFunctionSx/styleFunctionSx.js +3 -16
  73. package/esm/sx/sx.js +0 -2
  74. package/esm/useTheme.js +0 -2
  75. package/esm/useThemeProps/getThemeProps.js +0 -2
  76. package/esm/useThemeWithoutDefault.js +0 -3
  77. package/flexbox.js +0 -4
  78. package/getThemeValue.js +0 -14
  79. package/index.d.ts +2 -0
  80. package/index.js +16 -55
  81. package/legacy/Box/Box.js +1 -6
  82. package/legacy/Container/Container.js +3 -14
  83. package/legacy/Container/createContainer.js +29 -39
  84. package/legacy/Stack/Stack.js +1 -9
  85. package/legacy/Stack/createStack.js +17 -37
  86. package/legacy/ThemeProvider/ThemeProvider.js +3 -12
  87. package/legacy/Unstable_Grid/Grid.js +6 -39
  88. package/legacy/Unstable_Grid/createGrid.js +34 -53
  89. package/legacy/Unstable_Grid/gridGenerator.js +36 -58
  90. package/legacy/borders.js +0 -6
  91. package/legacy/breakpoints.js +9 -28
  92. package/legacy/colorManipulator.js +16 -48
  93. package/legacy/compose.js +0 -6
  94. package/legacy/createBox.js +9 -11
  95. package/legacy/createStyled.js +27 -68
  96. package/legacy/createTheme/createBreakpoints.js +20 -33
  97. package/legacy/createTheme/createSpacing.js +4 -9
  98. package/legacy/createTheme/createTheme.js +7 -13
  99. package/legacy/cssGrid.js +0 -9
  100. package/legacy/cssVars/createCssVarsProvider.js +98 -130
  101. package/legacy/cssVars/createGetCssVar.js +2 -10
  102. package/legacy/cssVars/cssVarsParser.js +7 -20
  103. package/legacy/cssVars/getInitColorSchemeScript.js +14 -15
  104. package/legacy/cssVars/useCurrentColorScheme.js +43 -69
  105. package/legacy/getThemeValue.js +0 -3
  106. package/legacy/index.js +4 -4
  107. package/legacy/memoize.js +0 -1
  108. package/legacy/merge.js +0 -3
  109. package/legacy/palette.js +0 -3
  110. package/legacy/propsToClassKey.js +2 -5
  111. package/legacy/sizing.js +0 -5
  112. package/legacy/spacing.js +6 -27
  113. package/legacy/style.js +9 -27
  114. package/legacy/styleFunctionSx/extendSxProp.js +3 -11
  115. package/legacy/styleFunctionSx/styleFunctionSx.js +6 -21
  116. package/legacy/sx/sx.js +0 -2
  117. package/legacy/useTheme.js +0 -2
  118. package/legacy/useThemeProps/getThemeProps.js +2 -4
  119. package/legacy/useThemeProps/useThemeProps.js +2 -2
  120. package/legacy/useThemeWithoutDefault.js +0 -3
  121. package/memoize.js +0 -2
  122. package/merge.js +0 -5
  123. package/modern/Box/Box.js +1 -6
  124. package/modern/Container/Container.js +3 -14
  125. package/modern/Container/createContainer.js +15 -25
  126. package/modern/Stack/Stack.js +1 -9
  127. package/modern/Stack/createStack.js +10 -29
  128. package/modern/ThemeProvider/ThemeProvider.js +2 -11
  129. package/modern/Unstable_Grid/Grid.js +6 -39
  130. package/modern/Unstable_Grid/createGrid.js +18 -34
  131. package/modern/Unstable_Grid/gridClasses.js +8 -4
  132. package/modern/Unstable_Grid/gridGenerator.js +20 -36
  133. package/modern/borders.js +0 -6
  134. package/modern/breakpoints.js +7 -21
  135. package/modern/colorManipulator.js +13 -43
  136. package/modern/compose.js +0 -5
  137. package/modern/createBox.js +5 -7
  138. package/modern/createStyled.js +27 -63
  139. package/modern/createTheme/createBreakpoints.js +22 -34
  140. package/modern/createTheme/createSpacing.js +4 -7
  141. package/modern/createTheme/createTheme.js +6 -9
  142. package/modern/cssGrid.js +0 -9
  143. package/modern/cssVars/createCssVarsProvider.js +33 -60
  144. package/modern/cssVars/createGetCssVar.js +2 -6
  145. package/modern/cssVars/cssVarsParser.js +3 -11
  146. package/modern/cssVars/useCurrentColorScheme.js +20 -44
  147. package/modern/getThemeValue.js +0 -2
  148. package/modern/index.js +4 -4
  149. package/modern/memoize.js +0 -1
  150. package/modern/merge.js +0 -3
  151. package/modern/palette.js +0 -3
  152. package/modern/propsToClassKey.js +4 -7
  153. package/modern/sizing.js +0 -4
  154. package/modern/spacing.js +3 -22
  155. package/modern/style.js +5 -22
  156. package/modern/styleFunctionSx/extendSxProp.js +3 -10
  157. package/modern/styleFunctionSx/styleFunctionSx.js +3 -16
  158. package/modern/sx/sx.js +0 -2
  159. package/modern/useTheme.js +0 -2
  160. package/modern/useThemeProps/getThemeProps.js +0 -2
  161. package/modern/useThemeWithoutDefault.js +0 -3
  162. package/package.json +6 -6
  163. package/palette.js +0 -6
  164. package/positions.js +0 -6
  165. package/propsToClassKey.js +4 -10
  166. package/responsivePropType.d.ts +3 -0
  167. package/responsivePropType.js +0 -3
  168. package/shadows.js +0 -3
  169. package/sizing.js +0 -11
  170. package/spacing.d.ts +14 -0
  171. package/spacing.js +3 -37
  172. package/style.d.ts +6 -0
  173. package/style.js +6 -27
  174. package/styleFunctionSx/extendSxProp.js +3 -15
  175. package/styleFunctionSx/index.js +0 -5
  176. package/styleFunctionSx/styleFunctionSx.js +3 -21
  177. package/styled.js +0 -3
  178. package/sx/index.js +0 -2
  179. package/sx/sx.js +0 -4
  180. package/typography.js +0 -4
  181. package/useTheme.js +0 -6
  182. package/useThemeProps/getThemeProps.js +0 -4
  183. package/useThemeProps/index.js +0 -3
  184. package/useThemeProps/useThemeProps.js +0 -4
  185. package/useThemeWithoutDefault.js +0 -4
@@ -1,23 +1,20 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  const _excluded = ["variant"];
3
3
  import { unstable_capitalize as capitalize } from '@mui/utils';
4
-
5
4
  function isEmpty(string) {
6
5
  return string.length === 0;
7
6
  }
7
+
8
8
  /**
9
9
  * Generates string classKey based on the properties provided. It starts with the
10
10
  * variant if defined, and then it appends all other properties in alphabetical order.
11
11
  * @param {object} props - the properties for which the classKey should be created.
12
12
  */
13
-
14
-
15
13
  export default function propsToClassKey(props) {
16
14
  const {
17
- variant
18
- } = props,
19
- other = _objectWithoutPropertiesLoose(props, _excluded);
20
-
15
+ variant
16
+ } = props,
17
+ other = _objectWithoutPropertiesLoose(props, _excluded);
21
18
  let classKey = variant || '';
22
19
  Object.keys(other).sort().forEach(key => {
23
20
  if (key === 'color') {
package/modern/sizing.js CHANGED
@@ -1,11 +1,9 @@
1
1
  import style from './style';
2
2
  import compose from './compose';
3
3
  import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
4
-
5
4
  function transform(value) {
6
5
  return value <= 1 && value !== 0 ? `${value * 100}%` : value;
7
6
  }
8
-
9
7
  export const width = style({
10
8
  prop: 'width',
11
9
  transform
@@ -18,10 +16,8 @@ export const maxWidth = props => {
18
16
  maxWidth: breakpoint || transform(propValue)
19
17
  };
20
18
  };
21
-
22
19
  return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
23
20
  }
24
-
25
21
  return null;
26
22
  };
27
23
  maxWidth.filterProps = ['maxWidth'];
package/modern/spacing.js CHANGED
@@ -20,10 +20,11 @@ const aliases = {
20
20
  marginY: 'my',
21
21
  paddingX: 'px',
22
22
  paddingY: 'py'
23
- }; // memoize() impact:
23
+ };
24
+
25
+ // memoize() impact:
24
26
  // From 300,000 ops/sec
25
27
  // To 350,000 ops/sec
26
-
27
28
  const getCssProperties = memoize(prop => {
28
29
  // It's not a shorthand notation.
29
30
  if (prop.length > 2) {
@@ -33,7 +34,6 @@ const getCssProperties = memoize(prop => {
33
34
  return [prop];
34
35
  }
35
36
  }
36
-
37
37
  const [a, b] = prop.split('');
38
38
  const property = properties[a];
39
39
  const direction = directions[b] || '';
@@ -44,29 +44,24 @@ const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddin
44
44
  const spacingKeys = [...marginKeys, ...paddingKeys];
45
45
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
46
46
  const themeSpacing = getPath(theme, themeKey, false) ?? defaultValue;
47
-
48
47
  if (typeof themeSpacing === 'number') {
49
48
  return abs => {
50
49
  if (typeof abs === 'string') {
51
50
  return abs;
52
51
  }
53
-
54
52
  if (process.env.NODE_ENV !== 'production') {
55
53
  if (typeof abs !== 'number') {
56
54
  console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${abs}.`);
57
55
  }
58
56
  }
59
-
60
57
  return themeSpacing * abs;
61
58
  };
62
59
  }
63
-
64
60
  if (Array.isArray(themeSpacing)) {
65
61
  return abs => {
66
62
  if (typeof abs === 'string') {
67
63
  return abs;
68
64
  }
69
-
70
65
  if (process.env.NODE_ENV !== 'production') {
71
66
  if (!Number.isInteger(abs)) {
72
67
  console.error([`MUI: The \`theme.${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.${themeKey}\` as a number.`].join('\n'));
@@ -74,19 +69,15 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
74
69
  console.error([`MUI: The value provided (${abs}) overflows.`, `The supported values are: ${JSON.stringify(themeSpacing)}.`, `${abs} > ${themeSpacing.length - 1}, you need to add the missing values.`].join('\n'));
75
70
  }
76
71
  }
77
-
78
72
  return themeSpacing[abs];
79
73
  };
80
74
  }
81
-
82
75
  if (typeof themeSpacing === 'function') {
83
76
  return themeSpacing;
84
77
  }
85
-
86
78
  if (process.env.NODE_ENV !== 'production') {
87
79
  console.error([`MUI: The \`theme.${themeKey}\` value (${themeSpacing}) is invalid.`, 'It should be a number, an array or a function.'].join('\n'));
88
80
  }
89
-
90
81
  return () => undefined;
91
82
  }
92
83
  export function createUnarySpacing(theme) {
@@ -96,18 +87,14 @@ export function getValue(transformer, propValue) {
96
87
  if (typeof propValue === 'string' || propValue == null) {
97
88
  return propValue;
98
89
  }
99
-
100
90
  const abs = Math.abs(propValue);
101
91
  const transformed = transformer(abs);
102
-
103
92
  if (propValue >= 0) {
104
93
  return transformed;
105
94
  }
106
-
107
95
  if (typeof transformed === 'number') {
108
96
  return -transformed;
109
97
  }
110
-
111
98
  return `-${transformed}`;
112
99
  }
113
100
  export function getStyleFromPropValue(cssProperties, transformer) {
@@ -116,25 +103,21 @@ export function getStyleFromPropValue(cssProperties, transformer) {
116
103
  return acc;
117
104
  }, {});
118
105
  }
119
-
120
106
  function resolveCssProperty(props, keys, prop, transformer) {
121
107
  // Using a hash computation over an array iteration could be faster, but with only 28 items,
122
108
  // it's doesn't worth the bundle size.
123
109
  if (keys.indexOf(prop) === -1) {
124
110
  return null;
125
111
  }
126
-
127
112
  const cssProperties = getCssProperties(prop);
128
113
  const styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
129
114
  const propValue = props[prop];
130
115
  return handleBreakpoints(props, propValue, styleFromPropValue);
131
116
  }
132
-
133
117
  function style(props, keys) {
134
118
  const transformer = createUnarySpacing(props.theme);
135
119
  return Object.keys(props).map(prop => resolveCssProperty(props, keys, prop, transformer)).reduce(merge, {});
136
120
  }
137
-
138
121
  export function margin(props) {
139
122
  return style(props, marginKeys);
140
123
  }
@@ -151,11 +134,9 @@ padding.propTypes = process.env.NODE_ENV !== 'production' ? paddingKeys.reduce((
151
134
  return obj;
152
135
  }, {}) : {};
153
136
  padding.filterProps = paddingKeys;
154
-
155
137
  function spacing(props) {
156
138
  return style(props, spacingKeys);
157
139
  }
158
-
159
140
  spacing.propTypes = process.env.NODE_ENV !== 'production' ? spacingKeys.reduce((obj, key) => {
160
141
  obj[key] = responsivePropType;
161
142
  return obj;
package/modern/style.js CHANGED
@@ -4,29 +4,24 @@ import { handleBreakpoints } from './breakpoints';
4
4
  export function getPath(obj, path, checkVars = true) {
5
5
  if (!path || typeof path !== 'string') {
6
6
  return null;
7
- } // Check if CSS variables are used
8
-
7
+ }
9
8
 
9
+ // Check if CSS variables are used
10
10
  if (obj && obj.vars && checkVars) {
11
11
  const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
12
-
13
12
  if (val != null) {
14
13
  return val;
15
14
  }
16
15
  }
17
-
18
16
  return path.split('.').reduce((acc, item) => {
19
17
  if (acc && acc[item] != null) {
20
18
  return acc[item];
21
19
  }
22
-
23
20
  return null;
24
21
  }, obj);
25
22
  }
26
-
27
- function getValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
23
+ export function getStyleValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
28
24
  let value;
29
-
30
25
  if (typeof themeMapping === 'function') {
31
26
  value = themeMapping(propValueFinal);
32
27
  } else if (Array.isArray(themeMapping)) {
@@ -34,14 +29,11 @@ function getValue(themeMapping, transform, propValueFinal, userValue = propValue
34
29
  } else {
35
30
  value = getPath(themeMapping, propValueFinal) || userValue;
36
31
  }
37
-
38
32
  if (transform) {
39
33
  value = transform(value, userValue);
40
34
  }
41
-
42
35
  return value;
43
36
  }
44
-
45
37
  function style(options) {
46
38
  const {
47
39
  prop,
@@ -49,41 +41,32 @@ function style(options) {
49
41
  themeKey,
50
42
  transform
51
43
  } = options;
52
-
53
44
  const fn = props => {
54
45
  if (props[prop] == null) {
55
46
  return null;
56
47
  }
57
-
58
48
  const propValue = props[prop];
59
49
  const theme = props.theme;
60
50
  const themeMapping = getPath(theme, themeKey) || {};
61
-
62
51
  const styleFromPropValue = propValueFinal => {
63
- let value = getValue(themeMapping, transform, propValueFinal);
64
-
52
+ let value = getStyleValue(themeMapping, transform, propValueFinal);
65
53
  if (propValueFinal === value && typeof propValueFinal === 'string') {
66
54
  // Haven't found value
67
- value = getValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
55
+ value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
68
56
  }
69
-
70
57
  if (cssProperty === false) {
71
58
  return value;
72
59
  }
73
-
74
60
  return {
75
61
  [cssProperty]: value
76
62
  };
77
63
  };
78
-
79
64
  return handleBreakpoints(props, propValue, styleFromPropValue);
80
65
  };
81
-
82
66
  fn.propTypes = process.env.NODE_ENV !== 'production' ? {
83
67
  [prop]: responsivePropType
84
68
  } : {};
85
69
  fn.filterProps = [prop];
86
70
  return fn;
87
71
  }
88
-
89
72
  export default style;
@@ -3,7 +3,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["sx"];
4
4
  import { isPlainObject } from '@mui/utils';
5
5
  import { propToStyleFunction } from '../getThemeValue';
6
-
7
6
  const splitProps = props => {
8
7
  const result = {
9
8
  systemProps: {},
@@ -18,35 +17,29 @@ const splitProps = props => {
18
17
  });
19
18
  return result;
20
19
  };
21
-
22
20
  export default function extendSxProp(props) {
23
21
  const {
24
- sx: inSx
25
- } = props,
26
- other = _objectWithoutPropertiesLoose(props, _excluded);
27
-
22
+ sx: inSx
23
+ } = props,
24
+ other = _objectWithoutPropertiesLoose(props, _excluded);
28
25
  const {
29
26
  systemProps,
30
27
  otherProps
31
28
  } = splitProps(other);
32
29
  let finalSx;
33
-
34
30
  if (Array.isArray(inSx)) {
35
31
  finalSx = [systemProps, ...inSx];
36
32
  } else if (typeof inSx === 'function') {
37
33
  finalSx = (...args) => {
38
34
  const result = inSx(...args);
39
-
40
35
  if (!isPlainObject(result)) {
41
36
  return systemProps;
42
37
  }
43
-
44
38
  return _extends({}, systemProps, result);
45
39
  };
46
40
  } else {
47
41
  finalSx = _extends({}, systemProps, inSx);
48
42
  }
49
-
50
43
  return _extends({}, otherProps, {
51
44
  sx: finalSx
52
45
  });
@@ -1,18 +1,16 @@
1
1
  import merge from '../merge';
2
2
  import { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
3
3
  import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
4
-
5
4
  function objectsHaveSameKeys(...objects) {
6
5
  const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
7
6
  const union = new Set(allKeys);
8
7
  return objects.every(object => union.size === Object.keys(object).length);
9
8
  }
10
-
11
9
  function callIfFn(maybeFn, arg) {
12
10
  return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
13
- } // eslint-disable-next-line @typescript-eslint/naming-convention
14
-
11
+ }
15
12
 
13
+ // eslint-disable-next-line @typescript-eslint/naming-convention
16
14
  export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultStyleFunctionMapping) {
17
15
  const propToStyleFunction = Object.keys(styleFunctionMapping).reduce((acc, styleFnName) => {
18
16
  styleFunctionMapping[styleFnName].filterProps.forEach(propName => {
@@ -20,7 +18,6 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
20
18
  });
21
19
  return acc;
22
20
  }, {});
23
-
24
21
  function getThemeValue(prop, value, theme) {
25
22
  const inputProps = {
26
23
  [prop]: value,
@@ -31,43 +28,36 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
31
28
  [prop]: value
32
29
  };
33
30
  }
34
-
35
31
  function styleFunctionSx(props) {
36
32
  const {
37
33
  sx,
38
34
  theme = {}
39
35
  } = props || {};
40
-
41
36
  if (!sx) {
42
37
  return null; // Emotion & styled-components will neglect null
43
38
  }
39
+
44
40
  /*
45
41
  * Receive `sxInput` as object or callback
46
42
  * and then recursively check keys & values to create media query object styles.
47
43
  * (the result will be used in `styled`)
48
44
  */
49
-
50
-
51
45
  function traverse(sxInput) {
52
46
  let sxObject = sxInput;
53
-
54
47
  if (typeof sxInput === 'function') {
55
48
  sxObject = sxInput(theme);
56
49
  } else if (typeof sxInput !== 'object') {
57
50
  // value
58
51
  return sxInput;
59
52
  }
60
-
61
53
  if (!sxObject) {
62
54
  return null;
63
55
  }
64
-
65
56
  const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
66
57
  const breakpointsKeys = Object.keys(emptyBreakpoints);
67
58
  let css = emptyBreakpoints;
68
59
  Object.keys(sxObject).forEach(styleKey => {
69
60
  const value = callIfFn(sxObject[styleKey], theme);
70
-
71
61
  if (value !== null && value !== undefined) {
72
62
  if (typeof value === 'object') {
73
63
  if (propToStyleFunction[styleKey]) {
@@ -78,7 +68,6 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
78
68
  }, value, x => ({
79
69
  [styleKey]: x
80
70
  }));
81
-
82
71
  if (objectsHaveSameKeys(breakpointsValues, value)) {
83
72
  css[styleKey] = styleFunctionSx({
84
73
  sx: value,
@@ -95,10 +84,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
95
84
  });
96
85
  return removeUnusedBreakpoints(breakpointsKeys, css);
97
86
  }
98
-
99
87
  return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
100
88
  }
101
-
102
89
  return styleFunctionSx;
103
90
  }
104
91
  const styleFunctionSx = unstable_createStyleFunctionSx();
package/modern/sx/sx.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import styleFunctionSx from '../styleFunctionSx';
2
-
3
2
  function sx(styles) {
4
3
  return ({
5
4
  theme
@@ -8,5 +7,4 @@ function sx(styles) {
8
7
  theme
9
8
  });
10
9
  }
11
-
12
10
  export default sx;
@@ -1,9 +1,7 @@
1
1
  import createTheme from './createTheme';
2
2
  import useThemeWithoutDefault from './useThemeWithoutDefault';
3
3
  export const systemDefaultTheme = createTheme();
4
-
5
4
  function useTheme(defaultTheme = systemDefaultTheme) {
6
5
  return useThemeWithoutDefault(defaultTheme);
7
6
  }
8
-
9
7
  export default useTheme;
@@ -5,10 +5,8 @@ export default function getThemeProps(params) {
5
5
  name,
6
6
  props
7
7
  } = params;
8
-
9
8
  if (!theme || !theme.components || !theme.components[name] || !theme.components[name].defaultProps) {
10
9
  return props;
11
10
  }
12
-
13
11
  return resolveProps(theme.components[name].defaultProps, props);
14
12
  }
@@ -1,12 +1,9 @@
1
1
  import { useTheme as muiUseTheme } from '@mui/private-theming';
2
-
3
2
  function isObjectEmpty(obj) {
4
3
  return Object.keys(obj).length === 0;
5
4
  }
6
-
7
5
  function useTheme(defaultTheme = null) {
8
6
  const contextTheme = muiUseTheme();
9
7
  return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
10
8
  }
11
-
12
9
  export default useTheme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.10.13",
3
+ "version": "5.10.15",
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.19.0",
47
- "@mui/private-theming": "^5.10.9",
48
- "@mui/styled-engine": "^5.10.8",
49
- "@mui/types": "^7.2.0",
50
- "@mui/utils": "^5.10.9",
46
+ "@babel/runtime": "^7.20.1",
47
+ "@mui/private-theming": "^5.10.15",
48
+ "@mui/styled-engine": "^5.10.14",
49
+ "@mui/types": "^7.2.1",
50
+ "@mui/utils": "^5.10.15",
51
51
  "clsx": "^1.2.1",
52
52
  "csstype": "^3.1.1",
53
53
  "prop-types": "^15.8.1"
package/palette.js CHANGED
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = exports.color = exports.bgcolor = exports.backgroundColor = void 0;
9
-
10
8
  var _style = _interopRequireDefault(require("./style"));
11
-
12
9
  var _compose = _interopRequireDefault(require("./compose"));
13
-
14
10
  function transform(value, userValue) {
15
11
  if (userValue === 'grey') {
16
12
  return userValue;
17
13
  }
18
-
19
14
  return value;
20
15
  }
21
-
22
16
  const color = (0, _style.default)({
23
17
  prop: 'color',
24
18
  themeKey: 'palette',
package/positions.js CHANGED
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.zIndex = exports.top = exports.right = exports.position = exports.left = exports.default = exports.bottom = void 0;
9
-
10
8
  var _style = _interopRequireDefault(require("./style"));
11
-
12
9
  var _compose = _interopRequireDefault(require("./compose"));
13
-
14
10
  const position = (0, _style.default)({
15
11
  prop: 'position'
16
12
  });
@@ -36,7 +32,5 @@ const left = (0, _style.default)({
36
32
  prop: 'left'
37
33
  });
38
34
  exports.left = left;
39
-
40
35
  var _default = (0, _compose.default)(position, zIndex, top, right, bottom, left);
41
-
42
36
  exports.default = _default;
@@ -1,33 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = propsToClassKey;
9
-
10
8
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
-
12
9
  var _utils = require("@mui/utils");
13
-
14
10
  const _excluded = ["variant"];
15
-
16
11
  function isEmpty(string) {
17
12
  return string.length === 0;
18
13
  }
14
+
19
15
  /**
20
16
  * Generates string classKey based on the properties provided. It starts with the
21
17
  * variant if defined, and then it appends all other properties in alphabetical order.
22
18
  * @param {object} props - the properties for which the classKey should be created.
23
19
  */
24
-
25
-
26
20
  function propsToClassKey(props) {
27
21
  const {
28
- variant
29
- } = props,
30
- other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
22
+ variant
23
+ } = props,
24
+ other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
31
25
  let classKey = variant || '';
32
26
  Object.keys(other).sort().forEach(key => {
33
27
  if (key === 'color') {
@@ -0,0 +1,3 @@
1
+ declare const responsivePropType: object;
2
+
3
+ export default responsivePropType;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  const responsivePropType = process.env.NODE_ENV !== 'production' ? _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string, _propTypes.default.object, _propTypes.default.array]) : {};
13
10
  var _default = responsivePropType;
14
11
  exports.default = _default;
package/shadows.js CHANGED
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _style = _interopRequireDefault(require("./style"));
11
-
12
9
  const boxShadow = (0, _style.default)({
13
10
  prop: 'boxShadow',
14
11
  themeKey: 'shadows'
package/sizing.js CHANGED
@@ -1,45 +1,34 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.width = exports.sizeWidth = exports.sizeHeight = exports.minWidth = exports.minHeight = exports.maxWidth = exports.maxHeight = exports.height = exports.default = exports.boxSizing = void 0;
9
-
10
8
  var _style = _interopRequireDefault(require("./style"));
11
-
12
9
  var _compose = _interopRequireDefault(require("./compose"));
13
-
14
10
  var _breakpoints = require("./breakpoints");
15
-
16
11
  function transform(value) {
17
12
  return value <= 1 && value !== 0 ? `${value * 100}%` : value;
18
13
  }
19
-
20
14
  const width = (0, _style.default)({
21
15
  prop: 'width',
22
16
  transform
23
17
  });
24
18
  exports.width = width;
25
-
26
19
  const maxWidth = props => {
27
20
  if (props.maxWidth !== undefined && props.maxWidth !== null) {
28
21
  const styleFromPropValue = propValue => {
29
22
  var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
30
-
31
23
  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];
32
24
  return {
33
25
  maxWidth: breakpoint || transform(propValue)
34
26
  };
35
27
  };
36
-
37
28
  return (0, _breakpoints.handleBreakpoints)(props, props.maxWidth, styleFromPropValue);
38
29
  }
39
-
40
30
  return null;
41
31
  };
42
-
43
32
  exports.maxWidth = maxWidth;
44
33
  maxWidth.filterProps = ['maxWidth'];
45
34
  const minWidth = (0, _style.default)({
package/spacing.d.ts CHANGED
@@ -10,6 +10,20 @@ export function createUnarySpacing<Spacing>(theme: { spacing: Spacing }): Spacin
10
10
  : // warns in Dev
11
11
  () => undefined;
12
12
 
13
+ export function createUnaryUnit<Spacing>(
14
+ theme: { spacing: Spacing },
15
+ themeKey: string,
16
+ defaultValue: Spacing,
17
+ propName: string,
18
+ ): Spacing extends number
19
+ ? (abs: number | string) => number | number
20
+ : Spacing extends any[]
21
+ ? <Index extends number>(abs: Index | string) => Spacing[Index] | string
22
+ : Spacing extends (...args: unknown[]) => unknown
23
+ ? Spacing
24
+ : // warns in Dev
25
+ () => undefined;
26
+
13
27
  export const margin: SimpleStyleFunction<
14
28
  | 'm'
15
29
  | 'mt'