@mui/system 5.2.1 → 5.2.5

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.
Files changed (39) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +279 -1
  3. package/createBox.d.ts +3 -3
  4. package/createBox.spec.d.ts +1 -0
  5. package/createTheme/createBreakpoints.d.ts +6 -0
  6. package/createTheme/createBreakpoints.js +16 -0
  7. package/createTheme/createSpacing.d.ts +10 -10
  8. package/cssVars/createCssVarsProvider.d.ts +24 -10
  9. package/cssVars/createCssVarsProvider.js +81 -8
  10. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  11. package/cssVars/cssVarsParser.d.ts +68 -68
  12. package/cssVars/cssVarsParser.js +18 -17
  13. package/cssVars/getInitColorSchemeScript.d.ts +12 -12
  14. package/cssVars/getInitColorSchemeScript.js +1 -1
  15. package/cssVars/index.d.ts +2 -2
  16. package/cssVars/useCurrentColorScheme.d.ts +50 -50
  17. package/esm/createTheme/createBreakpoints.js +16 -0
  18. package/esm/cssVars/createCssVarsProvider.js +78 -9
  19. package/esm/cssVars/cssVarsParser.js +18 -16
  20. package/esm/cssVars/getInitColorSchemeScript.js +1 -1
  21. package/esm/useThemeProps/getThemeProps.js +2 -17
  22. package/index.js +1 -1
  23. package/index.spec.d.ts +1 -1
  24. package/legacy/createTheme/createBreakpoints.js +16 -0
  25. package/legacy/cssVars/createCssVarsProvider.js +81 -9
  26. package/legacy/cssVars/cssVarsParser.js +20 -14
  27. package/legacy/cssVars/getInitColorSchemeScript.js +1 -1
  28. package/legacy/index.js +1 -1
  29. package/legacy/useThemeProps/getThemeProps.js +2 -17
  30. package/modern/createTheme/createBreakpoints.js +16 -0
  31. package/modern/cssVars/createCssVarsProvider.js +76 -9
  32. package/modern/cssVars/cssVarsParser.js +18 -16
  33. package/modern/cssVars/getInitColorSchemeScript.js +1 -1
  34. package/modern/index.js +1 -1
  35. package/modern/useThemeProps/getThemeProps.js +2 -17
  36. package/package.json +5 -5
  37. package/styleFunctionSx/styleFunctionSx.d.ts +1 -1
  38. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
  39. package/useThemeProps/getThemeProps.js +2 -17
package/Box/Box.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/CHANGELOG.md CHANGED
@@ -1,5 +1,283 @@
1
1
  ### [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.2.5
