@mui/system 5.9.0 → 5.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/Box/Box.spec.d.ts +1 -1
  2. package/CHANGELOG.md +196 -6
  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/Unstable_Grid/Grid.d.ts +12 -12
  8. package/Unstable_Grid/Grid.js +5 -0
  9. package/Unstable_Grid/GridProps.d.ts +162 -158
  10. package/Unstable_Grid/createGrid.d.ts +11 -11
  11. package/Unstable_Grid/createGrid.js +30 -5
  12. package/Unstable_Grid/gridClasses.d.ts +20 -20
  13. package/Unstable_Grid/gridGenerator.d.ts +26 -26
  14. package/Unstable_Grid/gridGenerator.js +10 -4
  15. package/Unstable_Grid/index.d.ts +5 -5
  16. package/breakpoints.js +1 -1
  17. package/createBox.spec.d.ts +1 -1
  18. package/createTheme/createSpacing.d.ts +10 -10
  19. package/cssVars/createCssVarsProvider.js +1 -1
  20. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  21. package/cssVars/createGetCssVar.d.ts +5 -5
  22. package/cssVars/cssVarsParser.d.ts +65 -65
  23. package/cssVars/getInitColorSchemeScript.d.ts +45 -45
  24. package/cssVars/index.d.ts +3 -3
  25. package/cssVars/useCurrentColorScheme.d.ts +53 -53
  26. package/esm/Unstable_Grid/Grid.js +5 -0
  27. package/esm/Unstable_Grid/createGrid.js +30 -5
  28. package/esm/Unstable_Grid/gridGenerator.js +10 -4
  29. package/esm/breakpoints.js +1 -1
  30. package/esm/cssVars/createCssVarsProvider.js +1 -1
  31. package/index.js +1 -1
  32. package/index.spec.d.ts +1 -1
  33. package/legacy/Unstable_Grid/Grid.js +5 -0
  34. package/legacy/Unstable_Grid/createGrid.js +28 -3
  35. package/legacy/Unstable_Grid/gridGenerator.js +10 -4
  36. package/legacy/breakpoints.js +1 -1
  37. package/legacy/cssVars/createCssVarsProvider.js +1 -1
  38. package/legacy/index.js +1 -1
  39. package/modern/Unstable_Grid/Grid.js +5 -0
  40. package/modern/Unstable_Grid/createGrid.js +29 -4
  41. package/modern/Unstable_Grid/gridGenerator.js +10 -4
  42. package/modern/breakpoints.js +1 -1
  43. package/modern/cssVars/createCssVarsProvider.js +1 -1
  44. package/modern/index.js +1 -1
  45. package/package.json +4 -4
  46. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -1,65 +1,65 @@
