@mui/system 9.0.0-alpha.3 → 9.0.0-beta.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.
Files changed (48) hide show
  1. package/Box/Box.d.mts +1 -1
  2. package/Box/Box.d.ts +1 -1
  3. package/CHANGELOG.md +224 -3
  4. package/Stack/StackProps.d.mts +1 -2
  5. package/Stack/StackProps.d.ts +1 -2
  6. package/Stack/createStack.js +1 -3
  7. package/Stack/createStack.mjs +1 -3
  8. package/breakpoints/breakpoints.d.mts +4 -1
  9. package/breakpoints/breakpoints.d.ts +4 -1
  10. package/breakpoints/breakpoints.js +90 -49
  11. package/breakpoints/breakpoints.mjs +86 -49
  12. package/compose/compose.js +6 -6
  13. package/compose/compose.mjs +6 -6
  14. package/createBox/createBox.js +2 -2
  15. package/createBox/createBox.mjs +2 -2
  16. package/createBreakpoints/createBreakpoints.d.mts +5 -0
  17. package/createBreakpoints/createBreakpoints.d.ts +5 -0
  18. package/createBreakpoints/createBreakpoints.js +5 -0
  19. package/createBreakpoints/createBreakpoints.mjs +5 -0
  20. package/createStyled/createStyled.js +2 -8
  21. package/createStyled/createStyled.mjs +1 -7
  22. package/createTheme/createTheme.js +1 -0
  23. package/createTheme/createTheme.mjs +1 -0
  24. package/cssContainerQueries/cssContainerQueries.d.mts +1 -0
  25. package/cssContainerQueries/cssContainerQueries.d.ts +1 -0
  26. package/cssContainerQueries/cssContainerQueries.js +27 -14
  27. package/cssContainerQueries/cssContainerQueries.mjs +27 -14
  28. package/cssVars/createCssVarsTheme.js +1 -0
  29. package/cssVars/createCssVarsTheme.mjs +1 -0
  30. package/index.js +1 -1
  31. package/index.mjs +1 -1
  32. package/merge/merge.js +4 -3
  33. package/merge/merge.mjs +4 -3
  34. package/package.json +6 -6
  35. package/spacing/spacing.js +45 -45
  36. package/spacing/spacing.mjs +47 -45
  37. package/style/index.d.mts +1 -0
  38. package/style/index.d.ts +1 -0
  39. package/style/index.js +9 -1
  40. package/style/index.mjs +1 -0
  41. package/style/style.d.mts +36 -7
  42. package/style/style.d.ts +36 -7
  43. package/style/style.js +85 -34
  44. package/style/style.mjs +84 -34
  45. package/styleFunctionSx/styleFunctionSx.js +95 -100
  46. package/styleFunctionSx/styleFunctionSx.mjs +98 -102
  47. package/version/index.js +2 -2
  48. package/version/index.mjs +2 -2
@@ -1,7 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
+ import isObjectEmpty from '@mui/utils/isObjectEmpty';
3
+ import fastDeepAssign from '@mui/utils/fastDeepAssign';
2
4
  import deepmerge from '@mui/utils/deepmerge';
3
5
  import merge from "../merge/index.mjs";
4
6
  import { isCqShorthand, getContainerQuery } from "../cssContainerQueries/index.mjs";
7
+ import createBreakpoints from "../createBreakpoints/createBreakpoints.mjs";
8
+ const EMPTY_THEME = {};
5
9
 
6
10
  // The breakpoint **start** at this value.
7
11
  // For instance with the first breakpoint xs: [xs, sm[.
@@ -16,12 +20,9 @@ export const values = {
16
20
  // desktop
17
21
  xl: 1536 // large screen
18
22
  };
