@mui/system 5.15.5 → 5.15.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/CHANGELOG.md +401 -249
- package/README.md +2 -2
- package/createTheme/applyStyles.d.ts +63 -0
- package/createTheme/applyStyles.js +80 -0
- package/createTheme/createTheme.d.ts +2 -0
- package/createTheme/createTheme.js +2 -0
- package/createTheme/index.d.ts +2 -0
- package/createTheme/index.js +8 -1
- package/esm/createTheme/applyStyles.js +74 -0
- package/esm/createTheme/createTheme.js +2 -0
- package/esm/createTheme/index.js +2 -1
- package/esm/index.js +0 -2
- package/index.js +1 -2
- package/legacy/createTheme/applyStyles.js +73 -0
- package/legacy/createTheme/createTheme.js +2 -0
- package/legacy/createTheme/index.js +2 -1
- package/legacy/index.js +1 -3
- package/modern/createTheme/applyStyles.js +74 -0
- package/modern/createTheme/createTheme.js +2 -0
- package/modern/createTheme/index.js +2 -1
- package/modern/index.js +1 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# MUI
|
|
1
|
+
# MUI System
|
|
2
2
|
|
|
3
|
-
MUI
|
|
3
|
+
MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CSSObject } from '@mui/styled-engine';
|
|
2
|
+
export interface ApplyStyles<K extends string> {
|
|
3
|
+
(key: K, styles: CSSObject): CSSObject;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
7
|
+
* It works with:
|
|
8
|
+
* - [Basic theme](https://mui.com/material-ui/customization/dark-mode/)
|
|
9
|
+
* - [CSS theme variables](https://mui.com/material-ui/experimental-api/css-theme-variables/overview/)
|
|
10
|
+
* - Zero-runtime engine
|
|
11
|
+
*
|
|
12
|
+
* Tips: Use an array over object spread and place `theme.applyStyles()` last.
|
|
13
|
+
*
|
|
14
|
+
* ✅ [{ background: '#e5e5e5' }, theme.applyStyles('dark', { background: '#1c1c1c' })]
|
|
15
|
+
*
|
|
16
|
+
* 🚫 { background: '#e5e5e5', ...theme.applyStyles('dark', { background: '#1c1c1c' })}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* 1. using with `styled`:
|
|
20
|
+
* ```jsx
|
|
21
|
+
* const Component = styled('div')(({ theme }) => [
|
|
22
|
+
* { background: '#e5e5e5' },
|
|
23
|
+
* theme.applyStyles('dark', {
|
|
24
|
+
* background: '#1c1c1c',
|
|
25
|
+
* color: '#fff',
|
|
26
|
+
* }),
|
|
27
|
+
* ]);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* 2. using with `sx` prop:
|
|
32
|
+
* ```jsx
|
|
33
|
+
* <Box sx={theme => [
|
|
34
|
+
* { background: '#e5e5e5' },
|
|
35
|
+
* theme.applyStyles('dark', {
|
|
36
|
+
* background: '#1c1c1c',
|
|
37
|
+
* color: '#fff',
|
|
38
|
+
* }),
|
|
39
|
+
* ]}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* 3. theming a component:
|
|
45
|
+
* ```jsx
|
|
46
|
+
* extendTheme({
|
|
47
|
+
* components: {
|
|
48
|
+
* MuiButton: {
|
|
49
|
+
* styleOverrides: {
|
|
50
|
+
* root: ({ theme }) => [
|
|
51
|
+
* { background: '#e5e5e5' },
|
|
52
|
+
* theme.applyStyles('dark', {
|
|
53
|
+
* background: '#1c1c1c',
|
|
54
|
+
* color: '#fff',
|
|
55
|
+
* }),
|
|
56
|
+
* ],
|
|
57
|
+
* },
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* })
|
|
61
|
+
*```
|
|
62
|
+
*/
|
|
63
|
+
export default function applyStyles<K extends string>(key: K, styles: CSSObject): CSSObject;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = applyStyles;
|
|
7
|
+
/**
|
|
8
|
+
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
9
|
+
* It works with:
|
|
10
|
+
* - [Basic theme](https://mui.com/material-ui/customization/dark-mode/)
|
|
11
|
+
* - [CSS theme variables](https://mui.com/material-ui/experimental-api/css-theme-variables/overview/)
|
|
12
|
+
* - Zero-runtime engine
|
|
13
|
+
*
|
|
14
|
+
* Tips: Use an array over object spread and place `theme.applyStyles()` last.
|
|
15
|
+
*
|
|
16
|
+
* ✅ [{ background: '#e5e5e5' }, theme.applyStyles('dark', { background: '#1c1c1c' })]
|
|
17
|
+
*
|
|
18
|
+
* 🚫 { background: '#e5e5e5', ...theme.applyStyles('dark', { background: '#1c1c1c' })}
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* 1. using with `styled`:
|
|
22
|
+
* ```jsx
|
|
23
|
+
* const Component = styled('div')(({ theme }) => [
|
|
24
|
+
* { background: '#e5e5e5' },
|
|
25
|
+
* theme.applyStyles('dark', {
|
|
26
|
+
* background: '#1c1c1c',
|
|
27
|
+
* color: '#fff',
|
|
28
|
+
* }),
|
|
29
|
+
* ]);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* 2. using with `sx` prop:
|
|
34
|
+
* ```jsx
|
|
35
|
+
* <Box sx={theme => [
|
|
36
|
+
* { background: '#e5e5e5' },
|
|
37
|
+
* theme.applyStyles('dark', {
|
|
38
|
+
* background: '#1c1c1c',
|
|
39
|
+
* color: '#fff',
|
|
40
|
+
* }),
|
|
41
|
+
* ]}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* 3. theming a component:
|
|
47
|
+
* ```jsx
|
|
48
|
+
* extendTheme({
|
|
49
|
+
* components: {
|
|
50
|
+
* MuiButton: {
|
|
51
|
+
* styleOverrides: {
|
|
52
|
+
* root: ({ theme }) => [
|
|
53
|
+
* { background: '#e5e5e5' },
|
|
54
|
+
* theme.applyStyles('dark', {
|
|
55
|
+
* background: '#1c1c1c',
|
|
56
|
+
* color: '#fff',
|
|
57
|
+
* }),
|
|
58
|
+
* ],
|
|
59
|
+
* },
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* })
|
|
63
|
+
*```
|
|
64
|
+
*/
|
|
65
|
+
function applyStyles(key, styles) {
|
|
66
|
+
// @ts-expect-error this is 'any' type
|
|
67
|
+
const theme = this;
|
|
68
|
+
if (theme.vars && typeof theme.getColorSchemeSelector === 'function') {
|
|
69
|
+
// If CssVarsProvider is used as a provider,
|
|
70
|
+
// returns '* :where([data-mui-color-scheme="light|dark"]) &'
|
|
71
|
+
const selector = theme.getColorSchemeSelector(key).replace(/(\[[^\]]+\])/, '*:where($1)');
|
|
72
|
+
return {
|
|
73
|
+
[selector]: styles
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (theme.palette.mode === key) {
|
|
77
|
+
return styles;
|
|
78
|
+
}
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
@@ -3,6 +3,7 @@ import { Breakpoints, BreakpointsOptions } from './createBreakpoints';
|
|
|
3
3
|
import { Shape, ShapeOptions } from './shape';
|
|
4
4
|
import { Spacing, SpacingOptions } from './createSpacing';
|
|
5
5
|
import { SxConfig, SxProps } from '../styleFunctionSx';
|
|
6
|
+
import { ApplyStyles } from './applyStyles';
|
|
6
7
|
|
|
7
8
|
export { Breakpoint, BreakpointOverrides } from './createBreakpoints';
|
|
8
9
|
|
|
@@ -35,6 +36,7 @@ export interface Theme {
|
|
|
35
36
|
mixins?: unknown;
|
|
36
37
|
typography?: unknown;
|
|
37
38
|
zIndex?: unknown;
|
|
39
|
+
applyStyles: ApplyStyles<'light' | 'dark'>;
|
|
38
40
|
unstable_sxConfig: SxConfig;
|
|
39
41
|
unstable_sx: (props: SxProps<Theme>) => CSSObject;
|
|
40
42
|
}
|
|
@@ -13,6 +13,7 @@ var _shape = _interopRequireDefault(require("./shape"));
|
|
|
13
13
|
var _createSpacing = _interopRequireDefault(require("./createSpacing"));
|
|
14
14
|
var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx/styleFunctionSx"));
|
|
15
15
|
var _defaultSxConfig = _interopRequireDefault(require("../styleFunctionSx/defaultSxConfig"));
|
|
16
|
+
var _applyStyles = _interopRequireDefault(require("./applyStyles"));
|
|
16
17
|
const _excluded = ["breakpoints", "palette", "spacing", "shape"];
|
|
17
18
|
function createTheme(options = {}, ...args) {
|
|
18
19
|
const {
|
|
@@ -35,6 +36,7 @@ function createTheme(options = {}, ...args) {
|
|
|
35
36
|
spacing,
|
|
36
37
|
shape: (0, _extends2.default)({}, _shape.default, shapeInput)
|
|
37
38
|
}, other);
|
|
39
|
+
muiTheme.applyStyles = _applyStyles.default;
|
|
38
40
|
muiTheme = args.reduce((acc, argument) => (0, _utils.deepmerge)(acc, argument), muiTheme);
|
|
39
41
|
muiTheme.unstable_sxConfig = (0, _extends2.default)({}, _defaultSxConfig.default, other == null ? void 0 : other.unstable_sxConfig);
|
|
40
42
|
muiTheme.unstable_sx = function sx(props) {
|
package/createTheme/index.d.ts
CHANGED
package/createTheme/index.js
CHANGED
|
@@ -16,5 +16,12 @@ Object.defineProperty(exports, "private_createBreakpoints", {
|
|
|
16
16
|
return _createBreakpoints.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "unstable_applyStyles", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _applyStyles.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
var _createTheme = _interopRequireDefault(require("./createTheme"));
|
|
20
|
-
var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
|
|
26
|
+
var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
|
|
27
|
+
var _applyStyles = _interopRequireDefault(require("./applyStyles"));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
3
|
+
* It works with:
|
|
4
|
+
* - [Basic theme](https://mui.com/material-ui/customization/dark-mode/)
|
|
5
|
+
* - [CSS theme variables](https://mui.com/material-ui/experimental-api/css-theme-variables/overview/)
|
|
6
|
+
* - Zero-runtime engine
|
|
7
|
+
*
|
|
8
|
+
* Tips: Use an array over object spread and place `theme.applyStyles()` last.
|
|
9
|
+
*
|
|
10
|
+
* ✅ [{ background: '#e5e5e5' }, theme.applyStyles('dark', { background: '#1c1c1c' })]
|
|
11
|
+
*
|
|
12
|
+
* 🚫 { background: '#e5e5e5', ...theme.applyStyles('dark', { background: '#1c1c1c' })}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* 1. using with `styled`:
|
|
16
|
+
* ```jsx
|
|
17
|
+
* const Component = styled('div')(({ theme }) => [
|
|
18
|
+
* { background: '#e5e5e5' },
|
|
19
|
+
* theme.applyStyles('dark', {
|
|
20
|
+
* background: '#1c1c1c',
|
|
21
|
+
* color: '#fff',
|
|
22
|
+
* }),
|
|
23
|
+
* ]);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* 2. using with `sx` prop:
|
|
28
|
+
* ```jsx
|
|
29
|
+
* <Box sx={theme => [
|
|
30
|
+
* { background: '#e5e5e5' },
|
|
31
|
+
* theme.applyStyles('dark', {
|
|
32
|
+
* background: '#1c1c1c',
|
|
33
|
+
* color: '#fff',
|
|
34
|
+
* }),
|
|
35
|
+
* ]}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* 3. theming a component:
|
|
41
|
+
* ```jsx
|
|
42
|
+
* extendTheme({
|
|
43
|
+
* components: {
|
|
44
|
+
* MuiButton: {
|
|
45
|
+
* styleOverrides: {
|
|
46
|
+
* root: ({ theme }) => [
|
|
47
|
+
* { background: '#e5e5e5' },
|
|
48
|
+
* theme.applyStyles('dark', {
|
|
49
|
+
* background: '#1c1c1c',
|
|
50
|
+
* color: '#fff',
|
|
51
|
+
* }),
|
|
52
|
+
* ],
|
|
53
|
+
* },
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* })
|
|
57
|
+
*```
|
|
58
|
+
*/
|
|
59
|
+
export default function applyStyles(key, styles) {
|
|
60
|
+
// @ts-expect-error this is 'any' type
|
|
61
|
+
const theme = this;
|
|
62
|
+
if (theme.vars && typeof theme.getColorSchemeSelector === 'function') {
|
|
63
|
+
// If CssVarsProvider is used as a provider,
|
|
64
|
+
// returns '* :where([data-mui-color-scheme="light|dark"]) &'
|
|
65
|
+
const selector = theme.getColorSchemeSelector(key).replace(/(\[[^\]]+\])/, '*:where($1)');
|
|
66
|
+
return {
|
|
67
|
+
[selector]: styles
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (theme.palette.mode === key) {
|
|
71
|
+
return styles;
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
@@ -7,6 +7,7 @@ import shape from './shape';
|
|
|
7
7
|
import createSpacing from './createSpacing';
|
|
8
8
|
import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
|
|
9
9
|
import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
|
|
10
|
+
import applyStyles from './applyStyles';
|
|
10
11
|
function createTheme(options = {}, ...args) {
|
|
11
12
|
const {
|
|
12
13
|
breakpoints: breakpointsInput = {},
|
|
@@ -28,6 +29,7 @@ function createTheme(options = {}, ...args) {
|
|
|
28
29
|
spacing,
|
|
29
30
|
shape: _extends({}, shape, shapeInput)
|
|
30
31
|
}, other);
|
|
32
|
+
muiTheme.applyStyles = applyStyles;
|
|
31
33
|
muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
|
|
32
34
|
muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other == null ? void 0 : other.unstable_sxConfig);
|
|
33
35
|
muiTheme.unstable_sx = function sx(props) {
|
package/esm/createTheme/index.js
CHANGED
package/esm/index.js
CHANGED
package/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/system v5.15.
|
|
2
|
+
* @mui/system v5.15.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
9
|
-
'use client';
|
|
10
9
|
|
|
11
10
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
12
11
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
/**
|
|
3
|
+
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
4
|
+
* It works with:
|
|
5
|
+
* - [Basic theme](https://mui.com/material-ui/customization/dark-mode/)
|
|
6
|
+
* - [CSS theme variables](https://mui.com/material-ui/experimental-api/css-theme-variables/overview/)
|
|
7
|
+
* - Zero-runtime engine
|
|
8
|
+
*
|
|
9
|
+
* Tips: Use an array over object spread and place `theme.applyStyles()` last.
|
|
10
|
+
*
|
|
11
|
+
* ✅ [{ background: '#e5e5e5' }, theme.applyStyles('dark', { background: '#1c1c1c' })]
|
|
12
|
+
*
|
|
13
|
+
* 🚫 { background: '#e5e5e5', ...theme.applyStyles('dark', { background: '#1c1c1c' })}
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* 1. using with `styled`:
|
|
17
|
+
* ```jsx
|
|
18
|
+
* const Component = styled('div')(({ theme }) => [
|
|
19
|
+
* { background: '#e5e5e5' },
|
|
20
|
+
* theme.applyStyles('dark', {
|
|
21
|
+
* background: '#1c1c1c',
|
|
22
|
+
* color: '#fff',
|
|
23
|
+
* }),
|
|
24
|
+
* ]);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* 2. using with `sx` prop:
|
|
29
|
+
* ```jsx
|
|
30
|
+
* <Box sx={theme => [
|
|
31
|
+
* { background: '#e5e5e5' },
|
|
32
|
+
* theme.applyStyles('dark', {
|
|
33
|
+
* background: '#1c1c1c',
|
|
34
|
+
* color: '#fff',
|
|
35
|
+
* }),
|
|
36
|
+
* ]}
|
|
37
|
+
* />
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* 3. theming a component:
|
|
42
|
+
* ```jsx
|
|
43
|
+
* extendTheme({
|
|
44
|
+
* components: {
|
|
45
|
+
* MuiButton: {
|
|
46
|
+
* styleOverrides: {
|
|
47
|
+
* root: ({ theme }) => [
|
|
48
|
+
* { background: '#e5e5e5' },
|
|
49
|
+
* theme.applyStyles('dark', {
|
|
50
|
+
* background: '#1c1c1c',
|
|
51
|
+
* color: '#fff',
|
|
52
|
+
* }),
|
|
53
|
+
* ],
|
|
54
|
+
* },
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* })
|
|
58
|
+
*```
|
|
59
|
+
*/
|
|
60
|
+
export default function applyStyles(key, styles) {
|
|
61
|
+
// @ts-expect-error this is 'any' type
|
|
62
|
+
var theme = this;
|
|
63
|
+
if (theme.vars && typeof theme.getColorSchemeSelector === 'function') {
|
|
64
|
+
// If CssVarsProvider is used as a provider,
|
|
65
|
+
// returns '* :where([data-mui-color-scheme="light|dark"]) &'
|
|
66
|
+
var selector = theme.getColorSchemeSelector(key).replace(/(\[[^\]]+\])/, '*:where($1)');
|
|
67
|
+
return _defineProperty({}, selector, styles);
|
|
68
|
+
}
|
|
69
|
+
if (theme.palette.mode === key) {
|
|
70
|
+
return styles;
|
|
71
|
+
}
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
@@ -6,6 +6,7 @@ import shape from './shape';
|
|
|
6
6
|
import createSpacing from './createSpacing';
|
|
7
7
|
import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
|
|
8
8
|
import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
|
|
9
|
+
import applyStyles from './applyStyles';
|
|
9
10
|
function createTheme() {
|
|
10
11
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
12
|
var _options$breakpoints = options.breakpoints,
|
|
@@ -29,6 +30,7 @@ function createTheme() {
|
|
|
29
30
|
spacing: spacing,
|
|
30
31
|
shape: _extends({}, shape, shapeInput)
|
|
31
32
|
}, other);
|
|
33
|
+
muiTheme.applyStyles = applyStyles;
|
|
32
34
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
33
35
|
args[_key - 1] = arguments[_key];
|
|
34
36
|
}
|
package/legacy/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/system v5.15.
|
|
2
|
+
* @mui/system v5.15.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
'use client';
|
|
9
|
-
|
|
10
8
|
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
11
9
|
export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
|
|
12
10
|
export { default as GlobalStyles } from './GlobalStyles';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A universal utility to style components with multiple color modes. Always use it from the theme object.
|
|
3
|
+
* It works with:
|
|
4
|
+
* - [Basic theme](https://mui.com/material-ui/customization/dark-mode/)
|
|
5
|
+
* - [CSS theme variables](https://mui.com/material-ui/experimental-api/css-theme-variables/overview/)
|
|
6
|
+
* - Zero-runtime engine
|
|
7
|
+
*
|
|
8
|
+
* Tips: Use an array over object spread and place `theme.applyStyles()` last.
|
|
9
|
+
*
|
|
10
|
+
* ✅ [{ background: '#e5e5e5' }, theme.applyStyles('dark', { background: '#1c1c1c' })]
|
|
11
|
+
*
|
|
12
|
+
* 🚫 { background: '#e5e5e5', ...theme.applyStyles('dark', { background: '#1c1c1c' })}
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* 1. using with `styled`:
|
|
16
|
+
* ```jsx
|
|
17
|
+
* const Component = styled('div')(({ theme }) => [
|
|
18
|
+
* { background: '#e5e5e5' },
|
|
19
|
+
* theme.applyStyles('dark', {
|
|
20
|
+
* background: '#1c1c1c',
|
|
21
|
+
* color: '#fff',
|
|
22
|
+
* }),
|
|
23
|
+
* ]);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* 2. using with `sx` prop:
|
|
28
|
+
* ```jsx
|
|
29
|
+
* <Box sx={theme => [
|
|
30
|
+
* { background: '#e5e5e5' },
|
|
31
|
+
* theme.applyStyles('dark', {
|
|
32
|
+
* background: '#1c1c1c',
|
|
33
|
+
* color: '#fff',
|
|
34
|
+
* }),
|
|
35
|
+
* ]}
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* 3. theming a component:
|
|
41
|
+
* ```jsx
|
|
42
|
+
* extendTheme({
|
|
43
|
+
* components: {
|
|
44
|
+
* MuiButton: {
|
|
45
|
+
* styleOverrides: {
|
|
46
|
+
* root: ({ theme }) => [
|
|
47
|
+
* { background: '#e5e5e5' },
|
|
48
|
+
* theme.applyStyles('dark', {
|
|
49
|
+
* background: '#1c1c1c',
|
|
50
|
+
* color: '#fff',
|
|
51
|
+
* }),
|
|
52
|
+
* ],
|
|
53
|
+
* },
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* })
|
|
57
|
+
*```
|
|
58
|
+
*/
|
|
59
|
+
export default function applyStyles(key, styles) {
|
|
60
|
+
// @ts-expect-error this is 'any' type
|
|
61
|
+
const theme = this;
|
|
62
|
+
if (theme.vars && typeof theme.getColorSchemeSelector === 'function') {
|
|
63
|
+
// If CssVarsProvider is used as a provider,
|
|
64
|
+
// returns '* :where([data-mui-color-scheme="light|dark"]) &'
|
|
65
|
+
const selector = theme.getColorSchemeSelector(key).replace(/(\[[^\]]+\])/, '*:where($1)');
|
|
66
|
+
return {
|
|
67
|
+
[selector]: styles
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (theme.palette.mode === key) {
|
|
71
|
+
return styles;
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
@@ -7,6 +7,7 @@ import shape from './shape';
|
|
|
7
7
|
import createSpacing from './createSpacing';
|
|
8
8
|
import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
|
|
9
9
|
import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
|
|
10
|
+
import applyStyles from './applyStyles';
|
|
10
11
|
function createTheme(options = {}, ...args) {
|
|
11
12
|
const {
|
|
12
13
|
breakpoints: breakpointsInput = {},
|
|
@@ -28,6 +29,7 @@ function createTheme(options = {}, ...args) {
|
|
|
28
29
|
spacing,
|
|
29
30
|
shape: _extends({}, shape, shapeInput)
|
|
30
31
|
}, other);
|
|
32
|
+
muiTheme.applyStyles = applyStyles;
|
|
31
33
|
muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
|
|
32
34
|
muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
|
|
33
35
|
muiTheme.unstable_sx = function sx(props) {
|
package/modern/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/system v5.15.
|
|
2
|
+
* @mui/system v5.15.7
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
'use client';
|
|
9
|
-
|
|
10
8
|
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
11
9
|
export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
|
|
12
10
|
export { default as GlobalStyles } from './GlobalStyles';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.15.
|
|
3
|
+
"version": "5.15.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"url": "https://opencollective.com/mui-org"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.23.
|
|
29
|
+
"@babel/runtime": "^7.23.9",
|
|
30
30
|
"clsx": "^2.1.0",
|
|
31
31
|
"csstype": "^3.1.2",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
|
-
"@mui/private-theming": "^5.15.5",
|
|
34
33
|
"@mui/types": "^7.2.13",
|
|
35
|
-
"@mui/
|
|
36
|
-
"@mui/
|
|
34
|
+
"@mui/styled-engine": "^5.15.7",
|
|
35
|
+
"@mui/utils": "^5.15.7",
|
|
36
|
+
"@mui/private-theming": "^5.15.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@emotion/react": "^11.5.0",
|