@mui/system 5.10.13 → 5.10.15

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