@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
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
export interface DefaultCssVarsTheme {
|
|
2
|
-
colorSchemes: Record<string, any>;
|
|
3
|
-
}
|
|
4
|
-
declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
|
|
5
|
-
prefix?: string;
|
|
6
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
7
|
-
}): {
|
|
8
|
-
vars: ThemeVars;
|
|
9
|
-
generateCssVars: (colorScheme?: string) => {
|
|
10
|
-
css:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
export interface DefaultCssVarsTheme {
|
|
2
|
+
colorSchemes: Record<string, any>;
|
|
3
|
+
}
|
|
4
|
+
declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
7
|
+
}): {
|
|
8
|
+
vars: ThemeVars;
|
|
9
|
+
generateCssVars: (colorScheme?: string) => {
|
|
10
|
+
css: {
|
|
11
|
+
[x: string]: string | number;
|
|
12
|
+
};
|
|
13
|
+
vars: ThemeVars;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default prepareCssVars;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
10
|
var _utils = require("@mui/utils");
|
|
10
11
|
var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
|
|
@@ -55,11 +56,14 @@ function prepareCssVars(theme, parserConfig) {
|
|
|
55
56
|
const generateCssVars = colorScheme => {
|
|
56
57
|
if (!colorScheme) {
|
|
57
58
|
return {
|
|
58
|
-
css: rootCss,
|
|
59
|
+
css: (0, _extends2.default)({}, rootCss),
|
|
59
60
|
vars: rootVars
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
css: (0, _extends2.default)({}, colorSchemesMap[colorScheme].css),
|
|
65
|
+
vars: colorSchemesMap[colorScheme].vars
|
|
66
|
+
};
|
|
63
67
|
};
|
|
64
68
|
return {
|
|
65
69
|
vars: themeVars,
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export type Mode = 'light' | 'dark' | 'system';
|
|
2
|
-
export type SystemMode = Exclude<Mode, 'system'>;
|
|
3
|
-
export interface State<SupportedColorScheme extends string> {
|
|
4
|
-
/**
|
|
5
|
-
* User selected mode.
|
|
6
|
-
* Note: on the server, mode is always undefined
|
|
7
|
-
*/
|
|
8
|
-
mode: Mode | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Only valid if `mode: 'system'`, either 'light' | 'dark'.
|
|
11
|
-
*/
|
|
12
|
-
systemMode: SystemMode | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* The color scheme for the light mode.
|
|
15
|
-
*/
|
|
16
|
-
lightColorScheme: SupportedColorScheme;
|
|
17
|
-
/**
|
|
18
|
-
* The color scheme for the dark mode.
|
|
19
|
-
*/
|
|
20
|
-
darkColorScheme: SupportedColorScheme;
|
|
21
|
-
}
|
|
22
|
-
export type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
|
|
23
|
-
/**
|
|
24
|
-
* The current application color scheme. It is always `undefined` on the server.
|
|
25
|
-
*/
|
|
26
|
-
colorScheme: SupportedColorScheme | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* `mode` is saved to internal state and localStorage
|
|
29
|
-
* If `mode` is null, it will be reset to the defaultMode
|
|
30
|
-
*/
|
|
31
|
-
setMode: (mode: Mode | null) => void;
|
|
32
|
-
/**
|
|
33
|
-
* `colorScheme` is saved to internal state and localStorage
|
|
34
|
-
* If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
|
|
35
|
-
*/
|
|
36
|
-
setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
|
|
37
|
-
light: SupportedColorScheme | null;
|
|
38
|
-
dark: SupportedColorScheme | null;
|
|
39
|
-
}> | null) => void;
|
|
40
|
-
};
|
|
41
|
-
export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
|
|
42
|
-
export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
|
|
43
|
-
interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
|
|
44
|
-
defaultLightColorScheme: SupportedColorScheme;
|
|
45
|
-
defaultDarkColorScheme: SupportedColorScheme;
|
|
46
|
-
supportedColorSchemes: Array<SupportedColorScheme>;
|
|
47
|
-
defaultMode?: Mode;
|
|
48
|
-
modeStorageKey?: string;
|
|
49
|
-
colorSchemeStorageKey?: string;
|
|
50
|
-
storageWindow?: Window | null;
|
|
51
|
-
}
|
|
52
|
-
export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
|
|
53
|
-
export {};
|
|
1
|
+
export type Mode = 'light' | 'dark' | 'system';
|
|
2
|
+
export type SystemMode = Exclude<Mode, 'system'>;
|
|
3
|
+
export interface State<SupportedColorScheme extends string> {
|
|
4
|
+
/**
|
|
5
|
+
* User selected mode.
|
|
6
|
+
* Note: on the server, mode is always undefined
|
|
7
|
+
*/
|
|
8
|
+
mode: Mode | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Only valid if `mode: 'system'`, either 'light' | 'dark'.
|
|
11
|
+
*/
|
|
12
|
+
systemMode: SystemMode | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The color scheme for the light mode.
|
|
15
|
+
*/
|
|
16
|
+
lightColorScheme: SupportedColorScheme;
|
|
17
|
+
/**
|
|
18
|
+
* The color scheme for the dark mode.
|
|
19
|
+
*/
|
|
20
|
+
darkColorScheme: SupportedColorScheme;
|
|
21
|
+
}
|
|
22
|
+
export type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
|
|
23
|
+
/**
|
|
24
|
+
* The current application color scheme. It is always `undefined` on the server.
|
|
25
|
+
*/
|
|
26
|
+
colorScheme: SupportedColorScheme | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* `mode` is saved to internal state and localStorage
|
|
29
|
+
* If `mode` is null, it will be reset to the defaultMode
|
|
30
|
+
*/
|
|
31
|
+
setMode: (mode: Mode | null) => void;
|
|
32
|
+
/**
|
|
33
|
+
* `colorScheme` is saved to internal state and localStorage
|
|
34
|
+
* If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
|
|
35
|
+
*/
|
|
36
|
+
setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
|
|
37
|
+
light: SupportedColorScheme | null;
|
|
38
|
+
dark: SupportedColorScheme | null;
|
|
39
|
+
}> | null) => void;
|
|
40
|
+
};
|
|
41
|
+
export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
|
|
42
|
+
export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
|
|
43
|
+
interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
|
|
44
|
+
defaultLightColorScheme: SupportedColorScheme;
|
|
45
|
+
defaultDarkColorScheme: SupportedColorScheme;
|
|
46
|
+
supportedColorSchemes: Array<SupportedColorScheme>;
|
|
47
|
+
defaultMode?: Mode;
|
|
48
|
+
modeStorageKey?: string;
|
|
49
|
+
colorSchemeStorageKey?: string;
|
|
50
|
+
storageWindow?: Window | null;
|
|
51
|
+
}
|
|
52
|
+
export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
|
|
53
|
+
export {};
|
|
@@ -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/esm/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 {
|
|
@@ -55,10 +54,10 @@ export default function createGrid(options = {}) {
|
|
|
55
54
|
const theme = useTheme();
|
|
56
55
|
const themeProps = useThemeProps(inProps);
|
|
57
56
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
58
|
-
const level = React.useContext(NestedContext);
|
|
59
57
|
const overflow = React.useContext(OverflowContext);
|
|
60
58
|
const {
|
|
61
59
|
className,
|
|
60
|
+
children,
|
|
62
61
|
columns: columnsProp = 12,
|
|
63
62
|
container = false,
|
|
64
63
|
component = 'div',
|
|
@@ -67,7 +66,8 @@ export default function createGrid(options = {}) {
|
|
|
67
66
|
spacing: spacingProp = 0,
|
|
68
67
|
rowSpacing: rowSpacingProp = spacingProp,
|
|
69
68
|
columnSpacing: columnSpacingProp = spacingProp,
|
|
70
|
-
disableEqualOverflow: themeDisableEqualOverflow
|
|
69
|
+
disableEqualOverflow: themeDisableEqualOverflow,
|
|
70
|
+
unstable_level: level = 0
|
|
71
71
|
} = props,
|
|
72
72
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
73
73
|
// Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
@@ -114,13 +114,17 @@ export default function createGrid(options = {}) {
|
|
|
114
114
|
as: component,
|
|
115
115
|
ownerState: ownerState,
|
|
116
116
|
className: clsx(classes.root, className)
|
|
117
|
-
}, other
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
}, other, {
|
|
118
|
+
children: React.Children.map(children, child => {
|
|
119
|
+
if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
|
|
120
|
+
var _child$props$unstable;
|
|
121
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
122
|
+
unstable_level: (_child$props$unstable = child.props.unstable_level) != null ? _child$props$unstable : level + 1
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return child;
|
|
126
|
+
})
|
|
127
|
+
}));
|
|
124
128
|
if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
|
|
125
129
|
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
|
|
126
130
|
// 1. It is the root grid with `disableEqualOverflow`.
|
|
@@ -156,5 +160,8 @@ export default function createGrid(options = {}) {
|
|
|
156
160
|
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
157
161
|
xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
|
|
158
162
|
} : void 0;
|
|
163
|
+
|
|
164
|
+
// @ts-ignore internal logic for nested grid
|
|
165
|
+
Grid.muiName = 'Grid';
|
|
159
166
|
return Grid;
|
|
160
167
|
}
|
|
@@ -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,12 +155,12 @@ 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
|
var _theme$spacing;
|
|
162
162
|
appendStyle(styles, {
|
|
163
|
-
[`--Grid-rowSpacing${appendLevel(ownerState.
|
|
163
|
+
[`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
return styles;
|
|
@@ -176,12 +176,12 @@ export const generateGridColumnSpacingStyles = ({
|
|
|
176
176
|
const styles = isNestedContainer(ownerState) ? {
|
|
177
177
|
// Set the default spacing as its parent spacing.
|
|
178
178
|
// It will be overridden if spacing props are provided
|
|
179
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
179
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('column')
|
|
180
180
|
} : {};
|
|
181
181
|
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
|
|
182
182
|
var _theme$spacing2;
|
|
183
183
|
appendStyle(styles, {
|
|
184
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
184
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
return styles;
|
package/esm/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/esm/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';
|
|
@@ -70,16 +68,26 @@ export const systemDefaultTheme = createTheme();
|
|
|
70
68
|
const lowercaseFirstLetter = string => {
|
|
71
69
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
72
70
|
};
|
|
71
|
+
function resolveTheme({
|
|
72
|
+
defaultTheme,
|
|
73
|
+
theme,
|
|
74
|
+
themeId
|
|
75
|
+
}) {
|
|
76
|
+
return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
|
|
77
|
+
}
|
|
73
78
|
export default function createStyled(input = {}) {
|
|
74
79
|
const {
|
|
80
|
+
themeId,
|
|
75
81
|
defaultTheme = systemDefaultTheme,
|
|
76
82
|
rootShouldForwardProp = shouldForwardProp,
|
|
77
83
|
slotShouldForwardProp = shouldForwardProp
|
|
78
84
|
} = input;
|
|
79
85
|
const systemSx = props => {
|
|
80
|
-
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
81
86
|
return styleFunctionSx(_extends({}, props, {
|
|
82
|
-
theme
|
|
87
|
+
theme: resolveTheme(_extends({}, props, {
|
|
88
|
+
defaultTheme,
|
|
89
|
+
themeId
|
|
90
|
+
}))
|
|
83
91
|
}));
|
|
84
92
|
};
|
|
85
93
|
systemSx.__mui_systemSx = true;
|
|
@@ -123,20 +131,22 @@ export default function createStyled(input = {}) {
|
|
|
123
131
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
124
132
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
125
133
|
// which are basically components used as a selectors.
|
|
126
|
-
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ?
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, other));
|
|
134
|
+
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? props => {
|
|
135
|
+
return stylesArg(_extends({}, props, {
|
|
136
|
+
theme: resolveTheme(_extends({}, props, {
|
|
137
|
+
defaultTheme,
|
|
138
|
+
themeId
|
|
139
|
+
}))
|
|
140
|
+
}));
|
|
134
141
|
} : stylesArg;
|
|
135
142
|
}) : [];
|
|
136
143
|
let transformedStyleArg = styleArg;
|
|
137
144
|
if (componentName && overridesResolver) {
|
|
138
145
|
expressionsWithDefaultTheme.push(props => {
|
|
139
|
-
const theme =
|
|
146
|
+
const theme = resolveTheme(_extends({}, props, {
|
|
147
|
+
defaultTheme,
|
|
148
|
+
themeId
|
|
149
|
+
}));
|
|
140
150
|
const styleOverrides = getStyleOverrides(componentName, theme);
|
|
141
151
|
if (styleOverrides) {
|
|
142
152
|
const resolvedStyleOverrides = {};
|
|
@@ -152,7 +162,10 @@ export default function createStyled(input = {}) {
|
|
|
152
162
|
}
|
|
153
163
|
if (componentName && !skipVariantsResolver) {
|
|
154
164
|
expressionsWithDefaultTheme.push(props => {
|
|
155
|
-
const theme =
|
|
165
|
+
const theme = resolveTheme(_extends({}, props, {
|
|
166
|
+
defaultTheme,
|
|
167
|
+
themeId
|
|
168
|
+
}));
|
|
156
169
|
return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
157
170
|
});
|
|
158
171
|
}
|
|
@@ -171,15 +184,12 @@ export default function createStyled(input = {}) {
|
|
|
171
184
|
// which are basically components used as a selectors.
|
|
172
185
|
styleArg.__emotion_real !== styleArg) {
|
|
173
186
|
// If the type is function, we need to define the default theme.
|
|
174
|
-
transformedStyleArg =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
theme: isEmpty(themeInput) ? defaultTheme : themeInput
|
|
181
|
-
}, other));
|
|
182
|
-
};
|
|
187
|
+
transformedStyleArg = props => styleArg(_extends({}, props, {
|
|
188
|
+
theme: resolveTheme(_extends({}, props, {
|
|
189
|
+
defaultTheme,
|
|
190
|
+
themeId
|
|
191
|
+
}))
|
|
192
|
+
}));
|
|
183
193
|
}
|
|
184
194
|
const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
185
195
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -192,6 +202,9 @@ export default function createStyled(input = {}) {
|
|
|
192
202
|
}
|
|
193
203
|
Component.displayName = displayName;
|
|
194
204
|
}
|
|
205
|
+
if (tag.muiName) {
|
|
206
|
+
Component.muiName = tag.muiName;
|
|
207
|
+
}
|
|
195
208
|
return Component;
|
|
196
209
|
};
|
|
197
210
|
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,
|