@mui/styled-engine 6.4.3 → 6.4.8

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,161 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 6.4.8
4
+
5
+ <!-- generated comparing v6.4.7..v6.x -->
6
+
7
+ _Mar 14, 2025_
8
+
9
+ A big thanks to the 9 contributors who made this release possible.
10
+
11
+ ### `@mui/material@6.4.8`
12
+
13
+ - [ListItemText] Add missing `root` slot (#45552) @sai6855
14
+ - [SpeedDial] Add missing `root` slot (#45551) @sai6855
15
+ - [Tooltip] Allow auto placement on tooltip (#45536) @Jtaks
16
+ - [useScrollTrigger] Do nothing if target is null (#45553) @vipierozan99
17
+ - [Accordion] Add missing `root` slot (#45534) @sai6855
18
+ - [AccordionSummary] Add slots and slotProps (#45560) @sai6855
19
+ - [TextareaAutosize] Fix ResizeObserver causing infinite `selectionchange` loop (#45351) (#45498) @mj12albert
20
+
21
+ ### `@mui/styled-engine@6.4.8`
22
+
23
+ - Add `enableCssLayer` prop to StyledEngineProvider (#45563) @siriwatknp
24
+
25
+ ### `@mui/system@6.4.8`
26
+
27
+ - [system] Prevent nested non-vars theme inheritance (#45564) @siriwatknp
28
+
29
+ ### `@mui/utils@6.4.8`
30
+
31
+ - Use correct iri-reference homepage format (#45511) @dahiro
32
+
33
+ ### Core
34
+
35
+ - [test] Fix React 18 tests (#45161) (#45496) @DiegoAndai
36
+
37
+ ### Docs
38
+
39
+ - [Backdrop] Fix component name in migration guide (#45507) @sai6855
40
+ - Fix broken links to MUI X docs (cherry-pick of #45145) (#45481) @mapache-salvaje
41
+ - [examples] Fix the invalid argument to extract examples (#45493) @ovtn
42
+ - Add `overriding-component-structure` doc to Material UI (#45570) @siriwatknp
43
+
44
+ All contributors of this release in alphabetical order: @dahiro, @DiegoAndai, @Jtaks, @mapache-salvaje, @mj12albert, @ovtn, @sai6855, @siriwatknp, @vipierozan99
45
+
46
+ ## 6.4.7
47
+
48
+ <!-- generated comparing v6.4.6..v6.x -->
49
+
50
+ _Mar 5, 2025_
51
+
52
+ A big thanks to the 3 contributors who made this release possible.
53
+
54
+ ### `@mui/material@6.4.7`
55
+
56
+ - [ThemeProvider] Add `storageManager` prop to `ThemeProvider` (@siriwatknp) (#45437) @siriwatknp
57
+ - [Rating] Deprecate \*Props and complete slots, slotProps (#45295) (#45398) @DiegoAndai
58
+ - [Radio] Fix `inputProps` not forwarded (@siriwatknp) (#45475) @siriwatknp
59
+
60
+ ### Core
61
+
62
+ - [blog] React 19 migration for MUI X (#45440) @arminmeh
63
+
64
+ All contributors of this release in alphabetical order: @arminmeh, @DiegoAndai, @siriwatknp
65
+
66
+ ## 6.4.6
67
+
68
+ <!-- generated comparing v6.4.5..v6.x -->
69
+
70
+ _Feb 26, 2025_
71
+
72
+ A big thanks to the 4 contributors who made this release possible.
73
+
74
+ ### `@mui/material@6.4.6`
75
+
76
+ - [Checkbox] Add slots and slotProps (#45361) @siriwatknp
77
+ - [Drawer] Deprecate \*Props and complete `slots`, `slotProps` (#45377) @siriwatknp
78
+ - [Grid] Improve Grid2 upgrade experience (#45372) @DiegoAndai
79
+ - [InputBase] Deprecate composed classes (#45366) @siriwatknp
80
+ - Fix `slotProps.transition` types (#45367) @siriwatknp
81
+ - Allow nested theme creation with `vars` (#45368) @siriwatknp
82
+ - Fix wrong slotProps of DetailsHTMLAttributes types (#45356) @siriwatknp
83
+ - [Popover] Deprecate \*Props and complete `slots`, `slotProps` (#45337) @siriwatknp
84
+ - [Radio] Add slots and slotProps (#45364) @siriwatknp
85
+ - [Slider] Fix css class selector in migration guide (#45409) @sai6855
86
+ - [Slider] Fix spacings in .md files (#45393) @sai6855
87
+ - [Snackbar] Add Slots and SlotProps (#45103) (#45352) @siriwatknp
88
+ - [SpeedDialAction] Add slots and slotProps (#45365) @siriwatknp
89
+ - [SwitchBase] Deprecate `inputProps` and complete slots, slotProps (#45338) @siriwatknp
90
+ - [Tabs] Deprecate \*Props and complete slots, slotProps (#45012) (#45355) @siriwatknp
91
+ - [Menu] Deprecate \*Props and complete `slots`, `slotProps` (#45369) @siriwatknp
92
+
93
+ ### Docs
94
+
95
+ - [Autocomplete] Remove unnecessary renderTags prop from Sizes demo (#45403) @ZeeshanTamboli
96
+ - Fix typo in slider docs (#45392) @sai6855
97
+
98
+ ### Core
99
+
100
+ - [test] Remove unused renderTags prop and fix key warning in Autocomplete regression test (#45412) @ZeeshanTamboli
101
+
102
+ All contributors of this release in alphabetical order: @DiegoAndai, @sai6855, @siriwatknp, @ZeeshanTamboli
103
+
104
+ ## 6.4.5
105
+
106
+ <!-- generated comparing v6.4.4..v6.x -->
107
+
108
+ _Feb 18, 2025_
109
+
110
+ A big thanks to the 5 contributors who made this release possible.
111
+
112
+ ### `@mui/material@6.4.5`
113
+
114
+ - [Autocomplete] Remove legacy `aria-owns` attribute for combobox (#45303) @ZeeshanTamboli
115
+ - [Button] Apply id only if loading indicator is present (#45339) @aarongarciah
116
+
117
+ ### Docs
118
+
119
+ - [icons] Fix typo in material-icons.md (#45336) @a-s-russo
120
+ - [Menu] Add Grouped Menu demo (#45292) @noobDev31
121
+
122
+ ### Core
123
+
124
+ - [blog] Consistent Base UI terminology (#45342) @aarongarciah
125
+ - Fix double redirection to Base UI (#45146) @oliviertassinari
126
+
127
+ All contributors of this release in alphabetical order: @a-s-russo, @aarongarciah, @noobDev31, @oliviertassinari, @ZeeshanTamboli
128
+
129
+ ## 6.4.4
130
+
131
+ <!-- generated comparing v6.4.3..v6.x -->
132
+
133
+ _Feb 11, 2025_
134
+
135
+ A big thanks to the 3 contributors who made this release possible.
136
+
137
+ ### `@mui/material@6.4.4`
138
+
139
+ - [MobileStepper] deprecate `LinearProgressProps` and complete `slots`, `slotProps` (@siriwatknp) (#45242) @siriwatknp
140
+ - [Slider] Deprecate composed classes (@sai6855) (#45223) @sai6855
141
+ - [utils] Merge `sx` instead of override when using `mergeSlotProps` (#45129) @siriwatknp
142
+
143
+ ### Docs
144
+
145
+ - [Autocomplete] Improve Google Maps search example (#44708) @oliviertassinari
146
+ - [Dialog] Removes deprecated PaperProps from docs (#45217) @sai6855
147
+ - A quick first step to update docs for Tailwind v4 (#45221) @oliviertassinari
148
+
149
+ ### Core
150
+
151
+ - Fix missing store contributor renaming (527222d) @oliviertassinari
152
+ - Fix MUI Base vale rule (#45140) @oliviertassinari
153
+ - Fix 404 errors (#45137) @oliviertassinari
154
+ - [docs] Sync active sponsors (#45204) @oliviertassinari
155
+ - [docs-infra] Move Ukraine banner to the bottom (#45135) @oliviertassinari
156
+
157
+ All contributors of this release in alphabetical order: @oliviertassinari, @sai6855, @siriwatknp
158
+
3
159
  ## 6.4.3
4
160
 
5
161
  <!-- generated comparing v6.4.2..v6.x -->
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
 
3
3
  export interface StyledEngineProviderProps {
4
4
  children?: React.ReactNode;
5
+ enableCssLayer?: boolean;
5
6
  injectFirst?: boolean;
6
7
  }
7
8
 
@@ -6,9 +6,26 @@ import { CacheProvider } from '@emotion/react';
6
6
  import createCache from '@emotion/cache';
7
7
  import { StyleSheet } from '@emotion/sheet';
8
8
 
9
+ // Need to add a private variable to test the generated CSS from Emotion, this is the simplest way to do it.
10
+ // We can't test the CSS from `style` tag easily because the `speedy: true` (produce empty text content) is enabled by Emotion.
11
+ // Even if we disable it, JSDOM needs extra configuration to be able to parse `@layer` CSS.
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export const TEST_INTERNALS_DO_NOT_USE = {
14
+ /**
15
+ * to intercept the generated CSS before inserting to the style tag, so that we can check the generated CSS.
16
+ *
17
+ * let rule;
18
+ * TEST_INTERNALS_DO_NOT_USE.insert = (...args) => {
19
+ * rule = args[0];
20
+ * };
21
+ *
22
+ * expect(rule).to.equal(...);
23
+ */
24
+ insert: undefined
25
+ };
26
+
9
27
  // We might be able to remove this when this issue is fixed:
10
28
  // https://github.com/emotion-js/emotion/issues/2790
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
29
  const createEmotionCache = (options, CustomSheet) => {
13
30
  const cache = createCache(options);
14
31
 
@@ -23,11 +40,11 @@ const createEmotionCache = (options, CustomSheet) => {
23
40
  });
24
41
  return cache;
25
42
  };
26
- let cache;
43
+ let insertionPoint;
27
44
  if (typeof document === 'object') {
28
45
  // Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order
29
46
  // For more information, see https://github.com/mui/material-ui/issues/44597
30
- let insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
47
+ insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
31
48
  if (!insertionPoint) {
32
49
  insertionPoint = document.createElement('meta');
33
50
  insertionPoint.setAttribute('name', 'emotion-insertion-point');
@@ -37,30 +54,51 @@ if (typeof document === 'object') {
37
54
  head.prepend(insertionPoint);
38
55
  }
39
56
  }
40
- /**
41
- * This is for client-side apps only.
42
- * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
43
- * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
44
- */
45
- class MyStyleSheet extends StyleSheet {
46
- insert(rule, options) {
47
- if (this.key && this.key.endsWith('global')) {
48
- this.before = insertionPoint;
57
+ }
58
+ function getCache(injectFirst, enableCssLayer) {
59
+ if (injectFirst || enableCssLayer) {
60
+ /**
61
+ * This is for client-side apps only.
62
+ * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
63
+ * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
64
+ */
65
+ class MyStyleSheet extends StyleSheet {
66
+ insert(rule, options) {
67
+ if (TEST_INTERNALS_DO_NOT_USE.insert) {
68
+ return TEST_INTERNALS_DO_NOT_USE.insert(rule, options);
69
+ }
70
+ if (this.key && this.key.endsWith('global')) {
71
+ this.before = insertionPoint;
72
+ }
73
+ return super.insert(rule, options);
49
74
  }
50
- return super.insert(rule, options);
51
75
  }
76
+ const emotionCache = createEmotionCache({
77
+ key: 'css',
78
+ insertionPoint: injectFirst ? insertionPoint : undefined
79
+ }, MyStyleSheet);
80
+ if (enableCssLayer) {
81
+ const prevInsert = emotionCache.insert;
82
+ emotionCache.insert = (...args) => {
83
+ if (!args[1].styles.startsWith('@layer')) {
84
+ // avoid nested @layer
85
+ args[1].styles = `@layer mui {${args[1].styles}}`;
86
+ }
87
+ return prevInsert(...args);
88
+ };
89
+ }
90
+ return emotionCache;
52
91
  }
53
- cache = createEmotionCache({
54
- key: 'css',
55
- insertionPoint
56
- }, MyStyleSheet);
92
+ return undefined;
57
93
  }
58
94
  export default function StyledEngineProvider(props) {
59
95
  const {
60
96
  injectFirst,
97
+ enableCssLayer,
61
98
  children
62
99
  } = props;
63
- return injectFirst && cache ? /*#__PURE__*/_jsx(CacheProvider, {
100
+ const cache = React.useMemo(() => getCache(injectFirst, enableCssLayer), [injectFirst, enableCssLayer]);
101
+ return cache ? /*#__PURE__*/_jsx(CacheProvider, {
64
102
  value: cache,
65
103
  children: children
66
104
  }) : children;
@@ -70,6 +108,11 @@ process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes = {
70
108
  * Your component tree.
71
109
  */
72
110
  children: PropTypes.node,
111
+ /**
112
+ * If `true`, the styles are wrapped in `@layer mui`.
113
+ * Learn more about [Cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers).
114
+ */
115
+ enableCssLayer: PropTypes.bool,
73
116
  /**
74
117
  * By default, the styles are injected last in the <head> element of the page.
75
118
  * As a result, they gain more specificity than any other style sheet.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine v6.4.3
2
+ * @mui/styled-engine v6.4.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -6,9 +6,26 @@ import { CacheProvider } from '@emotion/react';
6
6
  import createCache from '@emotion/cache';
7
7
  import { StyleSheet } from '@emotion/sheet';
8
8
 
9
+ // Need to add a private variable to test the generated CSS from Emotion, this is the simplest way to do it.
10
+ // We can't test the CSS from `style` tag easily because the `speedy: true` (produce empty text content) is enabled by Emotion.
11
+ // Even if we disable it, JSDOM needs extra configuration to be able to parse `@layer` CSS.
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ export const TEST_INTERNALS_DO_NOT_USE = {
14
+ /**
15
+ * to intercept the generated CSS before inserting to the style tag, so that we can check the generated CSS.
16
+ *
17
+ * let rule;
18
+ * TEST_INTERNALS_DO_NOT_USE.insert = (...args) => {
19
+ * rule = args[0];
20
+ * };
21
+ *
22
+ * expect(rule).to.equal(...);
23
+ */
24
+ insert: undefined
25
+ };
26
+
9
27
  // We might be able to remove this when this issue is fixed:
10
28
  // https://github.com/emotion-js/emotion/issues/2790
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
29
  const createEmotionCache = (options, CustomSheet) => {
13
30
  const cache = createCache(options);
14
31
 
@@ -23,11 +40,11 @@ const createEmotionCache = (options, CustomSheet) => {
23
40
  });
24
41
  return cache;
25
42
  };
26
- let cache;
43
+ let insertionPoint;
27
44
  if (typeof document === 'object') {
28
45
  // Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order
29
46
  // For more information, see https://github.com/mui/material-ui/issues/44597
30
- let insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
47
+ insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
31
48
  if (!insertionPoint) {
32
49
  insertionPoint = document.createElement('meta');
33
50
  insertionPoint.setAttribute('name', 'emotion-insertion-point');
@@ -37,30 +54,51 @@ if (typeof document === 'object') {
37
54
  head.prepend(insertionPoint);
38
55
  }
39
56
  }
40
- /**
41
- * This is for client-side apps only.
42
- * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
43
- * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
44
- */
45
- class MyStyleSheet extends StyleSheet {
46
- insert(rule, options) {
47
- if (this.key && this.key.endsWith('global')) {
48
- this.before = insertionPoint;
57
+ }
58
+ function getCache(injectFirst, enableCssLayer) {
59
+ if (injectFirst || enableCssLayer) {
60
+ /**
61
+ * This is for client-side apps only.
62
+ * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
63
+ * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
64
+ */
65
+ class MyStyleSheet extends StyleSheet {
66
+ insert(rule, options) {
67
+ if (TEST_INTERNALS_DO_NOT_USE.insert) {
68
+ return TEST_INTERNALS_DO_NOT_USE.insert(rule, options);
69
+ }
70
+ if (this.key && this.key.endsWith('global')) {
71
+ this.before = insertionPoint;
72
+ }
73
+ return super.insert(rule, options);
49
74
  }
50
- return super.insert(rule, options);
51
75
  }
76
+ const emotionCache = createEmotionCache({
77
+ key: 'css',
78
+ insertionPoint: injectFirst ? insertionPoint : undefined
79
+ }, MyStyleSheet);
80
+ if (enableCssLayer) {
81
+ const prevInsert = emotionCache.insert;
82
+ emotionCache.insert = (...args) => {
83
+ if (!args[1].styles.startsWith('@layer')) {
84
+ // avoid nested @layer
85
+ args[1].styles = `@layer mui {${args[1].styles}}`;
86
+ }
87
+ return prevInsert(...args);
88
+ };
89
+ }
90
+ return emotionCache;
52
91
  }
53
- cache = createEmotionCache({
54
- key: 'css',
55
- insertionPoint
56
- }, MyStyleSheet);
92
+ return undefined;
57
93
  }
58
94
  export default function StyledEngineProvider(props) {
59
95
  const {
60
96
  injectFirst,
97
+ enableCssLayer,
61
98
  children
62
99
  } = props;
63
- return injectFirst && cache ? /*#__PURE__*/_jsx(CacheProvider, {
100
+ const cache = React.useMemo(() => getCache(injectFirst, enableCssLayer), [injectFirst, enableCssLayer]);
101
+ return cache ? /*#__PURE__*/_jsx(CacheProvider, {
64
102
  value: cache,
65
103
  children: children
66
104
  }) : children;
@@ -70,6 +108,11 @@ process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes = {
70
108
  * Your component tree.
71
109
  */
72
110
  children: PropTypes.node,
111
+ /**
112
+ * If `true`, the styles are wrapped in `@layer mui`.
113
+ * Learn more about [Cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers).
114
+ */
115
+ enableCssLayer: PropTypes.bool,
73
116
  /**
74
117
  * By default, the styles are injected last in the <head> element of the page.
75
118
  * As a result, they gain more specificity than any other style sheet.
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine v6.4.3
2
+ * @mui/styled-engine v6.4.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -6,6 +6,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
+ exports.TEST_INTERNALS_DO_NOT_USE = void 0;
9
10
  exports.default = StyledEngineProvider;
10
11
  var React = _interopRequireWildcard(require("react"));
11
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
@@ -13,6 +14,23 @@ var _react2 = require("@emotion/react");
13
14
  var _cache = _interopRequireDefault(require("@emotion/cache"));
14
15
  var _sheet = require("@emotion/sheet");
15
16
  var _jsxRuntime = require("react/jsx-runtime");
17
+ // Need to add a private variable to test the generated CSS from Emotion, this is the simplest way to do it.
18
+ // We can't test the CSS from `style` tag easily because the `speedy: true` (produce empty text content) is enabled by Emotion.
19
+ // Even if we disable it, JSDOM needs extra configuration to be able to parse `@layer` CSS.
20
+ const TEST_INTERNALS_DO_NOT_USE = exports.TEST_INTERNALS_DO_NOT_USE = {
21
+ /**
22
+ * to intercept the generated CSS before inserting to the style tag, so that we can check the generated CSS.
23
+ *
24
+ * let rule;
25
+ * TEST_INTERNALS_DO_NOT_USE.insert = (...args) => {
26
+ * rule = args[0];
27
+ * };
28
+ *
29
+ * expect(rule).to.equal(...);
30
+ */
31
+ insert: undefined
32
+ };
33
+
16
34
  // We might be able to remove this when this issue is fixed:
17
35
  // https://github.com/emotion-js/emotion/issues/2790
18
36
  const createEmotionCache = (options, CustomSheet) => {
@@ -29,11 +47,11 @@ const createEmotionCache = (options, CustomSheet) => {
29
47
  });
30
48
  return cache;
31
49
  };
32
- let cache;
50
+ let insertionPoint;
33
51
  if (typeof document === 'object') {
34
52
  // Use `insertionPoint` over `prepend`(deprecated) because it can be controlled for GlobalStyles injection order
35
53
  // For more information, see https://github.com/mui/material-ui/issues/44597
36
- let insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
54
+ insertionPoint = document.querySelector('[name="emotion-insertion-point"]');
37
55
  if (!insertionPoint) {
38
56
  insertionPoint = document.createElement('meta');
39
57
  insertionPoint.setAttribute('name', 'emotion-insertion-point');
@@ -43,30 +61,51 @@ if (typeof document === 'object') {
43
61
  head.prepend(insertionPoint);
44
62
  }
45
63
  }
46
- /**
47
- * This is for client-side apps only.
48
- * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
49
- * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
50
- */
51
- class MyStyleSheet extends _sheet.StyleSheet {
52
- insert(rule, options) {
53
- if (this.key && this.key.endsWith('global')) {
54
- this.before = insertionPoint;
64
+ }
65
+ function getCache(injectFirst, enableCssLayer) {
66
+ if (injectFirst || enableCssLayer) {
67
+ /**
68
+ * This is for client-side apps only.
69
+ * A custom sheet is required to make the GlobalStyles API injected above the insertion point.
70
+ * This is because the [sheet](https://github.com/emotion-js/emotion/blob/main/packages/react/src/global.js#L94-L99) does not consume the options.
71
+ */
72
+ class MyStyleSheet extends _sheet.StyleSheet {
73
+ insert(rule, options) {
74
+ if (TEST_INTERNALS_DO_NOT_USE.insert) {
75
+ return TEST_INTERNALS_DO_NOT_USE.insert(rule, options);
76
+ }
77
+ if (this.key && this.key.endsWith('global')) {
78
+ this.before = insertionPoint;
79
+ }
80
+ return super.insert(rule, options);
55
81
  }
56
- return super.insert(rule, options);
57
82
  }
83
+ const emotionCache = createEmotionCache({
84
+ key: 'css',
85
+ insertionPoint: injectFirst ? insertionPoint : undefined
86
+ }, MyStyleSheet);
87
+ if (enableCssLayer) {
88
+ const prevInsert = emotionCache.insert;
89
+ emotionCache.insert = (...args) => {
90
+ if (!args[1].styles.startsWith('@layer')) {
91
+ // avoid nested @layer
92
+ args[1].styles = `@layer mui {${args[1].styles}}`;
93
+ }
94
+ return prevInsert(...args);
95
+ };
96
+ }
97
+ return emotionCache;
58
98
  }
59
- cache = createEmotionCache({
60
- key: 'css',
61
- insertionPoint
62
- }, MyStyleSheet);
99
+ return undefined;
63
100
  }
64
101
  function StyledEngineProvider(props) {
65
102
  const {
66
103
  injectFirst,
104
+ enableCssLayer,
67
105
  children
68
106
  } = props;
69
- return injectFirst && cache ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.CacheProvider, {
107
+ const cache = React.useMemo(() => getCache(injectFirst, enableCssLayer), [injectFirst, enableCssLayer]);
108
+ return cache ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.CacheProvider, {
70
109
  value: cache,
71
110
  children: children
72
111
  }) : children;
@@ -76,6 +115,11 @@ process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes = {
76
115
  * Your component tree.
77
116
  */
78
117
  children: _propTypes.default.node,
118
+ /**
119
+ * If `true`, the styles are wrapped in `@layer mui`.
120
+ * Learn more about [Cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers).
121
+ */
122
+ enableCssLayer: _propTypes.default.bool,
79
123
  /**
80
124
  * By default, the styles are injected last in the <head> element of the page.
81
125
  * As a result, they gain more specificity than any other style sheet.
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine v6.4.3
2
+ * @mui/styled-engine v6.4.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/styled-engine",
3
- "version": "6.4.3",
3
+ "version": "6.4.8",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "styled() API wrapper package for emotion.",