@mui/system 6.0.0-alpha.9 → 6.0.0-beta.1

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 (65) hide show
  1. package/CHANGELOG.md +363 -3
  2. package/Container/createContainer.js +0 -2
  3. package/DefaultPropsProvider/DefaultPropsProvider.d.ts +12 -0
  4. package/DefaultPropsProvider/DefaultPropsProvider.js +64 -0
  5. package/DefaultPropsProvider/index.d.ts +1 -0
  6. package/DefaultPropsProvider/index.js +1 -0
  7. package/DefaultPropsProvider/package.json +6 -0
  8. package/{cssVars/getInitColorSchemeScript.d.ts → InitColorSchemeScript/InitColorSchemeScript.d.ts} +9 -2
  9. package/{cssVars/getInitColorSchemeScript.js → InitColorSchemeScript/InitColorSchemeScript.js} +9 -2
  10. package/InitColorSchemeScript/index.d.ts +2 -0
  11. package/InitColorSchemeScript/index.js +1 -0
  12. package/InitColorSchemeScript/package.json +6 -0
  13. package/ThemeProvider/ThemeProvider.js +5 -1
  14. package/Unstable_Grid/Grid.js +5 -81
  15. package/Unstable_Grid/GridProps.d.ts +12 -97
  16. package/Unstable_Grid/createGrid.js +36 -55
  17. package/Unstable_Grid/gridClasses.js +1 -1
  18. package/Unstable_Grid/gridGenerator.d.ts +3 -10
  19. package/Unstable_Grid/gridGenerator.js +10 -19
  20. package/createTheme/createTheme.d.ts +1 -1
  21. package/cssContainerQueries/cssContainerQueries.js +4 -4
  22. package/cssVars/createCssVarsProvider.d.ts +2 -2
  23. package/cssVars/createCssVarsProvider.js +2 -2
  24. package/cssVars/index.d.ts +0 -1
  25. package/cssVars/index.js +0 -1
  26. package/cssVars/prepareCssVars.js +2 -2
  27. package/cssVars/useCurrentColorScheme.js +1 -1
  28. package/index.js +1 -1
  29. package/modern/Container/createContainer.js +0 -2
  30. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +64 -0
  31. package/modern/DefaultPropsProvider/index.js +1 -0
  32. package/modern/{cssVars/getInitColorSchemeScript.js → InitColorSchemeScript/InitColorSchemeScript.js} +9 -2
  33. package/modern/InitColorSchemeScript/index.js +1 -0
  34. package/modern/ThemeProvider/ThemeProvider.js +5 -1
  35. package/modern/Unstable_Grid/Grid.js +5 -81
  36. package/modern/Unstable_Grid/createGrid.js +36 -55
  37. package/modern/Unstable_Grid/gridClasses.js +1 -1
  38. package/modern/Unstable_Grid/gridGenerator.js +10 -19
  39. package/modern/cssContainerQueries/cssContainerQueries.js +4 -4
  40. package/modern/cssVars/createCssVarsProvider.js +2 -2
  41. package/modern/cssVars/index.js +0 -1
  42. package/modern/cssVars/prepareCssVars.js +2 -2
  43. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  44. package/modern/index.js +1 -1
  45. package/modern/useMediaQuery/useMediaQuery.js +5 -27
  46. package/node/Container/createContainer.js +0 -2
  47. package/node/DefaultPropsProvider/DefaultPropsProvider.js +73 -0
  48. package/node/DefaultPropsProvider/index.js +20 -0
  49. package/node/{cssVars/getInitColorSchemeScript.js → InitColorSchemeScript/InitColorSchemeScript.js} +11 -3
  50. package/node/InitColorSchemeScript/index.js +13 -0
  51. package/node/ThemeProvider/ThemeProvider.js +5 -1
  52. package/node/Unstable_Grid/Grid.js +5 -81
  53. package/node/Unstable_Grid/createGrid.js +37 -56
  54. package/node/Unstable_Grid/gridClasses.js +1 -1
  55. package/node/Unstable_Grid/gridGenerator.js +10 -19
  56. package/node/cssContainerQueries/cssContainerQueries.js +4 -4
  57. package/node/cssVars/createCssVarsProvider.js +5 -5
  58. package/node/cssVars/index.js +0 -7
  59. package/node/cssVars/prepareCssVars.js +2 -2
  60. package/node/cssVars/useCurrentColorScheme.js +3 -3
  61. package/node/index.js +1 -1
  62. package/node/useMediaQuery/useMediaQuery.js +5 -26
  63. package/package.json +5 -5
  64. package/useMediaQuery/useMediaQuery.d.ts +0 -18
  65. package/useMediaQuery/useMediaQuery.js +5 -27
