@mui/system 5.2.3 → 5.2.8
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 +302 -32
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createBreakpoints.d.ts +6 -0
- package/createTheme/createBreakpoints.js +16 -0
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.js +9 -3
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -0
- package/cssVars/createGetCssVar.js +27 -0
- package/cssVars/cssVarsParser.d.ts +68 -68
- package/cssVars/getInitColorSchemeScript.d.ts +12 -12
- package/cssVars/index.d.ts +2 -2
- package/cssVars/useCurrentColorScheme.d.ts +50 -50
- package/esm/createTheme/createBreakpoints.js +16 -0
- package/esm/cssVars/createCssVarsProvider.js +9 -4
- package/esm/cssVars/createGetCssVar.js +20 -0
- package/esm/index.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +11 -2
- package/index.spec.d.ts +1 -1
- package/legacy/createTheme/createBreakpoints.js +16 -0
- package/legacy/cssVars/createCssVarsProvider.js +9 -4
- package/legacy/cssVars/createGetCssVar.js +32 -0
- package/legacy/index.js +3 -2
- package/modern/createTheme/createBreakpoints.js +16 -0
- package/modern/cssVars/createCssVarsProvider.js +9 -4
- package/modern/cssVars/createGetCssVar.js +20 -0
- package/modern/index.js +3 -2
- package/package.json +2 -2
- package/styleFunctionSx/styleFunctionSx.d.ts +1 -0
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -7,13 +7,14 @@ const _excluded = ["colorSchemes"],
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { GlobalStyles } from '@mui/styled-engine';
|
|
10
|
-
import { deepmerge } from '@mui/utils';
|
|
10
|
+
import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
11
11
|
import createSpacing from '../createTheme/createSpacing';
|
|
12
12
|
import createBreakpoints from '../createTheme/createBreakpoints';
|
|
13
13
|
import cssVarsParser from './cssVarsParser';
|
|
14
14
|
import ThemeProvider from '../ThemeProvider';
|
|
15
15
|
import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
16
16
|
import useCurrentColorScheme from './useCurrentColorScheme';
|
|
17
|
+
import createGetCssVar from './createGetCssVar';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
@@ -69,7 +70,7 @@ export default function createCssVarsProvider(options) {
|
|
|
69
70
|
} = themeProp,
|
|
70
71
|
restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded2);
|
|
71
72
|
|
|
72
|
-
const hasMounted = React.useRef(
|
|
73
|
+
const hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
|
|
73
74
|
|
|
74
75
|
let _deepmerge = deepmerge(restBaseTheme, restThemeProp),
|
|
75
76
|
{
|
|
@@ -124,7 +125,8 @@ export default function createCssVarsProvider(options) {
|
|
|
124
125
|
colorSchemes,
|
|
125
126
|
vars: rootVars,
|
|
126
127
|
spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
|
|
127
|
-
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints
|
|
128
|
+
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
|
|
129
|
+
getCssVar: createGetCssVar(prefix)
|
|
128
130
|
});
|
|
129
131
|
const styleSheet = {};
|
|
130
132
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
@@ -162,7 +164,7 @@ export default function createCssVarsProvider(options) {
|
|
|
162
164
|
document.documentElement.setAttribute(attribute, colorScheme);
|
|
163
165
|
}
|
|
164
166
|
}, [colorScheme, attribute]);
|
|
165
|
-
|
|
167
|
+
useEnhancedEffect(() => {
|
|
166
168
|
if (!mode || !enableColorScheme) {
|
|
167
169
|
return undefined;
|
|
168
170
|
}
|
|
@@ -201,6 +203,9 @@ export default function createCssVarsProvider(options) {
|
|
|
201
203
|
}, [colorScheme]);
|
|
202
204
|
React.useEffect(() => {
|
|
203
205
|
hasMounted.current = true;
|
|
206
|
+
return () => {
|
|
207
|
+
hasMounted.current = false;
|
|
208
|
+
};
|
|
204
209
|
}, []);
|
|
205
210
|
return /*#__PURE__*/_jsxs(ColorSchemeContext.Provider, {
|
|
206
211
|
value: {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
3
|
+
* and they does not need to remember the prefix (defined once).
|
|
4
|
+
*/
|
|
5
|
+
export default function createGetCssVar(prefix = '') {
|
|
6
|
+
function appendVar(...vars) {
|
|
7
|
+
if (!vars.length) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return `, var(--${prefix ? `${prefix}-` : ''}${vars[0]}${appendVar(...vars.slice(1))})`;
|
|
12
|
+
} // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const getCssVar = (field, ...vars) => {
|
|
16
|
+
return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...vars)})`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return getCssVar;
|
|
20
|
+
}
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.2.
|
|
1
|
+
/** @license MUI v5.2.8
|
|
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.
|
|
@@ -43,4 +43,5 @@ export { default as useTheme } from './useTheme';
|
|
|
43
43
|
export { default as useThemeWithoutDefault } from './useThemeWithoutDefault';
|
|
44
44
|
export * from './colorManipulator';
|
|
45
45
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
46
|
-
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
46
|
+
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
47
|
+
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.16.3",
|
|
47
47
|
"@mui/private-theming": "^5.2.3",
|
|
48
|
-
"@mui/styled-engine": "^5.2.
|
|
48
|
+
"@mui/styled-engine": "^5.2.6",
|
|
49
49
|
"@mui/types": "^7.1.0",
|
|
50
50
|
"@mui/utils": "^5.2.3",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|