@mui/styled-engine 7.0.0-beta.3 → 7.0.0-beta.4

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,65 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 7.0.0-beta.4
4
+
5
+ <!-- generated comparing v7.0.0-beta.3..master -->
6
+
7
+ _Mar 13, 2025_
8
+
9
+ A big thanks to the 10 contributors who made this release possible.
10
+ This release contains bug fixes 🐛 and improvements to the new package layout 🏗️.
11
+
12
+ ### `@mui/material@7.0.0-beta.4`
13
+
14
+ - [Accordion] Add missing `root` slot (#45532) @sai6855
15
+ - [AccordionSummary] Add slots and slotProps (#45559) @sai6855
16
+ - [ListItemText] Add missing `root` slot (#45540) @sai6855
17
+ - [SpeedDial] Add missing `root` slot (#45541) @sai6855
18
+ - [Tooltip] Allow auto placement on tooltip (#45399) @Jtaks
19
+ - [useScrollTrigger] Do nothing if target is null (#45441) @vipierozan99
20
+ - [TextareaAutosize] Fix ResizeObserver causing infinite `selectionchange` loop (#45351) @mj12albert
21
+ - Fix negative input for CSS variables spacing array (#45550) @siriwatknp
22
+ - Add missing deprecations in deprecations-all file (#45505) @sai6855
23
+ - Rename some `@mui/material/styles/createTypography` exports (#45558) @Janpot
24
+
25
+ ### `@mui/icons-material@7.0.0-beta.4`
26
+
27
+ - Remove unused icon names from the download script (#45453) @yermartee
28
+
29
+ ### `@mui/system@7.0.0-beta.4`
30
+
31
+ - Prevent nested non-vars theme inheritance (#45545) @siriwatknp
32
+ - Disable theme recalculation as default behavior (#45405) @siriwatknp
33
+ - Fix package layout inconsistencies (#45491) @DiegoAndai
34
+
35
+ ### `@mui/styled-engine@7.0.0-beta.4`
36
+
37
+ - Add `enableCssLayer` prop to StyledEngineProvider (#45428) @siriwatknp
38
+
39
+ ### `@mui/types@7.3.0`
40
+
41
+ - [code-infra] Fix type resolution for @mui/types (#45513) @Janpot
42
+
43
+ ### `@mui/utils@7.0.0-beta.4`
44
+
45
+ - Fix package layout inconsistencies (#45491) @DiegoAndai
46
+ - Use correct iri-reference homepage format (#45472) @dahiro
47
+
48
+ ### Docs
49
+
50
+ - [Backdrop] Fix component name in migration guide (#45506) @sai6855
51
+ - [TextField] Add HTML input section to TextField page (#45439) @siriwatknp
52
+
53
+ ### Core
54
+
55
+ - [code-infra] Convert a few docs modules to ts (#45548) @Janpot
56
+ - [code-infra] Remove more CJS modules from the docs (#45557) @Janpot
57
+ - [code-infra] Remove nested imports from theme augmentation (#45514) @Janpot
58
+ - [docs-infra] Add @ts-ignore to avoid type checking for MUI X (#45555) @siriwatknp
59
+ - [blog] Fix author end-of-year updates (#45533) @oliviertassinari
60
+
61
+ All contributors of this release in alphabetical order: @dahiro, @DiegoAndai, @Janpot, @Jtaks, @mj12albert, @oliviertassinari, @sai6855, @siriwatknp, @vipierozan99, @yermartee
62
+
3
63
  ## 7.0.0-beta.3
4
64
 
5
65
  <!-- generated comparing v7.0.0-beta.2..master -->
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface StyledEngineProviderProps {
3
3
  children?: React.ReactNode;
4
+ enableCssLayer?: boolean;
4
5
  injectFirst?: boolean;
5
6
  }
6
7
  export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -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.
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface StyledEngineProviderProps {
3
3
  children?: React.ReactNode;
4
+ enableCssLayer?: boolean;
4
5
  injectFirst?: boolean;
5
6
  }
6
7
  export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -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/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine v7.0.0-beta.3
2
+ * @mui/styled-engine v7.0.0-beta.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/styled-engine v7.0.0-beta.3
2
+ * @mui/styled-engine v7.0.0-beta.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface StyledEngineProviderProps {
3
3
  children?: React.ReactNode;
4
+ enableCssLayer?: boolean;
4
5
  injectFirst?: boolean;
5
6
  }
6
7
  export default function StyledEngineProvider(props: StyledEngineProviderProps): React.JSX.Element;
@@ -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 v7.0.0-beta.3
2
+ * @mui/styled-engine v7.0.0-beta.4
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": "7.0.0-beta.3",
3
+ "version": "7.0.0-beta.4",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "styled() API wrapper package for emotion.",