@mui/system 5.6.3 → 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.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.6.4
4
+
5
+ <!-- generated comparing v5.6.3..master -->
6
+
7
+ _May 2, 2022_
8
+
9
+ A big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 💅 5 Material UI components were updated to support CSS variables by @ZeeshanTamboli & @vicasas
12
+ - And more 🐛 bug fixes and 📚 improvements.
13
+
14
+ ### `@mui/material@5.6.4`
15
+
16
+ - &#8203;<!-- 37 -->[Accordion] Add support for CSS variables (#32542) @ZeeshanTamboli
17
+ - &#8203;<!-- 36 -->[AvatarGroup] Add support for CSS variables (#32507) @vicasas
18
+ - &#8203;<!-- 35 -->[Badge] Add support for CSS variables (#32516) @vicasas
19
+ - &#8203;<!-- 34 -->[BottomNavigation] Add support for CSS variables (#32517) @vicasas
20
+ - &#8203;<!-- 33 -->[CircularProgress] Add support for CSS variables (#32543) @ZeeshanTamboli
21
+ - &#8203;<!-- 07 -->[FilledInput] Fix type error from undefined `color` (#32258) @hbjORbj
22
+ - &#8203;<!-- 02 -->[l10n] Fix typo in csCZ translation of Pagination component (#32509) @Martin005
23
+ - &#8203;<!-- 01 -->[Tabs] Fix `TabIndicatorProps` prop missing `sx` prop (#32503) @b-novikov-ipersonality
24
+
25
+ ### `@mui/codemod@5.6.4`
26
+
27
+ - &#8203;<!-- 32 -->[codemod] Leave numeric arguments to breakpoints functions unchanged (#32426) @ryancogswell
28
+ - &#8203;<!-- 31 -->[codemod] Allow for line breaks within theme.spacing parentheses (#32432) @ryancogswell
29
+
30
+ ### `@mui/joy@5.0.0-alpha.26`
31
+
32
+ - &#8203;<!-- 06 -->[Joy] Miscellaneous fixes (#32541) @siriwatknp
33
+ - &#8203;<!-- 05 -->[Joy] Add `extendSxProp` to Link (#32505) @siriwatknp
34
+ - &#8203;<!-- 04 -->[Joy] Rename variants (#32489) @siriwatknp
35
+ - &#8203;<!-- 03 -->[Joy] Add `extendTheme` (#32450) @siriwatknp
36
+
37
+ ### Docs
38
+
39
+ - &#8203;<!-- 30 -->[docs] SEO fixes (#32515) @oliviertassinari
40
+ - &#8203;<!-- 29 -->[docs] Replace `Overriding nested component styles` anchor link with text (#32487) @ZeeshanTamboli
41
+ - &#8203;<!-- 28 -->[docs] Update the list of external domains (#32514) @oliviertassinari
42
+ - &#8203;<!-- 27 -->[docs] Update Material UI code snippets for React 18 (#32361) @samuelsycamore
43
+ - &#8203;<!-- 26 -->[docs] Base TextareaAutosize style revisions and final review (#32481) @samuelsycamore
44
+ - &#8203;<!-- 25 -->[docs] Base ClickAwayListener style revisions and final review (#32156) @samuelsycamore
45
+ - &#8203;<!-- 24 -->[docs] Base Button style revisions and final review (#32380) @samuelsycamore
46
+ - &#8203;<!-- 23 -->[docs] Base NoSsr style revisions and final review (#32254) @samuelsycamore
47
+ - &#8203;<!-- 22 -->[docs] Correctly capitalize Ctrl @oliviertassinari
48
+ - &#8203;<!-- 21 -->[docs] Fix styling in `Basic Popper` demo on the MUI Base docs (#32488) @ZeeshanTamboli
49
+ - &#8203;<!-- 20 -->[docs] Add "Overview" page to Base docs (#32310) @samuelsycamore
50
+ - &#8203;<!-- 19 -->[docs] Add copy button to code block (#32390) @siriwatknp
51
+ - &#8203;<!-- 18 -->[docs] Base Tabs style revisions and final review (#32423) @samuelsycamore
52
+ - &#8203;<!-- 17 -->[docs] Base Popper style revisions and final review (#32412) @samuelsycamore
53
+ - &#8203;<!-- 16 -->[docs] Improve sidenav for MUI X (#32435) @oliviertassinari
54
+ - &#8203;<!-- 15 -->[docs] Don't redirect on deploy preview (#32399) @m4theushw
55
+ - &#8203;<!-- 14 -->[docs] A few SEO fixes (#32431) @oliviertassinari
56
+ - &#8203;<!-- 13 -->[docs] Update links to the new Group & Pivot pages (#32410) @flaviendelangle
57
+ - &#8203;<!-- 12 -->[docs] Support callouts (#32402) @siriwatknp
58
+ - &#8203;<!-- 11 -->[docs] Fix import path in the Snackbar article #32462 @mongolyy
59
+ - &#8203;<!-- 10 -->[docs] Fix grammar mistake in shadows.md (#32454) @HexM7
60
+ - &#8203;<!-- 09 -->[docs] Improve unstyled button docs (#32429) @oliviertassinari
61
+
62
+ ### Core
63
+
64
+ - &#8203;<!-- 08 -->[experiment] Add template for testing Material UI components with CSS variables (#32500) @siriwatknp
65
+
66
+ All contributors of this release in alphabetical order: @b-novikov-ipersonality, @flaviendelangle, @hbjORbj, @HexM7, @m4theushw, @Martin005, @mongolyy, @oliviertassinari, @ryancogswell, @samuelsycamore, @siriwatknp, @vicasas, @ZeeshanTamboli
67
+
3
68
  ## 5.6.3
