@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
package/breakpoints.js CHANGED
@@ -1,7 +1,6 @@
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
  });
@@ -13,15 +12,10 @@ exports.mergeBreakpointsInOrder = mergeBreakpointsInOrder;
13
12
  exports.removeUnusedBreakpoints = removeUnusedBreakpoints;
14
13
  exports.resolveBreakpointValues = resolveBreakpointValues;
15
14
  exports.values = void 0;
16
-
17
15
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
18
-
19
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
20
-
21
17
  var _utils = require("@mui/utils");
22
-
23
18
  var _merge = _interopRequireDefault(require("./merge"));
24
-
25
19
  // The breakpoint **start** at this value.
26
20
  // For instance with the first breakpoint xs: [xs, sm[.
27
21
  const values = {
@@ -34,7 +28,6 @@ const values = {
34
28
  lg: 1200,
35
29
  // desktop
36
30
  xl: 1536 // large screen
37
-
38
31
  };
39
32
  exports.values = values;
40
33
  const defaultBreakpoints = {
@@ -43,10 +36,8 @@ const defaultBreakpoints = {
43
36
  keys: ['xs', 'sm', 'md', 'lg', 'xl'],
44
37
  up: key => `@media (min-width:${values[key]}px)`
45
38
  };
46
-
47
39
  function handleBreakpoints(props, propValue, styleFromPropValue) {
48
40
  const theme = props.theme || {};
49
-
50
41
  if (Array.isArray(propValue)) {
51
42
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
52
43
  return propValue.reduce((acc, item, index) => {
@@ -54,7 +45,6 @@ function handleBreakpoints(props, propValue, styleFromPropValue) {
54
45
  return acc;
55
46
  }, {});
56
47
  }
57
-
58
48
  if (typeof propValue === 'object') {
59
49
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
60
50
  return Object.keys(propValue).reduce((acc, breakpoint) => {
@@ -66,15 +56,12 @@ function handleBreakpoints(props, propValue, styleFromPropValue) {
66
56
  const cssKey = breakpoint;
67
57
  acc[cssKey] = propValue[cssKey];
68
58
  }
69
-
70
59
  return acc;
71
60
  }, {});
72
61
  }
73
-
74
62
  const output = styleFromPropValue(propValue);
75
63
  return output;
76
64
  }
77
-
78
65
  function breakpoints(styleFunction) {
79
66
  const newStyleFunction = props => {
80
67
  const theme = props.theme || {};
@@ -87,12 +74,10 @@ function breakpoints(styleFunction) {
87
74
  theme
88
75
  }, props[key]));
89
76
  }
90
-
91
77
  return acc;
92
78
  }, null);
93
79
  return (0, _merge.default)(base, extended);
94
80
  };
95
-
96
81
  newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? (0, _extends2.default)({}, styleFunction.propTypes, {
97
82
  xs: _propTypes.default.object,
98
83
  sm: _propTypes.default.object,
@@ -103,10 +88,8 @@ function breakpoints(styleFunction) {
103
88
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
104
89
  return newStyleFunction;
105
90
  }
106
-
107
91
  function createEmptyBreakpointObject(breakpointsInput = {}) {
108
92
  var _breakpointsInput$key;
109
-
110
93
  const breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
111
94
  const breakpointStyleKey = breakpointsInput.up(key);
112
95
  acc[breakpointStyleKey] = {};
@@ -114,38 +97,32 @@ function createEmptyBreakpointObject(breakpointsInput = {}) {
114
97
  }, {});
115
98
  return breakpointsInOrder || {};
116
99
  }
117
-
118
100
  function removeUnusedBreakpoints(breakpointKeys, style) {
119
101
  return breakpointKeys.reduce((acc, key) => {
120
102
  const breakpointOutput = acc[key];
121
103
  const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
122
-
123
104
  if (isBreakpointUnused) {
124
105
  delete acc[key];
125
106
  }
126
-
127
107
  return acc;
128
108
  }, style);
129
109
  }
130
-
131
110
  function mergeBreakpointsInOrder(breakpointsInput, ...styles) {
132
111
  const emptyBreakpoints = createEmptyBreakpointObject(breakpointsInput);
133
112
  const mergedOutput = [emptyBreakpoints, ...styles].reduce((prev, next) => (0, _utils.deepmerge)(prev, next), {});
134
113
  return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
135
- } // compute base for responsive values; e.g.,
114
+ }
115
+
116
+ // compute base for responsive values; e.g.,
136
117
  // [1,2,3] => {xs: true, sm: true, md: true}
