@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
@@ -2,41 +2,35 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
-
6
5
  /* eslint-disable no-underscore-dangle */
7
6
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
8
7
  import { getDisplayName } from '@mui/utils';
9
8
  import createTheme from './createTheme';
10
9
  import propsToClassKey from './propsToClassKey';
11
10
  import defaultStyleFunctionSx from './styleFunctionSx';
12
-
13
11
  function isEmpty(obj) {
14
12
  return Object.keys(obj).length === 0;
15
- } // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
16
-
13
+ }
17
14
 
15
+ // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
18
16
  function isStringTag(tag) {
19
- return typeof tag === 'string' && // 96 is one less than the char code
17
+ return typeof tag === 'string' &&
18
+ // 96 is one less than the char code
20
19
  // for "a" so this is checking that
21
20
  // it's a lowercase character
22
21
  tag.charCodeAt(0) > 96;
23
22
  }
24
-
25
23
  var getStyleOverrides = function getStyleOverrides(name, theme) {
26
24
  if (theme.components && theme.components[name] && theme.components[name].styleOverrides) {
27
25
  return theme.components[name].styleOverrides;
28
26
  }
29
-
30
27
  return null;
31
28
  };
32
-
33
29
  var getVariantStyles = function getVariantStyles(name, theme) {
34
30
  var variants = [];
35
-
36
31
  if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
37
32
  variants = theme.components[name].variants;
38
33
  }
39
-
40
34
  var variantsStyles = {};
41
35
  variants.forEach(function (definition) {
42
36
  var key = propsToClassKey(definition.props);
@@ -44,15 +38,12 @@ var getVariantStyles = function getVariantStyles(name, theme) {
44
38
  });
45
39
  return variantsStyles;
46
40
  };
47
-
48
41
  var variantsResolver = function variantsResolver(props, styles, theme, name) {
49
42
  var _theme$components, _theme$components$nam;
50
-
51
43
  var _props$ownerState = props.ownerState,
52
- ownerState = _props$ownerState === void 0 ? {} : _props$ownerState;
44
+ ownerState = _props$ownerState === void 0 ? {} : _props$ownerState;
53
45
  var variantsStyles = [];
54
46
  var themeVariants = theme == null ? void 0 : (_theme$components = theme.components) == null ? void 0 : (_theme$components$nam = _theme$components[name]) == null ? void 0 : _theme$components$nam.variants;
55
-
56
47
  if (themeVariants) {
57
48
  themeVariants.forEach(function (themeVariant) {
58
49
  var isMatch = true;
@@ -61,44 +52,38 @@ var variantsResolver = function variantsResolver(props, styles, theme, name) {
61
52
  isMatch = false;
62
53
  }
63
54
  });
64
-
65
55
  if (isMatch) {
66
56
  variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
67
57
  }
68
58
  });
69
59
  }
70
-
71
60
  return variantsStyles;
72
- }; // Update /system/styled/#api in case if this changes
73
-
61
+ };
74
62
 
63
+ // Update /system/styled/#api in case if this changes
75
64
  export function shouldForwardProp(prop) {
76
65
  return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
77
66
  }
78
67
  export var systemDefaultTheme = createTheme();
79
-
80
68
  var lowercaseFirstLetter = function lowercaseFirstLetter(string) {
81
69
  return string.charAt(0).toLowerCase() + string.slice(1);
82
70
  };
83
-
84
71
  export default function createStyled() {
85
72
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
86
73
  var _input$defaultTheme = input.defaultTheme,
87
- defaultTheme = _input$defaultTheme === void 0 ? systemDefaultTheme : _input$defaultTheme,
88
- _input$rootShouldForw = input.rootShouldForwardProp,
89
- rootShouldForwardProp = _input$rootShouldForw === void 0 ? shouldForwardProp : _input$rootShouldForw,
90
- _input$slotShouldForw = input.slotShouldForwardProp,
91
- slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw,
92
- _input$styleFunctionS = input.styleFunctionSx,
93
- styleFunctionSx = _input$styleFunctionS === void 0 ? defaultStyleFunctionSx : _input$styleFunctionS;
94
-
74
+ defaultTheme = _input$defaultTheme === void 0 ? systemDefaultTheme : _input$defaultTheme,
75
+ _input$rootShouldForw = input.rootShouldForwardProp,
76
+ rootShouldForwardProp = _input$rootShouldForw === void 0 ? shouldForwardProp : _input$rootShouldForw,
77
+ _input$slotShouldForw = input.slotShouldForwardProp,
78
+ slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw,
79
+ _input$styleFunctionS = input.styleFunctionSx,
80
+ styleFunctionSx = _input$styleFunctionS === void 0 ? defaultStyleFunctionSx : _input$styleFunctionS;
95
81
  var systemSx = function systemSx(props) {
96
82
  var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
97
83
  return styleFunctionSx(_extends({}, props, {
98
84
  theme: theme
99
85
  }));
100
86
  };
101
-
102
87
  systemSx.__mui_systemSx = true;
103
88
  return function (tag) {
104
89
  var inputOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -108,27 +93,21 @@ export default function createStyled() {
108
93
  return !(style != null && style.__mui_systemSx);
109
94
  });
110
95
  });