4
69
 
5
70
  <!-- generated comparing v5.6.2..master -->
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/createStyled.js CHANGED
@@ -160,7 +160,9 @@ function createStyled(input = {}) {
160
160
  if (styleOverrides) {
161
161
  const resolvedStyleOverrides = {};
162
162
  Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
163
- resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
163
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle((0, _extends2.default)({}, props, {
164
+ theme
165
+ })) : slotStyle;
164
166
  });
165
167
  return overridesResolver(props, resolvedStyleOverrides);
166
168
  }
@@ -1,10 +1,10 @@
1
- export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
- export declare type SpacingArgument = number | string;
3
- export interface Spacing {
4
- (): string;
5
- (value: number): string;
6
- (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
- (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
- (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
- }
10
- export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
1
+ export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
+ export declare type SpacingArgument = number | string;
3
+ export interface Spacing {
4
+ (): string;
5
+ (value: number): string;
6
+ (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
+ (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
+ (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
+ }
10
+ export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
@@ -20,10 +20,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
20
20
 
21
21
  var _styledEngine = require("@mui/styled-engine");
22
22
 
23
- var _createSpacing = _interopRequireDefault(require("../createTheme/createSpacing"));
24
-
25
- var _createBreakpoints = _interopRequireDefault(require("../createTheme/createBreakpoints"));
26
-
27
23
  var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
28
24
 
29
25
  var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
@@ -36,9 +32,7 @@ var _createGetCssVar = _interopRequireDefault(require("./createGetCssVar"));
36
32
 
37
33
  var _jsxRuntime = require("react/jsx-runtime");
38
34
 
39
- const _excluded = ["colorSchemes"],
40
- _excluded2 = ["colorSchemes"],
41
- _excluded3 = ["components"];
35
+ const _excluded = ["colorSchemes", "components"];
42
36
 
43
37
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
44
38
 
@@ -48,10 +42,8 @@ const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transit
48
42
  exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
49
43
 
50
44
  function createCssVarsProvider(options) {
51
- var _baseTheme$breakpoint;
52
-
53
45
  const {
54
- theme: baseTheme = {},
46
+ theme: defaultTheme = {},
55
47
  defaultMode: desisgnSystemMode = 'light',
56
48
  defaultColorScheme: designSystemColorScheme,
57
49
  disableTransitionOnChange: designSystemTransitionOnChange = false,
@@ -60,10 +52,8 @@ function createCssVarsProvider(options) {
60
52
  shouldSkipGeneratingVar,
61
53
  resolveTheme
62
54
  } = options;
63
- const systemSpacing = (0, _createSpacing.default)(baseTheme.spacing);
64
- const systemBreakpoints = (0, _createBreakpoints.default)((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
65
55
 
66
- if (!baseTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !baseTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
56
+ 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]) {
67
57
  console.error(`MUI: \`${designSystemColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
68
58
  }
69
59
 
@@ -81,7 +71,7 @@ function createCssVarsProvider(options) {
81
71
 
82
72
  function CssVarsProvider({
83
73
  children,
84
- theme: themeProp = {},
74
+ theme: themeProp = defaultTheme,
85
75
  prefix = designSystemPrefix,
86
76
  modeStorageKey = _getInitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
87
77
  attribute = _getInitColorSchemeScript.DEFAULT_ATTRIBUTE,
@@ -90,23 +80,12 @@ function createCssVarsProvider(options) {
90
80
  disableTransitionOnChange = designSystemTransitionOnChange,
91
81
  enableColorScheme = designSystemEnableColorScheme
92
82
  }) {
83
+ const hasMounted = React.useRef(false);
93
84
  const {
94
- colorSchemes: baseColorSchemes = {}
95
- } = baseTheme,
96
- restBaseTheme = (0, _objectWithoutPropertiesLoose2.default)(baseTheme, _excluded);
97
- const {
98
- colorSchemes: colorSchemesProp = {}
99
- } = themeProp,
100
- restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded2);
101
- const hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
102
-
103
- let _deepmerge = (0, _utils.deepmerge)(restBaseTheme, restThemeProp),
104
- {
85
+ colorSchemes = {},
105
86
  components = {}
106
- } = _deepmerge,
107
- mergedTheme = (0, _objectWithoutPropertiesLoose2.default)(_deepmerge, _excluded3);
108
-
109
- const colorSchemes = (0, _utils.deepmerge)(baseColorSchemes, colorSchemesProp);
87
+ } = themeProp,
88
+ restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded);
110
89
  const allColorSchemes = Object.keys(colorSchemes);
111
90
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
112
91
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -140,22 +119,21 @@ function createCssVarsProvider(options) {
140
119
  return colorScheme;
141
120
  })();
142
121
 
122
+ let theme = restThemeProp;
143
123
  const {
144
124
  css: rootCss,
145
125
  vars: rootVars,
146
126
  parsedTheme
147
- } = (0, _cssVarsParser.default)(mergedTheme, {
127
+ } = (0, _cssVarsParser.default)(theme, {
148
128
  prefix,
149
129
  basePrefix: designSystemPrefix,
150
130
  shouldSkipGeneratingVar
151
131
  });
152
- mergedTheme = (0, _extends2.default)({}, parsedTheme, {
132
+ theme = (0, _extends2.default)({}, parsedTheme, {
153
133
  components,
154
134
  colorSchemes,
155
135
  prefix,
156
136
  vars: rootVars,
157
- spacing: themeProp.spacing ? (0, _createSpacing.default)(themeProp.spacing) : systemSpacing,
158
- breakpoints: themeProp.breakpoints ? (0, _createBreakpoints.default)(themeProp.breakpoints) : systemBreakpoints,
159
137
  getCssVar: (0, _createGetCssVar.default)(prefix)
160
138
  });
161
139
  const styleSheet = {};
@@ -169,10 +147,16 @@ function createCssVarsProvider(options) {
169
147
  basePrefix: designSystemPrefix,
170
148
  shouldSkipGeneratingVar
171
149
  });
172
- mergedTheme.vars = (0, _utils.deepmerge)(mergedTheme.vars, vars);
150
+ theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
173
151
 
174
152
  if (key === resolvedColorScheme) {
175
- mergedTheme = (0, _extends2.default)({}, mergedTheme, parsedScheme);
153
+ theme = (0, _extends2.default)({}, theme, parsedScheme);
154
+
155
+ if (theme.palette) {
156
+ // assign runtime mode & colorScheme
157
+ theme.palette.mode = mode;
158
+ theme.palette.colorScheme = resolvedColorScheme;
159
+ }
176
160
  }
177
161
 
178
162
  const resolvedDefaultColorScheme = (() => {
@@ -259,7 +243,7 @@ function createCssVarsProvider(options) {
259
243
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
260
244
  styles: styleSheet
261
245
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
262
- theme: resolveTheme ? resolveTheme(mergedTheme) : mergedTheme,
246
+ theme: resolveTheme ? resolveTheme(theme) : theme,
263
247
  children: children
264
248
  })]
265
249
  });
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,5 +1,5 @@
1
- /**
2
- * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
3
- * and they does not need to remember the prefix (defined once).
4
- */
5
- export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...vars: (T | AdditionalVars)[]) => string;
1
+ /**
2
+ * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
3
+ * and they does not need to remember the prefix (defined once).
4
+ */
5
+ export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...vars: (T | AdditionalVars)[]) => string;
@@ -1,70 +1,70 @@
1
- declare type NestedRecord<V = any> = {
2
- [k: string | number]: NestedRecord<V> | V;
3
- };
4
- /**
5
- * This function create an object from keys, value and then assign to target
6
- *
7
- * @param {Object} obj : the target object to be assigned
8
- * @param {string[]} keys
9
- * @param {string | number} value
10
- *
11
- * @example
12
- * const source = {}
13
- * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
- * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
- *
16
- * @example
17
- * const source = { palette: { primary: 'var(--palette-primary)' } }
18
- * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
- * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
- */
21
- export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value) => void;
22
- /**
23
- *
24
- * @param {Object} obj : source object
25
- * @param {Function} callback : a function that will be called when
26
- * - the deepest key in source object is reached
27
- * - the value of the deepest key is NOT `undefined` | `null`
28
- *
29
- * @example
30
- * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
- * // ['palette', 'primary', 'main'] '#000000'
32
- */
33
- export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, scope: Record<string, string | number>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
- /**
35
- * a function that parse theme and return { css, vars }
36
- *
37
- * @param {Object} theme
38
- * @param {{
39
- * prefix?: string,
40
- * basePrefix?: string,
41
- * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
- * }} options.
43
- * `basePrefix`: defined by design system.
44
- * `prefix`: defined by application
45
- *
46
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
- *
48
- * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
49
- *
50
- * @example
51
- * const { css, vars, parsedTheme } = parser({
52
- * fontSize: 12,
53
- * lineHeight: 1.2,
54
- * palette: { primary: { 500: 'var(--color)' } }
55
- * }, { prefix: 'foo' })
56
- *
57
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
- */
61
- export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
- prefix?: string;
63
- basePrefix?: string;
64
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
- }): {
66
- css: NestedRecord<string>;
67
- vars: NestedRecord<string>;
68
- parsedTheme: T;
69
- };
70
- export {};
1
+ declare type NestedRecord<V = any> = {
2
+ [k: string | number]: NestedRecord<V> | V;
3
+ };
4
+ /**
5
+ * This function create an object from keys, value and then assign to target
6
+ *
7
+ * @param {Object} obj : the target object to be assigned
8
+ * @param {string[]} keys
9
+ * @param {string | number} value
10
+ *
11
+ * @example
12
+ * const source = {}
13
+ * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
+ *
16
+ * @example
17
+ * const source = { palette: { primary: 'var(--palette-primary)' } }
18
+ * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
+ */
21
+ export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
22
+ /**
23
+ *
24
+ * @param {Object} obj : source object
25
+ * @param {Function} callback : a function that will be called when
26
+ * - the deepest key in source object is reached
27
+ * - the value of the deepest key is NOT `undefined` | `null`
28
+ *
29
+ * @example
30
+ * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
+ * // ['palette', 'primary', 'main'] '#000000'
32
+ */
33
+ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
+ /**
35
+ * a function that parse theme and return { css, vars }
36
+ *
37
+ * @param {Object} theme
38
+ * @param {{
39
+ * prefix?: string,
40
+ * basePrefix?: string,
41
+ * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
+ * }} options.
43
+ * `basePrefix`: defined by design system.
44
+ * `prefix`: defined by application
45
+ *
46
+ * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
+ *
48
+ * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
49
+ *
50
+ * @example
51
+ * const { css, vars, parsedTheme } = parser({
52
+ * fontSize: 12,
53
+ * lineHeight: 1.2,
54
+ * palette: { primary: { 500: 'var(--color)' } }
55
+ * }, { prefix: 'foo' })
56
+ *
57
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
+ * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
+ */
61
+ export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
+ prefix?: string;
63
+ basePrefix?: string;
64
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
+ }): {
66
+ css: NestedRecord<string>;
67
+ vars: NestedRecord<string>;
68
+ parsedTheme: T;
69
+ };
70
+ export {};
@@ -24,16 +24,18 @@ exports.walkObjectDeep = void 0;
24
24
  * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
25
25
  * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
26
26
  */
27
- const assignNestedKeys = (obj, keys, value) => {
27
+ const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
28
28
  let temp = obj;
29
29
  keys.forEach((k, index) => {
30
30
  if (index === keys.length - 1) {
31
- if (temp && typeof temp === 'object') {
31
+ if (Array.isArray(temp)) {
32
+ temp[Number(k)] = value;
33
+ } else if (temp && typeof temp === 'object') {
32
34
  temp[k] = value;
33
35
  }
34
36
  } else if (temp && typeof temp === 'object') {
35
37
  if (!temp[k]) {
36
- temp[k] = {};
38
+ temp[k] = arrayKeys.includes(k) ? [] : {};
37
39
  }
38
40
 
39
41
  temp = temp[k];
@@ -56,14 +58,14 @@ const assignNestedKeys = (obj, keys, value) => {
56
58
  exports.assignNestedKeys = assignNestedKeys;
57
59
 
58
60
  const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
59
- function recurse(object, parentKeys = []) {
61
+ function recurse(object, parentKeys = [], arrayKeys = []) {
60
62
  Object.entries(object).forEach(([key, value]) => {
61
63
  if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {
62
64
  if (value !== undefined && value !== null) {
63
65
  if (typeof value === 'object' && Object.keys(value).length > 0) {
64
- recurse(value, [...parentKeys, key]);
66
+ recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);
65
67
  } else {
66
- callback([...parentKeys, key], value, object);
68
+ callback([...parentKeys, key], value, arrayKeys);
67
69
  }
68
70
  }
69
71
  }
@@ -132,7 +134,7 @@ function cssVarsParser(theme, options) {
132
134
  const css = {};
133
135
  const vars = {};
134
136
  const parsedTheme = {};
135
- walkObjectDeep(theme, (keys, value) => {
137
+ walkObjectDeep(theme, (keys, value, arrayKeys) => {
136
138
  if (typeof value === 'string' || typeof value === 'number') {
137
139
  if (typeof value === 'string' && value.match(/var\(\s*--/)) {
138
140
  // for CSS variable, apply prefix or remove basePrefix from the variable
@@ -150,11 +152,11 @@ function cssVarsParser(theme, options) {
150
152
  Object.assign(css, {
151
153
  [cssVar]: getCssValue(keys, value)
152
154
  });
153
- assignNestedKeys(vars, keys, `var(${cssVar})`);
155
+ assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
154
156
  }
155
157
  }
156
158
 
157
- assignNestedKeys(parsedTheme, keys, value);
159
+ assignNestedKeys(parsedTheme, keys, value, arrayKeys);
158
160
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
159
161
  );
160
162
  return {
@@ -1,12 +1,12 @@
1
- /// <reference types="react" />
2
- export declare const DEFAULT_MODE_STORAGE_KEY = "mui-mode";
3
- export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "mui-color-scheme";
4
- export declare const DEFAULT_ATTRIBUTE = "data-mui-color-scheme";
5
- export default function getInitColorSchemeScript(options?: {
6
- enableSystem?: boolean;
7
- defaultLightColorScheme?: string;
8
- defaultDarkColorScheme?: string;
9
- modeStorageKey?: string;
10
- colorSchemeStorageKey?: string;
11
- attribute?: string;
12
- }): JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const DEFAULT_MODE_STORAGE_KEY = "mui-mode";
3
+ export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "mui-color-scheme";
4
+ export declare const DEFAULT_ATTRIBUTE = "data-mui-color-scheme";
5
+ export default function getInitColorSchemeScript(options?: {
6
+ enableSystem?: boolean;
7
+ defaultLightColorScheme?: string;
8
+ defaultDarkColorScheme?: string;
9
+ modeStorageKey?: string;
10
+ colorSchemeStorageKey?: string;
11
+ attribute?: string;
12
+ }): JSX.Element;
@@ -1,2 +1,2 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult } from './createCssVarsProvider';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult } from './createCssVarsProvider';
@@ -1,50 +1,50 @@
1
- export declare type Mode = 'light' | 'dark' | 'system';
2
- export declare 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 declare 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
- export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: {
44
- defaultLightColorScheme: SupportedColorScheme;
45
- defaultDarkColorScheme: SupportedColorScheme;
46
- supportedColorSchemes: Array<SupportedColorScheme>;
47
- defaultMode?: Mode;
48
- modeStorageKey?: string;
49
- colorSchemeStorageKey?: string;
50
- }): Result<SupportedColorScheme>;
1
+ export declare type Mode = 'light' | 'dark' | 'system';
2
+ export declare 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 declare 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
+ export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: {
44
+ defaultLightColorScheme: SupportedColorScheme;
45
+ defaultDarkColorScheme: SupportedColorScheme;
46
+ supportedColorSchemes: Array<SupportedColorScheme>;
47
+ defaultMode?: Mode;
48
+ modeStorageKey?: string;
49
+ colorSchemeStorageKey?: string;
50
+ }): Result<SupportedColorScheme>;
@@ -142,7 +142,9 @@ export default function createStyled(input = {}) {
142
142
  if (styleOverrides) {
143
143
  const resolvedStyleOverrides = {};
144
144
  Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
145
- resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
145
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
146
+ theme
147
+ })) : slotStyle;
146
148
  });
147
149
  return overridesResolver(props, resolvedStyleOverrides);
148
150
  }
@@ -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 createSpacing from '../createTheme/createSpacing';
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';
@@ -19,10 +15,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
19
15
  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
- var _baseTheme$breakpoint;
23
-
24
18
  const {
25
- theme: baseTheme = {},
19
+ theme: defaultTheme = {},
26
20
  defaultMode: desisgnSystemMode = 'light',
27
21
  defaultColorScheme: designSystemColorScheme,
28
22
  disableTransitionOnChange: designSystemTransitionOnChange = false,
@@ -31,10 +25,8 @@ export default function createCssVarsProvider(options) {
31
25
  shouldSkipGeneratingVar,
32
26
  resolveTheme
33
27
  } = options;
34
- const systemSpacing = createSpacing(baseTheme.spacing);
35
- const systemBreakpoints = createBreakpoints((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
36
28
 
37
- if (!baseTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !baseTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
29
+ 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]) {
38
30
  console.error(`MUI: \`${designSystemColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
39
31
  }
40
32
 
@@ -52,7 +44,7 @@ export default function createCssVarsProvider(options) {
52
44
 
53
45
  function CssVarsProvider({
54
46
  children,
55
- theme: themeProp = {},
47
+ theme: themeProp = defaultTheme,
56
48
  prefix = designSystemPrefix,
57
49
  modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
58
50
  attribute = DEFAULT_ATTRIBUTE,
@@ -61,25 +53,14 @@ export default function createCssVarsProvider(options) {
61
53
  disableTransitionOnChange = designSystemTransitionOnChange,
62
54
  enableColorScheme = designSystemEnableColorScheme
63
55
  }) {
64
- const {
65
- colorSchemes: baseColorSchemes = {}
66
- } = baseTheme,
67
- restBaseTheme = _objectWithoutPropertiesLoose(baseTheme, _excluded);
56
+ const hasMounted = React.useRef(false);
68
57
 
69
58
  const {
70
- colorSchemes: colorSchemesProp = {}
71
- } = themeProp,
72
- restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded2);
73
-
74
- const hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
75
-
76
- let _deepmerge = deepmerge(restBaseTheme, restThemeProp),
77
- {
59
+ colorSchemes = {},
78
60
  components = {}
79
- } = _deepmerge,
80
- mergedTheme = _objectWithoutPropertiesLoose(_deepmerge, _excluded3);
61
+ } = themeProp,
62
+ restThemeProp = _objectWithoutPropertiesLoose(themeProp, _excluded);
81
63
 
82
- const colorSchemes = deepmerge(baseColorSchemes, colorSchemesProp);
83
64
  const allColorSchemes = Object.keys(colorSchemes);
84
65
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
85
66
  const defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
@@ -113,22 +94,21 @@ export default function createCssVarsProvider(options) {
113
94
  return colorScheme;
114
95
  })();
115
96
 
97
+ let theme = restThemeProp;
116
98
  const {
117
99
  css: rootCss,
118
100
  vars: rootVars,
119
101
  parsedTheme
120
- } = cssVarsParser(mergedTheme, {
102
+ } = cssVarsParser(theme, {
121
103
  prefix,
122
104
  basePrefix: designSystemPrefix,
123
105
  shouldSkipGeneratingVar
124
106
  });
125
- mergedTheme = _extends({}, parsedTheme, {
107
+ theme = _extends({}, parsedTheme, {
126
108
  components,
127
109
  colorSchemes,
128
110
  prefix,
129
111
  vars: rootVars,
130
- spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
131
- breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
132
112
  getCssVar: createGetCssVar(prefix)
133
113
  });
134
114
  const styleSheet = {};
@@ -142,10 +122,16 @@ export default function createCssVarsProvider(options) {
142
122
  basePrefix: designSystemPrefix,
143
123
  shouldSkipGeneratingVar
144
124
  });
145
- mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
125
+ theme.vars = deepmerge(theme.vars, vars);
146
126
 
147
127
  if (key === resolvedColorScheme) {
148
- mergedTheme = _extends({}, mergedTheme, parsedScheme);
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
+ }
149
135
  }
150
136
 
151
137
  const resolvedDefaultColorScheme = (() => {
@@ -232,7 +218,7 @@ export default function createCssVarsProvider(options) {
232
218
  }), /*#__PURE__*/_jsx(GlobalStyles, {
233
219
  styles: styleSheet
234
220
  }), /*#__PURE__*/_jsx(ThemeProvider, {
235
- theme: resolveTheme ? resolveTheme(mergedTheme) : mergedTheme,
221
+ theme: resolveTheme ? resolveTheme(theme) : theme,
236
222
  children: children
237
223
  })]
238
224
  });
@@ -15,16 +15,18 @@
15
15
  * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
16
16
  * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
17
17
  */
18
- export const assignNestedKeys = (obj, keys, value) => {
18
+ export const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
19
19
  let temp = obj;
20
20
  keys.forEach((k, index) => {
21
21
  if (index === keys.length - 1) {
22
- if (temp && typeof temp === 'object') {
22
+ if (Array.isArray(temp)) {
23
+ temp[Number(k)] = value;
24
+ } else if (temp && typeof temp === 'object') {
23
25
  temp[k] = value;
24
26
  }
25
27
  } else if (temp && typeof temp === 'object') {
26
28
  if (!temp[k]) {
27
- temp[k] = {};
29
+ temp[k] = arrayKeys.includes(k) ? [] : {};
28
30
  }
29
31
 
30
32
  temp = temp[k];
@@ -44,14 +46,14 @@ export const assignNestedKeys = (obj, keys, value) => {
44
46
  */
45
47
 
46
48
  export const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
47
- function recurse(object, parentKeys = []) {
49
+ function recurse(object, parentKeys = [], arrayKeys = []) {
48
50
  Object.entries(object).forEach(([key, value]) => {
49
51
  if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {
50
52
  if (value !== undefined && value !== null) {
51
53
  if (typeof value === 'object' && Object.keys(value).length > 0) {
52
- recurse(value, [...parentKeys, key]);
54
+ recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);
53
55
  } else {
54
- callback([...parentKeys, key], value, object);
56
+ callback([...parentKeys, key], value, arrayKeys);
55
57
  }
56
58
  }
57
59
  }
@@ -118,7 +120,7 @@ export default function cssVarsParser(theme, options) {
118
120
  const css = {};
119
121
  const vars = {};
120
122
  const parsedTheme = {};
121
- walkObjectDeep(theme, (keys, value) => {
123
+ walkObjectDeep(theme, (keys, value, arrayKeys) => {
122
124
  if (typeof value === 'string' || typeof value === 'number') {
123
125
  if (typeof value === 'string' && value.match(/var\(\s*--/)) {
124
126
  // for CSS variable, apply prefix or remove basePrefix from the variable
@@ -136,11 +138,11 @@ export default function cssVarsParser(theme, options) {
136
138
  Object.assign(css, {
137
139
  [cssVar]: getCssValue(keys, value)
138
140
  });
139
- assignNestedKeys(vars, keys, `var(${cssVar})`);
141
+ assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
140
142
  }
141
143
  }
142
144
 
143
- assignNestedKeys(parsedTheme, keys, value);
145
+ assignNestedKeys(parsedTheme, keys, value, arrayKeys);
144
146
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
145
147
  );
146
148
  return {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.3
1
+ /** @license MUI v5.6.4
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -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) : slotStyle;
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 createSpacing from '../createTheme/createSpacing';
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
- baseTheme = _options$theme === void 0 ? {} : _options$theme,
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 (!baseTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !baseTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
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 ? {} : _ref$theme,
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
- colorSchemesProp = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
80
- restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes"]);
81
-
82
- var hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
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 _cssVarsParser = cssVarsParser(mergedTheme, {
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
- mergedTheme = _extends({}, parsedTheme, {
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
- mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
141
+ theme.vars = deepmerge(theme.vars, vars);
157
142
 
158
143
  if (key === resolvedColorScheme) {
159
- mergedTheme = _extends({}, mergedTheme, parsedScheme);
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(mergedTheme) : mergedTheme,
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 (temp && _typeof(temp) === 'object') {
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, object);
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
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.3
1
+ /** @license MUI v5.6.4
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -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) : slotStyle;
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 createSpacing from '../createTheme/createSpacing';
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: baseTheme = {},
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 (!baseTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !baseTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme?.light] || typeof designSystemColorScheme === 'object' && !baseTheme.colorSchemes[designSystemColorScheme?.dark]) {
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: colorSchemesProp = {}
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
- } = _deepmerge,
78
- mergedTheme = _objectWithoutPropertiesLoose(_deepmerge, _excluded3);
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(mergedTheme, {
102
+ } = cssVarsParser(theme, {
119
103
  prefix,
120
104
  basePrefix: designSystemPrefix,
121
105
  shouldSkipGeneratingVar
122
106
  });
123
- mergedTheme = _extends({}, parsedTheme, {
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
- mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
125
+ theme.vars = deepmerge(theme.vars, vars);
144
126
 
145
127
  if (key === resolvedColorScheme) {
146
- mergedTheme = _extends({}, mergedTheme, parsedScheme);
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(mergedTheme) : mergedTheme,
221
+ theme: resolveTheme ? resolveTheme(theme) : theme,
234
222
  children: children
235
223
  })]
236
224
  });
@@ -15,16 +15,18 @@
15
15
  * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
16
16
  * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
17
17
  */
18
- export const assignNestedKeys = (obj, keys, value) => {
18
+ export const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
19
19
  let temp = obj;
20
20
  keys.forEach((k, index) => {
21
21
  if (index === keys.length - 1) {
22
- if (temp && typeof temp === 'object') {
22
+ if (Array.isArray(temp)) {
23
+ temp[Number(k)] = value;
24
+ } else if (temp && typeof temp === 'object') {
23
25
  temp[k] = value;
24
26
  }
25
27
  } else if (temp && typeof temp === 'object') {
26
28
  if (!temp[k]) {
27
- temp[k] = {};
29
+ temp[k] = arrayKeys.includes(k) ? [] : {};
28
30
  }
29
31
 
30
32
  temp = temp[k];
@@ -44,14 +46,14 @@ export const assignNestedKeys = (obj, keys, value) => {
44
46
  */
45
47
 
46
48
  export const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
47
- function recurse(object, parentKeys = []) {
49
+ function recurse(object, parentKeys = [], arrayKeys = []) {
48
50
  Object.entries(object).forEach(([key, value]) => {
49
51
  if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {
50
52
  if (value !== undefined && value !== null) {
51
53
  if (typeof value === 'object' && Object.keys(value).length > 0) {
52
- recurse(value, [...parentKeys, key]);
54
+ recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);
53
55
  } else {
54
- callback([...parentKeys, key], value, object);
56
+ callback([...parentKeys, key], value, arrayKeys);
55
57
  }
56
58
  }
57
59
  }
@@ -118,7 +120,7 @@ export default function cssVarsParser(theme, options) {
118
120
  const css = {};
119
121
  const vars = {};
120
122
  const parsedTheme = {};
121
- walkObjectDeep(theme, (keys, value) => {
123
+ walkObjectDeep(theme, (keys, value, arrayKeys) => {
122
124
  if (typeof value === 'string' || typeof value === 'number') {
123
125
  if (typeof value === 'string' && value.match(/var\(\s*--/)) {
124
126
  // for CSS variable, apply prefix or remove basePrefix from the variable
@@ -136,11 +138,11 @@ export default function cssVarsParser(theme, options) {
136
138
  Object.assign(css, {
137
139
  [cssVar]: getCssValue(keys, value)
138
140
  });
139
- assignNestedKeys(vars, keys, `var(${cssVar})`);
141
+ assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
140
142
  }
141
143
  }
142
144
 
143
- assignNestedKeys(parsedTheme, keys, value);
145
+ assignNestedKeys(parsedTheme, keys, value, arrayKeys);
144
146
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
145
147
  );
146
148
  return {
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.3
1
+ /** @license MUI v5.6.4
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.6.3",
3
+ "version": "5.6.4",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -1 +1 @@
1
- export {};
1
+ export {};