@mui/system 6.0.0-alpha.1 → 6.0.0-alpha.3

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 (128) hide show
  1. package/CHANGELOG.md +114 -2
  2. package/Container/Container.d.ts +1 -1
  3. package/Stack/Stack.d.ts +1 -1
  4. package/Stack/createStack.d.ts +1 -1
  5. package/Unstable_Grid/Grid.d.ts +1 -1
  6. package/Unstable_Grid/createGrid.d.ts +1 -1
  7. package/breakpoints/breakpoints.js +19 -1
  8. package/createTheme/createTheme.d.ts +2 -1
  9. package/createTheme/createTheme.js +2 -0
  10. package/cssContainerQueries/cssContainerQueries.d.ts +24 -0
  11. package/cssContainerQueries/cssContainerQueries.js +68 -0
  12. package/cssContainerQueries/index.d.ts +3 -0
  13. package/cssContainerQueries/index.js +2 -0
  14. package/cssContainerQueries/package.json +6 -0
  15. package/cssVars/cssVarsParser.d.ts +1 -1
  16. package/index.d.ts +2 -0
  17. package/index.js +2 -1
  18. package/modern/breakpoints/breakpoints.js +19 -1
  19. package/modern/createTheme/createTheme.js +2 -0
  20. package/modern/cssContainerQueries/cssContainerQueries.js +68 -0
  21. package/modern/cssContainerQueries/index.js +2 -0
  22. package/modern/index.js +2 -1
  23. package/modern/styleFunctionSx/styleFunctionSx.js +2 -1
  24. package/node/breakpoints/breakpoints.js +19 -1
  25. package/node/createTheme/createTheme.js +2 -0
  26. package/node/cssContainerQueries/cssContainerQueries.js +79 -0
  27. package/node/cssContainerQueries/index.js +32 -0
  28. package/node/index.js +9 -1
  29. package/node/styleFunctionSx/styleFunctionSx.js +2 -1
  30. package/package.json +5 -5
  31. package/styleFunctionSx/styleFunctionSx.js +2 -1
  32. package/legacy/Box/Box.js +0 -30
  33. package/legacy/Box/boxClasses.js +0 -3
  34. package/legacy/Box/index.js +0 -5
  35. package/legacy/Container/Container.js +0 -61
  36. package/legacy/Container/ContainerProps.js +0 -1
  37. package/legacy/Container/containerClasses.js +0 -7
  38. package/legacy/Container/createContainer.js +0 -140
  39. package/legacy/Container/index.js +0 -5
  40. package/legacy/GlobalStyles/GlobalStyles.js +0 -37
  41. package/legacy/GlobalStyles/index.js +0 -4
  42. package/legacy/RtlProvider/index.js +0 -22
  43. package/legacy/Stack/Stack.js +0 -62
  44. package/legacy/Stack/StackProps.js +0 -1
  45. package/legacy/Stack/createStack.js +0 -180
  46. package/legacy/Stack/index.js +0 -7
  47. package/legacy/Stack/stackClasses.js +0 -7
  48. package/legacy/ThemeProvider/ThemeProvider.js +0 -87
  49. package/legacy/ThemeProvider/index.js +0 -3
  50. package/legacy/Unstable_Grid/Grid.js +0 -177
  51. package/legacy/Unstable_Grid/GridProps.js +0 -1
  52. package/legacy/Unstable_Grid/createGrid.js +0 -184
  53. package/legacy/Unstable_Grid/gridClasses.js +0 -28
  54. package/legacy/Unstable_Grid/gridGenerator.js +0 -216
  55. package/legacy/Unstable_Grid/index.js +0 -8
  56. package/legacy/Unstable_Grid/traverseBreakpoints.js +0 -48
  57. package/legacy/borders/borders.js +0 -51
  58. package/legacy/borders/index.js +0 -4
  59. package/legacy/breakpoints/breakpoints.js +0 -162
  60. package/legacy/breakpoints/index.js +0 -4
  61. package/legacy/colorManipulator/colorManipulator.js +0 -356
  62. package/legacy/colorManipulator/index.js +0 -3
  63. package/legacy/compose/compose.js +0 -32
  64. package/legacy/compose/index.js +0 -3
  65. package/legacy/createBox/createBox.js +0 -38
  66. package/legacy/createBox/index.js +0 -3
  67. package/legacy/createStyled/createStyled.js +0 -250
  68. package/legacy/createStyled/index.js +0 -4
  69. package/legacy/createTheme/applyStyles.js +0 -73
  70. package/legacy/createTheme/createBreakpoints.js +0 -83
  71. package/legacy/createTheme/createSpacing.js +0 -32
  72. package/legacy/createTheme/createTheme.js +0 -49
  73. package/legacy/createTheme/index.js +0 -3
  74. package/legacy/createTheme/shape.js +0 -4
  75. package/legacy/cssGrid/cssGrid.js +0 -91
  76. package/legacy/cssGrid/index.js +0 -4
  77. package/legacy/cssVars/createCssVarsProvider.js +0 -338
  78. package/legacy/cssVars/createCssVarsTheme.js +0 -13
  79. package/legacy/cssVars/createGetCssVar.js +0 -30
  80. package/legacy/cssVars/cssVarsParser.js +0 -141
  81. package/legacy/cssVars/getInitColorSchemeScript.js +0 -28
  82. package/legacy/cssVars/index.js +0 -6
  83. package/legacy/cssVars/prepareCssVars.js +0 -92
  84. package/legacy/cssVars/useCurrentColorScheme.js +0 -237
  85. package/legacy/display/display.js +0 -29
  86. package/legacy/display/index.js +0 -4
  87. package/legacy/flexbox/flexbox.js +0 -43
  88. package/legacy/flexbox/index.js +0 -4
  89. package/legacy/getThemeValue/getThemeValue.js +0 -47
  90. package/legacy/getThemeValue/index.js +0 -4
  91. package/legacy/index.js +0 -72
  92. package/legacy/memoize/index.js +0 -3
  93. package/legacy/memoize/memoize.js +0 -9
  94. package/legacy/merge/index.js +0 -3
  95. package/legacy/merge/merge.js +0 -10
  96. package/legacy/palette/index.js +0 -4
  97. package/legacy/palette/palette.js +0 -26
  98. package/legacy/positions/index.js +0 -4
  99. package/legacy/positions/positions.js +0 -22
  100. package/legacy/propsToClassKey/index.js +0 -3
  101. package/legacy/propsToClassKey/propsToClassKey.js +0 -24
  102. package/legacy/responsivePropType/index.js +0 -3
  103. package/legacy/responsivePropType/responsivePropType.js +0 -3
  104. package/legacy/shadows/index.js +0 -3
  105. package/legacy/shadows/shadows.js +0 -6
  106. package/legacy/sizing/index.js +0 -4
  107. package/legacy/sizing/sizing.js +0 -65
  108. package/legacy/spacing/index.js +0 -4
  109. package/legacy/spacing/spacing.js +0 -161
  110. package/legacy/style/index.js +0 -4
  111. package/legacy/style/style.js +0 -73
  112. package/legacy/styleFunctionSx/defaultSxConfig.js +0 -293
  113. package/legacy/styleFunctionSx/extendSxProp.js +0 -45
  114. package/legacy/styleFunctionSx/index.js +0 -4
  115. package/legacy/styleFunctionSx/styleFunctionSx.js +0 -126
  116. package/legacy/styled/index.js +0 -3
  117. package/legacy/styled/styled.js +0 -3
  118. package/legacy/typography/index.js +0 -4
  119. package/legacy/typography/typography.js +0 -37
  120. package/legacy/useMediaQuery/index.js +0 -2
  121. package/legacy/useMediaQuery/useMediaQuery.js +0 -145
  122. package/legacy/useTheme/index.js +0 -4
  123. package/legacy/useTheme/useTheme.js +0 -10
  124. package/legacy/useThemeProps/getThemeProps.js +0 -10
  125. package/legacy/useThemeProps/index.js +0 -4
  126. package/legacy/useThemeProps/useThemeProps.js +0 -20
  127. package/legacy/useThemeWithoutDefault/index.js +0 -3
  128. package/legacy/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v6.0.0-alpha.3
