@mui/system 5.8.5 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +190 -0
  2. package/Unstable_Grid/Grid.d.ts +12 -0
  3. package/Unstable_Grid/Grid.js +190 -0
  4. package/Unstable_Grid/GridProps.d.ts +158 -0
  5. package/Unstable_Grid/GridProps.js +5 -0
  6. package/Unstable_Grid/createGrid.d.ts +11 -0
  7. package/Unstable_Grid/createGrid.js +174 -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 +269 -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/{grid.js → cssGrid.js} +0 -0
  16. package/cssVars/createCssVarsProvider.d.ts +13 -18
  17. package/cssVars/createCssVarsProvider.js +13 -17
  18. package/cssVars/createGetCssVar.d.ts +1 -1
  19. package/cssVars/createGetCssVar.js +2 -2
  20. package/cssVars/cssVarsParser.d.ts +4 -9
  21. package/cssVars/cssVarsParser.js +4 -19
  22. package/cssVars/getInitColorSchemeScript.d.ts +5 -0
  23. package/cssVars/getInitColorSchemeScript.js +7 -0
  24. package/cssVars/index.d.ts +2 -1
  25. package/cssVars/index.js +9 -1
  26. package/cssVars/useCurrentColorScheme.js +1 -1
  27. package/esm/Unstable_Grid/Grid.js +179 -0
  28. package/esm/Unstable_Grid/GridProps.js +1 -0
  29. package/esm/Unstable_Grid/createGrid.js +152 -0
  30. package/esm/Unstable_Grid/gridClasses.js +14 -0
  31. package/esm/Unstable_Grid/gridGenerator.js +230 -0
  32. package/esm/Unstable_Grid/index.js +5 -0
  33. package/esm/{grid.js → cssGrid.js} +0 -0
  34. package/esm/cssVars/createCssVarsProvider.js +13 -16
  35. package/esm/cssVars/createGetCssVar.js +2 -2
  36. package/esm/cssVars/cssVarsParser.js +4 -19
  37. package/esm/cssVars/getInitColorSchemeScript.js +7 -0
  38. package/esm/cssVars/index.js +2 -1
  39. package/esm/cssVars/useCurrentColorScheme.js +1 -1
  40. package/esm/getThemeValue.js +1 -1
  41. package/esm/index.js +9 -3
  42. package/getThemeValue.js +3 -3
  43. package/index.d.ts +3 -0
  44. package/index.js +30 -7
  45. package/legacy/Unstable_Grid/Grid.js +179 -0
  46. package/legacy/Unstable_Grid/GridProps.js +1 -0
  47. package/legacy/Unstable_Grid/createGrid.js +166 -0
  48. package/legacy/Unstable_Grid/gridClasses.js +27 -0
  49. package/legacy/Unstable_Grid/gridGenerator.js +239 -0
  50. package/legacy/Unstable_Grid/index.js +5 -0
  51. package/legacy/{grid.js → cssGrid.js} +0 -0
  52. package/legacy/cssVars/createCssVarsProvider.js +13 -17
  53. package/legacy/cssVars/createGetCssVar.js +3 -3
  54. package/legacy/cssVars/cssVarsParser.js +4 -20
  55. package/legacy/cssVars/getInitColorSchemeScript.js +3 -1
  56. package/legacy/cssVars/index.js +2 -1
  57. package/legacy/cssVars/useCurrentColorScheme.js +1 -1
  58. package/legacy/getThemeValue.js +1 -1
  59. package/legacy/index.js +10 -4
  60. package/modern/Unstable_Grid/Grid.js +179 -0
  61. package/modern/Unstable_Grid/GridProps.js +1 -0
  62. package/modern/Unstable_Grid/createGrid.js +150 -0
  63. package/modern/Unstable_Grid/gridClasses.js +14 -0
  64. package/modern/Unstable_Grid/gridGenerator.js +226 -0
  65. package/modern/Unstable_Grid/index.js +5 -0
  66. package/modern/{grid.js → cssGrid.js} +0 -0
  67. package/modern/cssVars/createCssVarsProvider.js +13 -16
  68. package/modern/cssVars/createGetCssVar.js +2 -2
  69. package/modern/cssVars/cssVarsParser.js +4 -19
  70. package/modern/cssVars/getInitColorSchemeScript.js +7 -0
  71. package/modern/cssVars/index.js +2 -1
  72. package/modern/cssVars/useCurrentColorScheme.js +1 -1
  73. package/modern/getThemeValue.js +1 -1
  74. package/modern/index.js +10 -4
  75. package/package.json +5 -5
