@mui/system 7.0.0 → 7.0.2

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 (130) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/cssVars/cssVarsParser.d.ts +1 -1
  3. package/esm/cssVars/cssVarsParser.d.ts +1 -1
  4. package/esm/index.js +1 -1
  5. package/esm/memoTheme.d.ts +1 -1
  6. package/esm/useThemeProps/getThemeProps.d.ts +0 -5
  7. package/esm/version/index.js +2 -2
  8. package/index.js +1 -1
  9. package/memoTheme.d.ts +1 -1
  10. package/modern/cssVars/cssVarsParser.d.ts +1 -1
  11. package/modern/memoTheme.d.ts +1 -1
  12. package/modern/useThemeProps/getThemeProps.d.ts +0 -5
  13. package/package.json +6 -14
  14. package/useThemeProps/getThemeProps.d.ts +0 -5
  15. package/version/index.js +2 -2
  16. package/modern/Box/Box.js +0 -30
  17. package/modern/Box/boxClasses.js +0 -3
  18. package/modern/Box/index.js +0 -3
  19. package/modern/Container/Container.js +0 -61
  20. package/modern/Container/ContainerProps.js +0 -1
  21. package/modern/Container/containerClasses.js +0 -7
  22. package/modern/Container/createContainer.js +0 -149
  23. package/modern/Container/index.js +0 -3
  24. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +0 -64
  25. package/modern/DefaultPropsProvider/index.js +0 -1
  26. package/modern/GlobalStyles/GlobalStyles.js +0 -37
  27. package/modern/GlobalStyles/index.js +0 -2
  28. package/modern/Grid/Grid.js +0 -106
  29. package/modern/Grid/GridProps.js +0 -1
  30. package/modern/Grid/createGrid.js +0 -155
  31. package/modern/Grid/deleteLegacyGridProps.js +0 -41
  32. package/modern/Grid/gridClasses.js +0 -19
  33. package/modern/Grid/gridGenerator.js +0 -193
  34. package/modern/Grid/index.js +0 -7
  35. package/modern/Grid/traverseBreakpoints.js +0 -42
  36. package/modern/InitColorSchemeScript/InitColorSchemeScript.js +0 -78
  37. package/modern/InitColorSchemeScript/index.js +0 -1
  38. package/modern/RtlProvider/index.js +0 -24
  39. package/modern/Stack/Stack.js +0 -62
  40. package/modern/Stack/StackProps.js +0 -1
  41. package/modern/Stack/createStack.js +0 -173
  42. package/modern/Stack/index.js +0 -5
  43. package/modern/Stack/stackClasses.js +0 -7
  44. package/modern/ThemeProvider/ThemeProvider.js +0 -97
  45. package/modern/ThemeProvider/index.js +0 -1
  46. package/modern/borders/borders.js +0 -49
  47. package/modern/borders/index.js +0 -2
  48. package/modern/breakpoints/breakpoints.js +0 -171
  49. package/modern/breakpoints/index.js +0 -2
  50. package/modern/colorManipulator/colorManipulator.js +0 -349
  51. package/modern/colorManipulator/index.js +0 -1
  52. package/modern/compose/compose.js +0 -24
  53. package/modern/compose/index.js +0 -1
  54. package/modern/createBox/createBox.js +0 -35
  55. package/modern/createBox/index.js +0 -1
  56. package/modern/createBreakpoints/createBreakpoints.js +0 -81
  57. package/modern/createBreakpoints/index.js +0 -3
  58. package/modern/createStyled/createStyled.js +0 -276
  59. package/modern/createStyled/index.js +0 -2
  60. package/modern/createTheme/applyStyles.js +0 -87
  61. package/modern/createTheme/createSpacing.js +0 -31
  62. package/modern/createTheme/createTheme.js +0 -49
  63. package/modern/createTheme/index.js +0 -3
  64. package/modern/createTheme/shape.js +0 -4
  65. package/modern/cssContainerQueries/cssContainerQueries.js +0 -69
  66. package/modern/cssContainerQueries/index.js +0 -2
  67. package/modern/cssGrid/cssGrid.js +0 -85
  68. package/modern/cssGrid/index.js +0 -2
  69. package/modern/cssVars/createCssVarsProvider.js +0 -338
  70. package/modern/cssVars/createCssVarsTheme.js +0 -21
  71. package/modern/cssVars/createGetCssVar.js +0 -22
  72. package/modern/cssVars/cssVarsParser.js +0 -129
  73. package/modern/cssVars/getColorSchemeSelector.js +0 -26
  74. package/modern/cssVars/index.js +0 -5
  75. package/modern/cssVars/localStorageManager.js +0 -51
  76. package/modern/cssVars/prepareCssVars.js +0 -153
  77. package/modern/cssVars/prepareTypographyVars.js +0 -11
  78. package/modern/cssVars/useCurrentColorScheme.js +0 -228
  79. package/modern/display/display.js +0 -27
  80. package/modern/display/index.js +0 -2
  81. package/modern/flexbox/flexbox.js +0 -43
  82. package/modern/flexbox/index.js +0 -2
  83. package/modern/getThemeValue/getThemeValue.js +0 -51
  84. package/modern/getThemeValue/index.js +0 -2
  85. package/modern/index.js +0 -75
  86. package/modern/memoTheme.js +0 -28
  87. package/modern/memoize/index.js +0 -1
  88. package/modern/memoize/memoize.js +0 -9
  89. package/modern/merge/index.js +0 -1
  90. package/modern/merge/merge.js +0 -10
  91. package/modern/package.json +0 -1
  92. package/modern/palette/index.js +0 -2
  93. package/modern/palette/palette.js +0 -26
  94. package/modern/positions/index.js +0 -2
  95. package/modern/positions/positions.js +0 -22
  96. package/modern/preprocessStyles.js +0 -25
  97. package/modern/propsToClassKey/index.js +0 -1
  98. package/modern/propsToClassKey/propsToClassKey.js +0 -25
  99. package/modern/responsivePropType/index.js +0 -1
  100. package/modern/responsivePropType/responsivePropType.js +0 -3
  101. package/modern/shadows/index.js +0 -1
  102. package/modern/shadows/shadows.js +0 -6
  103. package/modern/sizing/index.js +0 -2
  104. package/modern/sizing/sizing.js +0 -64
  105. package/modern/spacing/index.js +0 -2
  106. package/modern/spacing/spacing.js +0 -157
  107. package/modern/style/index.js +0 -2
  108. package/modern/style/style.js +0 -75
  109. package/modern/styleFunctionSx/AliasesCSSProperties.js +0 -1
  110. package/modern/styleFunctionSx/OverwriteCSSProperties.js +0 -1
  111. package/modern/styleFunctionSx/StandardCssProperties.js +0 -1
  112. package/modern/styleFunctionSx/defaultSxConfig.js +0 -294
  113. package/modern/styleFunctionSx/extendSxProp.js +0 -51
  114. package/modern/styleFunctionSx/index.js +0 -4
  115. package/modern/styleFunctionSx/styleFunctionSx.js +0 -127
  116. package/modern/styled/index.js +0 -1
  117. package/modern/styled/styled.js +0 -3
  118. package/modern/typography/index.js +0 -2
  119. package/modern/typography/typography.js +0 -37
  120. package/modern/useMediaQuery/index.js +0 -2
  121. package/modern/useMediaQuery/useMediaQuery.js +0 -118
  122. package/modern/useTheme/index.js +0 -2
  123. package/modern/useTheme/useTheme.js +0 -9
  124. package/modern/useThemeProps/getThemeProps.js +0 -12
  125. package/modern/useThemeProps/index.js +0 -2
  126. package/modern/useThemeProps/useThemeProps.js +0 -20
  127. package/modern/useThemeWithoutDefault/index.js +0 -1
  128. package/modern/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -12
  129. package/modern/version/index.js +0 -6
  130. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,349 +0,0 @@
