@mui/system 5.11.7 → 5.11.9

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 (43) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +128 -1
  3. package/Container/Container.d.ts +13 -13
  4. package/Container/ContainerProps.d.ts +40 -40
  5. package/Container/containerClasses.d.ts +22 -22
  6. package/Container/createContainer.d.ts +18 -18
  7. package/Stack/Stack.d.ts +13 -13
  8. package/Stack/StackProps.d.ts +42 -42
  9. package/Stack/createStack.d.ts +21 -21
  10. package/Stack/index.d.ts +5 -5
  11. package/Stack/stackClasses.d.ts +8 -8
  12. package/Unstable_Grid/Grid.d.ts +12 -12
  13. package/Unstable_Grid/GridProps.d.ts +173 -162
  14. package/Unstable_Grid/createGrid.d.ts +11 -11
  15. package/Unstable_Grid/createGrid.js +10 -10
  16. package/Unstable_Grid/gridClasses.d.ts +20 -20
  17. package/Unstable_Grid/gridGenerator.d.ts +33 -29
  18. package/Unstable_Grid/gridGenerator.js +40 -18
  19. package/Unstable_Grid/index.d.ts +5 -5
  20. package/createBox.spec.d.ts +1 -1
  21. package/createTheme/createSpacing.d.ts +10 -10
  22. package/cssVars/createCssVarsProvider.js +7 -7
  23. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  24. package/cssVars/createGetCssVar.d.ts +5 -5
  25. package/cssVars/cssVarsParser.d.ts +63 -63
  26. package/cssVars/getInitColorSchemeScript.d.ts +42 -42
  27. package/cssVars/index.d.ts +3 -3
  28. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  29. package/esm/Unstable_Grid/createGrid.js +10 -10
  30. package/esm/Unstable_Grid/gridGenerator.js +40 -18
  31. package/esm/cssVars/createCssVarsProvider.js +7 -7
  32. package/index.js +1 -1
  33. package/index.spec.d.ts +1 -1
  34. package/legacy/Unstable_Grid/createGrid.js +10 -10
  35. package/legacy/Unstable_Grid/gridGenerator.js +53 -42
  36. package/legacy/cssVars/createCssVarsProvider.js +7 -7
  37. package/legacy/index.js +1 -1
  38. package/modern/Unstable_Grid/createGrid.js +10 -10
  39. package/modern/Unstable_Grid/gridGenerator.js +40 -18
  40. package/modern/cssVars/createCssVarsProvider.js +7 -7
  41. package/modern/index.js +1 -1
  42. package/package.json +5 -5
  43. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -1,162 +1,173 @@