111
-
112
96
  var componentName = inputOptions.name,
113
- componentSlot = inputOptions.slot,
114
- inputSkipVariantsResolver = inputOptions.skipVariantsResolver,
115
- inputSkipSx = inputOptions.skipSx,
116
- overridesResolver = inputOptions.overridesResolver,
117
- options = _objectWithoutProperties(inputOptions, ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]); // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
118
-
119
-
97
+ componentSlot = inputOptions.slot,
98
+ inputSkipVariantsResolver = inputOptions.skipVariantsResolver,
99
+ inputSkipSx = inputOptions.skipSx,
100
+ overridesResolver = inputOptions.overridesResolver,
101
+ options = _objectWithoutProperties(inputOptions, ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]); // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
120
102
  var skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver : componentSlot && componentSlot !== 'Root' || false;
121
103
  var skipSx = inputSkipSx || false;
122
104
  var label;
123
-
124
105
  if (process.env.NODE_ENV !== 'production') {
125
106
  if (componentName) {
126
107
  label = "".concat(componentName, "-").concat(lowercaseFirstLetter(componentSlot || 'Root'));
127
108
  }
128
109
  }
129
-
130
110
  var shouldForwardPropOption = shouldForwardProp;
131
-
132
111
  if (componentSlot === 'Root') {
133
112
  shouldForwardPropOption = rootShouldForwardProp;
134
113
  } else if (componentSlot) {
@@ -138,111 +117,91 @@ export default function createStyled() {
138
117
  // for string (html) tag, preserve the behavior in emotion & styled-components.
139
118
  shouldForwardPropOption = undefined;
140
119
  }
141
-
142
120
  var defaultStyledResolver = styledEngineStyled(tag, _extends({
143
121
  shouldForwardProp: shouldForwardPropOption,
144
122
  label: label
145
123
  }, options));
146
-
147
124
  var muiStyledResolver = function muiStyledResolver(styleArg) {
148
125
  for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
149
126
  expressions[_key - 1] = arguments[_key];
150
127
  }
151
-
152
128
  var expressionsWithDefaultTheme = expressions ? expressions.map(function (stylesArg) {
153
129
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
154
130
  // component stays as a function. This condition makes sure that we do not interpolate functions
155
131
  // which are basically components used as a selectors.
156
132
  return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (_ref) {
157
133
  var themeInput = _ref.theme,
158
- other = _objectWithoutProperties(_ref, ["theme"]);
159
-
134
+ other = _objectWithoutProperties(_ref, ["theme"]);
160
135
  return stylesArg(_extends({
161
136
  theme: isEmpty(themeInput) ? defaultTheme : themeInput
162
137
  }, other));
163
138
  } : stylesArg;
164
139
  }) : [];
165
140
  var transformedStyleArg = styleArg;
166
-
167
141
  if (componentName && overridesResolver) {
168
142
  expressionsWithDefaultTheme.push(function (props) {
169
143
  var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
170
144
  var styleOverrides = getStyleOverrides(componentName, theme);
171
-
172
145
  if (styleOverrides) {
173
146
  var resolvedStyleOverrides = {};
174
147
  Object.entries(styleOverrides).forEach(function (_ref2) {
175
148
  var _ref3 = _slicedToArray(_ref2, 2),
176
- slotKey = _ref3[0],
177
- slotStyle = _ref3[1];
178
-
149
+ slotKey = _ref3[0],
150
+ slotStyle = _ref3[1];
179
151
  resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
180
152
  theme: theme
181
153
  })) : slotStyle;
182
154
  });
183
155
  return overridesResolver(props, resolvedStyleOverrides);
184
156
  }
185
-
186
157
  return null;
187
158
  });
