@mui/system 5.8.6 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/Unstable_Grid/Grid.d.ts +12 -0
  3. package/Unstable_Grid/Grid.js +195 -0
  4. package/Unstable_Grid/GridProps.d.ts +162 -0
  5. package/Unstable_Grid/GridProps.js +5 -0
  6. package/Unstable_Grid/createGrid.d.ts +11 -0
  7. package/Unstable_Grid/createGrid.js +199 -0
  8. package/Unstable_Grid/gridClasses.d.ts +20 -0
  9. package/Unstable_Grid/gridClasses.js +25 -0
  10. package/Unstable_Grid/gridGenerator.d.ts +26 -0
  11. package/Unstable_Grid/gridGenerator.js +275 -0
  12. package/Unstable_Grid/index.d.ts +5 -0
  13. package/Unstable_Grid/index.js +65 -0
  14. package/Unstable_Grid/package.json +6 -0
  15. package/breakpoints.js +1 -1
  16. package/{grid.js → cssGrid.js} +0 -0
  17. package/cssVars/createCssVarsProvider.d.ts +13 -18
  18. package/cssVars/createCssVarsProvider.js +11 -16
  19. package/cssVars/createGetCssVar.d.ts +1 -1
  20. package/cssVars/createGetCssVar.js +2 -2
  21. package/cssVars/cssVarsParser.d.ts +4 -9
  22. package/cssVars/cssVarsParser.js +4 -19
  23. package/cssVars/index.d.ts +2 -1
  24. package/cssVars/index.js +9 -1
  25. package/cssVars/useCurrentColorScheme.js +1 -1
  26. package/esm/Unstable_Grid/Grid.js +184 -0
  27. package/esm/Unstable_Grid/GridProps.js +1 -0
  28. package/esm/Unstable_Grid/createGrid.js +177 -0
  29. package/esm/Unstable_Grid/gridClasses.js +14 -0
  30. package/esm/Unstable_Grid/gridGenerator.js +236 -0
  31. package/esm/Unstable_Grid/index.js +5 -0
  32. package/esm/breakpoints.js +1 -1
  33. package/esm/{grid.js → cssGrid.js} +0 -0
  34. package/esm/cssVars/createCssVarsProvider.js +11 -15
  35. package/esm/cssVars/createGetCssVar.js +2 -2
  36. package/esm/cssVars/cssVarsParser.js +4 -19
  37. package/esm/cssVars/index.js +2 -1
  38. package/esm/cssVars/useCurrentColorScheme.js +1 -1
  39. package/esm/getThemeValue.js +1 -1
  40. package/esm/index.js +9 -3
  41. package/getThemeValue.js +3 -3
  42. package/index.d.ts +3 -0
  43. package/index.js +30 -7
  44. package/legacy/Unstable_Grid/Grid.js +184 -0
  45. package/legacy/Unstable_Grid/GridProps.js +1 -0
  46. package/legacy/Unstable_Grid/createGrid.js +191 -0
  47. package/legacy/Unstable_Grid/gridClasses.js +27 -0
  48. package/legacy/Unstable_Grid/gridGenerator.js +245 -0
  49. package/legacy/Unstable_Grid/index.js +5 -0
  50. package/legacy/breakpoints.js +1 -1
  51. package/legacy/{grid.js → cssGrid.js} +0 -0
  52. package/legacy/cssVars/createCssVarsProvider.js +11 -16
  53. package/legacy/cssVars/createGetCssVar.js +3 -3
  54. package/legacy/cssVars/cssVarsParser.js +4 -20
  55. package/legacy/cssVars/index.js +2 -1
  56. package/legacy/cssVars/useCurrentColorScheme.js +1 -1
  57. package/legacy/getThemeValue.js +1 -1
  58. package/legacy/index.js +10 -4
  59. package/modern/Unstable_Grid/Grid.js +184 -0
  60. package/modern/Unstable_Grid/GridProps.js +1 -0
  61. package/modern/Unstable_Grid/createGrid.js +175 -0
  62. package/modern/Unstable_Grid/gridClasses.js +14 -0
  63. package/modern/Unstable_Grid/gridGenerator.js +232 -0
  64. package/modern/Unstable_Grid/index.js +5 -0
  65. package/modern/breakpoints.js +1 -1
  66. package/modern/{grid.js → cssGrid.js} +0 -0
  67. package/modern/cssVars/createCssVarsProvider.js +11 -15
  68. package/modern/cssVars/createGetCssVar.js +2 -2
  69. package/modern/cssVars/cssVarsParser.js +4 -19
  70. package/modern/cssVars/index.js +2 -1
  71. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  72. package/modern/getThemeValue.js +1 -1
  73. package/modern/index.js +10 -4
  74. package/package.json +5 -5
