@mui/system 5.10.16 → 5.11.0
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/CHANGELOG.md +148 -0
- package/borders.js +12 -7
- package/breakpoints.js +2 -0
- package/colorManipulator.d.ts +10 -0
- package/colorManipulator.js +57 -1
- package/compose.js +3 -0
- package/createBox.d.ts +0 -2
- package/createBox.js +2 -3
- package/createStyled.js +2 -3
- package/createTheme/createTheme.d.ts +5 -0
- package/createTheme/createTheme.js +9 -0
- package/cssGrid.js +8 -0
- package/cssVars/createCssVarsProvider.d.ts +54 -1
- package/cssVars/createCssVarsProvider.js +47 -13
- package/esm/borders.js +9 -6
- package/esm/breakpoints.js +2 -0
- package/esm/colorManipulator.js +50 -0
- package/esm/compose.js +3 -0
- package/esm/createBox.js +2 -3
- package/esm/createStyled.js +2 -3
- package/esm/createTheme/createTheme.js +9 -0
- package/esm/cssGrid.js +9 -0
- package/esm/cssVars/createCssVarsProvider.js +47 -13
- package/esm/index.js +1 -2
- package/esm/palette.js +4 -4
- package/esm/sizing.js +9 -9
- package/esm/spacing.js +2 -2
- package/esm/style.js +4 -1
- package/esm/styleFunctionSx/defaultSxConfig.js +284 -0
- package/esm/styleFunctionSx/extendSxProp.js +4 -2
- package/esm/styleFunctionSx/index.js +2 -1
- package/esm/styleFunctionSx/styleFunctionSx.js +45 -17
- package/index.d.ts +1 -2
- package/index.js +8 -9
- package/legacy/borders.js +9 -6
- package/legacy/breakpoints.js +2 -0
- package/legacy/colorManipulator.js +50 -0
- package/legacy/compose.js +3 -0
- package/legacy/createBox.js +2 -4
- package/legacy/createStyled.js +2 -4
- package/legacy/createTheme/createTheme.js +9 -0
- package/legacy/cssGrid.js +9 -0
- package/legacy/cssVars/createCssVarsProvider.js +47 -11
- package/legacy/index.js +2 -3
- package/legacy/palette.js +4 -4
- package/legacy/sizing.js +9 -9
- package/legacy/spacing.js +2 -2
- package/legacy/style.js +3 -2
- package/legacy/styleFunctionSx/defaultSxConfig.js +286 -0
- package/legacy/styleFunctionSx/extendSxProp.js +4 -2
- package/legacy/styleFunctionSx/index.js +2 -1
- package/legacy/styleFunctionSx/styleFunctionSx.js +44 -20
- package/modern/borders.js +9 -6
- package/modern/breakpoints.js +2 -0
- package/modern/colorManipulator.js +50 -0
- package/modern/compose.js +3 -0
- package/modern/createBox.js +2 -3
- package/modern/createStyled.js +2 -3
- package/modern/createTheme/createTheme.js +9 -0
- package/modern/cssGrid.js +9 -0
- package/modern/cssVars/createCssVarsProvider.js +47 -13
- package/modern/index.js +2 -3
- package/modern/palette.js +4 -4
- package/modern/sizing.js +9 -9
- package/modern/spacing.js +2 -2
- package/modern/style.js +4 -1
- package/modern/styleFunctionSx/defaultSxConfig.js +284 -0
- package/modern/styleFunctionSx/extendSxProp.js +3 -2
- package/modern/styleFunctionSx/index.js +2 -1
- package/modern/styleFunctionSx/styleFunctionSx.js +44 -17
- package/package.json +6 -6
- package/palette.js +5 -4
- package/sizing.js +12 -10
- package/spacing.js +4 -0
- package/style.d.ts +10 -8
- package/style.js +4 -1
- package/styleFunctionSx/defaultSxConfig.d.ts +20 -0
- package/styleFunctionSx/defaultSxConfig.js +291 -0
- package/styleFunctionSx/extendSxProp.js +4 -2
- package/styleFunctionSx/index.d.ts +4 -0
- package/styleFunctionSx/index.js +7 -0
- package/styleFunctionSx/styleFunctionSx.d.ts +2 -1
- package/styleFunctionSx/styleFunctionSx.js +45 -17
- package/esm/sx/index.js +0 -1
- package/esm/sx/sx.js +0 -10
- package/legacy/sx/index.js +0 -1
- package/legacy/sx/sx.js +0 -11
- package/modern/sx/index.js +0 -1
- package/modern/sx/sx.js +0 -10
- package/sx/index.d.ts +0 -1
- package/sx/index.js +0 -13
- package/sx/package.json +0 -6
- package/sx/sx.d.ts +0 -4
- package/sx/sx.js +0 -18
package/modern/borders.js
CHANGED
|
@@ -3,7 +3,7 @@ import style from './style';
|
|
|
3
3
|
import compose from './compose';
|
|
4
4
|
import { createUnaryUnit, getValue } from './spacing';
|
|
5
5
|
import { handleBreakpoints } from './breakpoints';
|
|
6
|
-
function
|
|
6
|
+
export function borderTransform(value) {
|
|
7
7
|
if (typeof value !== 'number') {
|
|
8
8
|
return value;
|
|
9
9
|
}
|
|
@@ -12,27 +12,27 @@ function getBorder(value) {
|
|
|
12
12
|
export const border = style({
|
|
13
13
|
prop: 'border',
|
|
14
14
|
themeKey: 'borders',
|
|
15
|
-
transform:
|
|
15
|
+
transform: borderTransform
|
|
16
16
|
});
|
|
17
17
|
export const borderTop = style({
|
|
18
18
|
prop: 'borderTop',
|
|
19
19
|
themeKey: 'borders',
|
|
20
|
-
transform:
|
|
20
|
+
transform: borderTransform
|
|
21
21
|
});
|
|
22
22
|
export const borderRight = style({
|
|
23
23
|
prop: 'borderRight',
|
|
24
24
|
themeKey: 'borders',
|
|
25
|
-
transform:
|
|
25
|
+
transform: borderTransform
|
|
26
26
|
});
|
|
27
27
|
export const borderBottom = style({
|
|
28
28
|
prop: 'borderBottom',
|
|
29
29
|
themeKey: 'borders',
|
|
30
|
-
transform:
|
|
30
|
+
transform: borderTransform
|
|
31
31
|
});
|
|
32
32
|
export const borderLeft = style({
|
|
33
33
|
prop: 'borderLeft',
|
|
34
34
|
themeKey: 'borders',
|
|
35
|
-
transform:
|
|
35
|
+
transform: borderTransform
|
|
36
36
|
});
|
|
37
37
|
export const borderColor = style({
|
|
38
38
|
prop: 'borderColor',
|
|
@@ -54,6 +54,9 @@ export const borderLeftColor = style({
|
|
|
54
54
|
prop: 'borderLeftColor',
|
|
55
55
|
themeKey: 'palette'
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
// false positive
|
|
59
|
+
// eslint-disable-next-line react/function-component-definition
|
|
57
60
|
export const borderRadius = props => {
|
|
58
61
|
if (props.borderRadius !== undefined && props.borderRadius !== null) {
|
|
59
62
|
const transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius');
|
package/modern/breakpoints.js
CHANGED
|
@@ -50,6 +50,8 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
|
|
|
50
50
|
return output;
|
|
51
51
|
}
|
|
52
52
|
function breakpoints(styleFunction) {
|
|
53
|
+
// false positive
|
|
54
|
+
// eslint-disable-next-line react/function-component-definition
|
|
53
55
|
const newStyleFunction = props => {
|
|
54
56
|
const theme = props.theme || {};
|
|
55
57
|
const base = styleFunction(props);
|
|
@@ -90,6 +90,16 @@ export const colorChannel = color => {
|
|
|
90
90
|
const decomposedColor = decomposeColor(color);
|
|
91
91
|
return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
|
|
92
92
|
};
|
|
93
|
+
export const private_safeColorChannel = (color, warning) => {
|
|
94
|
+
try {
|
|
95
|
+
return colorChannel(color);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
98
|
+
console.warn(warning);
|
|
99
|
+
}
|
|
100
|
+
return color;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
93
103
|
|
|
94
104
|
/**
|
|
95
105
|
* Converts a color object with type and values to a string.
|
|
@@ -220,6 +230,16 @@ export function alpha(color, value) {
|
|
|
220
230
|
}
|
|
221
231
|
return recomposeColor(color);
|
|
222
232
|
}
|
|
233
|
+
export function private_safeAlpha(color, value, warning) {
|
|
234
|
+
try {
|
|
235
|
+
return alpha(color, value);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
238
|
+
console.warn(warning);
|
|
239
|
+
}
|
|
240
|
+
return color;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
223
243
|
|
|
224
244
|
/**
|
|
225
245
|
* Darkens a color.
|
|
@@ -239,6 +259,16 @@ export function darken(color, coefficient) {
|
|
|
239
259
|
}
|
|
240
260
|
return recomposeColor(color);
|
|
241
261
|
}
|
|
262
|
+
export function private_safeDarken(color, coefficient, warning) {
|
|
263
|
+
try {
|
|
264
|
+
return darken(color, coefficient);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
267
|
+
console.warn(warning);
|
|
268
|
+
}
|
|
269
|
+
return color;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
242
272
|
|
|
243
273
|
/**
|
|
244
274
|
* Lightens a color.
|
|
@@ -262,6 +292,16 @@ export function lighten(color, coefficient) {
|
|
|
262
292
|
}
|
|
263
293
|
return recomposeColor(color);
|
|
264
294
|
}
|
|
295
|
+
export function private_safeLighten(color, coefficient, warning) {
|
|
296
|
+
try {
|
|
297
|
+
return lighten(color, coefficient);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
300
|
+
console.warn(warning);
|
|
301
|
+
}
|
|
302
|
+
return color;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
265
305
|
|
|
266
306
|
/**
|
|
267
307
|
* Darken or lighten a color, depending on its luminance.
|
|
@@ -272,4 +312,14 @@ export function lighten(color, coefficient) {
|
|
|
272
312
|
*/
|
|
273
313
|
export function emphasize(color, coefficient = 0.15) {
|
|
274
314
|
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
|
|
315
|
+
}
|
|
316
|
+
export function private_safeEmphasize(color, coefficient, warning) {
|
|
317
|
+
try {
|
|
318
|
+
return private_safeEmphasize(color, coefficient);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
321
|
+
console.warn(warning);
|
|
322
|
+
}
|
|
323
|
+
return color;
|
|
324
|
+
}
|
|
275
325
|
}
|
package/modern/compose.js
CHANGED
package/modern/createBox.js
CHANGED
|
@@ -4,15 +4,14 @@ const _excluded = ["className", "component"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import styled from '@mui/styled-engine';
|
|
7
|
-
import
|
|
7
|
+
import styleFunctionSx, { extendSxProp } from './styleFunctionSx';
|
|
8
8
|
import useTheme from './useTheme';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
export default function createBox(options = {}) {
|
|
11
11
|
const {
|
|
12
12
|
defaultTheme,
|
|
13
13
|
defaultClassName = 'MuiBox-root',
|
|
14
|
-
generateClassName
|
|
15
|
-
styleFunctionSx = defaultStyleFunctionSx
|
|
14
|
+
generateClassName
|
|
16
15
|
} = options;
|
|
17
16
|
const BoxRoot = styled('div', {
|
|
18
17
|
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
package/modern/createStyled.js
CHANGED
|
@@ -8,7 +8,7 @@ import styledEngineStyled, { internal_processStyles as processStyles } from '@mu
|
|
|
8
8
|
import { getDisplayName } from '@mui/utils';
|
|
9
9
|
import createTheme from './createTheme';
|
|
10
10
|
import propsToClassKey from './propsToClassKey';
|
|
11
|
-
import
|
|
11
|
+
import styleFunctionSx from './styleFunctionSx';
|
|
12
12
|
function isEmpty(obj) {
|
|
13
13
|
return Object.keys(obj).length === 0;
|
|
14
14
|
}
|
|
@@ -73,8 +73,7 @@ export default function createStyled(input = {}) {
|
|
|
73
73
|
const {
|
|
74
74
|
defaultTheme = systemDefaultTheme,
|
|
75
75
|
rootShouldForwardProp = shouldForwardProp,
|
|
76
|
-
slotShouldForwardProp = shouldForwardProp
|
|
77
|
-
styleFunctionSx = defaultStyleFunctionSx
|
|
76
|
+
slotShouldForwardProp = shouldForwardProp
|
|
78
77
|
} = input;
|
|
79
78
|
const systemSx = props => {
|
|
80
79
|
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
@@ -5,6 +5,8 @@ import { deepmerge } from '@mui/utils';
|
|
|
5
5
|
import createBreakpoints from './createBreakpoints';
|
|
6
6
|
import shape from './shape';
|
|
7
7
|
import createSpacing from './createSpacing';
|
|
8
|
+
import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
|
|
9
|
+
import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
|
|
8
10
|
function createTheme(options = {}, ...args) {
|
|
9
11
|
const {
|
|
10
12
|
breakpoints: breakpointsInput = {},
|
|
@@ -27,6 +29,13 @@ function createTheme(options = {}, ...args) {
|
|
|
27
29
|
shape: _extends({}, shape, shapeInput)
|
|
28
30
|
}, other);
|
|
29
31
|
muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
|
|
32
|
+
muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
|
|
33
|
+
muiTheme.unstable_sx = function sx(props) {
|
|
34
|
+
return styleFunctionSx({
|
|
35
|
+
sx: props,
|
|
36
|
+
theme: this
|
|
37
|
+
});
|
|
38
|
+
};
|
|
30
39
|
return muiTheme;
|
|
31
40
|
}
|
|
32
41
|
export default createTheme;
|
package/modern/cssGrid.js
CHANGED
|
@@ -3,6 +3,9 @@ import compose from './compose';
|
|
|
3
3
|
import { createUnaryUnit, getValue } from './spacing';
|
|
4
4
|
import { handleBreakpoints } from './breakpoints';
|
|
5
5
|
import responsivePropType from './responsivePropType';
|
|
6
|
+
|
|
7
|
+
// false positive
|
|
8
|
+
// eslint-disable-next-line react/function-component-definition
|
|
6
9
|
export const gap = props => {
|
|
7
10
|
if (props.gap !== undefined && props.gap !== null) {
|
|
8
11
|
const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'gap');
|
|
@@ -17,6 +20,9 @@ gap.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
|
17
20
|
gap: responsivePropType
|
|
18
21
|
} : {};
|
|
19
22
|
gap.filterProps = ['gap'];
|
|
23
|
+
|
|
24
|
+
// false positive
|
|
25
|
+
// eslint-disable-next-line react/function-component-definition
|
|
20
26
|
export const columnGap = props => {
|
|
21
27
|
if (props.columnGap !== undefined && props.columnGap !== null) {
|
|
22
28
|
const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'columnGap');
|
|
@@ -31,6 +37,9 @@ columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
|
31
37
|
columnGap: responsivePropType
|
|
32
38
|
} : {};
|
|
33
39
|
columnGap.filterProps = ['columnGap'];
|
|
40
|
+
|
|
41
|
+
// false positive
|
|
42
|
+
// eslint-disable-next-line react/function-component-definition
|
|
34
43
|
export const rowGap = props => {
|
|
35
44
|
if (props.rowGap !== undefined && props.rowGap !== null) {
|
|
36
45
|
const transformer = createUnaryUnit(props.theme, 'spacing', 8, 'rowGap');
|
|
@@ -6,6 +6,7 @@ import * as React from 'react';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { deepmerge } from '@mui/utils';
|
|
8
8
|
import { GlobalStyles } from '@mui/styled-engine';
|
|
9
|
+
import { useTheme as muiUseTheme } from '@mui/private-theming';
|
|
9
10
|
import cssVarsParser from './cssVarsParser';
|
|
10
11
|
import ThemeProvider from '../ThemeProvider';
|
|
11
12
|
import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
@@ -50,9 +51,14 @@ export default function createCssVarsProvider(options) {
|
|
|
50
51
|
documentNode = typeof document === 'undefined' ? undefined : document,
|
|
51
52
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
52
53
|
colorSchemeSelector = ':root',
|
|
53
|
-
shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar
|
|
54
|
+
shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar,
|
|
55
|
+
disableNestedContext = false,
|
|
56
|
+
disableStyleSheetGeneration = false
|
|
54
57
|
}) {
|
|
55
58
|
const hasMounted = React.useRef(false);
|
|
59
|
+
const upperTheme = muiUseTheme();
|
|
60
|
+
const ctx = React.useContext(ColorSchemeContext);
|
|
61
|
+
const nested = !!ctx && !disableNestedContext;
|
|
56
62
|
const {
|
|
57
63
|
colorSchemes = {},
|
|
58
64
|
components = {},
|
|
@@ -65,12 +71,12 @@ export default function createCssVarsProvider(options) {
|
|
|
65
71
|
|
|
66
72
|
// 1. Get the data about the `mode`, `colorScheme`, and setter functions.
|
|
67
73
|
const {
|
|
68
|
-
mode,
|
|
74
|
+
mode: stateMode,
|
|
69
75
|
setMode,
|
|
70
76
|
systemMode,
|
|
71
77
|
lightColorScheme,
|
|
72
78
|
darkColorScheme,
|
|
73
|
-
colorScheme,
|
|
79
|
+
colorScheme: stateColorScheme,
|
|
74
80
|
setColorScheme
|
|
75
81
|
} = useCurrentColorScheme({
|
|
76
82
|
supportedColorSchemes: allColorSchemes,
|
|
@@ -81,6 +87,12 @@ export default function createCssVarsProvider(options) {
|
|
|
81
87
|
defaultMode,
|
|
82
88
|
storageWindow
|
|
83
89
|
});
|
|
90
|
+
let mode = stateMode;
|
|
91
|
+
let colorScheme = stateColorScheme;
|
|
92
|
+
if (nested) {
|
|
93
|
+
mode = ctx.mode;
|
|
94
|
+
colorScheme = ctx.colorScheme;
|
|
95
|
+
}
|
|
84
96
|
const calculatedMode = (() => {
|
|
85
97
|
if (!mode) {
|
|
86
98
|
// This scope occurs on the server
|
|
@@ -217,21 +229,33 @@ export default function createCssVarsProvider(options) {
|
|
|
217
229
|
setColorScheme,
|
|
218
230
|
allColorSchemes
|
|
219
231
|
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode]);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
let shouldGenerateStyleSheet = true;
|
|
233
|
+
if (disableStyleSheetGeneration || nested && upperTheme?.cssVarPrefix === cssVarPrefix) {
|
|
234
|
+
shouldGenerateStyleSheet = false;
|
|
235
|
+
}
|
|
236
|
+
const element = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
237
|
+
children: [shouldGenerateStyleSheet && /*#__PURE__*/_jsxs(React.Fragment, {
|
|
238
|
+
children: [/*#__PURE__*/_jsx(GlobalStyles, {
|
|
239
|
+
styles: {
|
|
240
|
+
[colorSchemeSelector]: rootCss
|
|
241
|
+
}
|
|
242
|
+
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
243
|
+
styles: defaultColorSchemeStyleSheet
|
|
244
|
+
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
245
|
+
styles: otherColorSchemesStyleSheet
|
|
246
|
+
})]
|
|
230
247
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
231
248
|
theme: resolveTheme ? resolveTheme(theme) : theme,
|
|
232
249
|
children: children
|
|
233
250
|
})]
|
|
234
251
|
});
|
|
252
|
+
if (nested) {
|
|
253
|
+
return element;
|
|
254
|
+
}
|
|
255
|
+
return /*#__PURE__*/_jsx(ColorSchemeContext.Provider, {
|
|
256
|
+
value: contextValue,
|
|
257
|
+
children: element
|
|
258
|
+
});
|
|
235
259
|
}
|
|
236
260
|
process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
|
|
237
261
|
/**
|
|
@@ -262,6 +286,16 @@ export default function createCssVarsProvider(options) {
|
|
|
262
286
|
* The initial mode used.
|
|
263
287
|
*/
|
|
264
288
|
defaultMode: PropTypes.string,
|
|
289
|
+
/**
|
|
290
|
+
* If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
|
|
291
|
+
*/
|
|
292
|
+
disableNestedContext: PropTypes.bool,
|
|
293
|
+
/**
|
|
294
|
+
* If `true`, the style sheet won't be generated.
|
|
295
|
+
*
|
|
296
|
+
* This is useful for controlling nested CssVarsProvider behavior.
|
|
297
|
+
*/
|
|
298
|
+
disableStyleSheetGeneration: PropTypes.bool,
|
|
265
299
|
/**
|
|
266
300
|
* Disable CSS transitions when switching between modes or color schemes
|
|
267
301
|
*/
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.11.0
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -26,8 +26,7 @@ export * from './spacing';
|
|
|
26
26
|
export { default as style, getPath, getStyleValue } from './style';
|
|
27
27
|
export { default as typography } from './typography';
|
|
28
28
|
export * from './typography';
|
|
29
|
-
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
30
|
-
export { default as experimental_sx } from './sx';
|
|
29
|
+
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp, unstable_defaultSxConfig } from './styleFunctionSx';
|
|
31
30
|
export { default as unstable_getThemeValue } from './getThemeValue';
|
|
32
31
|
export { default as Box } from './Box';
|
|
33
32
|
export { default as createBox } from './createBox';
|
package/modern/palette.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
|
-
function
|
|
3
|
+
export function paletteTransform(value, userValue) {
|
|
4
4
|
if (userValue === 'grey') {
|
|
5
5
|
return userValue;
|
|
6
6
|
}
|
|
@@ -9,18 +9,18 @@ function transform(value, userValue) {
|
|
|
9
9
|
export const color = style({
|
|
10
10
|
prop: 'color',
|
|
11
11
|
themeKey: 'palette',
|
|
12
|
-
transform
|
|
12
|
+
transform: paletteTransform
|
|
13
13
|
});
|
|
14
14
|
export const bgcolor = style({
|
|
15
15
|
prop: 'bgcolor',
|
|
16
16
|
cssProperty: 'backgroundColor',
|
|
17
17
|
themeKey: 'palette',
|
|
18
|
-
transform
|
|
18
|
+
transform: paletteTransform
|
|
19
19
|
});
|
|
20
20
|
export const backgroundColor = style({
|
|
21
21
|
prop: 'backgroundColor',
|
|
22
22
|
themeKey: 'palette',
|
|
23
|
-
transform
|
|
23
|
+
transform: paletteTransform
|
|
24
24
|
});
|
|
25
25
|
const palette = compose(color, bgcolor, backgroundColor);
|
|
26
26
|
export default palette;
|
package/modern/sizing.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
3
|
import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
|
|
4
|
-
function
|
|
4
|
+
export function sizingTransform(value) {
|
|
5
5
|
return value <= 1 && value !== 0 ? `${value * 100}%` : value;
|
|
6
6
|
}
|
|
7
7
|
export const width = style({
|
|
8
8
|
prop: 'width',
|
|
9
|
-
transform
|
|
9
|
+
transform: sizingTransform
|
|
10
10
|
});
|
|
11
11
|
export const maxWidth = props => {
|
|
12
12
|
if (props.maxWidth !== undefined && props.maxWidth !== null) {
|
|
13
13
|
const styleFromPropValue = propValue => {
|
|
14
14
|
const breakpoint = props.theme?.breakpoints?.values?.[propValue] || breakpointsValues[propValue];
|
|
15
15
|
return {
|
|
16
|
-
maxWidth: breakpoint ||
|
|
16
|
+
maxWidth: breakpoint || sizingTransform(propValue)
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
|
|
@@ -23,29 +23,29 @@ export const maxWidth = props => {
|
|
|
23
23
|
maxWidth.filterProps = ['maxWidth'];
|
|
24
24
|
export const minWidth = style({
|
|
25
25
|
prop: 'minWidth',
|
|
26
|
-
transform
|
|
26
|
+
transform: sizingTransform
|
|
27
27
|
});
|
|
28
28
|
export const height = style({
|
|
29
29
|
prop: 'height',
|
|
30
|
-
transform
|
|
30
|
+
transform: sizingTransform
|
|
31
31
|
});
|
|
32
32
|
export const maxHeight = style({
|
|
33
33
|
prop: 'maxHeight',
|
|
34
|
-
transform
|
|
34
|
+
transform: sizingTransform
|
|
35
35
|
});
|
|
36
36
|
export const minHeight = style({
|
|
37
37
|
prop: 'minHeight',
|
|
38
|
-
transform
|
|
38
|
+
transform: sizingTransform
|
|
39
39
|
});
|
|
40
40
|
export const sizeWidth = style({
|
|
41
41
|
prop: 'size',
|
|
42
42
|
cssProperty: 'width',
|
|
43
|
-
transform
|
|
43
|
+
transform: sizingTransform
|
|
44
44
|
});
|
|
45
45
|
export const sizeHeight = style({
|
|
46
46
|
prop: 'size',
|
|
47
47
|
cssProperty: 'height',
|
|
48
|
-
transform
|
|
48
|
+
transform: sizingTransform
|
|
49
49
|
});
|
|
50
50
|
export const boxSizing = style({
|
|
51
51
|
prop: 'boxSizing'
|
package/modern/spacing.js
CHANGED
|
@@ -39,8 +39,8 @@ const getCssProperties = memoize(prop => {
|
|
|
39
39
|
const direction = directions[b] || '';
|
|
40
40
|
return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
|
|
41
41
|
});
|
|
42
|
-
const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
|
|
43
|
-
const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
42
|
+
export const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
|
|
43
|
+
export const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
44
44
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
45
45
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
46
46
|
const themeSpacing = getPath(theme, themeKey, false) ?? defaultValue;
|
package/modern/style.js
CHANGED
|
@@ -30,7 +30,7 @@ export function getStyleValue(themeMapping, transform, propValueFinal, userValue
|
|
|
30
30
|
value = getPath(themeMapping, propValueFinal) || userValue;
|
|
31
31
|
}
|
|
32
32
|
if (transform) {
|
|
33
|
-
value = transform(value, userValue);
|
|
33
|
+
value = transform(value, userValue, themeMapping);
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
@@ -41,6 +41,9 @@ function style(options) {
|
|
|
41
41
|
themeKey,
|
|
42
42
|
transform
|
|
43
43
|
} = options;
|
|
44
|
+
|
|
45
|
+
// false positive
|
|
46
|
+
// eslint-disable-next-line react/function-component-definition
|
|
44
47
|
const fn = props => {
|
|
45
48
|
if (props[prop] == null) {
|
|
46
49
|
return null;
|