@mui/system 5.10.13 → 5.10.14

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 (206) hide show
  1. package/Box/Box.js +1 -10
  2. package/Box/Box.spec.d.ts +1 -1
  3. package/Box/index.js +0 -2
  4. package/CHANGELOG.md +70 -2
  5. package/Container/Container.d.ts +13 -13
  6. package/Container/Container.js +2 -17
  7. package/Container/ContainerProps.d.ts +40 -40
  8. package/Container/containerClasses.d.ts +22 -22
  9. package/Container/containerClasses.js +0 -3
  10. package/Container/createContainer.d.ts +18 -18
  11. package/Container/createContainer.js +15 -37
  12. package/Container/index.js +0 -6
  13. package/Stack/Stack.d.ts +13 -13
  14. package/Stack/Stack.js +1 -12
  15. package/Stack/StackProps.d.ts +42 -42
  16. package/Stack/createStack.d.ts +21 -21
  17. package/Stack/createStack.js +10 -48
  18. package/Stack/index.d.ts +5 -5
  19. package/Stack/index.js +0 -9
  20. package/Stack/stackClasses.d.ts +8 -8
  21. package/Stack/stackClasses.js +0 -3
  22. package/ThemeProvider/ThemeProvider.js +2 -22
  23. package/ThemeProvider/index.js +0 -2
  24. package/Unstable_Grid/Grid.d.ts +12 -12
  25. package/Unstable_Grid/Grid.js +6 -42
  26. package/Unstable_Grid/GridProps.d.ts +162 -162
  27. package/Unstable_Grid/createGrid.d.ts +11 -11
  28. package/Unstable_Grid/createGrid.js +19 -49
  29. package/Unstable_Grid/gridClasses.d.ts +20 -20
  30. package/Unstable_Grid/gridClasses.js +8 -7
  31. package/Unstable_Grid/gridGenerator.d.ts +29 -28
  32. package/Unstable_Grid/gridGenerator.js +22 -63
  33. package/Unstable_Grid/index.d.ts +5 -5
  34. package/Unstable_Grid/index.js +0 -9
  35. package/borders.js +0 -14
  36. package/breakpoints.js +3 -32
  37. package/colorManipulator.js +13 -55
  38. package/compose.js +0 -7
  39. package/createBox.js +5 -20
  40. package/createBox.spec.d.ts +1 -1
  41. package/createStyled.js +27 -71
  42. package/createTheme/createBreakpoints.js +22 -37
  43. package/createTheme/createSpacing.d.ts +10 -10
  44. package/createTheme/createSpacing.js +4 -8
  45. package/createTheme/createTheme.js +6 -16
  46. package/createTheme/index.js +0 -2
  47. package/cssGrid.js +0 -21
  48. package/cssVars/createCssVarsProvider.js +24 -72
  49. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  50. package/cssVars/createGetCssVar.d.ts +5 -5
  51. package/cssVars/createGetCssVar.js +2 -7
  52. package/cssVars/cssVarsParser.d.ts +65 -65
  53. package/cssVars/cssVarsParser.js +3 -15
  54. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  55. package/cssVars/getInitColorSchemeScript.js +0 -6
  56. package/cssVars/index.d.ts +3 -3
  57. package/cssVars/index.js +0 -3
  58. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  59. package/cssVars/useCurrentColorScheme.js +20 -49
  60. package/display.js +0 -6
  61. package/esm/Box/Box.js +1 -6
  62. package/esm/Container/Container.js +3 -14
  63. package/esm/Container/createContainer.js +15 -25
  64. package/esm/Stack/Stack.js +1 -9
  65. package/esm/Stack/createStack.js +10 -29
  66. package/esm/ThemeProvider/ThemeProvider.js +2 -11
  67. package/esm/Unstable_Grid/Grid.js +6 -39
  68. package/esm/Unstable_Grid/createGrid.js +18 -35
  69. package/esm/Unstable_Grid/gridClasses.js +8 -4
  70. package/esm/Unstable_Grid/gridGenerator.js +20 -38
  71. package/esm/borders.js +0 -6
  72. package/esm/breakpoints.js +7 -22
  73. package/esm/colorManipulator.js +13 -43
  74. package/esm/compose.js +0 -5
  75. package/esm/createBox.js +5 -7
  76. package/esm/createStyled.js +27 -64
  77. package/esm/createTheme/createBreakpoints.js +22 -34
  78. package/esm/createTheme/createSpacing.js +4 -7
  79. package/esm/createTheme/createTheme.js +6 -9
  80. package/esm/cssGrid.js +0 -9
  81. package/esm/cssVars/createCssVarsProvider.js +24 -58
  82. package/esm/cssVars/createGetCssVar.js +2 -6
  83. package/esm/cssVars/cssVarsParser.js +3 -11
  84. package/esm/cssVars/useCurrentColorScheme.js +20 -44
  85. package/esm/getThemeValue.js +0 -2
  86. package/esm/index.js +1 -2
  87. package/esm/memoize.js +0 -1
  88. package/esm/merge.js +0 -3
  89. package/esm/palette.js +0 -3
  90. package/esm/propsToClassKey.js +4 -7
  91. package/esm/sizing.js +0 -5
  92. package/esm/spacing.js +3 -23
  93. package/esm/style.js +2 -19
  94. package/esm/styleFunctionSx/extendSxProp.js +3 -10
  95. package/esm/styleFunctionSx/styleFunctionSx.js +3 -16
  96. package/esm/sx/sx.js +0 -2
  97. package/esm/useTheme.js +0 -2
  98. package/esm/useThemeProps/getThemeProps.js +0 -2
  99. package/esm/useThemeWithoutDefault.js +0 -3
  100. package/flexbox.js +0 -4
  101. package/getThemeValue.js +0 -14
  102. package/index.js +1 -55
  103. package/index.spec.d.ts +1 -1
  104. package/legacy/Box/Box.js +1 -6
  105. package/legacy/Container/Container.js +3 -14
  106. package/legacy/Container/createContainer.js +29 -39
  107. package/legacy/Stack/Stack.js +1 -9
  108. package/legacy/Stack/createStack.js +17 -37
  109. package/legacy/ThemeProvider/ThemeProvider.js +3 -12
  110. package/legacy/Unstable_Grid/Grid.js +6 -39
  111. package/legacy/Unstable_Grid/createGrid.js +34 -53
  112. package/legacy/Unstable_Grid/gridGenerator.js +36 -58
  113. package/legacy/borders.js +0 -6
  114. package/legacy/breakpoints.js +9 -28
  115. package/legacy/colorManipulator.js +16 -48
  116. package/legacy/compose.js +0 -6
  117. package/legacy/createBox.js +9 -11
  118. package/legacy/createStyled.js +27 -68
  119. package/legacy/createTheme/createBreakpoints.js +20 -33
  120. package/legacy/createTheme/createSpacing.js +4 -9
  121. package/legacy/createTheme/createTheme.js +7 -13
  122. package/legacy/cssGrid.js +0 -9
  123. package/legacy/cssVars/createCssVarsProvider.js +90 -129
  124. package/legacy/cssVars/createGetCssVar.js +2 -10
  125. package/legacy/cssVars/cssVarsParser.js +7 -20
  126. package/legacy/cssVars/getInitColorSchemeScript.js +14 -15
  127. package/legacy/cssVars/useCurrentColorScheme.js +43 -69
  128. package/legacy/getThemeValue.js +0 -3
  129. package/legacy/index.js +2 -3
  130. package/legacy/memoize.js +0 -1
  131. package/legacy/merge.js +0 -3
  132. package/legacy/palette.js +0 -3
  133. package/legacy/propsToClassKey.js +2 -5
  134. package/legacy/sizing.js +0 -5
  135. package/legacy/spacing.js +6 -27
  136. package/legacy/style.js +6 -24
  137. package/legacy/styleFunctionSx/extendSxProp.js +3 -11
  138. package/legacy/styleFunctionSx/styleFunctionSx.js +6 -21
  139. package/legacy/sx/sx.js +0 -2
  140. package/legacy/useTheme.js +0 -2
  141. package/legacy/useThemeProps/getThemeProps.js +2 -4
  142. package/legacy/useThemeProps/useThemeProps.js +2 -2
  143. package/legacy/useThemeWithoutDefault.js +0 -3
  144. package/memoize.js +0 -2
  145. package/merge.js +0 -5
  146. package/modern/Box/Box.js +1 -6
  147. package/modern/Container/Container.js +3 -14
  148. package/modern/Container/createContainer.js +15 -25
  149. package/modern/Stack/Stack.js +1 -9
  150. package/modern/Stack/createStack.js +10 -29
  151. package/modern/ThemeProvider/ThemeProvider.js +2 -11
  152. package/modern/Unstable_Grid/Grid.js +6 -39
  153. package/modern/Unstable_Grid/createGrid.js +18 -34
  154. package/modern/Unstable_Grid/gridClasses.js +8 -4
  155. package/modern/Unstable_Grid/gridGenerator.js +20 -36
  156. package/modern/borders.js +0 -6
  157. package/modern/breakpoints.js +7 -21
  158. package/modern/colorManipulator.js +13 -43
  159. package/modern/compose.js +0 -5
  160. package/modern/createBox.js +5 -7
  161. package/modern/createStyled.js +27 -63
  162. package/modern/createTheme/createBreakpoints.js +22 -34
  163. package/modern/createTheme/createSpacing.js +4 -7
  164. package/modern/createTheme/createTheme.js +6 -9
  165. package/modern/cssGrid.js +0 -9
  166. package/modern/cssVars/createCssVarsProvider.js +24 -58
  167. package/modern/cssVars/createGetCssVar.js +2 -6
  168. package/modern/cssVars/cssVarsParser.js +3 -11
  169. package/modern/cssVars/useCurrentColorScheme.js +20 -44
  170. package/modern/getThemeValue.js +0 -2
  171. package/modern/index.js +2 -3
  172. package/modern/memoize.js +0 -1
  173. package/modern/merge.js +0 -3
  174. package/modern/palette.js +0 -3
  175. package/modern/propsToClassKey.js +4 -7
  176. package/modern/sizing.js +0 -4
  177. package/modern/spacing.js +3 -22
  178. package/modern/style.js +2 -19
  179. package/modern/styleFunctionSx/extendSxProp.js +3 -10
  180. package/modern/styleFunctionSx/styleFunctionSx.js +3 -16
  181. package/modern/sx/sx.js +0 -2
  182. package/modern/useTheme.js +0 -2
  183. package/modern/useThemeProps/getThemeProps.js +0 -2
  184. package/modern/useThemeWithoutDefault.js +0 -3
  185. package/package.json +6 -6
  186. package/palette.js +0 -6
  187. package/positions.js +0 -6
  188. package/propsToClassKey.js +4 -10
  189. package/responsivePropType.js +0 -3
  190. package/shadows.js +0 -3
  191. package/sizing.js +0 -11
  192. package/spacing.js +3 -37
  193. package/style.js +2 -24
  194. package/styleFunctionSx/extendSxProp.js +3 -15
  195. package/styleFunctionSx/index.js +0 -5
  196. package/styleFunctionSx/styleFunctionSx.js +3 -21
  197. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
  198. package/styled.js +0 -3
  199. package/sx/index.js +0 -2
  200. package/sx/sx.js +0 -4
  201. package/typography.js +0 -4
  202. package/useTheme.js +0 -6
  203. package/useThemeProps/getThemeProps.js +0 -4
  204. package/useThemeProps/index.js +0 -3
  205. package/useThemeProps/useThemeProps.js +0 -4
  206. package/useThemeWithoutDefault.js +0 -4
