@mui/system 5.4.3 → 5.5.1
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.spec.d.ts +1 -1
- package/CHANGELOG.md +214 -2
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +5 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.d.ts +25 -1
- package/cssVars/createCssVarsProvider.js +28 -13
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +70 -68
- package/cssVars/cssVarsParser.js +17 -17
- package/cssVars/getInitColorSchemeScript.d.ts +12 -12
- package/cssVars/index.d.ts +1 -1
- package/cssVars/useCurrentColorScheme.d.ts +50 -50
- package/esm/createStyled.js +5 -1
- package/esm/cssVars/createCssVarsProvider.js +28 -14
- package/esm/cssVars/cssVarsParser.js +17 -17
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/createStyled.js +5 -1
- package/legacy/cssVars/createCssVarsProvider.js +31 -16
- package/legacy/cssVars/cssVarsParser.js +23 -23
- package/legacy/index.js +1 -1
- package/modern/createStyled.js +5 -1
- package/modern/cssVars/createCssVarsProvider.js +28 -14
- package/modern/cssVars/cssVarsParser.js +17 -17
- package/modern/index.js +1 -1
- package/package.json +7 -7
- package/styleFunctionSx/styleFunctionSx.d.ts +13 -2
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -85,19 +85,20 @@ const getCssValue = (keys, value) => {
|
|
|
85
85
|
* `basePrefix`: defined by design system.
|
|
86
86
|
* `prefix`: defined by application
|
|
87
87
|
*
|
|
88
|
-
*
|
|
88
|
+
* the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
|
|
89
89
|
*
|
|
90
|
-
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme)
|
|
90
|
+
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
91
91
|
*
|
|
92
92
|
* @example
|
|
93
|
-
* const { css, vars } = parser({
|
|
93
|
+
* const { css, vars, parsedTheme } = parser({
|
|
94
94
|
* fontSize: 12,
|
|
95
95
|
* lineHeight: 1.2,
|
|
96
|
-
* palette: { primary: { 500: '
|
|
97
|
-
* })
|
|
96
|
+
* palette: { primary: { 500: 'var(--color)' } }
|
|
97
|
+
* }, { prefix: 'foo' })
|
|
98
98
|
*
|
|
99
|
-
* console.log(css) // { '--fontSize': '12px', '--lineHeight': 1.2, '--palette-primary-500': '
|
|
100
|
-
* console.log(vars) // { fontSize: '--fontSize', lineHeight: '--lineHeight', palette: { primary: { 500: 'var(--palette-primary-500)' } } }
|
|
99
|
+
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
|
|
100
|
+
* console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
101
|
+
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
|
|
101
102
|
*/
|
|
102
103
|
|
|
103
104
|
|
|
@@ -109,21 +110,17 @@ export default function cssVarsParser(theme, options) {
|
|
|
109
110
|
} = options || {};
|
|
110
111
|
const css = {};
|
|
111
112
|
const vars = {};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const parsedTheme = {};
|
|
114
|
+
walkObjectDeep(theme, (keys, value) => {
|
|
115
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
116
116
|
if (typeof value === 'string' && value.match(/var\(\s*--/)) {
|
|
117
|
-
//
|
|
117
|
+
// for CSS variable, apply prefix or remove basePrefix from the variable
|
|
118
118
|
if (!basePrefix && prefix) {
|
|
119
119
|
value = value.replace(/var\(\s*--/g, `var(--${prefix}-`);
|
|
120
120
|
} else {
|
|
121
121
|
value = prefix ? value.replace(new RegExp(`var\\(\\s*--${basePrefix}`, 'g'), `var(--${prefix}`) // removing spaces
|
|
122
122
|
: value.replace(new RegExp(`var\\(\\s*--${basePrefix}-`, 'g'), 'var(--');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
scope[keys.slice(-1)[0]] = value;
|
|
123
|
+
}
|
|
127
124
|
}
|
|
128
125
|
|
|
129
126
|
if (!shouldSkipGeneratingVar || shouldSkipGeneratingVar && !shouldSkipGeneratingVar(keys, value)) {
|
|
@@ -135,10 +132,13 @@ export default function cssVarsParser(theme, options) {
|
|
|
135
132
|
assignNestedKeys(vars, keys, `var(${cssVar})`);
|
|
136
133
|
}
|
|
137
134
|
}
|
|
135
|
+
|
|
136
|
+
assignNestedKeys(parsedTheme, keys, value);
|
|
138
137
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
|
139
138
|
);
|
|
140
139
|
return {
|
|
141
140
|
css,
|
|
142
|
-
vars
|
|
141
|
+
vars,
|
|
142
|
+
parsedTheme
|
|
143
143
|
};
|
|
144
144
|
}
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@babel/runtime": "^7.17.
|
|
47
|
-
"@mui/private-theming": "^5.4.
|
|
48
|
-
"@mui/styled-engine": "^5.4.
|
|
49
|
-
"@mui/types": "^7.1.
|
|
50
|
-
"@mui/utils": "^5.4.
|
|
46
|
+
"@babel/runtime": "^7.17.2",
|
|
47
|
+
"@mui/private-theming": "^5.4.4",
|
|
48
|
+
"@mui/styled-engine": "^5.4.4",
|
|
49
|
+
"@mui/types": "^7.1.3",
|
|
50
|
+
"@mui/utils": "^5.4.4",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
52
|
-
"csstype": "^3.0.
|
|
52
|
+
"csstype": "^3.0.11",
|
|
53
53
|
"prop-types": "^15.7.2"
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
@@ -24,6 +24,18 @@ export interface CSSSelectorObject<Theme extends object = {}> {
|
|
|
24
24
|
[cssSelector: string]: ((theme: Theme) => SystemStyleObject<Theme>) | SystemStyleObject<Theme>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
type CssVariableType = string | number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Map all nested selectors and CSS variables.
|
|
31
|
+
*/
|
|
32
|
+
export interface CSSSelectorObjectOrCssVariables<Theme extends object = {}> {
|
|
33
|
+
[cssSelectorOrVariable: string]:
|
|
34
|
+
| ((theme: Theme) => SystemStyleObject<Theme> | string | number)
|
|
35
|
+
| SystemStyleObject<Theme>
|
|
36
|
+
| CssVariableType;
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* Map of all available CSS properties (including aliases) and their raw value.
|
|
29
41
|
* Only used internally to map CSS properties to input types (responsive value,
|
|
@@ -48,8 +60,7 @@ export type SystemCssProperties<Theme extends object = {}> = {
|
|
|
48
60
|
export type SystemStyleObject<Theme extends object = {}> =
|
|
49
61
|
| SystemCssProperties<Theme>
|
|
50
62
|
| CSSPseudoSelectorProps<Theme>
|
|
51
|
-
|
|
|
52
|
-
| { [cssVariable: string]: string | number }
|
|
63
|
+
| CSSSelectorObjectOrCssVariables<Theme>
|
|
53
64
|
| null;
|
|
54
65
|
|
|
55
66
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|