@@ -12,7 +12,6 @@ import cssVarsParser from './cssVarsParser';
12
12
  import ThemeProvider from '../ThemeProvider';
13
13
  import systemGetInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_COLOR_SCHEME_STORAGE_KEY, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
14
14
  import useCurrentColorScheme from './useCurrentColorScheme';
15
- import createGetCssVar from './createGetCssVar';
16
15
  import { jsx as _jsx } from "react/jsx-runtime";
17
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
17
  export var DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
@@ -32,9 +31,7 @@ export default function createCssVarsProvider(options) {
32
31
  designSystemTransitionOnChange = _options$disableTrans === void 0 ? false : _options$disableTrans,
33
32
  _options$enableColorS = options.enableColorScheme,
34
33
  designSystemEnableColorScheme = _options$enableColorS === void 0 ? true : _options$enableColorS,
35
- _options$prefix = options.prefix,
36
- designSystemPrefix = _options$prefix === void 0 ? '' : _options$prefix,
37
- shouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
34
+ designSystemShouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
38
35
  resolveTheme = options.resolveTheme;
39
36
 
40
37
  if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
@@ -57,8 +54,6 @@ export default function createCssVarsProvider(options) {
57
54
  var children = _ref.children,
58
55
  _ref$theme = _ref.theme,
59
56
  themeProp = _ref$theme === void 0 ? defaultTheme : _ref$theme,
60
- _ref$prefix = _ref.prefix,
61
- prefix = _ref$prefix === void 0 ? designSystemPrefix : _ref$prefix,
62
57
  _ref$modeStorageKey = _ref.modeStorageKey,
63
58
  modeStorageKey = _ref$modeStorageKey === void 0 ? defaultModeStorageKey : _ref$modeStorageKey,
64
59
  _ref$colorSchemeStora = _ref.colorSchemeStorageKey,
@@ -80,14 +75,17 @@ export default function createCssVarsProvider(options) {
80
75
  _ref$colorSchemeNode = _ref.colorSchemeNode,
81
76
  colorSchemeNode = _ref$colorSchemeNode === void 0 ? typeof document === 'undefined' ? undefined : document.documentElement : _ref$colorSchemeNode,
82
77
  _ref$colorSchemeSelec = _ref.colorSchemeSelector,
83
- colorSchemeSelector = _ref$colorSchemeSelec === void 0 ? ':root' : _ref$colorSchemeSelec;
78
+ colorSchemeSelector = _ref$colorSchemeSelec === void 0 ? ':root' : _ref$colorSchemeSelec,
79
+ _ref$shouldSkipGenera = _ref.shouldSkipGeneratingVar,
80
+ shouldSkipGeneratingVar = _ref$shouldSkipGenera === void 0 ? designSystemShouldSkipGeneratingVar : _ref$shouldSkipGenera;
84
81
  var hasMounted = React.useRef(false);
85
82
 
86
83
  var _themeProp$colorSchem = themeProp.colorSchemes,
87
84
  colorSchemes = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
88
85
  _themeProp$components = themeProp.components,
89
86
  components = _themeProp$components === void 0 ? {} : _themeProp$components,
90
- restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components"]);
87
+ cssVarPrefix = themeProp.cssVarPrefix,
88
+ restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes", "components", "cssVarPrefix"]);
91
89
 
92
90
  var allColorSchemes = Object.keys(colorSchemes);
93
91
  var defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
@@ -127,8 +125,7 @@ export default function createCssVarsProvider(options) {
127
125
  var theme = restThemeProp;
128
126
 
129
127
  var _cssVarsParser = cssVarsParser(theme, {
130
- prefix: prefix,
131
- basePrefix: designSystemPrefix,
128
+ prefix: cssVarPrefix,
132
129
  shouldSkipGeneratingVar: shouldSkipGeneratingVar
133
130
  }),
134
131
  rootCss = _cssVarsParser.css,
@@ -138,9 +135,8 @@ export default function createCssVarsProvider(options) {
138
135
  theme = _extends({}, parsedTheme, {
139
136
  components: components,
140
137
  colorSchemes: colorSchemes,
141
- prefix: prefix,
138
+ cssVarPrefix: cssVarPrefix,
142
139
  vars: rootVars,
143
- getCssVar: createGetCssVar(prefix),
144
140
  getColorSchemeSelector: function getColorSchemeSelector(targetColorScheme) {
145
141
  return "[".concat(attribute, "=\"").concat(targetColorScheme, "\"] &");
146
142
  }
@@ -153,8 +149,7 @@ export default function createCssVarsProvider(options) {
153
149
  scheme = _ref3[1];
154
150
 
155
151
  var _cssVarsParser2 = cssVarsParser(scheme, {
156
- prefix: prefix,
157
- basePrefix: designSystemPrefix,
152
+ prefix: cssVarPrefix,
158
153
  shouldSkipGeneratingVar: shouldSkipGeneratingVar
159
154
  }),
160
155
  css = _cssVarsParser2.css,
@@ -322,9 +317,9 @@ export default function createCssVarsProvider(options) {
322
317
  modeStorageKey: PropTypes.string,
323
318
 
324
319
  /**
325
- * CSS variable prefix.
320
+ * A function to determine if the key, value should be attached as CSS Variable
326
321
  */
327
- prefix: PropTypes.string,
322
+ shouldSkipGeneratingVar: PropTypes.func,
328
323
 
329
324
  /**
330
325
  * The window that attaches the 'storage' event listener
@@ -342,7 +337,8 @@ export default function createCssVarsProvider(options) {
342
337
  return systemGetInitColorSchemeScript(_extends({
343
338
  attribute: defaultAttribute,
344
339
  colorSchemeStorageKey: defaultColorSchemeStorageKey,
345
- modeStorageKey: defaultModeStorageKey
340
+ modeStorageKey: defaultModeStorageKey,
341
+ enableColorScheme: designSystemEnableColorScheme
346
342
  }, params));
347
343
  };
348
344
 
@@ -27,11 +27,11 @@ export default function createGetCssVar() {
27
27
 
28
28
 
29
29
  var getCssVar = function getCssVar(field) {
30
- for (var _len2 = arguments.length, vars = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
31
- vars[_key2 - 1] = arguments[_key2];
30
+ for (var _len2 = arguments.length, fallbacks = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
31
+ fallbacks[_key2 - 1] = arguments[_key2];
32
32
  }
33
33
 
34
- return "var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(field).concat(appendVar.apply(void 0, vars), ")");
34
+ return "var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(field).concat(appendVar.apply(void 0, fallbacks), ")");
35
35
  };
36
36
 
37
37
  return getCssVar;
@@ -103,13 +103,9 @@ var getCssValue = function getCssValue(keys, value) {
103
103
  * @param {Object} theme
104
104
  * @param {{
105
105
  * prefix?: string,
106
- * basePrefix?: string,
107
106
  * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
108
107
  * }} options.
109
- * `basePrefix`: defined by design system.
110
- * `prefix`: defined by application
111
- *
112
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
108
+ * `prefix`: The prefix of the generated CSS variables. This function does not change the value.
113
109
  *
114
110
  * @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.
115
111
  *
@@ -120,17 +116,15 @@ var getCssValue = function getCssValue(keys, value) {
120
116
  * palette: { primary: { 500: 'var(--color)' } }
121
117
  * }, { prefix: 'foo' })
122
118
  *
123
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
124
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
125
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
119
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
120
+ * console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
121
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
126
122
  */
127
123
 
128
124
 
129
125
  export default function cssVarsParser(theme, options) {
130
126
  var _ref3 = options || {},
131
127
  prefix = _ref3.prefix,
132
- _ref3$basePrefix = _ref3.basePrefix,
133
- basePrefix = _ref3$basePrefix === void 0 ? '' : _ref3$basePrefix,
134
128
  shouldSkipGeneratingVar = _ref3.shouldSkipGeneratingVar;
135
129
 
136
130
  var css = {};
@@ -138,16 +132,6 @@ export default function cssVarsParser(theme, options) {
138
132
  var parsedTheme = {};
139
133
  walkObjectDeep(theme, function (keys, value, arrayKeys) {
140
134
  if (typeof value === 'string' || typeof value === 'number') {
141
- if (typeof value === 'string' && value.match(/var\(\s*--/)) {
142
- // for CSS variable, apply prefix or remove basePrefix from the variable
143
- if (!basePrefix && prefix) {
144
- value = value.replace(/var\(\s*--/g, "var(--".concat(prefix, "-"));
145
- } else {
146
- value = prefix ? value.replace(new RegExp("var\\(\\s*--".concat(basePrefix), 'g'), "var(--".concat(prefix)) // removing spaces
147
- : value.replace(new RegExp("var\\(\\s*--".concat(basePrefix, "-"), 'g'), 'var(--');
148
- }
149
- }
150
-
151
135
  if (!shouldSkipGeneratingVar || shouldSkipGeneratingVar && !shouldSkipGeneratingVar(keys, value)) {
152
136
  // only create css & var if `shouldSkipGeneratingVar` return false
153
137
  var cssVar = "--".concat(prefix ? "".concat(prefix, "-") : '').concat(keys.join('-'));
@@ -5,6 +5,8 @@ export var DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
5
5
  export var DEFAULT_ATTRIBUTE = 'data-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  var _ref = options || {},
8
+ _ref$enableColorSchem = _ref.enableColorScheme,
9
+ enableColorScheme = _ref$enableColorSchem === void 0 ? true : _ref$enableColorSchem,
8
10
  _ref$enableSystem = _ref.enableSystem,
9
11
  enableSystem = _ref$enableSystem === void 0 ? false : _ref$enableSystem,
10
12
  _ref$defaultLightColo = _ref.defaultLightColorScheme,
@@ -23,7 +25,7 @@ export default function getInitColorSchemeScript(options) {
23
25
  return /*#__PURE__*/_jsx("script", {
24
26
  // eslint-disable-next-line react/no-danger
25
27
  dangerouslySetInnerHTML: {
26
- __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var colorScheme = '';\n if (mode === 'system' || (!mode && !!").concat(enableSystem, ")) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n ").concat(colorSchemeNode, ".setAttribute('").concat(attribute, "', colorScheme);\n }\n } catch (e) {} })();")
28
+ __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var cssColorScheme = mode;\n var colorScheme = '';\n if (mode === 'system' || (!mode && !!").concat(enableSystem, ")) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n cssColorScheme = 'dark';\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n cssColorScheme = 'light';\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n ").concat(colorSchemeNode, ".setAttribute('").concat(attribute, "', colorScheme);\n }\n if (").concat(enableColorScheme, " && !!cssColorScheme) {\n ").concat(colorSchemeNode, ".style.setProperty('color-scheme', cssColorScheme);\n }\n } catch (e) {} })();")
27
29
  }
28
30
  });
29
31
  }
@@ -1 +1,2 @@
1
- export { default } from './createCssVarsProvider';
1
+ export { default } from './createCssVarsProvider';
2
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
@@ -161,7 +161,7 @@ export default function useCurrentColorScheme(options) {
161
161
  if (state.mode === 'system') {
162
162
  setState(function (currentState) {
163
163
  return _extends({}, currentState, {
164
- systemMode: e.matches ? 'dark' : 'light'
164
+ systemMode: e != null && e.matches ? 'dark' : 'light'
165
165
  });
166
166
  });
167
167
  }
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import borders from './borders';
3
3
  import display from './display';
4
4
  import flexbox from './flexbox';
5
- import grid from './grid';
5
+ import grid from './cssGrid';
6
6
  import positions from './positions';
7
7
  import palette from './palette';
8
8
  import shadows from './shadows';
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.8.5
1
+ /** @license MUI v5.9.0
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.
@@ -12,8 +12,8 @@ export { default as compose } from './compose';
12
12
  export { default as display } from './display';
13
13
  export { default as flexbox } from './flexbox';
14
14
  export * from './flexbox';
15
- export { default as grid } from './grid';
16
- export * from './grid';
15
+ export { default as grid } from './cssGrid';
16
+ export * from './cssGrid';
17
17
  export { default as palette } from './palette';
18
18
  export * from './palette';
19
19
  export { default as positions } from './positions';
@@ -45,6 +45,12 @@ export * from './colorManipulator';
45
45
  export { default as ThemeProvider } from './ThemeProvider';
46
46
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
47
47
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
48
+ /** ----------------- */
49
+
50
+ /** Layout components */
51
+
48
52
  export { default as createContainer } from './Container/createContainer';
49
53
  export { default as Container } from './Container';
50
- export * from './Container';
54
+ export * from './Container';
55
+ export { default as Unstable_Grid } from './Unstable_Grid/Grid';
56
+ export * from './Unstable_Grid';
@@ -0,0 +1,179 @@
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 a number, it sets the number of columns the grid item uses.
62
+ * It can't be greater than the total number of columns of the container (12 by default).
63
+ * If 'auto', the grid item's width matches its content.
64
+ * If false, the prop is ignored.
65
+ * If true, the grid item's width grows to use the space available in the grid container.
66
+ * The value is applied for the `lg` breakpoint and wider screens if not overridden.
67
+ * @default false
68
+ */
69
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
70
+
71
+ /**
72
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
73
+ * If 'auto', the grid item push itself to the right-end of the container.
74
+ * The value is applied for the `lg` breakpoint and wider screens if not overridden.
75
+ */
76
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
77
+
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 the `md` breakpoint and wider screens if not overridden.
85
+ * @default false
86
+ */
87
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
88
+
89
+ /**
90
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
91
+ * If 'auto', the grid item push itself to the right-end of the container.
92
+ * The value is applied for the `md` breakpoint and wider screens if not overridden.
93
+ */
94
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
95
+
96
+ /**
97
+ * Defines the vertical space between the type `item` components.
98
+ * It overrides the value of the `spacing` prop.
99
+ */
100
+ rowSpacing: PropTypes
101
+ /* @typescript-to-proptypes-ignore */
102
+ .oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
103
+
104
+ /**
105
+ * If a number, it sets the number of columns the grid item uses.
106
+ * It can't be greater than the total number of columns of the container (12 by default).
107
+ * If 'auto', the grid item's width matches its content.
108
+ * If false, the prop is ignored.
109
+ * If true, the grid item's width grows to use the space available in the grid container.
110
+ * The value is applied for the `sm` breakpoint and wider screens if not overridden.
111
+ * @default false
112
+ */
113
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
114
+
115
+ /**
116
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
117
+ * If 'auto', the grid item push itself to the right-end of the container.
118
+ * The value is applied for the `sm` breakpoint and wider screens if not overridden.
119
+ */
120
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
121
+
122
+ /**
123
+ * Defines the space between the type `item` components.
124
+ * It can only be used on a type `container` component.
125
+ * @default 0
126
+ */
127
+ spacing: PropTypes
128
+ /* @typescript-to-proptypes-ignore */
129
+ .oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
130
+
131
+ /**
132
+ * @ignore
133
+ */
134
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
135
+
136
+ /**
137
+ * Defines the `flex-wrap` style property.
138
+ * It's applied for all screen sizes.
139
+ * @default 'wrap'
140
+ */
141
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
142
+
143
+ /**
144
+ * If a number, it sets the number of columns the grid item uses.
145
+ * It can't be greater than the total number of columns of the container (12 by default).
146
+ * If 'auto', the grid item's width matches its content.
147
+ * If false, the prop is ignored.
148
+ * If true, the grid item's width grows to use the space available in the grid container.
149
+ * The value is applied for the `xl` breakpoint and wider screens if not overridden.
150
+ * @default false
151
+ */
152
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
153
+
154
+ /**
155
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
156
+ * If 'auto', the grid item push itself to the right-end of the container.
157
+ * The value is applied for the `xl` breakpoint and wider screens if not overridden.
158
+ */
159
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
160
+
161
+ /**
162
+ * If a number, it sets the number of columns the grid item uses.
163
+ * It can't be greater than the total number of columns of the container (12 by default).
164
+ * If 'auto', the grid item's width matches its content.
165
+ * If false, the prop is ignored.
166
+ * If true, the grid item's width grows to use the space available in the grid container.
167
+ * The value is applied for all the screen sizes with the lowest priority.
168
+ * @default false
169
+ */
170
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
171
+
172
+ /**
173
+ * If a number, it sets the margin-left equals to the number of columns the grid item uses.
174
+ * If 'auto', the grid item push itself to the right-end of the container.
175
+ * The value is applied for the `xs` breakpoint and wider screens if not overridden.
176
+ */
177
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
178
+ } : void 0;
179
+ export default Grid;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,150 @@
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"];
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
+
40
+ const useUtilityClasses = (ownerState, theme) => {
41
+ const {
42
+ container,
43
+ direction,
44
+ spacing,
45
+ wrap,
46
+ gridSize
47
+ } = ownerState;
48
+ const slots = {
49
+ 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]) : [])]
50
+ };
51
+ return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
52
+ };
53
+
54
+ const GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
55
+ const Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
56
+ const theme = useTheme();
57
+ const themeProps = useThemeProps(inProps);
58
+ const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
59
+
60
+ const nested = React.useContext(NestedContext);
61
+
62
+ const {
63
+ className,
64
+ columns: columnsProp = 12,
65
+ container = false,
66
+ component = 'div',
67
+ direction = 'row',
68
+ wrap = 'wrap',
69
+ spacing: spacingProp = 0,
70
+ rowSpacing: rowSpacingProp = spacingProp,
71
+ columnSpacing: columnSpacingProp = spacingProp
72
+ } = props,
73
+ rest = _objectWithoutPropertiesLoose(props, _excluded); // collect breakpoints related props because they can be custom from the theme.
74
+
75
+
76
+ const gridSize = {};
77
+ const gridOffset = {};
78
+ const other = {};
79
+ Object.entries(rest).forEach(([key, val]) => {
80
+ if (theme.breakpoints.values[key] !== undefined) {
81
+ gridSize[key] = val;
82
+ } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
83
+ gridOffset[key.replace('Offset', '')] = val;
84
+ } else {
85
+ other[key] = val;
86
+ }
87
+ });
88
+ const columns = inProps.columns ?? (nested ? undefined : columnsProp);
89
+ const spacing = inProps.spacing ?? (nested ? undefined : spacingProp);
90
+ const rowSpacing = inProps.rowSpacing ?? inProps.spacing ?? (nested ? undefined : rowSpacingProp);
91
+ const columnSpacing = inProps.columnSpacing ?? inProps.spacing ?? (nested ? undefined : columnSpacingProp);
92
+
93
+ const ownerState = _extends({}, props, {
94
+ nested,
95
+ columns,
96
+ container,
97
+ direction,
98
+ wrap,
99
+ spacing,
100
+ rowSpacing,
101
+ columnSpacing,
102
+ gridSize,
103
+ gridOffset
104
+ });
105
+
106
+ const classes = useUtilityClasses(ownerState, theme);
107
+
108
+ let result = /*#__PURE__*/_jsx(GridRoot, _extends({
109
+ ref: ref,
110
+ as: component,
111
+ ownerState: ownerState,
112
+ className: clsx(classes.root, className)
113
+ }, other));
114
+
115
+ if (!nested) {
116
+ result = /*#__PURE__*/_jsx(NestedContext.Provider, {
117
+ value: true,
118
+ children: result
119
+ });
120
+ }
121
+
122
+ return result;
123
+ });
124
+ process.env.NODE_ENV !== "production" ? Grid.propTypes
125
+ /* remove-proptypes */
126
+ = {
127
+ children: PropTypes.node,
128
+ className: PropTypes.string,
129
+ columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
130
+ columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
131
+ component: PropTypes.elementType,
132
+ container: PropTypes.bool,
133
+ direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
134
+ lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
135
+ lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
136
+ md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
137
+ mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
138
+ rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
139
+ sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
140
+ smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
141
+ spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
142
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
143
+ wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
144
+ xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
145
+ xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
146
+ xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
147
+ xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
148
+ } : void 0;
149
+ return Grid;
150
+ }
@@ -0,0 +1,14 @@
1
+ import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
2
+ export function getGridUtilityClass(slot) {
3
+ return generateUtilityClass('MuiGrid', slot);
4
+ }
5
+ const SPACINGS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
6
+ const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'];
7
+ const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'];
8
+ const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
9
+ const gridClasses = generateUtilityClasses('MuiGrid', ['root', 'container', 'item', // spacings
10
+ ...SPACINGS.map(spacing => `spacing-xs-${spacing}`), // direction values
11
+ ...DIRECTIONS.map(direction => `direction-xs-${direction}`), // wrap values
12
+ ...WRAPS.map(wrap => `wrap-xs-${wrap}`), // grid sizes for all breakpoints
13
+ ...GRID_SIZES.map(size => `grid-xs-${size}`), ...GRID_SIZES.map(size => `grid-sm-${size}`), ...GRID_SIZES.map(size => `grid-md-${size}`), ...GRID_SIZES.map(size => `grid-lg-${size}`), ...GRID_SIZES.map(size => `grid-xl-${size}`)]);
14
+ export default gridClasses;