@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
package/Box/Box.d.mts CHANGED
@@ -21,7 +21,7 @@ export type SimpleSystemKeys = keyof PropsFor<ComposedStyleFunction<[typeof bord
21
21
  // This is needed as these are used as keys inside AllSystemCSSProperties
22
22
  type StandardSystemKeys = Extract<SimpleSystemKeys, keyof AllSystemCSSProperties>;
23
23
  export type SystemProps<Theme extends object = {}> = { [K in StandardSystemKeys]?: ResponsiveStyleValue<AllSystemCSSProperties[K]> | ((theme: Theme) => ResponsiveStyleValue<AllSystemCSSProperties[K]>) };
24
- export interface BoxOwnProps<Theme extends object = SystemTheme> extends SystemProps<Theme> {
24
+ export interface BoxOwnProps<Theme extends object = SystemTheme> {
25
25
  children?: React.ReactNode;
26
26
  ref?: React.Ref<unknown> | undefined;
27
27
  /**
package/Box/Box.d.ts CHANGED
@@ -21,7 +21,7 @@ export type SimpleSystemKeys = keyof PropsFor<ComposedStyleFunction<[typeof bord
21
21
  // This is needed as these are used as keys inside AllSystemCSSProperties
22
22
  type StandardSystemKeys = Extract<SimpleSystemKeys, keyof AllSystemCSSProperties>;
23
23
  export type SystemProps<Theme extends object = {}> = { [K in StandardSystemKeys]?: ResponsiveStyleValue<AllSystemCSSProperties[K]> | ((theme: Theme) => ResponsiveStyleValue<AllSystemCSSProperties[K]>) };
24
- export interface BoxOwnProps<Theme extends object = SystemTheme> extends SystemProps<Theme> {
24
+ export interface BoxOwnProps<Theme extends object = SystemTheme> {
25
25
  children?: React.ReactNode;
26
26
  ref?: React.Ref<unknown> | undefined;
27
27
  /**
package/CHANGELOG.md CHANGED
@@ -1,5 +1,216 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 9.0.0-beta.0
4
+
5
+ <!-- generated comparing v9.0.0-alpha.4..master -->
6
+
7
+ _Mar 25, 2026_
8
+
9
+ A big thanks to the 8 contributors who made this release possible.
10
+
11
+ ### `@mui/material@9.0.0-beta.0`
12
+
13
+ #### Breaking Changes
14
+
15
+ - [linear-progress] Remove deprecated CSS classes (#48068) @mj12albert
16
+ - [list-item, list-item-text] Remove deprecated props (#48042) @siriwatknp
17
+ - [button-group] Remove deprecated classes (#48043) @siriwatknp
18
+ - [card] Remove deprecated CardHeader props (#47995) @silviuaavram
19
+ - [checkbox][radio][switch] Remove deprecated inputProps and inputRef (#48059) @siriwatknp
20
+ - [chip] Remove deprecated classes (#48046) @silviuaavram
21
+ - [dialog][modal][drawer][swipeabledrawer] Remove deprecated props and classes (#48039) @silviuaavram
22
+ - [divider] Remove deprecated CSS classes (#48075) @siriwatknp
23
+ - [drawer] Remove deprecated CSS classes (#48077) @siriwatknp
24
+ - [image-list-item-bar] Remove deprecated CSS classes (#48064) @siriwatknp
25
+ - [inputs] Remove deprecated props & classes (#48071) @mj12albert
26
+ - [material-ui] Remove unnecessary overridesResolvers from styled components (#48082) @ZeeshanTamboli
27
+ - [material-ui][system] Remove deprecated system props from Box, Stack, Typography (#48072) @siriwatknp
28
+ - [pagination-item] Remove deprecated CSS classes (#48076) @siriwatknp
29
+ - [pagination-item] Remove deprecated props (#48038) @siriwatknp
30
+ - [rating] Remove deprecated IconContainerComponent (#48019) @siriwatknp
31
+ - [select] Remove deprecated CSS classes (#48065) @mj12albert
32
+ - [slider] Remove deprecated CSS classes (#48074) @siriwatknp
33
+ - [step-connector][step-content][step-label] Remove deprecated props and classes (#48058) @siriwatknp
34
+ - [tabs][tab] Remove deprecated CSS classes (#48078) @siriwatknp
35
+ - [table-pagination][table-sort-label] Remove deprecated props and classes (#48060) @siriwatknp
36
+ - [toggle-button-group] Remove deprecated classes (#48061) @siriwatknp
37
+
38
+ #### Changes
39
+
40
+ - [system] Improve performance when using sx prop (#44254) @romgrk
41
+
42
+ ### `@mui/codemod@9.0.0-beta.0`
43
+
44
+ - [codemod] Add missing codemod links in upgrade guide (#48069) @silviuaavram
45
+
46
+ ### Docs
47
+
48
+ - Mention all breaking changes in changelog (#48091) @silviuaavram
49
+ - Fix link to upgrade-to-v9 docs in release CHANGELOG (#48081) @ZeeshanTamboli
50
+
51
+ ### Core
52
+
53
+ - Update browserslistrc (#48085) @silviuaavram
54
+ - [code-infra] Prevent major version updates of bundler/framework packages in bundling fixtures (#48062) @Copilot
55
+ - [code-infra][icons-material] Avoid material utils barrel in createSvgIcon (#48029) @anchmelev
56
+ - [docs-infra] Migrate more leaf components to mui-docs (#48018) @brijeshb42
57
+
58
+ All contributors of this release in alphabetical order: @anchmelev, @brijeshb42, @Copilot, @mj12albert, @romgrk, @silviuaavram, @siriwatknp, @ZeeshanTamboli
59
+
60
+ ## 9.0.0-alpha.4
61
+
62
+ <!-- generated comparing v9.0.0-alpha.3..master -->
63
+
64
+ _Mar 20, 2026_
65
+
66
+ A big thanks to the 11 contributors who made this release possible.
67
+
68
+ ### `@mui/material@9.0.0-alpha.4`
69
+
70
+ #### Breaking Changes
71
+
72
+ - [accordion] Remove deprecated props (#47963) @silviuaavram
73
+ - `TransitionComponent`
74
+ - `TransitionProps`
75
+ - [accordionsummary] Remove deprecated CSS class (#48006) @silviuaavram
76
+ - `contentGutters`
77
+ - [alert] Remove deprecated CSS classes (#48011) @silviuaavram
78
+ - `standardSuccess`
79
+ - `standardInfo`
80
+ - `standardWarning`
81
+ - `standardError`
82
+ - `outlinedSuccess`
83
+ - `outlinedInfo`
84
+ - `outlinedWarning`
85
+ - `outlinedError`
86
+ - `filledSuccess`
87
+ - `filledInfo`
88
+ - `filledWarning`
89
+ - `filledError`
90
+ - [alert] Remove deprecated props (#47965) @silviuaavram
91
+ - `components`
92
+ - `componentsProps`
93
+ - [autocomplete] Remove deprecated props (#47864) @ZeeshanTamboli
94
+ - `ChipProps`
95
+ - `componentsProps`
96
+ - `ListboxComponent`
97
+ - `ListboxProps`
98
+ - `PaperComponent`
99
+ - `PopperComponent`
100
+ - `renderTags`
101
+ - [avatar] Remove deprecated props (#47966) @silviuaavram
102
+ - `imgProps`
103
+ - [avatargroup] Remove deprecated props (#47968) @silviuaavram
104
+ - `componentsProps`
105
+ - [backdrop] Remove deprecated props (#47991) @silviuaavram
106
+ - `components`
107
+ - `componentsProps`
108
+ - `TransitionComponent`
109
+ - [badge] Remove deprecated props (#47993) @silviuaavram
110
+ - `components`
111
+ - `componentsProps`
112
+ - [button] Remove deprecated CSS classes (#48012) @silviuaavram
113
+ - Color variant classes: `textInherit`, `outlinedPrimary`, `containedSecondary`, etc.
114
+ - Size classes: `textSizeSmall`, `iconSizeMedium`, etc.
115
+ - [circularprogress] Remove deprecated CSS classes (#48014) @silviuaavram
116
+ - `circleDeterminate`
117
+ - `circleIndeterminate`
118
+ - [divider] Remove deprecated prop (#48013) @atharva3333
119
+ - `light`
120
+ - [formcontrollabel] Remove deprecated props (#48032) @atharva3333
121
+ - `componentsProps`
122
+ - [menu] Remove deprecated props (#48021) @siriwatknp
123
+ - `MenuListProps`
124
+ - `PaperProps`
125
+ - `TransitionProps`
126
+ - [mobilestepper] Remove deprecated props (#48041) @siriwatknp
127
+ - `LinearProgressProps`
128
+ - [popover] Remove deprecated props (#48021) @siriwatknp
129
+ - `BackdropComponent`
130
+ - `BackdropProps`
131
+ - `PaperProps`
132
+ - `TransitionComponent`
133
+ - `TransitionProps`
134
+ - [popper] Remove deprecated props (#48020) @siriwatknp
135
+ - `components`
136
+ - `componentsProps`
137
+ - [select] Remove deprecated props passed via `MenuProps` (#48021) @siriwatknp
138
+ - `MenuListProps`
139
+ - `PaperProps`
140
+ - `TransitionProps`
141
+ - [slider] Remove deprecated props (#47996) @siriwatknp
142
+ - `components`
143
+ - `componentsProps`
144
+ - [speeddial] Remove deprecated props (#47998) @siriwatknp
145
+ - `TransitionComponent`
146
+ - `TransitionProps`
147
+ - [speeddialaction] Remove deprecated props (#47998) @siriwatknp
148
+ - `FabProps`
149
+ - `tooltipTitle`
150
+ - `tooltipPlacement`
151
+ - `tooltipOpen`
152
+ - `TooltipClasses`
153
+ - [tabs] Remove deprecated props (#48017) @siriwatknp
154
+ - `ScrollButtonComponent`
155
+ - `TabIndicatorProps`
156
+ - `TabScrollButtonProps`
157
+ - `slots.StartScrollButtonIcon`
158
+ - `slots.EndScrollButtonIcon`
159
+ - [textfield] Remove deprecated props (#47878) @ZeeshanTamboli
160
+ - `InputProps`
161
+ - `inputProps`
162
+ - `SelectProps`
163
+ - `InputLabelProps`
164
+ - `FormHelperTextProps`
165
+ - [tooltip] Remove deprecated props (#47988) @siriwatknp
166
+ - `components`
167
+ - `componentsProps`
168
+ - `PopperComponent`
169
+ - `PopperProps`
170
+ - `TransitionComponent`
171
+ - `TransitionProps`
172
+ - [typography] Remove deprecated prop (#47986) @siriwatknp
173
+ - `paragraph`
174
+ - [buttonbase] Key handlers should not run on a disabled non-native button (#48003) @mj12albert
175
+ - [tablepagination] Format pagination numbers according to locale (#47803) @siriwatknp
176
+ - [textfield] Use non-native label for `<TextField select/>` (#47958) @mj12albert
177
+
178
+ Check out the [v9 upgrade guide](https://next.mui.com/material-ui/migration/upgrade-to-v9/).
179
+
180
+ #### Changes
181
+
182
+ - [autocomplete] Optimize selected option lookup (#47953) @anchmelev
183
+ - [buttonbase] Fix native button detection (#47985) @mj12albert
184
+ - [inputbase] Fix test using removed InputProps on TextField (#48000) @siriwatknp
185
+ - [popper] Add missing classes export (#48031) @mj12albert
186
+ - [select] Fix focus visible always set on menu item (#47912) @silviuaavram
187
+ - [slider] Fix focus visible styles incorrectly applied by pointer (#47894) @mj12albert
188
+ - [slider] Accept readonly array for the value prop (#47936) @pcorpet
189
+
190
+ ### `@mui/codemod@9.0.0-alpha.4`
191
+
192
+ - [codemod] Add slot key rename to `tabs-props` codemod and add to README (#48035) @siriwatknp
193
+ - [codemod] Add card-header-props migration guide (#48005) @siriwatknp
194
+
195
+ ### Docs
196
+
197
+ - [blog] Lowercase 2026-MUI-X-price-changes blog post URL (#47871) @Janpot
198
+ - [docs] Wide docs layout (#47950) @noraleonte
199
+ - [docs] Mention the list of props removed in upgrade guide (#48010) @silviuaavram
200
+ - [docs] Update Autocomplete deprecated props removal migration guide docs (#47990) @ZeeshanTamboli
201
+ - [docs-infra] Extract shared App component from \_app into @mui/docs (#47933) @brijeshb42
202
+ - [docs-infra] Expose global theme object (#47964) @Janpot
203
+ - [docs][system] Update `styled` API docs for easier understanding (#47957) @olivier-lxo
204
+
205
+ ### Core
206
+
207
+ - [code-infra] Add pkg-pr-new as dev dependency (#47992) @Janpot
208
+ - [code-infra] Remove CI coverage collection and upload to Codecov (#47930) @Janpot
209
+ - [core] Migrate to ESLint 10 (#47872) @brijeshb42
210
+ - [core] Remove GridLegacy component (#47956) @siriwatknp
211
+
212
+ All contributors of this release in alphabetical order: @anchmelev, @atharva3333, @brijeshb42, @Janpot, @mj12albert, @noraleonte, @olivier-lxo, @pcorpet, @silviuaavram, @siriwatknp, @ZeeshanTamboli
213
+
3
214
  ## 9.0.0-alpha.3
4
215
 
5
216
  <!-- generated comparing v9.0.0-alpha.2..master -->
@@ -13,11 +224,16 @@ A big thanks to the 10 contributors who made this release possible. Here are som
13
224
 
14
225
  ### `@mui/material@9.0.0-alpha.3`
15
226
 
227
+ #### Breaking Changes
228
+
229
+ - [stepper][menulist][tabs] Improve accessibility (#47687) @silviuaavram
230
+
231
+ #### Changes
232
+
16
233
  - [autocomplete] Add `root` slot (#47852) @GerardasB
17
234
  - [autocomplete] Fix popup reopening on window focus regain with openOnFocus (#47790) @aman44444
18
235
  - [autocomplete] Support full slots for clearIndicator and popupIndicator (#47891) @silviuaavram
19
236
  - [material-ui] Partially revert "[material-ui] Clean up duplicated CSS rules (#47838)" (#47927) @sai6855
20
- - [stepper][menulist][tabs] Improve accessibility (#47687) @silviuaavram
21
237
 
22
238
  ### Docs
23
239
 
@@ -75,16 +291,21 @@ A big thanks to the 13 contributors who made this release possible. Here are som
75
291
 
76
292
  ### @mui/material@9.0.0-alpha.1
77
293
 
294
+ #### Breaking Changes
295
+
78
296
  - [Autocomplete] Prevents Autocomplete menu from opening on right click (#47797) @silviuaavram
79
297
  - [Backdrop] Remove aria-hidden by default (#47798) @silviuaavram
80
298
  - [ButtonBase] Ensure that onClick propagates when non-native button is clicked (#47800) @silviuaavram
81
299
  - [Dialog][Modal] Remove `disableEscapeKeyDown` prop (#47695) @silviuaavram
82
300
  - [Grid] Remove system props support (#47846) @siriwatknp
83
- - [TableCell][theme] Apply `alpha` before color mixing to border bottom color when nativeColor + cssVariables is used (#47762) @ZeeshanTamboli
84
301
  - [theme] Remove MuiTouchRipple from theme component types (#47849) @siriwatknp
85
- - [Tooltip] Fix error is thrown when wrapping an input which is disabled while focused (#47684) @ZeeshanTamboli
86
302
  - [useAutocomplete] Improve isOptionEqualToValue value argument type (#47801) @silviuaavram
87
303
 
304
+ #### Changes
305
+
306
+ - [TableCell][theme] Apply `alpha` before color mixing to border bottom color when nativeColor + cssVariables is used (#47762) @ZeeshanTamboli
307
+ - [Tooltip] Fix error is thrown when wrapping an input which is disabled while focused (#47684) @ZeeshanTamboli
308
+
88
309
  ### Docs
89
310
 
90
311
  - [docs] Add updated community theme resource (#47847) @PeterTYLiu
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { OverrideProps } from '@mui/types';
3
3
  import { ResponsiveStyleValue, SxProps } from "../styleFunctionSx/index.mjs";
4
- import { SystemProps } from "../Box/index.mjs";
5
4
  import { Theme } from "../createTheme/index.mjs";
6
5
  export interface StackBaseProps {
7
6
  /**
@@ -40,7 +39,7 @@ export interface StackTypeMap<AdditionalProps = {}, DefaultComponent extends Rea
40
39
  * The system prop, which allows defining system overrides as well as additional CSS styles.
41
40
  */
42
41
  sx?: SxProps<Theme> | undefined;
43
- } & SystemProps<Theme>;
42
+ };
44
43
  defaultComponent: DefaultComponent;
45
44
  }
