@mui/system 5.0.4 → 5.0.5
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 +79 -0
- package/createStyled.d.ts +16 -190
- package/cssVars/createCssVarsProvider.d.ts +81 -0
- package/cssVars/createCssVarsProvider.js +206 -0
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -0
- package/cssVars/cssVarsParser.d.ts +57 -0
- package/cssVars/cssVarsParser.js +126 -0
- package/cssVars/getInitColorSchemeScript.d.ts +7 -0
- package/cssVars/getInitColorSchemeScript.js +38 -0
- package/cssVars/index.d.ts +2 -0
- package/cssVars/index.js +15 -0
- package/cssVars/package.json +6 -0
- package/esm/cssVars/createCssVarsProvider.js +188 -0
- package/esm/cssVars/cssVarsParser.js +112 -0
- package/esm/cssVars/getInitColorSchemeScript.js +21 -0
- package/esm/cssVars/index.js +1 -0
- package/esm/index.js +2 -1
- package/esm/styleFunctionSx/styleFunctionSx.js +6 -6
- package/index.d.ts +6 -0
- package/index.js +11 -2
- package/legacy/cssVars/createCssVarsProvider.js +202 -0
- package/legacy/cssVars/cssVarsParser.js +125 -0
- package/legacy/cssVars/getInitColorSchemeScript.js +18 -0
- package/legacy/cssVars/index.js +1 -0
- package/legacy/index.js +3 -2
- package/legacy/styleFunctionSx/styleFunctionSx.js +6 -6
- package/modern/cssVars/createCssVarsProvider.js +188 -0
- package/modern/cssVars/cssVarsParser.js +112 -0
- package/modern/cssVars/getInitColorSchemeScript.js +21 -0
- package/modern/cssVars/index.js +1 -0
- package/modern/index.js +3 -2
- package/modern/styleFunctionSx/styleFunctionSx.js +6 -6
- package/package.json +2 -3
- package/style.d.ts +1 -1
- package/styleFunctionSx/styleFunctionSx.d.ts +6 -1
- package/styleFunctionSx/styleFunctionSx.js +6 -6
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export const DEFAULT_STORAGE_KEY = 'mui-color-scheme';
|
|
4
|
+
export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
|
|
5
|
+
export default function getInitColorSchemeScript(options) {
|
|
6
|
+
const {
|
|
7
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
8
|
+
attribute = DEFAULT_ATTRIBUTE
|
|
9
|
+
} = options || {};
|
|
10
|
+
return /*#__PURE__*/_jsx("script", {
|
|
11
|
+
// eslint-disable-next-line react/no-danger
|
|
12
|
+
dangerouslySetInnerHTML: {
|
|
13
|
+
__html: `(function() { try {
|
|
14
|
+
var colorScheme = localStorage.getItem('${storageKey}');
|
|
15
|
+
if (colorScheme) {
|
|
16
|
+
document.body.setAttribute('${attribute}', colorScheme);
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {} })();`
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './createCssVarsProvider';
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.0.
|
|
1
|
+
/** @license MUI v5.0.5
|
|
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.
|
|
@@ -41,4 +41,5 @@ export { default as useThemeProps, getThemeProps } from './useThemeProps';
|
|
|
41
41
|
export { default as useTheme } from './useTheme';
|
|
42
42
|
export { default as useThemeWithoutDefault } from './useThemeWithoutDefault';
|
|
43
43
|
export * from './colorManipulator';
|
|
44
|
-
export { default as ThemeProvider } from './ThemeProvider';
|
|
44
|
+
export { default as ThemeProvider } from './ThemeProvider';
|
|
45
|
+
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
@@ -22,11 +22,11 @@ function styleFunctionSx(props) {
|
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
return styles(theme);
|
|
27
|
-
}
|
|
25
|
+
let stylesObject = styles;
|
|
28
26
|
|
|
29
|
-
if (typeof styles
|
|
27
|
+
if (typeof styles === 'function') {
|
|
28
|
+
stylesObject = styles(theme);
|
|
29
|
+
} else if (typeof styles !== 'object') {
|
|
30
30
|
// value
|
|
31
31
|
return styles;
|
|
32
32
|
}
|
|
@@ -34,8 +34,8 @@ function styleFunctionSx(props) {
|
|
|
34
34
|
const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
|
35
35
|
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
36
36
|
let css = emptyBreakpoints;
|
|
37
|
-
Object.keys(
|
|
38
|
-
const value = callIfFn(
|
|
37
|
+
Object.keys(stylesObject).forEach(styleKey => {
|
|
38
|
+
const value = callIfFn(stylesObject[styleKey], theme);
|
|
39
39
|
|
|
40
40
|
if (typeof value === 'object') {
|
|
41
41
|
if (propToStyleFunction[styleKey]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "https://opencollective.com/material-ui"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@emotion/react": "^11.
|
|
29
|
+
"@emotion/react": "^11.5.0",
|
|
30
30
|
"@emotion/styled": "^11.3.0",
|
|
31
31
|
"@types/react": "^16.8.6 || ^17.0.0",
|
|
32
32
|
"react": "^17.0.2"
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=12.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "86443310e4344ae1ce6e04f084d58e17e4d62170",
|
|
63
62
|
"module": "./esm/index.js",
|
|
64
63
|
"types": "./index.d.ts"
|
|
65
64
|
}
|
package/style.d.ts
CHANGED
|
@@ -51,7 +51,12 @@ export type SystemStyleObject<Theme extends object = {}> =
|
|
|
51
51
|
| CSSSelectorObject<Theme>
|
|
52
52
|
| null;
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The `SxProps` can be either object or function
|
|
56
|
+
*/
|
|
57
|
+
export type SxProps<Theme extends object = {}> =
|
|
58
|
+
| SystemStyleObject<Theme>
|
|
59
|
+
| ((theme: Theme) => SystemStyleObject<Theme>);
|
|
55
60
|
|
|
56
61
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
57
62
|
export default function unstable_styleFunctionSx(props: object): object;
|
|
@@ -37,11 +37,11 @@ function styleFunctionSx(props) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
return styles(theme);
|
|
42
|
-
}
|
|
40
|
+
let stylesObject = styles;
|
|
43
41
|
|
|
44
|
-
if (typeof styles
|
|
42
|
+
if (typeof styles === 'function') {
|
|
43
|
+
stylesObject = styles(theme);
|
|
44
|
+
} else if (typeof styles !== 'object') {
|
|
45
45
|
// value
|
|
46
46
|
return styles;
|
|
47
47
|
}
|
|
@@ -49,8 +49,8 @@ function styleFunctionSx(props) {
|
|
|
49
49
|
const emptyBreakpoints = (0, _breakpoints.createEmptyBreakpointObject)(theme.breakpoints);
|
|
50
50
|
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
51
51
|
let css = emptyBreakpoints;
|
|
52
|
-
Object.keys(
|
|
53
|
-
const value = callIfFn(
|
|
52
|
+
Object.keys(stylesObject).forEach(styleKey => {
|
|
53
|
+
const value = callIfFn(stylesObject[styleKey], theme);
|
|
54
54
|
|
|
55
55
|
if (typeof value === 'object') {
|
|
56
56
|
if (_getThemeValue.propToStyleFunction[styleKey]) {
|