4
+
5
+ <!-- generated comparing v6.0.0-alpha.2..next -->
6
+
7
+ _Apr 17, 2024_
8
+
9
+ A big thanks to the 24 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 🔥 Converted 5 more Material UI components to use Pigment CSS.
12
+ - 🚀 Added container queries utility to the `@mui/system` package (#41674) @siriwatknp.
13
+
14
+ ### `@mui/material@6.0.0-alpha.3`
15
+
16
+ - Convert `LinearProgress` to support Pigment CSS (#41816) @siriwatknp
17
+ - [Dialog] Prevent onClick on the root element from being overwritten (#41881) @ryanburr
18
+ - [FloatingActionButton] Convert to support CSS extraction (#41851) @gijsbotje
19
+ - Convert `CircularProgress` to support Pigment CSS (#41776) @siriwatknp
20
+ - [PaginationItem] Convert to support CSS extraction (#41848) @gijsbotje
21
+ - [StepConnector] deprecate composed classes (#41740) @sai6855
22
+ - [StepLabel] Deprecate `StepIconComponent`, `StepIconProps` (#41835) @sai6855
23
+ - [ToggleButton] Convert to support CSS extraction (#41782) @lhilgert9
24
+ - [ToggleButtonGroup] Deprecate composed classes (#41288) @sai6855
25
+ - [Typography] Fix Typography inherit variant styles (#41308) @kealjones-wk
26
+
27
+ ### `@mui/system@6.0.0-alpha.3`
28
+
29
+ - Add container queries utility (#41674) @siriwatknp
30
+
31
+ ### `@mui/codemod@6.0.0-alpha.3`
32
+
33
+ - Add styled v6 transformation (#41743) @siriwatknp
34
+
35
+ ### `@mui/joy@5.0.0-beta.36`
36
+
37
+ - [Button] Disable text highlighting (#41902) @mithun522
38
+
39
+ ### `@pigment-css/react@0.0.7`
40
+
41
+ - Patch WyW's WeakRef usage (#41909) @DiegoAndai
42
+ - Implement sx transform for system components (#41861) @brijeshb42
43
+
44
+ ### Docs
45
+
46
+ - [material-ui] Add Connect-related content (#40848) @danilo-leal
47
+ - [material-ui] Fix credit comment typo (#41872) @aarongarciah
48
+ - [material-ui] Remove Data Grid v7 beta callout (#41839) @cherniavskii
49
+ - [material-ui] Add stray design tweaks to free templates (#41696) @zanivan
50
+ - [material-ui] Simplify components styling on templates (#41845) @zanivan
51
+ - [material-ui][Button] Add `onChange` event handler to file upload example (#41863) @aarongarciah
52
+ - [material-ui] Fix import statement in migration guide (#41852) @sai6855
53
+ - Fix 301 redirection @oliviertassinari
54
+ - Fix format git diff regression (#41882) @oliviertassinari
55
+ - Fix small SEO issues @oliviertassinari
56
+ - [pigment-css] Fix README typos (#41870) @MohammadShehadeh
57
+
58
+ ### Core
59
+
60
+ - Begin removing IE 11-related code (#41709) @iammminzzy
61
+ - [blog] Add post to introduce the Connect plugin (#41763) @danilo-leal
62
+ - [code-infra] Fix require.context with aliases (#41682) @Janpot
63
+ - [code-infra] Allow customizing hooks imports in API docs generator (#41828) @michaldudak
64
+ - [codemod] Add utils for `*Component` and `*Props` props deprecations (#41685) @DiegoAndai
65
+ - Replace bundle size reporter filter (#38979) @Janpot
66
+ - [docs-infra] Make the whole header clickable (#39603) @MoazMirza-13
67
+ - [docs-infra] Improve demo container and related components design (#41827) @danilo-leal
68
+ - [docs-infra] Use edge function for card generation (#41188) (#41836) @alexfauquette
69
+ - [docs-infra] Fix code block layout shift (#41917) @oliviertassinari
70
+ - [docs-infra] Fine-tune the OG card image design (#41862) @danilo-leal
71
+ - [docs-infra] Fix markdown version for material (#41908) @alexfauquette
72
+ - [docs-infra] Support multiple tabs in demos (#40901) @bharatkashyap
73
+
74
+ All contributors of this release in alphabetical order: @aarongarciah, @alexfauquette, @bharatkashyap, @brijeshb42, @cherniavskii, @danilo-leal, @DiegoAndai, @EyaOuenniche, @gijsbotje, @iammminzzy, @Janpot, @kealjones-wk, @lhilgert9, @magnimarels, @michaldudak, @mithun522, @mnajdova, @MoazMirza-13, @MohammadShehadeh, @oliviertassinari, @ryanburr, @sai6855, @siriwatknp, @zanivan
75
+
76
+ ## v6.0.0-alpha.2
77
+
78
+ <!-- generated comparing v6.0.0-alpha.1..next -->
79
+
80
+ _Apr 9, 2024_
81
+
82
+ A big thanks to the 5 contributors who made this release possible.
83
+ This release was mostly about 🐛 bug fixes and 📚 documentation improvements.
84
+
85
+ ### `@mui/material@6.0.0-alpha.2`
86
+
87
+ - &#8203;<!-- 03 -->[typescript][Select] Fix `muiName` property TypeScript error (#41726) @EyaOuenniche
88
+ - &#8203;<!-- 04 -->[l10n] Fix typo in is-IS locale (#41810) @magnimarels
89
+
90
+ ### `@pigment-css/react@0.0.6`
91
+
92
+ - &#8203;<!-- 12 -->[core] Remove `muiName` during eval phase (#41811) @brijeshb42
93
+
94
+ ### `@pigment-css/nextjs-plugin@0.0.6`
95
+
96
+ - &#8203;<!-- 02 -->[nextjs] Handle file references passed through imports (#41817) @brijeshb42
97
+ - &#8203;<!-- 01 -->[nextjs] Allow usage of url() CSS function (#41758) @brijeshb42
98
+
99
+ ### Docs
100
+
101
+ - &#8203;<!-- 11 -->[docs] Fix 301 links @oliviertassinari
102
+ - &#8203;<!-- 06 -->[pigment-css][docs] Fix README typo (#41808) @aarongarciah
103
+ - &#8203;<!-- 05 -->[pigment-css][docs] Fix output on dynamic styles example (#41805) @aarongarciah
104
+ - &#8203;<!-- 07 -->[material-ui][docs] Fix Material 3 message typo (#41821) @aarongarciah
105
+ - &#8203;<!-- 08 -->[material-ui][docs] Add stray design tweaks to free templates (#41696) @zanivan
106
+
107
+ ### Core
108
+
109
+ - &#8203;<!-- 13 -->[core] Remove unused files (#41818) @mnajdova
110
+ - &#8203;<!-- 10 -->[docs-infra] Fix analytics about inline ads (#41474) (#41819) @alexfauquette
111
+ - &#8203;<!-- 08 -->[docs-infra] Fix drawer performances (#41807) @alexfauquette
112
+
113
+ All contributors of this release in alphabetical order: @aarongarciah, @alexfauquette, @brijeshb42, @EyaOuenniche, @oliviertassinari
114
+
3
115
  ## v6.0.0-alpha.1
4
116
 
5
117
  <!-- generated comparing v6.0.0-alpha.0..next -->
@@ -8128,7 +8240,7 @@ A big thanks to the 25 contributors who made this release possible. Here are som
8128
8240
 
8129
8241
  <a href="https://mui.com/components/tables/#unstyled-table"><img width="800" alt="unstyled table" src="https://user-images.githubusercontent.com/4512430/144862194-584356ef-7d9d-462c-a631-186a7e716193.png"></a>
8130
8242
 
8131
- You can follow our progress with unstyled components at https://github.com/mui/material-ui/issues/27170.
8243
+ You can follow our progress with unstyled components at https://github.com/mui/base-ui/issues/10.
8132
8244
 
8133
8245
  - 🎉 We have added an example of how to use MUI with [Remix](https://remix.run/) (#29952) @mnajdova
8134
8246
 
@@ -9598,7 +9710,7 @@ A big thanks to the 17 contributors who made this release possible. Here are som
9598
9710
 
9599
9711
  <a href="https://mui.com/components/switches/#unstyled"><img width="832" alt="switch" src="https://user-images.githubusercontent.com/3165635/125192249-236f8a80-e247-11eb-9df9-17d476379a32.png"></a>
9600
9712
 
9601
- You can follow our progress at https://github.com/mui/material-ui/issues/27170.
9713
+ You can follow our progress at https://github.com/mui/base-ui/issues/10.
9602
9714
 
9603
9715
  - 💄 We have updated the default `info` `success` `warning` color to be more accessible (#26817) @siriwatknp.
9604
9716
  You can find the new [default values](https://mui.com/material-ui/customization/palette/#default-values) in the documentation.
@@ -9,5 +9,5 @@
9
9
  *
10
10
  * - [Container API](https://mui.com/system/api/container/)
11
11
  */
12
- declare const Container: import("@mui/types").OverridableComponent<import("@mui/system").ContainerTypeMap<{}, "div">>;
12
+ declare const Container: import("@mui/types").OverridableComponent<import("./ContainerProps").ContainerTypeMap<{}, "div">>;
13
13
  export default Container;
package/Stack/Stack.d.ts CHANGED
@@ -10,5 +10,5 @@
10
10
  *
11
11
  * - [Stack API](https://mui.com/system/api/stack/)
12
12
  */
13
- declare const Stack: import("@mui/types").OverridableComponent<import("@mui/system").StackTypeMap<{}, "div">>;
13
+ declare const Stack: import("@mui/types").OverridableComponent<import("./StackProps").StackTypeMap<{}, "div">>;
14
14
  export default Stack;
@@ -10,7 +10,7 @@ interface StyleFunctionProps {
10
10
  };
11
11
  ownerState: StackOwnerState;
12
12
  }
13
- declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("@mui/system/createStyled/createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
13
+ declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
14
14
  declare function useThemePropsDefault<T extends {}>(props: T): T;
15
15
  export declare const style: ({ ownerState, theme }: StyleFunctionProps) => any;
16
16
  export default function createStack(options?: {
@@ -9,5 +9,5 @@
9
9
  *
10
10
  * - [Grid API](https://mui.com/system/api/grid/)
11
11
  */
12
- declare const Grid: import("@mui/types").OverridableComponent<import("@mui/system").GridTypeMap<{}, "div">>;
12
+ declare const Grid: import("@mui/types").OverridableComponent<import("./GridProps").GridTypeMap<{}, "div">>;
13
13
  export default Grid;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { OverridableComponent } from '@mui/types';
3
3
  import { GridTypeMap } from './GridProps';
4
- declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("@mui/system/createStyled/createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
4
+ declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
5
5
  declare function useThemePropsDefault<T extends {}>(props: T): T;
6
6
  export default function createGrid(options?: {
7
7
  createStyledComponent?: typeof defaultCreateStyledComponent;
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import PropTypes from 'prop-types';
3
3
  import deepmerge from '@mui/utils/deepmerge';
4
4
  import merge from '../merge';
5
+ import { isCqShorthand, getContainerQuery } from '../cssContainerQueries';
5
6
 
6
7
  // The breakpoint **start** at this value.
7
8
  // For instance with the first breakpoint xs: [xs, sm[.
@@ -22,6 +23,17 @@ const defaultBreakpoints = {
22
23
  keys: ['xs', 'sm', 'md', 'lg', 'xl'],
23
24
  up: key => `@media (min-width:${values[key]}px)`
24
25
  };
26
+ const defaultContainerQueries = {
27
+ containerQueries: containerName => ({
28
+ up: key => {
29
+ let result = typeof key === 'number' ? key : values[key] || key;
30
+ if (typeof result === 'number') {
31
+ result = `${result}px`;
32
+ }
33
+ return containerName ? `@container ${containerName} (min-width:${result})` : `@container (min-width:${result})`;
34
+ }
35
+ })
36
+ };
25
37
  export function handleBreakpoints(props, propValue, styleFromPropValue) {
26
38
  const theme = props.theme || {};
27
39
  if (Array.isArray(propValue)) {
@@ -34,8 +46,14 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
34
46
  if (typeof propValue === 'object') {
35
47
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
36
48
  return Object.keys(propValue).reduce((acc, breakpoint) => {
49
+ if (isCqShorthand(themeBreakpoints.keys, breakpoint)) {
50
+ const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
51
+ if (containerKey) {
52
+ acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
53
+ }
54
+ }
37
55
  // key is breakpoint
38
- if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
56
+ else if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
39
57
  const mediaKey = themeBreakpoints.up(breakpoint);
40
58
  acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
41
59
  } else {
@@ -4,6 +4,7 @@ import { Shape, ShapeOptions } from './shape';
4
4
  import { Spacing, SpacingOptions } from './createSpacing';
5
5
  import { SxConfig, SxProps } from '../styleFunctionSx';
6
6
  import { ApplyStyles } from './applyStyles';
7
+ import { CssContainerQueries } from '../cssContainerQueries';
7
8
 
8
9
  export { Breakpoint, BreakpointOverrides } from './createBreakpoints';
9
10
 
@@ -24,7 +25,7 @@ export interface ThemeOptions {
24
25
  unstable_sxConfig?: SxConfig;
25
26
  }
26
27
 
27
- export interface Theme {
28
+ export interface Theme extends CssContainerQueries {
28
29
  shape: Shape;
29
30
  breakpoints: Breakpoints;
30
31
  direction: Direction;
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["breakpoints", "palette", "spacing", "shape"];
4
4
  import deepmerge from '@mui/utils/deepmerge';
5
5
  import createBreakpoints from './createBreakpoints';
6
+ import cssContainerQueries from '../cssContainerQueries';
6
7
  import shape from './shape';
7
8
  import createSpacing from './createSpacing';
8
9
  import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
@@ -29,6 +30,7 @@ function createTheme(options = {}, ...args) {
29
30
  spacing,
30
31
  shape: _extends({}, shape, shapeInput)
31
32
  }, other);
33
+ muiTheme = cssContainerQueries(muiTheme);
32
34
  muiTheme.applyStyles = applyStyles;
33
35
  muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
34
36
  muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
@@ -0,0 +1,24 @@
1
+ import { Breakpoints } from '../createTheme/createBreakpoints';
2
+ interface ContainerQueries {
3
+ up: Breakpoints['up'];
4
+ down: Breakpoints['down'];
5
+ between: Breakpoints['between'];
6
+ only: Breakpoints['only'];
7
+ not: Breakpoints['not'];
8
+ }
9
+ export interface CssContainerQueries {
10
+ containerQueries: ((name: string) => ContainerQueries) & ContainerQueries;
11
+ }
12
+ /**
13
+ * For using in `sx` prop to sort the breakpoint from low to high.
14
+ * Note: this function does not work and will not support multiple units.
15
+ * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
16
+ * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 eventhough 40rem > 300px
17
+ */
18
+ export declare function sortContainerQueries(theme: Partial<CssContainerQueries>, css: Record<string, any>): Record<string, any>;
19
+ export declare function isCqShorthand(breakpointKeys: string[], value: string): boolean;
20
+ export declare function getContainerQuery(theme: CssContainerQueries, shorthand: string): string | null;
21
+ export default function cssContainerQueries<T extends {
22
+ breakpoints: Breakpoints;
23
+ }>(themeInput: T): T & CssContainerQueries;
24
+ export {};
@@ -0,0 +1,68 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
3
+ /**
4
+ * For using in `sx` prop to sort the breakpoint from low to high.
5
+ * Note: this function does not work and will not support multiple units.
6
+ * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
7
+ * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 eventhough 40rem > 300px
8
+ */
9
+ export function sortContainerQueries(theme, css) {
10
+ if (!theme.containerQueries) {
11
+ return css;
12
+ }
13
+ const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
14
+ const regex = /min-width:\s*([0-9.]+)/;
15
+ return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
16
+ });
17
+ if (!sorted.length) {
18
+ return css;
19
+ }
20
+ return sorted.reduce((acc, key) => {
21
+ const value = css[key];
22
+ delete acc[key];
23
+ acc[key] = value;
24
+ return acc;
25
+ }, _extends({}, css));
26
+ }
27
+ export function isCqShorthand(breakpointKeys, value) {
28
+ return value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
29
+ }
30
+ export function getContainerQuery(theme, shorthand) {
31
+ const matches = shorthand.match(/^@([^/]+)\/?(.+)?$/);
32
+ if (!matches) {
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The provided shorthand ${`(${shorthand})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
35
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.` : _formatMuiErrorMessage(21, `(${shorthand})`));
36
+ }
37
+ return null;
38
+ }
39
+ const [, containerQuery, containerName] = matches;
40
+ const value = Number.isNaN(+containerQuery) ? containerQuery : +containerQuery;
41
+ return theme.containerQueries(containerName).up(value);
42
+ }
43
+ export default function cssContainerQueries(themeInput) {
44
+ const toContainerQuery = (mediaQuery, name) => mediaQuery.replace('@media', name ? `@container ${name}` : '@container');
45
+ function attachCq(node, name) {
46
+ node.up = (...args) => toContainerQuery(themeInput.breakpoints.up(...args), name);
47
+ node.down = (...args) => toContainerQuery(themeInput.breakpoints.down(...args), name);
48
+ node.between = (...args) => toContainerQuery(themeInput.breakpoints.between(...args), name);
49
+ node.only = (...args) => toContainerQuery(themeInput.breakpoints.only(...args), name);
50
+ node.not = (...args) => {
51
+ const result = toContainerQuery(themeInput.breakpoints.not(...args), name);
52
+ if (result.includes('not all and')) {
53
+ // `@container` does not work with `not all and`, so need to invert the logic
54
+ return result.replace('not all and ', '').replace('min-width:', 'width<').replace('max-width:', 'width>');
55
+ }
56
+ return result;
57
+ };
58
+ }
59
+ const node = {};
60
+ const containerQueries = name => {
61
+ attachCq(node, name);
62
+ return node;
63
+ };
64
+ attachCq(containerQueries);
65
+ return _extends({}, themeInput, {
66
+ containerQueries
67
+ });
68
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from './cssContainerQueries';
2
+ export { isCqShorthand, getContainerQuery, sortContainerQueries } from './cssContainerQueries';
3
+ export type { CssContainerQueries } from './cssContainerQueries';
@@ -0,0 +1,2 @@
1
+ export { default } from './cssContainerQueries';
2
+ export { isCqShorthand, getContainerQuery, sortContainerQueries } from './cssContainerQueries';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/cssContainerQueries/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -30,7 +30,7 @@ export declare const assignNestedKeys: <T extends string | Record<string, any> |
30
30
  * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
31
  * // ['palette', 'primary', 'main'] '#000000'
32
32
  */
33
- export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
33
+ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: (keys: Array<string>) => boolean) => void;
34
34
  /**
35
35
  * a function that parse theme and return { css, vars }
36
36
  *
package/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export * from './borders';
5
5
 
6
6
  export { default as breakpoints, handleBreakpoints, mergeBreakpointsInOrder } from './breakpoints';
7
7
 
8
+ export { default as cssContainerQueries, type CssContainerQueries } from './cssContainerQueries';
9
+
8
10
  export { default as compose } from './compose';
9
11
 
10
12
  export * from './display';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.1
2
+ * @mui/system v6.0.0-alpha.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,6 +11,7 @@ export { default as GlobalStyles } from './GlobalStyles';
11
11
  export { default as borders } from './borders';
12
12
  export * from './borders';
13
13
  export { default as breakpoints } from './breakpoints';
14
+ export { default as cssContainerQueries } from './cssContainerQueries';
14
15
  export { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues as unstable_resolveBreakpointValues } from './breakpoints';
15
16
  export { default as compose } from './compose';
16
17
  export { default as display } from './display';
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import PropTypes from 'prop-types';
3
3
  import deepmerge from '@mui/utils/deepmerge';
4
4
  import merge from '../merge';
5
+ import { isCqShorthand, getContainerQuery } from '../cssContainerQueries';
5
6
 
6
7
  // The breakpoint **start** at this value.
7
8
  // For instance with the first breakpoint xs: [xs, sm[.
@@ -22,6 +23,17 @@ const defaultBreakpoints = {
22
23
  keys: ['xs', 'sm', 'md', 'lg', 'xl'],
23
24
  up: key => `@media (min-width:${values[key]}px)`
24
25
  };
26
+ const defaultContainerQueries = {
27
+ containerQueries: containerName => ({
28
+ up: key => {
29
+ let result = typeof key === 'number' ? key : values[key] || key;
30
+ if (typeof result === 'number') {
31
+ result = `${result}px`;
32
+ }
33
+ return containerName ? `@container ${containerName} (min-width:${result})` : `@container (min-width:${result})`;
34
+ }
35
+ })
36
+ };
25
37
  export function handleBreakpoints(props, propValue, styleFromPropValue) {
26
38
  const theme = props.theme || {};
27
39
  if (Array.isArray(propValue)) {
@@ -34,8 +46,14 @@ export function handleBreakpoints(props, propValue, styleFromPropValue) {
34
46
  if (typeof propValue === 'object') {
35
47
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
36
48
  return Object.keys(propValue).reduce((acc, breakpoint) => {
49
+ if (isCqShorthand(themeBreakpoints.keys, breakpoint)) {
50
+ const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
51
+ if (containerKey) {
52
+ acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
53
+ }
54
+ }
37
55
  // key is breakpoint
38
- if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
56
+ else if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
39
57
  const mediaKey = themeBreakpoints.up(breakpoint);
40
58
  acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
41
59
  } else {
@@ -3,6 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["breakpoints", "palette", "spacing", "shape"];
4
4
  import deepmerge from '@mui/utils/deepmerge';
5
5
  import createBreakpoints from './createBreakpoints';
6
+ import cssContainerQueries from '../cssContainerQueries';
6
7
  import shape from './shape';
7
8
  import createSpacing from './createSpacing';
8
9
  import styleFunctionSx from '../styleFunctionSx/styleFunctionSx';
@@ -29,6 +30,7 @@ function createTheme(options = {}, ...args) {
29
30
  spacing,
30
31
  shape: _extends({}, shape, shapeInput)
31
32
  }, other);
33
+ muiTheme = cssContainerQueries(muiTheme);
32
34
  muiTheme.applyStyles = applyStyles;
33
35
  muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme);
34
36
  muiTheme.unstable_sxConfig = _extends({}, defaultSxConfig, other?.unstable_sxConfig);
@@ -0,0 +1,68 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _formatMuiErrorMessage from "@mui/utils/formatMuiErrorMessage";
3
+ /**
4
+ * For using in `sx` prop to sort the breakpoint from low to high.
5
+ * Note: this function does not work and will not support multiple units.
6
+ * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
7
+ * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 eventhough 40rem > 300px
8
+ */
9
+ export function sortContainerQueries(theme, css) {
10
+ if (!theme.containerQueries) {
11
+ return css;
12
+ }
13
+ const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
14
+ const regex = /min-width:\s*([0-9.]+)/;
15
+ return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
16
+ });
17
+ if (!sorted.length) {
18
+ return css;
19
+ }
20
+ return sorted.reduce((acc, key) => {
21
+ const value = css[key];
22
+ delete acc[key];
23
+ acc[key] = value;
24
+ return acc;
25
+ }, _extends({}, css));
26
+ }
27
+ export function isCqShorthand(breakpointKeys, value) {
28
+ return value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
29
+ }
30
+ export function getContainerQuery(theme, shorthand) {
31
+ const matches = shorthand.match(/^@([^/]+)\/?(.+)?$/);
32
+ if (!matches) {
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The provided shorthand ${`(${shorthand})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
35
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.` : _formatMuiErrorMessage(21, `(${shorthand})`));
36
+ }
37
+ return null;
38
+ }
39
+ const [, containerQuery, containerName] = matches;
40
+ const value = Number.isNaN(+containerQuery) ? containerQuery : +containerQuery;
41
+ return theme.containerQueries(containerName).up(value);
42
+ }
43
+ export default function cssContainerQueries(themeInput) {
44
+ const toContainerQuery = (mediaQuery, name) => mediaQuery.replace('@media', name ? `@container ${name}` : '@container');
45
+ function attachCq(node, name) {
46
+ node.up = (...args) => toContainerQuery(themeInput.breakpoints.up(...args), name);
47
+ node.down = (...args) => toContainerQuery(themeInput.breakpoints.down(...args), name);
48
+ node.between = (...args) => toContainerQuery(themeInput.breakpoints.between(...args), name);
49
+ node.only = (...args) => toContainerQuery(themeInput.breakpoints.only(...args), name);
50
+ node.not = (...args) => {
51
+ const result = toContainerQuery(themeInput.breakpoints.not(...args), name);
52
+ if (result.includes('not all and')) {
53
+ // `@container` does not work with `not all and`, so need to invert the logic
54
+ return result.replace('not all and ', '').replace('min-width:', 'width<').replace('max-width:', 'width>');
55
+ }
56
+ return result;
57
+ };
58
+ }
59
+ const node = {};
60
+ const containerQueries = name => {
61
+ attachCq(node, name);
62
+ return node;
63
+ };
64
+ attachCq(containerQueries);
65
+ return _extends({}, themeInput, {
66
+ containerQueries
67
+ });
68
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './cssContainerQueries';
2
+ export { isCqShorthand, getContainerQuery, sortContainerQueries } from './cssContainerQueries';
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.1
2
+ * @mui/system v6.0.0-alpha.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -11,6 +11,7 @@ export { default as GlobalStyles } from './GlobalStyles';
11
11
  export { default as borders } from './borders';
12
12
  export * from './borders';
13
13
  export { default as breakpoints } from './breakpoints';
14
+ export { default as cssContainerQueries } from './cssContainerQueries';
14
15
  export { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues as unstable_resolveBreakpointValues } from './breakpoints';
15
16
  export { default as compose } from './compose';
16
17
  export { default as display } from './display';
@@ -2,6 +2,7 @@ import capitalize from '@mui/utils/capitalize';
2
2
  import merge from '../merge';
3
3
  import { getPath, getStyleValue as getValue } from '../style';
4
4
  import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
5
+ import { sortContainerQueries } from '../cssContainerQueries';
5
6
  import defaultSxConfig from './defaultSxConfig';
6
7
  function objectsHaveSameKeys(...objects) {
7
8
  const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
@@ -115,7 +116,7 @@ export function unstable_createStyleFunctionSx() {
115
116
  }
116
117
  }
117
118
  });
118
- return removeUnusedBreakpoints(breakpointsKeys, css);
119
+ return sortContainerQueries(theme, removeUnusedBreakpoints(breakpointsKeys, css));
119
120
  }
120
121
  return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
121
122
  }
@@ -16,6 +16,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
16
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
  var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
18
18
  var _merge = _interopRequireDefault(require("../merge"));
19
+ var _cssContainerQueries = require("../cssContainerQueries");
19
20
  // The breakpoint **start** at this value.
20
21
  // For instance with the first breakpoint xs: [xs, sm[.
21
22
  const values = exports.values = {
@@ -35,6 +36,17 @@ const defaultBreakpoints = {
35
36
  keys: ['xs', 'sm', 'md', 'lg', 'xl'],
36
37
  up: key => `@media (min-width:${values[key]}px)`
37
38
  };
39
+ const defaultContainerQueries = {
40
+ containerQueries: containerName => ({
41
+ up: key => {
42
+ let result = typeof key === 'number' ? key : values[key] || key;
43
+ if (typeof result === 'number') {
44
+ result = `${result}px`;
45
+ }
46
+ return containerName ? `@container ${containerName} (min-width:${result})` : `@container (min-width:${result})`;
47
+ }
48
+ })
49
+ };
38
50
  function handleBreakpoints(props, propValue, styleFromPropValue) {
39
51
  const theme = props.theme || {};
40
52
  if (Array.isArray(propValue)) {
@@ -47,8 +59,14 @@ function handleBreakpoints(props, propValue, styleFromPropValue) {
47
59
  if (typeof propValue === 'object') {
48
60
  const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
49
61
  return Object.keys(propValue).reduce((acc, breakpoint) => {
62
+ if ((0, _cssContainerQueries.isCqShorthand)(themeBreakpoints.keys, breakpoint)) {
63
+ const containerKey = (0, _cssContainerQueries.getContainerQuery)(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
64
+ if (containerKey) {
65
+ acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
66
+ }
67
+ }
50
68
  // key is breakpoint
51
- if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
69
+ else if (Object.keys(themeBreakpoints.values || values).indexOf(breakpoint) !== -1) {
52
70
  const mediaKey = themeBreakpoints.up(breakpoint);
53
71
  acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
54
72
  } else {
@@ -9,6 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
11
11
  var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
12
+ var _cssContainerQueries = _interopRequireDefault(require("../cssContainerQueries"));
12
13
  var _shape = _interopRequireDefault(require("./shape"));
13
14
  var _createSpacing = _interopRequireDefault(require("./createSpacing"));
14
15
  var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx/styleFunctionSx"));
@@ -36,6 +37,7 @@ function createTheme(options = {}, ...args) {
36
37
  spacing,
37
38
  shape: (0, _extends2.default)({}, _shape.default, shapeInput)
38
39
  }, other);
40
+ muiTheme = (0, _cssContainerQueries.default)(muiTheme);
39
41
  muiTheme.applyStyles = _applyStyles.default;
40
42
  muiTheme = args.reduce((acc, argument) => (0, _deepmerge.default)(acc, argument), muiTheme);
41
43
  muiTheme.unstable_sxConfig = (0, _extends2.default)({}, _defaultSxConfig.default, other == null ? void 0 : other.unstable_sxConfig);