137
118
  // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
138
-
139
-
140
119
  function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
141
120
  // fixed value
142
121
  if (typeof breakpointValues !== 'object') {
143
122
  return {};
144
123
  }
145
-
146
124
  const base = {};
147
125
  const breakpointsKeys = Object.keys(themeBreakpoints);
148
-
149
126
  if (Array.isArray(breakpointValues)) {
150
127
  breakpointsKeys.forEach((breakpoint, i) => {
151
128
  if (i < breakpointValues.length) {
@@ -159,10 +136,8 @@ function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
159
136
  }
160
137
  });
161
138
  }
162
-
163
139
  return base;
164
140
  }
165
-
166
141
  function resolveBreakpointValues({
167
142
  values: breakpointValues,
168
143
  breakpoints: themeBreakpoints,
@@ -170,11 +145,9 @@ function resolveBreakpointValues({
170
145
  }) {
171
146
  const base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
172
147
  const keys = Object.keys(base);
173
-
174
148
  if (keys.length === 0) {
175
149
  return breakpointValues;
176
150
  }
177
-
178
151
  let previous;
179
152
  return keys.reduce((acc, breakpoint, i) => {
180
153
  if (Array.isArray(breakpointValues)) {
@@ -186,10 +159,8 @@ function resolveBreakpointValues({
186
159
  } else {
187
160
  acc[breakpoint] = breakpointValues;
188
161
  }
189
-
190
162
  return acc;
191
163
  }, {});
192
164
  }
193
-
194
165
  var _default = breakpoints;
195
166
  exports.default = _default;
@@ -15,9 +15,7 @@ exports.hslToRgb = hslToRgb;
15
15
  exports.lighten = lighten;
16
16
  exports.recomposeColor = recomposeColor;
17
17
  exports.rgbToHex = rgbToHex;
18
-
19
18
  var _utils = require("@mui/utils");
20
-
21
19
  /**
22
20
  * Returns a number whose value is limited to the given range.
23
21
  * @param {number} value The value to be clamped
@@ -31,34 +29,30 @@ function clamp(value, min = 0, max = 1) {
31
29
  console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
32
30
  }
33
31
  }
34
-
35
32
  return Math.min(Math.max(min, value), max);
36
33
  }
34
+
37
35
  /**
38
36
  * Converts a color from CSS hex format to CSS rgb format.
39
37
  * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
40
38
  * @returns {string} A CSS rgb color string
41
39
  */
42
-
43
-
44
40
  function hexToRgb(color) {
45
41
  color = color.slice(1);
46
42
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
47
43
  let colors = color.match(re);
48
-
49
44
  if (colors && colors[0].length === 1) {
50
45
  colors = colors.map(n => n + n);
51
46
  }
52
-
53
47
  return colors ? `rgb${colors.length === 4 ? 'a' : ''}(${colors.map((n, index) => {
54
48
  return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
55
49
  }).join(', ')})` : '';
56
50
  }
57
-
58
51
  function intToHex(int) {
59
52
  const hex = int.toString(16);
60
53
  return hex.length === 1 ? `0${hex}` : hex;
61
54
  }
55
+
62
56
  /**
63
57
  * Returns an object with the type and values of a color.
64
58
  *
@@ -66,37 +60,28 @@ function intToHex(int) {
66
60
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
67
61
  * @returns {object} - A MUI color object: {type: string, values: number[]}
68
62
  */
69
-
70
-
71
63
  function decomposeColor(color) {
72
64
  // Idempotent
73
65
  if (color.type) {
74
66
  return color;
75
67
  }
76
-
77
68
  if (color.charAt(0) === '#') {
78
69
  return decomposeColor(hexToRgb(color));
79
70
  }
80
-
81
71
  const marker = color.indexOf('(');
82
72
  const type = color.substring(0, marker);
83
-
84
73
  if (['rgb', 'rgba', 'hsl', 'hsla', 'color'].indexOf(type) === -1) {
85
74
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Unsupported \`${color}\` color.
86
75
  The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().` : (0, _utils.formatMuiErrorMessage)(9, color));
87
76
  }
88
-
89
77
  let values = color.substring(marker + 1, color.length - 1);
90
78
  let colorSpace;
91
-
92
79
  if (type === 'color') {
93
80
  values = values.split(' ');
94
81
  colorSpace = values.shift();
95
-
96
82
  if (values.length === 4 && values[3].charAt(0) === '/') {
97
83
  values[3] = values[3].slice(1);
98
84
  }
99
-
100
85
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
101
86
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI: unsupported \`${colorSpace}\` color space.
102
87
  The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.` : (0, _utils.formatMuiErrorMessage)(10, colorSpace));
@@ -104,7 +89,6 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
104
89
  } else {
105
90
  values = values.split(',');
106
91
  }
107
-
108
92
  values = values.map(value => parseFloat(value));
109
93
  return {
110
94
  type,
@@ -112,18 +96,18 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
112
96
  colorSpace
113
97
  };
114
98
  }
99
+
115
100
  /**
116
101
  * Returns a channel created from the input color.
117
102
  *
118
103
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
119
104
  * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
120
105
  */
121
-
122
-
123
106
  const colorChannel = color => {
124
107
  const decomposedColor = decomposeColor(color);
125
108
  return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
126
109
  };
110
+
127
111
  /**
128
112
  * Converts a color object with type and values to a string.
129
113
  * @param {object} color - Decomposed color
@@ -131,10 +115,7 @@ const colorChannel = color => {
131
115
  * @param {array} color.values - [n,n,n] or [n,n,n,n]
132
116
  * @returns {string} A CSS color string
133
117
  */
134
-
135
-
136
118
  exports.colorChannel = colorChannel;
137
-
138
119
  function recomposeColor(color) {
139
120
  const {
140
121
  type,
@@ -143,7 +124,6 @@ function recomposeColor(color) {
143
124
  let {
144
125
  values
145
126
  } = color;
146
-
147
127
  if (type.indexOf('rgb') !== -1) {
148
128
  // Only convert the first 3 values to int (i.e. not alpha)
149
129
  values = values.map((n, i) => i < 3 ? parseInt(n, 10) : n);
@@ -151,40 +131,35 @@ function recomposeColor(color) {
151
131
  values[1] = `${values[1]}%`;
152
132
  values[2] = `${values[2]}%`;
153
133
  }
154
-
155
134
  if (type.indexOf('color') !== -1) {
156
135
  values = `${colorSpace} ${values.join(' ')}`;
157
136
  } else {
158
137
  values = `${values.join(', ')}`;
159
138
  }
160
-
161
139
  return `${type}(${values})`;
162
140
  }
141
+
163
142
  /**
164
143
  * Converts a color from CSS rgb format to CSS hex format.
165
144
  * @param {string} color - RGB color, i.e. rgb(n, n, n)
166
145
  * @returns {string} A CSS rgb color string, i.e. #nnnnnn
167
146
  */
168
-
169
-
170
147
  function rgbToHex(color) {
171
148
  // Idempotent
172
149
  if (color.indexOf('#') === 0) {
173
150
  return color;
174
151
  }
175
-
176
152
  const {
177
153
  values
178
154
  } = decomposeColor(color);
179
155
  return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
180
156
  }
157
+
181
158
  /**
182
159
  * Converts a color from hsl format to rgb format.
183
160
  * @param {string} color - HSL color values
184
161
  * @returns {string} rgb color values
185
162
  */
186
-
187
-
188
163
  function hslToRgb(color) {
189
164
  color = decomposeColor(color);
190
165
  const {
@@ -194,17 +169,13 @@ function hslToRgb(color) {
194
169
  const s = values[1] / 100;
195
170
  const l = values[2] / 100;
196
171
  const a = s * Math.min(l, 1 - l);
197
-
198
172
  const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
199
-
200
173
  let type = 'rgb';
201
174
  const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
202
-
203
175
  if (color.type === 'hsla') {
204
176
  type += 'a';
205
177
  rgb.push(values[3]);
206
178
  }
207
-
208
179
  return recomposeColor({
209
180
  type,
210
181
  values: rgb
@@ -218,8 +189,6 @@ function hslToRgb(color) {
218
189
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
219
190
  * @returns {number} The relative brightness of the color in the range 0 - 1
220
191
  */
221
-
222
-
223
192
  function getLuminance(color) {
224
193
  color = decomposeColor(color);
225
194
  let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
@@ -229,10 +198,12 @@ function getLuminance(color) {
229
198
  }
230
199
 
231
200
  return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
232
- }); // Truncate at 3 digits
201
+ });
233
202
 
203
+ // Truncate at 3 digits
234
204
  return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
235
205
  }
206
+
236
207
  /**
237
208
  * Calculates the contrast ratio between two colors.
238
209
  *
@@ -241,13 +212,12 @@ function getLuminance(color) {
241
212
  * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
242
213
  * @returns {number} A contrast ratio value in the range 0 - 21.
243
214
  */
244
-
245
-
246
215
  function getContrastRatio(foreground, background) {
247
216
  const lumA = getLuminance(foreground);
248
217
  const lumB = getLuminance(background);
249
218
  return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
250
219
  }
220
+
251
221
  /**
252
222
  * Sets the absolute transparency of a color.
253
223
  * Any existing alpha values are overwritten.
@@ -255,36 +225,29 @@ function getContrastRatio(foreground, background) {
255
225
  * @param {number} value - value to set the alpha channel to in the range 0 - 1
256
226
  * @returns {string} A CSS color string. Hex input values are returned as rgb
257
227
  */
258
-
259
-
260
228
  function alpha(color, value) {
261
229
  color = decomposeColor(color);
262
230
  value = clamp(value);
263
-
264
231
  if (color.type === 'rgb' || color.type === 'hsl') {
265
232
  color.type += 'a';
266
233
  }
267
-
268
234
  if (color.type === 'color') {
269
235
  color.values[3] = `/${value}`;
270
236
  } else {
271
237
  color.values[3] = value;
272
238
  }
273
-
274
239
  return recomposeColor(color);
275
240
  }
241
+
276
242
  /**
277
243
  * Darkens a color.
278
244
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
279
245
  * @param {number} coefficient - multiplier in the range 0 - 1
280
246
  * @returns {string} A CSS color string. Hex input values are returned as rgb
281
247
  */
282
-
283
-
284
248
  function darken(color, coefficient) {
285
249
  color = decomposeColor(color);
286
250
  coefficient = clamp(coefficient);
287
-
288
251
  if (color.type.indexOf('hsl') !== -1) {
289
252
  color.values[2] *= 1 - coefficient;
290
253
  } else if (color.type.indexOf('rgb') !== -1 || color.type.indexOf('color') !== -1) {
@@ -292,21 +255,18 @@ function darken(color, coefficient) {
292
255
  color.values[i] *= 1 - coefficient;
293
256
  }
294
257
  }
295
-
296
258
  return recomposeColor(color);
297
259
  }
260
+
298
261
  /**
299
262
  * Lightens a color.
300
263
  * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
301
264
  * @param {number} coefficient - multiplier in the range 0 - 1
302
265
  * @returns {string} A CSS color string. Hex input values are returned as rgb
303
266
  */
304
-
305
-
306
267
  function lighten(color, coefficient) {
307
268
  color = decomposeColor(color);
308
269
  coefficient = clamp(coefficient);
309
-
310
270
  if (color.type.indexOf('hsl') !== -1) {
311
271
  color.values[2] += (100 - color.values[2]) * coefficient;
312
272
  } else if (color.type.indexOf('rgb') !== -1) {
@@ -318,9 +278,9 @@ function lighten(color, coefficient) {
318
278
  color.values[i] += (1 - color.values[i]) * coefficient;
319
279
  }
320
280
  }
321
-
322
281
  return recomposeColor(color);
323
282
  }
283
+
324
284
  /**
325
285
  * Darken or lighten a color, depending on its luminance.
326
286
  * Light colors are darkened, dark colors are lightened.
@@ -328,8 +288,6 @@ function lighten(color, coefficient) {
328
288
  * @param {number} coefficient=0.15 - multiplier in the range 0 - 1
329
289
  * @returns {string} A CSS color string. Hex input values are returned as rgb
330
290
  */
331
-
332
-
333
291
  function emphasize(color, coefficient = 0.15) {
334
292
  return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
335
293
  }
package/compose.js CHANGED
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _merge = _interopRequireDefault(require("./merge"));
11
-
12
9
  function compose(...styles) {
13
10
  const handlers = styles.reduce((acc, style) => {
14
11
  style.filterProps.forEach(prop => {
@@ -16,21 +13,17 @@ function compose(...styles) {
16
13
  });
17
14
  return acc;
18
15
  }, {});
19
-
20
16
  const fn = props => {
21
17
  return Object.keys(props).reduce((acc, prop) => {
22
18
  if (handlers[prop]) {
23
19
  return (0, _merge.default)(acc, handlers[prop](props));
24
20
  }
25
-
26
21
  return acc;
27
22
  }, {});
28
23
  };
29
-
30
24
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
31
25
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
32
26
  return fn;
33
27
  }
34
-
35
28
  var _default = compose;
36
29
  exports.default = _default;
package/createBox.js CHANGED
@@ -1,34 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = createBox;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
13
-
14
10
  var React = _interopRequireWildcard(require("react"));
15
-
16
11
  var _clsx = _interopRequireDefault(require("clsx"));
17
-
18
12
  var _styledEngine = _interopRequireDefault(require("@mui/styled-engine"));
19
-
20
13
  var _styleFunctionSx = _interopRequireWildcard(require("./styleFunctionSx"));
21
-
22
14
  var _useTheme = _interopRequireDefault(require("./useTheme"));
23
-
24
15
  var _jsxRuntime = require("react/jsx-runtime");
25
-
26
16
  const _excluded = ["className", "component"];
27
-
28
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
-
30
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
-
32
19
  function createBox(options = {}) {
33
20
  const {
34
21
  defaultTheme,
@@ -41,14 +28,12 @@ function createBox(options = {}) {
41
28
  })(styleFunctionSx);
42
29
  const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
43
30
  const theme = (0, _useTheme.default)(defaultTheme);
44
-
45
31
  const _extendSxProp = (0, _styleFunctionSx.extendSxProp)(inProps),
46
- {
47
- className,
48
- component = 'div'
49
- } = _extendSxProp,
50
- other = (0, _objectWithoutPropertiesLoose2.default)(_extendSxProp, _excluded);
51
-
32
+ {
33
+ className,
34
+ component = 'div'
35
+ } = _extendSxProp,
36
+ other = (0, _objectWithoutPropertiesLoose2.default)(_extendSxProp, _excluded);
52
37
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(BoxRoot, (0, _extends2.default)({
53
38
  as: component,
54
39
  ref: ref,