@mui/system 5.11.16 → 5.12.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/CHANGELOG.md +147 -22
- 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/GlobalStyles/GlobalStyles.d.ts +13 -0
- package/GlobalStyles/GlobalStyles.js +45 -0
- package/GlobalStyles/index.d.ts +2 -0
- package/GlobalStyles/index.js +26 -0
- package/GlobalStyles/package.json +6 -0
- package/Stack/Stack.d.ts +14 -13
- package/Stack/Stack.js +2 -1
- package/Stack/StackProps.d.ts +53 -53
- package/Stack/createStack.d.ts +21 -21
- package/Stack/index.d.ts +5 -5
- package/Stack/stackClasses.d.ts +8 -8
- package/ThemeProvider/ThemeProvider.d.ts +4 -0
- package/ThemeProvider/ThemeProvider.js +43 -17
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +185 -173
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +18 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +38 -38
- package/Unstable_Grid/gridGenerator.js +12 -12
- package/Unstable_Grid/index.d.ts +5 -5
- package/createBox.d.ts +1 -0
- package/createBox.js +2 -1
- package/createStyled.d.ts +1 -0
- package/createStyled.js +37 -24
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.d.ts +22 -7
- package/cssVars/createCssVarsProvider.js +7 -3
- package/cssVars/createCssVarsTheme.d.ts +15 -13
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +64 -64
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/index.d.ts +5 -5
- package/cssVars/prepareCssVars.d.ts +16 -14
- package/cssVars/prepareCssVars.js +6 -2
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/GlobalStyles/GlobalStyles.js +35 -0
- package/esm/GlobalStyles/index.js +2 -0
- package/esm/Stack/Stack.js +2 -1
- package/esm/ThemeProvider/ThemeProvider.js +44 -18
- package/esm/Unstable_Grid/createGrid.js +19 -12
- package/esm/Unstable_Grid/gridGenerator.js +12 -12
- package/esm/createBox.js +2 -1
- package/esm/createStyled.js +37 -24
- package/esm/cssVars/createCssVarsProvider.js +7 -3
- package/esm/cssVars/prepareCssVars.js +6 -2
- package/esm/index.js +2 -1
- package/esm/useThemeProps/useThemeProps.js +6 -2
- package/esm/useThemeWithoutDefault.js +3 -2
- package/index.d.ts +2 -2
- package/index.js +4 -3
- package/legacy/GlobalStyles/GlobalStyles.js +35 -0
- package/legacy/GlobalStyles/index.js +2 -0
- package/legacy/Stack/Stack.js +2 -1
- package/legacy/ThemeProvider/ThemeProvider.js +44 -19
- package/legacy/Unstable_Grid/createGrid.js +19 -11
- package/legacy/Unstable_Grid/gridGenerator.js +12 -12
- package/legacy/createBox.js +3 -2
- package/legacy/createStyled.js +37 -17
- package/legacy/cssVars/createCssVarsProvider.js +18 -14
- package/legacy/cssVars/prepareCssVars.js +6 -2
- package/legacy/index.js +3 -2
- package/legacy/useThemeProps/useThemeProps.js +5 -1
- package/legacy/useThemeWithoutDefault.js +3 -2
- package/modern/GlobalStyles/GlobalStyles.js +35 -0
- package/modern/GlobalStyles/index.js +2 -0
- package/modern/Stack/Stack.js +2 -1
- package/modern/ThemeProvider/ThemeProvider.js +44 -18
- package/modern/Unstable_Grid/createGrid.js +18 -12
- package/modern/Unstable_Grid/gridGenerator.js +12 -12
- package/modern/createBox.js +2 -1
- package/modern/createStyled.js +37 -24
- package/modern/cssVars/createCssVarsProvider.js +7 -3
- package/modern/cssVars/prepareCssVars.js +6 -2
- package/modern/index.js +3 -2
- package/modern/useThemeProps/useThemeProps.js +6 -2
- package/modern/useThemeWithoutDefault.js +3 -2
- package/package.json +5 -5
- package/useThemeProps/useThemeProps.d.ts +6 -1
- package/useThemeProps/useThemeProps.js +6 -2
- package/useThemeWithoutDefault.js +5 -2
- package/Box/Box.spec.d.ts +0 -1
- package/createBox.spec.d.ts +0 -1
- package/cssVars/createCssVarsProvider.spec.d.ts +0 -1
- package/index.spec.d.ts +0 -1
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { GlobalStyles as MuiGlobalStyles } from '@mui/styled-engine';
|
|
4
|
+
import useTheme from '../useTheme';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
function GlobalStyles({
|
|
7
|
+
styles,
|
|
8
|
+
themeId,
|
|
9
|
+
defaultTheme = {}
|
|
10
|
+
}) {
|
|
11
|
+
const upperTheme = useTheme(defaultTheme);
|
|
12
|
+
const globalStyles = typeof styles === 'function' ? styles(themeId ? upperTheme[themeId] || upperTheme : upperTheme) : styles;
|
|
13
|
+
return /*#__PURE__*/_jsx(MuiGlobalStyles, {
|
|
14
|
+
styles: globalStyles
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
|
|
18
|
+
// ----------------------------- Warning --------------------------------
|
|
19
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
20
|
+
// | To update them edit TypeScript types and run "yarn proptypes" |
|
|
21
|
+
// ----------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* @ignore
|
|
24
|
+
*/
|
|
25
|
+
defaultTheme: PropTypes.object,
|
|
26
|
+
/**
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
styles: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.array, PropTypes.func, PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
|
|
30
|
+
/**
|
|
31
|
+
* @ignore
|
|
32
|
+
*/
|
|
33
|
+
themeId: PropTypes.string
|
|
34
|
+
} : void 0;
|
|
35
|
+
export default GlobalStyles;
|
package/modern/Stack/Stack.js
CHANGED
|
@@ -4,6 +4,7 @@ import createStack from './createStack';
|
|
|
4
4
|
*
|
|
5
5
|
* Demos:
|
|
6
6
|
*
|
|
7
|
+
* - [Stack (Joy UI)](https://mui.com/joy/react-stack/)
|
|
7
8
|
* - [Stack (Material UI)](https://mui.com/material-ui/react-stack/)
|
|
8
9
|
* - [Stack (MUI System)](https://mui.com/system/react-stack/)
|
|
9
10
|
*
|
|
@@ -48,7 +49,7 @@ process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ =
|
|
|
48
49
|
/**
|
|
49
50
|
* If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
|
|
50
51
|
*
|
|
51
|
-
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack
|
|
52
|
+
* While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
|
|
52
53
|
* it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
|
|
53
54
|
*
|
|
54
55
|
* To enable this flag globally, follow the theme's default props configuration.
|
|
@@ -1,37 +1,59 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { ThemeProvider as MuiThemeProvider } from '@mui/private-theming';
|
|
4
|
+
import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
|
|
4
5
|
import { exactProp } from '@mui/utils';
|
|
5
6
|
import { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';
|
|
6
|
-
import
|
|
7
|
+
import useThemeWithoutDefault from '../useThemeWithoutDefault';
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
const EMPTY_THEME = {};
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
|
|
11
|
+
return React.useMemo(() => {
|
|
12
|
+
const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
|
|
13
|
+
if (typeof localTheme === 'function') {
|
|
14
|
+
const mergedTheme = localTheme(resolvedTheme);
|
|
15
|
+
const result = themeId ? _extends({}, upperTheme, {
|
|
16
|
+
[themeId]: mergedTheme
|
|
17
|
+
}) : mergedTheme;
|
|
18
|
+
// must return a function for the private theme to NOT merge with the upper theme.
|
|
19
|
+
// see the test case "use provided theme from a callback" in ThemeProvider.test.js
|
|
20
|
+
if (isPrivate) {
|
|
21
|
+
return () => result;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
return themeId ? _extends({}, upperTheme, {
|
|
26
|
+
[themeId]: localTheme
|
|
27
|
+
}) : _extends({}, upperTheme, localTheme);
|
|
28
|
+
}, [themeId, upperTheme, localTheme, isPrivate]);
|
|
15
29
|
}
|
|
16
|
-
process.env.NODE_ENV !== "production" ? InnerThemeProvider.propTypes = {
|
|
17
|
-
/**
|
|
18
|
-
* Your component tree.
|
|
19
|
-
*/
|
|
20
|
-
children: PropTypes.node
|
|
21
|
-
} : void 0;
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* This component makes the `theme` available down the React tree.
|
|
25
33
|
* It should preferably be used at **the root of your component tree**.
|
|
34
|
+
*
|
|
35
|
+
* <ThemeProvider theme={theme}> // existing use case
|
|
36
|
+
* <ThemeProvider theme={{ id: theme }}> // theme scoping
|
|
26
37
|
*/
|
|
27
38
|
function ThemeProvider(props) {
|
|
28
39
|
const {
|
|
29
40
|
children,
|
|
30
|
-
theme: localTheme
|
|
41
|
+
theme: localTheme,
|
|
42
|
+
themeId
|
|
31
43
|
} = props;
|
|
44
|
+
const upperTheme = useThemeWithoutDefault(EMPTY_THEME);
|
|
45
|
+
const upperPrivateTheme = usePrivateTheme() || EMPTY_THEME;
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
if (upperTheme === null && typeof localTheme === 'function' || themeId && upperTheme && !upperTheme[themeId] && typeof localTheme === 'function') {
|
|
48
|
+
console.error(['MUI: You are providing a theme function prop to the ThemeProvider component:', '<ThemeProvider theme={outerTheme => outerTheme} />', '', 'However, no outer theme is present.', 'Make sure a theme is already injected higher in the React tree ' + 'or provide a theme object.'].join('\n'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
|
|
52
|
+
const privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
|
|
32
53
|
return /*#__PURE__*/_jsx(MuiThemeProvider, {
|
|
33
|
-
theme:
|
|
34
|
-
children: /*#__PURE__*/_jsx(
|
|
54
|
+
theme: privateTheme,
|
|
55
|
+
children: /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {
|
|
56
|
+
value: engineTheme,
|
|
35
57
|
children: children
|
|
36
58
|
})
|
|
37
59
|
});
|
|
@@ -48,7 +70,11 @@ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes /* remove-propty
|
|
|
48
70
|
/**
|
|
49
71
|
* A theme object. You can provide a function to extend the outer theme.
|
|
50
72
|
*/
|
|
51
|
-
theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
|
|
73
|
+
theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
|
|
74
|
+
/**
|
|
75
|
+
* The design system's unique id for getting the corresponded theme when there are multiple design systems.
|
|
76
|
+
*/
|
|
77
|
+
themeId: PropTypes.string
|
|
52
78
|
} : void 0;
|
|
53
79
|
if (process.env.NODE_ENV !== 'production') {
|
|
54
80
|
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes) : void 0;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
|
|
3
|
+
const _excluded = ["className", "children", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow", "unstable_level"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
7
|
+
import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_isMuiElement as isMuiElement } from '@mui/utils';
|
|
8
8
|
import systemStyled from '../styled';
|
|
9
9
|
import useThemePropsSystem from '../useThemeProps';
|
|
10
10
|
import useTheme from '../useTheme';
|
|
@@ -34,7 +34,6 @@ export default function createGrid(options = {}) {
|
|
|
34
34
|
useThemeProps = useThemePropsDefault,
|
|
35
35
|
componentName = 'MuiGrid'
|
|
36
36
|
} = options;
|
|
37
|
-
const NestedContext = /*#__PURE__*/React.createContext(0);
|
|
38
37
|
const OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
39
38
|
const useUtilityClasses = (ownerState, theme) => {
|
|
40
39
|
const {
|
|
@@ -54,10 +53,10 @@ export default function createGrid(options = {}) {
|
|
|
54
53
|
const theme = useTheme();
|
|
55
54
|
const themeProps = useThemeProps(inProps);
|
|
56
55
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
57
|
-
const level = React.useContext(NestedContext);
|
|
58
56
|
const overflow = React.useContext(OverflowContext);
|
|
59
57
|
const {
|
|
60
58
|
className,
|
|
59
|
+
children,
|
|
61
60
|
columns: columnsProp = 12,
|
|
62
61
|
container = false,
|
|
63
62
|
component = 'div',
|
|
@@ -66,7 +65,8 @@ export default function createGrid(options = {}) {
|
|
|
66
65
|
spacing: spacingProp = 0,
|
|
67
66
|
rowSpacing: rowSpacingProp = spacingProp,
|
|
68
67
|
columnSpacing: columnSpacingProp = spacingProp,
|
|
69
|
-
disableEqualOverflow: themeDisableEqualOverflow
|
|
68
|
+
disableEqualOverflow: themeDisableEqualOverflow,
|
|
69
|
+
unstable_level: level = 0
|
|
70
70
|
} = props,
|
|
71
71
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
72
72
|
// Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
@@ -113,13 +113,16 @@ export default function createGrid(options = {}) {
|
|
|
113
113
|
as: component,
|
|
114
114
|
ownerState: ownerState,
|
|
115
115
|
className: clsx(classes.root, className)
|
|
116
|
-
}, other
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
}, other, {
|
|
117
|
+
children: React.Children.map(children, child => {
|
|
118
|
+
if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
|
|
119
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
120
|
+
unstable_level: child.props.unstable_level ?? level + 1
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return child;
|
|
124
|
+
})
|
|
125
|
+
}));
|
|
123
126
|
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow ?? false)) {
|
|
124
127
|
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
125
128
|
// 1. It is the root grid with `disableEqualOverflow`.
|
|
@@ -155,5 +158,8 @@ export default function createGrid(options = {}) {
|
|
|
155
158
|
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
156
159
|
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
157
160
|
} : void 0;
|
|
161
|
+
|
|
162
|
+
// @ts-ignore internal logic for nested grid
|
|
163
|
+
Grid.muiName = 'Grid';
|
|
158
164
|
return Grid;
|
|
159
165
|
}
|
|
@@ -6,26 +6,26 @@ function appendLevel(level) {
|
|
|
6
6
|
return `Level${level}`;
|
|
7
7
|
}
|
|
8
8
|
function isNestedContainer(ownerState) {
|
|
9
|
-
return ownerState.
|
|
9
|
+
return ownerState.unstable_level > 0 && ownerState.container;
|
|
10
10
|
}
|
|
11
11
|
function createGetSelfSpacing(ownerState) {
|
|
12
12
|
return function getSelfSpacing(axis) {
|
|
13
|
-
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.
|
|
13
|
+
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level)})`;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function createGetParentSpacing(ownerState) {
|
|
17
17
|
return function getParentSpacing(axis) {
|
|
18
|
-
if (ownerState.
|
|
18
|
+
if (ownerState.unstable_level === 0) {
|
|
19
19
|
return `var(--Grid-${axis}Spacing)`;
|
|
20
20
|
}
|
|
21
|
-
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.
|
|
21
|
+
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level - 1)})`;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
function getParentColumns(ownerState) {
|
|
25
|
-
if (ownerState.
|
|
25
|
+
if (ownerState.unstable_level === 0) {
|
|
26
26
|
return `var(--Grid-columns)`;
|
|
27
27
|
}
|
|
28
|
-
return `var(--Grid-columns${appendLevel(ownerState.
|
|
28
|
+
return `var(--Grid-columns${appendLevel(ownerState.unstable_level - 1)})`;
|
|
29
29
|
}
|
|
30
30
|
export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
|
|
31
31
|
export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
|
|
@@ -133,13 +133,13 @@ export const generateGridColumnsStyles = ({
|
|
|
133
133
|
return {};
|
|
134
134
|
}
|
|
135
135
|
const styles = isNestedContainer(ownerState) ? {
|
|
136
|
-
[`--Grid-columns${appendLevel(ownerState.
|
|
136
|
+
[`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: getParentColumns(ownerState)
|
|
137
137
|
} : {
|
|
138
138
|
'--Grid-columns': 12
|
|
139
139
|
};
|
|
140
140
|
traverseBreakpoints(theme.breakpoints, ownerState.columns, (appendStyle, value) => {
|
|
141
141
|
appendStyle(styles, {
|
|
142
|
-
[`--Grid-columns${appendLevel(ownerState.
|
|
142
|
+
[`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: value
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
return styles;
|
|
@@ -155,11 +155,11 @@ export const generateGridRowSpacingStyles = ({
|
|
|
155
155
|
const styles = isNestedContainer(ownerState) ? {
|
|
156
156
|
// Set the default spacing as its parent spacing.
|
|
157
157
|
// It will be overridden if spacing props are provided
|
|
158
|
-
[`--Grid-rowSpacing${appendLevel(ownerState.
|
|
158
|
+
[`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('row')
|
|
159
159
|
} : {};
|
|
160
160
|
traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
|
|
161
161
|
appendStyle(styles, {
|
|
162
|
-
[`--Grid-rowSpacing${appendLevel(ownerState.
|
|
162
|
+
[`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : theme.spacing?.(value)
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
return styles;
|
|
@@ -175,11 +175,11 @@ export const generateGridColumnSpacingStyles = ({
|
|
|
175
175
|
const styles = isNestedContainer(ownerState) ? {
|
|
176
176
|
// Set the default spacing as its parent spacing.
|
|
177
177
|
// It will be overridden if spacing props are provided
|
|
178
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
178
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('column')
|
|
179
179
|
} : {};
|
|
180
180
|
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
|
|
181
181
|
appendStyle(styles, {
|
|
182
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
182
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : theme.spacing?.(value)
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
return styles;
|
package/modern/createBox.js
CHANGED
|
@@ -9,6 +9,7 @@ import useTheme from './useTheme';
|
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
export default function createBox(options = {}) {
|
|
11
11
|
const {
|
|
12
|
+
themeId,
|
|
12
13
|
defaultTheme,
|
|
13
14
|
defaultClassName = 'MuiBox-root',
|
|
14
15
|
generateClassName
|
|
@@ -28,7 +29,7 @@ export default function createBox(options = {}) {
|
|
|
28
29
|
as: component,
|
|
29
30
|
ref: ref,
|
|
30
31
|
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
31
|
-
theme: theme
|
|
32
|
+
theme: themeId ? theme[themeId] || theme : theme
|
|
32
33
|
}, other));
|
|
33
34
|
});
|
|
34
35
|
return Box;
|
package/modern/createStyled.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]
|
|
4
|
-
_excluded2 = ["theme"],
|
|
5
|
-
_excluded3 = ["theme"];
|
|
3
|
+
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
6
4
|
/* eslint-disable no-underscore-dangle */
|
|
7
5
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
8
6
|
import { getDisplayName } from '@mui/utils';
|
|
@@ -69,16 +67,26 @@ export const systemDefaultTheme = createTheme();
|
|
|
69
67
|
const lowercaseFirstLetter = string => {
|
|
70
68
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
71
69
|
};
|
|
70
|
+
function resolveTheme({
|
|
71
|
+
defaultTheme,
|
|
72
|
+
theme,
|
|
73
|
+
themeId
|
|
74
|
+
}) {
|
|
75
|
+
return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
|
|
76
|
+
}
|
|
72
77
|
export default function createStyled(input = {}) {
|
|
73
78
|
const {
|
|
79
|
+
themeId,
|
|
74
80
|
defaultTheme = systemDefaultTheme,
|
|
75
81
|
rootShouldForwardProp = shouldForwardProp,
|
|
76
82
|
slotShouldForwardProp = shouldForwardProp
|
|
77
83
|
} = input;
|
|
78
84
|
const systemSx = props => {
|
|
79
|
-
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
80
85
|
return styleFunctionSx(_extends({}, props, {
|
|
81
|
-
theme
|
|
86
|
+
theme: resolveTheme(_extends({}, props, {
|
|
87
|
+
defaultTheme,
|
|
88
|
+
themeId
|
|
89
|
+
}))
|
|
82
90
|
}));
|
|
83
91
|
};
|
|
84
92
|
systemSx.__mui_systemSx = true;
|
|
@@ -122,20 +130,22 @@ export default function createStyled(input = {}) {
|
|
|
122
130
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
123
131
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
124
132
|
// which are basically components used as a selectors.
|
|
125
|
-
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ?
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, other));
|
|
133
|
+
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
|
|
134
|
+
return stylesArg(_extends({}, props, {
|
|
135
|
+
theme: resolveTheme(_extends({}, props, {
|
|
136
|
+
defaultTheme,
|
|
137
|
+
themeId
|
|
138
|
+
}))
|
|
139
|
+
}));
|
|
133
140
|
} : stylesArg;
|
|
134
141
|
}) : [];
|
|
135
142
|
let transformedStyleArg = styleArg;
|
|
136
143
|
if (componentName && overridesResolver) {
|
|
137
144
|
expressionsWithDefaultTheme.push(props => {
|
|
138
|
-
const theme =
|
|
145
|
+
const theme = resolveTheme(_extends({}, props, {
|
|
146
|
+
defaultTheme,
|
|
147
|
+
themeId
|
|
148
|
+
}));
|
|
139
149
|
const styleOverrides = getStyleOverrides(componentName, theme);
|
|
140
150
|
if (styleOverrides) {
|
|
141
151
|
const resolvedStyleOverrides = {};
|
|
@@ -151,7 +161,10 @@ export default function createStyled(input = {}) {
|
|
|
151
161
|
}
|
|
152
162
|
if (componentName && !skipVariantsResolver) {
|
|
153
163
|
expressionsWithDefaultTheme.push(props => {
|
|
154
|
-
const theme =
|
|
164
|
+
const theme = resolveTheme(_extends({}, props, {
|
|
165
|
+
defaultTheme,
|
|
166
|
+
themeId
|
|
167
|
+
}));
|
|
155
168
|
return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
156
169
|
});
|
|
157
170
|
}
|
|
@@ -170,15 +183,12 @@ export default function createStyled(input = {}) {
|
|
|
170
183
|
// which are basically components used as a selectors.
|
|
171
184
|
styleArg.__emotion_real !== styleArg) {
|
|
172
185
|
// If the type is function, we need to define the default theme.
|
|
173
|
-
transformedStyleArg =
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
theme: isEmpty(themeInput) ? defaultTheme : themeInput
|
|
180
|
-
}, other));
|
|
181
|
-
};
|
|
186
|
+
transformedStyleArg = props => styleArg(_extends({}, props, {
|
|
187
|
+
theme: resolveTheme(_extends({}, props, {
|
|
188
|
+
defaultTheme,
|
|
189
|
+
themeId
|
|
190
|
+
}))
|
|
191
|
+
}));
|
|
182
192
|
}
|
|
183
193
|
const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
184
194
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -191,6 +201,9 @@ export default function createStyled(input = {}) {
|
|
|
191
201
|
}
|
|
192
202
|
Component.displayName = displayName;
|
|
193
203
|
}
|
|
204
|
+
if (tag.muiName) {
|
|
205
|
+
Component.muiName = tag.muiName;
|
|
206
|
+
}
|
|
194
207
|
return Component;
|
|
195
208
|
};
|
|
196
209
|
if (defaultStyledResolver.withConfig) {
|
|
@@ -15,6 +15,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
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}';
|
|
16
16
|
export default function createCssVarsProvider(options) {
|
|
17
17
|
const {
|
|
18
|
+
themeId,
|
|
18
19
|
theme: defaultTheme = {},
|
|
19
20
|
attribute: defaultAttribute = DEFAULT_ATTRIBUTE,
|
|
20
21
|
modeStorageKey: defaultModeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
@@ -56,7 +57,9 @@ export default function createCssVarsProvider(options) {
|
|
|
56
57
|
const upperTheme = muiUseTheme();
|
|
57
58
|
const ctx = React.useContext(ColorSchemeContext);
|
|
58
59
|
const nested = !!ctx && !disableNestedContext;
|
|
59
|
-
const
|
|
60
|
+
const scopedTheme = themeProp[themeId];
|
|
61
|
+
const _ref = scopedTheme || themeProp,
|
|
62
|
+
{
|
|
60
63
|
colorSchemes = {},
|
|
61
64
|
components = {},
|
|
62
65
|
generateCssVars = () => ({
|
|
@@ -64,8 +67,8 @@ export default function createCssVarsProvider(options) {
|
|
|
64
67
|
css: {}
|
|
65
68
|
}),
|
|
66
69
|
cssVarPrefix
|
|
67
|
-
} =
|
|
68
|
-
restThemeProp = _objectWithoutPropertiesLoose(
|
|
70
|
+
} = _ref,
|
|
71
|
+
restThemeProp = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
69
72
|
const allColorSchemes = Object.keys(colorSchemes);
|
|
70
73
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
71
74
|
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
@@ -241,6 +244,7 @@ export default function createCssVarsProvider(options) {
|
|
|
241
244
|
styles: otherColorSchemesStyleSheet
|
|
242
245
|
})]
|
|
243
246
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
247
|
+
themeId: scopedTheme ? themeId : undefined,
|
|
244
248
|
theme: resolveTheme ? resolveTheme(theme) : theme,
|
|
245
249
|
children: children
|
|
246
250
|
})]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
3
|
const _excluded = ["colorSchemes", "components"],
|
|
3
4
|
_excluded2 = ["light"];
|
|
@@ -48,11 +49,14 @@ function prepareCssVars(theme, parserConfig) {
|
|
|
48
49
|
const generateCssVars = colorScheme => {
|
|
49
50
|
if (!colorScheme) {
|
|
50
51
|
return {
|
|
51
|
-
css: rootCss,
|
|
52
|
+
css: _extends({}, rootCss),
|
|
52
53
|
vars: rootVars
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
return
|
|
56
|
+
return {
|
|
57
|
+
css: _extends({}, colorSchemesMap[colorScheme].css),
|
|
58
|
+
vars: colorSchemesMap[colorScheme].vars
|
|
59
|
+
};
|
|
56
60
|
};
|
|
57
61
|
return {
|
|
58
62
|
vars: themeVars,
|
package/modern/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/system v5.
|
|
2
|
+
* @mui/system v5.12.1
|
|
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
|
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
9
|
-
export { css, keyframes,
|
|
9
|
+
export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
|
|
10
|
+
export { default as GlobalStyles } from './GlobalStyles';
|
|
10
11
|
export { default as borders } from './borders';
|
|
11
12
|
export * from './borders';
|
|
12
13
|
export { default as breakpoints } from './breakpoints';
|
|
@@ -3,9 +3,13 @@ import useTheme from '../useTheme';
|
|
|
3
3
|
export default function useThemeProps({
|
|
4
4
|
props,
|
|
5
5
|
name,
|
|
6
|
-
defaultTheme
|
|
6
|
+
defaultTheme,
|
|
7
|
+
themeId
|
|
7
8
|
}) {
|
|
8
|
-
|
|
9
|
+
let theme = useTheme(defaultTheme);
|
|
10
|
+
if (themeId) {
|
|
11
|
+
theme = theme[themeId] || theme;
|
|
12
|
+
}
|
|
9
13
|
const mergedProps = getThemeProps({
|
|
10
14
|
theme,
|
|
11
15
|
name,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ThemeContext } from '@mui/styled-engine';
|
|
2
3
|
function isObjectEmpty(obj) {
|
|
3
4
|
return Object.keys(obj).length === 0;
|
|
4
5
|
}
|
|
5
6
|
function useTheme(defaultTheme = null) {
|
|
6
|
-
const contextTheme =
|
|
7
|
+
const contextTheme = React.useContext(ThemeContext);
|
|
7
8
|
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
|
|
8
9
|
}
|
|
9
10
|
export default useTheme;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.21.0",
|
|
47
|
-
"@mui/private-theming": "^5.
|
|
48
|
-
"@mui/styled-engine": "^5.
|
|
49
|
-
"@mui/types": "^7.2.
|
|
50
|
-
"@mui/utils": "^5.
|
|
47
|
+
"@mui/private-theming": "^5.12.0",
|
|
48
|
+
"@mui/styled-engine": "^5.12.0",
|
|
49
|
+
"@mui/types": "^7.2.4",
|
|
50
|
+
"@mui/utils": "^5.12.0",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.2",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
@@ -12,4 +12,9 @@ export default function useThemeProps<
|
|
|
12
12
|
Theme extends ThemeWithProps,
|
|
13
13
|
Props,
|
|
14
14
|
Name extends keyof any,
|
|
15
|
-
>(params: {
|
|
15
|
+
>(params: {
|
|
16
|
+
props: Props;
|
|
17
|
+
name: Name;
|
|
18
|
+
defaultTheme?: Theme;
|
|
19
|
+
themeId?: string;
|
|
20
|
+
}): Props & ThemedProps<Theme, Name>;
|
|
@@ -10,9 +10,13 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
10
10
|
function useThemeProps({
|
|
11
11
|
props,
|
|
12
12
|
name,
|
|
13
|
-
defaultTheme
|
|
13
|
+
defaultTheme,
|
|
14
|
+
themeId
|
|
14
15
|
}) {
|
|
15
|
-
|
|
16
|
+
let theme = (0, _useTheme.default)(defaultTheme);
|
|
17
|
+
if (themeId) {
|
|
18
|
+
theme = theme[themeId] || theme;
|
|
19
|
+
}
|
|
16
20
|
const mergedProps = (0, _getThemeProps.default)({
|
|
17
21
|
theme,
|
|
18
22
|
name,
|
|
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _styledEngine = require("@mui/styled-engine");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
8
11
|
function isObjectEmpty(obj) {
|
|
9
12
|
return Object.keys(obj).length === 0;
|
|
10
13
|
}
|
|
11
14
|
function useTheme(defaultTheme = null) {
|
|
12
|
-
const contextTheme = (
|
|
15
|
+
const contextTheme = React.useContext(_styledEngine.ThemeContext);
|
|
13
16
|
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
|
|
14
17
|
}
|
|
15
18
|
var _default = useTheme;
|
package/Box/Box.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/createBox.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/index.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|