@mui/system 5.8.6 → 5.8.7
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 +51 -0
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.d.ts +13 -18
- package/cssVars/createCssVarsProvider.js +11 -16
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/createGetCssVar.js +2 -2
- package/cssVars/cssVarsParser.d.ts +65 -70
- package/cssVars/cssVarsParser.js +4 -19
- package/cssVars/getInitColorSchemeScript.d.ts +45 -45
- package/cssVars/index.d.ts +3 -2
- package/cssVars/index.js +9 -1
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/cssVars/createCssVarsProvider.js +11 -15
- package/esm/cssVars/createGetCssVar.js +2 -2
- package/esm/cssVars/cssVarsParser.js +4 -19
- package/esm/cssVars/index.js +2 -1
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/cssVars/createCssVarsProvider.js +11 -16
- package/legacy/cssVars/createGetCssVar.js +3 -3
- package/legacy/cssVars/cssVarsParser.js +4 -20
- package/legacy/cssVars/index.js +2 -1
- package/legacy/index.js +1 -1
- package/modern/cssVars/createCssVarsProvider.js +11 -15
- package/modern/cssVars/createGetCssVar.js +2 -2
- package/modern/cssVars/cssVarsParser.js +4 -19
- package/modern/cssVars/index.js +2 -1
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
4
|
-
const _excluded = ["colorSchemes", "components"];
|
|
4
|
+
const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
@@ -10,7 +10,6 @@ import cssVarsParser from './cssVarsParser';
|
|
|
10
10
|
import ThemeProvider from '../ThemeProvider';
|
|
11
11
|
import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
12
12
|
import useCurrentColorScheme from './useCurrentColorScheme';
|
|
13
|
-
import createGetCssVar from './createGetCssVar';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
@@ -24,8 +23,7 @@ export default function createCssVarsProvider(options) {
|
|
|
24
23
|
defaultColorScheme: designSystemColorScheme,
|
|
25
24
|
disableTransitionOnChange: designSystemTransitionOnChange = false,
|
|
26
25
|
enableColorScheme: designSystemEnableColorScheme = true,
|
|
27
|
-
|
|
28
|
-
shouldSkipGeneratingVar,
|
|
26
|
+
shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
|
|
29
27
|
resolveTheme
|
|
30
28
|
} = options;
|
|
31
29
|
|
|
@@ -48,7 +46,6 @@ export default function createCssVarsProvider(options) {
|
|
|
48
46
|
function CssVarsProvider({
|
|
49
47
|
children,
|
|
50
48
|
theme: themeProp = defaultTheme,
|
|
51
|
-
prefix = designSystemPrefix,
|
|
52
49
|
modeStorageKey = defaultModeStorageKey,
|
|
53
50
|
colorSchemeStorageKey = defaultColorSchemeStorageKey,
|
|
54
51
|
attribute = defaultAttribute,
|
|
@@ -59,13 +56,15 @@ export default function createCssVarsProvider(options) {
|
|
|
59
56
|
storageWindow = typeof window === 'undefined' ? undefined : window,
|
|
60
57
|
documentNode = typeof document === 'undefined' ? undefined : document,
|
|
61
58
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
62
|
-
colorSchemeSelector = ':root'
|
|
59
|
+
colorSchemeSelector = ':root',
|
|
60
|
+
shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar
|
|
63
61
|
}) {
|
|
64
62
|
const hasMounted = React.useRef(false);
|
|
65
63
|
|
|
66
64
|
const {
|
|
67
65
|
colorSchemes = {},
|
|
68
|
-
components = {}
|
|
66
|
+
components = {},
|
|
67
|
+
cssVarPrefix
|
|
69
68
|
} = themeProp,
|
|
70
69
|
restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
|
|
71
70
|
|
|
@@ -110,16 +109,14 @@ export default function createCssVarsProvider(options) {
|
|
|
110
109
|
vars: rootVars,
|
|
111
110
|
parsedTheme
|
|
112
111
|
} = cssVarsParser(theme, {
|
|
113
|
-
prefix,
|
|
114
|
-
basePrefix: designSystemPrefix,
|
|
112
|
+
prefix: cssVarPrefix,
|
|
115
113
|
shouldSkipGeneratingVar
|
|
116
114
|
});
|
|
117
115
|
theme = _extends({}, parsedTheme, {
|
|
118
116
|
components,
|
|
119
117
|
colorSchemes,
|
|
120
|
-
|
|
118
|
+
cssVarPrefix,
|
|
121
119
|
vars: rootVars,
|
|
122
|
-
getCssVar: createGetCssVar(prefix),
|
|
123
120
|
getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
|
|
124
121
|
});
|
|
125
122
|
const defaultColorSchemeStyleSheet = {};
|
|
@@ -130,8 +127,7 @@ export default function createCssVarsProvider(options) {
|
|
|
130
127
|
vars,
|
|
131
128
|
parsedTheme: parsedScheme
|
|
132
129
|
} = cssVarsParser(scheme, {
|
|
133
|
-
prefix,
|
|
134
|
-
basePrefix: designSystemPrefix,
|
|
130
|
+
prefix: cssVarPrefix,
|
|
135
131
|
shouldSkipGeneratingVar
|
|
136
132
|
});
|
|
137
133
|
theme.vars = deepmerge(theme.vars, vars);
|
|
@@ -295,9 +291,9 @@ export default function createCssVarsProvider(options) {
|
|
|
295
291
|
modeStorageKey: PropTypes.string,
|
|
296
292
|
|
|
297
293
|
/**
|
|
298
|
-
* CSS
|
|
294
|
+
* A function to determine if the key, value should be attached as CSS Variable
|
|
299
295
|
*/
|
|
300
|
-
|
|
296
|
+
shouldSkipGeneratingVar: PropTypes.func,
|
|
301
297
|
|
|
302
298
|
/**
|
|
303
299
|
* The window that attaches the 'storage' event listener
|
|
@@ -18,8 +18,8 @@ export default function createGetCssVar(prefix = '') {
|
|
|
18
18
|
} // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
const getCssVar = (field, ...
|
|
22
|
-
return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...
|
|
21
|
+
const getCssVar = (field, ...fallbacks) => {
|
|
22
|
+
return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...fallbacks)})`;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return getCssVar;
|
|
@@ -88,13 +88,9 @@ const getCssValue = (keys, value) => {
|
|
|
88
88
|
* @param {Object} theme
|
|
89
89
|
* @param {{
|
|
90
90
|
* prefix?: string,
|
|
91
|
-
* basePrefix?: string,
|
|
92
91
|
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
93
92
|
* }} options.
|
|
94
|
-
* `
|
|
95
|
-
* `prefix`: defined by application
|
|
96
|
-
*
|
|
97
|
-
* the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
|
|
93
|
+
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
98
94
|
*
|
|
99
95
|
* @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.
|
|
100
96
|
*
|
|
@@ -105,16 +101,15 @@ const getCssValue = (keys, value) => {
|
|
|
105
101
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
106
102
|
* }, { prefix: 'foo' })
|
|
107
103
|
*
|
|
108
|
-
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--
|
|
109
|
-
* console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
110
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--
|
|
104
|
+
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
105
|
+
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
106
|
+
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
111
107
|
*/
|
|
112
108
|
|
|
113
109
|
|
|
114
110
|
export default function cssVarsParser(theme, options) {
|
|
115
111
|
const {
|
|
116
112
|
prefix,
|
|
117
|
-
basePrefix = '',
|
|
118
113
|
shouldSkipGeneratingVar
|
|
119
114
|
} = options || {};
|
|
120
115
|
const css = {};
|
|
@@ -122,16 +117,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
122
117
|
const parsedTheme = {};
|
|
123
118
|
walkObjectDeep(theme, (keys, value, arrayKeys) => {
|
|
124
119
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
125
|
-
if (typeof value === 'string' && value.match(/var\(\s*--/)) {
|
|
126
|
-
// for CSS variable, apply prefix or remove basePrefix from the variable
|
|
127
|
-
if (!basePrefix && prefix) {
|
|
128
|
-
value = value.replace(/var\(\s*--/g, `var(--${prefix}-`);
|
|
129
|
-
} else {
|
|
130
|
-
value = prefix ? value.replace(new RegExp(`var\\(\\s*--${basePrefix}`, 'g'), `var(--${prefix}`) // removing spaces
|
|
131
|
-
: value.replace(new RegExp(`var\\(\\s*--${basePrefix}-`, 'g'), 'var(--');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
120
|
if (!shouldSkipGeneratingVar || shouldSkipGeneratingVar && !shouldSkipGeneratingVar(keys, value)) {
|
|
136
121
|
// only create css & var if `shouldSkipGeneratingVar` return false
|
|
137
122
|
const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;
|
package/modern/cssVars/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from './createCssVarsProvider';
|
|
1
|
+
export { default } from './createCssVarsProvider';
|
|
2
|
+
export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.17.2",
|
|
47
47
|
"@mui/private-theming": "^5.8.6",
|
|
48
|
-
"@mui/styled-engine": "^5.8.
|
|
48
|
+
"@mui/styled-engine": "^5.8.7",
|
|
49
49
|
"@mui/types": "^7.1.4",
|
|
50
50
|
"@mui/utils": "^5.8.6",
|
|
51
|
-
"clsx": "^1.
|
|
51
|
+
"clsx": "^1.2.0",
|
|
52
52
|
"csstype": "^3.1.0",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|