188
159
  }
189
-
190
160
  if (componentName && !skipVariantsResolver) {
191
161
  expressionsWithDefaultTheme.push(function (props) {
192
162
  var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
193
163
  return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
194
164
  });
195
165
  }
196
-
197
166
  if (!skipSx) {
198
167
  expressionsWithDefaultTheme.push(systemSx);
199
168
  }
200
-
201
169
  var numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
202
-
203
170
  if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
204
- var placeholders = new Array(numOfCustomFnsApplied).fill(''); // If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
205
-
171
+ var placeholders = new Array(numOfCustomFnsApplied).fill('');
172
+ // If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
206
173
  transformedStyleArg = [].concat(_toConsumableArray(styleArg), _toConsumableArray(placeholders));
207
174
  transformedStyleArg.raw = [].concat(_toConsumableArray(styleArg.raw), _toConsumableArray(placeholders));
208
- } else if (typeof styleArg === 'function' && // On the server Emotion doesn't use React.forwardRef for creating components, so the created
175
+ } else if (typeof styleArg === 'function' &&
176
+ // On the server Emotion doesn't use React.forwardRef for creating components, so the created
209
177
  // component stays as a function. This condition makes sure that we do not interpolate functions
210
178
  // which are basically components used as a selectors.
211
179
  styleArg.__emotion_real !== styleArg) {
212
180
  // If the type is function, we need to define the default theme.
213
181
  transformedStyleArg = function transformedStyleArg(_ref4) {
214
182
  var themeInput = _ref4.theme,
215
- other = _objectWithoutProperties(_ref4, ["theme"]);
216
-
183
+ other = _objectWithoutProperties(_ref4, ["theme"]);
217
184
  return styleArg(_extends({
218
185
  theme: isEmpty(themeInput) ? defaultTheme : themeInput
219
186
  }, other));
220
187
  };
221
188
  }
222
-
223
189
  var Component = defaultStyledResolver.apply(void 0, [transformedStyleArg].concat(_toConsumableArray(expressionsWithDefaultTheme)));
224
-
225
190
  if (process.env.NODE_ENV !== 'production') {
226
191
  var displayName;
227
-
228
192
  if (componentName) {
229
193
  displayName = "".concat(componentName).concat(componentSlot || '');
230
194
  }
231
-
232
195
  if (displayName === undefined) {
233
196
  displayName = "Styled(".concat(getDisplayName(tag), ")");
234
197
  }
235
-
236
198
  Component.displayName = displayName;
237
199
  }
238
-
239
200
  return Component;
240
201
  };
241
-
242
202
  if (defaultStyledResolver.withConfig) {
243
203
  muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
244
204
  }
245
-
246
205
  return muiStyledResolver;
247
206
  };
248
207
  }
@@ -4,85 +4,72 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  // Sorted ASC by size. That's important.
5
5
  // It can't be configured as it's used statically for propTypes.
6
6
  export var breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
7
-
8
7
  var sortBreakpointsValues = function sortBreakpointsValues(values) {
9
8
  var breakpointsAsArray = Object.keys(values).map(function (key) {
10
9
  return {
11
10
  key: key,
12
11
  val: values[key]
13
12
  };
14
- }) || []; // Sort in ascending order
15
-
13
+ }) || [];
14
+ // Sort in ascending order
16
15
  breakpointsAsArray.sort(function (breakpoint1, breakpoint2) {
17
16
  return breakpoint1.val - breakpoint2.val;
18
17
  });
19
18
  return breakpointsAsArray.reduce(function (acc, obj) {
20
19
  return _extends({}, acc, _defineProperty({}, obj.key, obj.val));
21
20
  }, {});
22
- }; // Keep in mind that @media is inclusive by the CSS specification.
23
-
21
+ };
24
22
 