19
- const defaultBreakpoints = {
20
- // Sorted ASC by size. That's important.
21
- // It can't be configured as it's used statically for propTypes.
22
- keys: ['xs', 'sm', 'md', 'lg', 'xl'],
23
- up: key => `@media (min-width:${values[key]}px)`
24
- };
23
+ export const DEFAULT_BREAKPOINTS = createBreakpoints({
24
+ values
25
+ });
25
26
  const defaultContainerQueries = {
26
27
  containerQueries: containerName => ({
27
28
  up: key => {
@@ -34,44 +35,59 @@ const defaultContainerQueries = {
34
35
  })
35
36
  };
36
37
  export function handleBreakpoints(props, propValue, styleFromPropValue) {
37
- const theme = props.theme || {};
38
+ const result = {};
39
+ return iterateBreakpoints(result, props.theme, propValue, (mediaKey, value, initialKey) => {
40
+ const finalValue = styleFromPropValue(value, initialKey);
41
+ if (mediaKey) {
42
+ result[mediaKey] = finalValue;
43
+ } else {
44
+ fastDeepAssign(result, finalValue);
45
+ }
46
+ });
47
+ }
48
+ export function iterateBreakpoints(target, theme, propValue, callback) {
49
+ theme ??= EMPTY_THEME;
38
50
  if (Array.isArray(propValue)) {
39
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
40
- return propValue.reduce((acc, item, index) => {
41
- acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
42
- return acc;
43
- }, {});
51
+ const breakpoints = theme.breakpoints ?? DEFAULT_BREAKPOINTS;
52
+ for (let i = 0; i < propValue.length; i += 1) {
53
+ buildBreakpoint(target, breakpoints.up(breakpoints.keys[i]), propValue[i], undefined, callback);
54
+ }
55
+ return target;
44
56
  }
45
57
  if (typeof propValue === 'object') {
46
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
47
- return Object.keys(propValue).reduce((acc, breakpoint) => {
48
- if (isCqShorthand(themeBreakpoints.keys, breakpoint)) {
49
- const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
58
+ const breakpoints = theme.breakpoints ?? DEFAULT_BREAKPOINTS;
59
+ const breakpointValues = breakpoints.values ?? values;
60
+ for (const key in propValue) {
61
+ if (isCqShorthand(breakpoints.keys, key)) {
62
+ const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, key);
50
63
  if (containerKey) {
51
- acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
64
+ buildBreakpoint(target, containerKey, propValue[key], key, callback);
52
65
  }
53
66
  }
54
- // key is breakpoint
55
- else if (Object.keys(themeBreakpoints.values || values).includes(breakpoint)) {
56
- const mediaKey = themeBreakpoints.up(breakpoint);
57
- acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
67
+ // key is key
68
+ else if (key in breakpointValues) {
69
+ const mediaKey = breakpoints.up(key);
70
+ buildBreakpoint(target, mediaKey, propValue[key], key, callback);
58
71
  } else {
59
- const cssKey = breakpoint;
60
- acc[cssKey] = propValue[cssKey];
72
+ const cssKey = key;
73
+ target[cssKey] = propValue[cssKey];
61
74
  }
62
- return acc;
63
- }, {});
75
+ }
76
+ return target;
64
77
  }
65
- const output = styleFromPropValue(propValue);
66
- return output;
78
+ callback(undefined, propValue);
79
+ return target;
80
+ }
81
+ function buildBreakpoint(target, mediaKey, value, initialKey, callback) {
82
+ target[mediaKey] ??= {};
83
+ callback(mediaKey, value, initialKey);
67
84
  }
68
- function breakpoints(styleFunction) {
69
- // false positive
85
+ function setupBreakpoints(styleFunction) {
70
86
  // eslint-disable-next-line react/function-component-definition
71
87
  const newStyleFunction = props => {
72
88
  const theme = props.theme || {};
73
89
  const base = styleFunction(props);
74
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
90
+ const themeBreakpoints = theme.breakpoints || DEFAULT_BREAKPOINTS;
75
91
  const extended = themeBreakpoints.keys.reduce((acc, key) => {
76
92
  if (props[key]) {
77
93
  acc = acc || {};
@@ -95,28 +111,30 @@ function breakpoints(styleFunction) {
95
111
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
96
112
  return newStyleFunction;
97
113
  }
98
- export function createEmptyBreakpointObject(breakpointsInput = {}) {
99
- const breakpointsInOrder = breakpointsInput.keys?.reduce((acc, key) => {
100
- const breakpointStyleKey = breakpointsInput.up(key);
101
- acc[breakpointStyleKey] = {};
102
- return acc;
103
- }, {});
104
- return breakpointsInOrder || {};
114
+ export function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
115
+ const {
116
+ internal_mediaKeys: mediaKeys
117
+ } = breakpoints;
118
+ const result = {};
119
+ for (let i = 0; i < mediaKeys.length; i += 1) {
120
+ result[mediaKeys[i]] = {};
121
+ }
122
+ return result;
105
123
  }
106
- export function removeUnusedBreakpoints(breakpointKeys, style) {
107
- return breakpointKeys.reduce((acc, key) => {
108
- const breakpointOutput = acc[key];
109
- const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
110
- if (isBreakpointUnused) {
111
- delete acc[key];
124
+ export function removeUnusedBreakpoints(breakpoints, style) {
125
+ const breakpointKeys = breakpoints.internal_mediaKeys;
126
+ for (let i = 0; i < breakpointKeys.length; i += 1) {
127
+ const key = breakpointKeys[i];
128
+ if (isObjectEmpty(style[key])) {
129
+ delete style[key];
112
130
  }
113
- return acc;
114
- }, style);
131
+ }
132
+ return style;
115
133
  }
116
- export function mergeBreakpointsInOrder(breakpointsInput, ...styles) {
117
- const emptyBreakpoints = createEmptyBreakpointObject(breakpointsInput);
134
+ export function mergeBreakpointsInOrder(breakpoints, ...styles) {
135
+ const emptyBreakpoints = createEmptyBreakpointObject(breakpoints);
118
136
  const mergedOutput = [emptyBreakpoints, ...styles].reduce((prev, next) => deepmerge(prev, next), {});
119
- return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
137
+ return removeUnusedBreakpoints(breakpoints, mergedOutput);
120
138
  }
121
139
 
122
140
  // compute base for responsive values; e.g.,
@@ -168,4 +186,23 @@ export function resolveBreakpointValues({
168
186
  return acc;
169
187
  }, {});
170
188
  }
171
- export default breakpoints;
189
+ export function hasBreakpoint(breakpoints, value) {
190
+ if (Array.isArray(value)) {
191
+ return true;
192
+ }
193
+ if (typeof value === 'object' && value !== null) {
194
+ for (let i = 0; i < breakpoints.keys.length; i += 1) {
195
+ if (breakpoints.keys[i] in value) {
196
+ return true;
197
+ }
198
+ }
199
+ const valueKeys = Object.keys(value);
200
+ for (let i = 0; i < valueKeys.length; i += 1) {
201
+ if (isCqShorthand(breakpoints.keys, valueKeys[i])) {
202
+ return true;
203
+ }
204
+ }
205
+ }
206
+ return false;
207
+ }
208
+ export default setupBreakpoints;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _merge = _interopRequireDefault(require("../merge"));
8
+ var _fastDeepAssign = _interopRequireDefault(require("@mui/utils/fastDeepAssign"));
9
9
  function compose(...styles) {
10
10
  const handlers = styles.reduce((acc, style) => {
11
11
  style.filterProps.forEach(prop => {
@@ -14,15 +14,15 @@ function compose(...styles) {
14
14
  return acc;
15
15
  }, {});
16
16
 
17
- // false positive
18
17
  // eslint-disable-next-line react/function-component-definition
19
18
  const fn = props => {
20
- return Object.keys(props).reduce((acc, prop) => {
19
+ const result = {};
20
+ for (const prop in props) {
21
21
  if (handlers[prop]) {
22
- return (0, _merge.default)(acc, handlers[prop](props));
22
+ (0, _fastDeepAssign.default)(result, handlers[prop](props));
23
23
  }
24
- return acc;
25
- }, {});
24
+ }
25
+ return result;
26
26
  };
27
27
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
28
28
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
@@ -1,4 +1,4 @@
1
- import merge from "../merge/index.mjs";
1
+ import fastDeepAssign from '@mui/utils/fastDeepAssign';
2
2
  function compose(...styles) {
3
3
  const handlers = styles.reduce((acc, style) => {
4
4
  style.filterProps.forEach(prop => {
@@ -7,15 +7,15 @@ function compose(...styles) {
7
7
  return acc;
8
8
  }, {});
9
9
 
10
- // false positive
11
10
  // eslint-disable-next-line react/function-component-definition
12
11
  const fn = props => {
13
- return Object.keys(props).reduce((acc, prop) => {
12
+ const result = {};
13
+ for (const prop in props) {
14
14
  if (handlers[prop]) {
15
- return merge(acc, handlers[prop](props));
15
+ fastDeepAssign(result, handlers[prop](props));
16
16
  }
17
- return acc;
18
- }, {});
17
+ }
18
+ return result;
19
19
  };
20
20
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
21
21
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
@@ -10,7 +10,7 @@ exports.default = createBox;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _clsx = _interopRequireDefault(require("clsx"));
12
12
  var _styledEngine = _interopRequireDefault(require("@mui/styled-engine"));
13
- var _styleFunctionSx = _interopRequireWildcard(require("../styleFunctionSx"));
13
+ var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx"));
14
14
  var _useTheme = _interopRequireDefault(require("../useTheme"));
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  function createBox(options = {}) {
@@ -29,7 +29,7 @@ function createBox(options = {}) {
29
29
  className,
30
30
  component = 'div',
31
31
  ...other
32
- } = (0, _styleFunctionSx.extendSxProp)(inProps);
32
+ } = inProps;
33
33
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(BoxRoot, {
34
34
  as: component,
35
35
  ref: ref,
@@ -3,7 +3,7 @@
3
3
  import * as React from 'react';
4
4
  import clsx from 'clsx';
5
5
  import styled from '@mui/styled-engine';
6
- import styleFunctionSx, { extendSxProp } from "../styleFunctionSx/index.mjs";
6
+ import styleFunctionSx from "../styleFunctionSx/index.mjs";
7
7
  import useTheme from "../useTheme/index.mjs";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export default function createBox(options = {}) {
@@ -22,7 +22,7 @@ export default function createBox(options = {}) {
22
22
  className,
23
23
  component = 'div',
24
24
  ...other
25
- } = extendSxProp(inProps);
25
+ } = inProps;
26
26
  return /*#__PURE__*/_jsx(BoxRoot, {
27
27
  as: component,
28
28
  ref: ref,
@@ -61,6 +61,11 @@ export interface Breakpoints {
61
61
  * @default 'px'
62
62
  */
63
63
  unit?: string | undefined;
64
+ /**
65
+ * Media query keys
66
+ * @ignore - Do not document.
67
+ */
68
+ internal_mediaKeys: string[];
64
69
  }
65
70
  export interface BreakpointsOptions extends Partial<Breakpoints> {
66
71
  /**
@@ -61,6 +61,11 @@ export interface Breakpoints {
61
61
  * @default 'px'
62
62
  */
63
63
  unit?: string | undefined;
64
+ /**
65
+ * Media query keys
66
+ * @ignore - Do not document.
67
+ */
68
+ internal_mediaKeys: string[];
64
69
  }
65
70
  export interface BreakpointsOptions extends Partial<Breakpoints> {
66
71
  /**
@@ -74,6 +74,10 @@ function createBreakpoints(breakpoints) {
74
74
  }
75
75
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
76
76
  }
77
+ const mediaKeys = [];
78
+ for (let i = 0; i < keys.length; i += 1) {
79
+ mediaKeys.push(up(keys[i]));
80
+ }
77
81
  return {
78
82
  keys,
79
83
  values: sortedValues,
@@ -83,6 +87,7 @@ function createBreakpoints(breakpoints) {
83
87
  only,
84
88
  not,
85
89
  unit,
90
+ internal_mediaKeys: mediaKeys,
86
91
  ...other
87
92
  };
88
93
  }
@@ -67,6 +67,10 @@ export default function createBreakpoints(breakpoints) {
67
67
  }
68
68
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
69
69
  }
70
+ const mediaKeys = [];
71
+ for (let i = 0; i < keys.length; i += 1) {
72
+ mediaKeys.push(up(keys[i]));
73
+ }
70
74
  return {
71
75
  keys,
72
76
  values: sortedValues,
@@ -76,6 +80,7 @@ export default function createBreakpoints(breakpoints) {
76
80
  only,
77
81
  not,
78
82
  unit,
83
+ internal_mediaKeys: mediaKeys,
79
84
  ...other
80
85
  };
81
86
  }
@@ -9,6 +9,7 @@ exports.default = createStyled;
9
9
  exports.shouldForwardProp = shouldForwardProp;
10
10
  exports.systemDefaultTheme = void 0;
11
11
  var _styledEngine = _interopRequireWildcard(require("@mui/styled-engine"));
12
+ var _isObjectEmpty = _interopRequireDefault(require("@mui/utils/isObjectEmpty"));
12
13
  var _deepmerge = require("@mui/utils/deepmerge");
13
14
  var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
14
15
  var _getDisplayName = _interopRequireDefault(require("@mui/utils/getDisplayName"));
@@ -39,7 +40,7 @@ function defaultOverridesResolver(slot) {
39
40
  return (_props, styles) => styles[slot];
40
41
  }
41
42
  function attachTheme(props, themeId, defaultTheme) {
42
- props.theme = isObjectEmpty(props.theme) ? defaultTheme : props.theme[themeId] || props.theme;
43
+ props.theme = (0, _isObjectEmpty.default)(props.theme) ? defaultTheme : props.theme[themeId] || props.theme;
43
44
  }
44
45
  function processStyle(props, style, layerName) {
45
46
  /*
@@ -274,13 +275,6 @@ function generateStyledLabel(componentName, componentSlot) {
274
275
  }
275
276
  return label;
276
277
  }
277
- function isObjectEmpty(object) {
278
- // eslint-disable-next-line
279
- for (const _ in object) {
280
- return false;
281
- }
282
- return true;
283
- }
284
278
 
285
279
  // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
286
280
  function isStringTag(tag) {
@@ -1,4 +1,5 @@
1
1
  import styledEngineStyled, { internal_mutateStyles as mutateStyles, internal_serializeStyles as serializeStyles } from '@mui/styled-engine';
2
+ import isObjectEmpty from '@mui/utils/isObjectEmpty';
2
3
  import { isPlainObject } from '@mui/utils/deepmerge';
3
4
  import capitalize from '@mui/utils/capitalize';
4
5
  import getDisplayName from '@mui/utils/getDisplayName';
@@ -265,13 +266,6 @@ function generateStyledLabel(componentName, componentSlot) {
265
266
  }
266
267
  return label;
267
268
  }
268
- function isObjectEmpty(object) {
269
- // eslint-disable-next-line
270
- for (const _ in object) {
271
- return false;
272
- }
273
- return true;
274
- }
275
269
 
276
270
  // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
277
271
  function isStringTag(tag) {
@@ -51,6 +51,7 @@ function createTheme(options = {}, ...args) {
51
51
  theme: this
52
52
  });
53
53
  };
54
+ muiTheme.internal_cache = {};
54
55
  return muiTheme;
55
56
  }
56
57
  var _default = exports.default = createTheme;
@@ -44,6 +44,7 @@ function createTheme(options = {}, ...args) {
44
44
  theme: this
45
45
  });
46
46
  };
47
+ muiTheme.internal_cache = {};
47
48
  return muiTheme;
48
49
  }
49
50
  export default createTheme;
@@ -10,6 +10,7 @@ export interface CssContainerQueries {
10
10
  containerQueries: ((name: string) => ContainerQueries) & ContainerQueries;
11
11
  }
12
12
  /**
13
+ * WARN: Mutably updates the `css` object.
13
14
  * For using in `sx` prop to sort the breakpoint from low to high.
14
15
  * Note: this function does not work and will not support multiple units.
15
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
@@ -10,6 +10,7 @@ export interface CssContainerQueries {
10
10
  containerQueries: ((name: string) => ContainerQueries) & ContainerQueries;
11
11
  }
12
12
  /**
13
+ * WARN: Mutably updates the `css` object.
13
14
  * For using in `sx` prop to sort the breakpoint from low to high.
14
15
  * Note: this function does not work and will not support multiple units.
15
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
@@ -7,31 +7,44 @@ exports.default = cssContainerQueries;
7
7
  exports.getContainerQuery = getContainerQuery;
8
8
  exports.isCqShorthand = isCqShorthand;
9
9
  exports.sortContainerQueries = sortContainerQueries;
10
+ const MIN_WIDTH_PATTERN = /min-width:\s*([0-9.]+)/;
11
+
10
12
  /**
13
+ * WARN: Mutably updates the `css` object.
11
14
  * For using in `sx` prop to sort the breakpoint from low to high.
12
15
  * Note: this function does not work and will not support multiple units.
13
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
14
17
  * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 even though 40rem > 300px
15
18
  */
16
19
  function sortContainerQueries(theme, css) {
17
- if (!theme.containerQueries) {
20
+ if (!theme.containerQueries || !hasContainerQuery(css)) {
18
21
  return css;
19
22
  }
20
- const regex = /min-width:\s*([0-9.]+)/;
21
- const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
22
- return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
23
- });
24
- if (!sorted.length) {
25
- return css;
23
+ const keys = [];
24
+ for (const key in css) {
25
+ if (key.startsWith('@container')) {
26
+ keys.push(key);
27
+ }
26
28
  }
27
- return sorted.reduce((acc, key) => {
28
- const value = css[key];
29
- delete acc[key];
30
- acc[key] = value;
31
- return acc;
32
- }, {
33
- ...css
29
+ keys.sort((a, b) => {
30
+ return +(a.match(MIN_WIDTH_PATTERN)?.[1] || 0) - +(b.match(MIN_WIDTH_PATTERN)?.[1] || 0);
34
31
  });
32
+ const result = css;
33
+ for (let i = 0; i < keys.length; i += 1) {
34
+ const key = keys[i];
35
+ const value = result[key];
36
+ delete result[key];
37
+ result[key] = value;
38
+ }
39
+ return result;
40
+ }
41
+ function hasContainerQuery(css) {
42
+ for (const key in css) {
43
+ if (key.startsWith('@container')) {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
35
48
  }
36
49
  function isCqShorthand(breakpointKeys, value) {
37
50
  return value === '@' || value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
@@ -1,28 +1,41 @@
1
+ const MIN_WIDTH_PATTERN = /min-width:\s*([0-9.]+)/;
2
+
1
3
  /**
4
+ * WARN: Mutably updates the `css` object.
2
5
  * For using in `sx` prop to sort the breakpoint from low to high.
3
6
  * Note: this function does not work and will not support multiple units.
4
7
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
5
8
  * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 even though 40rem > 300px
6
9
  */
7
10
  export function sortContainerQueries(theme, css) {
8
- if (!theme.containerQueries) {
11
+ if (!theme.containerQueries || !hasContainerQuery(css)) {
9
12
  return css;
10
13
  }
11
- const regex = /min-width:\s*([0-9.]+)/;
12
- const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
13
- return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
14
- });
15
- if (!sorted.length) {
16
- return css;
14
+ const keys = [];
15
+ for (const key in css) {
16
+ if (key.startsWith('@container')) {
17
+ keys.push(key);
18
+ }
17
19
  }
18
- return sorted.reduce((acc, key) => {
19
- const value = css[key];
20
- delete acc[key];
21
- acc[key] = value;
22
- return acc;
23
- }, {
24
- ...css
20
+ keys.sort((a, b) => {
21
+ return +(a.match(MIN_WIDTH_PATTERN)?.[1] || 0) - +(b.match(MIN_WIDTH_PATTERN)?.[1] || 0);
25
22
  });
23
+ const result = css;
24
+ for (let i = 0; i < keys.length; i += 1) {
25
+ const key = keys[i];
26
+ const value = result[key];
27
+ delete result[key];
28
+ result[key] = value;
29
+ }
30
+ return result;
31
+ }
32
+ function hasContainerQuery(css) {
33
+ for (const key in css) {
34
+ if (key.startsWith('@container')) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
26
39
  }
27
40
  export function isCqShorthand(breakpointKeys, value) {
28
41
  return value === '@' || value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
@@ -23,6 +23,7 @@ function createCssVarsTheme({
23
23
  output.generateStyleSheets = result.generateStyleSheets;
24
24
  output.colorSchemeSelector = colorSchemeSelector;
25
25
  output.getColorSchemeSelector = (0, _getColorSchemeSelector.createGetColorSchemeSelector)(colorSchemeSelector);
26
+ output.internal_cache = {};
26
27
  return output;
27
28
  }
28
29
  var _default = exports.default = createCssVarsTheme;
@@ -16,6 +16,7 @@ function createCssVarsTheme({
16
16
  output.generateStyleSheets = result.generateStyleSheets;
17
17
  output.colorSchemeSelector = colorSchemeSelector;
18
18
  output.getColorSchemeSelector = createGetColorSchemeSelector(colorSchemeSelector);
19
+ output.internal_cache = {};
19
20
  return output;
20
21
  }
21
22
  export default createCssVarsTheme;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v9.0.0-alpha.3
2
+ * @mui/system v9.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v9.0.0-alpha.3
2
+ * @mui/system v9.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/merge/merge.js CHANGED
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
9
+ const options = {
10
+ clone: false
11
+ };
9
12
  function merge(acc, item) {
10
13
  if (!item) {
11
14
  return acc;
12
15
  }
13
- return (0, _deepmerge.default)(acc, item, {
14
- clone: false // No need to clone deep, it's way faster.
15
- });
16
+ return (0, _deepmerge.default)(acc, item, options);
16
17
  }
17
18
  var _default = exports.default = merge;
package/merge/merge.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  import deepmerge from '@mui/utils/deepmerge';
2
+ const options = {
3
+ clone: false
4
+ };
2
5
  function merge(acc, item) {
3
6
  if (!item) {
4
7
  return acc;
5
8
  }
6
- return deepmerge(acc, item, {
7
- clone: false // No need to clone deep, it's way faster.
8
- });
9
+ return deepmerge(acc, item, options);
9
10
  }
10
11
  export default merge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "9.0.0-alpha.3",
3
+ "version": "9.0.0-beta.0",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
6
6
  "keywords": [
@@ -24,14 +24,14 @@
24
24
  "url": "https://opencollective.com/mui-org"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/runtime": "^7.28.6",
27
+ "@babel/runtime": "^7.29.2",
28
28
  "clsx": "^2.1.1",
29
29
  "csstype": "^3.2.3",
30
30
  "prop-types": "^15.8.1",
31
- "@mui/private-theming": "9.0.0-alpha.3",
32
- "@mui/styled-engine": "9.0.0-alpha.3",
33
- "@mui/types": "^9.0.0-alpha.3",
34
- "@mui/utils": "9.0.0-alpha.3"
31
+ "@mui/private-theming": "9.0.0-beta.0",
32
+ "@mui/styled-engine": "9.0.0-beta.0",
33
+ "@mui/types": "^9.0.0-beta.0",
34
+ "@mui/utils": "9.0.0-beta.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@emotion/react": "^11.5.0",