@mui/system 6.1.2 → 6.1.3
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 +17 -11
- package/Box/boxClasses.js +10 -3
- package/Box/index.js +35 -3
- package/Box/package.json +2 -2
- package/CHANGELOG.md +81 -7
- package/Container/Container.js +17 -12
- package/Container/ContainerProps.js +5 -1
- package/Container/containerClasses.js +14 -6
- package/Container/createContainer.js +36 -28
- package/Container/index.js +35 -3
- package/Container/package.json +2 -2
- package/DefaultPropsProvider/DefaultPropsProvider.js +19 -11
- package/DefaultPropsProvider/index.js +19 -1
- package/DefaultPropsProvider/package.json +2 -2
- package/GlobalStyles/GlobalStyles.js +18 -11
- package/GlobalStyles/index.js +25 -2
- package/GlobalStyles/package.json +2 -2
- package/Grid/Grid.js +38 -27
- package/Grid/GridProps.d.ts +16 -11
- package/Grid/GridProps.js +5 -1
- package/Grid/createGrid.js +46 -38
- package/Grid/gridClasses.js +14 -6
- package/Grid/gridGenerator.d.ts +3 -7
- package/Grid/gridGenerator.js +62 -69
- package/Grid/index.js +63 -6
- package/Grid/package.json +2 -2
- package/Grid/traverseBreakpoints.js +11 -3
- package/InitColorSchemeScript/InitColorSchemeScript.js +16 -7
- package/InitColorSchemeScript/index.js +13 -1
- package/InitColorSchemeScript/package.json +2 -2
- package/RtlProvider/index.js +17 -8
- package/RtlProvider/package.json +2 -2
- package/Stack/Stack.js +17 -11
- package/Stack/StackProps.js +5 -1
- package/Stack/createStack.js +46 -36
- package/Stack/index.js +55 -5
- package/Stack/package.json +2 -2
- package/Stack/stackClasses.js +14 -6
- package/ThemeProvider/ThemeProvider.js +27 -20
- package/ThemeProvider/index.js +13 -1
- package/ThemeProvider/package.json +2 -2
- package/borders/borders.js +36 -26
- package/borders/index.js +25 -2
- package/borders/package.json +2 -2
- package/breakpoints/breakpoints.js +34 -21
- package/breakpoints/index.js +25 -2
- package/breakpoints/package.json +2 -2
- package/colorManipulator/colorManipulator.js +50 -25
- package/colorManipulator/index.js +16 -1
- package/colorManipulator/package.json +2 -2
- package/compose/compose.js +10 -3
- package/compose/index.js +13 -1
- package/compose/package.json +2 -2
- package/createBox/createBox.js +20 -13
- package/createBox/index.js +13 -1
- package/createBox/package.json +2 -2
- package/createBreakpoints/createBreakpoints.js +9 -2
- package/createBreakpoints/index.js +13 -3
- package/createBreakpoints/package.json +2 -2
- package/createStyled/createStyled.js +161 -117
- package/createStyled/index.js +25 -2
- package/createStyled/package.json +2 -2
- package/createTheme/applyStyles.js +7 -1
- package/createTheme/createSpacing.js +8 -3
- package/createTheme/createTheme.d.ts +16 -10
- package/createTheme/createTheme.js +25 -18
- package/createTheme/index.js +27 -3
- package/createTheme/package.json +2 -2
- package/createTheme/shape.js +7 -1
- package/cssContainerQueries/cssContainerQueries.js +16 -7
- package/cssContainerQueries/index.js +31 -2
- package/cssContainerQueries/package.json +2 -2
- package/cssGrid/cssGrid.js +40 -31
- package/cssGrid/index.js +25 -2
- package/cssGrid/package.json +2 -2
- package/cssVars/createCssVarsProvider.d.ts +1 -1
- package/cssVars/createCssVarsProvider.js +39 -30
- package/cssVars/createCssVarsTheme.js +14 -7
- package/cssVars/createGetCssVar.js +7 -1
- package/cssVars/cssVarsParser.js +13 -3
- package/cssVars/getColorSchemeSelector.js +7 -1
- package/cssVars/index.js +41 -5
- package/cssVars/package.json +2 -2
- package/cssVars/prepareCssVars.js +16 -9
- package/cssVars/prepareTypographyVars.js +7 -1
- package/cssVars/useCurrentColorScheme.js +15 -7
- package/display/display.js +16 -9
- package/display/index.js +25 -2
- package/display/package.json +2 -2
- package/esm/Box/Box.js +30 -0
- package/esm/Box/boxClasses.js +3 -0
- package/esm/Box/index.js +3 -0
- package/{node → esm}/Container/Container.js +12 -17
- package/esm/Container/ContainerProps.js +1 -0
- package/esm/Container/containerClasses.js +7 -0
- package/{node → esm}/Container/createContainer.js +28 -36
- package/esm/Container/index.js +3 -0
- package/{node → esm}/DefaultPropsProvider/DefaultPropsProvider.js +11 -19
- package/esm/DefaultPropsProvider/index.js +1 -0
- package/esm/GlobalStyles/GlobalStyles.js +37 -0
- package/esm/GlobalStyles/index.js +2 -0
- package/esm/Grid/Grid.js +106 -0
- package/esm/Grid/GridProps.js +1 -0
- package/esm/Grid/createGrid.js +148 -0
- package/{node → esm}/Grid/gridClasses.js +6 -14
- package/esm/Grid/gridGenerator.js +193 -0
- package/esm/Grid/index.js +6 -0
- package/{node → esm}/Grid/traverseBreakpoints.js +3 -11
- package/{node → esm}/InitColorSchemeScript/InitColorSchemeScript.js +7 -16
- package/esm/InitColorSchemeScript/index.js +1 -0
- package/esm/RtlProvider/index.js +22 -0
- package/{node → esm}/Stack/Stack.js +11 -17
- package/esm/Stack/StackProps.js +1 -0
- package/{node → esm}/Stack/createStack.js +36 -46
- package/esm/Stack/index.js +5 -0
- package/esm/Stack/stackClasses.js +7 -0
- package/{node → esm}/ThemeProvider/ThemeProvider.js +20 -27
- package/esm/ThemeProvider/index.js +1 -0
- package/esm/borders/borders.js +49 -0
- package/esm/borders/index.js +2 -0
- package/{node → esm}/breakpoints/breakpoints.js +21 -34
- package/esm/breakpoints/index.js +2 -0
- package/{node → esm}/colorManipulator/colorManipulator.js +23 -51
- package/esm/colorManipulator/index.js +1 -0
- package/{node → esm}/compose/compose.js +3 -10
- package/esm/compose/index.js +1 -0
- package/esm/createBox/createBox.js +35 -0
- package/esm/createBox/index.js +1 -0
- package/{node → esm}/createBreakpoints/createBreakpoints.js +2 -9
- package/esm/createBreakpoints/index.js +3 -0
- package/esm/createStyled/createStyled.js +276 -0
- package/esm/createStyled/index.js +2 -0
- package/{node → esm}/createTheme/applyStyles.js +1 -7
- package/{node → esm}/createTheme/createSpacing.js +3 -8
- package/esm/createTheme/createTheme.js +49 -0
- package/esm/createTheme/index.js +3 -0
- package/esm/createTheme/shape.js +4 -0
- package/{node → esm}/cssContainerQueries/cssContainerQueries.js +6 -17
- package/esm/cssContainerQueries/index.js +2 -0
- package/esm/cssGrid/cssGrid.js +85 -0
- package/esm/cssGrid/index.js +2 -0
- package/{node → esm}/cssVars/createCssVarsProvider.js +30 -39
- package/esm/cssVars/createCssVarsTheme.js +21 -0
- package/{node → esm}/cssVars/createGetCssVar.js +1 -7
- package/{node → esm}/cssVars/cssVarsParser.js +3 -13
- package/{node → esm}/cssVars/getColorSchemeSelector.js +1 -7
- package/esm/cssVars/index.js +5 -0
- package/{node → esm}/cssVars/prepareCssVars.js +9 -16
- package/{node → esm}/cssVars/prepareTypographyVars.js +1 -7
- package/{node → esm}/cssVars/useCurrentColorScheme.js +7 -15
- package/esm/display/display.js +27 -0
- package/esm/display/index.js +2 -0
- package/esm/flexbox/flexbox.js +43 -0
- package/esm/flexbox/index.js +2 -0
- package/esm/getThemeValue/getThemeValue.js +51 -0
- package/esm/getThemeValue/index.js +2 -0
- package/esm/index.js +68 -0
- package/esm/memoTheme.js +28 -0
- package/esm/memoize/index.js +1 -0
- package/{node → esm}/memoize/memoize.js +1 -7
- package/esm/merge/index.js +1 -0
- package/esm/merge/merge.js +10 -0
- package/esm/palette/index.js +2 -0
- package/esm/palette/palette.js +26 -0
- package/esm/positions/index.js +2 -0
- package/esm/positions/positions.js +22 -0
- package/esm/preprocessStyles.js +25 -0
- package/esm/propsToClassKey/index.js +1 -0
- package/esm/propsToClassKey/propsToClassKey.js +25 -0
- package/esm/responsivePropType/index.js +1 -0
- package/esm/responsivePropType/responsivePropType.js +3 -0
- package/esm/shadows/index.js +1 -0
- package/esm/shadows/shadows.js +6 -0
- package/esm/sizing/index.js +2 -0
- package/esm/sizing/sizing.js +64 -0
- package/esm/spacing/index.js +2 -0
- package/{node → esm}/spacing/spacing.js +21 -36
- package/esm/style/index.js +2 -0
- package/{node → esm}/style/style.js +9 -18
- package/{node → esm}/styleFunctionSx/defaultSxConfig.js +65 -71
- package/{node → esm}/styleFunctionSx/extendSxProp.js +5 -12
- package/esm/styleFunctionSx/index.js +4 -0
- package/{node → esm}/styleFunctionSx/styleFunctionSx.js +19 -27
- package/esm/styled/index.js +1 -0
- package/esm/styled/styled.js +3 -0
- package/esm/typography/index.js +2 -0
- package/esm/typography/typography.js +37 -0
- package/esm/useMediaQuery/index.js +2 -0
- package/{node → esm}/useMediaQuery/useMediaQuery.js +8 -15
- package/esm/useTheme/index.js +2 -0
- package/esm/useTheme/useTheme.js +9 -0
- package/esm/useThemeProps/getThemeProps.js +12 -0
- package/esm/useThemeProps/index.js +2 -0
- package/esm/useThemeProps/useThemeProps.js +20 -0
- package/esm/useThemeWithoutDefault/index.js +1 -0
- package/esm/useThemeWithoutDefault/useThemeWithoutDefault.js +12 -0
- package/esm/version/index.js +6 -0
- package/flexbox/flexbox.js +24 -17
- package/flexbox/index.js +25 -2
- package/flexbox/package.json +2 -2
- package/getThemeValue/getThemeValue.js +40 -33
- package/getThemeValue/index.js +25 -2
- package/getThemeValue/package.json +2 -2
- package/index.d.ts +2 -0
- package/index.js +606 -63
- package/memoTheme.d.ts +12 -0
- package/memoTheme.js +34 -0
- package/memoize/index.js +13 -1
- package/memoize/memoize.js +7 -1
- package/memoize/package.json +2 -2
- package/merge/index.js +13 -1
- package/merge/merge.js +10 -3
- package/merge/package.json +2 -2
- package/modern/Grid/Grid.js +16 -11
- package/modern/Grid/createGrid.js +1 -1
- package/modern/Grid/gridGenerator.js +28 -51
- package/modern/colorManipulator/colorManipulator.js +3 -4
- package/modern/createStyled/createStyled.js +144 -109
- package/modern/cssContainerQueries/cssContainerQueries.js +1 -2
- package/modern/index.js +3 -2
- package/modern/memoTheme.js +28 -0
- package/modern/preprocessStyles.js +25 -0
- package/modern/version/index.js +2 -2
- package/package.json +7 -7
- package/palette/index.js +25 -2
- package/palette/package.json +2 -2
- package/palette/palette.js +16 -8
- package/positions/index.js +25 -2
- package/positions/package.json +2 -2
- package/positions/positions.js +16 -9
- package/preprocessStyles.d.ts +5 -0
- package/preprocessStyles.js +31 -0
- package/propsToClassKey/index.js +13 -1
- package/propsToClassKey/package.json +2 -2
- package/propsToClassKey/propsToClassKey.js +11 -4
- package/responsivePropType/index.js +13 -1
- package/responsivePropType/package.json +2 -2
- package/responsivePropType/responsivePropType.js +10 -3
- package/shadows/index.js +13 -1
- package/shadows/package.json +2 -2
- package/shadows/shadows.js +10 -3
- package/sizing/index.js +25 -2
- package/sizing/package.json +2 -2
- package/sizing/sizing.js +27 -17
- package/spacing/index.js +25 -2
- package/spacing/package.json +2 -2
- package/spacing/spacing.js +36 -21
- package/style/index.js +25 -2
- package/style/package.json +2 -2
- package/style/style.js +18 -9
- package/styleFunctionSx/defaultSxConfig.js +71 -65
- package/styleFunctionSx/extendSxProp.js +12 -5
- package/styleFunctionSx/index.js +34 -4
- package/styleFunctionSx/package.json +2 -2
- package/styleFunctionSx/styleFunctionSx.d.ts +1 -1
- package/styleFunctionSx/styleFunctionSx.js +27 -19
- package/styled/index.js +13 -1
- package/styled/package.json +2 -2
- package/styled/styled.js +10 -3
- package/typography/index.js +25 -2
- package/typography/package.json +2 -2
- package/typography/typography.js +20 -13
- package/useMediaQuery/index.js +25 -2
- package/useMediaQuery/package.json +2 -2
- package/useMediaQuery/useMediaQuery.js +15 -8
- package/useTheme/index.js +25 -2
- package/useTheme/package.json +2 -2
- package/useTheme/useTheme.js +11 -5
- package/useThemeProps/getThemeProps.js +10 -3
- package/useThemeProps/index.js +20 -2
- package/useThemeProps/package.json +2 -2
- package/useThemeProps/useThemeProps.js +11 -5
- package/useThemeWithoutDefault/index.js +13 -1
- package/useThemeWithoutDefault/package.json +2 -2
- package/useThemeWithoutDefault/useThemeWithoutDefault.js +10 -4
- package/version/index.js +12 -6
- package/version/package.json +2 -2
- package/node/Box/Box.js +0 -36
- package/node/Box/boxClasses.js +0 -10
- package/node/Box/index.js +0 -35
- package/node/Container/ContainerProps.js +0 -5
- package/node/Container/containerClasses.js +0 -15
- package/node/Container/index.js +0 -35
- package/node/DefaultPropsProvider/index.js +0 -19
- package/node/GlobalStyles/GlobalStyles.js +0 -44
- package/node/GlobalStyles/index.js +0 -25
- package/node/Grid/Grid.js +0 -107
- package/node/Grid/GridProps.js +0 -5
- package/node/Grid/createGrid.js +0 -156
- package/node/Grid/gridGenerator.js +0 -232
- package/node/Grid/index.js +0 -63
- package/node/InitColorSchemeScript/index.js +0 -13
- package/node/RtlProvider/index.js +0 -31
- package/node/Stack/StackProps.js +0 -5
- package/node/Stack/index.js +0 -55
- package/node/Stack/stackClasses.js +0 -15
- package/node/ThemeProvider/index.js +0 -13
- package/node/borders/borders.js +0 -59
- package/node/borders/index.js +0 -25
- package/node/breakpoints/index.js +0 -25
- package/node/colorManipulator/index.js +0 -16
- package/node/compose/index.js +0 -13
- package/node/createBox/createBox.js +0 -42
- package/node/createBox/index.js +0 -13
- package/node/createBreakpoints/index.js +0 -13
- package/node/createStyled/createStyled.js +0 -252
- package/node/createStyled/index.js +0 -25
- package/node/createTheme/createTheme.js +0 -56
- package/node/createTheme/index.js +0 -27
- package/node/createTheme/shape.js +0 -10
- package/node/cssContainerQueries/index.js +0 -31
- package/node/cssGrid/cssGrid.js +0 -94
- package/node/cssGrid/index.js +0 -25
- package/node/cssVars/createCssVarsTheme.js +0 -28
- package/node/cssVars/index.js +0 -41
- package/node/display/display.js +0 -34
- package/node/display/index.js +0 -25
- package/node/flexbox/flexbox.js +0 -50
- package/node/flexbox/index.js +0 -25
- package/node/getThemeValue/getThemeValue.js +0 -58
- package/node/getThemeValue/index.js +0 -25
- package/node/index.js +0 -609
- package/node/memoize/index.js +0 -13
- package/node/merge/index.js +0 -13
- package/node/merge/merge.js +0 -17
- package/node/palette/index.js +0 -25
- package/node/palette/palette.js +0 -34
- package/node/positions/index.js +0 -25
- package/node/positions/positions.js +0 -29
- package/node/propsToClassKey/index.js +0 -13
- package/node/propsToClassKey/propsToClassKey.js +0 -32
- package/node/responsivePropType/index.js +0 -13
- package/node/responsivePropType/responsivePropType.js +0 -10
- package/node/shadows/index.js +0 -13
- package/node/shadows/shadows.js +0 -13
- package/node/sizing/index.js +0 -25
- package/node/sizing/sizing.js +0 -74
- package/node/spacing/index.js +0 -25
- package/node/style/index.js +0 -25
- package/node/styleFunctionSx/index.js +0 -34
- package/node/styled/index.js +0 -13
- package/node/styled/styled.js +0 -10
- package/node/typography/index.js +0 -25
- package/node/typography/typography.js +0 -44
- package/node/useMediaQuery/index.js +0 -25
- package/node/useTheme/index.js +0 -25
- package/node/useTheme/useTheme.js +0 -15
- package/node/useThemeProps/getThemeProps.js +0 -19
- package/node/useThemeProps/index.js +0 -20
- package/node/useThemeProps/useThemeProps.js +0 -26
- package/node/useThemeWithoutDefault/index.js +0 -13
- package/node/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -18
- package/node/version/index.js +0 -12
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.alpha = alpha;
|
|
8
|
-
exports.blend = blend;
|
|
9
|
-
exports.colorChannel = void 0;
|
|
10
|
-
exports.darken = darken;
|
|
11
|
-
exports.decomposeColor = decomposeColor;
|
|
12
|
-
exports.emphasize = emphasize;
|
|
13
|
-
exports.getContrastRatio = getContrastRatio;
|
|
14
|
-
exports.getLuminance = getLuminance;
|
|
15
|
-
exports.hexToRgb = hexToRgb;
|
|
16
|
-
exports.hslToRgb = hslToRgb;
|
|
17
|
-
exports.lighten = lighten;
|
|
18
|
-
exports.private_safeAlpha = private_safeAlpha;
|
|
19
|
-
exports.private_safeColorChannel = void 0;
|
|
20
|
-
exports.private_safeDarken = private_safeDarken;
|
|
21
|
-
exports.private_safeEmphasize = private_safeEmphasize;
|
|
22
|
-
exports.private_safeLighten = private_safeLighten;
|
|
23
|
-
exports.recomposeColor = recomposeColor;
|
|
24
|
-
exports.rgbToHex = rgbToHex;
|
|
25
|
-
var _formatMuiErrorMessage2 = _interopRequireDefault(require("@mui/utils/formatMuiErrorMessage"));
|
|
26
|
-
var _clamp = _interopRequireDefault(require("@mui/utils/clamp"));
|
|
1
|
+
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
27
2
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3
|
+
import clamp from '@mui/utils/clamp';
|
|
28
4
|
|
|
29
5
|
/**
|
|
30
6
|
* Returns a number whose value is limited to the given range.
|
|
@@ -39,7 +15,7 @@ function clampWrapper(value, min = 0, max = 1) {
|
|
|
39
15
|
console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
|
|
40
16
|
}
|
|
41
17
|
}
|
|
42
|
-
return (
|
|
18
|
+
return clamp(value, min, max);
|
|
43
19
|
}
|
|
44
20
|
|
|
45
21
|
/**
|
|
@@ -47,7 +23,7 @@ function clampWrapper(value, min = 0, max = 1) {
|
|
|
47
23
|
* @param {string} color - Hex color, i.e. #nnn or #nnnnnn
|
|
48
24
|
* @returns {string} A CSS rgb color string
|
|
49
25
|
*/
|
|
50
|
-
function hexToRgb(color) {
|
|
26
|
+
export function hexToRgb(color) {
|
|
51
27
|
color = color.slice(1);
|
|
52
28
|
const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
|
|
53
29
|
let colors = color.match(re);
|
|
@@ -70,7 +46,7 @@ function intToHex(int) {
|
|
|
70
46
|
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
71
47
|
* @returns {object} - A MUI color object: {type: string, values: number[]}
|
|
72
48
|
*/
|
|
73
|
-
function decomposeColor(color) {
|
|
49
|
+
export function decomposeColor(color) {
|
|
74
50
|
// Idempotent
|
|
75
51
|
if (color.type) {
|
|
76
52
|
return color;
|
|
@@ -81,8 +57,7 @@ function decomposeColor(color) {
|
|
|
81
57
|
const marker = color.indexOf('(');
|
|
82
58
|
const type = color.substring(0, marker);
|
|
83
59
|
if (!['rgb', 'rgba', 'hsl', 'hsla', 'color'].includes(type)) {
|
|
84
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Unsupported \`${color}\` color.
|
|
85
|
-
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().` : (0, _formatMuiErrorMessage2.default)(9, color));
|
|
60
|
+
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().' : _formatMuiErrorMessage(9, color));
|
|
86
61
|
}
|
|
87
62
|
let values = color.substring(marker + 1, color.length - 1);
|
|
88
63
|
let colorSpace;
|
|
@@ -93,8 +68,7 @@ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
|
93
68
|
values[3] = values[3].slice(1);
|
|
94
69
|
}
|
|
95
70
|
if (!['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].includes(colorSpace)) {
|
|
96
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: unsupported \`${colorSpace}\` color space.
|
|
97
|
-
The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.` : (0, _formatMuiErrorMessage2.default)(10, colorSpace));
|
|
71
|
+
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.' : _formatMuiErrorMessage(10, colorSpace));
|
|
98
72
|
}
|
|
99
73
|
} else {
|
|
100
74
|
values = values.split(',');
|
|
@@ -113,12 +87,11 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
|
|
|
113
87
|
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
114
88
|
* @returns {string} - The channel for the color, that can be used in rgba or hsla colors
|
|
115
89
|
*/
|
|
116
|
-
const colorChannel = color => {
|
|
90
|
+
export const colorChannel = color => {
|
|
117
91
|
const decomposedColor = decomposeColor(color);
|
|
118
92
|
return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.includes('hsl') && idx !== 0 ? `${val}%` : val).join(' ');
|
|
119
93
|
};
|
|
120
|
-
|
|
121
|
-
const private_safeColorChannel = (color, warning) => {
|
|
94
|
+
export const private_safeColorChannel = (color, warning) => {
|
|
122
95
|
try {
|
|
123
96
|
return colorChannel(color);
|
|
124
97
|
} catch (error) {
|
|
@@ -136,8 +109,7 @@ const private_safeColorChannel = (color, warning) => {
|
|
|
136
109
|
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
137
110
|
* @returns {string} A CSS color string
|
|
138
111
|
*/
|
|
139
|
-
|
|
140
|
-
function recomposeColor(color) {
|
|
112
|
+
export function recomposeColor(color) {
|
|
141
113
|
const {
|
|
142
114
|
type,
|
|
143
115
|
colorSpace
|
|
@@ -165,7 +137,7 @@ function recomposeColor(color) {
|
|
|
165
137
|
* @param {string} color - RGB color, i.e. rgb(n, n, n)
|
|
166
138
|
* @returns {string} A CSS rgb color string, i.e. #nnnnnn
|
|
167
139
|
*/
|
|
168
|
-
function rgbToHex(color) {
|
|
140
|
+
export function rgbToHex(color) {
|
|
169
141
|
// Idempotent
|
|
170
142
|
if (color.startsWith('#')) {
|
|
171
143
|
return color;
|
|
@@ -181,7 +153,7 @@ function rgbToHex(color) {
|
|
|
181
153
|
* @param {string} color - HSL color values
|
|
182
154
|
* @returns {string} rgb color values
|
|
183
155
|
*/
|
|
184
|
-
function hslToRgb(color) {
|
|
156
|
+
export function hslToRgb(color) {
|
|
185
157
|
color = decomposeColor(color);
|
|
186
158
|
const {
|
|
187
159
|
values
|
|
@@ -210,7 +182,7 @@ function hslToRgb(color) {
|
|
|
210
182
|
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
|
|
211
183
|
* @returns {number} The relative brightness of the color in the range 0 - 1
|
|
212
184
|
*/
|
|
213
|
-
function getLuminance(color) {
|
|
185
|
+
export function getLuminance(color) {
|
|
214
186
|
color = decomposeColor(color);
|
|
215
187
|
let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
216
188
|
rgb = rgb.map(val => {
|
|
@@ -232,7 +204,7 @@ function getLuminance(color) {
|
|
|
232
204
|
* @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
|
|
233
205
|
* @returns {number} A contrast ratio value in the range 0 - 21.
|
|
234
206
|
*/
|
|
235
|
-
function getContrastRatio(foreground, background) {
|
|
207
|
+
export function getContrastRatio(foreground, background) {
|
|
236
208
|
const lumA = getLuminance(foreground);
|
|
237
209
|
const lumB = getLuminance(background);
|
|
238
210
|
return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
|
|
@@ -245,7 +217,7 @@ function getContrastRatio(foreground, background) {
|
|
|
245
217
|
* @param {number} value - value to set the alpha channel to in the range 0 - 1
|
|
246
218
|
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
247
219
|
*/
|
|
248
|
-
function alpha(color, value) {
|
|
220
|
+
export function alpha(color, value) {
|
|
249
221
|
color = decomposeColor(color);
|
|
250
222
|
value = clampWrapper(value);
|
|
251
223
|
if (color.type === 'rgb' || color.type === 'hsl') {
|
|
@@ -258,7 +230,7 @@ function alpha(color, value) {
|
|
|
258
230
|
}
|
|
259
231
|
return recomposeColor(color);
|
|
260
232
|
}
|
|
261
|
-
function private_safeAlpha(color, value, warning) {
|
|
233
|
+
export function private_safeAlpha(color, value, warning) {
|
|
262
234
|
try {
|
|
263
235
|
return alpha(color, value);
|
|
264
236
|
} catch (error) {
|
|
@@ -275,7 +247,7 @@ function private_safeAlpha(color, value, warning) {
|
|
|
275
247
|
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
276
248
|
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
277
249
|
*/
|
|
278
|
-
function darken(color, coefficient) {
|
|
250
|
+
export function darken(color, coefficient) {
|
|
279
251
|
color = decomposeColor(color);
|
|
280
252
|
coefficient = clampWrapper(coefficient);
|
|
281
253
|
if (color.type.includes('hsl')) {
|
|
@@ -287,7 +259,7 @@ function darken(color, coefficient) {
|
|
|
287
259
|
}
|
|
288
260
|
return recomposeColor(color);
|
|
289
261
|
}
|
|
290
|
-
function private_safeDarken(color, coefficient, warning) {
|
|
262
|
+
export function private_safeDarken(color, coefficient, warning) {
|
|
291
263
|
try {
|
|
292
264
|
return darken(color, coefficient);
|
|
293
265
|
} catch (error) {
|
|
@@ -304,7 +276,7 @@ function private_safeDarken(color, coefficient, warning) {
|
|
|
304
276
|
* @param {number} coefficient - multiplier in the range 0 - 1
|
|
305
277
|
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
306
278
|
*/
|
|
307
|
-
function lighten(color, coefficient) {
|
|
279
|
+
export function lighten(color, coefficient) {
|
|
308
280
|
color = decomposeColor(color);
|
|
309
281
|
coefficient = clampWrapper(coefficient);
|
|
310
282
|
if (color.type.includes('hsl')) {
|
|
@@ -320,7 +292,7 @@ function lighten(color, coefficient) {
|
|
|
320
292
|
}
|
|
321
293
|
return recomposeColor(color);
|
|
322
294
|
}
|
|
323
|
-
function private_safeLighten(color, coefficient, warning) {
|
|
295
|
+
export function private_safeLighten(color, coefficient, warning) {
|
|
324
296
|
try {
|
|
325
297
|
return lighten(color, coefficient);
|
|
326
298
|
} catch (error) {
|
|
@@ -338,10 +310,10 @@ function private_safeLighten(color, coefficient, warning) {
|
|
|
338
310
|
* @param {number} coefficient=0.15 - multiplier in the range 0 - 1
|
|
339
311
|
* @returns {string} A CSS color string. Hex input values are returned as rgb
|
|
340
312
|
*/
|
|
341
|
-
function emphasize(color, coefficient = 0.15) {
|
|
313
|
+
export function emphasize(color, coefficient = 0.15) {
|
|
342
314
|
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
|
|
343
315
|
}
|
|
344
|
-
function private_safeEmphasize(color, coefficient, warning) {
|
|
316
|
+
export function private_safeEmphasize(color, coefficient, warning) {
|
|
345
317
|
try {
|
|
346
318
|
return emphasize(color, coefficient);
|
|
347
319
|
} catch (error) {
|
|
@@ -360,7 +332,7 @@ function private_safeEmphasize(color, coefficient, warning) {
|
|
|
360
332
|
* @param {number} opacity - Opacity multiplier in the range 0 - 1
|
|
361
333
|
* @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
|
|
362
334
|
*/
|
|
363
|
-
function blend(background, overlay, opacity, gamma = 1.0) {
|
|
335
|
+
export function blend(background, overlay, opacity, gamma = 1.0) {
|
|
364
336
|
const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
|
|
365
337
|
const backgroundColor = decomposeColor(background);
|
|
366
338
|
const overlayColor = decomposeColor(overlay);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./colorManipulator.js";
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _merge = _interopRequireDefault(require("../merge"));
|
|
1
|
+
import merge from "../merge/index.js";
|
|
9
2
|
function compose(...styles) {
|
|
10
3
|
const handlers = styles.reduce((acc, style) => {
|
|
11
4
|
style.filterProps.forEach(prop => {
|
|
@@ -19,7 +12,7 @@ function compose(...styles) {
|
|
|
19
12
|
const fn = props => {
|
|
20
13
|
return Object.keys(props).reduce((acc, prop) => {
|
|
21
14
|
if (handlers[prop]) {
|
|
22
|
-
return (
|
|
15
|
+
return merge(acc, handlers[prop](props));
|
|
23
16
|
}
|
|
24
17
|
return acc;
|
|
25
18
|
}, {});
|
|
@@ -28,4 +21,4 @@ function compose(...styles) {
|
|
|
28
21
|
fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
|
|
29
22
|
return fn;
|
|
30
23
|
}
|
|
31
|
-
|
|
24
|
+
export default compose;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./compose.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./createBox.js";
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.breakpointKeys = void 0;
|
|
7
|
-
exports.default = createBreakpoints;
|
|
8
1
|
// Sorted ASC by size. That's important.
|
|
9
2
|
// It can't be configured as it's used statically for propTypes.
|
|
10
|
-
const breakpointKeys =
|
|
3
|
+
export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
11
4
|
const sortBreakpointsValues = values => {
|
|
12
5
|
const breakpointsAsArray = Object.keys(values).map(key => ({
|
|
13
6
|
key,
|
|
@@ -24,7 +17,7 @@ const sortBreakpointsValues = values => {
|
|
|
24
17
|
};
|
|
25
18
|
|
|
26
19
|
// Keep in mind that @media is inclusive by the CSS specification.
|
|
27
|
-
function createBreakpoints(breakpoints) {
|
|
20
|
+
export default function createBreakpoints(breakpoints) {
|
|
28
21
|
const {
|
|
29
22
|
// The breakpoint **start** at this value.
|
|
30
23
|
// For instance with the first breakpoint xs: [xs, sm).
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import styledEngineStyled, { internal_mutateStyles as mutateStyles } from '@mui/styled-engine';
|
|
2
|
+
import { isPlainObject } from '@mui/utils/deepmerge';
|
|
3
|
+
import capitalize from '@mui/utils/capitalize';
|
|
4
|
+
import getDisplayName from '@mui/utils/getDisplayName';
|
|
5
|
+
import createTheme from "../createTheme/index.js";
|
|
6
|
+
import styleFunctionSx from "../styleFunctionSx/index.js";
|
|
7
|
+
import preprocessStyles from "../preprocessStyles.js";
|
|
8
|
+
|
|
9
|
+
/* eslint-disable no-underscore-dangle */
|
|
10
|
+
/* eslint-disable no-labels */
|
|
11
|
+
/* eslint-disable no-lone-blocks */
|
|
12
|
+
|
|
13
|
+
export const systemDefaultTheme = createTheme();
|
|
14
|
+
|
|
15
|
+
// Update /system/styled/#api in case if this changes
|
|
16
|
+
export function shouldForwardProp(prop) {
|
|
17
|
+
return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
|
18
|
+
}
|
|
19
|
+
function defaultOverridesResolver(slot) {
|
|
20
|
+
if (!slot) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return (_props, styles) => styles[slot];
|
|
24
|
+
}
|
|
25
|
+
function attachTheme(props, themeId, defaultTheme) {
|
|
26
|
+
props.theme = isObjectEmpty(props.theme) ? defaultTheme : props.theme[themeId] || props.theme;
|
|
27
|
+
}
|
|
28
|
+
function processStyle(props, style) {
|
|
29
|
+
/*
|
|
30
|
+
* Style types:
|
|
31
|
+
* - null/undefined
|
|
32
|
+
* - string
|
|
33
|
+
* - CSS style object: { [cssKey]: [cssValue], variants }
|
|
34
|
+
* - Processed style object: { style, variants, isProcessed: true }
|
|
35
|
+
* - Array of any of the above
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const resolvedStyle = typeof style === 'function' ? style(props) : style;
|
|
39
|
+
if (Array.isArray(resolvedStyle)) {
|
|
40
|
+
return resolvedStyle.flatMap(subStyle => processStyle(props, subStyle));
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(resolvedStyle?.variants)) {
|
|
43
|
+
let rootStyle;
|
|
44
|
+
if (resolvedStyle.isProcessed) {
|
|
45
|
+
rootStyle = resolvedStyle.style;
|
|
46
|
+
} else {
|
|
47
|
+
const {
|
|
48
|
+
variants,
|
|
49
|
+
...otherStyles
|
|
50
|
+
} = resolvedStyle;
|
|
51
|
+
rootStyle = otherStyles;
|
|
52
|
+
}
|
|
53
|
+
return processStyleVariants(props, resolvedStyle.variants, [rootStyle]);
|
|
54
|
+
}
|
|
55
|
+
if (resolvedStyle?.isProcessed) {
|
|
56
|
+
return resolvedStyle.style;
|
|
57
|
+
}
|
|
58
|
+
return resolvedStyle;
|
|
59
|
+
}
|
|
60
|
+
function processStyleVariants(props, variants, results = []) {
|
|
61
|
+
let mergedState; // We might not need it, initialized lazily
|
|
62
|
+
|
|
63
|
+
variantLoop: for (let i = 0; i < variants.length; i += 1) {
|
|
64
|
+
const variant = variants[i];
|
|
65
|
+
if (typeof variant.props === 'function') {
|
|
66
|
+
mergedState ??= {
|
|
67
|
+
...props,
|
|
68
|
+
...props.ownerState,
|
|
69
|
+
ownerState: props.ownerState
|
|
70
|
+
};
|
|
71
|
+
if (!variant.props(mergedState)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
for (const key in variant.props) {
|
|
76
|
+
if (props[key] !== variant.props[key] && props.ownerState?.[key] !== variant.props[key]) {
|
|
77
|
+
continue variantLoop;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (typeof variant.style === 'function') {
|
|
82
|
+
mergedState ??= {
|
|
83
|
+
...props,
|
|
84
|
+
...props.ownerState,
|
|
85
|
+
ownerState: props.ownerState
|
|
86
|
+
};
|
|
87
|
+
results.push(variant.style(mergedState));
|
|
88
|
+
} else {
|
|
89
|
+
results.push(variant.style);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return results;
|
|
93
|
+
}
|
|
94
|
+
export default function createStyled(input = {}) {
|
|
95
|
+
const {
|
|
96
|
+
themeId,
|
|
97
|
+
defaultTheme = systemDefaultTheme,
|
|
98
|
+
rootShouldForwardProp = shouldForwardProp,
|
|
99
|
+
slotShouldForwardProp = shouldForwardProp
|
|
100
|
+
} = input;
|
|
101
|
+
function styleAttachTheme(props) {
|
|
102
|
+
attachTheme(props, themeId, defaultTheme);
|
|
103
|
+
}
|
|
104
|
+
const styled = (tag, inputOptions = {}) => {
|
|
105
|
+
// If `tag` is already a styled component, filter out the `sx` style function
|
|
106
|
+
// to prevent unnecessary styles generated by the composite components.
|
|
107
|
+
mutateStyles(tag, styles => styles.filter(style => style !== styleFunctionSx));
|
|
108
|
+
const {
|
|
109
|
+
name: componentName,
|
|
110
|
+
slot: componentSlot,
|
|
111
|
+
skipVariantsResolver: inputSkipVariantsResolver,
|
|
112
|
+
skipSx: inputSkipSx,
|
|
113
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
114
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
115
|
+
overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot)),
|
|
116
|
+
...options
|
|
117
|
+
} = inputOptions;
|
|
118
|
+
|
|
119
|
+
// if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
120
|
+
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
121
|
+
// TODO v6: remove `Root` in the next major release
|
|
122
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
123
|
+
componentSlot && componentSlot !== 'Root' && componentSlot !== 'root' || false;
|
|
124
|
+
const skipSx = inputSkipSx || false;
|
|
125
|
+
let shouldForwardPropOption = shouldForwardProp;
|
|
126
|
+
|
|
127
|
+
// TODO v6: remove `Root` in the next major release
|
|
128
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
129
|
+
if (componentSlot === 'Root' || componentSlot === 'root') {
|
|
130
|
+
shouldForwardPropOption = rootShouldForwardProp;
|
|
131
|
+
} else if (componentSlot) {
|
|
132
|
+
// any other slot specified
|
|
133
|
+
shouldForwardPropOption = slotShouldForwardProp;
|
|
134
|
+
} else if (isStringTag(tag)) {
|
|
135
|
+
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
136
|
+
shouldForwardPropOption = undefined;
|
|
137
|
+
}
|
|
138
|
+
const defaultStyledResolver = styledEngineStyled(tag, {
|
|
139
|
+
shouldForwardProp: shouldForwardPropOption,
|
|
140
|
+
label: generateStyledLabel(componentName, componentSlot),
|
|
141
|
+
...options
|
|
142
|
+
});
|
|
143
|
+
const transformStyle = style => {
|
|
144
|
+
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
145
|
+
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
146
|
+
// which are basically components used as a selectors.
|
|
147
|
+
if (typeof style === 'function' && style.__emotion_real !== style) {
|
|
148
|
+
return function styleFunctionProcessor(props) {
|
|
149
|
+
return processStyle(props, style);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (isPlainObject(style)) {
|
|
153
|
+
const serialized = preprocessStyles(style);
|
|
154
|
+
if (!serialized.variants) {
|
|
155
|
+
return serialized.style;
|
|
156
|
+
}
|
|
157
|
+
return function styleObjectProcessor(props) {
|
|
158
|
+
return processStyle(props, serialized);
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return style;
|
|
162
|
+
};
|
|
163
|
+
const muiStyledResolver = (...expressionsInput) => {
|
|
164
|
+
const expressionsHead = [];
|
|
165
|
+
const expressionsBody = expressionsInput.map(transformStyle);
|
|
166
|
+
const expressionsTail = [];
|
|
167
|
+
|
|
168
|
+
// Preprocess `props` to set the scoped theme value.
|
|
169
|
+
// This must run before any other expression.
|
|
170
|
+
expressionsHead.push(styleAttachTheme);
|
|
171
|
+
if (componentName && overridesResolver) {
|
|
172
|
+
expressionsTail.push(function styleThemeOverrides(props) {
|
|
173
|
+
const theme = props.theme;
|
|
174
|
+
const styleOverrides = theme.components?.[componentName]?.styleOverrides;
|
|
175
|
+
if (!styleOverrides) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const resolvedStyleOverrides = {};
|
|
179
|
+
|
|
180
|
+
// TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
|
|
181
|
+
// eslint-disable-next-line guard-for-in
|
|
182
|
+
for (const slotKey in styleOverrides) {
|
|
183
|
+
resolvedStyleOverrides[slotKey] = processStyle(props, styleOverrides[slotKey]);
|
|
184
|
+
}
|
|
185
|
+
return overridesResolver(props, resolvedStyleOverrides);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (componentName && !skipVariantsResolver) {
|
|
189
|
+
expressionsTail.push(function styleThemeVariants(props) {
|
|
190
|
+
const theme = props.theme;
|
|
191
|
+
const themeVariants = theme?.components?.[componentName]?.variants;
|
|
192
|
+
if (!themeVariants) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
return processStyleVariants(props, themeVariants);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (!skipSx) {
|
|
199
|
+
expressionsTail.push(styleFunctionSx);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// This function can be called as a tagged template, so the first argument would contain
|
|
203
|
+
// CSS `string[]` values.
|
|
204
|
+
if (Array.isArray(expressionsBody[0])) {
|
|
205
|
+
const inputStrings = expressionsBody.shift();
|
|
206
|
+
|
|
207
|
+
// We need to add placeholders in the tagged template for the custom functions we have
|
|
208
|
+
// possibly added (attachTheme, overrides, variants, and sx).
|
|
209
|
+
const placeholdersHead = new Array(expressionsHead.length).fill('');
|
|
210
|
+
const placeholdersTail = new Array(expressionsTail.length).fill('');
|
|
211
|
+
let outputStrings;
|
|
212
|
+
// prettier-ignore
|
|
213
|
+
{
|
|
214
|
+
outputStrings = [...placeholdersHead, ...inputStrings, ...placeholdersTail];
|
|
215
|
+
outputStrings.raw = [...placeholdersHead, ...inputStrings.raw, ...placeholdersTail];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// The only case where we put something before `attachTheme`
|
|
219
|
+
expressionsHead.unshift(outputStrings);
|
|
220
|
+
}
|
|
221
|
+
const expressions = [...expressionsHead, ...expressionsBody, ...expressionsTail];
|
|
222
|
+
const Component = defaultStyledResolver(...expressions);
|
|
223
|
+
if (tag.muiName) {
|
|
224
|
+
Component.muiName = tag.muiName;
|
|
225
|
+
}
|
|
226
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
227
|
+
Component.displayName = generateDisplayName(componentName, componentSlot, tag);
|
|
228
|
+
}
|
|
229
|
+
return Component;
|
|
230
|
+
};
|
|
231
|
+
if (defaultStyledResolver.withConfig) {
|
|
232
|
+
muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
|
|
233
|
+
}
|
|
234
|
+
return muiStyledResolver;
|
|
235
|
+
};
|
|
236
|
+
return styled;
|
|
237
|
+
}
|
|
238
|
+
function generateDisplayName(componentName, componentSlot, tag) {
|
|
239
|
+
if (componentName) {
|
|
240
|
+
return `${componentName}${capitalize(componentSlot || '')}`;
|
|
241
|
+
}
|
|
242
|
+
return `Styled(${getDisplayName(tag)})`;
|
|
243
|
+
}
|
|
244
|
+
function generateStyledLabel(componentName, componentSlot) {
|
|
245
|
+
let label;
|
|
246
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
247
|
+
if (componentName) {
|
|
248
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
249
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
250
|
+
label = `${componentName}-${lowercaseFirstLetter(componentSlot || 'Root')}`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return label;
|
|
254
|
+
}
|
|
255
|
+
function isObjectEmpty(object) {
|
|
256
|
+
// eslint-disable-next-line
|
|
257
|
+
for (const _ in object) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
|
|
264
|
+
function isStringTag(tag) {
|
|
265
|
+
return typeof tag === 'string' &&
|
|
266
|
+
// 96 is one less than the char code
|
|
267
|
+
// for "a" so this is checking that
|
|
268
|
+
// it's a lowercase character
|
|
269
|
+
tag.charCodeAt(0) > 96;
|
|
270
|
+
}
|
|
271
|
+
function lowercaseFirstLetter(string) {
|
|
272
|
+
if (!string) {
|
|
273
|
+
return string;
|
|
274
|
+
}
|
|
275
|
+
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
276
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = applyStyles;
|
|
7
1
|
/**
|
|
8
2
|
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
9
3
|
* It works with:
|
|
@@ -62,7 +56,7 @@ exports.default = applyStyles;
|
|
|
62
56
|
* })
|
|
63
57
|
*```
|
|
64
58
|
*/
|
|
65
|
-
function applyStyles(key, styles) {
|
|
59
|
+
export default function applyStyles(key, styles) {
|
|
66
60
|
// @ts-expect-error this is 'any' type
|
|
67
61
|
const theme = this;
|
|
68
62
|
if (theme.vars) {
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { createUnarySpacing } from "../spacing/index.js";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = createSpacing;
|
|
7
|
-
var _spacing = require("../spacing");
|
|
8
3
|
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
9
4
|
// We express the difference with variable names.
|
|
10
5
|
|
|
11
|
-
function createSpacing(spacingInput = 8,
|
|
6
|
+
export default function createSpacing(spacingInput = 8,
|
|
12
7
|
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
13
8
|
// Smaller components, such as icons, can align to a 4dp grid.
|
|
14
9
|
// https://m2.material.io/design/layout/understanding-layout.html
|
|
15
|
-
transform =
|
|
10
|
+
transform = createUnarySpacing({
|
|
16
11
|
spacing: spacingInput
|
|
17
12
|
})) {
|
|
18
13
|
// Already transformed.
|