1
- declare type NestedRecord<V = any> = {
2
- [k: string | number]: NestedRecord<V> | V;
3
- };
4
- /**
5
- * This function create an object from keys, value and then assign to target
6
- *
7
- * @param {Object} obj : the target object to be assigned
8
- * @param {string[]} keys
9
- * @param {string | number} value
10
- *
11
- * @example
12
- * const source = {}
13
- * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
- * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
- *
16
- * @example
17
- * const source = { palette: { primary: 'var(--palette-primary)' } }
18
- * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
- * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
- */
21
- export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
22
- /**
23
- *
24
- * @param {Object} obj : source object
25
- * @param {Function} callback : a function that will be called when
26
- * - the deepest key in source object is reached
27
- * - the value of the deepest key is NOT `undefined` | `null`
28
- *
29
- * @example
30
- * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
- * // ['palette', 'primary', 'main'] '#000000'
32
- */
33
- export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
- /**
35
- * a function that parse theme and return { css, vars }
36
- *
37
- * @param {Object} theme
38
- * @param {{
39
- * prefix?: string,
40
- * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
41
- * }} options.
42
- * `prefix`: The prefix of the generated CSS variables. This function does not change the value.
43
- *
44
- * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
45
- *
46
- * @example
47
- * const { css, vars, parsedTheme } = parser({
48
- * fontSize: 12,
49
- * lineHeight: 1.2,
50
- * palette: { primary: { 500: 'var(--color)' } }
51
- * }, { prefix: 'foo' })
52
- *
53
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
54
- * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
55
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
56
- */
57
- export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
58
- prefix?: string;
59
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
60
- }): {
61
- css: NestedRecord<string>;
62
- vars: NestedRecord<string>;
63
- parsedTheme: T;
64
- };
65
- export {};
1
+ declare type NestedRecord<V = any> = {
2
+ [k: string | number]: NestedRecord<V> | V;
3
+ };
4
+ /**
5
+ * This function create an object from keys, value and then assign to target
6
+ *
7
+ * @param {Object} obj : the target object to be assigned
8
+ * @param {string[]} keys
9
+ * @param {string | number} value
10
+ *
11
+ * @example
12
+ * const source = {}
13
+ * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
+ *
16
+ * @example
17
+ * const source = { palette: { primary: 'var(--palette-primary)' } }
18
+ * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
+ */
21
+ export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
22
+ /**
23
+ *
24
+ * @param {Object} obj : source object
25
+ * @param {Function} callback : a function that will be called when
26
+ * - the deepest key in source object is reached
27
+ * - the value of the deepest key is NOT `undefined` | `null`
28
+ *
29
+ * @example
30
+ * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
+ * // ['palette', 'primary', 'main'] '#000000'
32
+ */
33
+ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
+ /**
35
+ * a function that parse theme and return { css, vars }
36
+ *
37
+ * @param {Object} theme
38
+ * @param {{
39
+ * prefix?: string,
40
+ * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
41
+ * }} options.
42
+ * `prefix`: The prefix of the generated CSS variables. This function does not change the value.
43
+ *
44
+ * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
45
+ *
46
+ * @example
47
+ * const { css, vars, parsedTheme } = parser({
48
+ * fontSize: 12,
49
+ * lineHeight: 1.2,
50
+ * palette: { primary: { 500: 'var(--color)' } }
51
+ * }, { prefix: 'foo' })
52
+ *
53
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
54
+ * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
55
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
56
+ */
57
+ export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
58
+ prefix?: string;
59
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
60
+ }): {
61
+ css: NestedRecord<string>;
62
+ vars: NestedRecord<string>;
63
+ parsedTheme: T;
64
+ };
65
+ export {};
@@ -1,45 +1,45 @@
1
- /// <reference types="react" />
2
- export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
3
- export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
4
- export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
5
- export interface GetInitColorSchemeScriptOptions {
6
- /**
7
- * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
8
- * @default true
9
- */
10
- enableColorScheme?: boolean;
11
- /**
12
- * If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
13
- * @default false
14
- */
15
- enableSystem?: boolean;
16
- /**
17
- * The default color scheme to be used on the light mode
18
- */
19
- defaultLightColorScheme?: string;
20
- /**
21
- * The default color scheme to be used on the dark mode
22
- */
23
- defaultDarkColorScheme?: string;
24
- /**
25
- * The node (provided as string) used to attach the color-scheme attribute
26
- * @default 'document.documentElement'
27
- */
28
- colorSchemeNode?: string;
29
- /**
30
- * localStorage key used to store `mode`
31
- * @default 'mode'
32
- */
33
- modeStorageKey?: string;
34
- /**
35
- * localStorage key used to store `colorScheme`
36
- * @default 'color-scheme'
37
- */
38
- colorSchemeStorageKey?: string;
39
- /**
40
- * DOM attribute for applying color scheme
41
- * @default 'data-color-scheme'
42
- */
43
- attribute?: string;
44
- }
45
- export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
3
+ export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
4
+ export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
5
+ export interface GetInitColorSchemeScriptOptions {
6
+ /**
7
+ * Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
8
+ * @default true
9
+ */
10
+ enableColorScheme?: boolean;
11
+ /**
12
+ * If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
13
+ * @default false
14
+ */
15
+ enableSystem?: boolean;
16
+ /**
17
+ * The default color scheme to be used on the light mode
18
+ */
19
+ defaultLightColorScheme?: string;
20
+ /**
21
+ * The default color scheme to be used on the dark mode
22
+ */
23
+ defaultDarkColorScheme?: string;
24
+ /**
25
+ * The node (provided as string) used to attach the color-scheme attribute
26
+ * @default 'document.documentElement'
27
+ */
28
+ colorSchemeNode?: string;
29
+ /**
30
+ * localStorage key used to store `mode`
31
+ * @default 'mode'
32
+ */
33
+ modeStorageKey?: string;
34
+ /**
35
+ * localStorage key used to store `colorScheme`
36
+ * @default 'color-scheme'
37
+ */
38
+ colorSchemeStorageKey?: string;
39
+ /**
40
+ * DOM attribute for applying color scheme
41
+ * @default 'data-color-scheme'
42
+ */
43
+ attribute?: string;
44
+ }
45
+ export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
@@ -1,3 +1,3 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
@@ -1,53 +1,53 @@
1
- export declare type Mode = 'light' | 'dark' | 'system';
2
- export declare type SystemMode = Exclude<Mode, 'system'>;
3
- export interface State<SupportedColorScheme extends string> {
4
- /**
5
- * User selected mode.
6
- * Note: on the server, mode is always undefined
7
- */
8
- mode: Mode | undefined;
9
- /**
10
- * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
- */
12
- systemMode: SystemMode | undefined;
13
- /**
14
- * The color scheme for the light mode.
15
- */
16
- lightColorScheme: SupportedColorScheme;
17
- /**
18
- * The color scheme for the dark mode.
19
- */
20
- darkColorScheme: SupportedColorScheme;
21
- }
22
- export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
- /**
24
- * The current application color scheme. It is always `undefined` on the server.
25
- */
26
- colorScheme: SupportedColorScheme | undefined;
27
- /**
28
- * `mode` is saved to internal state and localStorage
29
- * If `mode` is null, it will be reset to the defaultMode
30
- */
31
- setMode: (mode: Mode | null) => void;
32
- /**
33
- * `colorScheme` is saved to internal state and localStorage
34
- * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
- */
36
- setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
- light: SupportedColorScheme | null;
38
- dark: SupportedColorScheme | null;
39
- }> | null) => void;
40
- };
41
- export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
- export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
- interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
44
- defaultLightColorScheme: SupportedColorScheme;
45
- defaultDarkColorScheme: SupportedColorScheme;
46
- supportedColorSchemes: Array<SupportedColorScheme>;
47
- defaultMode?: Mode;
48
- modeStorageKey?: string;
49
- colorSchemeStorageKey?: string;
50
- storageWindow?: Window | null;
51
- }
52
- export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
53
- export {};
1
+ export declare type Mode = 'light' | 'dark' | 'system';
2
+ export declare type SystemMode = Exclude<Mode, 'system'>;
3
+ export interface State<SupportedColorScheme extends string> {
4
+ /**
5
+ * User selected mode.
6
+ * Note: on the server, mode is always undefined
7
+ */
8
+ mode: Mode | undefined;
9
+ /**
10
+ * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
+ */
12
+ systemMode: SystemMode | undefined;
13
+ /**
14
+ * The color scheme for the light mode.
15
+ */
16
+ lightColorScheme: SupportedColorScheme;
17
+ /**
18
+ * The color scheme for the dark mode.
19
+ */
20
+ darkColorScheme: SupportedColorScheme;
21
+ }
22
+ export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
+ /**
24
+ * The current application color scheme. It is always `undefined` on the server.
25
+ */
26
+ colorScheme: SupportedColorScheme | undefined;
27
+ /**
28
+ * `mode` is saved to internal state and localStorage
29
+ * If `mode` is null, it will be reset to the defaultMode
30
+ */
31
+ setMode: (mode: Mode | null) => void;
32
+ /**
33
+ * `colorScheme` is saved to internal state and localStorage
34
+ * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
+ */
36
+ setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
+ light: SupportedColorScheme | null;
38
+ dark: SupportedColorScheme | null;
39
+ }> | null) => void;
40
+ };
41
+ export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
+ export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
+ interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
44
+ defaultLightColorScheme: SupportedColorScheme;
45
+ defaultDarkColorScheme: SupportedColorScheme;
46
+ supportedColorSchemes: Array<SupportedColorScheme>;
47
+ defaultMode?: Mode;
48
+ modeStorageKey?: string;
49
+ colorSchemeStorageKey?: string;
50
+ storageWindow?: Window | null;
51
+ }
52
+ export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
53
+ export {};
@@ -57,6 +57,11 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes
57
57
  /* @typescript-to-proptypes-ignore */
