@mui/system 6.0.0-alpha.9 → 6.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 (62) hide show
  1. package/CHANGELOG.md +331 -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/useCurrentColorScheme.js +1 -1
  27. package/index.js +1 -1
  28. package/modern/Container/createContainer.js +0 -2
  29. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +64 -0
  30. package/modern/DefaultPropsProvider/index.js +1 -0
  31. package/modern/{cssVars/getInitColorSchemeScript.js → InitColorSchemeScript/InitColorSchemeScript.js} +9 -2
  32. package/modern/InitColorSchemeScript/index.js +1 -0
  33. package/modern/ThemeProvider/ThemeProvider.js +5 -1
  34. package/modern/Unstable_Grid/Grid.js +5 -81
  35. package/modern/Unstable_Grid/createGrid.js +36 -55
  36. package/modern/Unstable_Grid/gridClasses.js +1 -1
  37. package/modern/Unstable_Grid/gridGenerator.js +10 -19
  38. package/modern/cssContainerQueries/cssContainerQueries.js +4 -4
  39. package/modern/cssVars/createCssVarsProvider.js +2 -2
  40. package/modern/cssVars/index.js +0 -1
  41. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  42. package/modern/index.js +1 -1
  43. package/modern/useMediaQuery/useMediaQuery.js +5 -27
  44. package/node/Container/createContainer.js +0 -2
  45. package/node/DefaultPropsProvider/DefaultPropsProvider.js +73 -0
  46. package/node/DefaultPropsProvider/index.js +20 -0
  47. package/node/{cssVars/getInitColorSchemeScript.js → InitColorSchemeScript/InitColorSchemeScript.js} +11 -3
  48. package/node/InitColorSchemeScript/index.js +13 -0
  49. package/node/ThemeProvider/ThemeProvider.js +5 -1
  50. package/node/Unstable_Grid/Grid.js +5 -81
  51. package/node/Unstable_Grid/createGrid.js +37 -56
  52. package/node/Unstable_Grid/gridClasses.js +1 -1
  53. package/node/Unstable_Grid/gridGenerator.js +10 -19
  54. package/node/cssContainerQueries/cssContainerQueries.js +4 -4
  55. package/node/cssVars/createCssVarsProvider.js +5 -5
  56. package/node/cssVars/index.js +0 -7
  57. package/node/cssVars/useCurrentColorScheme.js +3 -3
  58. package/node/index.js +1 -1
  59. package/node/useMediaQuery/useMediaQuery.js +5 -26
  60. package/package.json +6 -6
  61. package/useMediaQuery/useMediaQuery.d.ts +0 -18
  62. package/useMediaQuery/useMediaQuery.js +5 -27
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { OverrideProps, IfEquals } from '@mui/types';
2
+ import { OverrideProps, PartiallyRequired } from '@mui/types';
3
3
  import { SxProps } from '../styleFunctionSx';
4
- import { Theme, Breakpoint, BreakpointOverrides } from '../createTheme';
4
+ import { Theme, Breakpoint } from '../createTheme';
5
5
  import { SystemProps } from '../Box';