46
45
  export type StackProps<RootComponent extends React.ElementType = StackTypeMap['defaultComponent'], AdditionalProps = {
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { OverrideProps } from '@mui/types';
3
3
  import { ResponsiveStyleValue, SxProps } from "../styleFunctionSx/index.js";
4
- import { SystemProps } from "../Box/index.js";
5
4
  import { Theme } from "../createTheme/index.js";
6
5
  export interface StackBaseProps {
7
6
  /**
@@ -40,7 +39,7 @@ export interface StackTypeMap<AdditionalProps = {}, DefaultComponent extends Rea
40
39
  * The system prop, which allows defining system overrides as well as additional CSS styles.
41
40
  */
42
41
  sx?: SxProps<Theme> | undefined;
43
- } & SystemProps<Theme>;
42
+ };
44
43
  defaultComponent: DefaultComponent;
45
44
  }
46
45
  export type StackProps<RootComponent extends React.ElementType = StackTypeMap['defaultComponent'], AdditionalProps = {
@@ -16,7 +16,6 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
16
16
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
17
17
  var _styled = _interopRequireDefault(require("../styled"));
18
18
  var _useThemeProps = _interopRequireDefault(require("../useThemeProps"));
19
- var _styleFunctionSx = require("../styleFunctionSx");
20
19
  var _createTheme = _interopRequireDefault(require("../createTheme"));
21
20
  var _breakpoints = require("../breakpoints");
22
21
  var _spacing = require("../spacing");
@@ -144,7 +143,6 @@ function createStack(options = {}) {
144
143
  const StackRoot = createStyledComponent(style);
145
144
  const Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
146
145
  const themeProps = useThemeProps(inProps);
147
- const props = (0, _styleFunctionSx.extendSxProp)(themeProps); // `color` type conflicts with html color attribute.
148
146
  const {
149
147
  component = 'div',
150
148
  direction = 'column',
@@ -154,7 +152,7 @@ function createStack(options = {}) {
154
152
  className,
155
153
  useFlexGap = false,
156
154
  ...other
157
- } = props;
155
+ } = themeProps;
158
156
  const ownerState = {
159
157
  direction,
160
158
  spacing,
@@ -8,7 +8,6 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
8
  import composeClasses from '@mui/utils/composeClasses';
9
9
  import systemStyled from "../styled/index.mjs";
10
10
  import useThemePropsSystem from "../useThemeProps/index.mjs";
11
- import { extendSxProp } from "../styleFunctionSx/index.mjs";
12
11
  import createTheme from "../createTheme/index.mjs";
13
12
  import { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues } from "../breakpoints/index.mjs";
14
13
  import { createUnarySpacing, getValue } from "../spacing/index.mjs";
@@ -135,7 +134,6 @@ export default function createStack(options = {}) {
135
134
  const StackRoot = createStyledComponent(style);
136
135
  const Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
137
136
  const themeProps = useThemeProps(inProps);
138
- const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
139
137
  const {
140
138
  component = 'div',
141
139
  direction = 'column',
@@ -145,7 +143,7 @@ export default function createStack(options = {}) {
145
143
  className,
146
144
  useFlexGap = false,
147
145
  ...other
148
- } = props;
146
+ } = themeProps;
149
147
  const ownerState = {
150
148
  direction,
151
149
  spacing,
@@ -1,8 +1,9 @@
1
1
  import { CSSObject } from '@mui/styled-engine';
2
2
  import { Breakpoints } from "../createBreakpoints/createBreakpoints.mjs";
3
- import type { Breakpoint } from "../createTheme/index.mjs";
3
+ import type { Breakpoint, Theme } from "../createTheme/index.mjs";
4
4
  import { ResponsiveStyleValue } from "../styleFunctionSx/index.mjs";
5
5
  import { StyleFunction } from "../style/index.mjs";
6
+ export const DEFAULT_BREAKPOINTS: Breakpoints;
6
7
  export interface ResolveBreakpointValuesOptions<T> {
7
8
  values: ResponsiveStyleValue<T>;
8
9
  breakpoints?: Breakpoints['values'] | undefined;
@@ -10,7 +11,9 @@ export interface ResolveBreakpointValuesOptions<T> {
10
11
  }
11
12
  export function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
12
13
  export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
14
+ export function iterateBreakpoints(target: any, theme: Theme, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
13
15
  export function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
16
+ export function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
14
17
  type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
18
 
16
19
  /**
@@ -1,8 +1,9 @@
1
1
  import { CSSObject } from '@mui/styled-engine';
2
2
  import { Breakpoints } from "../createBreakpoints/createBreakpoints.js";
3
- import type { Breakpoint } from "../createTheme/index.js";
3
+ import type { Breakpoint, Theme } from "../createTheme/index.js";
4
4
  import { ResponsiveStyleValue } from "../styleFunctionSx/index.js";
5
5
  import { StyleFunction } from "../style/index.js";
6
+ export const DEFAULT_BREAKPOINTS: Breakpoints;
6
7
  export interface ResolveBreakpointValuesOptions<T> {
7
8
  values: ResponsiveStyleValue<T>;
8
9
  breakpoints?: Breakpoints['values'] | undefined;
@@ -10,7 +11,9 @@ export interface ResolveBreakpointValuesOptions<T> {
10
11
  }
11
12
  export function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
12
13
  export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
14
+ export function iterateBreakpoints(target: any, theme: Theme, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
13
15
  export function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
16
+ export function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
14
17
  type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
18
 
16
19
  /**
@@ -4,18 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.DEFAULT_BREAKPOINTS = void 0;
7
8
  exports.computeBreakpointsBase = computeBreakpointsBase;
8
9
  exports.createEmptyBreakpointObject = createEmptyBreakpointObject;
9
10
  exports.default = void 0;
10
11
  exports.handleBreakpoints = handleBreakpoints;
12
+ exports.hasBreakpoint = hasBreakpoint;
13
+ exports.iterateBreakpoints = iterateBreakpoints;
11
14
  exports.mergeBreakpointsInOrder = mergeBreakpointsInOrder;
12
15
  exports.removeUnusedBreakpoints = removeUnusedBreakpoints;
13
16
  exports.resolveBreakpointValues = resolveBreakpointValues;
14
17
  exports.values = void 0;
15
18
  var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _isObjectEmpty = _interopRequireDefault(require("@mui/utils/isObjectEmpty"));
20
+ var _fastDeepAssign = _interopRequireDefault(require("@mui/utils/fastDeepAssign"));
16
21
  var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
17
22
  var _merge = _interopRequireDefault(require("../merge"));
18
23
  var _cssContainerQueries = require("../cssContainerQueries");
24
+ var _createBreakpoints = _interopRequireDefault(require("../createBreakpoints/createBreakpoints"));
25
+ const EMPTY_THEME = {};
26
+
19
27
  // The breakpoint **start** at this value.
20
28
  // For instance with the first breakpoint xs: [xs, sm[.
21
29
  const values = exports.values = {
@@ -29,12 +37,9 @@ const values = exports.values = {
29
37
  // desktop
30
38
  xl: 1536 // large screen
31
39
  };
32
- const defaultBreakpoints = {
33
- // Sorted ASC by size. That's important.
34
- // It can't be configured as it's used statically for propTypes.
35
- keys: ['xs', 'sm', 'md', 'lg', 'xl'],
36
- up: key => `@media (min-width:${values[key]}px)`
37
- };
40
+ const DEFAULT_BREAKPOINTS = exports.DEFAULT_BREAKPOINTS = (0, _createBreakpoints.default)({
41
+ values
42
+ });
38
43
  const defaultContainerQueries = {
39
44
  containerQueries: containerName => ({
40
45
  up: key => {
@@ -47,44 +52,59 @@ const defaultContainerQueries = {
47
52
  })
48
53
  };
49
54
  function handleBreakpoints(props, propValue, styleFromPropValue) {
50
- const theme = props.theme || {};
55
+ const result = {};
56
+ return iterateBreakpoints(result, props.theme, propValue, (mediaKey, value, initialKey) => {
57
+ const finalValue = styleFromPropValue(value, initialKey);
58
+ if (mediaKey) {
59
+ result[mediaKey] = finalValue;
60
+ } else {
61
+ (0, _fastDeepAssign.default)(result, finalValue);
62
+ }
63
+ });
64
+ }
65
+ function iterateBreakpoints(target, theme, propValue, callback) {
66
+ theme ?? (theme = EMPTY_THEME);
51
67
  if (Array.isArray(propValue)) {
52
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
53
- return propValue.reduce((acc, item, index) => {
54
- acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
55
- return acc;
56
- }, {});
68
+ const breakpoints = theme.breakpoints ?? DEFAULT_BREAKPOINTS;
69
+ for (let i = 0; i < propValue.length; i += 1) {
70
+ buildBreakpoint(target, breakpoints.up(breakpoints.keys[i]), propValue[i], undefined, callback);
71
+ }
72
+ return target;
57
73
  }
58
74
  if (typeof propValue === 'object') {
59
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
60
- return Object.keys(propValue).reduce((acc, breakpoint) => {
61
- if ((0, _cssContainerQueries.isCqShorthand)(themeBreakpoints.keys, breakpoint)) {
62
- const containerKey = (0, _cssContainerQueries.getContainerQuery)(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
75
+ const breakpoints = theme.breakpoints ?? DEFAULT_BREAKPOINTS;
76
+ const breakpointValues = breakpoints.values ?? values;
77
+ for (const key in propValue) {
78
+ if ((0, _cssContainerQueries.isCqShorthand)(breakpoints.keys, key)) {
79
+ const containerKey = (0, _cssContainerQueries.getContainerQuery)(theme.containerQueries ? theme : defaultContainerQueries, key);
63
80
  if (containerKey) {
64
- acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
81
+ buildBreakpoint(target, containerKey, propValue[key], key, callback);
65
82
  }
66
83
  }
67
- // key is breakpoint
68
- else if (Object.keys(themeBreakpoints.values || values).includes(breakpoint)) {
69
- const mediaKey = themeBreakpoints.up(breakpoint);
70
- acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
84
+ // key is key
85
+ else if (key in breakpointValues) {
86
+ const mediaKey = breakpoints.up(key);
87
+ buildBreakpoint(target, mediaKey, propValue[key], key, callback);
71
88
  } else {
72
- const cssKey = breakpoint;
73
- acc[cssKey] = propValue[cssKey];
89
+ const cssKey = key;
90
+ target[cssKey] = propValue[cssKey];
74
91
  }
75
- return acc;
76
- }, {});
92
+ }
93
+ return target;
77
94
  }
78
- const output = styleFromPropValue(propValue);
79
- return output;
95
+ callback(undefined, propValue);
96
+ return target;
97
+ }
98
+ function buildBreakpoint(target, mediaKey, value, initialKey, callback) {
99
+ target[mediaKey] ?? (target[mediaKey] = {});
100
+ callback(mediaKey, value, initialKey);
80
101
  }
81
- function breakpoints(styleFunction) {
82
- // false positive
102
+ function setupBreakpoints(styleFunction) {
83
103
  // eslint-disable-next-line react/function-component-definition
84
104
  const newStyleFunction = props => {
85
105
  const theme = props.theme || {};
86
106
  const base = styleFunction(props);
87
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
107
+ const themeBreakpoints = theme.breakpoints || DEFAULT_BREAKPOINTS;
88
108
  const extended = themeBreakpoints.keys.reduce((acc, key) => {
89
109
  if (props[key]) {
90
110
  acc = acc || {};
@@ -108,28 +128,30 @@ function breakpoints(styleFunction) {
108
128
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
109
129
  return newStyleFunction;
110
130
  }
111
- function createEmptyBreakpointObject(breakpointsInput = {}) {
112
- const breakpointsInOrder = breakpointsInput.keys?.reduce((acc, key) => {
113
- const breakpointStyleKey = breakpointsInput.up(key);
114
- acc[breakpointStyleKey] = {};
115
- return acc;
116
- }, {});
117
- return breakpointsInOrder || {};
131
+ function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
132
+ const {
133
+ internal_mediaKeys: mediaKeys
134
+ } = breakpoints;
135
+ const result = {};
136
+ for (let i = 0; i < mediaKeys.length; i += 1) {
137
+ result[mediaKeys[i]] = {};
138
+ }
139
+ return result;
118
140
  }
119
- function removeUnusedBreakpoints(breakpointKeys, style) {
120
- return breakpointKeys.reduce((acc, key) => {
121
- const breakpointOutput = acc[key];
122
- const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
123
- if (isBreakpointUnused) {
124
- delete acc[key];
141
+ function removeUnusedBreakpoints(breakpoints, style) {
142
+ const breakpointKeys = breakpoints.internal_mediaKeys;
143
+ for (let i = 0; i < breakpointKeys.length; i += 1) {
144
+ const key = breakpointKeys[i];
145
+ if ((0, _isObjectEmpty.default)(style[key])) {
146
+ delete style[key];
125
147
  }
126
- return acc;
127
- }, style);
148
+ }
149
+ return style;
128
150
  }
129
- function mergeBreakpointsInOrder(breakpointsInput, ...styles) {
130
- const emptyBreakpoints = createEmptyBreakpointObject(breakpointsInput);
151
+ function mergeBreakpointsInOrder(breakpoints, ...styles) {
152
+ const emptyBreakpoints = createEmptyBreakpointObject(breakpoints);
131
153
  const mergedOutput = [emptyBreakpoints, ...styles].reduce((prev, next) => (0, _deepmerge.default)(prev, next), {});
132
- return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
154
+ return removeUnusedBreakpoints(breakpoints, mergedOutput);
133
155
  }
134
156
 
135
157
  // compute base for responsive values; e.g.,
@@ -181,4 +203,23 @@ function resolveBreakpointValues({
181
203
  return acc;
182
204
  }, {});
183
205
  }
184
- var _default = exports.default = breakpoints;
206
+ function hasBreakpoint(breakpoints, value) {
207
+ if (Array.isArray(value)) {
208
+ return true;
209
+ }
210
+ if (typeof value === 'object' && value !== null) {
211
+ for (let i = 0; i < breakpoints.keys.length; i += 1) {
212
+ if (breakpoints.keys[i] in value) {
213
+ return true;
214
+ }
215
+ }
216
+ const valueKeys = Object.keys(value);
217
+ for (let i = 0; i < valueKeys.length; i += 1) {
218
+ if ((0, _cssContainerQueries.isCqShorthand)(breakpoints.keys, valueKeys[i])) {
219
+ return true;
220
+ }
221
+ }
222
+ }
223
+ return false;
224
+ }
225
+ var _default = exports.default = setupBreakpoints;