@mui/system 5.4.3 → 5.4.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.4.4
4
+
5
+ <!-- generated comparing v5.4.3..master -->
6
+
7
+ _Feb 28, 2022_
8
+
9
+ A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - ✨ New `Input` and `Sheet` components were added in the experimental Joy design system by @hbjORbj (#31124, #31086) @hbjORbj
12
+ - Several 🐛 bug fixes and 📚 documentation improvements
13
+
14
+ ### `@mui/material@5.4.4`
15
+
16
+ - &#8203;<!-- 28 -->[Autocomplete] Have Autocomplete with multiline textfield log a warning instead of an error (#30680) @iclaude3
17
+ - &#8203;<!-- 27 -->[Chip] Fix ellipsis when the children is too long (#31087) @PunitSoniME
18
+ - &#8203;<!-- 14 -->[Input] Export InputBase's classes from the classes const (#31186) @mnajdova
19
+ - &#8203;<!-- 29 -->[TextField] Fix Horizontal scroll when label too long (#31187) @RedHeadphone
20
+ - &#8203;<!-- 08 -->[styles] Fix typo in import error (#31167) @davwheat
21
+
22
+ ### `@mui/system@5.4.4`
23
+
24
+ - &#8203;<!-- 07 -->[system] Fix executing server-side Emotion component as function interpolation 2 (#31024) @Andarist
25
+ - &#8203;<!-- 06 -->[system] Fix sx prop types when CSS variables are used with nested selectors (#31163) @mnajdova
26
+ - &#8203;<!-- 05 -->[system] Fix `CssVarsProvider` theme mutation (#31148) @siriwatknp
27
+
28
+ ### `@mui/codemod@5.4.4`
29
+
30
+ - &#8203;<!-- 26 -->[codemods] Add v5.0.0/top-level-imports codemod (#31195) @greengiraffe
31
+
32
+ ### `@mui/base@5.0.0-alpha.70`
33
+
34
+ - &#8203;<!-- 31 -->[SelectUnstyled, MultiSelectUnstyled, ButtonUnstyled] Export additional types to make customization easier (#31172) @michaldudak
35
+
36
+ ### `@mui/joy@5.0.0-alpha.17`
37
+
38
+ - &#8203;<!-- 13 -->[Joy] Add nested list components (#31159) @siriwatknp
39
+ - &#8203;<!-- 12 -->[Joy] Improve color customization on `Switch` (#31137) @siriwatknp
40
+ - &#8203;<!-- 11 -->[Joy] Add `Sheet` component (#31124) @hbjORbj
41
+ - &#8203;<!-- 10 -->[Joy] add `Input` component (#31086) @siriwatknp
42
+ - &#8203;<!-- 09 -->[Joy] Fix Button missing slot type (#31166) @siriwatknp
43
+
44
+ ### Docs
45
+
46
+ - &#8203;<!-- 22 -->[docs] Fix 404 link to the blog (#31234) @oliviertassinari
47
+ - &#8203;<!-- 21 -->[docs] Use `material-ui` for product name (#31200) @siriwatknp
48
+ - &#8203;<!-- 20 -->[docs] Add Base installation page (#30969) @siriwatknp
49
+ - &#8203;<!-- 19 -->[docs] Use new Algolia app for new structure (#31178) @siriwatknp
50
+ - &#8203;<!-- 18 -->[docs] Typo in the `FormControl` API documentation (#31169) @bonellia
51
+ - &#8203;<!-- 17 -->[docs] Fix typo in Stack documentation (#31176) @adriancampos
52
+ - &#8203;<!-- 16 -->[docs] Update interoperability.md broken tailwind links (#31182) @robertwt7
53
+ - &#8203;<!-- 15 -->[docs] Add missing import into tss-react migration guide (#31162) @sviande
54
+ - &#8203;<!-- 03 -->[website] The role is filled (#31216) @oliviertassinari
55
+ - &#8203;<!-- 02 -->[website] Revise the row grouping blog post (#31101) @samuelsycamore
56
+ - &#8203;<!-- 01 -->[website] Fix a few SEO issues (#31150) @oliviertassinari
57
+
58
+ ### Core
59
+
60
+ - &#8203;<!-- 30 -->[core] Add group for the @fortawesome dependencies (#31193) @mnajdova
61
+ - &#8203;<!-- 25 -->[core] Update playwright docker to match the specified version (#31236) @siriwatknp
62
+ - &#8203;<!-- 24 -->[core] Remove parallel on buildTypes (#31189) @siriwatknp
63
+ - &#8203;<!-- 23 -->[core] Fix propTypes generation for optional any props (#31141) @m4theushw
64
+ - &#8203;<!-- 04 -->[Typescript] Remove variants deprecation (#31239) @siriwatknp
65
+
66
+ All contributors of this release in alphabetical order: @adriancampos, @Andarist, @bonellia, @davwheat, @greengiraffe, @hbjORbj, @iclaude3, @m4theushw, @michaldudak, @mnajdova, @oliviertassinari, @PunitSoniME, @RedHeadphone, @robertwt7, @samuelsycamore, @siriwatknp, @sviande
67
+
3
68
  ## 5.4.3
4
69
 
5
70
  <!-- generated comparing v5.4.2..master -->
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/createStyled.js CHANGED
@@ -192,7 +192,11 @@ function createStyled(input = {}) {
192
192
 
193
193
  transformedStyleArg = [...styleArg, ...placeholders];
194
194
  transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
195
- } else if (typeof styleArg === 'function') {
195
+ } else if (typeof styleArg === 'function' && // On the server emotion doesn't use React.forwardRef for creating components, so the created
196
+ // component stays as a function. This condition makes sure that we do not interpolate functions
197
+ // which are basically components used as a selectors.
198
+ // eslint-disable-next-line no-underscore-dangle
199
+ styleArg.__emotion_real !== styleArg) {
196
200
  // If the type is function, we need to define the default theme.
197
201
  transformedStyleArg = _ref2 => {
198
202
  let {
@@ -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;
@@ -9,7 +9,9 @@ export interface ColorSchemeContextValue<SupportedColorScheme extends string>
9
9
 
10
10
  export interface CssVarsProviderConfig<ColorScheme extends string> {
11
11
  /**
12
- * Design system default color scheme
12
+ * Design system default color scheme.
13
+ * - provides string if the design system has one default color scheme (either light or dark)
14
+ * - provides object if the design system has default light & dark color schemes
13
15
  */
14
16
  defaultColorScheme: ColorScheme | { light: ColorScheme; dark: ColorScheme };
15
17
  /**
@@ -41,6 +43,28 @@ export default function createCssVarsProvider<
41
43
  options: CssVarsProviderConfig<ColorScheme> & {
42
44
  /**
43
45
  * Design system default theme
46
+ *
47
+ * The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
48
+ * those object of the color scheme will be used when the color scheme is active.
49
+ *
50
+ * {
51
+ * colorSchemes: {
52
+ * light: { ...lightColorSchemeValues },
53
+ * dark: { ...darkColorSchemeValues }
54
+ * }
55
+ * }
56
+ *
57
+ * If colorScheme is 'light', the `lightColorSchemeValues` will be merged to theme as `{ ...theme, ...lightColorSchemeValues }`
58
+ * likewise, if colorScheme is 'dark', the `darkColorSchemeValues` will be merged to theme as `{ ...theme, ...darkColorSchemeValues }`
59
+ *
60
+ * !!! Don't provided the same keys as in colorSchemes to theme because they will be replaced internally when the selected colorScheme is calculated.
61
+ * Ex. {
62
+ * colorSchemes: {
63
+ * light: { palette: { ... } },
64
+ * dark: { palette: { ... } }
65
+ * },
66
+ * palette: { ... }, // This values will be replaced by the `palette` from the light | dark color scheme at runtime.
67
+ * }
44
68
  */
45
69
  theme: any;
46
70
  /**
@@ -54,8 +54,8 @@ function createCssVarsProvider(options) {
54
54
  theme: baseTheme = {},
55
55
  defaultMode: desisgnSystemMode = 'light',
56
56
  defaultColorScheme: designSystemColorScheme,
57
- disableTransitionOnChange = false,
58
- enableColorScheme = true,
57
+ disableTransitionOnChange: designSystemTransitionOnChange = false,
58
+ enableColorScheme: designSystemEnableColorScheme = true,
59
59
  prefix: designSystemPrefix = '',
60
60
  shouldSkipGeneratingVar,
61
61
  resolveTheme
@@ -86,15 +86,14 @@ function createCssVarsProvider(options) {
86
86
  modeStorageKey = _getInitColorSchemeScript.DEFAULT_MODE_STORAGE_KEY,
87
87
  attribute = _getInitColorSchemeScript.DEFAULT_ATTRIBUTE,
88
88
  defaultMode = desisgnSystemMode,
89
- defaultColorScheme = designSystemColorScheme
89
+ defaultColorScheme = designSystemColorScheme,
90
+ disableTransitionOnChange = designSystemTransitionOnChange,
91
+ enableColorScheme = designSystemEnableColorScheme
90
92
  }) {
91
- // make sure that baseTheme is always independent of each <CssVarsProvider /> call.
92
- // JSON.parse(JSON.stringify(...)) is okay to be used as long as the baseTheme is a plain object.
93
- const clonedBaseTheme = React.useMemo(() => JSON.parse(JSON.stringify(baseTheme)), []);
94
93
  const {
95
94
  colorSchemes: baseColorSchemes = {}
96
- } = clonedBaseTheme,
97
- restBaseTheme = (0, _objectWithoutPropertiesLoose2.default)(clonedBaseTheme, _excluded);
95
+ } = baseTheme,
96
+ restBaseTheme = (0, _objectWithoutPropertiesLoose2.default)(baseTheme, _excluded);
98
97
  const {
99
98
  colorSchemes: colorSchemesProp = {}
100
99
  } = themeProp,
@@ -143,13 +142,14 @@ function createCssVarsProvider(options) {
143
142
 
144
143
  const {
145
144
  css: rootCss,
146
- vars: rootVars
145
+ vars: rootVars,
146
+ parsedTheme
147
147
  } = (0, _cssVarsParser.default)(mergedTheme, {
148
148
  prefix,
149
149
  basePrefix: designSystemPrefix,
150
150
  shouldSkipGeneratingVar
151
151
  });
152
- mergedTheme = (0, _extends2.default)({}, mergedTheme, colorSchemes[resolvedColorScheme], {
152
+ mergedTheme = (0, _extends2.default)({}, parsedTheme, {
153
153
  components,
154
154
  colorSchemes,
155
155
  prefix,
@@ -162,7 +162,8 @@ function createCssVarsProvider(options) {
162
162
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
163
163
  const {
164
164
  css,
165
- vars
165
+ vars,
166
+ parsedTheme: parsedScheme
166
167
  } = (0, _cssVarsParser.default)(scheme, {
167
168
  prefix,
168
169
  basePrefix: designSystemPrefix,
@@ -170,6 +171,10 @@ function createCssVarsProvider(options) {
170
171
  });
171
172
  mergedTheme.vars = (0, _utils.deepmerge)(mergedTheme.vars, vars);
172
173
 
174
+ if (key === resolvedColorScheme) {
175
+ mergedTheme = (0, _extends2.default)({}, mergedTheme, parsedScheme);
176
+ }
177
+
173
178
  const resolvedDefaultColorScheme = (() => {
174
179
  if (typeof defaultColorScheme === 'string') {
175
180
  return defaultColorScheme;
@@ -210,7 +215,7 @@ function createCssVarsProvider(options) {
210
215
  return () => {
211
216
  document.documentElement.style.setProperty('color-scheme', priorColorScheme);
212
217
  };
213
- }, [mode, systemMode]);
218
+ }, [mode, systemMode, enableColorScheme]);
214
219
  React.useEffect(() => {
215
220
  let timer;
216
221
 
@@ -230,7 +235,7 @@ function createCssVarsProvider(options) {
230
235
  return () => {
231
236
  clearTimeout(timer);
232
237
  };
233
- }, [colorScheme]);
238
+ }, [colorScheme, disableTransitionOnChange]);
234
239
  React.useEffect(() => {
235
240
  hasMounted.current = true;
236
241
  return () => {
@@ -281,6 +286,16 @@ function createCssVarsProvider(options) {
281
286
  */
282
287
  defaultMode: _propTypes.default.string,
283
288
 
289
+ /**
290
+ * Disable CSS transitions when switching between modes or color schemes
291
+ */
292
+ disableTransitionOnChange: _propTypes.default.bool,
293
+
294
+ /**
295
+ * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
296
+ */
297
+ enableColorScheme: _propTypes.default.bool,
298
+
284
299
  /**
285
300
  * The key in the local storage used to store current color scheme.
286
301
  */
@@ -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,68 +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
- * This function also mutate the string value of theme input by replacing `basePrefix` (if existed) with `prefix`
47
- *
48
- * @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme)
49
- *
50
- * @example
51
- * const { css, vars } = parser({
52
- * fontSize: 12,
53
- * lineHeight: 1.2,
54
- * palette: { primary: { 500: '#000000' } }
55
- * })
56
- *
57
- * console.log(css) // { '--fontSize': '12px', '--lineHeight': 1.2, '--palette-primary-500': '#000000' }
58
- * console.log(vars) // { fontSize: '--fontSize', lineHeight: '--lineHeight', palette: { primary: { 500: 'var(--palette-primary-500)' } } }
59
- */
60
- export default function cssVarsParser(theme: Record<string, any>, options?: {
61
- prefix?: string;
62
- basePrefix?: string;
63
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
64
- }): {
65
- css: NestedRecord<string>;
66
- vars: NestedRecord<string>;
67
- };
68
- 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) => 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 {};
@@ -99,19 +99,20 @@ const getCssValue = (keys, value) => {
99
99
  * `basePrefix`: defined by design system.
100
100
  * `prefix`: defined by application
101
101
  *
102
- * This function also mutate the string value of theme input by replacing `basePrefix` (if existed) with `prefix`
102
+ * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
103
103
  *
104
- * @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme)
104
+ * @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.
105
105
  *
106
106
  * @example
107
- * const { css, vars } = parser({
107
+ * const { css, vars, parsedTheme } = parser({
108
108
  * fontSize: 12,
109
109
  * lineHeight: 1.2,
110
- * palette: { primary: { 500: '#000000' } }
111
- * })
110
+ * palette: { primary: { 500: 'var(--color)' } }
111
+ * }, { prefix: 'foo' })
112
112
  *
113
- * console.log(css) // { '--fontSize': '12px', '--lineHeight': 1.2, '--palette-primary-500': '#000000' }
114
- * console.log(vars) // { fontSize: '--fontSize', lineHeight: '--lineHeight', palette: { primary: { 500: 'var(--palette-primary-500)' } } }
113
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
114
+ * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
115
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
115
116
  */
116
117
 
117
118
 
@@ -123,21 +124,17 @@ function cssVarsParser(theme, options) {
123
124
  } = options || {};
124
125
  const css = {};
125
126
  const vars = {};
126
- walkObjectDeep(theme, (keys, val, scope) => {
127
- if (typeof val === 'string' || typeof val === 'number') {
128
- let value = val;
129
-
127
+ const parsedTheme = {};
128
+ walkObjectDeep(theme, (keys, value) => {
129
+ if (typeof value === 'string' || typeof value === 'number') {
130
130
  if (typeof value === 'string' && value.match(/var\(\s*--/)) {
131
- // replace the value of the `scope` object with the prefix or remove basePrefix from the value
131
+ // for CSS variable, apply prefix or remove basePrefix from the variable
132
132
  if (!basePrefix && prefix) {
133
133
  value = value.replace(/var\(\s*--/g, `var(--${prefix}-`);
134
134
  } else {
135
135
  value = prefix ? value.replace(new RegExp(`var\\(\\s*--${basePrefix}`, 'g'), `var(--${prefix}`) // removing spaces
136
136
  : value.replace(new RegExp(`var\\(\\s*--${basePrefix}-`, 'g'), 'var(--');
137
- } // scope is the deepest object in the tree, keys is the theme path keys
138
-
139
-
140
- scope[keys.slice(-1)[0]] = value;
137
+ }
141
138
  }
142
139
 
143
140
  if (!shouldSkipGeneratingVar || shouldSkipGeneratingVar && !shouldSkipGeneratingVar(keys, value)) {
@@ -149,10 +146,13 @@ function cssVarsParser(theme, options) {
149
146
  assignNestedKeys(vars, keys, `var(${cssVar})`);
150
147
  }
151
148
  }
149
+
150
+ assignNestedKeys(parsedTheme, keys, value);
152
151
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
153
152
  );
154
153
  return {
155
154
  css,
156
- vars
155
+ vars,
156
+ parsedTheme
157
157
  };
158
158
  }
@@ -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 +1 @@
1
- export { default } from './createCssVarsProvider';
1
+ export { default } 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>;
@@ -174,7 +174,11 @@ export default function createStyled(input = {}) {
174
174
 
175
175
  transformedStyleArg = [...styleArg, ...placeholders];
176
176
  transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
177
- } else if (typeof styleArg === 'function') {
177
+ } else if (typeof styleArg === 'function' && // On the server emotion doesn't use React.forwardRef for creating components, so the created
178
+ // component stays as a function. This condition makes sure that we do not interpolate functions
179
+ // which are basically components used as a selectors.
180
+ // eslint-disable-next-line no-underscore-dangle
181
+ styleArg.__emotion_real !== styleArg) {
178
182
  // If the type is function, we need to define the default theme.
179
183
  transformedStyleArg = _ref2 => {
180
184
  let {