58
58
  .oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
59
59
 
60
+ /**
61
+ * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
62
+ */
63
+ disableEqualOverflow: PropTypes.bool,
64
+
60
65
  /**
61
66
  * If a number, it sets the number of columns the grid item uses.
62
67
  * It can't be greater than the total number of columns of the container (12 by default).
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"];
3
+ const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -36,6 +36,7 @@ export default function createGrid(options = {}) {
36
36
  componentName = 'MuiGrid'
37
37
  } = options;
38
38
  const NestedContext = /*#__PURE__*/React.createContext(false);
39
+ const OverflowContext = /*#__PURE__*/React.createContext(undefined);
39
40
 
40
41
  const useUtilityClasses = (ownerState, theme) => {
41
42
  const {
@@ -53,13 +54,14 @@ export default function createGrid(options = {}) {
53
54
 
54
55
  const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
55
56
  const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
56
- var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin;
57
+ var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin, _ref3, _disableEqualOverflow;
57
58
 
58
59
  const theme = useTheme();
59
60
  const themeProps = useThemeProps(inProps);
60
61
  const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
61
62
 
62
63
  const nested = React.useContext(NestedContext);
64
+ const overflow = React.useContext(OverflowContext);
63
65
 
64
66
  const {
65
67
  className,
@@ -70,9 +72,17 @@ export default function createGrid(options = {}) {
70
72
  wrap = 'wrap',
71
73
  spacing: spacingProp = 0,
72
74
  rowSpacing: rowSpacingProp = spacingProp,
73
- columnSpacing: columnSpacingProp = spacingProp
75
+ columnSpacing: columnSpacingProp = spacingProp,
76
+ disableEqualOverflow: themeDisableEqualOverflow
74
77
  } = props,
75
- rest = _objectWithoutPropertiesLoose(props, _excluded); // collect breakpoints related props because they can be custom from the theme.
78
+ rest = _objectWithoutPropertiesLoose(props, _excluded); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
79
+
80
+
81
+ let disableEqualOverflow = themeDisableEqualOverflow;
82
+
83
+ if (nested && themeDisableEqualOverflow !== undefined) {
84
+ disableEqualOverflow = inProps.disableEqualOverflow;
85
+ } // collect breakpoints related props because they can be customized from the theme.
76
86
 
77
87
 
78
88
  const gridSize = {};
@@ -102,7 +112,11 @@ export default function createGrid(options = {}) {
102
112
  rowSpacing,
103
113
  columnSpacing,
104
114
  gridSize,
105
- gridOffset
115
+ gridOffset,
116
+ disableEqualOverflow: (_ref3 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref3 : false,
117
+ // use context value if exists.
118
+ parentDisableEqualOverflow: overflow // for nested grid
119
+
106
120
  });
107
121
 
108
122
  const classes = useUtilityClasses(ownerState, theme);
@@ -121,6 +135,16 @@ export default function createGrid(options = {}) {
121
135
  });
122
136
  }
123
137
 
138
+ if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
139
+ // There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
140
+ // 1. It is the root grid with `disableEqualOverflow`.
141
+ // 2. It is a nested grid with different `disableEqualOverflow` from the context.
142
+ result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
143
+ value: disableEqualOverflow,
144
+ children: result
145
+ });
146
+ }
147
+
124
148
  return result;
