@mui/system 6.0.0-alpha.1 → 6.0.0-alpha.4

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