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