125
149
  });
126
150
  process.env.NODE_ENV !== "production" ? Grid.propTypes
@@ -133,6 +157,7 @@ export default function createGrid(options = {}) {
133
157
  component: PropTypes.elementType,
134
158
  container: PropTypes.bool,
135
159
  direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
160
+ disableEqualOverflow: PropTypes.bool,
136
161
  lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
137
162
  lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
138
163
  md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
@@ -185,14 +185,20 @@ export const generateGridStyles = ({
185
185
  flexWrap: ownerState.wrap
186
186
  }, {
187
187
  margin: `calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)`
188
- }, ownerState.nested ? {
188
+ }, ownerState.disableEqualOverflow && {
189
+ margin: `calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)`
190
+ }, ownerState.nested ? _extends({
189
191
  padding: `calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)`
190
- } : {
192
+ }, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
193
+ padding: `calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))`
194
+ }) : {
191
195
  '--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
192
196
  '--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
193
- }) : {
197
+ }) : _extends({
194
198
  padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
195
- });
199
+ }, ownerState.disableEqualOverflow && {
200
+ padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
201
+ }));
196
202
  };
197
203
  export const generateSizeClassNames = gridSize => {
198
204
  const classNames = [];
@@ -85,7 +85,7 @@ function breakpoints(styleFunction) {
85
85
  export function createEmptyBreakpointObject(breakpointsInput = {}) {
86
86
  var _breakpointsInput$key;
87
87
 
88
- const breakpointsInOrder = breakpointsInput == null ? void 0 : (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
88
+ const breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce((acc, key) => {
89
89
  const breakpointStyleKey = breakpointsInput.up(key);
90
90
  acc[breakpointStyleKey] = {};
91
91
  return acc;
@@ -155,7 +155,7 @@ export default function createCssVarsProvider(options) {
155
155
  })();
156
156
 
157
157
  if (key === resolvedDefaultColorScheme) {
158
- defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
158
+ defaultColorSchemeStyleSheet[`${colorSchemeSelector}, [${attribute}="${key}"]`] = css;
159
159
  } else {
160
160
  otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
161
161
  }
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.9.0
1
+ /** @license MUI v5.9.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -57,6 +57,11 @@ process.env.NODE_ENV !== "production" ? Grid.propTypes
57
57
  /* @typescript-to-proptypes-ignore */
58
58
  .oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
59
59
 
60
+ /**
61
+ * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
62
+ */
63
+ disableEqualOverflow: PropTypes.bool,
64
+
60
65
  /**
61
66
  * If a number, it sets the number of columns the grid item uses.
62
67
  * It can't be greater than the total number of columns of the container (12 by default).
@@ -40,6 +40,7 @@ export default function createGrid() {
40
40
  _options$componentNam = options.componentName,
41
41
  componentName = _options$componentNam === void 0 ? 'MuiGrid' : _options$componentNam;
42
42
  var NestedContext = /*#__PURE__*/React.createContext(false);
43
+ var OverflowContext = /*#__PURE__*/React.createContext(undefined);
43
44
 
44
45
  var useUtilityClasses = function useUtilityClasses(ownerState, theme) {
45
46
  var container = ownerState.container,
@@ -57,13 +58,14 @@ export default function createGrid() {
57
58
 
58
59
  var GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
59
60
  var Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
60
- var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin;
61
+ var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin, _ref5, _disableEqualOverflow;
61
62
 
62
63
  var theme = useTheme();
63
64
  var themeProps = useThemeProps(inProps);
64
65
  var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
65
66
 
66
67
  var nested = React.useContext(NestedContext);
68
+ var overflow = React.useContext(OverflowContext);
67
69
 
68
70
  var className = props.className,
69
71
  _props$columns = props.columns,
@@ -82,7 +84,15 @@ export default function createGrid() {
82
84
  rowSpacingProp = _props$rowSpacing === void 0 ? spacingProp : _props$rowSpacing,
83
85
  _props$columnSpacing = props.columnSpacing,
84
86
  columnSpacingProp = _props$columnSpacing === void 0 ? spacingProp : _props$columnSpacing,
85
- rest = _objectWithoutProperties(props, ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing"]); // collect breakpoints related props because they can be custom from the theme.
87
+ themeDisableEqualOverflow = props.disableEqualOverflow,
88
+ rest = _objectWithoutProperties(props, ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"]); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
89
+
90
+
91
+ var disableEqualOverflow = themeDisableEqualOverflow;
92
+
93
+ if (nested && themeDisableEqualOverflow !== undefined) {
94
+ disableEqualOverflow = inProps.disableEqualOverflow;
95
+ } // collect breakpoints related props because they can be customized from the theme.
86
96
 
87
97
 
88
98
  var gridSize = {};
@@ -116,7 +126,11 @@ export default function createGrid() {
116
126
  rowSpacing: rowSpacing,
117
127
  columnSpacing: columnSpacing,
118
128
  gridSize: gridSize,
119
- gridOffset: gridOffset
129
+ gridOffset: gridOffset,
130
+ disableEqualOverflow: (_ref5 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref5 : false,
131
+ // use context value if exists.
132
+ parentDisableEqualOverflow: overflow // for nested grid
133
+
120
134
  });
121
135
 
122
136
  var classes = useUtilityClasses(ownerState, theme);
@@ -135,6 +149,16 @@ export default function createGrid() {
135
149
  });
136
150
  }
137
151
 
152
+ if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
153
+ // There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
154
+ // 1. It is the root grid with `disableEqualOverflow`.
155
+ // 2. It is a nested grid with different `disableEqualOverflow` from the context.
156
+ result = /*#__PURE__*/_jsx(OverflowContext.Provider, {
157
+ value: disableEqualOverflow,
158
+ children: result
159
+ });
160
+ }
161
+
138
162
  return result;
139
163
  });
140
164
  process.env.NODE_ENV !== "production" ? Grid.propTypes
@@ -147,6 +171,7 @@ export default function createGrid() {
147
171
  component: PropTypes.elementType,
148
172
  container: PropTypes.bool,
149
173
  direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
174
+ disableEqualOverflow: PropTypes.bool,
150
175
  lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
151
176
  lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
152
177
  md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
@@ -184,14 +184,20 @@ export var generateGridStyles = function generateGridStyles(_ref7) {
184
184
  flexWrap: ownerState.wrap
185
185
  }, {
186
186
  margin: "calc(var(--Grid-rowSpacing) / -2) calc(var(--Grid-columnSpacing) / -2)"
187
- }, ownerState.nested ? {
187
+ }, ownerState.disableEqualOverflow && {
188
+ margin: "calc(var(--Grid-rowSpacing) * -1) 0px 0px calc(var(--Grid-columnSpacing) * -1)"
189
+ }, ownerState.nested ? _extends({
188
190
  padding: "calc(var(--Grid-nested-rowSpacing) / 2) calc(var(--Grid-nested-columnSpacing) / 2)"
189
- } : {
191
+ }, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
192
+ padding: "calc(var(--Grid-nested-rowSpacing)) 0px 0px calc(var(--Grid-nested-columnSpacing))"
193
+ }) : {
190
194
  '--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
191
195
  '--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
192
- }) : {
196
+ }) : _extends({
193
197
  padding: "calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)"
194
- });
198
+ }, ownerState.disableEqualOverflow && {
199
+ padding: "calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))"
200
+ }));
195
201
  };
196
202
  export var generateSizeClassNames = function generateSizeClassNames(gridSize) {
197
203
  var classNames = [];
@@ -92,7 +92,7 @@ export function createEmptyBreakpointObject() {
92
92
  var _breakpointsInput$key;
93
93
 
94
94
  var breakpointsInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
95
- var breakpointsInOrder = breakpointsInput == null ? void 0 : (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce(function (acc, key) {
95
+ var breakpointsInOrder = (_breakpointsInput$key = breakpointsInput.keys) == null ? void 0 : _breakpointsInput$key.reduce(function (acc, key) {
96
96
  var breakpointStyleKey = breakpointsInput.up(key);
97
97
  acc[breakpointStyleKey] = {};
98
98
  return acc;
@@ -181,7 +181,7 @@ export default function createCssVarsProvider(options) {
181
181
  }();
182
182
 
183
183
  if (key === resolvedDefaultColorScheme) {
184
- defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
184
+ defaultColorSchemeStyleSheet["".concat(colorSchemeSelector, ", [").concat(attribute, "=\"").concat(key, "\"]")] = css;
185
185
  } else {
186
186
  otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
187
187
  }
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.9.0
1
+ /** @license MUI v5.9.3
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.