6
6
  type ResponsiveStyleValue<T> = T | Array<T | null> | {
7
7
  [key in Breakpoint]?: T | null;
@@ -9,94 +9,9 @@ type ResponsiveStyleValue<T> = T | Array<T | null> | {
9
9
  export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
10
10
  export type GridSpacing = number | string;
11
11
  export type GridWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
12
- export type GridSize = 'auto' | number;
13
- export interface GridDefaultBreakpoints {
14
- /**
15
- * If a number, it sets the number of columns the grid item uses.
16
- * It can't be greater than the total number of columns of the container (12 by default).
17
- * If 'auto', the grid item's width matches its content.
18
- * If false, the prop is ignored.
19
- * If true, the grid item's width grows to use the space available in the grid container.
20
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
21
- * @default false
22
- */
23
- lg?: boolean | GridSize;
24
- /**
25
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
26
- * If 'auto', the grid item push itself to the right-end of the container.
27
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
28
- */
29
- lgOffset?: GridSize;
30
- /**
31
- * If a number, it sets the number of columns the grid item uses.
32
- * It can't be greater than the total number of columns of the container (12 by default).
33
- * If 'auto', the grid item's width matches its content.
34
- * If false, the prop is ignored.
35
- * If true, the grid item's width grows to use the space available in the grid container.
36
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
37
- * @default false
38
- */
39
- md?: boolean | GridSize;
40
- /**
41
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
42
- * If 'auto', the grid item push itself to the right-end of the container.
43
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
44
- */
45
- mdOffset?: GridSize;
46
- /**
47
- * If a number, it sets the number of columns the grid item uses.
48
- * It can't be greater than the total number of columns of the container (12 by default).
49
- * If 'auto', the grid item's width matches its content.
50
- * If false, the prop is ignored.
51
- * If true, the grid item's width grows to use the space available in the grid container.
52
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
53
- * @default false
54
- */
55
- sm?: boolean | GridSize;
56
- /**
57
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
58
- * If 'auto', the grid item push itself to the right-end of the container.
59
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
60
- */
61
- smOffset?: GridSize;
62
- /**
63
- * If a number, it sets the number of columns the grid item uses.
64
- * It can't be greater than the total number of columns of the container (12 by default).
65
- * If 'auto', the grid item's width matches its content.
66
- * If false, the prop is ignored.
67
- * If true, the grid item's width grows to use the space available in the grid container.
68
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
69
- * @default false
70
- */
71
- xl?: boolean | GridSize;
72
- /**
73
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
74
- * If 'auto', the grid item push itself to the right-end of the container.
75
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
76
- */
77
- xlOffset?: GridSize;
78
- /**
79
- * If a number, it sets the number of columns the grid item uses.
80
- * It can't be greater than the total number of columns of the container (12 by default).
81
- * If 'auto', the grid item's width matches its content.
82
- * If false, the prop is ignored.
83
- * If true, the grid item's width grows to use the space available in the grid container.
84
- * The value is applied for all the screen sizes with the lowest priority.
85
- * @default false
86
- */
87
- xs?: boolean | GridSize;
88
- /**
89
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
90
- * If 'auto', the grid item push itself to the right-end of the container.
91
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
92
- */
93
- xsOffset?: GridSize;
94
- }
95
- type CustomBreakpoints = Partial<Record<Breakpoint, boolean | GridSize> & Record<`${Breakpoint}Offset`, GridSize>>;
96
- interface BreakpointOverridesEmpty {
97
- }
98
- type Breakpoints = IfEquals<BreakpointOverrides, BreakpointOverridesEmpty, GridDefaultBreakpoints, CustomBreakpoints>;
99
- export interface GridBaseProps extends Breakpoints {
12
+ export type GridSize = 'auto' | 'grow' | number | false;
13
+ export type GridOffset = 'auto' | number;
14
+ export interface GridBaseProps {
100
15
  /**
101
16
  * The content of the component.
102
17
  */
@@ -124,9 +39,9 @@ export interface GridBaseProps extends Breakpoints {
124
39
  */
125
40
  direction?: ResponsiveStyleValue<GridDirection>;
126
41
  /**
127
- * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
42
+ * Defines the offset value for the type `item` components.
128
43
  */
129
- disableEqualOverflow?: boolean;
44
+ offset?: ResponsiveStyleValue<GridOffset>;
130
45
  /**
131
46
  * @internal
132
47
  * The level of the grid starts from `0`
@@ -155,6 +70,10 @@ export interface GridBaseProps extends Breakpoints {
155
70
  * It overrides the value of the `spacing` prop.
156
71
  */
157
72
  rowSpacing?: ResponsiveStyleValue<GridSpacing>;
73
+ /**
74
+ * Defines the size of the the type `item` components.
75
+ */
76
+ size?: ResponsiveStyleValue<GridSize>;
158
77
  /**
159
78
  * Defines the space between the type `item` components.
160
79
  * It can only be used on a type `container` component.
@@ -168,11 +87,7 @@ export interface GridBaseProps extends Breakpoints {
168
87
  */
169
88
  wrap?: GridWrap;
170
89
  }
171
- export interface GridOwnerState extends GridBaseProps {
172
- unstable_level: number;
173
- gridSize: Partial<Record<Breakpoint, GridSize | boolean>>;
174
- gridOffset: Partial<Record<Breakpoint, GridSize>>;
175
- }
90
+ export type GridOwnerState = PartiallyRequired<GridBaseProps, 'size' | 'offset' | 'unstable_level'>;
176
91
  export interface GridTypeMap<AdditionalProps = {}, DefaultComponent extends React.ElementType = 'div'> {
177
92
  props: AdditionalProps & GridBaseProps & {
178
93
  sx?: SxProps<Theme>;
@@ -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
91
  ...rest
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,19 +106,16 @@ 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,
117
117
  className: clsx(classes.root, className),
118
- ...other,
118
+ ...rest,
119
119
  children: React.Children.map(children, child => {
120
120
  if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
121
121
  return /*#__PURE__*/React.cloneElement(child, {
@@ -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}`),
@@ -7,18 +7,11 @@ interface Props {
7
7
  breakpoints: Breakpoints;
8
8
  spacing?: Spacing;
9
9
  };
10
- ownerState: GridOwnerState & {
11
- parentDisableEqualOverflow?: boolean;
12
- };
10
+ ownerState: GridOwnerState;
13
11
  }
14
12
  export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
15
13
  export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
16
- export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {
17
- [x: string]: string;
18
- '--Grid-columns'?: undefined;
19
- } | {
20
- '--Grid-columns': number;
21
- };
14
+ export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => Record<string, string | number | undefined>;
22
15
  export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {
23
16
  [x: string]: string;
24
17
  };
@@ -27,7 +20,7 @@ export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Pr
27
20
  };
28
21
  export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
29
22
  export declare const generateGridStyles: ({ ownerState }: Props) => {};
30
- export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
23
+ export declare const generateSizeClassNames: (size: GridOwnerState['size']) => string[];
31
24
  export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
32
25
  export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
33
26
  export {};
@@ -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
  }
@@ -6,7 +6,7 @@ import { SxConfig, SxProps } from '../styleFunctionSx';
6
6
  import { ApplyStyles } from './applyStyles';
7
7
  import { CssContainerQueries } from '../cssContainerQueries';
8
8
 
9
- export { Breakpoint, BreakpointOverrides } from './createBreakpoints';
9
+ export { Breakpoint, Breakpoints, BreakpointOverrides } from './createBreakpoints';
10
10
 
11
11
  export type Direction = 'ltr' | 'rtl';
12
12
 
@@ -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
  };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import getInitColorSchemeScript from './getInitColorSchemeScript';
2
+ import InitColorSchemeScript from '../InitColorSchemeScript';
3
3
  import { Mode, Result } from './useCurrentColorScheme';
4
4
 
5
5
  export interface ColorSchemeContextValue<SupportedColorScheme extends string>
@@ -92,7 +92,7 @@ export interface CreateCssVarsProviderResult<
92
92
  >,
93
93
  ) => React.ReactElement<any>;
94
94
  useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
95
- getInitColorSchemeScript: typeof getInitColorSchemeScript;
95
+ getInitColorSchemeScript: typeof InitColorSchemeScript;
96
96
  }
97
97
 
98
98
  export default function createCssVarsProvider<
@@ -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,6 +1,5 @@
1
1
  export { default } from './createCssVarsProvider';
2
2
  export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
4
3
  export { default as prepareCssVars } from './prepareCssVars';
5
4
  export { default as prepareTypographyVars } from './prepareTypographyVars';
6
5
  export type { ExtractTypographyTokens } from './prepareTypographyVars';
package/cssVars/index.js CHANGED
@@ -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';
@@ -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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.9
2
+ * @mui/system v6.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -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';