@@ -45,17 +45,23 @@ export interface CssVarsProviderConfig<ColorScheme extends string> {
45
45
  */
46
46
  enableColorScheme?: boolean;
47
47
  /**
48
- * CSS variable prefix
49
- * @default ''
48
+ * A function to determine if the key, value should be attached as CSS Variable
49
+ * `keys` is an array that represents the object path keys.
50
+ * Ex, if the theme is { foo: { bar: 'var(--test)' } }
51
+ * then, keys = ['foo', 'bar']
52
+ * value = 'var(--test)'
50
53
  */
51
- prefix?: string;
54
+ shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
52
55
  }
53
56
 
54
- export interface CreateCssVarsProviderResult<ColorScheme extends string, ThemeInput> {
57
+ export interface CreateCssVarsProviderResult<ColorScheme extends string> {
55
58
  CssVarsProvider: (
56
59
  props: React.PropsWithChildren<
57
60
  Partial<CssVarsProviderConfig<ColorScheme>> & {
58
- theme?: ThemeInput;
61
+ theme?: {
62
+ cssVarPrefix?: string;
63
+ colorSchemes: Record<ColorScheme, Record<string, any>>;
64
+ };
59
65
  /**
60
66
  * The document used to perform `disableTransitionOnChange` feature
61
67
  * @default document
@@ -83,10 +89,7 @@ export interface CreateCssVarsProviderResult<ColorScheme extends string, ThemeIn
83
89
  getInitColorSchemeScript: typeof getInitColorSchemeScript;
84
90
  }
85
91
 
86
- export default function createCssVarsProvider<
87
- ColorScheme extends string,
88
- ThemeInput extends { colorSchemes?: Partial<Record<ColorScheme, any>> },
89
- >(
92
+ export default function createCssVarsProvider<ColorScheme extends string>(
90
93
  options: CssVarsProviderConfig<ColorScheme> & {
91
94
  /**
92
95
  * Design system default theme
@@ -114,14 +117,6 @@ export default function createCssVarsProvider<
114
117
  * }
115
118
  */
116
119
  theme: any;
117
- /**
118
- * A function to determine if the key, value should be attached as CSS Variable
119
- * `keys` is an array that represents the object path keys.
120
- * Ex, if the theme is { foo: { bar: 'var(--test)' } }
121
- * then, keys = ['foo', 'bar']
122
- * value = 'var(--test)'
123
- */
124
- shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
125
120
  /**
126
121
  * A function to be called after the CSS variables are attached. The result of this function will be the final theme pass to ThemeProvider.
127
122
  *
@@ -130,7 +125,7 @@ export default function createCssVarsProvider<
130
125
  */
131
126
  resolveTheme?: (theme: any) => any; // the type is any because it depends on the design system.
132
127
  },
133
- ): CreateCssVarsProviderResult<ColorScheme, ThemeInput>;
128
+ ): CreateCssVarsProviderResult<ColorScheme>;
134
129
 
135
130
  // disable automatic export
136
131
  export {};
@@ -28,11 +28,9 @@ var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorS
28
28
 
29
29
  var _useCurrentColorScheme = _interopRequireDefault(require("./useCurrentColorScheme"));
30
30
 
31
- var _createGetCssVar = _interopRequireDefault(require("./createGetCssVar"));
32
-
33
31
  var _jsxRuntime = require("react/jsx-runtime");
34
32
 
35
- const _excluded = ["colorSchemes", "components"];
33
+ const _excluded = ["colorSchemes", "components", "cssVarPrefix"];
36
34
 
37
35
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
38
36
 
@@ -51,8 +49,7 @@ function createCssVarsProvider(options) {
51
49
  defaultColorScheme: designSystemColorScheme,
52
50
  disableTransitionOnChange: designSystemTransitionOnChange = false,
53
51
  enableColorScheme: designSystemEnableColorScheme = true,
54
- prefix: designSystemPrefix = '',
55
- shouldSkipGeneratingVar,
52
+ shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
56
53
  resolveTheme
57
54
  } = options;
58
55
 
@@ -75,7 +72,6 @@ function createCssVarsProvider(options) {
75
72
  function CssVarsProvider({
76
73
  children,
77
74
  theme: themeProp = defaultTheme,
78
- prefix = designSystemPrefix,
79
75
  modeStorageKey = defaultModeStorageKey,
80
76
  colorSchemeStorageKey = defaultColorSchemeStorageKey,
81
77
  attribute = defaultAttribute,
@@ -86,12 +82,14 @@ function createCssVarsProvider(options) {
86
82
  storageWindow = typeof window === 'undefined' ? undefined : window,
87
83
  documentNode = typeof document === 'undefined' ? undefined : document,
88
84
  colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
89
- colorSchemeSelector = ':root'
85
+ colorSchemeSelector = ':root',
86
+ shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar
90
87
  }) {
91
88
  const hasMounted = React.useRef(false);
92
89
  const {
93
90
  colorSchemes = {},
94
- components = {}
91
+ components = {},
92
+ cssVarPrefix
95
93
  } = themeProp,
96
94
  restThemeProp = (0, _objectWithoutPropertiesLoose2.default)(themeProp, _excluded);
97
95
  const allColorSchemes = Object.keys(colorSchemes);
@@ -135,16 +133,14 @@ function createCssVarsProvider(options) {
135
133
  vars: rootVars,
136
134
  parsedTheme
137
135
  } = (0, _cssVarsParser.default)(theme, {
138
- prefix,
139
- basePrefix: designSystemPrefix,
136
+ prefix: cssVarPrefix,
140
137
  shouldSkipGeneratingVar
141
138
  });
142
139
  theme = (0, _extends2.default)({}, parsedTheme, {
143
140
  components,
144
141
  colorSchemes,
145
- prefix,
142
+ cssVarPrefix,
146
143
  vars: rootVars,
147
- getCssVar: (0, _createGetCssVar.default)(prefix),
148
144
  getColorSchemeSelector: targetColorScheme => `[${attribute}="${targetColorScheme}"] &`
149
145
  });
150
146
  const defaultColorSchemeStyleSheet = {};
@@ -155,8 +151,7 @@ function createCssVarsProvider(options) {
155
151
  vars,
156
152
  parsedTheme: parsedScheme
157
153
  } = (0, _cssVarsParser.default)(scheme, {
158
- prefix,
159
- basePrefix: designSystemPrefix,
154
+ prefix: cssVarPrefix,
160
155
  shouldSkipGeneratingVar
161
156
  });
162
157
  theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
@@ -320,9 +315,9 @@ function createCssVarsProvider(options) {
320
315
  modeStorageKey: _propTypes.default.string,
321
316
 
322
317
  /**
323
- * CSS variable prefix.
318
+ * A function to determine if the key, value should be attached as CSS Variable
324
319
  */
325
- prefix: _propTypes.default.string,
320
+ shouldSkipGeneratingVar: _propTypes.default.func,
326
321
 
327
322
  /**
328
323
  * The window that attaches the 'storage' event listener
@@ -2,4 +2,4 @@
2
2
  * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
3
3
  * and they does not need to remember the prefix (defined once).
4
4
  */
5
- export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...vars: (T | AdditionalVars)[]) => string;
5
+ export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...fallbacks: (T | AdditionalVars)[]) => string;
@@ -25,8 +25,8 @@ function createGetCssVar(prefix = '') {
25
25
  } // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
26
26
 
27
27
 
28
- const getCssVar = (field, ...vars) => {
29
- return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...vars)})`;
28
+ const getCssVar = (field, ...fallbacks) => {
29
+ return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...fallbacks)})`;
30
30
  };
