@mui/system 5.4.3 → 5.5.1

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,217 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.5.1
4
+
5
+ <!-- generated comparing v5.5.0..master -->
6
+
7
+ _Mar 14, 2022_
8
+
9
+ A big thanks to the 23 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 📊 2021 survey results post by @danilo-leal (#30999)
12
+ - Several 🐛 bug fixes and 📚 documentation improvements
13
+
14
+ ### @mui/material@5.5.1
15
+
16
+ - [Fab] Add z-index (#30842) @issamElmohadeb098
17
+ - [Grid] Fix columns of nested container (#31340) @boutahlilsoufiane
18
+ - [i10n] Update italian locale (#30974) @SalvatoreMazzullo
19
+ - [Pagination] Fix type of UsePaginationItem["page"] (#31295) @aaronadamsCA
20
+ - [Popper] Allow setting default props in a theme (#30118) @hafley66
21
+ - [TextField] fix disappearing border in Safari (#31406) @krysia1
22
+
23
+ ### @mui/joy@5.0.0-alpha.19
24
+
25
+ - [Joy] Support horizontal List (#31620) @siriwatknp
26
+ - [Joy] Add icon & label `Switch` examples (#31359) @siriwatknp
27
+ - [Joy] Add `TextField` component (#31299) @siriwatknp
28
+ - [Joy] Add `--Icon-fontSize` to components (#31360) @siriwatknp
29
+ - [Joy] Add `Checkbox` component (#31273) @siriwatknp
30
+
31
+ ### Docs
32
+
33
+ - [blog] 2021 survey results post (#30999) @danilo-leal
34
+ - [docs] Add Macedonian translation (#31402) @theCuriousOne
35
+ - [docs] Fix API page table styles in Safari (#31696) @aaarichter
36
+ - [docs] Fix SEO issues (#31505) @oliviertassinari
37
+ - [docs] Fix Link leak of Next.js props (#31418) @oliviertassinari
38
+ - [docs] Add "Work in biotech" to showcase (#31711) @klyburke
39
+ - [docs] Fix docs site crash on iOS Safari 12 (#31458) @badalsaibo
40
+ - [docs] Fix search icons crash (#31651) @juanpc10
41
+ - [docs] Remove unnecessary await in e2e-tests (#31767) @siriwatknp
42
+ - [docs] Fix source code links on the Templates page (#31425) @danilo-leal
43
+ - [docs] Adjust Stack's basic usage demo (#31423) @danilo-leal
44
+ - [docs] Migrate button demos to base (#31395) @siriwatknp
45
+ - [docs] Fix y-axis unit used in the responsive font sizes chart (#31424) @aaarichter
46
+ - [docs] Remove joy mockup pages (#31412) @siriwatknp
47
+ - [docs] Fix the statement that styleOverrides are added by default (#31257) @mnajdova
48
+ - [docs] Refine the product identifier menu (#31262) @danilo-leal
49
+ - [docs] Fix Search crash (#31386) @reckter
50
+ - [docs] Update TextField multiline description (#31291) @jontewks
51
+ - [docs] Add gap theme mapping in the System properties table (#31382) @danilo-leal
52
+ - [docs] Test products search (#31351) @siriwatknp
53
+ - [docs] Fix GitHub source links in the demo toolbar (#31339) @PunitSoniME
54
+ - [docs] Add Algolia verification code to robot.txt (#31356) @siriwatknp
55
+ - [examples] Ignore tsbuildinfo with Next.js (#31460) @B0und
56
+ - [website] Add new gold sponsor (#31354) @hbjORbj
57
+ - [website] Update Ukraine support link (#31378) @samuelsycamore
58
+
59
+ ### Core
60
+
61
+ - [core] Simplify anchor link (#31419) @oliviertassinari
62
+ - [core] Revert unrelated changes in #31354 @oliviertassinari
63
+ - [test] Upgrade CircleCI convenience image (#31394) @m4theushw
64
+ - [typescript] Simplify display of slot props types (#31240) @michaldudak
65
+
66
+ All contributors of this release in alphabetical order: @aaarichter, @aaronadamsCA, @B0und, @badalsaibo, @boutahlilsoufiane, @danilo-leal, @hafley66, @hbjORbj, @issamElmohadeb098, @jontewks, @juanpc10, @klyburke, @krysia1, @m4theushw, @michaldudak, @mnajdova, @oliviertassinari, @PunitSoniME, @reckter, @SalvatoreMazzullo, @samuelsycamore, @siriwatknp, @theCuriousOne
67
+
68
+ ## 5.5.0
69
+
70
+ <!-- generated comparing v5.4.4..master -->
71
+
72
+ _Mar 7, 2022_
73
+
74
+ A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:
75
+
76
+ - ♿️ made the `Autocomplete` conform to [ARIA 1.2 combobox](https://www.w3.org/TR/wai-aria-1.2/#combobox) (#30601) @EdmundMai
77
+ - Several 🐛 bug fixes and 📚 documentation improvements
78
+
79
+ ### `@mui/material@5.5.0`
80
+
81
+ #### Breaking change
82
+
83
+ - &#8203;<!-- 24 -->[ClassNameGenerator] Prevent all `base` imports (#31297) @siriwatknp
84
+
85
+ `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:
86
+
87
+ ```diff
88
+ - import { unstable_ClassNameGenerator } from '@mui/material/utils';
89
+ + import { unstable_ClassNameGenerator } from '@mui/material/className';
90
+ ```
91
+
92
+ #### Changes
93
+
94
+ - &#8203;<!-- 28 -->[Autocomplete] Fix failing unit tests (#31302) @michaldudak
95
+ - &#8203;<!-- 27 -->[Autocomplete] Have the screen reader announce when autocomplete is open and closed (#30601) @EdmundMai
96
+ - &#8203;<!-- 26 -->[AvatarGroup] Fix misalignment with non-default spacing (#31165) @sjdemartini
97
+ - &#8203;<!-- 15 -->[Drawer] Adjustments to the mini variant to improve UI/UX (#31267) @siriwatknp
98
+ - &#8203;<!-- 04 -->[Select] Add extending `OutlinedInputProps` by SelectProps (#31209) @jrozbicki
99
+
100
+ ### `@mui/icons-material@5.5.0`
101
+
102
+ - &#8203;<!-- 13 -->[icons] Sync new Google Material Icons (#30766) @simonecervini
103
+
104
+ ### `@mui/codemod@5.5.0`
105
+
106
+ - &#8203;<!-- 23 -->[codemod] Fix top level imports codemod (#31308) @mnajdova
107
+
108
+ ### `@mui/lab@5.0.0-alpha.72`
109
+
110
+ - &#8203;<!-- 07 -->[LoadingButton] Fix padding of loading icon in small button (#31113) @PunitSoniME
111
+
112
+ ### `@mui/base@5.0.0-alpha.71`
113
+
114
+ - &#8203;<!-- 05 -->[MenuUnstyled] Create MenuUnstyled and useMenu (#30961) @michaldudak
115
+ - &#8203;<!-- 03 -->[SelectUnstyled] Prevent window scrolling after opening (#31237) @michaldudak
116
+
117
+ ### `@mui/joy@5.0.0-alpha.18`
118
+
119
+ - &#8203;<!-- 12 -->[Joy] Make Icon `fontSize` adaptable to its parent (#31268) @siriwatknp
120
+ - &#8203;<!-- 11 -->[Joy] Add `Link` component (#31175) @hbjORbj
121
+ - &#8203;<!-- 10 -->[Joy] Improve `Sheet` tests (#31241) @hbjORbj
122
+ - &#8203;<!-- 09 -->[Joy] Improve SvgIcon tests (#31242) @hbjORbj
123
+
124
+ ### `@mui/material-next@6.0.0-alpha.26`
125
+
126
+ - &#8203;<!-- 06 -->[material-next] Mark @mui/material as a dependency (#31270) @siriwatknp
127
+
128
+ ### Docs
129
+
130
+ - &#8203;<!-- 21 -->[docs] Remove career pages from translation (#31346) @oliviertassinari
131
+ - &#8203;<!-- 20 -->[docs] Fix JS files overloading (#31341) @oliviertassinari
132
+ - &#8203;<!-- 19 -->[docs] Add banner in solidarity of Ukraine (#31275) @danilo-leal
133
+ - &#8203;<!-- 18 -->[docs] Fix maxWidth of scrollable Tabs demos (#31285) @danilo-leal
134
+ - &#8203;<!-- 17 -->[docs] Fix icon linking implementation concurrent safe (#30428) @Janpot
135
+ - &#8203;<!-- 16 -->[docs] Follow up new doc space issues (#31251) @siriwatknp
136
+ - &#8203;<!-- 29 -->[examples] Add `@types/node` to nextjs typescript starter (#30918) @Daggy1234
137
+ - &#8203;<!-- 14 -->[examples] Fix import ThemeProvider from correct package in remix-wit… (#30981) @nnecec
138
+ - &#8203;<!-- 25 -->[blog] Simplify the labels (#30921) @oliviertassinari
139
+ - &#8203;<!-- 08 -->[l10n] Add Croatian (hr-HR) and Serbian (sr-RS) translation (#30906) @m14d3n
140
+
141
+ ### Core
142
+
143
+ - &#8203;<!-- 23 -->[core] Fix running markdownlint on Windows (#31352) @michaldudak
144
+ - &#8203;<!-- 22 -->[core] Fix the stylelint script on Windows (#31281) @mnajdova
145
+ - &#8203;<!-- 02 -->[test] Fix buildApiUtils tests on Windows (#31304) @michaldudak
146
+ - &#8203;<!-- 01 -->[test] Remove legacyRoot option from test renderer (#31284) @eps1lon
147
+
148
+ 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
149
+
150
+ ## 5.4.4
151
+
152
+ <!-- generated comparing v5.4.3..master -->
153
+
154
+ _Feb 28, 2022_
155
+
156
+ A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
157
+
158
+ - ✨ New `Input` and `Sheet` components were added in the experimental Joy design system by @hbjORbj (#31124, #31086) @hbjORbj
159
+ - Several 🐛 bug fixes and 📚 documentation improvements
160
+
161
+ ### `@mui/material@5.4.4`
162
+
163
+ - &#8203;<!-- 28 -->[Autocomplete] Have Autocomplete with multiline textfield log a warning instead of an error (#30680) @iclaude3
164
+ - &#8203;<!-- 27 -->[Chip] Fix ellipsis when the children is too long (#31087) @PunitSoniME
165
+ - &#8203;<!-- 14 -->[Input] Export InputBase's classes from the classes const (#31186) @mnajdova
166
+ - &#8203;<!-- 29 -->[TextField] Fix Horizontal scroll when label too long (#31187) @RedHeadphone
167
+ - &#8203;<!-- 08 -->[styles] Fix typo in import error (#31167) @davwheat
168
+
169
+ ### `@mui/system@5.4.4`
170
+
171
+ - &#8203;<!-- 07 -->[system] Fix executing server-side Emotion component as function interpolation 2 (#31024) @Andarist
172
+ - &#8203;<!-- 06 -->[system] Fix sx prop types when CSS variables are used with nested selectors (#31163) @mnajdova
173
+ - &#8203;<!-- 05 -->[system] Fix `CssVarsProvider` theme mutation (#31148) @siriwatknp
174
+
175
+ ### `@mui/codemod@5.4.4`
176
+
177
+ - &#8203;<!-- 26 -->[codemods] Add v5.0.0/top-level-imports codemod (#31195) @greengiraffe
178
+
179
+ ### `@mui/base@5.0.0-alpha.70`
180
+
181
+ - &#8203;<!-- 31 -->[SelectUnstyled, MultiSelectUnstyled, ButtonUnstyled] Export additional types to make customization easier (#31172) @michaldudak
182
+
183
+ ### `@mui/joy@5.0.0-alpha.17`
184
+
185
+ - &#8203;<!-- 13 -->[Joy] Add nested list components (#31159) @siriwatknp
186
+ - &#8203;<!-- 12 -->[Joy] Improve color customization on `Switch` (#31137) @siriwatknp
187
+ - &#8203;<!-- 11 -->[Joy] Add `Sheet` component (#31124) @hbjORbj
188
+ - &#8203;<!-- 10 -->[Joy] add `Input` component (#31086) @siriwatknp
189
+ - &#8203;<!-- 09 -->[Joy] Fix Button missing slot type (#31166) @siriwatknp
190
+
191
+ ### Docs
192
+
193
+ - &#8203;<!-- 22 -->[docs] Fix 404 link to the blog (#31234) @oliviertassinari
194
+ - &#8203;<!-- 21 -->[docs] Use `material-ui` for product name (#31200) @siriwatknp
195
+ - &#8203;<!-- 20 -->[docs] Add Base installation page (#30969) @siriwatknp
196
+ - &#8203;<!-- 19 -->[docs] Use new Algolia app for new structure (#31178) @siriwatknp
197
+ - &#8203;<!-- 18 -->[docs] Typo in the `FormControl` API documentation (#31169) @bonellia
198
+ - &#8203;<!-- 17 -->[docs] Fix typo in Stack documentation (#31176) @adriancampos
199
+ - &#8203;<!-- 16 -->[docs] Update interoperability.md broken tailwind links (#31182) @robertwt7
200
+ - &#8203;<!-- 15 -->[docs] Add missing import into tss-react migration guide (#31162) @sviande
201
+ - &#8203;<!-- 03 -->[website] The role is filled (#31216) @oliviertassinari
202
+ - &#8203;<!-- 02 -->[website] Revise the row grouping blog post (#31101) @samuelsycamore
203
+ - &#8203;<!-- 01 -->[website] Fix a few SEO issues (#31150) @oliviertassinari
204
+
205
+ ### Core
206
+
207
+ - &#8203;<!-- 30 -->[core] Add group for the @fortawesome dependencies (#31193) @mnajdova
208
+ - &#8203;<!-- 25 -->[core] Update playwright docker to match the specified version (#31236) @siriwatknp
209
+ - &#8203;<!-- 24 -->[core] Remove parallel on buildTypes (#31189) @siriwatknp
210
+ - &#8203;<!-- 23 -->[core] Fix propTypes generation for optional any props (#31141) @m4theushw
211
+ - &#8203;<!-- 04 -->[Typescript] Remove variants deprecation (#31239) @siriwatknp
212
+
213
+ 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
214
+
3
215
  ## 5.4.3
4
216
 
5
217
  <!-- generated comparing v5.4.2..master -->
@@ -167,7 +379,7 @@ A big thanks to the 24 contributors who made this release possible. Here are som
167
379
  - &#8203;<!-- 20 -->[docs] Clarify what the name of @mui/material is (#30866) @oliviertassinari
168
380
  - &#8203;<!-- 19 -->[docs] Remove migration from the releases page (#30863) @mnajdova
169
381
  - &#8203;<!-- 18 -->[docs] Update Instructions for Google Maps Autocomplete (#30849) @kjschabra
170
- - &#8203;<!-- 17 -->[docs] Hotfix notification <b> (#30862) @siriwatknp
382
+ - &#8203;<!-- 17 -->[docs] Hotfix notification (#30862) @siriwatknp
171
383
  - &#8203;<!-- 04 -->[website] Sample GA to avoid hit limit (#30919) @oliviertassinari
172
384
  - &#8203;<!-- 03 -->[website] Hide scrollbars of hero containers (#29474) @theiliad
173
385
  - &#8203;<!-- 02 -->[website] Polishing spacing and other small things (#30828) @danilo-leal
@@ -3576,7 +3788,7 @@ A big thanks to the 15 contributors who made this release possible. Here are som
3576
3788
  - &#8203;<!-- 53 -->[DateTimePicker] `date` is nullable in `onChange` (#25981) @eps1lon
3577
3789
  - &#8203;<!-- 39 -->[internal][pickers] Remove unused TView type argument (#25936) @eps1lon
3578
3790
  - &#8203;<!-- 48 -->[internal][pickers] Inline some BasePickerProps usages (#25971) @eps1lon
3579
- - &#8203;<!-- 44 -->[internal][pickers] Entangle what *Props vs All*Props means (#25938) @eps1lon
3791
+ - &#8203;<!-- 44 -->[internal][pickers] Entangle what Props vs AllProps means (#25938) @eps1lon
3580
3792
  - &#8203;<!-- 19 -->[lab] Update slot components to use overridesResolver (#25906) @mnajdova
3581
3793
  - &#8203;<!-- 40 -->[Timeline] Remove use of nth-child in favor of nth-of-type (#25915) @wellwellmissesanderson
3582
3794
  - &#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;
@@ -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
  }