@mui/system 5.6.1 → 5.6.4
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/Box/Box.d.ts +18 -1
- package/Box/Box.js +26 -0
- package/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +185 -2
- package/ThemeProvider/ThemeProvider.d.ts +6 -0
- package/ThemeProvider/ThemeProvider.js +9 -2
- package/createBox.js +0 -26
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +3 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.js +20 -36
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +70 -70
- package/cssVars/cssVarsParser.js +11 -9
- package/cssVars/getInitColorSchemeScript.d.ts +12 -12
- package/cssVars/index.d.ts +2 -2
- package/cssVars/useCurrentColorScheme.d.ts +50 -50
- package/esm/Box/Box.js +25 -0
- package/esm/ThemeProvider/ThemeProvider.js +9 -2
- package/esm/createBox.js +0 -25
- package/esm/createStyled.js +3 -1
- package/esm/cssVars/createCssVarsProvider.js +21 -35
- package/esm/cssVars/cssVarsParser.js +11 -9
- package/esm/spacing.js +3 -1
- package/esm/style.js +16 -1
- package/index.d.ts +4 -0
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/Box/Box.js +25 -0
- package/legacy/ThemeProvider/ThemeProvider.js +9 -2
- package/legacy/createBox.js +0 -25
- package/legacy/createStyled.js +3 -1
- package/legacy/cssVars/createCssVarsProvider.js +22 -31
- package/legacy/cssVars/cssVarsParser.js +11 -7
- package/legacy/index.js +1 -1
- package/legacy/spacing.js +3 -1
- package/legacy/style.js +16 -1
- package/modern/Box/Box.js +25 -0
- package/modern/ThemeProvider/ThemeProvider.js +9 -2
- package/modern/createBox.js +0 -25
- package/modern/createStyled.js +3 -1
- package/modern/cssVars/createCssVarsProvider.js +21 -33
- package/modern/cssVars/cssVarsParser.js +11 -9
- package/modern/index.js +1 -1
- package/modern/spacing.js +1 -1
- package/modern/style.js +16 -1
- package/package.json +2 -2
- package/spacing.js +3 -1
- package/style.js +16 -1
- package/styleFunctionSx/styleFunctionSx.d.ts +3 -1
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
package/esm/style.js
CHANGED
|
@@ -4,9 +4,24 @@ import { handleBreakpoints } from './breakpoints';
|
|
|
4
4
|
export function getPath(obj, path) {
|
|
5
5
|
if (!path || typeof path !== 'string') {
|
|
6
6
|
return null;
|
|
7
|
+
} // Check if CSS variables are used
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if (obj && obj.vars) {
|
|
11
|
+
const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
|
|
12
|
+
|
|
13
|
+
if (val != null) {
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
7
16
|
}
|
|
8
17
|
|
|
9
|
-
return path.split('.').reduce((acc, item) =>
|
|
18
|
+
return path.split('.').reduce((acc, item) => {
|
|
19
|
+
if (acc && acc[item] != null) {
|
|
20
|
+
return acc[item];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
}, obj);
|
|
10
25
|
}
|
|
11
26
|
|
|
12
27
|
function getValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
|
package/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export const borderRight: SimpleStyleFunction<'borderRight'>;
|
|
|
23
23
|
export const borderBottom: SimpleStyleFunction<'borderBottom'>;
|
|
24
24
|
export const borderLeft: SimpleStyleFunction<'borderLeft'>;
|
|
25
25
|
export const borderColor: SimpleStyleFunction<'borderColor'>;
|
|
26
|
+
export const borderTopColor: SimpleStyleFunction<'borderTopColor'>;
|
|
27
|
+
export const borderRightColor: SimpleStyleFunction<'borderRightColor'>;
|
|
28
|
+
export const borderBottomColor: SimpleStyleFunction<'borderBottomColor'>;
|
|
29
|
+
export const borderLeftColor: SimpleStyleFunction<'borderLeftColor'>;
|
|
26
30
|
export const borderRadius: SimpleStyleFunction<'borderRadius'>;
|
|
27
31
|
export type BordersProps = PropsFor<typeof borders>;
|
|
28
32
|
|
package/index.js
CHANGED
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/legacy/Box/Box.js
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
1
2
|
import createBox from '../createBox';
|
|
2
3
|
var Box = createBox();
|
|
4
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes
|
|
5
|
+
/* remove-proptypes */
|
|
6
|
+
= {
|
|
7
|
+
// ----------------------------- Warning --------------------------------
|
|
8
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
9
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
10
|
+
// ----------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
children: PropTypes.node,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The component used for the root node.
|
|
19
|
+
* Either a string to use a HTML element or a component.
|
|
20
|
+
*/
|
|
21
|
+
component: PropTypes.elementType,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
25
|
+
*/
|
|
26
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
27
|
+
} : void 0;
|
|
3
28
|
export default Box;
|
|
@@ -37,7 +37,14 @@ function ThemeProvider(props) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes
|
|
40
|
+
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes
|
|
41
|
+
/* remove-proptypes */
|
|
42
|
+
= {
|
|
43
|
+
// ----------------------------- Warning --------------------------------
|
|
44
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
45
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
46
|
+
// ----------------------------------------------------------------------
|
|
47
|
+
|
|
41
48
|
/**
|
|
42
49
|
* Your component tree.
|
|
43
50
|
*/
|
|
@@ -46,7 +53,7 @@ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
|
|
46
53
|
/**
|
|
47
54
|
* A theme object. You can provide a function to extend the outer theme.
|
|
48
55
|
*/
|
|
49
|
-
theme: PropTypes.oneOfType([PropTypes.
|
|
56
|
+
theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
|
|
50
57
|
} : void 0;
|
|
51
58
|
|
|
52
59
|
if (process.env.NODE_ENV !== 'production') {
|
package/legacy/createBox.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import clsx from 'clsx';
|
|
6
5
|
import styled from '@mui/styled-engine';
|
|
7
6
|
import defaultStyleFunctionSx, { extendSxProp } from './styleFunctionSx';
|
|
@@ -32,29 +31,5 @@ export default function createBox() {
|
|
|
32
31
|
theme: theme
|
|
33
32
|
}, other));
|
|
34
33
|
});
|
|
35
|
-
process.env.NODE_ENV !== "production" ? Box.propTypes
|
|
36
|
-
/* remove-proptypes */
|
|
37
|
-
= {
|
|
38
|
-
// ----------------------------- Warning --------------------------------
|
|
39
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
40
|
-
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
41
|
-
// ----------------------------------------------------------------------
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @ignore
|
|
45
|
-
*/
|
|
46
|
-
children: PropTypes.node,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The component used for the root node.
|
|
50
|
-
* Either a string to use a HTML element or a component.
|
|
51
|
-
*/
|
|
52
|
-
component: PropTypes.elementType,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @ignore
|
|
56
|
-
*/
|
|
57
|
-
sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
|
|
58
|
-
} : void 0;
|
|
59
34
|
return Box;
|
|
60
35
|
}
|
package/legacy/createStyled.js
CHANGED
|
@@ -149,7 +149,9 @@ export default function createStyled() {
|
|
|
149
149
|
slotKey = _ref3[0],
|
|
150
150
|
slotStyle = _ref3[1];
|
|
151
151
|
|
|
152
|
-
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props
|
|
152
|
+
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
|
|
153
|
+
theme: theme
|
|
154
|
+
})) : slotStyle;
|
|
153
155
|
});
|
|
154
156
|
return overridesResolver(props, resolvedStyleOverrides);
|
|
155
157
|
}
|
|
@@ -5,10 +5,8 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
|
5
5
|
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { GlobalStyles } from '@mui/styled-engine';
|
|
9
8
|
import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
10
|
-
import
|
|
11
|
-
import createBreakpoints from '../createTheme/createBreakpoints';
|
|
9
|
+
import { GlobalStyles } from '@mui/styled-engine';
|
|
12
10
|
import cssVarsParser from './cssVarsParser';
|
|
13
11
|
import ThemeProvider from '../ThemeProvider';
|
|
14
12
|
import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
@@ -18,10 +16,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
17
|
export var DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
20
18
|
export default function createCssVarsProvider(options) {
|
|
21
|
-
var _baseTheme$breakpoint;
|
|
22
|
-
|
|
23
19
|
var _options$theme = options.theme,
|
|
24
|
-
|
|
20
|
+
defaultTheme = _options$theme === void 0 ? {} : _options$theme,
|
|
25
21
|
_options$defaultMode = options.defaultMode,
|
|
26
22
|
desisgnSystemMode = _options$defaultMode === void 0 ? 'light' : _options$defaultMode,
|
|
27
23
|
designSystemColorScheme = options.defaultColorScheme,
|
|
@@ -33,10 +29,8 @@ export default function createCssVarsProvider(options) {
|
|
|
33
29
|
designSystemPrefix = _options$prefix === void 0 ? '' : _options$prefix,
|
|
34
30
|
shouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
|
|
35
31
|
resolveTheme = options.resolveTheme;
|
|
36
|
-
var systemSpacing = createSpacing(baseTheme.spacing);
|
|
37
|
-
var systemBreakpoints = createBreakpoints((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
|
|
38
32
|
|
|
39
|
-
if (!
|
|
33
|
+
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
|
|
40
34
|
console.error("MUI: `".concat(designSystemColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -55,7 +49,7 @@ export default function createCssVarsProvider(options) {
|
|
|
55
49
|
function CssVarsProvider(_ref) {
|
|
56
50
|
var children = _ref.children,
|
|
57
51
|
_ref$theme = _ref.theme,
|
|
58
|
-
themeProp = _ref$theme === void 0 ?
|
|
52
|
+
themeProp = _ref$theme === void 0 ? defaultTheme : _ref$theme,
|
|
59
53
|
_ref$prefix = _ref.prefix,
|
|
60
54
|
prefix = _ref$prefix === void 0 ? designSystemPrefix : _ref$prefix,
|
|
61
55
|
_ref$modeStorageKey = _ref.modeStorageKey,
|
|
@@ -70,23 +64,14 @@ export default function createCssVarsProvider(options) {
|
|
|
70
64
|
disableTransitionOnChange = _ref$disableTransitio === void 0 ? designSystemTransitionOnChange : _ref$disableTransitio,
|
|
71
65
|
_ref$enableColorSchem = _ref.enableColorScheme,
|
|
72
66
|
enableColorScheme = _ref$enableColorSchem === void 0 ? designSystemEnableColorScheme : _ref$enableColorSchem;
|
|
73
|
-
|
|
74
|
-
var _baseTheme$colorSchem = baseTheme.colorSchemes,
|
|
75
|
-
baseColorSchemes = _baseTheme$colorSchem === void 0 ? {} : _baseTheme$colorSchem,
|
|
76
|
-
restBaseTheme = _objectWithoutProperties(baseTheme, ["colorSchemes"]);
|
|
67
|
+
var hasMounted = React.useRef(false);
|
|
77
68
|
|
|
78
69
|
var _themeProp$colorSchem = themeProp.colorSchemes,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
colorSchemes = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
|
|
71
|
+
_themeProp$components = themeProp.components,
|
|
72
|
+
components = _themeProp$components === void 0 ? {} : _themeProp$components,
|
|
73
|
+
restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components"]);
|
|
83
74
|
|
|
84
|
-
var _deepmerge = deepmerge(restBaseTheme, restThemeProp),
|
|
85
|
-
_deepmerge$components = _deepmerge.components,
|
|
86
|
-
components = _deepmerge$components === void 0 ? {} : _deepmerge$components,
|
|
87
|
-
mergedTheme = _objectWithoutProperties(_deepmerge, ["components"]);
|
|
88
|
-
|
|
89
|
-
var colorSchemes = deepmerge(baseColorSchemes, colorSchemesProp);
|
|
90
75
|
var allColorSchemes = Object.keys(colorSchemes);
|
|
91
76
|
var defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
92
77
|
var defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
@@ -120,7 +105,9 @@ export default function createCssVarsProvider(options) {
|
|
|
120
105
|
return colorScheme;
|
|
121
106
|
}();
|
|
122
107
|
|
|
123
|
-
var
|
|
108
|
+
var theme = restThemeProp;
|
|
109
|
+
|
|
110
|
+
var _cssVarsParser = cssVarsParser(theme, {
|
|
124
111
|
prefix: prefix,
|
|
125
112
|
basePrefix: designSystemPrefix,
|
|
126
113
|
shouldSkipGeneratingVar: shouldSkipGeneratingVar
|
|
@@ -129,13 +116,11 @@ export default function createCssVarsProvider(options) {
|
|
|
129
116
|
rootVars = _cssVarsParser.vars,
|
|
130
117
|
parsedTheme = _cssVarsParser.parsedTheme;
|
|
131
118
|
|
|
132
|
-
|
|
119
|
+
theme = _extends({}, parsedTheme, {
|
|
133
120
|
components: components,
|
|
134
121
|
colorSchemes: colorSchemes,
|
|
135
122
|
prefix: prefix,
|
|
136
123
|
vars: rootVars,
|
|
137
|
-
spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
|
|
138
|
-
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
|
|
139
124
|
getCssVar: createGetCssVar(prefix)
|
|
140
125
|
});
|
|
141
126
|
var styleSheet = {};
|
|
@@ -153,10 +138,16 @@ export default function createCssVarsProvider(options) {
|
|
|
153
138
|
vars = _cssVarsParser2.vars,
|
|
154
139
|
parsedScheme = _cssVarsParser2.parsedTheme;
|
|
155
140
|
|
|
156
|
-
|
|
141
|
+
theme.vars = deepmerge(theme.vars, vars);
|
|
157
142
|
|
|
158
143
|
if (key === resolvedColorScheme) {
|
|
159
|
-
|
|
144
|
+
theme = _extends({}, theme, parsedScheme);
|
|
145
|
+
|
|
146
|
+
if (theme.palette) {
|
|
147
|
+
// assign runtime mode & colorScheme
|
|
148
|
+
theme.palette.mode = mode;
|
|
149
|
+
theme.palette.colorScheme = resolvedColorScheme;
|
|
150
|
+
}
|
|
160
151
|
}
|
|
161
152
|
|
|
162
153
|
var resolvedDefaultColorScheme = function () {
|
|
@@ -245,7 +236,7 @@ export default function createCssVarsProvider(options) {
|
|
|
245
236
|
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
246
237
|
styles: styleSheet
|
|
247
238
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
248
|
-
theme: resolveTheme ? resolveTheme(
|
|
239
|
+
theme: resolveTheme ? resolveTheme(theme) : theme,
|
|
249
240
|
children: children
|
|
250
241
|
})]
|
|
251
242
|
});
|
|
@@ -22,15 +22,18 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
|
22
22
|
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
23
23
|
*/
|
|
24
24
|
export var assignNestedKeys = function assignNestedKeys(obj, keys, value) {
|
|
25
|
+
var arrayKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
25
26
|
var temp = obj;
|
|
26
27
|
keys.forEach(function (k, index) {
|
|
27
28
|
if (index === keys.length - 1) {
|
|
28
|
-
if (
|
|
29
|
+
if (Array.isArray(temp)) {
|
|
30
|
+
temp[Number(k)] = value;
|
|
31
|
+
} else if (temp && _typeof(temp) === 'object') {
|
|
29
32
|
temp[k] = value;
|
|
30
33
|
}
|
|
31
34
|
} else if (temp && _typeof(temp) === 'object') {
|
|
32
35
|
if (!temp[k]) {
|
|
33
|
-
temp[k] = {};
|
|
36
|
+
temp[k] = arrayKeys.includes(k) ? [] : {};
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
temp = temp[k];
|
|
@@ -52,6 +55,7 @@ export var assignNestedKeys = function assignNestedKeys(obj, keys, value) {
|
|
|
52
55
|
export var walkObjectDeep = function walkObjectDeep(obj, callback, shouldSkipPaths) {
|
|
53
56
|
function recurse(object) {
|
|
54
57
|
var parentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
58
|
+
var arrayKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
55
59
|
Object.entries(object).forEach(function (_ref) {
|
|
56
60
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
57
61
|
key = _ref2[0],
|
|
@@ -60,9 +64,9 @@ export var walkObjectDeep = function walkObjectDeep(obj, callback, shouldSkipPat
|
|
|
60
64
|
if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([].concat(_toConsumableArray(parentKeys), [key]))) {
|
|
61
65
|
if (value !== undefined && value !== null) {
|
|
62
66
|
if (_typeof(value) === 'object' && Object.keys(value).length > 0) {
|
|
63
|
-
recurse(value, [].concat(_toConsumableArray(parentKeys), [key]));
|
|
67
|
+
recurse(value, [].concat(_toConsumableArray(parentKeys), [key]), Array.isArray(value) ? [].concat(_toConsumableArray(arrayKeys), [key]) : arrayKeys);
|
|
64
68
|
} else {
|
|
65
|
-
callback([].concat(_toConsumableArray(parentKeys), [key]), value,
|
|
69
|
+
callback([].concat(_toConsumableArray(parentKeys), [key]), value, arrayKeys);
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
}
|
|
@@ -132,7 +136,7 @@ export default function cssVarsParser(theme, options) {
|
|
|
132
136
|
var css = {};
|
|
133
137
|
var vars = {};
|
|
134
138
|
var parsedTheme = {};
|
|
135
|
-
walkObjectDeep(theme, function (keys, value) {
|
|
139
|
+
walkObjectDeep(theme, function (keys, value, arrayKeys) {
|
|
136
140
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
137
141
|
if (typeof value === 'string' && value.match(/var\(\s*--/)) {
|
|
138
142
|
// for CSS variable, apply prefix or remove basePrefix from the variable
|
|
@@ -150,11 +154,11 @@ export default function cssVarsParser(theme, options) {
|
|
|
150
154
|
|
|
151
155
|
_extends(css, _defineProperty({}, cssVar, getCssValue(keys, value)));
|
|
152
156
|
|
|
153
|
-
assignNestedKeys(vars, keys, "var(".concat(cssVar, ")"));
|
|
157
|
+
assignNestedKeys(vars, keys, "var(".concat(cssVar, ")"), arrayKeys);
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
assignNestedKeys(parsedTheme, keys, value);
|
|
161
|
+
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
158
162
|
}, function (keys) {
|
|
159
163
|
return keys[0] === 'vars';
|
|
160
164
|
} // skip 'vars/*' paths
|
package/legacy/index.js
CHANGED
package/legacy/spacing.js
CHANGED
|
@@ -50,7 +50,9 @@ var marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop'
|
|
|
50
50
|
var paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
51
51
|
var spacingKeys = [].concat(marginKeys, paddingKeys);
|
|
52
52
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
53
|
-
var
|
|
53
|
+
var _getPath;
|
|
54
|
+
|
|
55
|
+
var themeSpacing = (_getPath = getPath(theme, themeKey)) != null ? _getPath : defaultValue;
|
|
54
56
|
|
|
55
57
|
if (typeof themeSpacing === 'number') {
|
|
56
58
|
return function (abs) {
|
package/legacy/style.js
CHANGED
|
@@ -5,10 +5,25 @@ import { handleBreakpoints } from './breakpoints';
|
|
|
5
5
|
export function getPath(obj, path) {
|
|
6
6
|
if (!path || typeof path !== 'string') {
|
|
7
7
|
return null;
|
|
8
|
+
} // Check if CSS variables are used
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if (obj && obj.vars) {
|
|
12
|
+
var val = "vars.".concat(path).split('.').reduce(function (acc, item) {
|
|
13
|
+
return acc && acc[item] ? acc[item] : null;
|
|
14
|
+
}, obj);
|
|
15
|
+
|
|
16
|
+
if (val != null) {
|
|
17
|
+
return val;
|
|
18
|
+
}
|
|
8
19
|
}
|
|
9
20
|
|
|
10
21
|
return path.split('.').reduce(function (acc, item) {
|
|
11
|
-
|
|
22
|
+
if (acc && acc[item] != null) {
|
|
23
|
+
return acc[item];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
12
27
|
}, obj);
|
|
13
28
|
}
|
|
14
29
|
|
package/modern/Box/Box.js
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
1
2
|
import createBox from '../createBox';
|
|
2
3
|
const Box = createBox();
|
|
4
|
+
process.env.NODE_ENV !== "production" ? Box.propTypes
|
|
5
|
+
/* remove-proptypes */
|
|
6
|
+
= {
|
|
7
|
+
// ----------------------------- Warning --------------------------------
|
|
8
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
9
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
10
|
+
// ----------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
children: PropTypes.node,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The component used for the root node.
|
|
19
|
+
* Either a string to use a HTML element or a component.
|
|
20
|
+
*/
|
|
21
|
+
component: PropTypes.elementType,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
25
|
+
*/
|
|
26
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
27
|
+
} : void 0;
|
|
3
28
|
export default Box;
|
|
@@ -38,7 +38,14 @@ function ThemeProvider(props) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes
|
|
41
|
+
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes
|
|
42
|
+
/* remove-proptypes */
|
|
43
|
+
= {
|
|
44
|
+
// ----------------------------- Warning --------------------------------
|
|
45
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
46
|
+
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
47
|
+
// ----------------------------------------------------------------------
|
|
48
|
+
|
|
42
49
|
/**
|
|
43
50
|
* Your component tree.
|
|
44
51
|
*/
|
|
@@ -47,7 +54,7 @@ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
|
|
47
54
|
/**
|
|
48
55
|
* A theme object. You can provide a function to extend the outer theme.
|
|
49
56
|
*/
|
|
50
|
-
theme: PropTypes.oneOfType([PropTypes.
|
|
57
|
+
theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
|
|
51
58
|
} : void 0;
|
|
52
59
|
|
|
53
60
|
if (process.env.NODE_ENV !== 'production') {
|
package/modern/createBox.js
CHANGED
|
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["className", "component"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
5
|
import clsx from 'clsx';
|
|
7
6
|
import styled from '@mui/styled-engine';
|
|
8
7
|
import defaultStyleFunctionSx, { extendSxProp } from './styleFunctionSx';
|
|
@@ -33,29 +32,5 @@ export default function createBox(options = {}) {
|
|
|
33
32
|
theme: theme
|
|
34
33
|
}, other));
|
|
35
34
|
});
|
|
36
|
-
process.env.NODE_ENV !== "production" ? Box.propTypes
|
|
37
|
-
/* remove-proptypes */
|
|
38
|
-
= {
|
|
39
|
-
// ----------------------------- Warning --------------------------------
|
|
40
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
41
|
-
// | To update them edit the d.ts file and run "yarn proptypes" |
|
|
42
|
-
// ----------------------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @ignore
|
|
46
|
-
*/
|
|
47
|
-
children: PropTypes.node,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* The component used for the root node.
|
|
51
|
-
* Either a string to use a HTML element or a component.
|
|
52
|
-
*/
|
|
53
|
-
component: PropTypes.elementType,
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @ignore
|
|
57
|
-
*/
|
|
58
|
-
sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
|
|
59
|
-
} : void 0;
|
|
60
35
|
return Box;
|
|
61
36
|
}
|
package/modern/createStyled.js
CHANGED
|
@@ -140,7 +140,9 @@ export default function createStyled(input = {}) {
|
|
|
140
140
|
if (styleOverrides) {
|
|
141
141
|
const resolvedStyleOverrides = {};
|
|
142
142
|
Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
|
|
143
|
-
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props
|
|
143
|
+
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
|
|
144
|
+
theme
|
|
145
|
+
})) : slotStyle;
|
|
144
146
|
});
|
|
145
147
|
return overridesResolver(props, resolvedStyleOverrides);
|
|
146
148
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
4
|
-
const _excluded = ["colorSchemes"]
|
|
5
|
-
_excluded2 = ["colorSchemes"],
|
|
6
|
-
_excluded3 = ["components"];
|
|
4
|
+
const _excluded = ["colorSchemes", "components"];
|
|
7
5
|
import * as React from 'react';
|
|
8
6
|
import PropTypes from 'prop-types';
|
|
9
|
-
import { GlobalStyles } from '@mui/styled-engine';
|
|
10
7
|
import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
11
|
-
import
|
|
12
|
-
import createBreakpoints from '../createTheme/createBreakpoints';
|
|
8
|
+
import { GlobalStyles } from '@mui/styled-engine';
|
|
13
9
|
import cssVarsParser from './cssVarsParser';
|
|
14
10
|
import ThemeProvider from '../ThemeProvider';
|
|
15
11
|
import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
@@ -20,7 +16,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
20
16
|
export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
21
17
|
export default function createCssVarsProvider(options) {
|
|
22
18
|
const {
|
|
23
|
-
theme:
|
|
19
|
+
theme: defaultTheme = {},
|
|
24
20
|
defaultMode: desisgnSystemMode = 'light',
|
|
25
21
|
defaultColorScheme: designSystemColorScheme,
|
|
26
22
|
disableTransitionOnChange: designSystemTransitionOnChange = false,
|
|
@@ -29,10 +25,8 @@ export default function createCssVarsProvider(options) {
|
|
|
29
25
|
shouldSkipGeneratingVar,
|
|
30
26
|
resolveTheme
|
|
31
27
|
} = options;
|
|
32
|
-
const systemSpacing = createSpacing(baseTheme.spacing);
|
|
33
|
-
const systemBreakpoints = createBreakpoints(baseTheme.breakpoints ?? {});
|
|
34
28
|
|
|
35
|
-
if (!
|
|
29
|
+
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme?.light] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme?.dark]) {
|
|
36
30
|
console.error(`MUI: \`${designSystemColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
37
31
|
}
|
|
38
32
|
|
|
@@ -50,7 +44,7 @@ export default function createCssVarsProvider(options) {
|
|
|
50
44
|
|
|
51
45
|
function CssVarsProvider({
|
|
52
46
|
children,
|
|
53
|
-
theme: themeProp =
|
|
47
|
+
theme: themeProp = defaultTheme,
|
|
54
48
|
prefix = designSystemPrefix,
|
|
55
49
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
56
50
|
attribute = DEFAULT_ATTRIBUTE,
|
|
@@ -59,25 +53,14 @@ export default function createCssVarsProvider(options) {
|
|
|
59
53
|
disableTransitionOnChange = designSystemTransitionOnChange,
|
|
60
54
|
enableColorScheme = designSystemEnableColorScheme
|
|
61
55
|
}) {
|
|
62
|
-
const
|
|
63
|
-
colorSchemes: baseColorSchemes = {}
|
|
64
|
-
} = baseTheme,
|
|
65
|
-
restBaseTheme = _objectWithoutPropertiesLoose(baseTheme, _excluded);
|
|
56
|
+
const hasMounted = React.useRef(false);
|
|
66
57
|
|
|
67
58
|
const {
|
|
68
|
-
colorSchemes
|
|
69
|
-
} = themeProp,
|
|
70
|
-
restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded2);
|
|
71
|
-
|
|
72
|
-
const hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
|
|
73
|
-
|
|
74
|
-
let _deepmerge = deepmerge(restBaseTheme, restThemeProp),
|
|
75
|
-
{
|
|
59
|
+
colorSchemes = {},
|
|
76
60
|
components = {}
|
|
77
|
-
} =
|
|
78
|
-
|
|
61
|
+
} = themeProp,
|
|
62
|
+
restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
|
|
79
63
|
|
|
80
|
-
const colorSchemes = deepmerge(baseColorSchemes, colorSchemesProp);
|
|
81
64
|
const allColorSchemes = Object.keys(colorSchemes);
|
|
82
65
|
const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
83
66
|
const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
@@ -111,22 +94,21 @@ export default function createCssVarsProvider(options) {
|
|
|
111
94
|
return colorScheme;
|
|
112
95
|
})();
|
|
113
96
|
|
|
97
|
+
let theme = restThemeProp;
|
|
114
98
|
const {
|
|
115
99
|
css: rootCss,
|
|
116
100
|
vars: rootVars,
|
|
117
101
|
parsedTheme
|
|
118
|
-
} = cssVarsParser(
|
|
102
|
+
} = cssVarsParser(theme, {
|
|
119
103
|
prefix,
|
|
120
104
|
basePrefix: designSystemPrefix,
|
|
121
105
|
shouldSkipGeneratingVar
|
|
122
106
|
});
|
|
123
|
-
|
|
107
|
+
theme = _extends({}, parsedTheme, {
|
|
124
108
|
components,
|
|
125
109
|
colorSchemes,
|
|
126
110
|
prefix,
|
|
127
111
|
vars: rootVars,
|
|
128
|
-
spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
|
|
129
|
-
breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
|
|
130
112
|
getCssVar: createGetCssVar(prefix)
|
|
131
113
|
});
|
|
132
114
|
const styleSheet = {};
|
|
@@ -140,10 +122,16 @@ export default function createCssVarsProvider(options) {
|
|
|
140
122
|
basePrefix: designSystemPrefix,
|
|
141
123
|
shouldSkipGeneratingVar
|
|
142
124
|
});
|
|
143
|
-
|
|
125
|
+
theme.vars = deepmerge(theme.vars, vars);
|
|
144
126
|
|
|
145
127
|
if (key === resolvedColorScheme) {
|
|
146
|
-
|
|
128
|
+
theme = _extends({}, theme, parsedScheme);
|
|
129
|
+
|
|
130
|
+
if (theme.palette) {
|
|
131
|
+
// assign runtime mode & colorScheme
|
|
132
|
+
theme.palette.mode = mode;
|
|
133
|
+
theme.palette.colorScheme = resolvedColorScheme;
|
|
134
|
+
}
|
|
147
135
|
}
|
|
148
136
|
|
|
149
137
|
const resolvedDefaultColorScheme = (() => {
|
|
@@ -230,7 +218,7 @@ export default function createCssVarsProvider(options) {
|
|
|
230
218
|
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
231
219
|
styles: styleSheet
|
|
232
220
|
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
233
|
-
theme: resolveTheme ? resolveTheme(
|
|
221
|
+
theme: resolveTheme ? resolveTheme(theme) : theme,
|
|
234
222
|
children: children
|
|
235
223
|
})]
|
|
236
224
|
});
|