@@ -1,43 +1,44 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- export const traverseBreakpoints = (breakpoints, responsize, iterator) => {
2
+ export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
3
+ export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
3
4
  const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
4
5
 
5
- if (Array.isArray(responsize)) {
6
- responsize.forEach((breakpointValue, index) => {
7
- iterator((responsizeStyles, style) => {
6
+ if (Array.isArray(responsive)) {
7
+ responsive.forEach((breakpointValue, index) => {
8
+ iterator((responsiveStyles, style) => {
8
9
  if (index <= breakpoints.keys.length - 1) {
9
10
  if (index === 0) {
10
- Object.assign(responsizeStyles, style);
11
+ Object.assign(responsiveStyles, style);
11
12
  } else {
12
- responsizeStyles[breakpoints.up(breakpoints.keys[index])] = style;
13
+ responsiveStyles[breakpoints.up(breakpoints.keys[index])] = style;
13
14
  }
14
15
  }
15
16
  }, breakpointValue);
16
17
  });
17
- } else if (responsize && typeof responsize === 'object') {
18
+ } else if (responsive && typeof responsive === 'object') {
18
19
  // prevent null
19
- // responsize could be a very big object, pick the smallest responsive values
20
- const keys = Object.keys(responsize).length > breakpoints.keys.length ? breakpoints.keys : Object.keys(responsize);
20
+ // responsive could be a very big object, pick the smallest responsive values
21
+
22
+ const keys = Object.keys(responsive).length > breakpoints.keys.length ? breakpoints.keys : filterBreakpointKeys(breakpoints.keys, Object.keys(responsive));
21
23
  keys.forEach(key => {
22
24
  if (breakpoints.keys.indexOf(key) !== -1) {
23
- // @ts-ignore already checked that responsize is an object
24
- const breakpointValue = responsize[key];
25
-
25
+ // @ts-ignore already checked that responsive is an object
26
+ const breakpointValue = responsive[key];
26
27
  if (breakpointValue !== undefined) {
27
- iterator((responsizeStyles, style) => {
28
+ iterator((responsiveStyles, style) => {
28
29
  if (smallestBreakpoint === key) {
29
- Object.assign(responsizeStyles, style);
30
+ Object.assign(responsiveStyles, style);
30
31
  } else {
31
- responsizeStyles[breakpoints.up(key)] = style;
32
+ responsiveStyles[breakpoints.up(key)] = style;
32
33
  }
33
34
  }, breakpointValue);
34
35
  }
35
36
  }
36
37
  });
37
- } else if (typeof responsize === 'number' || typeof responsize === 'string') {
38
- iterator((responsizeStyles, style) => {
39
- Object.assign(responsizeStyles, style);
40
- }, responsize);
38
+ } else if (typeof responsive === 'number' || typeof responsive === 'string') {
39
+ iterator((responsiveStyles, style) => {
40
+ Object.assign(responsiveStyles, style);
41
+ }, responsive);
41
42
  }
42
43
  };
43
44
  export const generateGridSizeStyles = ({
@@ -47,7 +48,6 @@ export const generateGridSizeStyles = ({
47
48
  const styles = {};
48
49
  traverseBreakpoints(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
49
50
  let style = {};
50
-
51
51
  if (value === true) {
52
52
  style = {
53
53
  flexBasis: 0,
@@ -55,7 +55,6 @@ export const generateGridSizeStyles = ({
55
55
  maxWidth: '100%'
56
56
  };
57
57
  }
58
-
59
58
  if (value === 'auto') {
60
59
  style = {
61
60
  flexBasis: 'auto',
@@ -65,7 +64,6 @@ export const generateGridSizeStyles = ({
65
64
  width: 'auto'
66
65
  };
67
66
  }
68
-
69
67
  if (typeof value === 'number') {
70
68
  style = {
71
69
  flexGrow: 0,
@@ -73,7 +71,6 @@ export const generateGridSizeStyles = ({
73
71
  width: `calc(100% * ${value} / var(--Grid-columns)${ownerState.nested && ownerState.container ? ` + var(--Grid-columnSpacing)` : ''})`
74
72
  };
75
73
  }
76
-
77
74
  appendStyle(styles, style);
78
75
  });
79
76
  return styles;
@@ -85,19 +82,16 @@ export const generateGridOffsetStyles = ({
85
82
  const styles = {};
86
83
  traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
87
84
  let style = {};
88
-
89
85
  if (value === 'auto') {
90
86
  style = {
91
87
  marginLeft: 'auto'
92
88
  };
93
89
  }
94
-
95
90
  if (typeof value === 'number') {
96
91
  style = {
97
92
  marginLeft: value === 0 ? '0px' : `calc(100% * ${value} / var(--Grid-columns))`
98
93
  };
99
94
  }
100
-
101
95
  appendStyle(styles, style);
102
96
  });
103
97
  return styles;
@@ -109,7 +103,6 @@ export const generateGridColumnsStyles = ({
109
103
  if (!ownerState.container) {
110
104
  return {};
111
105
  }
112
-
113
106
  const styles = {
114
107
  '--Grid-columns': 12
115
108
  };
@@ -127,11 +120,9 @@ export const generateGridRowSpacingStyles = ({
127
120
  if (!ownerState.container) {
128
121
  return {};
129
122
  }
130
-
131
123
  const styles = {};
132
124
  traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
133
125
  var _theme$spacing;
134
-
135
126
  appendStyle(styles, {
136
127
  '--Grid-rowSpacing': typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
137
128
  });
@@ -145,11 +136,9 @@ export const generateGridColumnSpacingStyles = ({
145
136
  if (!ownerState.container) {
146
137
  return {};
147
138
  }
148
-
149
139
  const styles = {};
150
140
  traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
151
141
  var _theme$spacing2;
152
-
153
142
  appendStyle(styles, {
154
143
  '--Grid-columnSpacing': typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
155
144
  });
@@ -163,7 +152,6 @@ export const generateGridDirectionStyles = ({
163
152
  if (!ownerState.container) {
164
153
  return {};
165
154
  }
166
-
167
155
  const styles = {};
168
156
  traverseBreakpoints(theme.breakpoints, ownerState.direction, (appendStyle, value) => {
169
157
  appendStyle(styles, {
@@ -214,14 +202,11 @@ export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') =>
214
202
  if (val === undefined) {
215
203
  return false;
216
204
  }
217
-
218
205
  return typeof val === 'string' && !Number.isNaN(Number(val)) || typeof val === 'number' && val > 0;
219
206
  }
220
-
221
207
  if (isValidSpacing(spacing)) {
222
208
  return [`spacing-${smallestBreakpoint}-${String(spacing)}`];
223
209
  }
224
-
225
210
  if (typeof spacing === 'object' && !Array.isArray(spacing)) {
226
211
  const classNames = [];
227
212
  Object.entries(spacing).forEach(([key, value]) => {
@@ -231,17 +216,14 @@ export const generateSpacingClassNames = (spacing, smallestBreakpoint = 'xs') =>
231
216
  });
232
217
  return classNames;
233
218
  }
234
-
235
219
  return [];
236
220
  };
237
221
  export const generateDirectionClasses = direction => {
238
222
  if (direction === undefined) {
239
223
  return [];
240
224
  }
241
-
242
225
  if (typeof direction === 'object') {
243
226
  return Object.entries(direction).map(([key, value]) => `direction-${key}-${value}`);
244
227
  }
245
-
246
228
  return [`direction-xs-${String(direction)}`];
247
229
  };
package/esm/borders.js CHANGED
@@ -3,15 +3,12 @@ import style from './style';
3
3
  import compose from './compose';
4
4
  import { createUnaryUnit, getValue } from './spacing';
5
5
  import { handleBreakpoints } from './breakpoints';
6
-
7
6
  function getBorder(value) {
8
7
  if (typeof value !== 'number') {
9
8
  return value;
10
9
  }
11
-
12
10
  return `${value}px solid`;
13
11
  }
14
-
15
12
  export const border = style({
16
13
  prop: 'border',
17
14
  themeKey: 'borders',
@@ -60,14 +57,11 @@ export const borderLeftColor = style({
60
57
  export const borderRadius = props => {
61
58
  if (props.borderRadius !== undefined && props.borderRadius !== null) {
62
59
  const transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius');
63
-
64
60
  const styleFromPropValue = propValue => ({
65
61
  borderRadius: getValue(transformer, propValue)
66
62
  });
67
-
68
63
  return handleBreakpoints(props, props.borderRadius, styleFromPropValue);
69
64
  }
70
-
71
65
  return null;
72
66
  };
73
67
  borderRadius.propTypes = process.env.NODE_ENV !== 'production' ? {
@@ -1,9 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import PropTypes from 'prop-types';
3
3
  import { deepmerge } from '@mui/utils';
4
- import merge from './merge'; // The breakpoint **start** at this value.
5
- // For instance with the first breakpoint xs: [xs, sm[.
4
+ import merge from './merge';
6
5
 
6
+ // The breakpoint **start** at this value.
7
+ // For instance with the first breakpoint xs: [xs, sm[.
7
8
  export const values = {
8
9
  xs: 0,
9
10
  // phone
@@ -14,8 +15,8 @@ export const values = {
14
15
  lg: 1200,
15
16
  // desktop
16
17
  xl: 1536 // large screen
17
-
18
18
  };
19
+
19
20
  const defaultBreakpoints = {
20
21
  // Sorted ASC by size. That's important.
21
22
  // It can't be configured as it's used statically for propTypes.
@@ -24,7 +25,6 @@ const defaultBreakpoints = {
24
25
  };
25
26
  export function handleBreakpoints(props, propValue, styleFromPropValue) {
26
27
  const theme = props.theme || {};
27
-
28
28
  if (Array.isArray(propValue)) {
29
29
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
30
30
  return propValue.reduce((acc, item, index) => {
@@ -32,7 +32,6 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
32
32
  return acc;
33
33
  }, {});
34
34
  }
35
-
36
35
  if (typeof propValue === 'object') {
37
36
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
38
37
  return Object.keys(propValue).reduce((acc, breakpoint) => {
@@ -44,15 +43,12 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
44
43
  const cssKey = breakpoint;
45
44
  acc[cssKey] = propValue[cssKey];
46
45
  }
47
-
48
46
  return acc;
49
47
  }, {});
50
48
  }
51
-
52
49
  const output = styleFromPropValue(propValue);
53
50
  return output;
54
51
  }
55
-
56
52
  function breakpoints(styleFunction) {
57
53
  const newStyleFunction = props => {
58
54
  const theme = props.theme || {};
@@ -65,12 +61,10 @@ function breakpoints(styleFunction) {
65
61
  theme
66
62
  }, props[key]));
67
63
  }
68
-
69
64
  return acc;
70
65
  }, null);
71
66
  return merge(base, extended);
72
67
  };
73
-
74
68
  newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? _extends({}, styleFunction.propTypes, {
75
69
  xs: PropTypes.object,
76
70
  sm: PropTypes.object,
@@ -81,10 +75,8 @@ function breakpoints(styleFunction) {
81
75
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
82
76
  return newStyleFunction;
83
77
  }
84
-
85
78
  export function createEmptyBreakpointObject(breakpointsInput = {}) {
86
79
  var _breakpointsInput$key;
87
-
88
80
  const breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
89
81
  const breakpointStyleKey = breakpointsInput.up(key);
90
82
  acc[breakpointStyleKey] = {};
@@ -96,11 +88,9 @@ export function removeUnusedBreakpoints(breakpointKeys, style) {
96
88
  return breakpointKeys.reduce((acc, key) => {
97
89
  const breakpointOutput = acc[key];
98
90
  const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
99
-
100
91
  if (isBreakpointUnused) {
101
92
  delete acc[key];
102
93
  }
103
-
104
94
  return acc;
105
95
  }, style);
106
96
  }
@@ -108,19 +98,18 @@ export function mergeBreakpointsInOrder(breakpointsInput, ...styles) {
108
98
  const emptyBreakpoints = createEmptyBreakpointObject(breakpointsInput);
109
99
  const mergedOutput = [emptyBreakpoints, ...styles].reduce((prev, next) => deepmerge(prev, next), {});
110
100
  return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
111
- } // compute base for responsive values; e.g.,
101
+ }
102
+
103
+ // compute base for responsive values; e.g.,
112
104
  // [1,2,3] => {xs: true, sm: true, md: true}
113
105
  // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
114
-
115
106
  export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
116
107
  // fixed value
117
108
  if (typeof breakpointValues !== 'object') {
118
109
  return {};
119
110
  }
120
-
121
111
  const base = {};
122
112
  const breakpointsKeys = Object.keys(themeBreakpoints);
123
-
124
113
  if (Array.isArray(breakpointValues)) {
125
114
  breakpointsKeys.forEach((breakpoint, i) => {
126
115
  if (i < breakpointValues.length) {
@@ -134,7 +123,6 @@ export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
134
123
  }
135
124
  });
136
125
  }
137
-
138
126
  return base;
139
127
  }
140
128
  export function resolveBreakpointValues({
@@ -144,11 +132,9 @@ export function resolveBreakpointValues({
144
132
  }) {
145
133
  const base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
146
134
  const keys = Object.keys(base);
147
-
148
135
  if (keys.length === 0) {
149
136
  return breakpointValues;
150
137
  }
151
-
152
138
  let previous;
153
139
  return keys.reduce((acc, breakpoint, i) => {
154
140
  if (Array.isArray(breakpointValues)) {
@@ -160,7 +146,6 @@ export function resolveBreakpointValues({
160
146
  } else {
161
147
  acc[breakpoint] = breakpointValues;
162
148
  }
163
-
164
149
  return acc;
165
150
  }, {});
166
151
  }
@@ -1,5 +1,4 @@
1
1
  import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
2
-
3
2
  /**
4
3
  * Returns a number whose value is limited to the given range.
5
4
  * @param {number} value The value to be clamped
@@ -13,34 +12,30 @@ function clamp(value, min = 0, max = 1) {
13
12
  console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
14
13
  }
15
14
  }
16
-
17
15
  return Math.min(Math.max(min, value), max);
18
16
  }
17
+
19
18
  /**
20
19
  * Converts a color from CSS hex format to CSS rgb format.
21
20
  * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
22
21
  * @returns {string} A CSS rgb color string
23
22
  */
24
-
25
-
26
23
  export function hexToRgb(color) {
27
24
  color = color.slice(1);
28
25
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
29
26
  let colors = color.match(re);
30
-
31
27
  if (colors && colors[0].length === 1) {
32
28
  colors = colors.map(n => n + n);
33
29
  }
34
-
35
30
  return colors ? `rgb${colors.length === 4 ? 'a' : ''}(${colors.map((n, index) => {
36
31
  return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
37
32
  }).join(', ')})` : '';
38
33
  }
39
-
40
34
  function intToHex(int) {
41
35
  const hex = int.toString(16);
42
36
  return hex.length === 1 ? `0${hex}` : hex;
43
37
  }
38
+
44
39
  /**
45
40
  * Returns an object with the type and values of a color.
46
41
  *
@@ -48,37 +43,28 @@ function intToHex(int) {
48
43
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
49
44
  * @returns {object} - A MUI color object: {type: string, values: number[]}
50
45
  */
51
-
52
-
53
46
  export function decomposeColor(color) {
54
47
  // Idempotent
55
48
  if (color.type) {
56
49
  return color;
57
50
  }
58
-
59
51
  if (color.charAt(0) === '#') {
60
52
  return decomposeColor(hexToRgb(color));
61
53
  }
62
-
63
54
  const marker = color.indexOf('(');
64
55
  const type = color.substring(0, marker);
65
-
66
56
  if (['rgb', 'rgba', 'hsl', 'hsla', 'color'].indexOf(type) === -1) {
67
57
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Unsupported \`${color}\` color.
68
58
  The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().` : _formatMuiErrorMessage(9, color));
69
59
  }
70
-
71
60
  let values = color.substring(marker + 1, color.length - 1);
72
61
  let colorSpace;
73
-
74
62
  if (type === 'color') {
75
63
  values = values.split(' ');
76
64
  colorSpace = values.shift();
77
-
78
65
  if (values.length === 4 && values[3].charAt(0) === '/') {
79
66
  values[3] = values[3].slice(1);
80
67
  }
81
-
82
68
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
83
69
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: unsupported \`${colorSpace}\` color space.
84
70
  The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.` : _formatMuiErrorMessage(10, colorSpace));
@@ -86,7 +72,6 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
86
72
  } else {
87
73
  values = values.split(',');
88
74
  }
89
-
90
75
  values = values.map(value => parseFloat(value));
91
76
  return {
92
77
  type,
@@ -94,17 +79,18 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
94
79
  colorSpace
95
80
  };
96
81
  }
82
+
97
83
  /**
98
84
  * Returns a channel created from the input color.
99
85
  *
100
86
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
101
87
  * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
102
88
  */
103
-
104
89
  export const colorChannel = color => {
105
90
  const decomposedColor = decomposeColor(color);
106
91
  return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
107
92
  };
93
+
108
94
  /**
109
95
  * Converts a color object with type and values to a string.
110
96
  * @param {object} color - Decomposed color
@@ -112,7 +98,6 @@ export const colorChannel = color => {
112
98
  * @param {array} color.values - [n,n,n] or [n,n,n,n]
113
99
  * @returns {string} A CSS color string
114
100
  */
115
-
116
101
  export function recomposeColor(color) {
117
102
  const {
118
103
  type,
@@ -121,7 +106,6 @@ export function recomposeColor(color) {
121
106
  let {
122
107
  values
123
108
  } = color;
124
-
125
109
  if (type.indexOf('rgb') !== -1) {
126
110
  // Only convert the first 3 values to int (i.e. not alpha)
127
111
  values = values.map((n, i) => i < 3 ? parseInt(n, 10) : n);
@@ -129,38 +113,35 @@ export function recomposeColor(color) {
129
113
  values[1] = `${values[1]}%`;
130
114
  values[2] = `${values[2]}%`;
131
115
  }
132
-
133
116
  if (type.indexOf('color') !== -1) {
134
117
  values = `${colorSpace} ${values.join(' ')}`;
135
118
  } else {
136
119
  values = `${values.join(', ')}`;
137
120
  }
138
-
139
121
  return `${type}(${values})`;
140
122
  }
123
+
141
124
  /**
142
125
  * Converts a color from CSS rgb format to CSS hex format.
143
126
  * @param {string} color - RGB color, i.e. rgb(n, n, n)
144
127
  * @returns {string} A CSS rgb color string, i.e. #nnnnnn
145
128
  */
146
-
147
129
  export function rgbToHex(color) {
148
130
  // Idempotent
149
131
  if (color.indexOf('#') === 0) {
150
132
  return color;
151
133
  }
152
-
153
134
  const {
154
135
  values
155
136
  } = decomposeColor(color);
156
137
  return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
157
138
  }
139
+
158
140
  /**
159
141
  * Converts a color from hsl format to rgb format.
160
142
  * @param {string} color - HSL color values
161
143
  * @returns {string} rgb color values
162
144
  */
163
-
164
145
  export function hslToRgb(color) {
165
146
  color = decomposeColor(color);
166
147
  const {
@@ -170,17 +151,13 @@ export function hslToRgb(color) {
170
151
  const s = values[1] / 100;
171
152
  const l = values[2] / 100;
172
153
  const a = s * Math.min(l, 1 - l);
173
-
174
154
  const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
175
-
176
155
  let type = 'rgb';
177
156
  const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
178
-
179
157
  if (color.type === 'hsla') {
180
158
  type += 'a';
181
159
  rgb.push(values[3]);
182
160
  }
183
-
184
161
  return recomposeColor({
185
162
  type,
186
163
  values: rgb
@@ -194,7 +171,6 @@ export function hslToRgb(color) {
194
171
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
195
172
  * @returns {number} The relative brightness of the color in the range 0 - 1
196
173
  */
197
-
198
174
  export function getLuminance(color) {
199
175
  color = decomposeColor(color);
200
176
  let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
@@ -204,10 +180,12 @@ export function getLuminance(color) {
204
180
  }
205
181
 
206
182
  return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
207
- }); // Truncate at 3 digits
183
+ });
208
184
 
185
+ // Truncate at 3 digits
209
186
  return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
210
187
  }
188
+
211
189
  /**
212
190
  * Calculates the contrast ratio between two colors.
213
191
  *
@@ -216,12 +194,12 @@ export function getLuminance(color) {
216
194
  * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
217
195
  * @returns {number} A contrast ratio value in the range 0 - 21.
218
196
  */
219
-
220
197
  export function getContrastRatio(foreground, background) {
221
198
  const lumA = getLuminance(foreground);
222
199
  const lumB = getLuminance(background);
223
200
  return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
224
201
  }
202
+
225
203
  /**
226
204
  * Sets the absolute transparency of a color.
227
205
  * Any existing alpha values are overwritten.
@@ -229,34 +207,29 @@ export function getContrastRatio(foreground, background) {
229
207
  * @param {number} value - value to set the alpha channel to in the range 0 - 1
230
208
  * @returns {string} A CSS color string. Hex input values are returned as rgb
231
209
  */
232
-
233
210
  export function alpha(color, value) {
234
211
  color = decomposeColor(color);
235
212
  value = clamp(value);
236
-
237
213
  if (color.type === 'rgb' || color.type === 'hsl') {
238
214
  color.type += 'a';
239
215
  }
240
-
241
216
  if (color.type === 'color') {
242
217
  color.values[3] = `/${value}`;
243
218
  } else {
244
219
  color.values[3] = value;
245
220
  }
246
-
247
221
  return recomposeColor(color);
248
222
  }
223
+
249
224
  /**
250
225
  * Darkens a color.
251
226
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
252
227
  * @param {number} coefficient - multiplier in the range 0 - 1
253
228
  * @returns {string} A CSS color string. Hex input values are returned as rgb
254
229
  */
255
-
256
230
  export function darken(color, coefficient) {
257
231
  color = decomposeColor(color);
258
232
  coefficient = clamp(coefficient);
259
-
260
233
  if (color.type.indexOf('hsl') !== -1) {
261
234
  color.values[2] *= 1 - coefficient;
262
235
  } else if (color.type.indexOf('rgb') !== -1 || color.type.indexOf('color') !== -1) {
@@ -264,20 +237,18 @@ export function darken(color, coefficient) {
264
237
  color.values[i] *= 1 - coefficient;
265
238
  }
266
239
  }
267
-
268
240
  return recomposeColor(color);
269
241
  }
242
+
270
243
  /**
271
244
  * Lightens a color.
272
245
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
273
246
  * @param {number} coefficient - multiplier in the range 0 - 1
274
247
  * @returns {string} A CSS color string. Hex input values are returned as rgb
275
248
  */
276
-
277
249
  export function lighten(color, coefficient) {
278
250
  color = decomposeColor(color);
279
251
  coefficient = clamp(coefficient);
280
-
281
252
  if (color.type.indexOf('hsl') !== -1) {
282
253
  color.values[2] += (100 - color.values[2]) * coefficient;
283
254
  } else if (color.type.indexOf('rgb') !== -1) {
@@ -289,9 +260,9 @@ export function lighten(color, coefficient) {
289
260
  color.values[i] += (1 - color.values[i]) * coefficient;
290
261
  }
291
262
  }
292
-
293
263
  return recomposeColor(color);
294
264
  }
265
+
295
266
  /**
296
267
  * Darken or lighten a color, depending on its luminance.
297
268
  * Light colors are darkened, dark colors are lightened.
@@ -299,7 +270,6 @@ export function lighten(color, coefficient) {
299
270
  * @param {number} coefficient=0.15 - multiplier in the range 0 - 1
300
271
  * @returns {string} A CSS color string. Hex input values are returned as rgb
301
272
  */
302
-
303
273
  export function emphasize(color, coefficient = 0.15) {
304
274
  return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
305
275
  }
package/esm/compose.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import merge from './merge';
2
-
3
2
  function compose(...styles) {
4
3
  const handlers = styles.reduce((acc, style) => {
5
4
  style.filterProps.forEach(prop => {
@@ -7,20 +6,16 @@ function compose(...styles) {
7
6
  });
8
7
  return acc;
9
8
  }, {});
10
-
11
9
  const fn = props => {
12
10
  return Object.keys(props).reduce((acc, prop) => {
13
11
  if (handlers[prop]) {
14
12
  return merge(acc, handlers[prop](props));
15
13
  }
16
-
17
14
  return acc;
18
15
  }, {});
19
16
  };
20
-
21
17
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
22
18
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
23
19
  return fn;
24
20
  }
25
-
26
21
  export default compose;
package/esm/createBox.js CHANGED
@@ -19,14 +19,12 @@ export default function createBox(options = {}) {
19
19
  })(styleFunctionSx);
20
20
  const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
21
21
  const theme = useTheme(defaultTheme);
22
-
23
22
  const _extendSxProp = extendSxProp(inProps),
24
- {
25
- className,
26
- component = 'div'
27
- } = _extendSxProp,
28
- other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded);
29
-
23
+ {
24
+ className,
25
+ component = 'div'
26
+ } = _extendSxProp,
27
+ other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded);
30
28
  return /*#__PURE__*/_jsx(BoxRoot, _extends({
31
29
  as: component,
32
30
  ref: ref,