@mui/system 5.4.2 → 5.5.0

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,199 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.5.0
4
+
5
+ <!-- generated comparing v5.4.4..master -->
6
+
7
+ _Mar 7, 2022_
8
+
9
+ A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - ♿️ made the `Autocomplete` conform to [ARIA 1.2 combobox](https://www.w3.org/TR/wai-aria-1.2/#combobox) (#30601) @EdmundMai
12
+ - Several 🐛 bug fixes and 📚 documentation improvements
13
+
14
+ ### `@mui/material@5.5.0`
15
+
16
+ #### Breaking change
17
+
18
+ - &#8203;<!-- 24 -->[ClassNameGenerator] Prevent all `base` imports (#31297) @siriwatknp
19
+
20
+ `unstable_ClassNameGenerator` has been moved from `utils` to `className` folder to prevent all MUI Base module imports. If you use the module, please update the import as suggested in the diff below:
21
+
22
+ ```diff
23
+ - import { unstable_ClassNameGenerator } from '@mui/material/utils';
24
+ + import { unstable_ClassNameGenerator } from '@mui/material/className';
25
+ ```
26
+
27
+ #### Changes
28
+
29
+ - &#8203;<!-- 28 -->[Autocomplete] Fix failing unit tests (#31302) @michaldudak
30
+ - &#8203;<!-- 27 -->[Autocomplete] Have the screen reader announce when autocomplete is open and closed (#30601) @EdmundMai
31
+ - &#8203;<!-- 26 -->[AvatarGroup] Fix misalignment with non-default spacing (#31165) @sjdemartini
32
+ - &#8203;<!-- 15 -->[Drawer] Adjustments to the mini variant to improve UI/UX (#31267) @siriwatknp
33
+ - &#8203;<!-- 04 -->[Select] Add extending `OutlinedInputProps` by SelectProps (#31209) @jrozbicki
34
+
35
+ ### `@mui/icons-material@5.5.0`
36
+
37
+ - &#8203;<!-- 13 -->[icons] Sync new Google Material Icons (#30766) @simonecervini
38
+
39
+ ### `@mui/codemod@5.5.0`
40
+
41
+ - &#8203;<!-- 23 -->[codemod] Fix top level imports codemod (#31308) @mnajdova
42
+
43
+ ### `@mui/lab@5.0.0-alpha.72`
44
+
45
+ - &#8203;<!-- 07 -->[LoadingButton] Fix padding of loading icon in small button (#31113) @PunitSoniME
46
+
47
+ ### `@mui/base@5.0.0-alpha.71`
48
+
49
+ - &#8203;<!-- 05 -->[MenuUnstyled] Create MenuUnstyled and useMenu (#30961) @michaldudak
50
+ - &#8203;<!-- 03 -->[SelectUnstyled] Prevent window scrolling after opening (#31237) @michaldudak
51
+
52
+ ### `@mui/joy@5.0.0-alpha.18`
53
+
54
+ - &#8203;<!-- 12 -->[Joy] Make Icon `fontSize` adaptable to its parent (#31268) @siriwatknp
55
+ - &#8203;<!-- 11 -->[Joy] Add `Link` component (#31175) @hbjORbj
56
+ - &#8203;<!-- 10 -->[Joy] Improve `Sheet` tests (#31241) @hbjORbj
57
+ - &#8203;<!-- 09 -->[Joy] Improve SvgIcon tests (#31242) @hbjORbj
58
+
59
+ ### `@mui/material-next@6.0.0-alpha.26`
60
+
61
+ - &#8203;<!-- 06 -->[material-next] Mark @mui/material as a dependency (#31270) @siriwatknp
62
+
63
+ ### Docs
64
+
65
+ - &#8203;<!-- 21 -->[docs] Remove career pages from translation (#31346) @oliviertassinari
66
+ - &#8203;<!-- 20 -->[docs] Fix JS files overloading (#31341) @oliviertassinari
67
+ - &#8203;<!-- 19 -->[docs] Add banner in solidarity of Ukraine (#31275) @danilo-leal
68
+ - &#8203;<!-- 18 -->[docs] Fix maxWidth of scrollable Tabs demos (#31285) @danilo-leal
69
+ - &#8203;<!-- 17 -->[docs] Fix icon linking implementation concurrent safe (#30428) @Janpot
70
+ - &#8203;<!-- 16 -->[docs] Follow up new doc space issues (#31251) @siriwatknp
71
+ - &#8203;<!-- 29 -->[examples] Add `@types/node` to nextjs typescript starter (#30918) @Daggy1234
72
+ - &#8203;<!-- 14 -->[examples] Fix import ThemeProvider from correct package in remix-wit… (#30981) @nnecec
73
+ - &#8203;<!-- 25 -->[blog] Simplify the labels (#30921) @oliviertassinari
74
+ - &#8203;<!-- 08 -->[l10n] Add Croatian (hr-HR) and Serbian (sr-RS) translation (#30906) @m14d3n
75
+
76
+ ### Core
77
+
78
+ - &#8203;<!-- 23 -->[core] Fix running markdownlint on Windows (#31352) @michaldudak
79
+ - &#8203;<!-- 22 -->[core] Fix the stylelint script on Windows (#31281) @mnajdova
80
+ - &#8203;<!-- 02 -->[test] Fix buildApiUtils tests on Windows (#31304) @michaldudak
81
+ - &#8203;<!-- 01 -->[test] Remove legacyRoot option from test renderer (#31284) @eps1lon
82
+
83
+ All contributors of this release in alphabetical order: @Daggy1234, @danilo-leal, @EdmundMai, @eps1lon, @hbjORbj, @Janpot, @jrozbicki, @m14d3n, @michaldudak, @mnajdova, @nnecec, @oliviertassinari, @PunitSoniME, @simonecervini, @siriwatknp, @sjdemartini
84
+
85
+ ## 5.4.4
86
+
87
+ <!-- generated comparing v5.4.3..master -->
88
+
89
+ _Feb 28, 2022_
90
+
91
+ A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
92
+
93
+ - ✨ New `Input` and `Sheet` components were added in the experimental Joy design system by @hbjORbj (#31124, #31086) @hbjORbj
94
+ - Several 🐛 bug fixes and 📚 documentation improvements
95
+
96
+ ### `@mui/material@5.4.4`
97
+
98
+ - &#8203;<!-- 28 -->[Autocomplete] Have Autocomplete with multiline textfield log a warning instead of an error (#30680) @iclaude3
99
+ - &#8203;<!-- 27 -->[Chip] Fix ellipsis when the children is too long (#31087) @PunitSoniME
100
+ - &#8203;<!-- 14 -->[Input] Export InputBase's classes from the classes const (#31186) @mnajdova
101
+ - &#8203;<!-- 29 -->[TextField] Fix Horizontal scroll when label too long (#31187) @RedHeadphone
102
+ - &#8203;<!-- 08 -->[styles] Fix typo in import error (#31167) @davwheat
103
+
104
+ ### `@mui/system@5.4.4`
105
+
106
+ - &#8203;<!-- 07 -->[system] Fix executing server-side Emotion component as function interpolation 2 (#31024) @Andarist
107
+ - &#8203;<!-- 06 -->[system] Fix sx prop types when CSS variables are used with nested selectors (#31163) @mnajdova
108
+ - &#8203;<!-- 05 -->[system] Fix `CssVarsProvider` theme mutation (#31148) @siriwatknp
109
+
110
+ ### `@mui/codemod@5.4.4`
111
+
112
+ - &#8203;<!-- 26 -->[codemods] Add v5.0.0/top-level-imports codemod (#31195) @greengiraffe
113
+
114
+ ### `@mui/base@5.0.0-alpha.70`
115
+
116
+ - &#8203;<!-- 31 -->[SelectUnstyled, MultiSelectUnstyled, ButtonUnstyled] Export additional types to make customization easier (#31172) @michaldudak
117
+
118
+ ### `@mui/joy@5.0.0-alpha.17`
119
+
120
+ - &#8203;<!-- 13 -->[Joy] Add nested list components (#31159) @siriwatknp
121
+ - &#8203;<!-- 12 -->[Joy] Improve color customization on `Switch` (#31137) @siriwatknp
122
+ - &#8203;<!-- 11 -->[Joy] Add `Sheet` component (#31124) @hbjORbj
123
+ - &#8203;<!-- 10 -->[Joy] add `Input` component (#31086) @siriwatknp
124
+ - &#8203;<!-- 09 -->[Joy] Fix Button missing slot type (#31166) @siriwatknp
125
+
126
+ ### Docs
127
+
128
+ - &#8203;<!-- 22 -->[docs] Fix 404 link to the blog (#31234) @oliviertassinari
129
+ - &#8203;<!-- 21 -->[docs] Use `material-ui` for product name (#31200) @siriwatknp
130
+ - &#8203;<!-- 20 -->[docs] Add Base installation page (#30969) @siriwatknp
131
+ - &#8203;<!-- 19 -->[docs] Use new Algolia app for new structure (#31178) @siriwatknp
132
+ - &#8203;<!-- 18 -->[docs] Typo in the `FormControl` API documentation (#31169) @bonellia
133
+ - &#8203;<!-- 17 -->[docs] Fix typo in Stack documentation (#31176) @adriancampos
134
+ - &#8203;<!-- 16 -->[docs] Update interoperability.md broken tailwind links (#31182) @robertwt7
135
+ - &#8203;<!-- 15 -->[docs] Add missing import into tss-react migration guide (#31162) @sviande
136
+ - &#8203;<!-- 03 -->[website] The role is filled (#31216) @oliviertassinari
137
+ - &#8203;<!-- 02 -->[website] Revise the row grouping blog post (#31101) @samuelsycamore
138
+ - &#8203;<!-- 01 -->[website] Fix a few SEO issues (#31150) @oliviertassinari
139
+
140
+ ### Core
141
+
142
+ - &#8203;<!-- 30 -->[core] Add group for the @fortawesome dependencies (#31193) @mnajdova
143
+ - &#8203;<!-- 25 -->[core] Update playwright docker to match the specified version (#31236) @siriwatknp
144
+ - &#8203;<!-- 24 -->[core] Remove parallel on buildTypes (#31189) @siriwatknp
145
+ - &#8203;<!-- 23 -->[core] Fix propTypes generation for optional any props (#31141) @m4theushw
146
+ - &#8203;<!-- 04 -->[Typescript] Remove variants deprecation (#31239) @siriwatknp
147
+
148
+ 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
149
+
150
+ ## 5.4.3
151
+
152
+ <!-- generated comparing v5.4.2..master -->
153
+
154
+ _Feb 21, 2022_
155
+
156
+ A big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
157
+
158
+ - 🛠 @hbjORbj made components use theme duration/easing values by default (#30894)
159
+ - A meaningful number of 🐛 bug fixes and 📚 documentation improvements
160
+
161
+ ### `@mui/material@5.4.3`
162
+
163
+ - &#8203;<!-- 18 -->[ButtonBase] Fix typo (#31135) @Jastor11
164
+ - &#8203;<!-- 05 -->[Stepper] Export useStepContext (#31021) @michaldudak
165
+ - &#8203;<!-- 04 -->[Transitions] Some components do not use transition duration/easing values from theme (#30894) @hbjORbj
166
+
167
+ ### `@mui/icons-material@5.4.3`
168
+
169
+ - &#8203;<!-- 11 -->[icons] Add "circle" icon synonyms (#31118) @gnowland
170
+
171
+ ### `@mui/joy@5.0.0-alpha.16`
172
+
173
+ - &#8203;<!-- 10 -->[Joy] `List` second iteration (#31134) @siriwatknp
174
+ - &#8203;<!-- 09 -->[Joy] Fix typings (#31120) @siriwatknp
175
+ - &#8203;<!-- 08 -->[Joy] Add initial `List` components (#30987) @siriwatknp
176
+
177
+ ### Docs
178
+
179
+ - &#8203;<!-- 19 -->[website] Improve full-stack role job description (#31160) @Janpot
180
+ - &#8203;<!-- 14 -->[docs] Fix typo of migration guides v4 (#31136) @pppp606
181
+ - &#8203;<!-- 13 -->[docs] Update on the support page to account for v4 LTS support (#31029) @danilo-leal
182
+ - &#8203;<!-- 12 -->[docs] Fix small typo in chips.md (#31092) @cameliaben
183
+ - &#8203;<!-- 07 -->[l10n] Add it-IT translation for labelDisplayedRows (#31131) @frab90
184
+ - &#8203;<!-- 06 -->[l10n] Add pl-PL translation for labelDisplayedRows (#31088) @ThomasTheHuman
185
+ - &#8203;<!-- 03 -->[website] Sync MUI X table feature (#30913) @alexfauquette
186
+ - &#8203;<!-- 02 -->[website] Prefill source in job application links (#31036) @oliviertassinari
187
+ - &#8203;<!-- 01 -->[website] Fix a grammar mistake (#31099) @huyenltnguyen
188
+
189
+ ### Core
190
+
191
+ - &#8203;<!-- 17 -->[core] Add jsx, html, css and prisma to prettier extensions (#31161) @Janpot
192
+ - &#8203;<!-- 16 -->[core] Allow to run material-ui.com/store alongside mui.com/store (#31065) @oliviertassinari
193
+ - &#8203;<!-- 15 -->[core] Polish design tokens (#31095) @oliviertassinari
194
+
195
+ All contributors of this release in alphabetical order: @alexfauquette, @cameliaben, @danilo-leal, @frab90, @gnowland, @hbjORbj, @huyenltnguyen, @Janpot, @Jastor11, @michaldudak, @oliviertassinari, @pppp606, @siriwatknp, @ThomasTheHuman
196
+
3
197
  ## 5.4.2
4
198
 
5
199
  _Feb 15, 2022_
@@ -120,7 +314,7 @@ A big thanks to the 24 contributors who made this release possible. Here are som
120
314
  - &#8203;<!-- 20 -->[docs] Clarify what the name of @mui/material is (#30866) @oliviertassinari
121
315
  - &#8203;<!-- 19 -->[docs] Remove migration from the releases page (#30863) @mnajdova
122
316
  - &#8203;<!-- 18 -->[docs] Update Instructions for Google Maps Autocomplete (#30849) @kjschabra
123
- - &#8203;<!-- 17 -->[docs] Hotfix notification <b> (#30862) @siriwatknp
317
+ - &#8203;<!-- 17 -->[docs] Hotfix notification (#30862) @siriwatknp
124
318
  - &#8203;<!-- 04 -->[website] Sample GA to avoid hit limit (#30919) @oliviertassinari
125
319
  - &#8203;<!-- 03 -->[website] Hide scrollbars of hero containers (#29474) @theiliad
126
320
  - &#8203;<!-- 02 -->[website] Polishing spacing and other small things (#30828) @danilo-leal
@@ -3529,7 +3723,7 @@ A big thanks to the 15 contributors who made this release possible. Here are som
3529
3723
  - &#8203;<!-- 53 -->[DateTimePicker] `date` is nullable in `onChange` (#25981) @eps1lon
3530
3724
  - &#8203;<!-- 39 -->[internal][pickers] Remove unused TView type argument (#25936) @eps1lon
3531
3725
  - &#8203;<!-- 48 -->[internal][pickers] Inline some BasePickerProps usages (#25971) @eps1lon
3532
- - &#8203;<!-- 44 -->[internal][pickers] Entangle what *Props vs All*Props means (#25938) @eps1lon
3726
+ - &#8203;<!-- 44 -->[internal][pickers] Entangle what Props vs AllProps means (#25938) @eps1lon
3533
3727
  - &#8203;<!-- 19 -->[lab] Update slot components to use overridesResolver (#25906) @mnajdova
3534
3728
  - &#8203;<!-- 40 -->[Timeline] Remove use of nth-child in favor of nth-of-type (#25915) @wellwellmissesanderson
3535
3729
  - &#8203;<!-- 06 -->[Timeline] Migrate Timeline to emotion (#25838) @siriwatknp
@@ -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;
@@ -2,73 +2,18 @@ import * as React from 'react';
2
2
  import getInitColorSchemeScript from './getInitColorSchemeScript';
3
3
  import { Mode, Result } from './useCurrentColorScheme';
4
4
 
5
- export type BuildCssVarsTheme<ThemeInput> = ThemeInput extends {
6
- colorSchemes: Record<string, infer ColorSystems>;
7
- }
8
- ? Omit<ThemeInput, 'colorSchemes'> &
9
- ColorSystems & { vars: Omit<ThemeInput, 'colorSchemes'> & ColorSystems }
10
- : never;
11
-
12
- /**
13
- * DesignSystemColorScheme: is what a design system provide by default. Mostly, `light` and `dark`
14
- * ApplicationColorScheme: is what developer can extend from a design system. Ex, `comfort` `trueDark` ...any name that they want
15
- *
16
- * This type enhance customization experience by checking if developer has extended the colorScheme or not (usually via module augmentation)
17
- * If yes, they must provide the palette of the extended colorScheme. Otherwise `theme` is optional.
18
- */
19
- type DecideTheme<
20
- DesignSystemTheme extends { colorSchemes: Record<DesignSystemColorScheme, any> },
21
- DesignSystemColorScheme extends string,
22
- ApplicationTheme extends { colorSchemes: Record<ApplicationColorScheme, any> },
23
- ApplicationColorScheme extends string | never,
24
- > = [ApplicationColorScheme] extends [never]
25
- ? {
26
- theme?: Omit<DesignSystemTheme, 'colorSchemes'> & {
27
- colorSchemes?: Partial<
28
- Record<
29
- DesignSystemColorScheme,
30
- DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
31
- >
32
- >;
33
- };
34
- }
35
- : {
36
- theme: Omit<ApplicationTheme, 'colorSchemes'> & {
37
- colorSchemes: Partial<
38
- Record<
39
- DesignSystemColorScheme,
40
- DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
41
- >
42
- > &
43
- Record<ApplicationColorScheme, ApplicationTheme['colorSchemes'][ApplicationColorScheme]>;
44
- };
45
- };
46
-
47
5
  export interface ColorSchemeContextValue<SupportedColorScheme extends string>
48
6
  extends Result<SupportedColorScheme> {
49
7
  allColorSchemes: SupportedColorScheme[];
50
8
  }
51
9
 
52
- export default function createCssVarsProvider<
53
- DesignSystemThemeInput extends {
54
- colorSchemes: Record<DesignSystemColorScheme, any>;
55
- },
56
- DesignSystemColorScheme extends string,
57
- ApplicationThemeInput extends {
58
- colorSchemes: Record<ApplicationColorScheme, any>;
59
- } = never,
60
- ApplicationColorScheme extends string = never,
61
- >(options: {
10
+ export interface CssVarsProviderConfig<ColorScheme extends string> {
62
11
  /**
63
- * Design system default theme
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
64
15
  */
65
- theme: DesignSystemThemeInput;
66
- /**
67
- * Design system default color scheme
68
- */
69
- defaultColorScheme:
70
- | DesignSystemColorScheme
71
- | { light: DesignSystemColorScheme; dark: DesignSystemColorScheme };
16
+ defaultColorScheme: ColorScheme | { light: ColorScheme; dark: ColorScheme };
72
17
  /**
73
18
  * Design system default mode
74
19
  * @default 'light'
@@ -89,39 +34,60 @@ export default function createCssVarsProvider<
89
34
  * @default ''
90
35
  */
91
36
  prefix?: string;
92
- /**
93
- * A function to determine if the key, value should be attached as CSS Variable
94
- * `keys` is an array that represents the object path keys.
95
- * Ex, if the theme is { foo: { bar: 'var(--test)' } }
96
- * then, keys = ['foo', 'bar']
97
- * value = 'var(--test)'
98
- */
99
- shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
100
- /**
101
- * A function to be called after the CSS variables are attached. The result of this function will be the final theme pass to ThemeProvider.
102
- *
103
- * The example usage is the variant generation in Joy. We need to combine the token from user-input and the default theme first, then generate
104
- * variants from those tokens.
105
- */
106
- resolveTheme?: (theme: any) => any; // the type is any because it depends on the design system.
107
- }): {
37
+ }
38
+
39
+ export default function createCssVarsProvider<
40
+ ColorScheme extends string,
41
+ ThemeInput extends { colorSchemes?: Partial<Record<ColorScheme, any>> },
42
+ >(
43
+ options: CssVarsProviderConfig<ColorScheme> & {
44
+ /**
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
+ * }
68
+ */
69
+ theme: any;
70
+ /**
71
+ * A function to determine if the key, value should be attached as CSS Variable
72
+ * `keys` is an array that represents the object path keys.
73
+ * Ex, if the theme is { foo: { bar: 'var(--test)' } }
74
+ * then, keys = ['foo', 'bar']
75
+ * value = 'var(--test)'
76
+ */
77
+ shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
78
+ /**
79
+ * A function to be called after the CSS variables are attached. The result of this function will be the final theme pass to ThemeProvider.
80
+ *
81
+ * The example usage is the variant generation in Joy. We need to combine the token from user-input and the default theme first, then generate
82
+ * variants from those tokens.
83
+ */
84
+ resolveTheme?: (theme: any) => any; // the type is any because it depends on the design system.
85
+ },
86
+ ): {
108
87
  CssVarsProvider: (
109
88
  props: React.PropsWithChildren<
110
- {
111
- /**
112
- * Application default mode (overrides design system `defaultMode` if specified)
113
- */
114
- defaultMode?: Mode;
115
- /**
116
- * Application default colorScheme (overrides design system `defaultColorScheme` if specified)
117
- */
118
- defaultColorScheme?:
119
- | DesignSystemColorScheme
120
- | ApplicationColorScheme
121
- | {
122
- light: DesignSystemColorScheme | ApplicationColorScheme;
123
- dark: DesignSystemColorScheme | ApplicationColorScheme;
124
- };
89
+ Partial<CssVarsProviderConfig<ColorScheme>> & {
90
+ theme?: ThemeInput;
125
91
  /**
126
92
  * localStorage key used to store application `mode`
127
93
  * @default 'mui-mode'
@@ -132,19 +98,10 @@ export default function createCssVarsProvider<
132
98
  * @default 'data-mui-color-scheme'
133
99
  */
134
100
  attribute?: string;
135
- /**
136
- * CSS variable prefix (overrides design system `prefix` if specified)
137
- */
138
- prefix?: string;
139
- } & DecideTheme<
140
- DesignSystemThemeInput,
141
- DesignSystemColorScheme,
142
- ApplicationThemeInput,
143
- ApplicationColorScheme
144
- >
101
+ }
145
102
  >,
146
103
  ) => React.ReactElement;
147
- useColorScheme: () => ColorSchemeContextValue<DesignSystemColorScheme | ApplicationColorScheme>;
104
+ useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
148
105
  getInitColorSchemeScript: typeof getInitColorSchemeScript;
149
106
  };
150
107
 
@@ -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;