@mui/material-nextjs 6.4.3 → 6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,304 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 6.5.0
4
+
5
+ <!-- generated comparing v6.4.12..v6.x -->
6
+
7
+ _Jul 2, 2025_
8
+
9
+ A big thanks to the 2 contributors who made this release possible.
10
+
11
+ CSS layers make it easier to override styles by splitting a single style sheet into multiple layers.
12
+ To learn more, check out the [CSS layers documentation](https://v6.mui.com/material-ui/customization/css-layers/).
13
+
14
+ ### `@mui/material@6.5.0`
15
+
16
+ - [Dialog] Add codemod for deprecated props (#46335) @sai6855
17
+
18
+ ### `@mui/system@6.5.0`
19
+
20
+ - Backport CSS layers feature from v7 (#46283) @siriwatknp
21
+
22
+ ### `@mui/material-nextjs@6.5.0`
23
+
24
+ - Backport CSS layers feature from v7 (#46283) @siriwatknp
25
+
26
+ ### Docs
27
+
28
+ - Add ListItemButton to make the deprecation clear (#46357) @sai6855
29
+
30
+ All contributors of this release in alphabetical order: @sai6855, @siriwatknp
31
+
32
+ ## 6.4.12
33
+
34
+ <!-- generated comparing v6.4.11..v6.x -->
35
+
36
+ _May 30, 2025_
37
+
38
+ A big thanks to the 7 contributors who made this release possible.
39
+
40
+ ### `@mui/material@6.4.12`
41
+
42
+ - [Badge] Replace useSlotProps with useSlot hook (#45876) @sai6855
43
+ - [BottomNavigationAction] Add slots and slotProps (#45875) @sai6855
44
+ - [CardActionArea] Add slots and slotProps (#45877) @sai6855
45
+ - [OutlinedInput] Add missing `notchedOutline` slot (#45938) @siriwatknp
46
+ - [useMediaQuery] Add warning and docs for using `useMediaQuery('print')` (#45886) @good-jinu
47
+ - Fix theme object changes between renders (#45874) @siriwatknp
48
+
49
+ ### `@mui/material-nextjs@6.4.12`
50
+
51
+ - Do not wrap `@layer` order rules in App Router (#45870) @Nayeem-XTREME
52
+
53
+ ### `@mui/system@6.4.12`
54
+
55
+ - Skip styled component from being transformed (#46184) @siriwatknp
56
+
57
+ ### Docs
58
+
59
+ - [Dialog] Remove deprecated props usage in demos (#45928) @sai6855
60
+ - [Grid] Update grid migration guide (#46153) @sai6855
61
+ - [Menu] Update `paper` slot JSDoc default from `Paper` to `PopoverPaper` (@andreachiera) (#45865) @andreachiera
62
+ - Update CSS variable usage in migration guide for Pigment CSS (#46038) @sai6855
63
+ - Remove outdated StackOverflow tag (9b9f96b) @oliviertassinari
64
+ - Update `@mui/icons-material` install command to use 6.x version (#45810) @Nickknack
65
+ - Add AccordionSummary to the breaking change migration (#45973) @siriwatknp
66
+
67
+ All contributors of this release in alphabetical order: @andreachiera, @good-jinu, @Nayeem-XTREME, @Nickknack, @oliviertassinari, @sai6855, @siriwatknp
68
+
69
+ ## 6.4.11
70
+
71
+ _Apr 9, 2025_
72
+
73
+ A big thanks to the 3 contributors who made this release possible.
74
+
75
+ ### `@mui/material@6.4.11`
76
+
77
+ - [AvatarGroup] Fix `spacing` prop ignoring value `0` (#45845) @Kartik-Murthy
78
+ - [Dialog] Deprecate composed classes (#45814) @sai6855
79
+
80
+ ### `@mui/styled-engine@6.4.11`
81
+
82
+ - Add caching to improve performance for running tests with Jest (#45855) @siriwatknp
83
+
84
+ ### Docs
85
+
86
+ - Add missing v7 docs banner (#45842) @DiegoAndai
87
+ - Add v7 is here banner (#45838) @DiegoAndai
88
+ - Fix lab version install instructions (#45770) @DiegoAndai
89
+
90
+ All contributors of this release in alphabetical order: @DiegoAndai, @Kartik-Murthy, @sai6855
91
+
92
+ ## 6.4.10
93
+
94
+ <!-- generated comparing v6.4.9..v6.x -->
95
+
96
+ _Mar 31, 2025_
97
+
98
+ A big thanks to the 4 contributors who made this release possible.
99
+
100
+ ### `@mui/material@6.4.10`
101
+
102
+ - [Autocomplete] Prevent shrink animation in controlled Autocomplete when initial `value` is provided (#45735) @imadx
103
+ - [Popover] Allow `null` in `anchorEl` function return type (#45723) @eduter
104
+
105
+ ### Docs
106
+
107
+ - Fix new React project link, CRA deprecated (#45669) @oliviertassinari
108
+
109
+ ### Core
110
+
111
+ - [utils] Support cleanup callbacks in useForkRef (#45733) @DiegoAndai
112
+
113
+ All contributors of this release in alphabetical order: @DiegoAndai, @eduter, @imadx, @oliviertassinari
114
+
115
+ ## 6.4.9
116
+
117
+ <!-- generated comparing v6.4.8..v6.x -->
118
+
119
+ _Mar 25, 2025_
120
+
121
+ A big thanks to the 7 contributors who made this release possible.
122
+
123
+ ### `@mui/material@6.4.9`
124
+
125
+ - [Autocomplete] Fix when `onHighlightChange` is called (@ZeeshanTamboli) (#45635) @ZeeshanTamboli
126
+ - [StepLabel] Add missing root slot (#45607) @sai6855
127
+ - [Switch] Add slots and slotProps (#45628) @siriwatknp
128
+ - [TextField] Add `root` slot (#45616) @sai6855
129
+ - [Tabs] Fix modifier keys + Left/Right Arrow key from being consumed by tab navigation (#45620) @mushfiqbh
130
+
131
+ ### `@mui/codemon@6.4.9`
132
+
133
+ - Add missing deprecations in deprecations-all file (#45508) @sai6855
134
+
135
+ ### Docs
136
+
137
+ - [docs] Fix grammatical errors in support.md (#45636) @letianpailove
138
+ - [docs] Restore utility component docs from MUI Base to Material UI (#45240) @mapache-salvaje
139
+
140
+ ### Core
141
+
142
+ - [core] Prepare v6 branch for v7 stable release (#45668) @DiegoAndai
143
+
144
+ All contributors of this release in alphabetical order: @DiegoAndai, @letianpailove, @mapache-salvaje, @mushfiqbh, @sai6855, @siriwatknp, @ZeeshanTamboli
145
+
146
+ ## 6.4.8
147
+
148
+ <!-- generated comparing v6.4.7..v6.x -->
149
+
150
+ _Mar 14, 2025_
151
+
152
+ A big thanks to the 9 contributors who made this release possible.
153
+
154
+ ### `@mui/material@6.4.8`
155
+
156
+ - [ListItemText] Add missing `root` slot (#45552) @sai6855
157
+ - [SpeedDial] Add missing `root` slot (#45551) @sai6855
158
+ - [Tooltip] Allow auto placement on tooltip (#45536) @Jtaks
159
+ - [useScrollTrigger] Do nothing if target is null (#45553) @vipierozan99
160
+ - [Accordion] Add missing `root` slot (#45534) @sai6855
161
+ - [AccordionSummary] Add slots and slotProps (#45560) @sai6855
162
+ - [TextareaAutosize] Fix ResizeObserver causing infinite `selectionchange` loop (#45351) (#45498) @mj12albert
163
+
164
+ ### `@mui/styled-engine@6.4.8`
165
+
166
+ - Add `enableCssLayer` prop to StyledEngineProvider (#45563) @siriwatknp
167
+
168
+ ### `@mui/system@6.4.8`
169
+
170
+ - [system] Prevent nested non-vars theme inheritance (#45564) @siriwatknp
171
+
172
+ ### `@mui/utils@6.4.8`
173
+
174
+ - Use correct iri-reference homepage format (#45511) @dahiro
175
+
176
+ ### Core
177
+
178
+ - [test] Fix React 18 tests (#45161) (#45496) @DiegoAndai
179
+
180
+ ### Docs
181
+
182
+ - [Backdrop] Fix component name in migration guide (#45507) @sai6855
183
+ - Fix broken links to MUI X docs (cherry-pick of #45145) (#45481) @mapache-salvaje
184
+ - [examples] Fix the invalid argument to extract examples (#45493) @ovtn
185
+ - Add `overriding-component-structure` doc to Material UI (#45570) @siriwatknp
186
+
187
+ All contributors of this release in alphabetical order: @dahiro, @DiegoAndai, @Jtaks, @mapache-salvaje, @mj12albert, @ovtn, @sai6855, @siriwatknp, @vipierozan99
188
+
189
+ ## 6.4.7
190
+
191
+ <!-- generated comparing v6.4.6..v6.x -->
192
+
193
+ _Mar 5, 2025_
194
+
195
+ A big thanks to the 3 contributors who made this release possible.
196
+
197
+ ### `@mui/material@6.4.7`
198
+
199
+ - [ThemeProvider] Add `storageManager` prop to `ThemeProvider` (@siriwatknp) (#45437) @siriwatknp
200
+ - [Rating] Deprecate \*Props and complete slots, slotProps (#45295) (#45398) @DiegoAndai
201
+ - [Radio] Fix `inputProps` not forwarded (@siriwatknp) (#45475) @siriwatknp
202
+
203
+ ### Core
204
+
205
+ - [blog] React 19 migration for MUI X (#45440) @arminmeh
206
+
207
+ All contributors of this release in alphabetical order: @arminmeh, @DiegoAndai, @siriwatknp
208
+
209
+ ## 6.4.6
210
+
211
+ <!-- generated comparing v6.4.5..v6.x -->
212
+
213
+ _Feb 26, 2025_
214
+
215
+ A big thanks to the 4 contributors who made this release possible.
216
+
217
+ ### `@mui/material@6.4.6`
218
+
219
+ - [Checkbox] Add slots and slotProps (#45361) @siriwatknp
220
+ - [Drawer] Deprecate \*Props and complete `slots`, `slotProps` (#45377) @siriwatknp
221
+ - [Grid] Improve Grid2 upgrade experience (#45372) @DiegoAndai
222
+ - [InputBase] Deprecate composed classes (#45366) @siriwatknp
223
+ - Fix `slotProps.transition` types (#45367) @siriwatknp
224
+ - Allow nested theme creation with `vars` (#45368) @siriwatknp
225
+ - Fix wrong slotProps of DetailsHTMLAttributes types (#45356) @siriwatknp
226
+ - [Popover] Deprecate \*Props and complete `slots`, `slotProps` (#45337) @siriwatknp
227
+ - [Radio] Add slots and slotProps (#45364) @siriwatknp
228
+ - [Slider] Fix css class selector in migration guide (#45409) @sai6855
229
+ - [Slider] Fix spacings in .md files (#45393) @sai6855
230
+ - [Snackbar] Add Slots and SlotProps (#45103) (#45352) @siriwatknp
231
+ - [SpeedDialAction] Add slots and slotProps (#45365) @siriwatknp
232
+ - [SwitchBase] Deprecate `inputProps` and complete slots, slotProps (#45338) @siriwatknp
233
+ - [Tabs] Deprecate \*Props and complete slots, slotProps (#45012) (#45355) @siriwatknp
234
+ - [Menu] Deprecate \*Props and complete `slots`, `slotProps` (#45369) @siriwatknp
235
+
236
+ ### Docs
237
+
238
+ - [Autocomplete] Remove unnecessary renderTags prop from Sizes demo (#45403) @ZeeshanTamboli
239
+ - Fix typo in slider docs (#45392) @sai6855
240
+
241
+ ### Core
242
+
243
+ - [test] Remove unused renderTags prop and fix key warning in Autocomplete regression test (#45412) @ZeeshanTamboli
244
+
245
+ All contributors of this release in alphabetical order: @DiegoAndai, @sai6855, @siriwatknp, @ZeeshanTamboli
246
+
247
+ ## 6.4.5
248
+
249
+ <!-- generated comparing v6.4.4..v6.x -->
250
+
251
+ _Feb 18, 2025_
252
+
253
+ A big thanks to the 5 contributors who made this release possible.
254
+
255
+ ### `@mui/material@6.4.5`
256
+
257
+ - [Autocomplete] Remove legacy `aria-owns` attribute for combobox (#45303) @ZeeshanTamboli
258
+ - [Button] Apply id only if loading indicator is present (#45339) @aarongarciah
259
+
260
+ ### Docs
261
+
262
+ - [icons] Fix typo in material-icons.md (#45336) @a-s-russo
263
+ - [Menu] Add Grouped Menu demo (#45292) @noobDev31
264
+
265
+ ### Core
266
+
267
+ - [blog] Consistent Base UI terminology (#45342) @aarongarciah
268
+ - Fix double redirection to Base UI (#45146) @oliviertassinari
269
+
270
+ All contributors of this release in alphabetical order: @a-s-russo, @aarongarciah, @noobDev31, @oliviertassinari, @ZeeshanTamboli
271
+
272
+ ## 6.4.4
273
+
274
+ <!-- generated comparing v6.4.3..v6.x -->
275
+
276
+ _Feb 11, 2025_
277
+
278
+ A big thanks to the 3 contributors who made this release possible.
279
+
280
+ ### `@mui/material@6.4.4`
281
+
282
+ - [MobileStepper] deprecate `LinearProgressProps` and complete `slots`, `slotProps` (@siriwatknp) (#45242) @siriwatknp
283
+ - [Slider] Deprecate composed classes (@sai6855) (#45223) @sai6855
284
+ - [utils] Merge `sx` instead of override when using `mergeSlotProps` (#45129) @siriwatknp
285
+
286
+ ### Docs
287
+
288
+ - [Autocomplete] Improve Google Maps search example (#44708) @oliviertassinari
289
+ - [Dialog] Removes deprecated PaperProps from docs (#45217) @sai6855
290
+ - A quick first step to update docs for Tailwind v4 (#45221) @oliviertassinari
291
+
292
+ ### Core
293
+
294
+ - Fix missing store contributor renaming (527222d) @oliviertassinari
295
+ - Fix MUI Base vale rule (#45140) @oliviertassinari
296
+ - Fix 404 errors (#45137) @oliviertassinari
297
+ - [docs] Sync active sponsors (#45204) @oliviertassinari
298
+ - [docs-infra] Move Ukraine banner to the bottom (#45135) @oliviertassinari
299
+
300
+ All contributors of this release in alphabetical order: @oliviertassinari, @sai6855, @siriwatknp
301
+
3
302
  ## 6.4.3
4
303
 
5
304
  <!-- generated comparing v6.4.2..v6.x -->
@@ -26,7 +26,7 @@ export default function AppRouterCacheProvider(props) {
26
26
  let inserted = [];
27
27
  // Override the insert method to support streaming SSR with flush().
28
28
  cache.insert = (...args) => {
29
- if (options?.enableCssLayer) {
29
+ if (options?.enableCssLayer && !args[1].styles.match(/^@layer\s+[^{]*$/)) {
30
30
  args[1].styles = `@layer mui {${args[1].styles}}`;
31
31
  }
32
32
  const [selector, serialized] = args;
@@ -4,14 +4,30 @@ const isBrowser = typeof document !== 'undefined';
4
4
  // On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
5
5
  // This assures that MUI styles are loaded first.
6
6
  // It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
7
- export default function createEmotionCache() {
7
+ export default function createEmotionCache(options) {
8
8
  let insertionPoint;
9
9
  if (isBrowser) {
10
10
  const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
11
11
  insertionPoint = emotionInsertionPoint ?? undefined;
12
12
  }
13
- return createCache({
13
+ const {
14
+ enableCssLayer,
15
+ ...rest
16
+ } = options ?? {};
17
+ const emotionCache = createCache({
14
18
  key: 'mui',
15
- insertionPoint
19
+ insertionPoint,
20
+ ...rest
16
21
  });
22
+ if (enableCssLayer) {
23
+ const prevInsert = emotionCache.insert;
24
+ emotionCache.insert = (...args) => {
25
+ // ignore styles that contain layer order (`@layer ...` without `{`)
26
+ if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
27
+ args[1].styles = `@layer mui {${args[1].styles}}`;
28
+ }
29
+ return prevInsert(...args);
30
+ };
31
+ }
32
+ return emotionCache;
17
33
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./pagesRouterV13Document.js";
2
- export * from "./pagesRouterV13App.js";
2
+ export * from "./pagesRouterV13App.js";
3
+ export { default as createEmotionCache } from "./createCache.js";
@@ -73,13 +73,22 @@ export async function documentGetInitialProps(ctx, options) {
73
73
  } = extractCriticalToChunks(initialProps.html);
74
74
  return {
75
75
  ...initialProps,
76
- emotionStyleTags: styles.map(style => /*#__PURE__*/_jsx("style", {
77
- "data-emotion": `${style.key} ${style.ids.join(' ')}`,
78
- // eslint-disable-next-line react/no-danger
79
- dangerouslySetInnerHTML: {
80
- __html: style.css
76
+ emotionStyleTags: styles.map(style => {
77
+ if (!style.css.trim()) {
78
+ return null;
81
79
  }
82
- }, style.key))
80
+ const isLayerOrderRule = style.css.startsWith('@layer') && !style.css.match(/\{.*\}/);
81
+ return /*#__PURE__*/_jsx("style", {
82
+ // If the style is a layer order rule, prefix with the cache key to let Emotion hydrate this node.
83
+ // Otherwise, Emotion will hydrate only the non-global styles and they will override the layer order rule.
84
+ "data-emotion": `${isLayerOrderRule ? `${cache.key} ` : ''}${style.key} ${style.ids.join(' ')}`,
85
+ // eslint-disable-next-line react/no-danger
86
+ dangerouslySetInnerHTML: {
87
+ __html: style.css
88
+ },
89
+ nonce: cache.nonce
90
+ }, style.key);
91
+ })
83
92
  };
84
93
  }
85
94
  }, ...(options?.plugins ?? [])])(ctx);
@@ -33,7 +33,7 @@ function AppRouterCacheProvider(props) {
33
33
  let inserted = [];
34
34
  // Override the insert method to support streaming SSR with flush().
35
35
  cache.insert = (...args) => {
36
- if (options?.enableCssLayer) {
36
+ if (options?.enableCssLayer && !args[1].styles.match(/^@layer\s+[^{]*$/)) {
37
37
  args[1].styles = `@layer mui {${args[1].styles}}`;
38
38
  }
39
39
  const [selector, serialized] = args;
@@ -11,14 +11,30 @@ const isBrowser = typeof document !== 'undefined';
11
11
  // On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
12
12
  // This assures that MUI styles are loaded first.
13
13
  // It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
14
- function createEmotionCache() {
14
+ function createEmotionCache(options) {
15
15
  let insertionPoint;
16
16
  if (isBrowser) {
17
17
  const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
18
18
  insertionPoint = emotionInsertionPoint ?? undefined;
19
19
  }
20
- return (0, _cache.default)({
20
+ const {
21
+ enableCssLayer,
22
+ ...rest
23
+ } = options ?? {};
24
+ const emotionCache = (0, _cache.default)({
21
25
  key: 'mui',
22
- insertionPoint
26
+ insertionPoint,
27
+ ...rest
23
28
  });
29
+ if (enableCssLayer) {
30
+ const prevInsert = emotionCache.insert;
31
+ emotionCache.insert = (...args) => {
32
+ // ignore styles that contain layer order (`@layer ...` without `{`)
33
+ if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
34
+ args[1].styles = `@layer mui {${args[1].styles}}`;
35
+ }
36
+ return prevInsert(...args);
37
+ };
38
+ }
39
+ return emotionCache;
24
40
  }
@@ -1,11 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
7
+ var _exportNames = {
8
+ createEmotionCache: true
9
+ };
10
+ Object.defineProperty(exports, "createEmotionCache", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _createCache.default;
14
+ }
15
+ });
6
16
  var _pagesRouterV13Document = require("./pagesRouterV13Document");
7
17
  Object.keys(_pagesRouterV13Document).forEach(function (key) {
8
18
  if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
9
20
  if (key in exports && exports[key] === _pagesRouterV13Document[key]) return;
10
21
  Object.defineProperty(exports, key, {
11
22
  enumerable: true,
@@ -17,6 +28,7 @@ Object.keys(_pagesRouterV13Document).forEach(function (key) {
17
28
  var _pagesRouterV13App = require("./pagesRouterV13App");
18
29
  Object.keys(_pagesRouterV13App).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
32
  if (key in exports && exports[key] === _pagesRouterV13App[key]) return;
21
33
  Object.defineProperty(exports, key, {
22
34
  enumerable: true,
@@ -24,4 +36,5 @@ Object.keys(_pagesRouterV13App).forEach(function (key) {
24
36
  return _pagesRouterV13App[key];
25
37
  }
26
38
  });
27
- });
39
+ });
40
+ var _createCache = _interopRequireDefault(require("./createCache"));
@@ -83,13 +83,22 @@ async function documentGetInitialProps(ctx, options) {
83
83
  } = extractCriticalToChunks(initialProps.html);
84
84
  return {
85
85
  ...initialProps,
86
- emotionStyleTags: styles.map(style => /*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
87
- "data-emotion": `${style.key} ${style.ids.join(' ')}`,
88
- // eslint-disable-next-line react/no-danger
89
- dangerouslySetInnerHTML: {
90
- __html: style.css
86
+ emotionStyleTags: styles.map(style => {
87
+ if (!style.css.trim()) {
88
+ return null;
91
89
  }
92
- }, style.key))
90
+ const isLayerOrderRule = style.css.startsWith('@layer') && !style.css.match(/\{.*\}/);
91
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("style", {
92
+ // If the style is a layer order rule, prefix with the cache key to let Emotion hydrate this node.
93
+ // Otherwise, Emotion will hydrate only the non-global styles and they will override the layer order rule.
94
+ "data-emotion": `${isLayerOrderRule ? `${cache.key} ` : ''}${style.key} ${style.ids.join(' ')}`,
95
+ // eslint-disable-next-line react/no-danger
96
+ dangerouslySetInnerHTML: {
97
+ __html: style.css
98
+ },
99
+ nonce: cache.nonce
100
+ }, style.key);
101
+ })
93
102
  };
94
103
  }
95
104
  }, ...(options?.plugins ?? [])])(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/material-nextjs",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Collection of utilities for integration between Material UI and Next.js.",
@@ -26,7 +26,7 @@ export default function AppRouterCacheProvider(props) {
26
26
  let inserted = [];
27
27
  // Override the insert method to support streaming SSR with flush().
28
28
  cache.insert = (...args) => {
29
- if (options?.enableCssLayer) {
29
+ if (options?.enableCssLayer && !args[1].styles.match(/^@layer\s+[^{]*$/)) {
30
30
  args[1].styles = `@layer mui {${args[1].styles}}`;
31
31
  }
32
32
  const [selector, serialized] = args;
@@ -1 +1,4 @@
1
- export default function createEmotionCache(): import("@emotion/cache").EmotionCache;
1
+ import createCache from '@emotion/cache';
2
+ export default function createEmotionCache(options?: {
3
+ enableCssLayer?: boolean;
4
+ } & Parameters<typeof createCache>[0]): import("@emotion/cache").EmotionCache;
@@ -4,14 +4,30 @@ const isBrowser = typeof document !== 'undefined';
4
4
  // On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
5
5
  // This assures that MUI styles are loaded first.
6
6
  // It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
7
- export default function createEmotionCache() {
7
+ export default function createEmotionCache(options) {
8
8
  let insertionPoint;
9
9
  if (isBrowser) {
10
10
  const emotionInsertionPoint = document.querySelector('meta[name="emotion-insertion-point"]');
11
11
  insertionPoint = emotionInsertionPoint ?? undefined;
12
12
  }
13
- return createCache({
13
+ const {
14
+ enableCssLayer,
15
+ ...rest
16
+ } = options ?? {};
17
+ const emotionCache = createCache({
14
18
  key: 'mui',
15
- insertionPoint
19
+ insertionPoint,
20
+ ...rest
16
21
  });
22
+ if (enableCssLayer) {
23
+ const prevInsert = emotionCache.insert;
24
+ emotionCache.insert = (...args) => {
25
+ // ignore styles that contain layer order (`@layer ...` without `{`)
26
+ if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
27
+ args[1].styles = `@layer mui {${args[1].styles}}`;
28
+ }
29
+ return prevInsert(...args);
30
+ };
31
+ }
32
+ return emotionCache;
17
33
  }
@@ -1,2 +1,3 @@
1
1
  export * from './pagesRouterV13Document';
2
2
  export * from './pagesRouterV13App';
3
+ export { default as createEmotionCache } from './createCache';
@@ -1,2 +1,3 @@
1
1
  export * from "./pagesRouterV13Document.js";
2
- export * from "./pagesRouterV13App.js";
2
+ export * from "./pagesRouterV13App.js";
3
+ export { default as createEmotionCache } from "./createCache.js";
@@ -73,13 +73,22 @@ export async function documentGetInitialProps(ctx, options) {
73
73
  } = extractCriticalToChunks(initialProps.html);
74
74
  return {
75
75
  ...initialProps,
76
- emotionStyleTags: styles.map(style => /*#__PURE__*/_jsx("style", {
77
- "data-emotion": `${style.key} ${style.ids.join(' ')}`,
78
- // eslint-disable-next-line react/no-danger
79
- dangerouslySetInnerHTML: {
80
- __html: style.css
76
+ emotionStyleTags: styles.map(style => {
77
+ if (!style.css.trim()) {
78
+ return null;
81
79
  }
82
- }, style.key))
80
+ const isLayerOrderRule = style.css.startsWith('@layer') && !style.css.match(/\{.*\}/);
81
+ return /*#__PURE__*/_jsx("style", {
82
+ // If the style is a layer order rule, prefix with the cache key to let Emotion hydrate this node.
83
+ // Otherwise, Emotion will hydrate only the non-global styles and they will override the layer order rule.
84
+ "data-emotion": `${isLayerOrderRule ? `${cache.key} ` : ''}${style.key} ${style.ids.join(' ')}`,
85
+ // eslint-disable-next-line react/no-danger
86
+ dangerouslySetInnerHTML: {
87
+ __html: style.css
88
+ },
89
+ nonce: cache.nonce
90
+ }, style.key);
91
+ })
83
92
  };
84
93
  }
85
94
  }, ...(options?.plugins ?? [])])(ctx);