@mui/system 5.2.8 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Box/Box.d.ts +2 -1
- package/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +373 -28
- package/ThemeProvider/ThemeProvider.d.ts +1 -1
- package/createBox.d.ts +2 -0
- package/createBox.js +3 -2
- package/createBox.spec.d.ts +1 -1
- package/createStyled.d.ts +2 -1
- package/createStyled.js +16 -6
- package/createTheme/createBreakpoints.js +21 -6
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.d.ts +7 -0
- package/cssVars/createCssVarsProvider.js +4 -2
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/createGetCssVar.js +7 -1
- package/cssVars/cssVarsParser.d.ts +68 -68
- package/cssVars/cssVarsParser.js +4 -3
- package/cssVars/getInitColorSchemeScript.d.ts +12 -12
- package/cssVars/index.d.ts +2 -2
- package/cssVars/useCurrentColorScheme.d.ts +50 -50
- package/esm/createBox.js +3 -2
- package/esm/createStyled.js +14 -4
- package/esm/createTheme/createBreakpoints.js +20 -4
- package/esm/cssVars/createCssVarsProvider.js +4 -2
- package/esm/cssVars/createGetCssVar.js +7 -1
- package/esm/cssVars/cssVarsParser.js +4 -3
- package/esm/getThemeValue.js +1 -1
- package/esm/index.js +1 -1
- package/esm/styleFunctionSx/index.js +1 -0
- package/esm/styleFunctionSx/styleFunctionSx.js +78 -51
- package/esm/typography.js +4 -1
- package/getThemeValue.js +2 -1
- package/index.d.ts +2 -0
- package/index.js +8 -1
- package/index.spec.d.ts +1 -1
- package/legacy/createBox.js +4 -2
- package/legacy/createStyled.js +23 -7
- package/legacy/createTheme/createBreakpoints.js +23 -4
- package/legacy/cssVars/createCssVarsProvider.js +4 -2
- package/legacy/cssVars/createGetCssVar.js +7 -1
- package/legacy/cssVars/cssVarsParser.js +4 -3
- package/legacy/getThemeValue.js +1 -1
- package/legacy/index.js +2 -2
- package/legacy/styleFunctionSx/index.js +1 -0
- package/legacy/styleFunctionSx/styleFunctionSx.js +76 -51
- package/legacy/typography.js +4 -1
- package/modern/createBox.js +3 -2
- package/modern/createStyled.js +14 -4
- package/modern/createTheme/createBreakpoints.js +20 -4
- package/modern/cssVars/createCssVarsProvider.js +4 -2
- package/modern/cssVars/createGetCssVar.js +7 -1
- package/modern/cssVars/cssVarsParser.js +4 -3
- package/modern/getThemeValue.js +1 -1
- package/modern/index.js +2 -2
- package/modern/styleFunctionSx/index.js +1 -0
- package/modern/styleFunctionSx/styleFunctionSx.js +78 -51
- package/modern/typography.js +4 -1
- package/package.json +9 -9
- package/style.d.ts +1 -1
- package/styleFunctionSx/index.js +12 -2
- package/styleFunctionSx/styleFunctionSx.d.ts +12 -1
- package/styleFunctionSx/styleFunctionSx.js +79 -54
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
- package/typography.js +6 -2
|
@@ -28,7 +28,8 @@ export default function createCssVarsProvider(options) {
|
|
|
28
28
|
disableTransitionOnChange = false,
|
|
29
29
|
enableColorScheme = true,
|
|
30
30
|
prefix: designSystemPrefix = '',
|
|
31
|
-
shouldSkipGeneratingVar
|
|
31
|
+
shouldSkipGeneratingVar,
|
|
32
|
+
resolveTheme
|
|
32
33
|
} = options;
|
|
33
34
|
const systemSpacing = createSpacing(baseTheme.spacing);
|
|
34
35
|
const systemBreakpoints = createBreakpoints((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
|
|
@@ -125,6 +126,7 @@ export default function createCssVarsProvider(options) {
|
|
|
125
126
|
mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
|
|
126
127
|
components,
|
|
127
128
|
colorSchemes,
|
|
129
|
+
prefix,
|
|
128
130
|
vars: rootVars,
|
|
129
131
|
spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
|
|
130
132
|
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
|
|
@@ -226,7 +228,7 @@ export default function createCssVarsProvider(options) {
|
|
|
226
228
|
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
227
229
|
styles: styleSheet
|
|
228
230
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
229
|
-
theme: mergedTheme,
|
|
231
|
+
theme: resolveTheme ? resolveTheme(mergedTheme) : mergedTheme,
|
|
230
232
|
children: children
|
|
231
233
|
})]
|
|
232
234
|
});
|
|
@@ -8,7 +8,13 @@ export default function createGetCssVar(prefix = '') {
|
|
|
8
8
|
return '';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const value = vars[0];
|
|
12
|
+
|
|
13
|
+
if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
|
|
14
|
+
return `, var(--${prefix ? `${prefix}-` : ''}${value}${appendVar(...vars.slice(1))})`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return `, ${value}`;
|
|
12
18
|
} // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
|
|
13
19
|
|
|
14
20
|
|
|
@@ -113,12 +113,13 @@ export default function cssVarsParser(theme, options) {
|
|
|
113
113
|
if (typeof val === 'string' || typeof val === 'number') {
|
|
114
114
|
let value = val;
|
|
115
115
|
|
|
116
|
-
if (typeof value === 'string' && value.
|
|
116
|
+
if (typeof value === 'string' && value.match(/var\(\s*--/)) {
|
|
117
117
|
// replace the value of the `scope` object with the prefix or remove basePrefix from the value
|
|
118
118
|
if (!basePrefix && prefix) {
|
|
119
|
-
value = value.replace(/var\(
|
|
119
|
+
value = value.replace(/var\(\s*--/g, `var(--${prefix}-`);
|
|
120
120
|
} else {
|
|
121
|
-
value = prefix ? value.replace(new RegExp(basePrefix
|
|
121
|
+
value = prefix ? value.replace(new RegExp(`var\\(\\s*--${basePrefix}`, 'g'), `var(--${prefix}`) // removing spaces
|
|
122
|
+
: value.replace(new RegExp(`var\\(\\s*--${basePrefix}-`, 'g'), 'var(--');
|
|
122
123
|
} // scope is the deepest object in the tree, keys is the theme path keys
|
|
123
124
|
|
|
124
125
|
|
package/esm/getThemeValue.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export * from './spacing';
|
|
|
21
21
|
export { default as style, getPath } from './style';
|
|
22
22
|
export { default as typography } from './typography';
|
|
23
23
|
export * from './typography';
|
|
24
|
-
export { default as unstable_styleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
24
|
+
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
25
25
|
export { default as experimental_sx } from './sx';
|
|
26
26
|
export { default as unstable_getThemeValue } from './getThemeValue';
|
|
27
27
|
export { default as Box } from './Box';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import merge from '../merge';
|
|
2
|
-
import
|
|
2
|
+
import { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
|
|
3
3
|
import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
|
|
4
4
|
|
|
5
5
|
function objectsHaveSameKeys(...objects) {
|
|
@@ -10,70 +10,97 @@ function objectsHaveSameKeys(...objects) {
|
|
|
10
10
|
|
|
11
11
|
function callIfFn(maybeFn, arg) {
|
|
12
12
|
return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
|
|
13
|
-
}
|
|
13
|
+
} // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
14
|
|
|
15
|
-
function styleFunctionSx(props) {
|
|
16
|
-
const {
|
|
17
|
-
sx,
|
|
18
|
-
theme = {}
|
|
19
|
-
} = props || {};
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
16
|
+
export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultStyleFunctionMapping) {
|
|
17
|
+
const propToStyleFunction = Object.keys(styleFunctionMapping).reduce((acc, styleFnName) => {
|
|
18
|
+
styleFunctionMapping[styleFnName].filterProps.forEach(propName => {
|
|
19
|
+
acc[propName] = styleFunctionMapping[styleFnName];
|
|
20
|
+
});
|
|
21
|
+
return acc;
|
|
22
|
+
}, {});
|
|
29
23
|
|
|
24
|
+
function getThemeValue(prop, value, theme) {
|
|
25
|
+
const inputProps = {
|
|
26
|
+
[prop]: value,
|
|
27
|
+
theme
|
|
28
|
+
};
|
|
29
|
+
const styleFunction = propToStyleFunction[prop];
|
|
30
|
+
return styleFunction ? styleFunction(inputProps) : {
|
|
31
|
+
[prop]: value
|
|
32
|
+
};
|
|
33
|
+
}
|
|
30
34
|
|
|
31
|
-
function
|
|
32
|
-
|
|
35
|
+
function styleFunctionSx(props) {
|
|
36
|
+
const {
|
|
37
|
+
sx,
|
|
38
|
+
theme = {}
|
|
39
|
+
} = props || {};
|
|
33
40
|
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
} else if (typeof sxInput !== 'object') {
|
|
37
|
-
// value
|
|
38
|
-
return sxInput;
|
|
41
|
+
if (!sx) {
|
|
42
|
+
return null; // emotion & styled-components will neglect null
|
|
39
43
|
}
|
|
44
|
+
/*
|
|
45
|
+
* Receive `sxInput` as object or callback
|
|
46
|
+
* and then recursively check keys & values to create media query object styles.
|
|
47
|
+
* (the result will be used in `styled`)
|
|
48
|
+
*/
|
|
40
49
|
|
|
41
|
-
const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
|
42
|
-
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
43
|
-
let css = emptyBreakpoints;
|
|
44
|
-
Object.keys(sxObject).forEach(styleKey => {
|
|
45
|
-
const value = callIfFn(sxObject[styleKey], theme);
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
function traverse(sxInput) {
|
|
52
|
+
let sxObject = sxInput;
|
|
53
|
+
|
|
54
|
+
if (typeof sxInput === 'function') {
|
|
55
|
+
sxObject = sxInput(theme);
|
|
56
|
+
} else if (typeof sxInput !== 'object') {
|
|
57
|
+
// value
|
|
58
|
+
return sxInput;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!sxObject) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
|
66
|
+
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
67
|
+
let css = emptyBreakpoints;
|
|
68
|
+
Object.keys(sxObject).forEach(styleKey => {
|
|
69
|
+
const value = callIfFn(sxObject[styleKey], theme);
|
|
70
|
+
|
|
71
|
+
if (value !== null && value !== undefined) {
|
|
72
|
+
if (typeof value === 'object') {
|
|
73
|
+
if (propToStyleFunction[styleKey]) {
|
|
74
|
+
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
63
75
|
} else {
|
|
64
|
-
|
|
76
|
+
const breakpointsValues = handleBreakpoints({
|
|
77
|
+
theme
|
|
78
|
+
}, value, x => ({
|
|
79
|
+
[styleKey]: x
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
if (objectsHaveSameKeys(breakpointsValues, value)) {
|
|
83
|
+
css[styleKey] = styleFunctionSx({
|
|
84
|
+
sx: value,
|
|
85
|
+
theme
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
css = merge(css, breakpointsValues);
|
|
89
|
+
}
|
|
65
90
|
}
|
|
91
|
+
} else {
|
|
92
|
+
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
66
93
|
}
|
|
67
|
-
} else {
|
|
68
|
-
css = merge(css, getThemeValue(styleKey, value, theme));
|
|
69
94
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
95
|
+
});
|
|
96
|
+
return removeUnusedBreakpoints(breakpointsKeys, css);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
|
|
73
100
|
}
|
|
74
101
|
|
|
75
|
-
return
|
|
102
|
+
return styleFunctionSx;
|
|
76
103
|
}
|
|
77
|
-
|
|
104
|
+
const styleFunctionSx = unstable_createStyleFunctionSx();
|
|
78
105
|
styleFunctionSx.filterProps = ['sx'];
|
|
79
106
|
export default styleFunctionSx;
|
package/esm/typography.js
CHANGED
|
@@ -19,6 +19,9 @@ export const fontWeight = style({
|
|
|
19
19
|
export const letterSpacing = style({
|
|
20
20
|
prop: 'letterSpacing'
|
|
21
21
|
});
|
|
22
|
+
export const textTransform = style({
|
|
23
|
+
prop: 'textTransform'
|
|
24
|
+
});
|
|
22
25
|
export const lineHeight = style({
|
|
23
26
|
prop: 'lineHeight'
|
|
24
27
|
});
|
|
@@ -30,5 +33,5 @@ export const typographyVariant = style({
|
|
|
30
33
|
cssProperty: false,
|
|
31
34
|
themeKey: 'typography'
|
|
32
35
|
});
|
|
33
|
-
const typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
|
|
36
|
+
const typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform);
|
|
34
37
|
export default typography;
|
package/getThemeValue.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.propToStyleFunction = exports.default = void 0;
|
|
8
|
+
exports.styleFunctionMapping = exports.propToStyleFunction = exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _borders = _interopRequireDefault(require("./borders"));
|
|
11
11
|
|
|
@@ -51,6 +51,7 @@ const styleFunctionMapping = {
|
|
|
51
51
|
spacing: _spacing.default,
|
|
52
52
|
typography: _typography.default
|
|
53
53
|
};
|
|
54
|
+
exports.styleFunctionMapping = styleFunctionMapping;
|
|
54
55
|
const propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
|
|
55
56
|
filterPropsMapping[styleFnName].forEach(propName => {
|
|
56
57
|
acc[propName] = styleFunctionMapping[styleFnName];
|
package/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export const fontWeight: SimpleStyleFunction<'fontWeight'>;
|
|
|
88
88
|
export const letterSpacing: SimpleStyleFunction<'letterSpacing'>;
|
|
89
89
|
export const lineHeight: SimpleStyleFunction<'lineHeight'>;
|
|
90
90
|
export const textAlign: SimpleStyleFunction<'textAlign'>;
|
|
91
|
+
export const textTransform: SimpleStyleFunction<'textTransform'>;
|
|
91
92
|
export type TypographyProps = PropsFor<typeof typography>;
|
|
92
93
|
|
|
93
94
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -117,6 +118,7 @@ export * from './spacing';
|
|
|
117
118
|
|
|
118
119
|
export {
|
|
119
120
|
default as unstable_styleFunctionSx,
|
|
121
|
+
unstable_createStyleFunctionSx,
|
|
120
122
|
extendSxProp as unstable_extendSxProp,
|
|
121
123
|
} from './styleFunctionSx';
|
|
122
124
|
export * from './styleFunctionSx';
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.2
|
|
1
|
+
/** @license MUI v5.4.2
|
|
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.
|
|
@@ -33,6 +33,7 @@ var _exportNames = {
|
|
|
33
33
|
getPath: true,
|
|
34
34
|
typography: true,
|
|
35
35
|
unstable_styleFunctionSx: true,
|
|
36
|
+
unstable_createStyleFunctionSx: true,
|
|
36
37
|
unstable_extendSxProp: true,
|
|
37
38
|
experimental_sx: true,
|
|
38
39
|
unstable_getThemeValue: true,
|
|
@@ -250,6 +251,12 @@ Object.defineProperty(exports, "unstable_createGetCssVar", {
|
|
|
250
251
|
return _createGetCssVar.default;
|
|
251
252
|
}
|
|
252
253
|
});
|
|
254
|
+
Object.defineProperty(exports, "unstable_createStyleFunctionSx", {
|
|
255
|
+
enumerable: true,
|
|
256
|
+
get: function () {
|
|
257
|
+
return _styleFunctionSx.unstable_createStyleFunctionSx;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
253
260
|
Object.defineProperty(exports, "unstable_extendSxProp", {
|
|
254
261
|
enumerable: true,
|
|
255
262
|
get: function () {
|
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/legacy/createBox.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import styled from '@mui/styled-engine';
|
|
7
|
-
import
|
|
7
|
+
import defaultStyleFunctionSx, { 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() {
|
|
@@ -12,7 +12,9 @@ export default function createBox() {
|
|
|
12
12
|
var defaultTheme = options.defaultTheme,
|
|
13
13
|
_options$defaultClass = options.defaultClassName,
|
|
14
14
|
defaultClassName = _options$defaultClass === void 0 ? 'MuiBox-root' : _options$defaultClass,
|
|
15
|
-
generateClassName = options.generateClassName
|
|
15
|
+
generateClassName = options.generateClassName,
|
|
16
|
+
_options$styleFunctio = options.styleFunctionSx,
|
|
17
|
+
styleFunctionSx = _options$styleFunctio === void 0 ? defaultStyleFunctionSx : _options$styleFunctio;
|
|
16
18
|
var BoxRoot = styled('div')(styleFunctionSx);
|
|
17
19
|
var Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
18
20
|
var theme = useTheme(defaultTheme);
|
package/legacy/createStyled.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
5
|
import styledEngineStyled from '@mui/styled-engine';
|
|
5
6
|
import { getDisplayName } from '@mui/utils';
|
|
6
7
|
import createTheme from './createTheme';
|
|
7
|
-
import styleFunctionSx from './styleFunctionSx';
|
|
8
8
|
import propsToClassKey from './propsToClassKey';
|
|
9
|
+
import defaultStyleFunctionSx from './styleFunctionSx';
|
|
9
10
|
|
|
10
11
|
function isEmpty(obj) {
|
|
11
12
|
return Object.keys(obj).length === 0;
|
|
@@ -58,7 +59,8 @@ var variantsResolver = function variantsResolver(props, styles, theme, name) {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
return variantsStyles;
|
|
61
|
-
};
|
|
62
|
+
}; // Update /system/styled/#api in case if this changes
|
|
63
|
+
|
|
62
64
|
|
|
63
65
|
export function shouldForwardProp(prop) {
|
|
64
66
|
return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
|
@@ -76,7 +78,9 @@ export default function createStyled() {
|
|
|
76
78
|
_input$rootShouldForw = input.rootShouldForwardProp,
|
|
77
79
|
rootShouldForwardProp = _input$rootShouldForw === void 0 ? shouldForwardProp : _input$rootShouldForw,
|
|
78
80
|
_input$slotShouldForw = input.slotShouldForwardProp,
|
|
79
|
-
slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw
|
|
81
|
+
slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw,
|
|
82
|
+
_input$styleFunctionS = input.styleFunctionSx,
|
|
83
|
+
styleFunctionSx = _input$styleFunctionS === void 0 ? defaultStyleFunctionSx : _input$styleFunctionS;
|
|
80
84
|
return function (tag) {
|
|
81
85
|
var inputOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
82
86
|
|
|
@@ -139,7 +143,15 @@ export default function createStyled() {
|
|
|
139
143
|
var styleOverrides = getStyleOverrides(componentName, theme);
|
|
140
144
|
|
|
141
145
|
if (styleOverrides) {
|
|
142
|
-
|
|
146
|
+
var resolvedStyleOverrides = {};
|
|
147
|
+
Object.entries(styleOverrides).forEach(function (_ref2) {
|
|
148
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
149
|
+
slotKey = _ref3[0],
|
|
150
|
+
slotStyle = _ref3[1];
|
|
151
|
+
|
|
152
|
+
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
|
|
153
|
+
});
|
|
154
|
+
return overridesResolver(props, resolvedStyleOverrides);
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
return null;
|
|
@@ -171,9 +183,9 @@ export default function createStyled() {
|
|
|
171
183
|
transformedStyleArg.raw = [].concat(_toConsumableArray(styleArg.raw), _toConsumableArray(placeholders));
|
|
172
184
|
} else if (typeof styleArg === 'function') {
|
|
173
185
|
// If the type is function, we need to define the default theme.
|
|
174
|
-
transformedStyleArg = function transformedStyleArg(
|
|
175
|
-
var themeInput =
|
|
176
|
-
other = _objectWithoutProperties(
|
|
186
|
+
transformedStyleArg = function transformedStyleArg(_ref4) {
|
|
187
|
+
var themeInput = _ref4.theme,
|
|
188
|
+
other = _objectWithoutProperties(_ref4, ["theme"]);
|
|
177
189
|
|
|
178
190
|
return styleArg(_extends({
|
|
179
191
|
theme: isEmpty(themeInput) ? defaultTheme : themeInput
|
|
@@ -200,6 +212,10 @@ export default function createStyled() {
|
|
|
200
212
|
return Component;
|
|
201
213
|
};
|
|
202
214
|
|
|
215
|
+
if (defaultStyledResolver.withConfig) {
|
|
216
|
+
muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
|
|
217
|
+
}
|
|
218
|
+
|
|
203
219
|
return muiStyledResolver;
|
|
204
220
|
};
|
|
205
221
|
}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
// Sorted ASC by size. That's important.
|
|
4
5
|
// It can't be configured as it's used statically for propTypes.
|
|
5
|
-
export var breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
6
|
+
export var breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
7
|
+
|
|
8
|
+
var sortBreakpointsValues = function sortBreakpointsValues(values) {
|
|
9
|
+
var breakpointsAsArray = Object.keys(values).map(function (key) {
|
|
10
|
+
return {
|
|
11
|
+
key: key,
|
|
12
|
+
val: values[key]
|
|
13
|
+
};
|
|
14
|
+
}) || []; // Sort in ascending order
|
|
15
|
+
|
|
16
|
+
breakpointsAsArray.sort(function (breakpoint1, breakpoint2) {
|
|
17
|
+
return breakpoint1.val - breakpoint2.val;
|
|
18
|
+
});
|
|
19
|
+
return breakpointsAsArray.reduce(function (acc, obj) {
|
|
20
|
+
return _extends({}, acc, _defineProperty({}, obj.key, obj.val));
|
|
21
|
+
}, {});
|
|
22
|
+
}; // Keep in mind that @media is inclusive by the CSS specification.
|
|
23
|
+
|
|
6
24
|
|
|
7
25
|
export default function createBreakpoints(breakpoints) {
|
|
8
26
|
var _breakpoints$values = breakpoints.values,
|
|
@@ -24,7 +42,8 @@ export default function createBreakpoints(breakpoints) {
|
|
|
24
42
|
step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
|
|
25
43
|
other = _objectWithoutProperties(breakpoints, ["values", "unit", "step"]);
|
|
26
44
|
|
|
27
|
-
var
|
|
45
|
+
var sortedValues = sortBreakpointsValues(values);
|
|
46
|
+
var keys = Object.keys(sortedValues);
|
|
28
47
|
|
|
29
48
|
function up(key) {
|
|
30
49
|
var value = typeof values[key] === 'number' ? values[key] : key;
|
|
@@ -66,7 +85,7 @@ export default function createBreakpoints(breakpoints) {
|
|
|
66
85
|
|
|
67
86
|
return _extends({
|
|
68
87
|
keys: keys,
|
|
69
|
-
values:
|
|
88
|
+
values: sortedValues,
|
|
70
89
|
up: up,
|
|
71
90
|
down: down,
|
|
72
91
|
between: between,
|
|
@@ -31,7 +31,8 @@ export default function createCssVarsProvider(options) {
|
|
|
31
31
|
enableColorScheme = _options$enableColorS === void 0 ? true : _options$enableColorS,
|
|
32
32
|
_options$prefix = options.prefix,
|
|
33
33
|
designSystemPrefix = _options$prefix === void 0 ? '' : _options$prefix,
|
|
34
|
-
shouldSkipGeneratingVar = options.shouldSkipGeneratingVar
|
|
34
|
+
shouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
|
|
35
|
+
resolveTheme = options.resolveTheme;
|
|
35
36
|
var systemSpacing = createSpacing(baseTheme.spacing);
|
|
36
37
|
var systemBreakpoints = createBreakpoints((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
|
|
37
38
|
|
|
@@ -131,6 +132,7 @@ export default function createCssVarsProvider(options) {
|
|
|
131
132
|
mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
|
|
132
133
|
components: components,
|
|
133
134
|
colorSchemes: colorSchemes,
|
|
135
|
+
prefix: prefix,
|
|
134
136
|
vars: rootVars,
|
|
135
137
|
spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
|
|
136
138
|
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
|
|
@@ -238,7 +240,7 @@ export default function createCssVarsProvider(options) {
|
|
|
238
240
|
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
239
241
|
styles: styleSheet
|
|
240
242
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
241
|
-
theme: mergedTheme,
|
|
243
|
+
theme: resolveTheme ? resolveTheme(mergedTheme) : mergedTheme,
|
|
242
244
|
children: children
|
|
243
245
|
})]
|
|
244
246
|
});
|
|
@@ -16,7 +16,13 @@ export default function createGetCssVar() {
|
|
|
16
16
|
return '';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var value = vars[0];
|
|
20
|
+
|
|
21
|
+
if (typeof value === 'string' && !value.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))/)) {
|
|
22
|
+
return ", var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(value).concat(appendVar.apply(void 0, _toConsumableArray(vars.slice(1))), ")");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return ", ".concat(value);
|
|
20
26
|
} // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
|
|
21
27
|
|
|
22
28
|
|
|
@@ -127,12 +127,13 @@ export default function cssVarsParser(theme, options) {
|
|
|
127
127
|
if (typeof val === 'string' || typeof val === 'number') {
|
|
128
128
|
var _value = val;
|
|
129
129
|
|
|
130
|
-
if (typeof _value === 'string' && _value.
|
|
130
|
+
if (typeof _value === 'string' && _value.match(/var\(\s*--/)) {
|
|
131
131
|
// replace the value of the `scope` object with the prefix or remove basePrefix from the value
|
|
132
132
|
if (!basePrefix && prefix) {
|
|
133
|
-
_value = _value.replace(/var\(
|
|
133
|
+
_value = _value.replace(/var\(\s*--/g, "var(--".concat(prefix, "-"));
|
|
134
134
|
} else {
|
|
135
|
-
_value = prefix ? _value.replace(new RegExp(basePrefix, 'g'),
|
|
135
|
+
_value = prefix ? _value.replace(new RegExp("var\\(\\s*--".concat(basePrefix), 'g'), "var(--".concat(prefix)) // removing spaces
|
|
136
|
+
: _value.replace(new RegExp("var\\(\\s*--".concat(basePrefix, "-"), 'g'), 'var(--');
|
|
136
137
|
} // scope is the deepest object in the tree, keys is the theme path keys
|
|
137
138
|
|
|
138
139
|
|
package/legacy/getThemeValue.js
CHANGED
package/legacy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.2
|
|
1
|
+
/** @license MUI v5.4.2
|
|
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,7 +26,7 @@ export * from './spacing';
|
|
|
26
26
|
export { default as style, getPath } from './style';
|
|
27
27
|
export { default as typography } from './typography';
|
|
28
28
|
export * from './typography';
|
|
29
|
-
export { default as unstable_styleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
29
|
+
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
30
30
|
export { default as experimental_sx } from './sx';
|
|
31
31
|
export { default as unstable_getThemeValue } from './getThemeValue';
|
|
32
32
|
export { default as Box } from './Box';
|