31
31
 
32
32
  return getCssVar;
@@ -37,13 +37,9 @@ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, ca
37
37
  * @param {Object} theme
38
38
  * @param {{
39
39
  * prefix?: string,
40
- * basePrefix?: string,
41
40
  * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
41
  * }} options.
43
- * `basePrefix`: defined by design system.
44
- * `prefix`: defined by application
45
- *
46
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
42
+ * `prefix`: The prefix of the generated CSS variables. This function does not change the value.
47
43
  *
48
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.
49
45
  *
@@ -54,13 +50,12 @@ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, ca
54
50
  * palette: { primary: { 500: 'var(--color)' } }
55
51
  * }, { prefix: 'foo' })
56
52
  *
57
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
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)' } } }
60
56
  */
61
57
  export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
58
  prefix?: string;
63
- basePrefix?: string;
64
59
  shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
60
  }): {
66
61
  css: NestedRecord<string>;
@@ -102,13 +102,9 @@ const getCssValue = (keys, value) => {
102
102
  * @param {Object} theme
103
103
  * @param {{
104
104
  * prefix?: string,
105
- * basePrefix?: string,
106
105
  * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
107
106
  * }} options.
108
- * `basePrefix`: defined by design system.
109
- * `prefix`: defined by application
110
- *
111
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
107
+ * `prefix`: The prefix of the generated CSS variables. This function does not change the value.
112
108
  *
113
109
  * @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.
114
110
  *
@@ -119,16 +115,15 @@ const getCssValue = (keys, value) => {
119
115
  * palette: { primary: { 500: 'var(--color)' } }
120
116
  * }, { prefix: 'foo' })
121
117
  *
122
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
123
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
124
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
118
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
119
+ * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
120
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
125
121
  */
126
122
 
127
123
 
128
124
  function cssVarsParser(theme, options) {
129
125
  const {
130
126
  prefix,
131
- basePrefix = '',
132
127
  shouldSkipGeneratingVar
133
128
  } = options || {};
134
129
  const css = {};
@@ -136,16 +131,6 @@ function cssVarsParser(theme, options) {
136
131
  const parsedTheme = {};
137
132
  walkObjectDeep(theme, (keys, value, arrayKeys) => {
138
133
  if (typeof value === 'string' || typeof value === 'number') {
139
- if (typeof value === 'string' && value.match(/var\(\s*--/)) {
140
- // for CSS variable, apply prefix or remove basePrefix from the variable
141
- if (!basePrefix && prefix) {
142
- value = value.replace(/var\(\s*--/g, `var(--${prefix}-`);
143
- } else {
144
- value = prefix ? value.replace(new RegExp(`var\\(\\s*--${basePrefix}`, 'g'), `var(--${prefix}`) // removing spaces
145
- : value.replace(new RegExp(`var\\(\\s*--${basePrefix}-`, 'g'), 'var(--');
146
- }
147
- }
148
-
149
134
  if (!shouldSkipGeneratingVar || shouldSkipGeneratingVar && !shouldSkipGeneratingVar(keys, value)) {
150
135
  // only create css & var if `shouldSkipGeneratingVar` return false
151
136
  const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;
@@ -1,2 +1,3 @@
1
1
  export { default } from './createCssVarsProvider';
2
- export type { CreateCssVarsProviderResult } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
3
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
package/cssVars/index.js CHANGED
@@ -11,5 +11,13 @@ Object.defineProperty(exports, "default", {
11
11
  return _createCssVarsProvider.default;
12
12
  }
13
13
  });
14
+ Object.defineProperty(exports, "getInitColorSchemeScript", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _getInitColorSchemeScript.default;
18
+ }
19
+ });
20
+
21
+ var _createCssVarsProvider = _interopRequireDefault(require("./createCssVarsProvider"));
14
22
 
15
- var _createCssVarsProvider = _interopRequireDefault(require("./createCssVarsProvider"));
23
+ var _getInitColorSchemeScript = _interopRequireDefault(require("./getInitColorSchemeScript"));
@@ -171,7 +171,7 @@ function useCurrentColorScheme(options) {
171
171
  const handleMediaQuery = React.useCallback(e => {
172
172
  if (state.mode === 'system') {
173
173
  setState(currentState => (0, _extends2.default)({}, currentState, {
174
- systemMode: e.matches ? 'dark' : 'light'
174
+ systemMode: e != null && e.matches ? 'dark' : 'light'
175
175
  }));
176
176
  }
177
177
  }, [state.mode]); // Ref hack to avoid adding handleMediaQuery as a dep
@@ -0,0 +1,184 @@
1
+ import PropTypes from 'prop-types';
2
+ import createGrid from './createGrid';
3
+ /**
4
+ *
5
+ * Demos:
6
+ *
7
+ * - [Grid (Material UI)](https://mui.com/material-ui/react-grid/)
8
+ *
9
+ * API:
10
+ *
11
+ * - [Grid API](https://mui.com/system/api/grid/)
12
+ */
13
+
14
+ const Grid = createGrid();
15
+ process.env.NODE_ENV !== "production" ? Grid.propTypes
16
+ /* remove-proptypes */
17
+ = {
18
+ // ----------------------------- Warning --------------------------------
19
+ // | These PropTypes are generated from the TypeScript type definitions |
20
+ // | To update them edit TypeScript types and run "yarn proptypes" |
21
+ // ----------------------------------------------------------------------
22
+
23
+ /**
24
+ * The content of the component.
25
+ */
26
+ children: PropTypes.node,
27
+
28
+ /**
29
+ * The number of columns.
30
+ * @default 12
31
+ */
32
+ columns: PropTypes
33
+ /* @typescript-to-proptypes-ignore */
34
+ .oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
35
+
36
+ /**
37
+ * Defines the horizontal space between the type `item` components.
38
+ * It overrides the value of the `spacing` prop.
39
+ */
40
+ columnSpacing: PropTypes
41
+ /* @typescript-to-proptypes-ignore */
42
+ .oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
43
+
44
+ /**
45
+ * If `true`, the component will have the flex *container* behavior.
46
+ * You should be wrapping *items* with a *container*.
47
+ * @default false
48
+ */
49
+ container: PropTypes.bool,
50
+
51
+ /**
52
+ * Defines the `flex-direction` style property.
53
+ * It is applied for all screen sizes.
54
+ * @default 'row'
55
+ */
56
+ direction: PropTypes
57
+ /* @typescript-to-proptypes-ignore */
58
+ .oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
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
+
65
+ /**
66
+ * If a number, it sets the number of columns the grid item uses.
67
+ * It can't be greater than the total number of columns of the container (12 by default).
68
+ * If 'auto', the grid item's width matches its content.
69
+ * If false, the prop is ignored.
70
+ * If true, the grid item's width grows to use the space available in the grid container.
71
+ * The value is applied for the `lg` breakpoint and wider screens if not overridden.
72
+ * @default false
73
+ */
74
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
75
+
76
+ /**
77
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
78
+ * If 'auto', the grid item push itself to the right-end of the container.
79
+ * The value is applied for the `lg` breakpoint and wider screens if not overridden.
80
+ */
81
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
82
+
83
+ /**
84
+ * If a number, it sets the number of columns the grid item uses.
85
+ * It can't be greater than the total number of columns of the container (12 by default).
86
+ * If 'auto', the grid item's width matches its content.
87
+ * If false, the prop is ignored.
88
+ * If true, the grid item's width grows to use the space available in the grid container.
89
+ * The value is applied for the `md` breakpoint and wider screens if not overridden.
90
+ * @default false
91
+ */
92
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
93
+
94
+ /**
95
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
96
+ * If 'auto', the grid item push itself to the right-end of the container.
97
+ * The value is applied for the `md` breakpoint and wider screens if not overridden.
98
+ */
99
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
100
+
101
+ /**
102
+ * Defines the vertical space between the type `item` components.
103
+ * It overrides the value of the `spacing` prop.
104
+ */
105
+ rowSpacing: PropTypes
106
+ /* @typescript-to-proptypes-ignore */
107
+ .oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
108
+
109
+ /**
110
+ * If a number, it sets the number of columns the grid item uses.
111
+ * It can't be greater than the total number of columns of the container (12 by default).
112
+ * If 'auto', the grid item's width matches its content.
113
+ * If false, the prop is ignored.
114
+ * If true, the grid item's width grows to use the space available in the grid container.
115
+ * The value is applied for the `sm` breakpoint and wider screens if not overridden.
116
+ * @default false
117
+ */
118
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
119
+
120
+ /**
121
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
122
+ * If 'auto', the grid item push itself to the right-end of the container.
123
+ * The value is applied for the `sm` breakpoint and wider screens if not overridden.
124
+ */
125
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
126
+
127
+ /**
128
+ * Defines the space between the type `item` components.
129
+ * It can only be used on a type `container` component.
130
+ * @default 0
131
+ */
132
+ spacing: PropTypes
133
+ /* @typescript-to-proptypes-ignore */
134
+ .oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
135
+
136
+ /**
137
+ * @ignore
138
+ */
139
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
140
+
141
+ /**
142
+ * Defines the `flex-wrap` style property.
143
+ * It's applied for all screen sizes.
144
+ * @default 'wrap'
145
+ */
146
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
147
+
148
+ /**
149
+ * If a number, it sets the number of columns the grid item uses.
150
+ * It can't be greater than the total number of columns of the container (12 by default).
151
+ * If 'auto', the grid item's width matches its content.
152
+ * If false, the prop is ignored.
153
+ * If true, the grid item's width grows to use the space available in the grid container.
154
+ * The value is applied for the `xl` breakpoint and wider screens if not overridden.
155
+ * @default false
156
+ */
157
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
158
+
159
+ /**
160
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
161
+ * If 'auto', the grid item push itself to the right-end of the container.
162
+ * The value is applied for the `xl` breakpoint and wider screens if not overridden.
163
+ */
164
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
165
+
166
+ /**
167
+ * If a number, it sets the number of columns the grid item uses.
168
+ * It can't be greater than the total number of columns of the container (12 by default).
169
+ * If 'auto', the grid item's width matches its content.
170
+ * If false, the prop is ignored.
171
+ * If true, the grid item's width grows to use the space available in the grid container.
172
+ * The value is applied for all the screen sizes with the lowest priority.
173
+ * @default false
174
+ */
175
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
176
+
177
+ /**
178
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
179
+ * If 'auto', the grid item push itself to the right-end of the container.
180
+ * The value is applied for the `xs` breakpoint and wider screens if not overridden.
181
+ */
182
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
183
+ } : void 0;
184
+ export default Grid;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,177 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["className", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import clsx from 'clsx';
7
+ import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
8
+ import systemStyled from '../styled';
9
+ import useThemePropsSystem from '../useThemeProps';
10
+ import useTheme from '../useTheme';
11
+ import { extendSxProp } from '../styleFunctionSx';
12
+ import createTheme from '../createTheme';
13
+ import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames } from './gridGenerator';
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ const defaultTheme = createTheme(); // widening Theme to any so that the consumer can own the theme structure.
16
+
17
+ const defaultCreateStyledComponent = systemStyled('div', {
18
+ name: 'MuiGrid',
19
+ slot: 'Root',
20
+ overridesResolver: (props, styles) => styles.root
21
+ });
22
+
23
+ function useThemePropsDefault(props) {
24
+ return useThemePropsSystem({
25
+ props,
26
+ name: 'MuiGrid',
27
+ defaultTheme
28
+ });
29
+ }
30
+
31
+ export default function createGrid(options = {}) {
32
+ const {
33
+ // This will allow adding custom styled fn (for example for custom sx style function)
34
+ createStyledComponent = defaultCreateStyledComponent,
35
+ useThemeProps = useThemePropsDefault,
36
+ componentName = 'MuiGrid'
37
+ } = options;
38
+ const NestedContext = /*#__PURE__*/React.createContext(false);
39
+ const OverflowContext = /*#__PURE__*/React.createContext(undefined);
40
+
41
+ const useUtilityClasses = (ownerState, theme) => {
42
+ const {
43
+ container,
44
+ direction,
45
+ spacing,
46
+ wrap,
47
+ gridSize
48
+ } = ownerState;
49
+ const slots = {
50
+ root: ['root', container && 'container', direction !== 'row' && `direction-xs-${String(direction)}`, wrap !== 'wrap' && `wrap-xs-${String(wrap)}`, ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : [])]
51
+ };
52
+ return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
53
+ };
54
+
55
+ const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
56
+ const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
57
+ var _inProps$columns, _inProps$spacing, _ref, _inProps$rowSpacing, _ref2, _inProps$columnSpacin, _ref3, _disableEqualOverflow;
58
+
59
+ const theme = useTheme();
60
+ const themeProps = useThemeProps(inProps);
61
+ const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
62
+
63
+ const nested = React.useContext(NestedContext);
64
+ const overflow = React.useContext(OverflowContext);
65
+
66
+ const {
67
+ className,
68
+ columns: columnsProp = 12,
69
+ container = false,
70
+ component = 'div',
71
+ direction = 'row',
72
+ wrap = 'wrap',
73
+ spacing: spacingProp = 0,
74
+ rowSpacing: rowSpacingProp = spacingProp,
75
+ columnSpacing: columnSpacingProp = spacingProp,
76
+ disableEqualOverflow: themeDisableEqualOverflow
77
+ } = props,
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.
86
+
87
+
88
+ const gridSize = {};
89
+ const gridOffset = {};
90
+ const other = {};
91
+ Object.entries(rest).forEach(([key, val]) => {
92
+ if (theme.breakpoints.values[key] !== undefined) {
93
+ gridSize[key] = val;
94
+ } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
95
+ gridOffset[key.replace('Offset', '')] = val;
96
+ } else {
97
+ other[key] = val;
98
+ }
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;
104
+
105
+ const ownerState = _extends({}, props, {
106
+ nested,
107
+ columns,
108
+ container,
109
+ direction,
110
+ wrap,
111
+ spacing,
112
+ rowSpacing,
113
+ columnSpacing,
114
+ gridSize,
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
+
120
+ });
121
+
122
+ const classes = useUtilityClasses(ownerState, theme);
123
+
124
+ let result = /*#__PURE__*/_jsx(GridRoot, _extends({
125
+ ref: ref,
126
+ as: component,
127
+ ownerState: ownerState,
128
+ className: clsx(classes.root, className)
129
+ }, other));
130
+
131
+ if (!nested) {
132
+ result = /*#__PURE__*/_jsx(NestedContext.Provider, {
133
+ value: true,
134
+ children: result
135
+ });
136
+ }
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
+
148
+ return result;
149
+ });
150
+ process.env.NODE_ENV !== "production" ? Grid.propTypes
151
+ /* remove-proptypes */
152
+ = {
153
+ children: PropTypes.node,
154
+ className: PropTypes.string,
155
+ columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
156
+ columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
157
+ component: PropTypes.elementType,
158
+ container: PropTypes.bool,
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,
161
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
162
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
163
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
164
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
165
+ rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
166
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
167
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
168
+ spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
169
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
170
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
171
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
172
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
173
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
174
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
175
+ } : void 0;
176
+ return Grid;
177
+ }