@@ -54,8 +54,6 @@ export default function createContainer(options = {}) {
54
54
  marginLeft: 'auto',
55
55
  boxSizing: 'border-box',
56
56
  marginRight: 'auto',
57
- display: 'block',
58
- // Fix IE11 layout when used with main.
59
57
  ...(!ownerState.disableGutters && {
60
58
  paddingLeft: theme.spacing(2),
61
59
  paddingRight: theme.spacing(2),
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import resolveProps from '@mui/utils/resolveProps';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const PropsContext = /*#__PURE__*/React.createContext(undefined);
8
+ function DefaultPropsProvider({
9
+ value,
10
+ children
11
+ }) {
12
+ return /*#__PURE__*/_jsx(PropsContext.Provider, {
13
+ value: value,
14
+ children: children
15
+ });
16
+ }
17
+ process.env.NODE_ENV !== "production" ? DefaultPropsProvider.propTypes /* remove-proptypes */ = {
18
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
19
+ // │ These PropTypes are generated from the TypeScript type definitions. │
20
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
21
+ // └─────────────────────────────────────────────────────────────────────┘
22
+ /**
23
+ * @ignore
24
+ */
25
+ children: PropTypes.node,
26
+ /**
27
+ * @ignore
28
+ */
29
+ value: PropTypes.object
30
+ } : void 0;
31
+ function getThemeProps(params) {
32
+ const {
33
+ theme,
34
+ name,
35
+ props
36
+ } = params;
37
+ if (!theme || !theme.components || !theme.components[name]) {
38
+ return props;
39
+ }
40
+ const config = theme.components[name];
41
+ if (config.defaultProps) {
42
+ // compatible with v5 signature
43
+ return resolveProps(config.defaultProps, props);
44
+ }
45
+ if (!config.styleOverrides && !config.variants) {
46
+ // v6 signature, no property 'defaultProps'
47
+ return resolveProps(config, props);
48
+ }
49
+ return props;
50
+ }
51
+ export function useDefaultProps({
52
+ props,
53
+ name
54
+ }) {
55
+ const ctx = React.useContext(PropsContext);
56
+ return getThemeProps({
57
+ props,
58
+ name,
59
+ theme: {
60
+ components: ctx
61
+ }
62
+ });
63
+ }
64
+ export default DefaultPropsProvider;
@@ -0,0 +1 @@
1
+ export { default, useDefaultProps } from './DefaultPropsProvider';
@@ -1,9 +1,12 @@
1
+ /**
2
+ * Split this component for RSC import
3
+ */
1
4
  import * as React from 'react';
2
5
  import { jsx as _jsx } from "react/jsx-runtime";
3
6
  export const DEFAULT_MODE_STORAGE_KEY = 'mode';
4
7
  export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
5
8
  export const DEFAULT_ATTRIBUTE = 'data-color-scheme';
6
- export default function getInitColorSchemeScript(options) {
9
+ export default function InitColorSchemeScript(options) {
7
10
  const {
8
11
  defaultMode = 'light',
9
12
  defaultLightColorScheme = 'light',
@@ -11,10 +14,14 @@ export default function getInitColorSchemeScript(options) {
11
14
  modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
12
15
  colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
13
16
  attribute = DEFAULT_ATTRIBUTE,
14
- colorSchemeNode = 'document.documentElement'
17
+ colorSchemeNode = 'document.documentElement',
18
+ nonce
15
19
  } = options || {};
16
20
  return /*#__PURE__*/_jsx("script", {
21
+ suppressHydrationWarning: true,
22
+ nonce: typeof window === 'undefined' ? nonce : ''
17
23
  // eslint-disable-next-line react/no-danger
24
+ ,
18
25
  dangerouslySetInnerHTML: {
19
26
  __html: `(function() {
20
27
  try {
@@ -0,0 +1 @@
1
+ export { default } from './InitColorSchemeScript';
@@ -7,6 +7,7 @@ import exactProp from '@mui/utils/exactProp';
7
7
  import { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';
8
8
  import useThemeWithoutDefault from '../useThemeWithoutDefault';
9
9
  import RtlProvider from '../RtlProvider';
10
+ import DefaultPropsProvider from '../DefaultPropsProvider';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  const EMPTY_THEME = {};
12
13
  function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
@@ -64,7 +65,10 @@ function ThemeProvider(props) {
64
65
  value: engineTheme,
65
66
  children: /*#__PURE__*/_jsx(RtlProvider, {
66
67
  value: rtlValue,
67
- children: children
68
+ children: /*#__PURE__*/_jsx(DefaultPropsProvider, {
69
+ value: engineTheme?.components,
70
+ children: children
71
+ })
68
72
  })
69
73
  })
70
74
  });
@@ -46,62 +46,18 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
46
46
  */
47
47
  direction: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
48
48
  /**
49
- * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
49
+ * Defines the offset value for the type `item` components.
50
50
  */
51
- disableEqualOverflow: PropTypes.bool,
52
- /**
53
- * If a number, it sets the number of columns the grid item uses.
54
- * It can't be greater than the total number of columns of the container (12 by default).
55
- * If 'auto', the grid item's width matches its content.
56
- * If false, the prop is ignored.
57
- * If true, the grid item's width grows to use the space available in the grid container.
58
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
59
- * @default false
60
- */
61
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
62
- /**
63
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
64
- * If 'auto', the grid item push itself to the right-end of the container.
65
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
66
- */
67
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
68
- /**
69
- * If a number, it sets the number of columns the grid item uses.
70
- * It can't be greater than the total number of columns of the container (12 by default).
71
- * If 'auto', the grid item's width matches its content.
72
- * If false, the prop is ignored.
73
- * If true, the grid item's width grows to use the space available in the grid container.
74
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
75
- * @default false
76
- */
77
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
78
- /**
79
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
80
- * If 'auto', the grid item push itself to the right-end of the container.
81
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
82
- */
83
- mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
51
+ offset: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.object]),
84
52
  /**
85
53
  * Defines the vertical space between the type `item` components.
86
54
  * It overrides the value of the `spacing` prop.
87
55
  */
88
56
  rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
89
57
  /**
90
- * If a number, it sets the number of columns the grid item uses.
91
- * It can't be greater than the total number of columns of the container (12 by default).
92
- * If 'auto', the grid item's width matches its content.
93
- * If false, the prop is ignored.
94
- * If true, the grid item's width grows to use the space available in the grid container.
95
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
96
- * @default false
58
+ * Defines the size of the the type `item` components.
97
59
  */
98
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
99
- /**
100
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
101
- * If 'auto', the grid item push itself to the right-end of the container.
102
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
103
- */
104
- smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
60
+ size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number])), PropTypes.object]),
105
61
  /**
106
62
  * Defines the space between the type `item` components.
107
63
  * It can only be used on a type `container` component.
@@ -140,38 +96,6 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
140
96
  * It's applied for all screen sizes.
141
97
  * @default 'wrap'
142
98
  */
143
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
144
- /**
145
- * If a number, it sets the number of columns the grid item uses.
146
- * It can't be greater than the total number of columns of the container (12 by default).
147
- * If 'auto', the grid item's width matches its content.
148
- * If false, the prop is ignored.
149
- * If true, the grid item's width grows to use the space available in the grid container.
150
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
151
- * @default false
152
- */
153
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
154
- /**
155
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
156
- * If 'auto', the grid item push itself to the right-end of the container.
157
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
158
- */
159
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
160
- /**
161
- * If a number, it sets the number of columns the grid item uses.
162
- * It can't be greater than the total number of columns of the container (12 by default).
163
- * If 'auto', the grid item's width matches its content.
164
- * If false, the prop is ignored.
165
- * If true, the grid item's width grows to use the space available in the grid container.
166
- * The value is applied for all the screen sizes with the lowest priority.
167
- * @default false
168
- */
169
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
170
- /**
171
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
172
- * If 'auto', the grid item push itself to the right-end of the container.
173
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
174
- */
175
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
99
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
176
100
  } : void 0;
177
101
  export default Grid;
@@ -33,29 +33,47 @@ export default function createGrid(options = {}) {
33
33
  useThemeProps = useThemePropsDefault,
34
34
  componentName = 'MuiGrid'
35
35
  } = options;
36
- const GridOverflowContext = /*#__PURE__*/React.createContext(undefined);
37
- if (process.env.NODE_ENV !== 'production') {
38
- GridOverflowContext.displayName = 'GridOverflowContext';
39
- }
40
36
  const useUtilityClasses = (ownerState, theme) => {
41
37
  const {
42
38
  container,
43
39
  direction,
44
40
  spacing,
45
41
  wrap,
46
- gridSize
42
+ size
47
43
  } = ownerState;
48
44
  const slots = {
49
- root: ['root', container && 'container', wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateDirectionClasses(direction), ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
45
+ root: ['root', container && 'container', wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateDirectionClasses(direction), ...generateSizeClassNames(size), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
50
46
  };
51
47
  return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
52
48
  };
49
+ function parseResponsiveProp(propValue, breakpoints, shouldUseValue = () => true) {
50
+ const parsedProp = {};
51
+ if (propValue === null) {
52
+ return parsedProp;
53
+ }
54
+ if (Array.isArray(propValue)) {
55
+ propValue.forEach((value, index) => {
56
+ if (value !== null && shouldUseValue(value) && breakpoints.keys[index]) {
57
+ parsedProp[breakpoints.keys[index]] = value;
58
+ }
59
+ });
60
+ } else if (typeof propValue === 'object') {
61
+ Object.keys(propValue).forEach(key => {
62
+ const value = propValue[key];
63
+ if (value !== null && value !== undefined && shouldUseValue(value)) {
64
+ parsedProp[key] = value;
65
+ }
66
+ });
67
+ } else {
68
+ parsedProp[breakpoints.keys[0]] = propValue;
69
+ }
70
+ return parsedProp;
71
+ }
53
72
  const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
54
73
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
55
74
  const theme = useTheme();
56
75
  const themeProps = useThemeProps(inProps);
57
76
  const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
58
- const overflow = React.useContext(GridOverflowContext);
59
77
  const {
60
78
  className,
61
79
  children,
@@ -64,31 +82,16 @@ export default function createGrid(options = {}) {
64
82
  component = 'div',
65
83
  direction = 'row',
66
84
  wrap = 'wrap',
85
+ size: sizeProp = {},
86
+ offset: offsetProp = {},
67
87
  spacing: spacingProp = 0,
68
88
  rowSpacing: rowSpacingProp = spacingProp,
69
89
  columnSpacing: columnSpacingProp = spacingProp,
70
- disableEqualOverflow: themeDisableEqualOverflow,
71
90
  unstable_level: level = 0,
72
- ...rest
91
+ ...other
73
92
  } = props;
74
- // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
75
- let disableEqualOverflow = themeDisableEqualOverflow;
76
- if (level && themeDisableEqualOverflow !== undefined) {
77
- disableEqualOverflow = inProps.disableEqualOverflow;
78
- }
79
- // collect breakpoints related props because they can be customized from the theme.
80
- const gridSize = {};
81
- const gridOffset = {};
82
- const other = {};
83
- Object.entries(rest).forEach(([key, val]) => {
84
- if (theme.breakpoints.values[key] !== undefined) {
85
- gridSize[key] = val;
86
- } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
87
- gridOffset[key.replace('Offset', '')] = val;
88
- } else {
89
- other[key] = val;
90
- }
91
- });
93
+ const size = parseResponsiveProp(sizeProp, theme.breakpoints, val => val !== false);
94
+ const offset = parseResponsiveProp(offsetProp, theme.breakpoints);
92
95
  const columns = inProps.columns ?? (level ? undefined : columnsProp);
93
96
  const spacing = inProps.spacing ?? (level ? undefined : spacingProp);
94
97
  const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (level ? undefined : rowSpacingProp);
@@ -103,14 +106,11 @@ export default function createGrid(options = {}) {
103
106
  spacing,
104
107
  rowSpacing,
105
108
  columnSpacing,
106
- gridSize,
107
- gridOffset,
108
- disableEqualOverflow: disableEqualOverflow ?? overflow ?? false,
109
- // use context value if exists.
110
- parentDisableEqualOverflow: overflow // for nested grid
109
+ size,
110
+ offset
111
111
  };
112
112
  const classes = useUtilityClasses(ownerState, theme);
113
- let result = /*#__PURE__*/_jsx(GridRoot, {
113
+ return /*#__PURE__*/_jsx(GridRoot, {
114
114
  ref: ref,
115
115
  as: component,
116
116
  ownerState: ownerState,
@@ -125,16 +125,6 @@ export default function createGrid(options = {}) {
125
125
  return child;
126
126
  })
127
127
  });
128
- if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow ?? false)) {
129
- // There are 2 possibilities that should wrap with the GridOverflowContext to communicate with the nested grids:
130
- // 1. It is the root grid with `disableEqualOverflow`.
131
- // 2. It is a nested grid with different `disableEqualOverflow` from the context.
132
- result = /*#__PURE__*/_jsx(GridOverflowContext.Provider, {
133
- value: disableEqualOverflow,
134
- children: result
135
- });
136
- }
137
- return result;
138
128
  });
139
129
  process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ = {
140
130
  children: PropTypes.node,
@@ -144,21 +134,12 @@ export default function createGrid(options = {}) {
144
134
  component: PropTypes.elementType,
145
135
  container: PropTypes.bool,
146
136
  direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
147
- disableEqualOverflow: PropTypes.bool,
148
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
149
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
150
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
151
- mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
137
+ offset: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.object]),
152
138
  rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
153
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
154
- smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
139
+ size: PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.bool, PropTypes.number])), PropTypes.object]),
155
140
  spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
156
141
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
157
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
158
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
159
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
160
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
161
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
142
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
162
143
  } : void 0;
163
144
 
164
145
  // @ts-ignore internal logic for nested grid
@@ -6,7 +6,7 @@ export function getGridUtilityClass(slot) {
6
6
  const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
7
7
  const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
8
8
  const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
9
- const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
9
+ const GRID_SIZES = ['auto', 'grow', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
10
10
  const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container', 'item',
11
11
  // spacings
12
12
  ...SPACINGS.map(spacing => `spacing-xs-${spacing}`),
@@ -31,11 +31,11 @@ export const generateGridSizeStyles = ({
31
31
  theme,
32
32
  ownerState
33
33
  }) => {
34
- const getSelfSpacing = createGetSelfSpacing(ownerState);
34
+ const getParentSpacing = createGetParentSpacing(ownerState);
35
35
  const styles = {};
36
- traverseBreakpoints(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
36
+ traverseBreakpoints(theme.breakpoints, ownerState.size, (appendStyle, value) => {
37
37
  let style = {};
38
- if (value === true) {
38
+ if (value === 'grow') {
39
39
  style = {
40
40
  flexBasis: 0,
41
41
  flexGrow: 1,
@@ -55,7 +55,7 @@ export const generateGridSizeStyles = ({
55
55
  style = {
56
56
  flexGrow: 0,
57
57
  flexBasis: 'auto',
58
- width: `calc(100% * ${value} / ${getParentColumns(ownerState)}${isNestedContainer(ownerState) ? ` + ${getSelfSpacing('column')}` : ''})`
58
+ width: `calc(100% * ${value} / ${getParentColumns(ownerState)} - (${getParentColumns(ownerState)} - ${value}) * (${getParentSpacing('column')} / ${getParentColumns(ownerState)}))`
59
59
  };
60
60
  }
61
61
  appendStyle(styles, style);
@@ -66,8 +66,9 @@ export const generateGridOffsetStyles = ({
66
66
  theme,
67
67
  ownerState
68
68
  }) => {
69
+ const getParentSpacing = createGetParentSpacing(ownerState);
69
70
  const styles = {};
70
- traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
71
+ traverseBreakpoints(theme.breakpoints, ownerState.offset, (appendStyle, value) => {
71
72
  let style = {};
72
73
  if (value === 'auto') {
73
74
  style = {
@@ -76,7 +77,7 @@ export const generateGridOffsetStyles = ({
76
77
  }
77
78
  if (typeof value === 'number') {
78
79
  style = {
79
- marginLeft: value === 0 ? '0px' : `calc(100% * ${value} / ${getParentColumns(ownerState)})`
80
+ marginLeft: value === 0 ? '0px' : `calc(100% * ${value} / ${getParentColumns(ownerState)} + ${getParentSpacing('column')} * ${value} / ${getParentColumns(ownerState)})`
80
81
  };
81
82
  }
82
83
  appendStyle(styles, style);
@@ -161,7 +162,6 @@ export const generateGridStyles = ({
161
162
  ownerState
162
163
  }) => {
163
164
  const getSelfSpacing = createGetSelfSpacing(ownerState);
164
- const getParentSpacing = createGetParentSpacing(ownerState);
165
165
  return {
166
166
  minWidth: 0,
167
167
  boxSizing: 'border-box',
@@ -171,22 +171,13 @@ export const generateGridStyles = ({
171
171
  ...(ownerState.wrap && ownerState.wrap !== 'wrap' && {
172
172
  flexWrap: ownerState.wrap
173
173
  }),
174
- margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`,
175
- ...(ownerState.disableEqualOverflow && {
176
- margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
177
- })
178
- }),
179
- ...((!ownerState.container || isNestedContainer(ownerState)) && {
180
- padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`,
181
- ...((ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
182
- padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
183
- })
174
+ gap: `${getSelfSpacing('row')} ${getSelfSpacing('column')}`
184
175
  })
185
176
  };
186
177
  };
187
- export const generateSizeClassNames = gridSize => {
178
+ export const generateSizeClassNames = size => {
188
179
  const classNames = [];
189
- Object.entries(gridSize).forEach(([key, value]) => {
180
+ Object.entries(size).forEach(([key, value]) => {
190
181
  if (value !== false && value !== undefined) {
191
182
  classNames.push(`grid-${key}-${String(value)}`);
192
183
  }
@@ -26,10 +26,10 @@ export function sortContainerQueries(theme, css) {
26
26
  });
27
27
  }
28
28
  export function isCqShorthand(breakpointKeys, value) {
29
- return value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
29
+ return value === '@' || value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
30
30
  }
31
31
  export function getContainerQuery(theme, shorthand) {
32
- const matches = shorthand.match(/^@([^/]+)\/?(.+)?$/);
32
+ const matches = shorthand.match(/^@([^/]+)?\/?(.+)?$/);
33
33
  if (!matches) {
34
34
  if (process.env.NODE_ENV !== 'production') {
35
35
  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>\`.
@@ -38,7 +38,7 @@ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.` : _formatMuiErrorMessag
38
38
  return null;
39
39
  }
40
40
  const [, containerQuery, containerName] = matches;
41
- const value = Number.isNaN(+containerQuery) ? containerQuery : +containerQuery;
41
+ const value = Number.isNaN(+containerQuery) ? containerQuery || 0 : +containerQuery;
42
42
  return theme.containerQueries(containerName).up(value);
43
43
  }
44
44
  export default function cssContainerQueries(themeInput) {
@@ -52,7 +52,7 @@ export default function cssContainerQueries(themeInput) {
52
52
  const result = toContainerQuery(themeInput.breakpoints.not(...args), name);
53
53
  if (result.includes('not all and')) {
54
54
  // `@container` does not work with `not all and`, so need to invert the logic
55
- return result.replace('not all and ', '').replace('min-width:', 'width<').replace('max-width:', 'width>');
55
+ return result.replace('not all and ', '').replace('min-width:', 'width<').replace('max-width:', 'width>').replace('and', 'or');
56
56
  }
57
57
  return result;
58
58
  };
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import { GlobalStyles } from '@mui/styled-engine';
5
5
  import { useTheme as muiUseTheme } from '@mui/private-theming';
6
6
  import ThemeProvider from '../ThemeProvider';
7
- import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
7
+ import InitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from '../InitColorSchemeScript/InitColorSchemeScript';
8
8
  import useCurrentColorScheme from './useCurrentColorScheme';
9
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
@@ -299,7 +299,7 @@ export default function createCssVarsProvider(options) {
299
299
  } : void 0;
300
300
  const defaultLightColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.light;
301
301
  const defaultDarkColorScheme = typeof designSystemColorScheme === 'string' ? designSystemColorScheme : designSystemColorScheme.dark;
302
- const getInitColorSchemeScript = params => systemGetInitColorSchemeScript({
302
+ const getInitColorSchemeScript = params => InitColorSchemeScript({
303
303
  attribute: defaultAttribute,
304
304
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
305
305
  defaultMode: designSystemMode,
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  export { default } from './createCssVarsProvider';
4
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
5
4
  export { default as prepareCssVars } from './prepareCssVars';
6
5
  export { default as prepareTypographyVars } from './prepareTypographyVars';
7
6
  export { default as createCssVarsTheme } from './createCssVarsTheme';
@@ -75,7 +75,7 @@ function prepareCssVars(theme, {
75
75
  }) || ':root', rootCss);
76
76
  const {
77
77
  [colorScheme]: defaultSchemeVal,
78
- ...rest
78
+ ...other
79
79
  } = colorSchemesMap;
80
80
  if (defaultSchemeVal) {
81
81
  // default color scheme has to come before other color schemes
@@ -86,7 +86,7 @@ function prepareCssVars(theme, {
86
86
  ...css
87
87
  }) || `[${theme.attribute || 'data-color-scheme'}="${colorScheme}"]`, css);
88
88
  }
89
- Object.entries(rest).forEach(([key, {
89
+ Object.entries(other).forEach(([key, {
90
90
  css
91
91
  }]) => {
92
92
  insertStyleSheet(getSelector?.(key, {
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from './getInitColorSchemeScript';
4
+ import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from '../InitColorSchemeScript/InitColorSchemeScript';
5
5
  export function getSystemMode(mode) {
6
6
  if (typeof window !== 'undefined' && mode === 'system') {
7
7
  const mql = window.matchMedia('(prefers-color-scheme: dark)');
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.9
2
+ * @mui/system v6.0.0-beta.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -4,19 +4,6 @@ import * as React from 'react';
4
4
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
5
  import { getThemeProps } from '../useThemeProps';
6
6
  import useTheme from '../useThemeWithoutDefault';
7
-
8
- /**
9
- * @deprecated Not used internally. Use `MediaQueryListEvent` from lib.dom.d.ts instead.
10
- */
11
-
12
- /**
13
- * @deprecated Not used internally. Use `MediaQueryList` from lib.dom.d.ts instead.
14
- */
15
-
16
- /**
17
- * @deprecated Not used internally. Use `(event: MediaQueryListEvent) => void` instead.
18
- */
19
-
20
7
  function useMediaQueryOld(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr) {
21
8
  const [match, setMatch] = React.useState(() => {
22
9
  if (noSsr && matchMedia) {
@@ -31,25 +18,17 @@ function useMediaQueryOld(query, defaultMatches, matchMedia, ssrMatchMedia, noSs
31
18
  return defaultMatches;
32
19
  });
33
20
  useEnhancedEffect(() => {
34
- let active = true;
35
21
  if (!matchMedia) {
36
22
  return undefined;
37
23
  }
38
24
  const queryList = matchMedia(query);
39
25
  const updateMatch = () => {
40
- // Workaround Safari wrong implementation of matchMedia
41
- // TODO can we remove it?
42
- // https://github.com/mui/material-ui/pull/17315#issuecomment-528286677
43
- if (active) {
44
- setMatch(queryList.matches);
45
- }
26
+ setMatch(queryList.matches);
46
27
  };
47
28
  updateMatch();
48
- // TODO: Use `addEventListener` once support for Safari < 14 is dropped
49
- queryList.addListener(updateMatch);
29
+ queryList.addEventListener('change', updateMatch);
50
30
  return () => {
51
- active = false;
52
- queryList.removeListener(updateMatch);
31
+ queryList.removeEventListener('change', updateMatch);
53
32
  };
54
33
  }, [query, matchMedia]);
55
34
  return match;
@@ -77,10 +56,9 @@ function useMediaQueryNew(query, defaultMatches, matchMedia, ssrMatchMedia, noSs
77
56
  }
78
57
  const mediaQueryList = matchMedia(query);
79
58
  return [() => mediaQueryList.matches, notify => {
80
- // TODO: Use `addEventListener` once support for Safari < 14 is dropped
81
- mediaQueryList.addListener(notify);
59
+ mediaQueryList.addEventListener('change', notify);
82
60
  return () => {
83
- mediaQueryList.removeListener(notify);
61
+ mediaQueryList.removeEventListener('change', notify);
84
62
  };
85
63
  }];
86
64
  }, [getDefaultSnapshot, matchMedia, query]);
@@ -63,8 +63,6 @@ function createContainer(options = {}) {
63
63
  marginLeft: 'auto',
64
64
  boxSizing: 'border-box',
65
65
  marginRight: 'auto',
66
- display: 'block',
67
- // Fix IE11 layout when used with main.
68
66
  ...(!ownerState.disableGutters && {
69
67
  paddingLeft: theme.spacing(2),
70
68
  paddingRight: theme.spacing(2),