@mui/system 6.0.0-alpha.12 → 6.0.0-alpha.14

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,96 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v6.0.0-alpha.14
4
+
5
+ <!-- generated comparing v6.0.0-alpha.13..next -->
6
+
7
+ _Jul 3, 2024_
8
+
9
+ A big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - ✨ Updated Grid v2 to match PigmentGrid (#42742) @DiegoAndai
12
+
13
+ ### `@mui/material@v6.0.0-alpha.14`
14
+
15
+ #### BREAKING CHANGES
16
+
17
+ - [Grid] Update Grid props to match PigmentGrid (#42742) @DiegoAndai
18
+
19
+ Use the codemod below to migrate the props:
20
+
21
+ ```bash
22
+ npx @mui/codemod@next v6.0.0/grid-v2-props /path/to/folder
23
+ ```
24
+
25
+ #### Changes
26
+
27
+ - [Alert] Add ability to override slot props (#42787) @alexey-kozlenkov
28
+ - [Dialog] Revert incorrect textAlign style removal (#42778) @DiegoAndai
29
+ - [theme] Support `CssVarsTheme` in `responsiveFontSizes` return type (#42786) @jxdp
30
+
31
+ ### Docs
32
+
33
+ - [material-ui] Add some writing tweaks to v6 migration page (#42623) @danilo-leal
34
+ - [material-ui] Fix issues reported by react-compiler in docs folder (#42830) @sai6855
35
+ - [material-ui] Add some writing tweaks to v6 migration page (#42623) @danilo-leal
36
+ - [base-ui] Fix wrong description for `UseTabParameters.onChange` (#42749) @ohgree
37
+ - Fix 301 MDN redirections @oliviertassinari
38
+
39
+ ### Core
40
+
41
+ - [core] Bump React to 18.3.1 (#42047) @renovate[bot]
42
+ - [core] Revert lint for `useThemeProps` (#42817) @siriwatknp
43
+ - [core] Remove useIsFocusVisible util (#42467) @DiegoAndai
44
+ - [core] Remove react-test-renderer (#42784) @aarongarciah
45
+ - [core][mui-utils] Remove remaining IE11 references (#42777) @DiegoAndai
46
+ - [code-infra] Move `HighlightedCode` test into `@mui/docs` package (#42835) @LukasTy
47
+ - [code-infra] Cleanup `@mui/docs` usage and legacy re-exports (#42833) @LukasTy
48
+ - [docs-infra] Fix React Compiler ESLint issues in website components (#42566) @aarongarciah
49
+ - [docs-infra] Add batch of design polish (#42823) @danilo-leal
50
+ - [test][mui-utils] Remove usages of deprecated react-dom APIs (#42780) @aarongarciah
51
+ - [test][joy-ui][Autocomplete] Fix spread key error in test (#42775) @aarongarciah
52
+
53
+ All contributors of this release in alphabetical order: @aarongarciah, @alexey-kozlenkov, @danilo-leal, @DiegoAndai, @Janpot, @jxdp, @LukasTy, @ohgree, @oliviertassinari, @renovate[bot], @sai6855, @siriwatknp
54
+
55
+ ## v6.0.0-alpha.13
56
+
57
+ <!-- generated comparing v6.0.0-alpha.12..next -->
58
+
59
+ _Jun 27, 2024_
60
+
61
+ A big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
62
+
63
+ - 🚀 Added layout components for Pigment CSS integration (#42693) @siriwatknp
64
+
65
+ ### `@mui/material@6.0.0-alpha.13`
66
+
67
+ - [Autocomplete] Fix more React 18.3 key spread warnings in demos (#42639) @wbt
68
+ - [Container][Grid][Stack][Hidden] Export Pigment CSS layout components (#42693) @siriwatknp
69
+ - [Text Field] when click password visibility button, text caret position change to very front. (#42595) @appleSimple
70
+ - [Modal] migrate useSlotProps to useSLot (#42150) @sai6855
71
+
72
+ ### `@mui/styles@6.0.0-alpha.13`
73
+
74
+ - [withStyles] Expect React defaultProps warning in test (#42752) @aarongarciah
75
+
76
+ ### Docs
77
+
78
+ - Fix link in CONTRIBUTING.md (#42755) @Janpot
79
+ - Add documentation on migrating JSS's alternative, array-based syntax to syntax supported by Emotion (#42053) @cjl750
80
+ - Fix type error in virtualized table demo (#42757) @aarongarciah
81
+ - Add first batch of v6 migration (#42242) @siriwatknp
82
+ - Fix quotes on font-family dedeclaration in the Landing Page template theme (#42748) @joetats
83
+
84
+ ### Core
85
+
86
+ - [code-infra] Refactor eslint `import/no-cycle` rule (#42705) @LukasTy
87
+ - [core] Target direct version for prerelease (#42768) @siriwatknp
88
+ - [test] Remove enzyme (#42706) @aarongarciah
89
+ - [test] Remove createMount test util (#42703) @aarongarciah
90
+ - [website] Add Ale to team (#42764) @alelthomas
91
+
92
+ All contributors of this release in alphabetical order: @aarongarciah, @alelthomas, @appleSimple, @cjl750, @Janpot, @joetats, @LukasTy, @sai6855, @siriwatknp, @wbt
93
+
3
94
  ## v6.0.0-alpha.12
4
95
 
5
96
  <!-- generated comparing v6.0.0-alpha.11..next -->
@@ -46,58 +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 a number, it sets the number of columns the grid item uses.
50
- * It can't be greater than the total number of columns of the container (12 by default).
51
- * If 'auto', the grid item's width matches its content.
52
- * If false, the prop is ignored.
53
- * If true, the grid item's width grows to use the space available in the grid container.
54
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
55
- * @default false
56
- */
57
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
58
- /**
59
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
60
- * If 'auto', the grid item push itself to the right-end of the container.
61
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
62
- */
63
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
64
- /**
65
- * If a number, it sets the number of columns the grid item uses.
66
- * It can't be greater than the total number of columns of the container (12 by default).
67
- * If 'auto', the grid item's width matches its content.
68
- * If false, the prop is ignored.
69
- * If true, the grid item's width grows to use the space available in the grid container.
70
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
71
- * @default false
49
+ * Defines the offset value for the type `item` components.
72
50
  */
73
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
74
- /**
75
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
76
- * If 'auto', the grid item push itself to the right-end of the container.
77
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
78
- */
79
- 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]),
80
52
  /**
81
53
  * Defines the vertical space between the type `item` components.
82
54
  * It overrides the value of the `spacing` prop.
83
55
  */
84
56
  rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
85
57
  /**
86
- * If a number, it sets the number of columns the grid item uses.
87
- * It can't be greater than the total number of columns of the container (12 by default).
88
- * If 'auto', the grid item's width matches its content.
89
- * If false, the prop is ignored.
90
- * If true, the grid item's width grows to use the space available in the grid container.
91
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
92
- * @default false
93
- */
94
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
95
- /**
96
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
97
- * If 'auto', the grid item push itself to the right-end of the container.
98
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
58
+ * Defines the size of the the type `item` components.
99
59
  */
100
- 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]),
101
61
  /**
102
62
  * Defines the space between the type `item` components.
103
63
  * It can only be used on a type `container` component.
@@ -136,38 +96,6 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
136
96
  * It's applied for all screen sizes.
137
97
  * @default 'wrap'
138
98
  */
139
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
140
- /**
141
- * If a number, it sets the number of columns the grid item uses.
142
- * It can't be greater than the total number of columns of the container (12 by default).
143
- * If 'auto', the grid item's width matches its content.
144
- * If false, the prop is ignored.
145
- * If true, the grid item's width grows to use the space available in the grid container.
146
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
147
- * @default false
148
- */
149
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
150
- /**
151
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
152
- * If 'auto', the grid item push itself to the right-end of the container.
153
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
154
- */
155
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
156
- /**
157
- * If a number, it sets the number of columns the grid item uses.
158
- * It can't be greater than the total number of columns of the container (12 by default).
159
- * If 'auto', the grid item's width matches its content.
160
- * If false, the prop is ignored.
161
- * If true, the grid item's width grows to use the space available in the grid container.
162
- * The value is applied for all the screen sizes with the lowest priority.
163
- * @default false
164
- */
165
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
166
- /**
167
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
168
- * If 'auto', the grid item push itself to the right-end of the container.
169
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
170
- */
171
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
99
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
172
100
  } : void 0;
173
101
  export default Grid;
@@ -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
  */
@@ -123,6 +38,10 @@ export interface GridBaseProps extends Breakpoints {
123
38
  * @default 'row'
124
39
  */
125
40
  direction?: ResponsiveStyleValue<GridDirection>;
41
+ /**
42
+ * Defines the offset value for the type `item` components.
43
+ */
44
+ offset?: ResponsiveStyleValue<GridOffset>;
126
45
  /**
127
46
  * @internal
128
47
  * The level of the grid starts from `0`
@@ -151,6 +70,10 @@ export interface GridBaseProps extends Breakpoints {
151
70
  * It overrides the value of the `spacing` prop.
152
71
  */
153
72
  rowSpacing?: ResponsiveStyleValue<GridSpacing>;
73
+ /**
74
+ * Defines the size of the the type `item` components.
75
+ */
76
+ size?: ResponsiveStyleValue<GridSize>;
154
77
  /**
155
78
  * Defines the space between the type `item` components.
156
79
  * It can only be used on a type `container` component.
@@ -164,11 +87,7 @@ export interface GridBaseProps extends Breakpoints {
164
87
  */
165
88
  wrap?: GridWrap;
166
89
  }
167
- export interface GridOwnerState extends GridBaseProps {
168
- unstable_level: number;
169
- gridSize: Partial<Record<Breakpoint, GridSize | boolean>>;
170
- gridOffset: Partial<Record<Breakpoint, GridSize>>;
171
- }
90
+ export type GridOwnerState = PartiallyRequired<GridBaseProps, 'size' | 'offset' | 'unstable_level'>;
172
91
  export interface GridTypeMap<AdditionalProps = {}, DefaultComponent extends React.ElementType = 'div'> {
173
92
  props: AdditionalProps & GridBaseProps & {
174
93
  sx?: SxProps<Theme>;
@@ -39,13 +39,36 @@ export default function createGrid(options = {}) {
39
39
  direction,
40
40
  spacing,
41
41
  wrap,
42
- gridSize
42
+ size
43
43
  } = ownerState;
44
44
  const slots = {
45
- 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]) : [])]
46
46
  };
47
47
  return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
48
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
+ }
49
72
  const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
50
73
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
51
74
  const theme = useTheme();
@@ -59,25 +82,16 @@ export default function createGrid(options = {}) {
59
82
  component = 'div',
60
83
  direction = 'row',
61
84
  wrap = 'wrap',
85
+ size: sizeProp = {},
86
+ offset: offsetProp = {},
62
87
  spacing: spacingProp = 0,
63
88
  rowSpacing: rowSpacingProp = spacingProp,
64
89
  columnSpacing: columnSpacingProp = spacingProp,
65
90
  unstable_level: level = 0,
66
91
  ...rest
67
92
  } = props;
68
- // collect breakpoints related props because they can be customized from the theme.
69
- const gridSize = {};
70
- const gridOffset = {};
71
- const other = {};
72
- Object.entries(rest).forEach(([key, val]) => {
73
- if (theme.breakpoints.values[key] !== undefined) {
74
- gridSize[key] = val;
75
- } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
76
- gridOffset[key.replace('Offset', '')] = val;
77
- } else {
78
- other[key] = val;
79
- }
80
- });
93
+ const size = parseResponsiveProp(sizeProp, theme.breakpoints, val => val !== false);
94
+ const offset = parseResponsiveProp(offsetProp, theme.breakpoints);
81
95
  const columns = inProps.columns ?? (level ? undefined : columnsProp);
82
96
  const spacing = inProps.spacing ?? (level ? undefined : spacingProp);
83
97
  const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (level ? undefined : rowSpacingProp);
@@ -92,8 +106,8 @@ export default function createGrid(options = {}) {
92
106
  spacing,
93
107
  rowSpacing,
94
108
  columnSpacing,
95
- gridSize,
96
- gridOffset
109
+ size,
110
+ offset
97
111
  };
98
112
  const classes = useUtilityClasses(ownerState, theme);
99
113
  return /*#__PURE__*/_jsx(GridRoot, {
@@ -101,7 +115,7 @@ export default function createGrid(options = {}) {
101
115
  as: component,
102
116
  ownerState: ownerState,
103
117
  className: clsx(classes.root, className),
104
- ...other,
118
+ ...rest,
105
119
  children: React.Children.map(children, child => {
106
120
  if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
107
121
  return /*#__PURE__*/React.cloneElement(child, {
@@ -120,20 +134,12 @@ export default function createGrid(options = {}) {
120
134
  component: PropTypes.elementType,
121
135
  container: PropTypes.bool,
122
136
  direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
123
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
124
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
125
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
126
- 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]),
127
138
  rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
128
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
129
- 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]),
130
140
  spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
131
141
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
132
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
133
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
134
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
135
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
136
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
142
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
137
143
  } : void 0;
138
144
 
139
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}`),
@@ -11,12 +11,7 @@ interface Props {
11
11
  }
12
12
  export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
13
13
  export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
14
- export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {
15
- [x: string]: string;
16
- '--Grid-columns'?: undefined;
17
- } | {
18
- '--Grid-columns': number;
19
- };
14
+ export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => Record<string, string | number | undefined>;
20
15
  export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {
21
16
  [x: string]: string;
22
17
  };
@@ -25,7 +20,7 @@ export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Pr
25
20
  };
26
21
  export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
27
22
  export declare const generateGridStyles: ({ ownerState }: Props) => {};
28
- export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
23
+ export declare const generateSizeClassNames: (size: GridOwnerState['size']) => string[];
29
24
  export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
30
25
  export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
31
26
  export {};
@@ -33,9 +33,9 @@ export const generateGridSizeStyles = ({
33
33
  }) => {
34
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,
@@ -68,7 +68,7 @@ export const generateGridOffsetStyles = ({
68
68
  }) => {
69
69
  const getParentSpacing = createGetParentSpacing(ownerState);
70
70
  const styles = {};
71
- traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
71
+ traverseBreakpoints(theme.breakpoints, ownerState.offset, (appendStyle, value) => {
72
72
  let style = {};
73
73
  if (value === 'auto') {
74
74
  style = {
@@ -175,9 +175,9 @@ export const generateGridStyles = ({
175
175
  })
176
176
  };
177
177
  };
178
- export const generateSizeClassNames = gridSize => {
178
+ export const generateSizeClassNames = size => {
179
179
  const classNames = [];
180
- Object.entries(gridSize).forEach(([key, value]) => {
180
+ Object.entries(size).forEach(([key, value]) => {
181
181
  if (value !== false && value !== undefined) {
182
182
  classNames.push(`grid-${key}-${String(value)}`);
183
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
 
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.12
2
+ * @mui/system v6.0.0-alpha.14
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -46,58 +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 a number, it sets the number of columns the grid item uses.
50
- * It can't be greater than the total number of columns of the container (12 by default).
51
- * If 'auto', the grid item's width matches its content.
52
- * If false, the prop is ignored.
53
- * If true, the grid item's width grows to use the space available in the grid container.
54
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
55
- * @default false
56
- */
57
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
58
- /**
59
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
60
- * If 'auto', the grid item push itself to the right-end of the container.
61
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
62
- */
63
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
64
- /**
65
- * If a number, it sets the number of columns the grid item uses.
66
- * It can't be greater than the total number of columns of the container (12 by default).
67
- * If 'auto', the grid item's width matches its content.
68
- * If false, the prop is ignored.
69
- * If true, the grid item's width grows to use the space available in the grid container.
70
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
71
- * @default false
49
+ * Defines the offset value for the type `item` components.
72
50
  */
73
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
74
- /**
75
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
76
- * If 'auto', the grid item push itself to the right-end of the container.
77
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
78
- */
79
- 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]),
80
52
  /**
81
53
  * Defines the vertical space between the type `item` components.
82
54
  * It overrides the value of the `spacing` prop.
83
55
  */
84
56
  rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
85
57
  /**
86
- * If a number, it sets the number of columns the grid item uses.
87
- * It can't be greater than the total number of columns of the container (12 by default).
88
- * If 'auto', the grid item's width matches its content.
89
- * If false, the prop is ignored.
90
- * If true, the grid item's width grows to use the space available in the grid container.
91
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
92
- * @default false
93
- */
94
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
95
- /**
96
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
97
- * If 'auto', the grid item push itself to the right-end of the container.
98
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
58
+ * Defines the size of the the type `item` components.
99
59
  */
100
- 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]),
101
61
  /**
102
62
  * Defines the space between the type `item` components.
103
63
  * It can only be used on a type `container` component.
@@ -136,38 +96,6 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
136
96
  * It's applied for all screen sizes.
137
97
  * @default 'wrap'
138
98
  */
139
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
140
- /**
141
- * If a number, it sets the number of columns the grid item uses.
142
- * It can't be greater than the total number of columns of the container (12 by default).
143
- * If 'auto', the grid item's width matches its content.
144
- * If false, the prop is ignored.
145
- * If true, the grid item's width grows to use the space available in the grid container.
146
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
147
- * @default false
148
- */
149
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
150
- /**
151
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
152
- * If 'auto', the grid item push itself to the right-end of the container.
153
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
154
- */
155
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
156
- /**
157
- * If a number, it sets the number of columns the grid item uses.
158
- * It can't be greater than the total number of columns of the container (12 by default).
159
- * If 'auto', the grid item's width matches its content.
160
- * If false, the prop is ignored.
161
- * If true, the grid item's width grows to use the space available in the grid container.
162
- * The value is applied for all the screen sizes with the lowest priority.
163
- * @default false
164
- */
165
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
166
- /**
167
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
168
- * If 'auto', the grid item push itself to the right-end of the container.
169
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
170
- */
171
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
99
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
172
100
  } : void 0;
173
101
  export default Grid;
@@ -39,13 +39,36 @@ export default function createGrid(options = {}) {
39
39
  direction,
40
40
  spacing,
41
41
  wrap,
42
- gridSize
42
+ size
43
43
  } = ownerState;
44
44
  const slots = {
45
- 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]) : [])]
46
46
  };
47
47
  return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
48
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
+ }
49
72
  const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
50
73
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
51
74
  const theme = useTheme();
@@ -59,25 +82,16 @@ export default function createGrid(options = {}) {
59
82
  component = 'div',
60
83
  direction = 'row',
61
84
  wrap = 'wrap',
85
+ size: sizeProp = {},
86
+ offset: offsetProp = {},
62
87
  spacing: spacingProp = 0,
63
88
  rowSpacing: rowSpacingProp = spacingProp,
64
89
  columnSpacing: columnSpacingProp = spacingProp,
65
90
  unstable_level: level = 0,
66
91
  ...rest
67
92
  } = props;
68
- // collect breakpoints related props because they can be customized from the theme.
69
- const gridSize = {};
70
- const gridOffset = {};
71
- const other = {};
72
- Object.entries(rest).forEach(([key, val]) => {
73
- if (theme.breakpoints.values[key] !== undefined) {
74
- gridSize[key] = val;
75
- } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
76
- gridOffset[key.replace('Offset', '')] = val;
77
- } else {
78
- other[key] = val;
79
- }
80
- });
93
+ const size = parseResponsiveProp(sizeProp, theme.breakpoints, val => val !== false);
94
+ const offset = parseResponsiveProp(offsetProp, theme.breakpoints);
81
95
  const columns = inProps.columns ?? (level ? undefined : columnsProp);
82
96
  const spacing = inProps.spacing ?? (level ? undefined : spacingProp);
83
97
  const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (level ? undefined : rowSpacingProp);
@@ -92,8 +106,8 @@ export default function createGrid(options = {}) {
92
106
  spacing,
93
107
  rowSpacing,
94
108
  columnSpacing,
95
- gridSize,
96
- gridOffset
109
+ size,
110
+ offset
97
111
  };
98
112
  const classes = useUtilityClasses(ownerState, theme);
99
113
  return /*#__PURE__*/_jsx(GridRoot, {
@@ -101,7 +115,7 @@ export default function createGrid(options = {}) {
101
115
  as: component,
102
116
  ownerState: ownerState,
103
117
  className: clsx(classes.root, className),
104
- ...other,
118
+ ...rest,
105
119
  children: React.Children.map(children, child => {
106
120
  if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
107
121
  return /*#__PURE__*/React.cloneElement(child, {
@@ -120,20 +134,12 @@ export default function createGrid(options = {}) {
120
134
  component: PropTypes.elementType,
121
135
  container: PropTypes.bool,
122
136
  direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
123
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
124
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
125
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
126
- 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]),
127
138
  rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
128
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
129
- 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]),
130
140
  spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
131
141
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
132
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
133
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
134
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
135
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
136
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
142
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
137
143
  } : void 0;
138
144
 
139
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}`),
@@ -33,9 +33,9 @@ export const generateGridSizeStyles = ({
33
33
  }) => {
34
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,
@@ -68,7 +68,7 @@ export const generateGridOffsetStyles = ({
68
68
  }) => {
69
69
  const getParentSpacing = createGetParentSpacing(ownerState);
70
70
  const styles = {};
71
- traverseBreakpoints(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
71
+ traverseBreakpoints(theme.breakpoints, ownerState.offset, (appendStyle, value) => {
72
72
  let style = {};
73
73
  if (value === 'auto') {
74
74
  style = {
@@ -175,9 +175,9 @@ export const generateGridStyles = ({
175
175
  })
176
176
  };
177
177
  };
178
- export const generateSizeClassNames = gridSize => {
178
+ export const generateSizeClassNames = size => {
179
179
  const classNames = [];
180
- Object.entries(gridSize).forEach(([key, value]) => {
180
+ Object.entries(size).forEach(([key, value]) => {
181
181
  if (value !== false && value !== undefined) {
182
182
  classNames.push(`grid-${key}-${String(value)}`);
183
183
  }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.12
2
+ * @mui/system v6.0.0-alpha.14
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,58 +52,18 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
52
52
  */
53
53
  direction: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), _propTypes.default.object]),
54
54
  /**
55
- * If a number, it sets the number of columns the grid item uses.
56
- * It can't be greater than the total number of columns of the container (12 by default).
57
- * If 'auto', the grid item's width matches its content.
58
- * If false, the prop is ignored.
59
- * If true, the grid item's width grows to use the space available in the grid container.
60
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
61
- * @default false
62
- */
63
- lg: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
64
- /**
65
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
66
- * If 'auto', the grid item push itself to the right-end of the container.
67
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
68
- */
69
- lgOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
70
- /**
71
- * If a number, it sets the number of columns the grid item uses.
72
- * It can't be greater than the total number of columns of the container (12 by default).
73
- * If 'auto', the grid item's width matches its content.
74
- * If false, the prop is ignored.
75
- * If true, the grid item's width grows to use the space available in the grid container.
76
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
77
- * @default false
55
+ * Defines the offset value for the type `item` components.
78
56
  */
79
- md: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
80
- /**
81
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
82
- * If 'auto', the grid item push itself to the right-end of the container.
83
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
84
- */
85
- mdOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
57
+ offset: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])), _propTypes.default.object]),
86
58
  /**
87
59
  * Defines the vertical space between the type `item` components.
88
60
  * It overrides the value of the `spacing` prop.
89
61
  */
90
62
  rowSpacing: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.string]),
91
63
  /**
92
- * If a number, it sets the number of columns the grid item uses.
93
- * It can't be greater than the total number of columns of the container (12 by default).
94
- * If 'auto', the grid item's width matches its content.
95
- * If false, the prop is ignored.
96
- * If true, the grid item's width grows to use the space available in the grid container.
97
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
98
- * @default false
99
- */
100
- sm: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
101
- /**
102
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
103
- * If 'auto', the grid item push itself to the right-end of the container.
104
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
64
+ * Defines the size of the the type `item` components.
105
65
  */
106
- smOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
66
+ size: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number])), _propTypes.default.object]),
107
67
  /**
108
68
  * Defines the space between the type `item` components.
109
69
  * It can only be used on a type `container` component.
@@ -142,38 +102,6 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ =
142
102
  * It's applied for all screen sizes.
143
103
  * @default 'wrap'
144
104
  */
145
- wrap: _propTypes.default.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
146
- /**
147
- * If a number, it sets the number of columns the grid item uses.
148
- * It can't be greater than the total number of columns of the container (12 by default).
149
- * If 'auto', the grid item's width matches its content.
150
- * If false, the prop is ignored.
151
- * If true, the grid item's width grows to use the space available in the grid container.
152
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
153
- * @default false
154
- */
155
- xl: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
156
- /**
157
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
158
- * If 'auto', the grid item push itself to the right-end of the container.
159
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
160
- */
161
- xlOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
162
- /**
163
- * If a number, it sets the number of columns the grid item uses.
164
- * It can't be greater than the total number of columns of the container (12 by default).
165
- * If 'auto', the grid item's width matches its content.
166
- * If false, the prop is ignored.
167
- * If true, the grid item's width grows to use the space available in the grid container.
168
- * The value is applied for all the screen sizes with the lowest priority.
169
- * @default false
170
- */
171
- xs: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
172
- /**
173
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
174
- * If 'auto', the grid item push itself to the right-end of the container.
175
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
176
- */
177
- xsOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number])
105
+ wrap: _propTypes.default.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
178
106
  } : void 0;
179
107
  var _default = exports.default = Grid;
@@ -48,13 +48,36 @@ function createGrid(options = {}) {
48
48
  direction,
49
49
  spacing,
50
50
  wrap,
51
- gridSize
51
+ size
52
52
  } = ownerState;
53
53
  const slots = {
54
- root: ['root', container && 'container', wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...(0, _gridGenerator.generateDirectionClasses)(direction), ...(0, _gridGenerator.generateSizeClassNames)(gridSize), ...(container ? (0, _gridGenerator.generateSpacingClassNames)(spacing, theme.breakpoints.keys[0]) : [])]
54
+ root: ['root', container && 'container', wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...(0, _gridGenerator.generateDirectionClasses)(direction), ...(0, _gridGenerator.generateSizeClassNames)(size), ...(container ? (0, _gridGenerator.generateSpacingClassNames)(spacing, theme.breakpoints.keys[0]) : [])]
55
55
  };
56
56
  return (0, _composeClasses.default)(slots, slot => (0, _generateUtilityClass.default)(componentName, slot), {});
57
57
  };
58
+ function parseResponsiveProp(propValue, breakpoints, shouldUseValue = () => true) {
59
+ const parsedProp = {};
60
+ if (propValue === null) {
61
+ return parsedProp;
62
+ }
63
+ if (Array.isArray(propValue)) {
64
+ propValue.forEach((value, index) => {
65
+ if (value !== null && shouldUseValue(value) && breakpoints.keys[index]) {
66
+ parsedProp[breakpoints.keys[index]] = value;
67
+ }
68
+ });
69
+ } else if (typeof propValue === 'object') {
70
+ Object.keys(propValue).forEach(key => {
71
+ const value = propValue[key];
72
+ if (value !== null && value !== undefined && shouldUseValue(value)) {
73
+ parsedProp[key] = value;
74
+ }
75
+ });
76
+ } else {
77
+ parsedProp[breakpoints.keys[0]] = propValue;
78
+ }
79
+ return parsedProp;
80
+ }
58
81
  const GridRoot = createStyledComponent(_gridGenerator.generateGridColumnsStyles, _gridGenerator.generateGridColumnSpacingStyles, _gridGenerator.generateGridRowSpacingStyles, _gridGenerator.generateGridSizeStyles, _gridGenerator.generateGridDirectionStyles, _gridGenerator.generateGridStyles, _gridGenerator.generateGridOffsetStyles);
59
82
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
60
83
  var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin;
@@ -69,25 +92,16 @@ function createGrid(options = {}) {
69
92
  component = 'div',
70
93
  direction = 'row',
71
94
  wrap = 'wrap',
95
+ size: sizeProp = {},
96
+ offset: offsetProp = {},
72
97
  spacing: spacingProp = 0,
73
98
  rowSpacing: rowSpacingProp = spacingProp,
74
99
  columnSpacing: columnSpacingProp = spacingProp,
75
100
  unstable_level: level = 0,
76
101
  ...rest
77
102
  } = props;
78
- // collect breakpoints related props because they can be customized from the theme.
79
- const gridSize = {};
80
- const gridOffset = {};
81
- const other = {};
82
- Object.entries(rest).forEach(([key, val]) => {
83
- if (theme.breakpoints.values[key] !== undefined) {
84
- gridSize[key] = val;
85
- } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
86
- gridOffset[key.replace('Offset', '')] = val;
87
- } else {
88
- other[key] = val;
89
- }
90
- });
103
+ const size = parseResponsiveProp(sizeProp, theme.breakpoints, val => val !== false);
104
+ const offset = parseResponsiveProp(offsetProp, theme.breakpoints);
91
105
  const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : level ? undefined : columnsProp;
92
106
  const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : level ? undefined : spacingProp;
93
107
  const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : level ? undefined : rowSpacingProp;
@@ -102,8 +116,8 @@ function createGrid(options = {}) {
102
116
  spacing,
103
117
  rowSpacing,
104
118
  columnSpacing,
105
- gridSize,
106
- gridOffset
119
+ size,
120
+ offset
107
121
  };
108
122
  const classes = useUtilityClasses(ownerState, theme);
109
123
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridRoot, {
@@ -111,7 +125,7 @@ function createGrid(options = {}) {
111
125
  as: component,
112
126
  ownerState: ownerState,
113
127
  className: (0, _clsx.default)(classes.root, className),
114
- ...other,
128
+ ...rest,
115
129
  children: React.Children.map(children, child => {
116
130
  if ( /*#__PURE__*/React.isValidElement(child) && (0, _isMuiElement.default)(child, ['Grid'])) {
117
131
  var _unstable_level;
@@ -131,20 +145,12 @@ function createGrid(options = {}) {
131
145
  component: _propTypes.default.elementType,
132
146
  container: _propTypes.default.bool,
133
147
  direction: _propTypes.default.oneOfType([_propTypes.default.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), _propTypes.default.arrayOf(_propTypes.default.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), _propTypes.default.object]),
134
- lg: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
135
- lgOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
136
- md: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
137
- mdOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
148
+ offset: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])), _propTypes.default.object]),
138
149
  rowSpacing: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.string]),
139
- sm: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
140
- smOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
150
+ size: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool, _propTypes.default.number])), _propTypes.default.object]),
141
151
  spacing: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])), _propTypes.default.number, _propTypes.default.object, _propTypes.default.string]),
142
152
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
143
- wrap: _propTypes.default.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
144
- xl: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
145
- xlOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]),
146
- xs: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number, _propTypes.default.bool]),
147
- xsOffset: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number])
153
+ wrap: _propTypes.default.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
148
154
  } : void 0;