1
- import * as React from 'react';
2
- import { OverrideProps, IfEquals } from '@mui/types';
3
- import { SxProps } from '../styleFunctionSx';
4
- import { Theme, Breakpoint, BreakpointOverrides } from '../createTheme';
5
- import { SystemProps } from '../Box';
6
- type ResponsiveStyleValue<T> = T | Array<T | null> | {
7
- [key in Breakpoint]?: T | null;
8
- };
9
- export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
10
- export type GridSpacing = number | string;
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 {
100
- /**
101
- * The content of the component.
102
- */
103
- children?: React.ReactNode;
104
- /**
105
- * The number of columns.
106
- * @default 12
107
- */
108
- columns?: ResponsiveStyleValue<number>;
109
- /**
110
- * Defines the horizontal space between the type `item` components.
111
- * It overrides the value of the `spacing` prop.
112
- */
113
- columnSpacing?: ResponsiveStyleValue<GridSpacing>;
114
- /**
115
- * If `true`, the component will have the flex *container* behavior.
116
- * You should be wrapping *items* with a *container*.
117
- * @default false
118
- */
119
- container?: boolean;
120
- /**
121
- * Defines the `flex-direction` style property.
122
- * It is applied for all screen sizes.
123
- * @default 'row'
124
- */
125
- direction?: ResponsiveStyleValue<GridDirection>;
126
- /**
127
- * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
128
- */
129
- disableEqualOverflow?: boolean;
130
- /**
131
- * Defines the vertical space between the type `item` components.
132
- * It overrides the value of the `spacing` prop.
133
- */
134
- rowSpacing?: ResponsiveStyleValue<GridSpacing>;
135
- /**
136
- * Defines the space between the type `item` components.
137
- * It can only be used on a type `container` component.
138
- * @default 0
139
- */
140
- spacing?: ResponsiveStyleValue<GridSpacing> | undefined;
141
- /**
142
- * Defines the `flex-wrap` style property.
143
- * It's applied for all screen sizes.
144
- * @default 'wrap'
145
- */
146
- wrap?: GridWrap;
147
- }
148
- export interface GridOwnerState extends GridBaseProps {
149
- nested: boolean;
150
- gridSize: Partial<Record<Breakpoint, GridSize | boolean>>;
151
- gridOffset: Partial<Record<Breakpoint, GridSize>>;
152
- }
153
- export interface GridTypeMap<P = {}, D extends React.ElementType = 'div'> {
154
- props: P & GridBaseProps & {
155
- sx?: SxProps<Theme>;
156
- } & SystemProps<Theme>;
157
- defaultComponent: D;
158
- }
159
- export type GridProps<D extends React.ElementType = GridTypeMap['defaultComponent'], P = {
160
- component?: React.ElementType;
161
- }> = OverrideProps<GridTypeMap<P, D>, D>;
162
- export {};
1
+ import * as React from 'react';
2
+ import { OverrideProps, IfEquals } from '@mui/types';
3
+ import { SxProps } from '../styleFunctionSx';
4
+ import { Theme, Breakpoint, BreakpointOverrides } from '../createTheme';
5
+ import { SystemProps } from '../Box';
6
+ type ResponsiveStyleValue<T> = T | Array<T | null> | {
7
+ [key in Breakpoint]?: T | null;
8
+ };
9
+ export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
10
+ export type GridSpacing = number | string;
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 {
100
+ /**
101
+ * The content of the component.
102
+ */
103
+ children?: React.ReactNode;
104
+ /**
105
+ * The number of columns.
106
+ * @default 12
107
+ */
108
+ columns?: ResponsiveStyleValue<number>;
109
+ /**
110
+ * Defines the horizontal space between the type `item` components.
111
+ * It overrides the value of the `spacing` prop.
112
+ */
113
+ columnSpacing?: ResponsiveStyleValue<GridSpacing>;
114
+ /**
115
+ * If `true`, the component will have the flex *container* behavior.
116
+ * You should be wrapping *items* with a *container*.
117
+ * @default false
118
+ */
119
+ container?: boolean;
120
+ /**
121
+ * Defines the `flex-direction` style property.
122
+ * It is applied for all screen sizes.
123
+ * @default 'row'
124
+ */
125
+ direction?: ResponsiveStyleValue<GridDirection>;
126
+ /**
127
+ * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
128
+ */
129
+ disableEqualOverflow?: boolean;
130
+ /**
131
+ * Defines the vertical space between the type `item` components.
132
+ * It overrides the value of the `spacing` prop.
133
+ */
134
+ rowSpacing?: ResponsiveStyleValue<GridSpacing>;
135
+ /**
136
+ * Defines the space between the type `item` components.
137
+ * It can only be used on a type `container` component.
138
+ * @default 0
139
+ */
140
+ spacing?: ResponsiveStyleValue<GridSpacing> | undefined;
141
+ /**
142
+ * Defines the `flex-wrap` style property.
143
+ * It's applied for all screen sizes.
144
+ * @default 'wrap'
145
+ */
146
+ wrap?: GridWrap;
147
+ }
148
+ export interface GridOwnerState extends GridBaseProps {
149
+ /**
150
+ * The level of the grid starts from `0`
151
+ * and increases when the grid nests inside another grid regardless of container or item.
152
+ *
153
+ * ```js
154
+ * <Grid> // level 0
155
+ * <Grid> // level 1
156
+ * <Grid> // level 2
157
+ * <Grid> // level 1
158
+ * ```
159
+ */
160
+ level: number;
161
+ gridSize: Partial<Record<Breakpoint, GridSize | boolean>>;
162
+ gridOffset: Partial<Record<Breakpoint, GridSize>>;
163
+ }
164
+ export interface GridTypeMap<P = {}, D extends React.ElementType = 'div'> {
165
+ props: P & GridBaseProps & {
166
+ sx?: SxProps<Theme>;
167
+ } & SystemProps<Theme>;
168
+ defaultComponent: D;
169
+ }
170
+ export type GridProps<D extends React.ElementType = GridTypeMap['defaultComponent'], P = {
171
+ component?: React.ElementType;
172
+ }> = OverrideProps<GridTypeMap<P, D>, D>;
173
+ export {};
@@ -1,11 +1,11 @@
1
- import * as React from 'react';
2
- import { OverridableComponent } from '@mui/types';
3
- import { GridTypeMap } from './GridProps';
4
- declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
5
- declare function useThemePropsDefault<T extends {}>(props: T): T & {};
6
- export default function createGrid(options?: {
7
- createStyledComponent?: typeof defaultCreateStyledComponent;
8
- useThemeProps?: typeof useThemePropsDefault;
9
- componentName?: string;
10
- }): OverridableComponent<GridTypeMap<{}, "div">>;
11
- export {};
1
+ import * as React from 'react';
2
+ import { OverridableComponent } from '@mui/types';
3
+ import { GridTypeMap } from './GridProps';
4
+ declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
5
+ declare function useThemePropsDefault<T extends {}>(props: T): T & {};
6
+ export default function createGrid(options?: {
7
+ createStyledComponent?: typeof defaultCreateStyledComponent;
8
+ useThemeProps?: typeof useThemePropsDefault;
9
+ componentName?: string;
10
+ }): OverridableComponent<GridTypeMap<{}, "div">>;
11
+ export {};
@@ -43,7 +43,7 @@ function createGrid(options = {}) {
43
43
  useThemeProps = useThemePropsDefault,
44
44
  componentName = 'MuiGrid'
45
45
  } = options;
