@mui/styled-engine 7.0.0-beta.3 → 7.0.0-rc.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 +84 -0
- package/StyledEngineProvider/StyledEngineProvider.d.ts +1 -0
- package/StyledEngineProvider/StyledEngineProvider.js +61 -17
- package/esm/StyledEngineProvider/StyledEngineProvider.d.ts +1 -0
- package/esm/StyledEngineProvider/StyledEngineProvider.js +61 -18
- package/esm/index.js +1 -1
- package/index.js +1 -1
- package/modern/StyledEngineProvider/StyledEngineProvider.d.ts +1 -0
- package/modern/StyledEngineProvider/StyledEngineProvider.js +61 -18
- package/modern/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 7.0.0-rc.0
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v7.0.0-beta.4..master -->
|
|
6
|
+
|
|
7
|
+
_Mar 18, 2025_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 4 contributors who made this release possible.
|
|
10
|
+
|
|
11
|
+
### `@mui/material@7.0.0-rc.0`
|
|
12
|
+
|
|
13
|
+
- [StepLabel] Add missing root slot (#45603) @sai6855
|
|
14
|
+
- [Switch] Add slots and slotProps (#45595) @siriwatknp
|
|
15
|
+
- [utils] Add merging function to `mergeSlotProps` utility (#45543) @siriwatknp
|
|
16
|
+
|
|
17
|
+
### Core
|
|
18
|
+
|
|
19
|
+
- [blog] Clarify the difference between the two Pro plans (#45266) @oliviertassinari
|
|
20
|
+
- [code-infra] Allow specifying a custom error formatter module for error minifcation (#45291) @Janpot
|
|
21
|
+
- [code-infra] Make `getVersionEnvVariables` reusable for other repos (#45562) @Janpot
|
|
22
|
+
- [code-infra] Update peer dependency of `@mui/utils` in `@mui/docs` (#45561) @Janpot
|
|
23
|
+
- Add StackBlitz template to issue template (#45504) @Janpot
|
|
24
|
+
|
|
25
|
+
All contributors of this release in alphabetical order: @Janpot, @oliviertassinari, @sai6855, @siriwatknp
|
|
26
|
+
|
|
27
|
+
## 7.0.0-beta.4
|
|
28
|
+
|
|
29
|
+
<!-- generated comparing v7.0.0-beta.3..master -->
|
|
30
|
+
|
|
31
|
+
_Mar 13, 2025_
|
|
32
|
+
|
|
33
|
+
A big thanks to the 10 contributors who made this release possible.
|
|
34
|
+
This release contains bug fixes 🐛 and improvements to the new package layout 🏗️.
|
|
35
|
+
|
|
36
|
+
### `@mui/material@7.0.0-beta.4`
|
|
37
|
+
|
|
38
|
+
- [Accordion] Add missing `root` slot (#45532) @sai6855
|
|
39
|
+
- [AccordionSummary] Add slots and slotProps (#45559) @sai6855
|
|
40
|
+
- [ListItemText] Add missing `root` slot (#45540) @sai6855
|
|
41
|
+
- [SpeedDial] Add missing `root` slot (#45541) @sai6855
|
|
42
|
+
- [Tooltip] Allow auto placement on tooltip (#45399) @Jtaks
|
|
43
|
+
- [useScrollTrigger] Do nothing if target is null (#45441) @vipierozan99
|
|
44
|
+
- [TextareaAutosize] Fix ResizeObserver causing infinite `selectionchange` loop (#45351) @mj12albert
|
|
45
|
+
- Fix negative input for CSS variables spacing array (#45550) @siriwatknp
|
|
46
|
+
- Add missing deprecations in deprecations-all file (#45505) @sai6855
|
|
47
|
+
- Rename some `@mui/material/styles/createTypography` exports (#45558) @Janpot
|
|
48
|
+
|
|
49
|
+
### `@mui/icons-material@7.0.0-beta.4`
|
|
50
|
+
|
|
51
|
+
- Remove unused icon names from the download script (#45453) @yermartee
|
|
52
|
+
|
|
53
|
+
### `@mui/system@7.0.0-beta.4`
|
|
54
|
+
|
|
55
|
+
- Prevent nested non-vars theme inheritance (#45545) @siriwatknp
|
|
56
|
+
- Disable theme recalculation as default behavior (#45405) @siriwatknp
|
|
57
|
+
- Fix package layout inconsistencies (#45491) @DiegoAndai
|
|
58
|
+
|
|
59
|
+
### `@mui/styled-engine@7.0.0-beta.4`
|
|
60
|
+
|
|
61
|
+
- Add `enableCssLayer` prop to StyledEngineProvider (#45428) @siriwatknp
|
|
62
|
+
|
|
63
|
+
### `@mui/types@7.3.0`
|
|
64
|
+
|
|
65
|
+
- [code-infra] Fix type resolution for @mui/types (#45513) @Janpot
|
|
66
|
+
|
|
67
|
+
### `@mui/utils@7.0.0-beta.4`
|
|
68
|
+
|
|
69
|
+
- Fix package layout inconsistencies (#45491) @DiegoAndai
|
|
70
|
+
- Use correct iri-reference homepage format (#45472) @dahiro
|
|
71
|
+
|
|
72
|
+
### Docs
|
|
73
|
+
|
|
74
|
+
- [Backdrop] Fix component name in migration guide (#45506) @sai6855
|
|
75
|
+
- [TextField] Add HTML input section to TextField page (#45439) @siriwatknp
|
|
76
|
+
|
|
77
|
+
### Core
|
|
78
|
+
|
|
79
|
+
- [code-infra] Convert a few docs modules to ts (#45548) @Janpot
|
|
80
|
+
- [code-infra] Remove more CJS modules from the docs (#45557) @Janpot
|
|
81
|
+
- [code-infra] Remove nested imports from theme augmentation (#45514) @Janpot
|
|
82
|
+
- [docs-infra] Add @ts-ignore to avoid type checking for MUI X (#45555) @siriwatknp
|
|
83
|
+
- [blog] Fix author end-of-year updates (#45533) @oliviertassinari
|
|
84
|
+
|
|
85
|
+
All contributors of this release in alphabetical order: @dahiro, @DiegoAndai, @Janpot, @Jtaks, @mj12albert, @oliviertassinari, @sai6855, @siriwatknp, @vipierozan99, @yermartee
|
|
86
|
+
|
|
3
87
|
## 7.0.0-beta.3
|
|
4
88
|
|
|
5
89
|
<!-- generated comparing v7.0.0-beta.2..master -->
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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/esm/index.js
CHANGED
package/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/styled-engine",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "styled() API wrapper package for emotion.",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "https://opencollective.com/mui-org"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.26.
|
|
29
|
+
"@babel/runtime": "^7.26.10",
|
|
30
30
|
"@emotion/cache": "^11.13.5",
|
|
31
31
|
"@emotion/serialize": "^1.3.3",
|
|
32
32
|
"@emotion/sheet": "^1.4.0",
|