@mui/system 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +37 -2
- package/Container/createContainer.js +41 -35
- package/RtlProvider/index.js +8 -11
- package/Stack/createStack.js +24 -26
- package/ThemeProvider/ThemeProvider.js +9 -5
- package/Unstable_Grid/createGrid.js +21 -23
- package/Unstable_Grid/gridGenerator.js +20 -17
- package/breakpoints/breakpoints.js +7 -6
- package/createBox/createBox.js +9 -12
- package/createStyled/createStyled.js +59 -51
- package/createTheme/createBreakpoints.js +24 -25
- package/createTheme/createTheme.js +18 -14
- package/cssContainerQueries/cssContainerQueries.js +6 -4
- package/cssVars/createCssVarsProvider.js +17 -16
- package/cssVars/createCssVarsTheme.js +3 -3
- package/cssVars/prepareCssVars.js +30 -25
- package/cssVars/useCurrentColorScheme.js +18 -11
- package/index.js +1 -1
- package/modern/Container/createContainer.js +41 -35
- package/modern/RtlProvider/index.js +8 -11
- package/modern/Stack/createStack.js +24 -26
- package/modern/ThemeProvider/ThemeProvider.js +9 -5
- package/modern/Unstable_Grid/createGrid.js +21 -23
- package/modern/Unstable_Grid/gridGenerator.js +20 -17
- package/modern/breakpoints/breakpoints.js +7 -6
- package/modern/createBox/createBox.js +9 -12
- package/modern/createStyled/createStyled.js +59 -51
- package/modern/createTheme/createBreakpoints.js +24 -25
- package/modern/createTheme/createTheme.js +18 -14
- package/modern/cssContainerQueries/cssContainerQueries.js +6 -4
- package/modern/cssVars/createCssVarsProvider.js +17 -16
- package/modern/cssVars/createCssVarsTheme.js +3 -3
- package/modern/cssVars/prepareCssVars.js +30 -25
- package/modern/cssVars/useCurrentColorScheme.js +18 -11
- package/modern/index.js +1 -1
- package/modern/propsToClassKey/propsToClassKey.js +3 -5
- package/modern/styleFunctionSx/extendSxProp.js +14 -10
- package/node/Container/createContainer.js +41 -35
- package/node/RtlProvider/index.js +8 -11
- package/node/Stack/createStack.js +24 -26
- package/node/ThemeProvider/ThemeProvider.js +9 -5
- package/node/Unstable_Grid/createGrid.js +21 -23
- package/node/Unstable_Grid/gridGenerator.js +20 -18
- package/node/breakpoints/breakpoints.js +7 -6
- package/node/createBox/createBox.js +9 -12
- package/node/createStyled/createStyled.js +61 -52
- package/node/createTheme/createBreakpoints.js +24 -26
- package/node/createTheme/createTheme.js +18 -14
- package/node/cssContainerQueries/cssContainerQueries.js +6 -4
- package/node/cssVars/createCssVarsProvider.js +17 -16
- package/node/cssVars/createCssVarsTheme.js +3 -3
- package/node/cssVars/prepareCssVars.js +30 -25
- package/node/cssVars/useCurrentColorScheme.js +18 -12
- package/node/index.js +1 -1
- package/node/propsToClassKey/propsToClassKey.js +3 -5
- package/node/styleFunctionSx/extendSxProp.js +14 -10
- package/package.json +5 -5
- package/propsToClassKey/propsToClassKey.js +3 -5
- package/styleFunctionSx/extendSxProp.js +14 -10
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["values", "unit", "step"];
|
|
4
1
|
// Sorted ASC by size. That's important.
|
|
5
2
|
// It can't be configured as it's used statically for propTypes.
|
|
6
3
|
export const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
@@ -12,32 +9,33 @@ const sortBreakpointsValues = values => {
|
|
|
12
9
|
// Sort in ascending order
|
|
13
10
|
breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
|
|
14
11
|
return breakpointsAsArray.reduce((acc, obj) => {
|
|
15
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
...acc,
|
|
16
14
|
[obj.key]: obj.val
|
|
17
|
-
}
|
|
15
|
+
};
|
|
18
16
|
}, {});
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
// Keep in mind that @media is inclusive by the CSS specification.
|
|
22
20
|
export default function createBreakpoints(breakpoints) {
|
|
23
21
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
// The breakpoint **start** at this value.
|
|
23
|
+
// For instance with the first breakpoint xs: [xs, sm).
|
|
24
|
+
values = {
|
|
25
|
+
xs: 0,
|
|
26
|
+
// phone
|
|
27
|
+
sm: 600,
|
|
28
|
+
// tablet
|
|
29
|
+
md: 900,
|
|
30
|
+
// small laptop
|
|
31
|
+
lg: 1200,
|
|
32
|
+
// desktop
|
|
33
|
+
xl: 1536 // large screen
|
|
34
|
+
},
|
|
35
|
+
unit = 'px',
|
|
36
|
+
step = 5,
|
|
37
|
+
...other
|
|
38
|
+
} = breakpoints;
|
|
41
39
|
const sortedValues = sortBreakpointsValues(values);
|
|
42
40
|
const keys = Object.keys(sortedValues);
|
|
43
41
|
function up(key) {
|
|
@@ -69,7 +67,7 @@ export default function createBreakpoints(breakpoints) {
|
|
|
69
67
|
}
|
|
70
68
|
return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
|
|
71
69
|
}
|
|
72
|
-
return
|
|
70
|
+
return {
|
|
73
71
|
keys,
|
|
74
72
|
values: sortedValues,
|
|
75
73
|
up,
|
|
@@ -77,6 +75,7 @@ export default function createBreakpoints(breakpoints) {
|
|
|
77
75
|
between,
|
|
78
76
|
only,
|
|
79
77
|
not,
|
|
80
|
-
unit
|
|
81
|
-
|
|
78
|
+
unit,
|
|
79
|
+
...other
|
|
80
|
+
};
|
|
82
81
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["breakpoints", "palette", "spacing", "shape"];
|
|
4
1
|
import deepmerge from '@mui/utils/deepmerge';
|
|
5
2
|
import createBreakpoints from './createBreakpoints';
|
|
6
3
|
import cssContainerQueries from '../cssContainerQueries';
|
|
@@ -11,12 +8,12 @@ import defaultSxConfig from '../styleFunctionSx/defaultSxConfig';
|
|
|
11
8
|
import applyStyles from './applyStyles';
|
|
12
9
|
function createTheme(options = {}, ...args) {
|
|
13
10
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
breakpoints: breakpointsInput = {},
|
|
12
|
+
palette: paletteInput = {},
|
|
13
|
+
spacing: spacingInput,
|
|
14
|
+
shape: shapeInput = {},
|
|
15
|
+
...other
|
|
16
|
+
} = options;
|
|
20
17
|
const breakpoints = createBreakpoints(breakpointsInput);
|
|
21
18
|
const spacing = createSpacing(spacingInput);
|
|
22
19
|
let muiTheme = deepmerge({
|
|
@@ -24,16 +21,23 @@ function createTheme(options = {}, ...args) {
|
|
|
24
21
|
direction: 'ltr',
|
|
25
22
|
components: {},
|
|
26
23
|
// Inject component definitions.
|
|
27
|
-
palette:
|
|
28
|
-
mode: 'light'
|
|
29
|
-
|
|
24
|
+
palette: {
|
|
25
|
+
mode: 'light',
|
|
26
|
+
...paletteInput
|
|
27
|
+
},
|
|
30
28
|
spacing,
|
|
31
|
-
shape:
|
|
29
|
+
shape: {
|
|
30
|
+
...shape,
|
|
31
|
+
...shapeInput
|
|
32
|
+
}
|
|
32
33
|
}, other);
|
|
33
34
|
muiTheme = cssContainerQueries(muiTheme);
|
|
34
35
|
muiTheme.applyStyles = applyStyles;
|
|
35
36
|
muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
|
|
36
|
-
muiTheme.unstable_sxConfig =
|
|
37
|
+
muiTheme.unstable_sxConfig = {
|
|
38
|
+
...defaultSxConfig,
|
|
39
|
+
...other?.unstable_sxConfig
|
|
40
|
+
};
|
|
37
41
|
muiTheme.unstable_sx = function sx(props) {
|
|
38
42
|
return styleFunctionSx({
|
|
39
43
|
sx: props,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
3
2
|
/**
|
|
4
3
|
* For using in `sx` prop to sort the breakpoint from low to high.
|
|
@@ -22,7 +21,9 @@ export function sortContainerQueries(theme, css) {
|
|
|
22
21
|
delete acc[key];
|
|
23
22
|
acc[key] = value;
|
|
24
23
|
return acc;
|
|
25
|
-
},
|
|
24
|
+
}, {
|
|
25
|
+
...css
|
|
26
|
+
});
|
|
26
27
|
}
|
|
27
28
|
export function isCqShorthand(breakpointKeys, value) {
|
|
28
29
|
return value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
|
|
@@ -62,7 +63,8 @@ export default function cssContainerQueries(themeInput) {
|
|
|
62
63
|
return node;
|
|
63
64
|
};
|
|
64
65
|
attachCq(containerQueries);
|
|
65
|
-
return
|
|
66
|
+
return {
|
|
67
|
+
...themeInput,
|
|
66
68
|
containerQueries
|
|
67
|
-
}
|
|
69
|
+
};
|
|
68
70
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
1
|
import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
4
|
-
const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
|
|
5
2
|
import * as React from 'react';
|
|
6
3
|
import PropTypes from 'prop-types';
|
|
7
4
|
import { GlobalStyles } from '@mui/styled-engine';
|
|
@@ -65,13 +62,12 @@ export default function createCssVarsProvider(options) {
|
|
|
65
62
|
const ctx = React.useContext(ColorSchemeContext);
|
|
66
63
|
const nested = !!ctx && !disableNestedContext;
|
|
67
64
|
const scopedTheme = themeProp[themeId];
|
|
68
|
-
const
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
restThemeProp = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
65
|
+
const {
|
|
66
|
+
colorSchemes = {},
|
|
67
|
+
components = {},
|
|
68
|
+
cssVarPrefix,
|
|
69
|
+
...restThemeProp
|
|
70
|
+
} = scopedTheme || themeProp;
|
|
75
71
|
const allColorSchemes = Object.keys(colorSchemes);
|
|
76
72
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
77
73
|
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
@@ -126,12 +122,13 @@ export default function createCssVarsProvider(options) {
|
|
|
126
122
|
const themeVars = restThemeProp.generateThemeVars?.() || restThemeProp.vars;
|
|
127
123
|
|
|
128
124
|
// 3. Start composing the theme object
|
|
129
|
-
const theme =
|
|
125
|
+
const theme = {
|
|
126
|
+
...restThemeProp,
|
|
130
127
|
components,
|
|
131
128
|
colorSchemes,
|
|
132
129
|
cssVarPrefix,
|
|
133
130
|
vars: themeVars
|
|
134
|
-
}
|
|
131
|
+
};
|
|
135
132
|
if (typeof theme.generateSpacing === 'function') {
|
|
136
133
|
theme.spacing = theme.generateSpacing();
|
|
137
134
|
}
|
|
@@ -143,7 +140,10 @@ export default function createCssVarsProvider(options) {
|
|
|
143
140
|
Object.keys(scheme).forEach(schemeKey => {
|
|
144
141
|
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
145
142
|
// shallow merge the 1st level structure of the theme.
|
|
146
|
-
theme[schemeKey] =
|
|
143
|
+
theme[schemeKey] = {
|
|
144
|
+
...theme[schemeKey],
|
|
145
|
+
...scheme[schemeKey]
|
|
146
|
+
};
|
|
147
147
|
} else {
|
|
148
148
|
theme[schemeKey] = scheme[schemeKey];
|
|
149
149
|
}
|
|
@@ -299,14 +299,15 @@ export default function createCssVarsProvider(options) {
|
|
|
299
299
|
} : void 0;
|
|
300
300
|
const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
|
|
301
301
|
const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
|
|
302
|
-
const getInitColorSchemeScript = params => systemGetInitColorSchemeScript(
|
|
302
|
+
const getInitColorSchemeScript = params => systemGetInitColorSchemeScript({
|
|
303
303
|
attribute: defaultAttribute,
|
|
304
304
|
colorSchemeStorageKey: defaultColorSchemeStorageKey,
|
|
305
305
|
defaultMode: designSystemMode,
|
|
306
306
|
defaultLightColorScheme,
|
|
307
307
|
defaultDarkColorScheme,
|
|
308
|
-
modeStorageKey: defaultModeStorageKey
|
|
309
|
-
|
|
308
|
+
modeStorageKey: defaultModeStorageKey,
|
|
309
|
+
...params
|
|
310
|
+
});
|
|
310
311
|
return {
|
|
311
312
|
CssVarsProvider,
|
|
312
313
|
useColorScheme,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import prepareCssVars from './prepareCssVars';
|
|
3
2
|
function createCssVarsTheme(theme) {
|
|
4
3
|
const output = theme;
|
|
5
|
-
const result = prepareCssVars(output,
|
|
4
|
+
const result = prepareCssVars(output, {
|
|
5
|
+
...theme,
|
|
6
6
|
prefix: theme.cssVarPrefix
|
|
7
|
-
})
|
|
7
|
+
});
|
|
8
8
|
output.vars = result.vars;
|
|
9
9
|
output.generateThemeVars = result.generateThemeVars;
|
|
10
10
|
output.generateStyleSheets = result.generateStyleSheets;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
const _excluded = ["getSelector"],
|
|
5
|
-
_excluded2 = ["colorSchemes", "components", "defaultColorScheme"];
|
|
6
1
|
import deepmerge from '@mui/utils/deepmerge';
|
|
7
2
|
import cssVarsParser from './cssVarsParser';
|
|
8
|
-
function prepareCssVars(theme,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
parserConfig = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
3
|
+
function prepareCssVars(theme, {
|
|
4
|
+
getSelector,
|
|
5
|
+
...parserConfig
|
|
6
|
+
} = {}) {
|
|
13
7
|
// @ts-ignore - ignore components do not exist
|
|
14
8
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
otherTheme
|
|
9
|
+
colorSchemes = {},
|
|
10
|
+
components,
|
|
11
|
+
defaultColorScheme = 'light',
|
|
12
|
+
...otherTheme
|
|
13
|
+
} = theme;
|
|
19
14
|
const {
|
|
20
15
|
vars: rootVars,
|
|
21
16
|
css: rootCss,
|
|
@@ -24,9 +19,9 @@ function prepareCssVars(theme, _ref = {}) {
|
|
|
24
19
|
let themeVars = rootVarsWithDefaults;
|
|
25
20
|
const colorSchemesMap = {};
|
|
26
21
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
[defaultColorScheme]: defaultScheme,
|
|
23
|
+
...otherColorSchemes
|
|
24
|
+
} = colorSchemes;
|
|
30
25
|
Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
|
|
31
26
|
const {
|
|
32
27
|
vars,
|
|
@@ -53,7 +48,9 @@ function prepareCssVars(theme, _ref = {}) {
|
|
|
53
48
|
};
|
|
54
49
|
}
|
|
55
50
|
const generateThemeVars = () => {
|
|
56
|
-
let vars =
|
|
51
|
+
let vars = {
|
|
52
|
+
...rootVars
|
|
53
|
+
};
|
|
57
54
|
Object.entries(colorSchemesMap).forEach(([, {
|
|
58
55
|
vars: schemeVars
|
|
59
56
|
}]) => {
|
|
@@ -67,26 +64,34 @@ function prepareCssVars(theme, _ref = {}) {
|
|
|
67
64
|
function insertStyleSheet(selector, css) {
|
|
68
65
|
if (Object.keys(css).length) {
|
|
69
66
|
stylesheets.push(typeof selector === 'string' ? {
|
|
70
|
-
[selector]:
|
|
67
|
+
[selector]: {
|
|
68
|
+
...css
|
|
69
|
+
}
|
|
71
70
|
} : selector);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
insertStyleSheet(getSelector?.(undefined,
|
|
73
|
+
insertStyleSheet(getSelector?.(undefined, {
|
|
74
|
+
...rootCss
|
|
75
|
+
}) || ':root', rootCss);
|
|
75
76
|
const {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
[colorScheme]: defaultSchemeVal,
|
|
78
|
+
...rest
|
|
79
|
+
} = colorSchemesMap;
|
|
79
80
|
if (defaultSchemeVal) {
|
|
80
81
|
// default color scheme has to come before other color schemes
|
|
81
82
|
const {
|
|
82
83
|
css
|
|
83
84
|
} = defaultSchemeVal;
|
|
84
|
-
insertStyleSheet(getSelector?.(colorScheme,
|
|
85
|
+
insertStyleSheet(getSelector?.(colorScheme, {
|
|
86
|
+
...css
|
|
87
|
+
}) || `[${theme.attribute || 'data-color-scheme'}="${colorScheme}"]`, css);
|
|
85
88
|
}
|
|
86
89
|
Object.entries(rest).forEach(([key, {
|
|
87
90
|
css
|
|
88
91
|
}]) => {
|
|
89
|
-
insertStyleSheet(getSelector?.(key,
|
|
92
|
+
insertStyleSheet(getSelector?.(key, {
|
|
93
|
+
...css
|
|
94
|
+
}) || `[${theme.attribute || 'data-color-scheme'}="${key}"]`, css);
|
|
90
95
|
});
|
|
91
96
|
return stylesheets;
|
|
92
97
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
6
5
|
export function getSystemMode(mode) {
|
|
@@ -84,10 +83,11 @@ export default function useCurrentColorScheme(options) {
|
|
|
84
83
|
} catch (e) {
|
|
85
84
|
// Unsupported
|
|
86
85
|
}
|
|
87
|
-
return
|
|
86
|
+
return {
|
|
87
|
+
...currentState,
|
|
88
88
|
mode: newMode,
|
|
89
89
|
systemMode: getSystemMode(newMode)
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
91
|
});
|
|
92
92
|
}, [modeStorageKey, defaultMode]);
|
|
93
93
|
const setColorScheme = React.useCallback(value => {
|
|
@@ -99,17 +99,20 @@ export default function useCurrentColorScheme(options) {
|
|
|
99
99
|
} catch (e) {
|
|
100
100
|
// Unsupported
|
|
101
101
|
}
|
|
102
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
...currentState,
|
|
103
104
|
lightColorScheme: defaultLightColorScheme,
|
|
104
105
|
darkColorScheme: defaultDarkColorScheme
|
|
105
|
-
}
|
|
106
|
+
};
|
|
106
107
|
});
|
|
107
108
|
} else if (typeof value === 'string') {
|
|
108
109
|
if (value && !joinedColorSchemes.includes(value)) {
|
|
109
110
|
console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
|
|
110
111
|
} else {
|
|
111
112
|
setState(currentState => {
|
|
112
|
-
const newState =
|
|
113
|
+
const newState = {
|
|
114
|
+
...currentState
|
|
115
|
+
};
|
|
113
116
|
processState(currentState, mode => {
|
|
114
117
|
try {
|
|
115
118
|
localStorage.setItem(`${colorSchemeStorageKey}-${mode}`, value);
|
|
@@ -128,7 +131,9 @@ export default function useCurrentColorScheme(options) {
|
|
|
128
131
|
}
|
|
129
132
|
} else {
|
|
130
133
|
setState(currentState => {
|
|
131
|
-
const newState =
|
|
134
|
+
const newState = {
|
|
135
|
+
...currentState
|
|
136
|
+
};
|
|
132
137
|
const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
133
138
|
const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
134
139
|
if (newLightColorScheme) {
|
|
@@ -168,9 +173,10 @@ export default function useCurrentColorScheme(options) {
|
|
|
168
173
|
if (currentState.systemMode === systemMode) {
|
|
169
174
|
return currentState;
|
|
170
175
|
}
|
|
171
|
-
return
|
|
176
|
+
return {
|
|
177
|
+
...currentState,
|
|
172
178
|
systemMode
|
|
173
|
-
}
|
|
179
|
+
};
|
|
174
180
|
});
|
|
175
181
|
}
|
|
176
182
|
}, [state.mode]);
|
|
@@ -222,9 +228,10 @@ export default function useCurrentColorScheme(options) {
|
|
|
222
228
|
}
|
|
223
229
|
return undefined;
|
|
224
230
|
}, [setColorScheme, setMode, modeStorageKey, colorSchemeStorageKey, joinedColorSchemes, defaultMode, storageWindow]);
|
|
225
|
-
return
|
|
231
|
+
return {
|
|
232
|
+
...state,
|
|
226
233
|
colorScheme,
|
|
227
234
|
setMode,
|
|
228
235
|
setColorScheme
|
|
229
|
-
}
|
|
236
|
+
};
|
|
230
237
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
-
const _excluded = ["variant"];
|
|
3
1
|
import capitalize from '@mui/utils/capitalize';
|
|
4
2
|
function isEmpty(string) {
|
|
5
3
|
return string.length === 0;
|
|
@@ -12,9 +10,9 @@ function isEmpty(string) {
|
|
|
12
10
|
*/
|
|
13
11
|
export default function propsToClassKey(props) {
|
|
14
12
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
variant,
|
|
14
|
+
...other
|
|
15
|
+
} = props;
|
|
18
16
|
let classKey = variant || '';
|
|
19
17
|
Object.keys(other).sort().forEach(key => {
|
|
20
18
|
if (key === 'color') {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["sx"];
|
|
4
1
|
import { isPlainObject } from '@mui/utils/deepmerge';
|
|
5
2
|
import defaultSxConfig from './defaultSxConfig';
|
|
6
3
|
const splitProps = props => {
|
|
@@ -20,9 +17,9 @@ const splitProps = props => {
|
|
|
20
17
|
};
|
|
21
18
|
export default function extendSxProp(props) {
|
|
22
19
|
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
sx: inSx,
|
|
21
|
+
...other
|
|
22
|
+
} = props;
|
|
26
23
|
const {
|
|
27
24
|
systemProps,
|
|
28
25
|
otherProps
|
|
@@ -36,12 +33,19 @@ export default function extendSxProp(props) {
|
|
|
36
33
|
if (!isPlainObject(result)) {
|
|
37
34
|
return systemProps;
|
|
38
35
|
}
|
|
39
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
...systemProps,
|
|
38
|
+
...result
|
|
39
|
+
};
|
|
40
40
|
};
|
|
41
41
|
} else {
|
|
42
|
-
finalSx =
|
|
42
|
+
finalSx = {
|
|
43
|
+
...systemProps,
|
|
44
|
+
...inSx
|
|
45
|
+
};
|
|
43
46
|
}
|
|
44
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
...otherProps,
|
|
45
49
|
sx: finalSx
|
|
46
|
-
}
|
|
50
|
+
};
|
|
47
51
|
}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = createContainer;
|
|
8
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
10
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
@@ -17,7 +15,6 @@ var _useThemeProps = _interopRequireDefault(require("../useThemeProps"));
|
|
|
17
15
|
var _styled = _interopRequireDefault(require("../styled"));
|
|
18
16
|
var _createTheme = _interopRequireDefault(require("../createTheme"));
|
|
19
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["className", "component", "disableGutters", "fixed", "maxWidth", "classes"];
|
|
21
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
20
|
const defaultTheme = (0, _createTheme.default)();
|
|
@@ -61,20 +58,22 @@ function createContainer(options = {}) {
|
|
|
61
58
|
const ContainerRoot = createStyledComponent(({
|
|
62
59
|
theme,
|
|
63
60
|
ownerState
|
|
64
|
-
}) => (
|
|
61
|
+
}) => ({
|
|
65
62
|
width: '100%',
|
|
66
63
|
marginLeft: 'auto',
|
|
67
64
|
boxSizing: 'border-box',
|
|
68
65
|
marginRight: 'auto',
|
|
69
|
-
display: 'block'
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
display: 'block',
|
|
67
|
+
// Fix IE11 layout when used with main.
|
|
68
|
+
...(!ownerState.disableGutters && {
|
|
69
|
+
paddingLeft: theme.spacing(2),
|
|
70
|
+
paddingRight: theme.spacing(2),
|
|
71
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
72
|
+
[theme.breakpoints.up('sm')]: {
|
|
73
|
+
paddingLeft: theme.spacing(3),
|
|
74
|
+
paddingRight: theme.spacing(3)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
78
77
|
}), ({
|
|
79
78
|
theme,
|
|
80
79
|
ownerState
|
|
@@ -91,51 +90,58 @@ function createContainer(options = {}) {
|
|
|
91
90
|
}, {}), ({
|
|
92
91
|
theme,
|
|
93
92
|
ownerState
|
|
94
|
-
}) => (
|
|
93
|
+
}) => ({
|
|
95
94
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
96
|
-
|
|
95
|
+
...(ownerState.maxWidth === 'xs' && {
|
|
97
96
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
[theme.breakpoints.up('xs')]: {
|
|
98
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
99
|
+
maxWidth: Math.max(theme.breakpoints.values.xs, 444)
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
...(ownerState.maxWidth &&
|
|
103
103
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
104
|
-
|
|
104
|
+
ownerState.maxWidth !== 'xs' && {
|
|
105
105
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
[theme.breakpoints.up(ownerState.maxWidth)]: {
|
|
107
|
+
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
108
|
+
maxWidth: `${theme.breakpoints.values[ownerState.maxWidth]}${theme.breakpoints.unit}`
|
|
109
|
+
}
|
|
110
|
+
})
|
|
108
111
|
}));
|
|
109
112
|
const Container = /*#__PURE__*/React.forwardRef(function Container(inProps, ref) {
|
|
110
113
|
const props = useThemeProps(inProps);
|
|
111
114
|
const {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
other
|
|
119
|
-
|
|
115
|
+
className,
|
|
116
|
+
component = 'div',
|
|
117
|
+
disableGutters = false,
|
|
118
|
+
fixed = false,
|
|
119
|
+
maxWidth = 'lg',
|
|
120
|
+
classes: classesProp,
|
|
121
|
+
...other
|
|
122
|
+
} = props;
|
|
123
|
+
const ownerState = {
|
|
124
|
+
...props,
|
|
120
125
|
component,
|
|
121
126
|
disableGutters,
|
|
122
127
|
fixed,
|
|
123
128
|
maxWidth
|
|
124
|
-
}
|
|
129
|
+
};
|
|
125
130
|
|
|
126
131
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
127
132
|
const classes = useUtilityClasses(ownerState, componentName);
|
|
128
133
|
return (
|
|
129
134
|
/*#__PURE__*/
|
|
130
135
|
// @ts-ignore theme is injected by the styled util
|
|
131
|
-
(0, _jsxRuntime.jsx)(ContainerRoot,
|
|
136
|
+
(0, _jsxRuntime.jsx)(ContainerRoot, {
|
|
132
137
|
as: component
|
|
133
138
|
// @ts-ignore module augmentation fails if custom breakpoints are used
|
|
134
139
|
,
|
|
135
140
|
ownerState: ownerState,
|
|
136
141
|
className: (0, _clsx.default)(classes.root, className),
|
|
137
|
-
ref: ref
|
|
138
|
-
|
|
142
|
+
ref: ref,
|
|
143
|
+
...other
|
|
144
|
+
})
|
|
139
145
|
);
|
|
140
146
|
});
|
|
141
147
|
process.env.NODE_ENV !== "production" ? Container.propTypes /* remove-proptypes */ = {
|
|
@@ -5,23 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useRtl = exports.default = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
const _excluded = ["value"];
|
|
14
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
13
|
const RtlContext = /*#__PURE__*/React.createContext();
|
|
17
|
-
function RtlProvider(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
14
|
+
function RtlProvider({
|
|
15
|
+
value,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(RtlContext.Provider, {
|
|
19
|
+
value: value != null ? value : true,
|
|
20
|
+
...props
|
|
21
|
+
});
|
|
25
22
|
}
|
|
26
23
|
process.env.NODE_ENV !== "production" ? RtlProvider.propTypes = {
|
|
27
24
|
children: _propTypes.default.node,
|