149
155
 
150
156
  // @ts-ignore internal logic for nested grid
@@ -14,7 +14,7 @@ function getGridUtilityClass(slot) {
14
14
  const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
15
15
  const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
16
16
  const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
17
- const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
17
+ const GRID_SIZES = ['auto', 'grow', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
18
18
  const gridClasses = (0, _generateUtilityClasses.default)('MuiGrid', ['root', 'container', 'item',
19
19
  // spacings
20
20
  ...SPACINGS.map(spacing => `spacing-xs-${spacing}`),
@@ -39,9 +39,9 @@ const generateGridSizeStyles = ({
39
39
  }) => {
40
40
  const getParentSpacing = createGetParentSpacing(ownerState);
41
41
  const styles = {};
42
- (0, _traverseBreakpoints.traverseBreakpoints)(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
42
+ (0, _traverseBreakpoints.traverseBreakpoints)(theme.breakpoints, ownerState.size, (appendStyle, value) => {
43
43
  let style = {};
44
- if (value === true) {
44
+ if (value === 'grow') {
45
45
  style = {
46
46
  flexBasis: 0,
47
47
  flexGrow: 1,
@@ -75,7 +75,7 @@ const generateGridOffsetStyles = ({
75
75
  }) => {
76
76
  const getParentSpacing = createGetParentSpacing(ownerState);
77
77
  const styles = {};
78
- (0, _traverseBreakpoints.traverseBreakpoints)(theme.breakpoints, ownerState.gridOffset, (appendStyle, value) => {
78
+ (0, _traverseBreakpoints.traverseBreakpoints)(theme.breakpoints, ownerState.offset, (appendStyle, value) => {
79
79
  let style = {};
80
80
  if (value === 'auto') {
81
81
  style = {
@@ -190,9 +190,9 @@ const generateGridStyles = ({
190
190
  };
191
191
  };
192
192
  exports.generateGridStyles = generateGridStyles;
193
- const generateSizeClassNames = gridSize => {
193
+ const generateSizeClassNames = size => {
194
194
  const classNames = [];
195
- Object.entries(gridSize).forEach(([key, value]) => {
195
+ Object.entries(size).forEach(([key, value]) => {
196
196
  if (value !== false && value !== undefined) {
197
197
  classNames.push(`grid-${key}-${String(value)}`);
198
198
  }
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v6.0.0-alpha.12
2
+ * @mui/system v6.0.0-alpha.14
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "6.0.0-alpha.12",
3
+ "version": "6.0.0-alpha.14",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
@@ -30,10 +30,10 @@
30
30
  "clsx": "^2.1.1",
31
31
  "csstype": "^3.1.3",
32
32
  "prop-types": "^15.8.1",
33
- "@mui/private-theming": "^6.0.0-alpha.12",
33
+ "@mui/private-theming": "6.0.0-alpha.14",
34
34
  "@mui/types": "^7.2.14",
35
- "@mui/utils": "^6.0.0-alpha.12",
36
- "@mui/styled-engine": "^6.0.0-alpha.12"
35
+ "@mui/styled-engine": "6.0.0-alpha.14",
36
+ "@mui/utils": "6.0.0-alpha.14"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@emotion/react": "^11.5.0",