23
+ // Keep in mind that @media is inclusive by the CSS specification.
25
24
  export default function createBreakpoints(breakpoints) {
26
25
  var _breakpoints$values = breakpoints.values,
27
- values = _breakpoints$values === void 0 ? {
28
- xs: 0,
29
- // phone
30
- sm: 600,
31
- // tablet
32
- md: 900,
33
- // small laptop
34
- lg: 1200,
35
- // desktop
36
- xl: 1536 // large screen
37
-
38
- } : _breakpoints$values,
39
- _breakpoints$unit = breakpoints.unit,
40
- unit = _breakpoints$unit === void 0 ? 'px' : _breakpoints$unit,
41
- _breakpoints$step = breakpoints.step,
42
- step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
43
- other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
44
-
26
+ values = _breakpoints$values === void 0 ? {
27
+ xs: 0,
28
+ // phone
29
+ sm: 600,
30
+ // tablet
31
+ md: 900,
32
+ // small laptop
33
+ lg: 1200,
34
+ // desktop
35
+ xl: 1536 // large screen
36
+ } : _breakpoints$values,
37
+ _breakpoints$unit = breakpoints.unit,
38
+ unit = _breakpoints$unit === void 0 ? 'px' : _breakpoints$unit,
39
+ _breakpoints$step = breakpoints.step,
40
+ step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
41
+ other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
45
42
  var sortedValues = sortBreakpointsValues(values);
46
43
  var keys = Object.keys(sortedValues);
47
-
48
44
  function up(key) {
49
45
  var value = typeof values[key] === 'number' ? values[key] : key;
50
46
  return "@media (min-width:".concat(value).concat(unit, ")");
51
47
  }
52
-
53
48
  function down(key) {
54
49
  var value = typeof values[key] === 'number' ? values[key] : key;
55
50
  return "@media (max-width:".concat(value - step / 100).concat(unit, ")");
56
51
  }
57
-
58
52
  function between(start, end) {
59
53
  var endIndex = keys.indexOf(end);
60
54
  return "@media (min-width:".concat(typeof values[start] === 'number' ? values[start] : start).concat(unit, ") and ") + "(max-width:".concat((endIndex !== -1 && typeof values[keys[endIndex]] === 'number' ? values[keys[endIndex]] : end) - step / 100).concat(unit, ")");
61
55
  }
62
-
63
56
  function only(key) {
64
57
  if (keys.indexOf(key) + 1 < keys.length) {
65
58
  return between(key, keys[keys.indexOf(key) + 1]);
66
59
  }
67
-
68
60
  return up(key);
69
61
  }
70
-
71
62
  function not(key) {
72
63
  // handle first and last key separately, for better readability
73
64
  var keyIndex = keys.indexOf(key);
74
-
75
65
  if (keyIndex === 0) {
76
66
  return up(keys[1]);
77
67
  }
78
-
79
68
  if (keyIndex === keys.length - 1) {
80
69
  return down(keys[keyIndex]);
81
70
  }
82
-
83
71
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
84
72
  }
85
-
86
73
  return _extends({
87
74
  keys: keys,
88
75
  values: sortedValues,
@@ -1,39 +1,34 @@
1
1
  import { createUnarySpacing } from '../spacing';
2
-
3
2
  /* tslint:enable:unified-signatures */
3
+
4
4
  export default function createSpacing() {
5
5
  var spacingInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
6
-
7
6
  // Already transformed.
8
7
  if (spacingInput.mui) {
9
8
  return spacingInput;
10
- } // Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
9
+ }
10
+
11
+ // Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
11
12
  // Smaller components, such as icons, can align to a 4dp grid.
12
13
  // https://m2.material.io/design/layout/understanding-layout.html
13
-
14
-
15
14
  var transform = createUnarySpacing({
16
15
  spacing: spacingInput
17
16
  });
18
-
19
17
  var spacing = function spacing() {
20
18
  for (var _len = arguments.length, argsInput = new Array(_len), _key = 0; _key < _len; _key++) {
21
19
  argsInput[_key] = arguments[_key];
22
20
  }
23
-
24
21
  if (process.env.NODE_ENV !== 'production') {
25
22
  if (!(argsInput.length <= 4)) {
26
23
  console.error("MUI: Too many arguments provided, expected between 0 and 4, got ".concat(argsInput.length));
27
24
  }
28
25
  }
29
-
30
26
  var args = argsInput.length === 0 ? [1] : argsInput;
31
27
  return args.map(function (argument) {
32
28
  var output = transform(argument);
33
29
  return typeof output === 'number' ? "".concat(output, "px") : output;
34
30
  }).join(' ');
35
31
  };
36
-
37
32
  spacing.mui = true;
38
33
  return spacing;
39
34
  }
@@ -4,19 +4,16 @@ import { deepmerge } from '@mui/utils';
4
4
  import createBreakpoints from './createBreakpoints';
5
5
  import shape from './shape';
6
6
  import createSpacing from './createSpacing';
7
-
8
7
  function createTheme() {
9
8
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
-
11
9
  var _options$breakpoints = options.breakpoints,
12
- breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints,
13
- _options$palette = options.palette,
14
- paletteInput = _options$palette === void 0 ? {} : _options$palette,
15
- spacingInput = options.spacing,
16
- _options$shape = options.shape,
17
- shapeInput = _options$shape === void 0 ? {} : _options$shape,
18
- other = _objectWithoutProperties(options, ["breakpoints", "palette", "spacing", "shape"]);
19
-
10
+ breakpointsInput = _options$breakpoints === void 0 ? {} : _options$breakpoints,
11
+ _options$palette = options.palette,
12
+ paletteInput = _options$palette === void 0 ? {} : _options$palette,
13
+ spacingInput = options.spacing,
14
+ _options$shape = options.shape,
15
+ shapeInput = _options$shape === void 0 ? {} : _options$shape,
16
+ other = _objectWithoutProperties(options, ["breakpoints", "palette", "spacing", "shape"]);
20
17
  var breakpoints = createBreakpoints(breakpointsInput);
21
18
  var spacing = createSpacing(spacingInput);
22
19
  var muiTheme = deepmerge({
@@ -30,15 +27,12 @@ function createTheme() {
30
27
  spacing: spacing,
31
28
  shape: _extends({}, shape, shapeInput)
32
29
  }, other);
33
-
34
30
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
35
31
  args[_key - 1] = arguments[_key];
36
32
  }
37
-
38
33
  muiTheme = args.reduce(function (acc, argument) {
39
34
  return deepmerge(acc, argument);
40
35
  }, muiTheme);
41
36
  return muiTheme;
42
37
  }
43
-
44
38
  export default createTheme;
package/legacy/cssGrid.js CHANGED
@@ -6,16 +6,13 @@ import responsivePropType from './responsivePropType';
6
6
  export var gap = function gap(props) {
7
7
  if (props.gap !== undefined && props.gap !== null) {
8
8
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'gap');
9
-
10
9
  var styleFromPropValue = function styleFromPropValue(propValue) {
11
10
  return {
12
11
  gap: getValue(transformer, propValue)
13
12
  };
14
13
  };
15
-
16
14
  return handleBreakpoints(props, props.gap, styleFromPropValue);
17
15
  }
18
-
19
16
  return null;
20
17
  };
21
18
  gap.propTypes = process.env.NODE_ENV !== 'production' ? {
@@ -25,16 +22,13 @@ gap.filterProps = ['gap'];
25
22
  export var columnGap = function columnGap(props) {
26
23
  if (props.columnGap !== undefined && props.columnGap !== null) {
27
24
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'columnGap');
28
-
29
25
  var styleFromPropValue = function styleFromPropValue(propValue) {
30
26
  return {
31
27
  columnGap: getValue(transformer, propValue)
32
28
  };
33
29
  };
34
-
35
30
  return handleBreakpoints(props, props.columnGap, styleFromPropValue);
36
31
  }
37
-
38
32
  return null;
39
33
  };
40
34
  columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
@@ -44,16 +38,13 @@ columnGap.filterProps = ['columnGap'];
44
38
  export var rowGap = function rowGap(props) {
45
39
  if (props.rowGap !== undefined && props.rowGap !== null) {
46
40
  var transformer = createUnaryUnit(props.theme, 'spacing', 8, 'rowGap');
47
-
48
41
  var styleFromPropValue = function styleFromPropValue(propValue) {
49
42
  return {
50
43
  rowGap: getValue(transformer, propValue)
51
44
  };
52
45
  };
53
-
54
46
  return handleBreakpoints(props, props.rowGap, styleFromPropValue);
55
47
  }
56
-
57
48
  return null;
58
49
  };
59
50
  rowGap.propTypes = process.env.NODE_ENV !== 'production' ? {