4
+
5
+ <!-- generated comparing v5.2.4..master -->
6
+
7
+ _Dec 20, 2021_
8
+
9
+ A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 🛠 This release mostly improves what's behind the scenes: infrastructure and tests
12
+ - 📓 Danish (da-DK) locale was added (#29485) @mikk5829
13
+ - 🖌 Polished the design of Base components (#30149) and the docs in general (#29994) @danilo-leal
14
+ - 📚 Many additions and improvements to the documentation were made
15
+
16
+ ### `@mui/material@5.2.5`
17
+
18
+ - [l10n] Add Danish (da-DK) locale (#29485) @mikk5829
19
+ - [LoadingButton] Label progressbar by the LoadingButton (#30002) @eps1lon
20
+ - [Tabs] Remove unnecessary `Partial<>` type around TabIndicatorProps type (#30254) @ZeeshanTamboli
21
+
22
+ ### `@mui/system@5.2.5`
23
+
24
+ - [system] Use `useEnhancedEffect` to prevent flicker (#30216) @hbjORbj
25
+
26
+ ### `@mui/lab@5.0.0-alpha.61`
27
+
28
+ - [pickers] Fix the wrong MuiClockPicker's ArrowSwitcher slot name (#30226) @rejetto
29
+
30
+ ### Docs
31
+
32
+ - [docs] Run JS compiler on markdown output (#29732) @Janpot
33
+ - [Badge] Add tests for `anchorOrigin` prop (#30147) @daniel-sachs
34
+ - [docs] Add cssmodule injection order comments to Nextjs example (#30213) @ShuPink
35
+ - [docs] Remove extra word in Select component code example comments (#30281) @KThompso
36
+ - [docs] Improve the description of the Accordion (#30253) @jamesmelzer
37
+ - [docs] Heading capitalization convention @oliviertassinari
38
+ - [docs] Rename remaining 'unstyled' references to 'base' (#30206) @michaldudak
39
+ - [docs] Add to migration doc about ref type specificity (#30114) @hbjORbj
40
+ - [docs] Add script to clone pages (#30107) @siriwatknp
41
+ - [docs] Correct colors in breakpoints documentation (#30219) @michaldudak
42
+ - [docs] Sync icon search UI state with the url (#30075) @Janpot
43
+ - [docs] Base components demos design polish (#30149) @danilo-leal
44
+ - [docs] General documentation polish (#29994) @danilo-leal
45
+ - [examples] Fix typo in the remix example's README (#30289) @lemol
46
+ - [website] Remove expired gold sponsor (#30222) @oliviertassinari
47
+ - [website] Remove broken showcase links (#30217) @mnajdova
48
+
49
+ ### Core
50
+
51
+ - [test] Reduce bundle size comparison memory consumption (#30195) @Janpot
52
+ - [core] make snapshot comparison more resilient (#30183) @Janpot
53
+ - [core] update formatted ts demo to support new structure (#30248) @siriwatknp
54
+ - [core] cache dependencies in github actions (#30211) @siriwatknp
55
+ - [core] fix root package version (#30204) @siriwatknp
56
+ - [core] Fail the build when the dangerjs script errors (#30186) @Janpot
57
+ - [test] Add E2E website tests (#30128) @siriwatknp
58
+
59
+ All contributors of this release in alphabetical order: @daniel-sachs, @danilo-leal, @eps1lon, @hbjORbj, @jamesmelzer, @Janpot, @KThompso, @lemol, @michaldudak, @mikk5829, @mnajdova, @oliviertassinari, @rejetto, @ShuPink, @siriwatknp, @ZeeshanTamboli
60
+
61
+ ## 5.2.4
62
+
63
+ <!-- generated comparing v5.2.3..master -->
64
+
65
+ _Dec 14, 2021_
66
+
67
+ A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:
68
+
69
+ - ✨ Add `not` operator to `theme.breakpoints` (#29311) @Philipp000
70
+
71
+ ```js
72
+ const styles = (theme) => ({
73
+ root: {
74
+ backgroundColor: 'blue',
75
+ // Match [xs, md) and [md + 1, ∞)
76
+ // [xs, md) and [lg, ∞)
77
+ // [0px, 900px) and [1200px, ∞)
78
+ [theme.breakpoints.not('md')]: {
79
+ backgroundColor: 'red',
80
+ },
81
+ },
82
+ });
83
+ ```
84
+
85
+ - And many more 🐛 bug fixes and 📚 improvements.
86
+
87
+ ### `@mui/material@5.2.4`
88
+
89
+ - &#8203;<!-- 14 -->[esm] Correct a styles imports (#29976) @Janpot
90
+ - &#8203;<!-- 12 -->[GlobalStyles] Fix `theme` type (#30072) @mnajdova
91
+ - &#8203;<!-- 11 -->[Grid] Fix grid items to respond to the container's responsive columns (#29715) @kkorach
92
+ - &#8203;<!-- 04 -->[TextField] Fix missing space before asterisk in `OutlinedInput`'s label (#29630) @alisasanib
93
+ - &#8203;<!-- 03 -->[Transition] Allow any valid HTML attribute to be passed (#29888) @Janpot
94
+ - &#8203;<!-- 02 -->[types] Fix discrepancy between core and system `ThemeOptions` (#30095) @fmeum
95
+ - &#8203;<!-- 09 -->[InputBase] Add prop for disabling global styles (#29213) @bryan-hunter
96
+ - &#8203;<!-- 08 -->[Select] Improve multiple logic (#30135) @ladygo93
97
+
98
+ ### `@mui/system@5.2.4`
99
+
100
+ - &#8203;<!-- 06 -->[system] Don't transition when re-appearing (#30108) @eps1lon
101
+ - &#8203;<!-- 05 -->[system] Add `not` operator to `breakpoints` (#29311) @Philipp000
102
+
103
+ ### `@mui/base@5.0.0-alpha.60`
104
+
105
+ - &#8203;<!-- 25 -->[BadgeUnstyled] Make it conformant with other base components (#30141) @mnajdova
106
+
107
+ ### `@mui/icons-material@5.2.4`
108
+
109
+ - &#8203;<!-- 10 -->[icons] Correct location of icon download folder (#29839) @yaboi
110
+
111
+ ### Docs
112
+
113
+ - &#8203;<!-- 22 -->[docs] Explain the use of Select's label in FormControl (#30189) @michaldudak
114
+ - &#8203;<!-- 21 -->[docs] Don't run nprogress on shallow routing (#30087) @Janpot
115
+ - &#8203;<!-- 20 -->[docs] Add Data Driven Forms to related projects (#30078) @rvsia
116
+ - &#8203;<!-- 19 -->[docs] Sync translations with Crowdin (#30067) @l10nbot
117
+ - &#8203;<!-- 18 -->[docs] Fix link on "Custom variables" section in the Theming page #30100 @danilo-leal
118
+ - &#8203;<!-- 17 -->[docs] Fix justifyContent option in the Grid interactive demo (#30117) @danilo-leal
119
+ - &#8203;<!-- 16 -->[docs] Add tip to help access the docs of a previous version when finding answers in StackOverflow (#30101) @danilo-leal
120
+ - &#8203;<!-- 15 -->[docs] Fix import example inside Unstyled Backdrop section (#30098) @TheodosiouTh
121
+ - &#8203;<!-- 01 -->[website] Column pinning and Tree data are out (#30136) @oliviertassinari
122
+ - &#8203;<!-- 07 -->[survey] Remove survey promotion items (#30122) @danilo-leal
123
+
124
+ ### Core
125
+
126
+ - &#8203;<!-- 23 -->[core] Fix link to Open Collective @oliviertassinari
127
+ - &#8203;<!-- 26 -->[core] Update snapshots and s3 fallback (#30134) @Janpot
128
+ - &#8203;<!-- 24 -->[ci] Update CI bucket (#30080) @Janpot
129
+ - &#8203;<!-- 13 -->[fix] size:snapshot for mui-material-next and mui-joy components (#30106) @Janpot
130
+
131
+ All contributors of this release in alphabetical order: @alisasanib, @bryan-hunter, @danilo-leal, @eps1lon, @fmeum, @Janpot, @kkorach, @l10nbot, @ladygo93, @michaldudak, @mnajdova, @oliviertassinari, @Philipp000, @rvsia, @TheodosiouTh, @yaboi
132
+
133
+ ## 5.2.3
134
+
135
+ <!-- generated comparing v5.2.2..master -->
136
+
137
+ _Dec 6, 2021_
138
+
139
+ A big thanks to the 25 contributors who made this release possible. Here are some highlights ✨:
140
+
141
+ - ✨ We have introduced a new unstyled component in `@mui/base`: `TablePagination` (#29759) @mnajdova
142
+
143
+ <a href="https://mui.com/components/tables/#unstyled-table"><img width="800" alt="unstyled table" src="https://user-images.githubusercontent.com/4512430/144862194-584356ef-7d9d-462c-a631-186a7e716193.png"></a>
144
+
145
+ You can follow our progress with unstyled components at https://github.com/mui-org/material-ui/issues/27170.
146
+
147
+ - 🎉 We have added an example of how to use MUI with [Remix](https://remix.run/) (#29952) @mnajdova
148
+
149
+ - And many more 🐛 bug fixes and 📚 improvements.
150
+
151
+ ### `@mui/material@5.2.3`
152
+
153
+ - &#8203;<!-- 33 -->[Accordion] Add a test for handling `square` prop (#29972) @daniel-sachs
154
+ - &#8203;<!-- 32 -->[Alert] Fix `square` Paper prop (#30027) @ZeeshanTamboli
155
+ - &#8203;<!-- 31 -->[AvatarGroup] Allow specifying total number of avatars (#29898) @eduardomcv
156
+ - &#8203;<!-- 29 -->[Button] Fix regression from context API (#29982) @siriwatknp
157
+ - &#8203;<!-- 13 -->[Grid] Fix generated classes for `spacing` prop when the value is object (#29880) @jayeclark
158
+ - &#8203;<!-- 10 -->[Select] Should not crash when an empty array is passed with `multiple` enabled (#29957) @Domino987
159
+
160
+ ### `@mui/system@5.2.3`
161
+
162
+ - &#8203;<!-- 06 -->[system] Fix return type of `createBox` (#29989) @mnajdova
163
+ - &#8203;<!-- 05 -->[system] Support boolean values in typescript for the `sx` prop when used as array (#29911) @tasugi
164
+
165
+ ### `@mui/utils@5.2.3`
166
+
167
+ - &#8203;<!-- 03 -->[utils] Add typings for `@mui-material/styles/cssUtils` (#29621) @Semigradsky
168
+
169
+ ### `@mui/icons-material@5.2.1`
170
+
171
+ - &#8203;<!-- 12 -->[icons] Consolidate ignored icons into one list (#29843) @chao813
172
+
173
+ ### `@mui/base@5.0.0-alpha.59`
174
+
175
+ - &#8203;<!-- 30 -->[base] Fix missing ClickAwayListener barrel index export (#30000) @oliviertassinari
176
+ - &#8203;<!-- 04 -->[TablePaginationUnstyled] Introduce new component (#29759) @mnajdova
177
+
178
+ ### `@mui/lab@5.0.0-alpha.59`
179
+
180
+ - &#8203;<!-- 27 -->[DateRangePicker] Fix `DateRangePickerDayProps` interface (#29067) @jonathanrtuck
181
+ - &#8203;<!-- 10 -->[Pickers] Remove propagation of custom props to the `MonthPicker` component's DOM element (#30021) @ZeeshanTamboli
182
+ - &#8203;<!-- 08 -->[StaticDatePicker] Add className and slot to PickerStaticWrapper (#29619) @kkorach
183
+
184
+ ### `@mui/joy@5.0.0-alpha.5`
185
+
186
+ - &#8203;<!-- 11 -->[Joy] Theme setup (#29846) @siriwatknp
187
+
188
+ ### Docs
189
+
190
+ - &#8203;<!-- 34 -->[docs] Fix link in TypeScript doc page (#30044) @genzyy
191
+ - &#8203;<!-- 26 -->[docs] Remove the 'WIP' icon from the 'Group & Pivot' page title (#30077) @flaviendelangle
192
+ - &#8203;<!-- 25 -->[docs] Add warning that `@mui/styled-engine-sc` does not work in SSR (#30026) @mnajdova
193
+ - &#8203;<!-- 24 -->[docs] Add section for CSS specificity in the migration guide (#30008) @hbjORbj
194
+ - &#8203;<!-- 28 -->[docs] Clarify comment in migration doc (#30076) @hbjORbj
195
+ - &#8203;<!-- 23 -->[docs] Sync translations with Crowdin (#30041) @l10nbot
196
+ - &#8203;<!-- 22 -->[docs] Explain how Paper changes shade in dark mode (#30003) @michaldudak
197
+ - &#8203;<!-- 21 -->[docs] Update nextjs-typescript-example (#29974) @huydhoang
198
+ - &#8203;<!-- 20 -->[docs] Add missing global state classes to API docs generator (#29945) @michaldudak
199
+ - &#8203;<!-- 19 -->[docs] Fix benchmarks folder link (#29981) @fourjr
200
+ - &#8203;<!-- 18 -->[docs] Improve wording in StackOverflow section of support page (#29956) @ronwarner
201
+ - &#8203;<!-- 17 -->[docs] Remove Black Friday sale notification (#29936) @mbrookes
202
+ - &#8203;<!-- 16 -->[examples] Fix typos in the Remix example (#30071) @MichaelDeBoey
203
+ - &#8203;<!-- 15 -->[examples] Add Remix example (#29952) @mnajdova
204
+ - &#8203;<!-- 14 -->[examples] Fix lint issue for displayName missing in the Next.js examples (#29985) @ZeeshanTamboli
205
+ - &#8203;<!-- 09 -->[Stack] Document system props in Stack API (#30069) @ThewBear
206
+ - &#8203;<!-- 07 -->[survey] Add a banner and card for promoting the 2021 survey (#29950) @danilo-leal
207
+ - &#8203;<!-- 02 -->[website] Correct the Careers page description (#30073) @michaldudak
208
+ - &#8203;<!-- 01 -->[website] Fix 301 links (#30040) @oliviertassinari
209
+
210
+ ### Core
211
+
212
+ - &#8203;<!-- 31 -->[core] Batch small changes (#30042) @oliviertassinari
213
+ - &#8203;<!-- 28 -->[core] Transition to a new StackOverflow tag (#29967) @oliviertassinari
214
+
215
+ All contributors of this release in alphabetical order: @chao813, @daniel-sachs, @danilo-leal, @Domino987, @eduardomcv, @flaviendelangle, @fourjr, @genzyy, @hbjORbj, @huydhoang, @jayeclark, @jonathanrtuck, @kkorach, @l10nbot, @mbrookes, @MichaelDeBoey, @michaldudak, @mnajdova, @oliviertassinari, @ronwarner, @Semigradsky, @siriwatknp, @tasugi, @ThewBear, @ZeeshanTamboli
216
+
217
+ ## 5.2.2
218
+
219
+ <!-- generated comparing v5.2.1..master -->
220
+
221
+ _Nov 29, 2021_
222
+
223
+ A big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
224
+
225
+ - ♿️ Improved accessibility of `Snackbar` and `TextField` in `@mui/material` (#29782) (#29850) (#29852) @eps1lon.
226
+ - 🎉 Added support for `sx` syntax inside `styled()` utility (#29833) @mnajdova.
227
+ - 🎉 Added support for more options for `createCssVarsProvider` in `@mui/system` (#29845) (#29857) @hbjORbj.
228
+ - And many more 🐛 bug fixes and 📚 improvements.
229
+
230
+ ### `@mui/material@5.2.2`
231
+
232
+ - &#8203;<!-- 14 -->[MenuList] Add component prop (#29882) @Harshikerfuffle
233
+ - &#8203;<!-- 13 -->[Snackbar] Interrupt auto-hide on keyboard interaction (#29852) @eps1lon
234
+ - &#8203;<!-- 12 -->[Snackbar] Dismiss on Escape press (#29850) @eps1lon
235
+ - &#8203;<!-- 06 -->[TextField] Associate accessible name and description by default (#29782) @eps1lon
236
+
237
+ ### `@mui/joy@5.0.0-alpha.4`
238
+
239
+ - &#8203;<!-- 15 -->[Joy] Add `Button` - 1st iteration (#29464) @siriwatknp
240
+
241
+ ### `@mui/codemod@5.2.1`
242
+
243
+ - &#8203;<!-- 28 -->[codemod] Fix alias import for box-sx-prop (#29902) @siriwatknp
244
+
245
+ ### `@mui/system@5.2.2`
246
+
247
+ - &#8203;<!-- 11 -->[system] CSSVarsProvider cleans up `html[style]` when unmounting (#29946) @eps1lon
248
+ - &#8203;<!-- 10 -->[system] Add support for `disableTransitionOnChange` in `createCssVarsProvider` (#29857) @hbjORbj
249
+ - &#8203;<!-- 09 -->[system] Add support for `enableColorScheme` in `createCssVarsProvider` (#29845) @hbjORbj
250
+
251
+ ### `@mui/utils@5.2.2`
252
+
253
+ - &#8203;<!-- 05 -->[useId] Trade random collisions for collisions on overflow (#29781) @eps1lon
254
+ - &#8203;<!-- 04 -->[useIsFocusVisible] Convert to TypeScript (#29779) @eps1lon
255
+
256
+ ### Docs
257
+
258
+ - &#8203;<!-- 24 -->[docs] Fix v5-beta confusing example description (#29932) @oliviertassinari
259
+ - &#8203;<!-- 23 -->[docs] Apply the z-index on the right DOM element (#29934) @oliviertassinari
260
+ - &#8203;<!-- 22 -->[docs] Improve git diff format (#29935) @oliviertassinari
261
+ - &#8203;<!-- 21 -->[docs] Fix typo (#29866) @sinclairity
262
+ - &#8203;<!-- 20 -->[docs] Fix key display (#29933) @oliviertassinari
263
+ - &#8203;<!-- 19 -->[docs] Fix outdated link to next/link docs (#29937) @radlinskii
264
+ - &#8203;<!-- 18 -->[docs] Add how to pass `sx` prop (#29905) @siriwatknp
265
+ - &#8203;<!-- 17 -->[docs] Fix typo in notifications @mbrookes
266
+ - &#8203;<!-- 16 -->[docs] Black Friday sale notification @mbrookes
267
+ - &#8203;<!-- 03 -->[website] Fix canonical links (#29938) @oliviertassinari
268
+ - &#8203;<!-- 02 -->[website] Fix SEO issues (#29939) @oliviertassinari
269
+ - &#8203;<!-- 01 -->[website] Improvements to the /x product page (#28964) @danilo-leal
270
+
271
+ ### Core
272
+
273
+ - &#8203;<!-- 27 -->[core] Remove dead code (#29940) @oliviertassinari
274
+ - &#8203;<!-- 26 -->[core] Move benchmark CI job from AZP to CircleCI (#29894) @eps1lon
275
+ - &#8203;<!-- 25 -->[core] Fix PR detection pattern in test_bundle_size_monitor (#29895) @eps1lon
276
+ - &#8203;<!-- 08 -->[test] Fix browser tests (#29929) @eps1lon
277
+ - &#8203;<!-- 07 -->[test] Reject shorthand properties in style matchers (#29893) @eps1lon
278
+
279
+ All contributors of this release in alphabetical order: @danilo-leal, @eps1lon, @Harshikerfuffle, @hbjORbj, @mbrookes, @oliviertassinari, @radlinskii, @sinclairity, @siriwatknp
280
+
3
281
  ## 5.2.1
4
282
 
5
283
  <!-- generated comparing v5.2.0..master -->
@@ -2004,7 +2282,7 @@ _May 31, 2021_
2004
2282
  A big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
2005
2283
 
2006
2284
  - 👩‍🎤 We have completed the migration to emotion of all the components (`@material-ui/core` and `@material-ui/lab`) @siriwatknp, @mnajdova.
2007
- - 📦 Save [10 kB gzipped](https://bundlephobia.com/result?p=@material-ui/core@5.0.0-alpha.34) by removing the dependency on `@material-ui/styles` (JSS) from the core and the lab (#26377, #26382, #26376) @mnajdova.
2285
+ - 📦 Save [10 kB gzipped](https://bundlephobia.com/package/@material-ui/core@5.0.0-alpha.34) by removing the dependency on `@material-ui/styles` (JSS) from the core and the lab (#26377, #26382, #26376) @mnajdova.
2008
2286
  - ⚒️ Add many new [codemods](https://github.com/mui-org/material-ui/blob/HEAD/packages/mui-codemod/README.md) to automate the migration from v4 to v5 (#24867) @mbrookes.
2009
2287
  - And many more 🐛 bug fixes and 📚 improvements.
2010
2288
 
package/createBox.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
1
+ import Box from './Box';
2
2
 
3
3
  export default function createBox(options?: {
4
4
  defaultTheme: object;
5
5
  defaultClassName?: string;
6
- generateClassName?: () => string;
7
- }): React.ElementType;
6
+ generateClassName?: (componentName: string) => string;
7
+ }): typeof Box;
@@ -0,0 +1 @@
1
+ export {};
@@ -55,6 +55,12 @@ export interface Breakpoints {
55
55
  * @see [API documentation](https://mui.com/customization/breakpoints/#theme-breakpoints-only-key-media-query)
56
56
  */
57
57
  only: (key: Breakpoint) => string;
58
+ /**
59
+ * @param key - A breakpoint key (`xs`, `sm`, etc.).
60
+ * @returns A media query string ready to be used with most styling solutions, which matches screen widths stopping at
61
+ * the screen size given by the breakpoint key (exclusive) and starting at the screen size given by the next breakpoint key (inclusive).
62
+ */
63
+ not: (key: Breakpoint) => string;
58
64
  }
59
65
 
60
66
  export interface BreakpointsOptions extends Partial<Breakpoints> {
@@ -64,6 +64,21 @@ function createBreakpoints(breakpoints) {
64
64
  return up(key);
65
65
  }
66
66
 
67
+ function not(key) {
68
+ // handle first and last key separately, for better readability
69
+ const keyIndex = keys.indexOf(key);
70
+
71
+ if (keyIndex === 0) {
72
+ return up(keys[1]);
73
+ }
74
+
75
+ if (keyIndex === keys.length - 1) {
76
+ return down(keys[keyIndex]);
77
+ }
78
+
79
+ return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
80
+ }
81
+
67
82
  return (0, _extends2.default)({
68
83
  keys,
69
84
  values,
@@ -71,6 +86,7 @@ function createBreakpoints(breakpoints) {
71
86
  down,
72
87
  between,
73
88
  only,
89
+ not,
74
90
  unit
75
91
  }, other);
76
92
  }
@@ -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;
@@ -1,9 +1,6 @@
1
1
  import * as React from 'react';
2
- import { Result, Mode } from './useCurrentColorScheme';
3
-
4
- type RequiredDeep<T> = {
5
- [K in keyof T]-?: RequiredDeep<T[K]>;
6
- };
2
+ import getInitColorSchemeScript from './getInitColorSchemeScript';
3
+ import { Mode, Result } from './useCurrentColorScheme';
7
4
 
8
5
  export type BuildCssVarsTheme<ThemeInput> = ThemeInput extends {
9
6
  colorSchemes: Record<string, infer ColorSystems>;
@@ -25,7 +22,16 @@ type DecideTheme<
25
22
  ApplicationTheme extends { colorSchemes: Record<ApplicationColorScheme, any> },
26
23
  ApplicationColorScheme extends string | never,
27
24
  > = [ApplicationColorScheme] extends [never]
28
- ? { theme?: DesignSystemTheme }
25
+ ? {
26
+ theme?: Omit<DesignSystemTheme, 'colorSchemes'> & {
27
+ colorSchemes?: Partial<
28
+ Record<
29
+ DesignSystemColorScheme,
30
+ DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
31
+ >
32
+ >;
33
+ };
34
+ }
29
35
  : {
30
36
  theme: Omit<ApplicationTheme, 'colorSchemes'> & {
31
37
  colorSchemes: Partial<
@@ -34,9 +40,7 @@ type DecideTheme<
34
40
  DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
35
41
  >
36
42
  > &
37
- RequiredDeep<
38
- Record<ApplicationColorScheme, ApplicationTheme['colorSchemes'][ApplicationColorScheme]>
39
- >;
43
+ Record<ApplicationColorScheme, ApplicationTheme['colorSchemes'][ApplicationColorScheme]>;
40
44
  };
41
45
  };
42
46
 
@@ -70,6 +74,16 @@ export default function createCssVarsProvider<
70
74
  * @default 'light'
71
75
  */
72
76
  defaultMode?: Mode;
77
+ /**
78
+ * Disable CSS transitions when switching between modes or color schemes
79
+ * @default false
80
+ */
81
+ disableTransitionOnChange?: boolean;
82
+ /**
83
+ * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
84
+ * @default true
85
+ */
86
+ enableColorScheme?: boolean;
73
87
  /**
74
88
  * CSS variable prefix
75
89
  * @default ''
@@ -124,7 +138,7 @@ export default function createCssVarsProvider<
124
138
  >,
125
139
  ) => React.ReactElement;
126
140
  useColorScheme: () => ColorSchemeContextValue<DesignSystemColorScheme | ApplicationColorScheme>;
127
- getInitColorSchemeScript: () => React.ReactElement;
141
+ getInitColorSchemeScript: typeof getInitColorSchemeScript;
128
142
  };
129
143
 
130
144
  // disable automatic export
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.DISABLE_CSS_TRANSITION = void 0;
8
9
  exports.default = createCssVarsProvider;
9
10
 
10
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -19,6 +20,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
19
20
 
20
21
  var _styledEngine = require("@mui/styled-engine");
21
22
 
23
+ var _createSpacing = _interopRequireDefault(require("../createTheme/createSpacing"));
24
+
25
+ var _createBreakpoints = _interopRequireDefault(require("../createTheme/createBreakpoints"));
26
+
22
27
  var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
23
28
 
24
29
  var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
@@ -30,20 +35,30 @@ var _useCurrentColorScheme = _interopRequireDefault(require("./useCurrentColorSc
30
35
  var _jsxRuntime = require("react/jsx-runtime");
31
36
 
32
37
  const _excluded = ["colorSchemes"],
33
- _excluded2 = ["colorSchemes"];
38
+ _excluded2 = ["colorSchemes"],
39
+ _excluded3 = ["components"];
34
40
 
35
41
  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); }
36
42
 
37
43
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
38
44
 
45
+ const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
46
+ exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
47
+
39
48
  function createCssVarsProvider(options) {
49
+ var _baseTheme$breakpoint;
50
+
40
51
  const {
41
52
  theme: baseTheme = {},
42
53
  defaultMode: desisgnSystemMode = 'light',
43
54
  defaultColorScheme: designSystemColorScheme,
55
+ disableTransitionOnChange = false,
56
+ enableColorScheme = true,
44
57
  prefix: designSystemPrefix = '',
45
58
  shouldSkipGeneratingVar
46
59
  } = options;
60
+ const systemSpacing = (0, _createSpacing.default)(baseTheme.spacing);
61
+ const systemBreakpoints = (0, _createBreakpoints.default)((_baseTheme$breakpoint = baseTheme.breakpoints) != null ? _baseTheme$breakpoint : {});
47
62
 
48
63
  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]) {
49
64
  console.error(`MUI: \`${designSystemColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
@@ -70,15 +85,25 @@ function createCssVarsProvider(options) {
70
85
  defaultMode = desisgnSystemMode,
71
86
  defaultColorScheme = designSystemColorScheme
72
87
  }) {
88
+ // make sure that baseTheme is always independent of each <CssVarsProvider /> call.
89
+ // JSON.parse(JSON.stringify(...)) is okay to be used as long as the baseTheme is a plain object.
90
+ const clonedBaseTheme = React.useMemo(() => JSON.parse(JSON.stringify(baseTheme)), []);
73
91
  const {
74
92
  colorSchemes: baseColorSchemes = {}
75
- } = baseTheme,
76
- restBaseTheme = (0, _objectWithoutPropertiesLoose2.default)(baseTheme, _excluded);
93
+ } = clonedBaseTheme,
94
+ restBaseTheme = (0, _objectWithoutPropertiesLoose2.default)(clonedBaseTheme, _excluded);
77
95
  const {
78
96
  colorSchemes: colorSchemesProp = {}
79
97
  } = themeProp,
80
98
  restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded2);
81
- let mergedTheme = (0, _utils.deepmerge)(restBaseTheme, restThemeProp);
99
+ const hasMounted = React.useRef(false); // eslint-disable-next-line prefer-const
100
+
101
+ let _deepmerge = (0, _utils.deepmerge)(restBaseTheme, restThemeProp),
102
+ {
103
+ components = {}
104
+ } = _deepmerge,
105
+ mergedTheme = (0, _objectWithoutPropertiesLoose2.default)(_deepmerge, _excluded3);
106
+
82
107
  const colorSchemes = (0, _utils.deepmerge)(baseColorSchemes, colorSchemesProp);
83
108
  const allColorSchemes = Object.keys(colorSchemes);
84
109
  const defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
@@ -86,6 +111,7 @@ function createCssVarsProvider(options) {
86
111
  const {
87
112
  mode,
88
113
  setMode,
114
+ systemMode,
89
115
  lightColorScheme,
90
116
  darkColorScheme,
91
117
  colorScheme,
@@ -121,8 +147,11 @@ function createCssVarsProvider(options) {
121
147
  shouldSkipGeneratingVar
122
148
  });
123
149
  mergedTheme = (0, _extends2.default)({}, mergedTheme, colorSchemes[resolvedColorScheme], {
150
+ components,
124
151
  colorSchemes,
125
- vars: rootVars
152
+ vars: rootVars,
153
+ spacing: themeProp.spacing ? (0, _createSpacing.default)(themeProp.spacing) : systemSpacing,
154
+ breakpoints: themeProp.breakpoints ? (0, _createBreakpoints.default)(themeProp.breakpoints) : systemBreakpoints
126
155
  });
127
156
  const styleSheet = {};
128
157
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
@@ -156,9 +185,53 @@ function createCssVarsProvider(options) {
156
185
  });
157
186
  React.useEffect(() => {
158
187
  if (colorScheme) {
159
- document.body.setAttribute(attribute, colorScheme);
188
+ // attaches attribute to <html> because the css variables are attached to :root (html)
189
+ document.documentElement.setAttribute(attribute, colorScheme);
160
190
  }
161
191
  }, [colorScheme, attribute]);
192
+ (0, _utils.unstable_useEnhancedEffect)(() => {
193
+ if (!mode || !enableColorScheme) {
194
+ return undefined;
195
+ }
196
+
197
+ const priorColorScheme = document.documentElement.style.getPropertyValue('color-scheme'); // `color-scheme` tells browser to render built-in elements according to its value: `light` or `dark`
198
+
199
+ if (mode === 'system') {
200
+ document.documentElement.style.setProperty('color-scheme', systemMode);
201
+ } else {
202
+ document.documentElement.style.setProperty('color-scheme', mode);
203
+ }
204
+
205
+ return () => {
206
+ document.documentElement.style.setProperty('color-scheme', priorColorScheme);
207
+ };
208
+ }, [mode, systemMode]);
209
+ React.useEffect(() => {
210
+ let timer;
211
+
212
+ if (disableTransitionOnChange && hasMounted.current) {
213
+ // credit: https://github.com/pacocoursey/next-themes/blob/b5c2bad50de2d61ad7b52a9c5cdc801a78507d7a/index.tsx#L313
214
+ const css = document.createElement('style');
215
+ css.appendChild(document.createTextNode(DISABLE_CSS_TRANSITION));
216
+ document.head.appendChild(css); // Force browser repaint
217
+
218
+ (() => window.getComputedStyle(document.body))();
219
+
220
+ timer = setTimeout(() => {
221
+ document.head.removeChild(css);
222
+ }, 1);
223
+ }
224
+
225
+ return () => {
226
+ clearTimeout(timer);
227
+ };
228
+ }, [colorScheme]);
229
+ React.useEffect(() => {
230
+ hasMounted.current = true;
231
+ return () => {
232
+ hasMounted.current = false;
233
+ };
234
+ }, []);
162
235
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ColorSchemeContext.Provider, {
163
236
  value: {
164
237
  mode,
@@ -189,7 +262,7 @@ function createCssVarsProvider(options) {
189
262
  attribute: _propTypes.default.string,
190
263
 
191
264
  /**
192
- * Your component tree.
265
+ * The component tree.
193
266
  */
194
267
  children: _propTypes.default.node,
195
268
 
@@ -209,7 +282,7 @@ function createCssVarsProvider(options) {
209
282
  modeStorageKey: _propTypes.default.string,
210
283
 
211
284
  /**
212
- * css variable prefix
285
+ * CSS variable prefix.
213
286
  */
214
287
  prefix: _propTypes.default.string,
215
288
 
@@ -1 +1 @@
1
- export {};
1
+ export {};