1
- import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- import clamp from '@mui/utils/clamp';
4
-
5
- /**
6
- * Returns a number whose value is limited to the given range.
7
- * @param {number} value The value to be clamped
8
- * @param {number} min The lower boundary of the output range
9
- * @param {number} max The upper boundary of the output range
10
- * @returns {number} A number in the range [min, max]
11
- */
12
- function clampWrapper(value, min = 0, max = 1) {
13
- if (process.env.NODE_ENV !== 'production') {
14
- if (value < min || value > max) {
15
- console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
16
- }
17
- }
18
- return clamp(value, min, max);
19
- }
20
-
21
- /**
22
- * Converts a color from CSS hex format to CSS rgb format.
23
- * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
24
- * @returns {string} A CSS rgb color string
25
- */
26
- export function hexToRgb(color) {
27
- color = color.slice(1);
28
- const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
29
- let colors = color.match(re);
30
- if (colors && colors[0].length === 1) {
31
- colors = colors.map(n => n + n);
32
- }
33
- if (process.env.NODE_ENV !== 'production') {
34
- if (color.length !== color.trim().length) {
35
- console.error(`MUI: The color: "${color}" is invalid. Make sure the color input doesn't contain leading/trailing space.`);
36
- }
37
- }
38
- return colors ? `rgb${colors.length === 4 ? 'a' : ''}(${colors.map((n, index) => {
39
- return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
40
- }).join(', ')})` : '';
41
- }
42
- function intToHex(int) {
43
- const hex = int.toString(16);
44
- return hex.length === 1 ? `0${hex}` : hex;
45
- }
46
-
47
- /**
48
- * Returns an object with the type and values of a color.
49
- *
50
- * Note: Does not support rgb % values.
51
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
52
- * @returns {object} - A MUI color object: {type: string, values: number[]}
53
- */
54
- export function decomposeColor(color) {
55
- // Idempotent
56
- if (color.type) {
57
- return color;
58
- }
59
- if (color.charAt(0) === '#') {
60
- return decomposeColor(hexToRgb(color));
61
- }
62
- const marker = color.indexOf('(');
63
- const type = color.substring(0, marker);
64
- if (!['rgb', 'rgba', 'hsl', 'hsla', 'color'].includes(type)) {
65
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Unsupported \`${color}\` color.\n` + 'The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().' : _formatErrorMessage(9, color));
66
- }
67
- let values = color.substring(marker + 1, color.length - 1);
68
- let colorSpace;
69
- if (type === 'color') {
70
- values = values.split(' ');
71
- colorSpace = values.shift();
72
- if (values.length === 4 && values[3].charAt(0) === '/') {
73
- values[3] = values[3].slice(1);
74
- }
75
- if (!['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].includes(colorSpace)) {
76
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI: unsupported \`${colorSpace}\` color space.\n` + 'The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.' : _formatErrorMessage(10, colorSpace));
77
- }
78
- } else {
79
- values = values.split(',');
80
- }
81
- values = values.map(value => parseFloat(value));
82
- return {
83
- type,
84
- values,
85
- colorSpace
86
- };
87
- }
88
-
89
- /**
90
- * Returns a channel created from the input color.
91
- *
92
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
93
- * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
94
- */
95
- export const colorChannel = color => {
96
- const decomposedColor = decomposeColor(color);
97
- return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.includes('hsl') && idx !== 0 ? `${val}%` : val).join(' ');
98
- };
99
- export const private_safeColorChannel = (color, warning) => {
100
- try {
101
- return colorChannel(color);
102
- } catch (error) {
103
- if (warning && process.env.NODE_ENV !== 'production') {
104
- console.warn(warning);
105
- }
106
- return color;
107
- }
108
- };
109
-
110
- /**
111
- * Converts a color object with type and values to a string.
112
- * @param {object} color - Decomposed color
113
- * @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla', 'color'
114
- * @param {array} color.values - [n,n,n] or [n,n,n,n]
115
- * @returns {string} A CSS color string
116
- */
117
- export function recomposeColor(color) {
118
- const {
119
- type,
120
- colorSpace
121
- } = color;
122
- let {
123
- values
124
- } = color;
125
- if (type.includes('rgb')) {
126
- // Only convert the first 3 values to int (i.e. not alpha)
127
- values = values.map((n, i) => i < 3 ? parseInt(n, 10) : n);
128
- } else if (type.includes('hsl')) {
129
- values[1] = `${values[1]}%`;
130
- values[2] = `${values[2]}%`;
131
- }
132
- if (type.includes('color')) {
133
- values = `${colorSpace} ${values.join(' ')}`;
134
- } else {
135
- values = `${values.join(', ')}`;
136
- }
137
- return `${type}(${values})`;
138
- }
139
-
140
- /**
141
- * Converts a color from CSS rgb format to CSS hex format.
142
- * @param {string} color - RGB color, i.e. rgb(n, n, n)
143
- * @returns {string} A CSS rgb color string, i.e. #nnnnnn
144
- */
145
- export function rgbToHex(color) {
146
- // Idempotent
147
- if (color.startsWith('#')) {
148
- return color;
149
- }
150
- const {
151
- values
152
- } = decomposeColor(color);
153
- return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
154
- }
155
-
156
- /**
157
- * Converts a color from hsl format to rgb format.
158
- * @param {string} color - HSL color values
159
- * @returns {string} rgb color values
160
- */
161
- export function hslToRgb(color) {
162
- color = decomposeColor(color);
163
- const {
164
- values
165
- } = color;
166
- const h = values[0];
167
- const s = values[1] / 100;
168
- const l = values[2] / 100;
169
- const a = s * Math.min(l, 1 - l);
170
- const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
171
- let type = 'rgb';
172
- const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
173
- if (color.type === 'hsla') {
174
- type += 'a';
175
- rgb.push(values[3]);
176
- }
177
- return recomposeColor({
178
- type,
179
- values: rgb
180
- });
181
- }
182
- /**
183
- * The relative brightness of any point in a color space,
184
- * normalized to 0 for darkest black and 1 for lightest white.
185
- *
186
- * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
187
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
188
- * @returns {number} The relative brightness of the color in the range 0 - 1
189
- */
190
- export function getLuminance(color) {
191
- color = decomposeColor(color);
192
- let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
193
- rgb = rgb.map(val => {
194
- if (color.type !== 'color') {
195
- val /= 255; // normalized
196
- }
197
- return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
198
- });
199
-
200
- // Truncate at 3 digits
201
- return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
202
- }
203
-
204
- /**
205
- * Calculates the contrast ratio between two colors.
206
- *
207
- * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
208
- * @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
209
- * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
210
- * @returns {number} A contrast ratio value in the range 0 - 21.
211
- */
212
- export function getContrastRatio(foreground, background) {
213
- const lumA = getLuminance(foreground);
214
- const lumB = getLuminance(background);
215
- return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
216
- }
217
-
218
- /**
219
- * Sets the absolute transparency of a color.
220
- * Any existing alpha values are overwritten.
221
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
222
- * @param {number} value - value to set the alpha channel to in the range 0 - 1
223
- * @returns {string} A CSS color string. Hex input values are returned as rgb
224
- */
225
- export function alpha(color, value) {
226
- color = decomposeColor(color);
227
- value = clampWrapper(value);
228
- if (color.type === 'rgb' || color.type === 'hsl') {
229
- color.type += 'a';
230
- }
231
- if (color.type === 'color') {
232
- color.values[3] = `/${value}`;
233
- } else {
234
- color.values[3] = value;
235
- }
236
- return recomposeColor(color);
237
- }
238
- export function private_safeAlpha(color, value, warning) {
239
- try {
240
- return alpha(color, value);
241
- } catch (error) {
242
- if (warning && process.env.NODE_ENV !== 'production') {
243
- console.warn(warning);
244
- }
245
- return color;
246
- }
247
- }
248
-
249
- /**
250
- * Darkens a color.
251
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
252
- * @param {number} coefficient - multiplier in the range 0 - 1
253
- * @returns {string} A CSS color string. Hex input values are returned as rgb
254
- */
255
- export function darken(color, coefficient) {
256
- color = decomposeColor(color);
257
- coefficient = clampWrapper(coefficient);
258
- if (color.type.includes('hsl')) {
259
- color.values[2] *= 1 - coefficient;
260
- } else if (color.type.includes('rgb') || color.type.includes('color')) {
261
- for (let i = 0; i < 3; i += 1) {
262
- color.values[i] *= 1 - coefficient;
263
- }
264
- }
265
- return recomposeColor(color);
266
- }
267
- export function private_safeDarken(color, coefficient, warning) {
268
- try {
269
- return darken(color, coefficient);
270
- } catch (error) {
271
- if (warning && process.env.NODE_ENV !== 'production') {
272
- console.warn(warning);
273
- }
274
- return color;
275
- }
276
- }
277
-
278
- /**
279
- * Lightens a color.
280
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
281
- * @param {number} coefficient - multiplier in the range 0 - 1
282
- * @returns {string} A CSS color string. Hex input values are returned as rgb
283
- */
284
- export function lighten(color, coefficient) {
285
- color = decomposeColor(color);
286
- coefficient = clampWrapper(coefficient);
287
- if (color.type.includes('hsl')) {
288
- color.values[2] += (100 - color.values[2]) * coefficient;
289
- } else if (color.type.includes('rgb')) {
290
- for (let i = 0; i < 3; i += 1) {
291
- color.values[i] += (255 - color.values[i]) * coefficient;
292
- }
293
- } else if (color.type.includes('color')) {
294
- for (let i = 0; i < 3; i += 1) {
295
- color.values[i] += (1 - color.values[i]) * coefficient;
296
- }
297
- }
298
- return recomposeColor(color);
299
- }
300
- export function private_safeLighten(color, coefficient, warning) {
301
- try {
302
- return lighten(color, coefficient);
303
- } catch (error) {
304
- if (warning && process.env.NODE_ENV !== 'production') {
305
- console.warn(warning);
306
- }
307
- return color;
308
- }
309
- }
310
-
311
- /**
312
- * Darken or lighten a color, depending on its luminance.
313
- * Light colors are darkened, dark colors are lightened.
314
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
315
- * @param {number} coefficient=0.15 - multiplier in the range 0 - 1
316
- * @returns {string} A CSS color string. Hex input values are returned as rgb
317
- */
318
- export function emphasize(color, coefficient = 0.15) {
319
- return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
320
- }
321
- export function private_safeEmphasize(color, coefficient, warning) {
322
- try {
323
- return emphasize(color, coefficient);
324
- } catch (error) {
325
- if (warning && process.env.NODE_ENV !== 'production') {
326
- console.warn(warning);
327
- }
328
- return color;
329
- }
330
- }
331
-
332
- /**
333
- * Blend a transparent overlay color with a background color, resulting in a single
334
- * RGB color.
335
- * @param {string} background - CSS color
336
- * @param {string} overlay - CSS color
337
- * @param {number} opacity - Opacity multiplier in the range 0 - 1
338
- * @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
339
- */
340
- export function blend(background, overlay, opacity, gamma = 1.0) {
341
- const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
342
- const backgroundColor = decomposeColor(background);
343
- const overlayColor = decomposeColor(overlay);
344
- const rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
345
- return recomposeColor({
346
- type: 'rgb',
347
- values: rgb
348
- });
349
- }
@@ -1 +0,0 @@
1
- export * from "./colorManipulator.js";
@@ -1,24 +0,0 @@
1
- import merge from "../merge/index.js";
2
- function compose(...styles) {
3
- const handlers = styles.reduce((acc, style) => {
4
- style.filterProps.forEach(prop => {
5
- acc[prop] = style;
6
- });
7
- return acc;
8
- }, {});
9
-
10
- // false positive
11
- // eslint-disable-next-line react/function-component-definition
12
- const fn = props => {
13
- return Object.keys(props).reduce((acc, prop) => {
14
- if (handlers[prop]) {
15
- return merge(acc, handlers[prop](props));
16
- }
17
- return acc;
18
- }, {});
19
- };
20
- fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
21
- fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
22
- return fn;
23
- }
24
- export default compose;
@@ -1 +0,0 @@
1
- export { default } from "./compose.js";
@@ -1,35 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import clsx from 'clsx';
5
- import styled from '@mui/styled-engine';
6
- import styleFunctionSx, { extendSxProp } from "../styleFunctionSx/index.js";
7
- import useTheme from "../useTheme/index.js";
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- export default function createBox(options = {}) {
10
- const {
11
- themeId,
12
- defaultTheme,
13
- defaultClassName = 'MuiBox-root',
14
- generateClassName
15
- } = options;
16
- const BoxRoot = styled('div', {
17
- shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
18
- })(styleFunctionSx);
19
- const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
20
- const theme = useTheme(defaultTheme);
21
- const {
22
- className,
23
- component = 'div',
24
- ...other
25
- } = extendSxProp(inProps);
26
- return /*#__PURE__*/_jsx(BoxRoot, {
27
- as: component,
28
- ref: ref,
29
- className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
30
- theme: themeId ? theme[themeId] || theme : theme,
31
- ...other
32
- });
33
- });
34
- return Box;
35
- }
@@ -1 +0,0 @@
1
- export { default } from "./createBox.js";
@@ -1,81 +0,0 @@
1
- // Sorted ASC by size. That's important.
2
- // It can't be configured as it's used statically for propTypes.
3
- export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
4
- const sortBreakpointsValues = values => {
5
- const breakpointsAsArray = Object.keys(values).map(key => ({
6
- key,
7
- val: values[key]
8
- })) || [];
9
- // Sort in ascending order
10
- breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
11
- return breakpointsAsArray.reduce((acc, obj) => {
12
- return {
13
- ...acc,
14
- [obj.key]: obj.val
15
- };
16
- }, {});
17
- };
18
-
19
- // Keep in mind that @media is inclusive by the CSS specification.
20
- export default function createBreakpoints(breakpoints) {
21
- const {
22
- // The breakpoint **start** at this value.
23
- // For instance with the first breakpoint xs: [xs, sm).
24
- values = {
25
- xs: 0,
26
- // phone
27
- sm: 600,
28
- // tablet
29
- md: 900,
30
- // small laptop
31
- lg: 1200,
32
- // desktop
33
- xl: 1536 // large screen
34
- },
35
- unit = 'px',
36
- step = 5,
37
- ...other
38
- } = breakpoints;
39
- const sortedValues = sortBreakpointsValues(values);
40
- const keys = Object.keys(sortedValues);
41
- function up(key) {
42
- const value = typeof values[key] === 'number' ? values[key] : key;
43
- return `@media (min-width:${value}${unit})`;
44
- }
45
- function down(key) {
46
- const value = typeof values[key] === 'number' ? values[key] : key;
47
- return `@media (max-width:${value - step / 100}${unit})`;
48
- }
49
- function between(start, end) {
50
- const endIndex = keys.indexOf(end);
51
- 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})`;
52
- }
53
- function only(key) {
54
- if (keys.indexOf(key) + 1 < keys.length) {
55
- return between(key, keys[keys.indexOf(key) + 1]);
56
- }
57
- return up(key);
58
- }
59
- function not(key) {
60
- // handle first and last key separately, for better readability
61
- const keyIndex = keys.indexOf(key);
62
- if (keyIndex === 0) {
63
- return up(keys[1]);
64
- }
65
- if (keyIndex === keys.length - 1) {
66
- return down(keys[keyIndex]);
67
- }
68
- return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
69
- }
70
- return {
71
- keys,
72
- values: sortedValues,
73
- up,
74
- down,
75
- between,
76
- only,
77
- not,
78
- unit,
79
- ...other
80
- };
81
- }
@@ -1,3 +0,0 @@
1
- /** This export is intended for internal integration with Pigment CSS */
2
- /* eslint-disable import/prefer-default-export */
3
- export { default as unstable_createBreakpoints } from "./createBreakpoints.js";