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