46
- const NestedContext = /*#__PURE__*/React.createContext(false);
46
+ const NestedContext = /*#__PURE__*/React.createContext(0);
47
47
  const OverflowContext = /*#__PURE__*/React.createContext(undefined);
48
48
  const useUtilityClasses = (ownerState, theme) => {
49
49
  const {
@@ -64,7 +64,7 @@ function createGrid(options = {}) {
64
64
  const theme = (0, _useTheme.default)();
65
65
  const themeProps = useThemeProps(inProps);
66
66
  const props = (0, _styleFunctionSx.extendSxProp)(themeProps); // `color` type conflicts with html color attribute.
67
- const nested = React.useContext(NestedContext);
67
+ const level = React.useContext(NestedContext);
68
68
  const overflow = React.useContext(OverflowContext);
69
69
  const {
70
70
  className,
@@ -81,7 +81,7 @@ function createGrid(options = {}) {
81
81
  rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
82
82
  // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
83
83
  let disableEqualOverflow = themeDisableEqualOverflow;
84
- if (nested && themeDisableEqualOverflow !== undefined) {
84
+ if (level && themeDisableEqualOverflow !== undefined) {
85
85
  disableEqualOverflow = inProps.disableEqualOverflow;
86
86
  }
87
87
  // collect breakpoints related props because they can be customized from the theme.
@@ -97,12 +97,12 @@ function createGrid(options = {}) {
97
97
  other[key] = val;
98
98
  }
99
99
  });
100
- const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : nested ? undefined : columnsProp;
101
- const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : nested ? undefined : spacingProp;
102
- const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : nested ? undefined : rowSpacingProp;
103
- const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : nested ? undefined : columnSpacingProp;
100
+ const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : level ? undefined : columnsProp;
101
+ const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : level ? undefined : spacingProp;
102
+ const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : level ? undefined : rowSpacingProp;
103
+ const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : level ? undefined : columnSpacingProp;
104
104
  const ownerState = (0, _extends2.default)({}, props, {
105
- nested,
105
+ level,
106
106
  columns,
107
107
  container,
108
108
  direction,
@@ -124,9 +124,9 @@ function createGrid(options = {}) {
124
124
  ownerState: ownerState,
125
125
  className: (0, _clsx.default)(classes.root, className)
126
126
  }, other));
127
- if (!nested) {
127
+ if (container) {
128
128
  result = /*#__PURE__*/(0, _jsxRuntime.jsx)(NestedContext.Provider, {
129
- value: true,
129
+ value: level + 1,
130
130
  children: result
131
131
  });
132
132
  }
@@ -1,20 +1,20 @@
1
- export interface GridClasses {
2
- /** Styles applied to the root element. */
3
- root: string;
4
- /** Styles applied to the root element if `container={true}`. */
5
- container: string;
6
- /** Styles applied to the root element if `direction="column"`. */
7
- 'direction-xs-column': string;
8
- /** Styles applied to the root element if `direction="column-reverse"`. */
9
- 'direction-xs-column-reverse': string;
10
- /** Styles applied to the root element if `direction="row-reverse"`. */
11
- 'direction-xs-row-reverse': string;
12
- /** Styles applied to the root element if `wrap="nowrap"`. */
13
- 'wrap-xs-nowrap': string;
14
- /** Styles applied to the root element if `wrap="reverse"`. */
15
- 'wrap-xs-wrap-reverse': string;
16
- }
17
- export type GridClassKey = keyof GridClasses;
18
- export declare function getGridUtilityClass(slot: string): string;
19
- declare const gridClasses: GridClasses;
20
- export default gridClasses;
1
+ export interface GridClasses {
2
+ /** Styles applied to the root element. */
3
+ root: string;
4
+ /** Styles applied to the root element if `container={true}`. */
5
+ container: string;
6
+ /** Styles applied to the root element if `direction="column"`. */
7
+ 'direction-xs-column': string;
8
+ /** Styles applied to the root element if `direction="column-reverse"`. */
9
+ 'direction-xs-column-reverse': string;
10
+ /** Styles applied to the root element if `direction="row-reverse"`. */
11
+ 'direction-xs-row-reverse': string;
12
+ /** Styles applied to the root element if `wrap="nowrap"`. */
13
+ 'wrap-xs-nowrap': string;
14
+ /** Styles applied to the root element if `wrap="reverse"`. */
15
+ 'wrap-xs-wrap-reverse': string;
16
+ }
17
+ export type GridClassKey = keyof GridClasses;
18
+ export declare function getGridUtilityClass(slot: string): string;
19
+ declare const gridClasses: GridClasses;
20
+ export default gridClasses;
@@ -1,29 +1,33 @@
1
- import { Breakpoints, Breakpoint } from '../createTheme/createBreakpoints';
2
- import { Spacing } from '../createTheme/createSpacing';
3
- import { ResponsiveStyleValue } from '../styleFunctionSx';
4
- import { GridDirection, GridOwnerState } from './GridProps';
5
- interface Props {
6
- theme: {
7
- breakpoints: Breakpoints;
8
- spacing?: Spacing;
9
- };
10
- ownerState: GridOwnerState & {
11
- parentDisableEqualOverflow?: boolean;
12
- };
13
- }
14
- interface Iterator<T> {
15
- (appendStyle: (responsiveStyles: Record<string, any>, style: object) => void, value: T): void;
16
- }
17
- export declare const filterBreakpointKeys: (breakpointsKeys: Breakpoint[], responsiveKeys: string[]) => Breakpoint[];
18
- export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsive: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
19
- export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
20
- export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
21
- export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {};
22
- export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {};
23
- export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {};
24
- export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
25
- export declare const generateGridStyles: ({ ownerState }: Props) => {};
26
- export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
27
- export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
28
- export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
29
- export {};
1
+ import { Breakpoints, Breakpoint } from '../createTheme/createBreakpoints';
2
+ import { Spacing } from '../createTheme/createSpacing';
3
+ import { ResponsiveStyleValue } from '../styleFunctionSx';
4
+ import { GridDirection, GridOwnerState } from './GridProps';
5
+ interface Props {
6
+ theme: {
7
+ breakpoints: Breakpoints;
8
+ spacing?: Spacing;
9
+ };
10
+ ownerState: GridOwnerState & {
11
+ parentDisableEqualOverflow?: boolean;
12
+ };
13
+ }
14
+ interface Iterator<T> {
15
+ (appendStyle: (responsiveStyles: Record<string, any>, style: object) => void, value: T): void;
16
+ }
17
+ export declare const filterBreakpointKeys: (breakpointsKeys: Breakpoint[], responsiveKeys: string[]) => Breakpoint[];
18
+ export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsive: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
19
+ export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
20
+ export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
21
+ export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {};
22
+ export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {
23
+ [x: string]: string;
24
+ };
25
+ export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {
26
+ [x: string]: string;
27
+ };
28
+ export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
29
+ export declare const generateGridStyles: ({ ownerState }: Props) => {};
30
+ export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
31
+ export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
32
+ export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
33
+ export {};
@@ -6,6 +6,22 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.traverseBreakpoints = exports.generateSpacingClassNames = exports.generateSizeClassNames = exports.generateGridStyles = exports.generateGridSizeStyles = exports.generateGridRowSpacingStyles = exports.generateGridOffsetStyles = exports.generateGridDirectionStyles = exports.generateGridColumnsStyles = exports.generateGridColumnSpacingStyles = exports.generateDirectionClasses = exports.filterBreakpointKeys = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ function isNestedContainer(ownerState) {
10
+ return ownerState.level > 0 && ownerState.container;
11
+ }
12
+ function createGetSelfSpacing(ownerState) {
13
+ return function getSelfSpacing(axis) {
14
+ return `var(--Grid-${axis}Spacing${ownerState.level || ''})`;
15
+ };
16
+ }
17
+ function createGetParentSpacing(ownerState) {
18
+ return function getParentSpacing(axis) {
19
+ if (ownerState.level === 0) {
20
+ return `var(--Grid-${axis}Spacing)`;
21
+ }
22
+ return `var(--Grid-${axis}Spacing${ownerState.level - 1 || ''})`;
23
+ };
24
+ }
9
25
  const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
10
26
  exports.filterBreakpointKeys = filterBreakpointKeys;
11
27
  const traverseBreakpoints = (breakpoints, responsive, iterator) => {
@@ -54,6 +70,7 @@ const generateGridSizeStyles = ({
54
70
  theme,
55
71
  ownerState
56
72
  }) => {
73
+ const getSelfSpacing = createGetSelfSpacing(ownerState);
57
74
  const styles = {};
58
75
  traverseBreakpoints(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
59
76
  let style = {};
@@ -77,7 +94,7 @@ const generateGridSizeStyles = ({
77
94
  style = {
78
95
  flexGrow: 0,
79
96
  flexBasis: 'auto',
80
- width: `calc(100% * ${value} / var(--Grid-columns)${ownerState.nested && ownerState.container ? ` + var(--Grid-columnSpacing)` : ''})`
97
+ width: `calc(100% * ${value} / var(--Grid-columns)${isNestedContainer(ownerState) ? ` + ${getSelfSpacing('column')}` : ''})`
81
98
  };
82
99
  }
83
100
  appendStyle(styles, style);
@@ -132,11 +149,16 @@ const generateGridRowSpacingStyles = ({
132
149
  if (!ownerState.container) {
133
150
  return {};
134
151
  }
135
- const styles = {};
152
+ const getParentSpacing = createGetParentSpacing(ownerState);
153
+ const styles = isNestedContainer(ownerState) ? {
154
+ // Set the default spacing as its parent spacing.
155
+ // It will be overridden if spacing props are provided
156
+ [`--Grid-rowSpacing${ownerState.level || ''}`]: getParentSpacing('row')
157
+ } : {};
136
158
  traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
137
159
  var _theme$spacing;
138
160
  appendStyle(styles, {
139
- '--Grid-rowSpacing': typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
161
+ [`--Grid-rowSpacing${ownerState.level || ''}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
140
162
  });
141
163
  });
142
164
  return styles;
@@ -149,11 +171,16 @@ const generateGridColumnSpacingStyles = ({
149
171
  if (!ownerState.container) {
150
172
  return {};
151
173
  }
152
- const styles = {};
174
+ const getParentSpacing = createGetParentSpacing(ownerState);
175
+ const styles = isNestedContainer(ownerState) ? {
176
+ // Set the default spacing as its parent spacing.
177
+ // It will be overridden if spacing props are provided
178
+ [`--Grid-columnSpacing${ownerState.level || ''}`]: getParentSpacing('column')
179
+ } : {};
153
180
  traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
154
181
  var _theme$spacing2;
155
182
  appendStyle(styles, {
156
- '--Grid-columnSpacing': typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
183
+ [`--Grid-columnSpacing${ownerState.level || ''}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
157
184
  });
158
185
  });
159
186
  return styles;
@@ -178,29 +205,24 @@ exports.generateGridDirectionStyles = generateGridDirectionStyles;
178
205
  const generateGridStyles = ({
179
206
  ownerState
180
207
  }) => {
208
+ const getSelfSpacing = createGetSelfSpacing(ownerState);
209
+ const getParentSpacing = createGetParentSpacing(ownerState);
181
210
  return (0, _extends2.default)({
182
211
  minWidth: 0,
183
212
  boxSizing: 'border-box'
184
- }, ownerState.container ? (0, _extends2.default)({
213
+ }, ownerState.container && (0, _extends2.default)({
185
214
  display: 'flex',
186
215
  flexWrap: 'wrap'
187
216
  }, ownerState.wrap && ownerState.wrap !== 'wrap' && {
188
217
  flexWrap: ownerState.wrap
189
218
  }, {
190
- margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
219
+ margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`
191
220
  }, ownerState.disableEqualOverflow && {
192
- margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
193
- }, ownerState.nested ? (0, _extends2.default)({
194
- padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
221
+ margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
222
+ }), (!ownerState.container || isNestedContainer(ownerState)) && (0, _extends2.default)({
223
+ padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`
195
224
  }, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
196
- padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
197
- }) : {
198
- '--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
199
- '--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
200
- }) : (0, _extends2.default)({
201
- padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
202
- }, ownerState.disableEqualOverflow && {
203
- padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
225
+ padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
204
226
  }));
205
227
  };
206
228
  exports.generateGridStyles = generateGridStyles;