@mui/system 6.0.0-alpha.1 → 6.0.0-alpha.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 (128) hide show
  1. package/CHANGELOG.md +114 -2
  2. package/Container/Container.d.ts +1 -1
  3. package/Stack/Stack.d.ts +1 -1
  4. package/Stack/createStack.d.ts +1 -1
  5. package/Unstable_Grid/Grid.d.ts +1 -1
  6. package/Unstable_Grid/createGrid.d.ts +1 -1
  7. package/breakpoints/breakpoints.js +19 -1
  8. package/createTheme/createTheme.d.ts +2 -1
  9. package/createTheme/createTheme.js +2 -0
  10. package/cssContainerQueries/cssContainerQueries.d.ts +24 -0
  11. package/cssContainerQueries/cssContainerQueries.js +68 -0
  12. package/cssContainerQueries/index.d.ts +3 -0
  13. package/cssContainerQueries/index.js +2 -0
  14. package/cssContainerQueries/package.json +6 -0
  15. package/cssVars/cssVarsParser.d.ts +1 -1
  16. package/index.d.ts +2 -0
  17. package/index.js +2 -1
  18. package/modern/breakpoints/breakpoints.js +19 -1
  19. package/modern/createTheme/createTheme.js +2 -0
  20. package/modern/cssContainerQueries/cssContainerQueries.js +68 -0
  21. package/modern/cssContainerQueries/index.js +2 -0
  22. package/modern/index.js +2 -1
  23. package/modern/styleFunctionSx/styleFunctionSx.js +2 -1
  24. package/node/breakpoints/breakpoints.js +19 -1
  25. package/node/createTheme/createTheme.js +2 -0
  26. package/node/cssContainerQueries/cssContainerQueries.js +79 -0
  27. package/node/cssContainerQueries/index.js +32 -0
  28. package/node/index.js +9 -1
  29. package/node/styleFunctionSx/styleFunctionSx.js +2 -1
  30. package/package.json +5 -5
  31. package/styleFunctionSx/styleFunctionSx.js +2 -1
  32. package/legacy/Box/Box.js +0 -30
  33. package/legacy/Box/boxClasses.js +0 -3
  34. package/legacy/Box/index.js +0 -5
  35. package/legacy/Container/Container.js +0 -61
  36. package/legacy/Container/ContainerProps.js +0 -1
  37. package/legacy/Container/containerClasses.js +0 -7
  38. package/legacy/Container/createContainer.js +0 -140
  39. package/legacy/Container/index.js +0 -5
  40. package/legacy/GlobalStyles/GlobalStyles.js +0 -37
  41. package/legacy/GlobalStyles/index.js +0 -4
  42. package/legacy/RtlProvider/index.js +0 -22
  43. package/legacy/Stack/Stack.js +0 -62
  44. package/legacy/Stack/StackProps.js +0 -1
  45. package/legacy/Stack/createStack.js +0 -180
  46. package/legacy/Stack/index.js +0 -7
  47. package/legacy/Stack/stackClasses.js +0 -7
  48. package/legacy/ThemeProvider/ThemeProvider.js +0 -87
  49. package/legacy/ThemeProvider/index.js +0 -3
  50. package/legacy/Unstable_Grid/Grid.js +0 -177
  51. package/legacy/Unstable_Grid/GridProps.js +0 -1
  52. package/legacy/Unstable_Grid/createGrid.js +0 -184
  53. package/legacy/Unstable_Grid/gridClasses.js +0 -28
  54. package/legacy/Unstable_Grid/gridGenerator.js +0 -216
  55. package/legacy/Unstable_Grid/index.js +0 -8
  56. package/legacy/Unstable_Grid/traverseBreakpoints.js +0 -48
  57. package/legacy/borders/borders.js +0 -51
  58. package/legacy/borders/index.js +0 -4
  59. package/legacy/breakpoints/breakpoints.js +0 -162
  60. package/legacy/breakpoints/index.js +0 -4
  61. package/legacy/colorManipulator/colorManipulator.js +0 -356
  62. package/legacy/colorManipulator/index.js +0 -3
  63. package/legacy/compose/compose.js +0 -32
  64. package/legacy/compose/index.js +0 -3
  65. package/legacy/createBox/createBox.js +0 -38
  66. package/legacy/createBox/index.js +0 -3
  67. package/legacy/createStyled/createStyled.js +0 -250
  68. package/legacy/createStyled/index.js +0 -4
  69. package/legacy/createTheme/applyStyles.js +0 -73
  70. package/legacy/createTheme/createBreakpoints.js +0 -83
  71. package/legacy/createTheme/createSpacing.js +0 -32
  72. package/legacy/createTheme/createTheme.js +0 -49
  73. package/legacy/createTheme/index.js +0 -3
  74. package/legacy/createTheme/shape.js +0 -4
  75. package/legacy/cssGrid/cssGrid.js +0 -91
  76. package/legacy/cssGrid/index.js +0 -4
  77. package/legacy/cssVars/createCssVarsProvider.js +0 -338
  78. package/legacy/cssVars/createCssVarsTheme.js +0 -13
  79. package/legacy/cssVars/createGetCssVar.js +0 -30
  80. package/legacy/cssVars/cssVarsParser.js +0 -141
  81. package/legacy/cssVars/getInitColorSchemeScript.js +0 -28
  82. package/legacy/cssVars/index.js +0 -6
  83. package/legacy/cssVars/prepareCssVars.js +0 -92
  84. package/legacy/cssVars/useCurrentColorScheme.js +0 -237
  85. package/legacy/display/display.js +0 -29
  86. package/legacy/display/index.js +0 -4
  87. package/legacy/flexbox/flexbox.js +0 -43
  88. package/legacy/flexbox/index.js +0 -4
  89. package/legacy/getThemeValue/getThemeValue.js +0 -47
  90. package/legacy/getThemeValue/index.js +0 -4
  91. package/legacy/index.js +0 -72
  92. package/legacy/memoize/index.js +0 -3
  93. package/legacy/memoize/memoize.js +0 -9
  94. package/legacy/merge/index.js +0 -3
  95. package/legacy/merge/merge.js +0 -10
  96. package/legacy/palette/index.js +0 -4
  97. package/legacy/palette/palette.js +0 -26
  98. package/legacy/positions/index.js +0 -4
  99. package/legacy/positions/positions.js +0 -22
  100. package/legacy/propsToClassKey/index.js +0 -3
  101. package/legacy/propsToClassKey/propsToClassKey.js +0 -24
  102. package/legacy/responsivePropType/index.js +0 -3
  103. package/legacy/responsivePropType/responsivePropType.js +0 -3
  104. package/legacy/shadows/index.js +0 -3
  105. package/legacy/shadows/shadows.js +0 -6
  106. package/legacy/sizing/index.js +0 -4
  107. package/legacy/sizing/sizing.js +0 -65
  108. package/legacy/spacing/index.js +0 -4
  109. package/legacy/spacing/spacing.js +0 -161
  110. package/legacy/style/index.js +0 -4
  111. package/legacy/style/style.js +0 -73
  112. package/legacy/styleFunctionSx/defaultSxConfig.js +0 -293
  113. package/legacy/styleFunctionSx/extendSxProp.js +0 -45
  114. package/legacy/styleFunctionSx/index.js +0 -4
  115. package/legacy/styleFunctionSx/styleFunctionSx.js +0 -126
  116. package/legacy/styled/index.js +0 -3
  117. package/legacy/styled/styled.js +0 -3
  118. package/legacy/typography/index.js +0 -4
  119. package/legacy/typography/typography.js +0 -37
  120. package/legacy/useMediaQuery/index.js +0 -2
  121. package/legacy/useMediaQuery/useMediaQuery.js +0 -145
  122. package/legacy/useTheme/index.js +0 -4
  123. package/legacy/useTheme/useTheme.js +0 -10
  124. package/legacy/useThemeProps/getThemeProps.js +0 -10
  125. package/legacy/useThemeProps/index.js +0 -4
  126. package/legacy/useThemeProps/useThemeProps.js +0 -20
  127. package/legacy/useThemeWithoutDefault/index.js +0 -3
  128. package/legacy/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -13
@@ -1,180 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import _typeof from "@babel/runtime/helpers/esm/typeof";
4
- import _extends from "@babel/runtime/helpers/esm/extends";
5
- import * as React from 'react';
6
- import PropTypes from 'prop-types';
7
- import clsx from 'clsx';
8
- import deepmerge from '@mui/utils/deepmerge';
9
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
10
- import composeClasses from '@mui/utils/composeClasses';
11
- import systemStyled from '../styled';
12
- import useThemePropsSystem from '../useThemeProps';
13
- import { extendSxProp } from '../styleFunctionSx';
14
- import createTheme from '../createTheme';
15
- import { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues } from '../breakpoints';
16
- import { createUnarySpacing, getValue } from '../spacing';
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- var defaultTheme = createTheme();
19
- // widening Theme to any so that the consumer can own the theme structure.
20
- var defaultCreateStyledComponent = systemStyled('div', {
21
- name: 'MuiStack',
22
- slot: 'Root',
23
- overridesResolver: function overridesResolver(props, styles) {
24
- return styles.root;
25
- }
26
- });
27
- function useThemePropsDefault(props) {
28
- return useThemePropsSystem({
29
- props: props,
30
- name: 'MuiStack',
31
- defaultTheme: defaultTheme
32
- });
33
- }
34
-
35
- /**
36
- * Return an array with the separator React element interspersed between
37
- * each React node of the input children.
38
- *
39
- * > joinChildren([1,2,3], 0)
40
- * [1,0,2,0,3]
41
- */
42
- function joinChildren(children, separator) {
43
- var childrenArray = React.Children.toArray(children).filter(Boolean);
44
- return childrenArray.reduce(function (output, child, index) {
45
- output.push(child);
46
- if (index < childrenArray.length - 1) {
47
- output.push( /*#__PURE__*/React.cloneElement(separator, {
48
- key: "separator-".concat(index)
49
- }));
50
- }
51
- return output;
52
- }, []);
53
- }
54
- var getSideFromDirection = function getSideFromDirection(direction) {
55
- return {
56
- row: 'Left',
57
- 'row-reverse': 'Right',
58
- column: 'Top',
59
- 'column-reverse': 'Bottom'
60
- }[direction];
61
- };
62
- export var style = function style(_ref) {
63
- var ownerState = _ref.ownerState,
64
- theme = _ref.theme;
65
- var styles = _extends({
66
- display: 'flex',
67
- flexDirection: 'column'
68
- }, handleBreakpoints({
69
- theme: theme
70
- }, resolveBreakpointValues({
71
- values: ownerState.direction,
72
- breakpoints: theme.breakpoints.values
73
- }), function (propValue) {
74
- return {
75
- flexDirection: propValue
76
- };
77
- }));
78
- if (ownerState.spacing) {
79
- var transformer = createUnarySpacing(theme);
80
- var base = Object.keys(theme.breakpoints.values).reduce(function (acc, breakpoint) {
81
- if (_typeof(ownerState.spacing) === 'object' && ownerState.spacing[breakpoint] != null || _typeof(ownerState.direction) === 'object' && ownerState.direction[breakpoint] != null) {
82
- acc[breakpoint] = true;
83
- }
84
- return acc;
85
- }, {});
86
- var directionValues = resolveBreakpointValues({
87
- values: ownerState.direction,
88
- base: base
89
- });
90
- var spacingValues = resolveBreakpointValues({
91
- values: ownerState.spacing,
92
- base: base
93
- });
94
- if (_typeof(directionValues) === 'object') {
95
- Object.keys(directionValues).forEach(function (breakpoint, index, breakpoints) {
96
- var directionValue = directionValues[breakpoint];
97
- if (!directionValue) {
98
- var previousDirectionValue = index > 0 ? directionValues[breakpoints[index - 1]] : 'column';
99
- directionValues[breakpoint] = previousDirectionValue;
100
- }
101
- });
102
- }
103
- var styleFromPropValue = function styleFromPropValue(propValue, breakpoint) {
104
- if (ownerState.useFlexGap) {
105
- return {
106
- gap: getValue(transformer, propValue)
107
- };
108
- }
109
- return {
110
- // The useFlexGap={false} implement relies on each child to give up control of the margin.
111
- // We need to reset the margin to avoid double spacing.
112
- '& > :not(style):not(style)': {
113
- margin: 0
114
- },
115
- '& > :not(style) ~ :not(style)': _defineProperty({}, "margin".concat(getSideFromDirection(breakpoint ? directionValues[breakpoint] : ownerState.direction)), getValue(transformer, propValue))
116
- };
117
- };
118
- styles = deepmerge(styles, handleBreakpoints({
119
- theme: theme
120
- }, spacingValues, styleFromPropValue));
121
- }
122
- styles = mergeBreakpointsInOrder(theme.breakpoints, styles);
123
- return styles;
124
- };
125
- export default function createStack() {
126
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
127
- var _options$createStyled = options.createStyledComponent,
128
- createStyledComponent = _options$createStyled === void 0 ? defaultCreateStyledComponent : _options$createStyled,
129
- _options$useThemeProp = options.useThemeProps,
130
- useThemeProps = _options$useThemeProp === void 0 ? useThemePropsDefault : _options$useThemeProp,
131
- _options$componentNam = options.componentName,
132
- componentName = _options$componentNam === void 0 ? 'MuiStack' : _options$componentNam;
133
- var useUtilityClasses = function useUtilityClasses() {
134
- var slots = {
135
- root: ['root']
136
- };
137
- return composeClasses(slots, function (slot) {
138
- return generateUtilityClass(componentName, slot);
139
- }, {});
140
- };
141
- var StackRoot = createStyledComponent(style);
142
- var Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
143
- var themeProps = useThemeProps(inProps);
144
- var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
145
- var _props$component = props.component,
146
- component = _props$component === void 0 ? 'div' : _props$component,
147
- _props$direction = props.direction,
148
- direction = _props$direction === void 0 ? 'column' : _props$direction,
149
- _props$spacing = props.spacing,
150
- spacing = _props$spacing === void 0 ? 0 : _props$spacing,
151
- divider = props.divider,
152
- children = props.children,
153
- className = props.className,
154
- _props$useFlexGap = props.useFlexGap,
155
- useFlexGap = _props$useFlexGap === void 0 ? false : _props$useFlexGap,
156
- other = _objectWithoutProperties(props, ["component", "direction", "spacing", "divider", "children", "className", "useFlexGap"]);
157
- var ownerState = {
158
- direction: direction,
159
- spacing: spacing,
160
- useFlexGap: useFlexGap
161
- };
162
- var classes = useUtilityClasses();
163
- return /*#__PURE__*/_jsx(StackRoot, _extends({
164
- as: component,
165
- ownerState: ownerState,
166
- ref: ref,
167
- className: clsx(classes.root, className)
168
- }, other, {
169
- children: divider ? joinChildren(children, divider) : children
170
- }));
171
- });
172
- process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
173
- children: PropTypes.node,
174
- direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
175
- divider: PropTypes.node,
176
- spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
177
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
178
- } : void 0;
179
- return Stack;
180
- }
@@ -1,7 +0,0 @@
1
- 'use client';
2
-
3
- export { default } from './Stack';
4
- export { default as createStack } from './createStack';
5
- export * from './StackProps';
6
- export { default as stackClasses } from './stackClasses';
7
- export * from './stackClasses';
@@ -1,7 +0,0 @@
1
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
2
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
- export function getStackUtilityClass(slot) {
4
- return generateUtilityClass('MuiStack', slot);
5
- }
6
- var stackClasses = generateUtilityClasses('MuiStack', ['root']);
7
- export default stackClasses;
@@ -1,87 +0,0 @@
1
- 'use client';
2
-
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import _extends from "@babel/runtime/helpers/esm/extends";
5
- import * as React from 'react';
6
- import PropTypes from 'prop-types';
7
- import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
8
- import exactProp from '@mui/utils/exactProp';
9
- import { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';
10
- import useThemeWithoutDefault from '../useThemeWithoutDefault';
11
- import RtlProvider from '../RtlProvider';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- var EMPTY_THEME = {};
14
- function useThemeScoping(themeId, upperTheme, localTheme) {
15
- var isPrivate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
16
- return React.useMemo(function () {
17
- var resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
18
- if (typeof localTheme === 'function') {
19
- var mergedTheme = localTheme(resolvedTheme);
20
- var result = themeId ? _extends({}, upperTheme, _defineProperty({}, themeId, mergedTheme)) : mergedTheme;
21
- // must return a function for the private theme to NOT merge with the upper theme.
22
- // see the test case "use provided theme from a callback" in ThemeProvider.test.js
23
- if (isPrivate) {
24
- return function () {
25
- return result;
26
- };
27
- }
28
- return result;
29
- }
30
- return themeId ? _extends({}, upperTheme, _defineProperty({}, themeId, localTheme)) : _extends({}, upperTheme, localTheme);
31
- }, [themeId, upperTheme, localTheme, isPrivate]);
32
- }
33
-
34
- /**
35
- * This component makes the `theme` available down the React tree.
36
- * It should preferably be used at **the root of your component tree**.
37
- *
38
- * <ThemeProvider theme={theme}> // existing use case
39
- * <ThemeProvider theme={{ id: theme }}> // theme scoping
40
- */
41
- function ThemeProvider(props) {
42
- var children = props.children,
43
- localTheme = props.theme,
44
- themeId = props.themeId;
45
- var upperTheme = useThemeWithoutDefault(EMPTY_THEME);
46
- var upperPrivateTheme = usePrivateTheme() || EMPTY_THEME;
47
- if (process.env.NODE_ENV !== 'production') {
48
- if (upperTheme === null && typeof localTheme === 'function' || themeId && upperTheme && !upperTheme[themeId] && typeof localTheme === 'function') {
49
- console.error(['MUI: You are providing a theme function prop to the ThemeProvider component:', '<ThemeProvider theme={outerTheme => outerTheme} />', '', 'However, no outer theme is present.', 'Make sure a theme is already injected higher in the React tree ' + 'or provide a theme object.'].join('\n'));
50
- }
51
- }
52
- var engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
53
- var privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
54
- var rtlValue = engineTheme.direction === 'rtl';
55
- return /*#__PURE__*/_jsx(MuiThemeProvider, {
56
- theme: privateTheme,
57
- children: /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {
58
- value: engineTheme,
59
- children: /*#__PURE__*/_jsx(RtlProvider, {
60
- value: rtlValue,
61
- children: children
62
- })
63
- })
64
- });
65
- }
66
- process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes /* remove-proptypes */ = {
67
- // ┌────────────────────────────── Warning ──────────────────────────────┐
68
- // │ These PropTypes are generated from the TypeScript type definitions. │
69
- // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
70
- // └─────────────────────────────────────────────────────────────────────┘
71
- /**
72
- * Your component tree.
73
- */
74
- children: PropTypes.node,
75
- /**
76
- * A theme object. You can provide a function to extend the outer theme.
77
- */
78
- theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
79
- /**
80
- * The design system's unique id for getting the corresponded theme when there are multiple design systems.
81
- */
82
- themeId: PropTypes.string
83
- } : void 0;
84
- if (process.env.NODE_ENV !== 'production') {
85
- process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes) : void 0;
86
- }
87
- export default ThemeProvider;
@@ -1,3 +0,0 @@
1
- 'use client';
2
-
3
- export { default } from './ThemeProvider';
@@ -1,177 +0,0 @@
1
- 'use client';
2
-
3
- import PropTypes from 'prop-types';
4
- import createGrid from './createGrid';
5
- /**
6
- *
7
- * Demos:
8
- *
9
- * - [Grid (Joy UI)](https://mui.com/joy-ui/react-grid/)
10
- * - [Grid (Material UI)](https://mui.com/material-ui/react-grid/)
11
- *
12
- * API:
13
- *
14
- * - [Grid API](https://mui.com/system/api/grid/)
15
- */
16
- var Grid = createGrid();
17
- process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ = {
18
- // ┌────────────────────────────── Warning ──────────────────────────────┐
19
- // │ These PropTypes are generated from the TypeScript type definitions. │
20
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
21
- // └─────────────────────────────────────────────────────────────────────┘
22
- /**
23
- * The content of the component.
24
- */
25
- children: PropTypes.node,
26
- /**
27
- * The number of columns.
28
- * @default 12
29
- */
30
- columns: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
31
- /**
32
- * Defines the horizontal space between the type `item` components.
33
- * It overrides the value of the `spacing` prop.
34
- */
35
- columnSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
36
- /**
37
- * If `true`, the component will have the flex *container* behavior.
38
- * You should be wrapping *items* with a *container*.
39
- * @default false
40
- */
41
- container: PropTypes.bool,
42
- /**
43
- * Defines the `flex-direction` style property.
44
- * It is applied for all screen sizes.
45
- * @default 'row'
46
- */
47
- direction: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
48
- /**
49
- * If `true`, the negative margin and padding are apply only to the top and left sides of the grid.
50
- */
51
- disableEqualOverflow: PropTypes.bool,
52
- /**
53
- * If a number, it sets the number of columns the grid item uses.
54
- * It can't be greater than the total number of columns of the container (12 by default).
55
- * If 'auto', the grid item's width matches its content.
56
- * If false, the prop is ignored.
57
- * If true, the grid item's width grows to use the space available in the grid container.
58
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
59
- * @default false
60
- */
61
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
62
- /**
63
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
64
- * If 'auto', the grid item push itself to the right-end of the container.
65
- * The value is applied for the `lg` breakpoint and wider screens if not overridden.
66
- */
67
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
68
- /**
69
- * If a number, it sets the number of columns the grid item uses.
70
- * It can't be greater than the total number of columns of the container (12 by default).
71
- * If 'auto', the grid item's width matches its content.
72
- * If false, the prop is ignored.
73
- * If true, the grid item's width grows to use the space available in the grid container.
74
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
75
- * @default false
76
- */
77
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
78
- /**
79
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
80
- * If 'auto', the grid item push itself to the right-end of the container.
81
- * The value is applied for the `md` breakpoint and wider screens if not overridden.
82
- */
83
- mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
84
- /**
85
- * Defines the vertical space between the type `item` components.
86
- * It overrides the value of the `spacing` prop.
87
- */
88
- rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
89
- /**
90
- * If a number, it sets the number of columns the grid item uses.
91
- * It can't be greater than the total number of columns of the container (12 by default).
92
- * If 'auto', the grid item's width matches its content.
93
- * If false, the prop is ignored.
94
- * If true, the grid item's width grows to use the space available in the grid container.
95
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
96
- * @default false
97
- */
98
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
99
- /**
100
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
101
- * If 'auto', the grid item push itself to the right-end of the container.
102
- * The value is applied for the `sm` breakpoint and wider screens if not overridden.
103
- */
104
- smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
105
- /**
106
- * Defines the space between the type `item` components.
107
- * It can only be used on a type `container` component.
108
- * @default 0
109
- */
110
- spacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
111
- /**
112
- * @ignore
113
- */
114
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
115
- /**
116
- * @internal
117
- * The level of the grid starts from `0`
118
- * and increases when the grid nests inside another grid regardless of container or item.
119
- *
120
- * ```js
121
- * <Grid> // level 0
122
- * <Grid> // level 1
123
- * <Grid> // level 2
124
- * <Grid> // level 1
125
- * ```
126
- *
127
- * Only consecutive grid is considered nesting.
128
- * A grid container will start at `0` if there are non-Grid element above it.
129
- *
130
- * ```js
131
- * <Grid> // level 0
132
- * <div>
133
- * <Grid> // level 0
134
- * <Grid> // level 1
135
- * ```
136
- */
137
- unstable_level: PropTypes.number,
138
- /**
139
- * Defines the `flex-wrap` style property.
140
- * It's applied for all screen sizes.
141
- * @default 'wrap'
142
- */
143
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
144
- /**
145
- * If a number, it sets the number of columns the grid item uses.
146
- * It can't be greater than the total number of columns of the container (12 by default).
147
- * If 'auto', the grid item's width matches its content.
148
- * If false, the prop is ignored.
149
- * If true, the grid item's width grows to use the space available in the grid container.
150
- * The value is applied for the `xl` breakpoint and wider screens if not overridden.
151
- * @default false
152
- */
153
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
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
- * If a number, it sets the number of columns the grid item uses.
162
- * It can't be greater than the total number of columns of the container (12 by default).
163
- * If 'auto', the grid item's width matches its content.
164
- * If false, the prop is ignored.
165
- * If true, the grid item's width grows to use the space available in the grid container.
166
- * The value is applied for all the screen sizes with the lowest priority.
167
- * @default false
168
- */
169
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
170
- /**
171
- * If a number, it sets the margin-left equals to the number of columns the grid item uses.
172
- * If 'auto', the grid item push itself to the right-end of the container.
173
- * The value is applied for the `xs` breakpoint and wider screens if not overridden.
174
- */
175
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
176
- } : void 0;
177
- export default Grid;
@@ -1 +0,0 @@
1
- export {};
@@ -1,184 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- import * as React from 'react';
6
- import PropTypes from 'prop-types';
7
- import clsx from 'clsx';
8
- import isMuiElement from '@mui/utils/isMuiElement';
9
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
10
- import composeClasses from '@mui/utils/composeClasses';
11
- import systemStyled from '../styled';
12
- import useThemePropsSystem from '../useThemeProps';
13
- import useTheme from '../useTheme';
14
- import { extendSxProp } from '../styleFunctionSx';
15
- import createTheme from '../createTheme';
16
- import { generateGridStyles, generateGridSizeStyles, generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridDirectionStyles, generateGridOffsetStyles, generateSizeClassNames, generateSpacingClassNames, generateDirectionClasses } from './gridGenerator';
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- var defaultTheme = createTheme();
19
-
20
- // widening Theme to any so that the consumer can own the theme structure.
21
- var defaultCreateStyledComponent = systemStyled('div', {
22
- name: 'MuiGrid',
23
- slot: 'Root',
24
- overridesResolver: function overridesResolver(props, styles) {
25
- return styles.root;
26
- }
27
- });
28
- function useThemePropsDefault(props) {
29
- return useThemePropsSystem({
30
- props: props,
31
- name: 'MuiGrid',
32
- defaultTheme: defaultTheme
33
- });
34
- }
35
- export default function createGrid() {
36
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
37
- var _options$createStyled = options.createStyledComponent,
38
- createStyledComponent = _options$createStyled === void 0 ? defaultCreateStyledComponent : _options$createStyled,
39
- _options$useThemeProp = options.useThemeProps,
40
- useThemeProps = _options$useThemeProp === void 0 ? useThemePropsDefault : _options$useThemeProp,
41
- _options$componentNam = options.componentName,
42
- componentName = _options$componentNam === void 0 ? 'MuiGrid' : _options$componentNam;
43
- var GridOverflowContext = /*#__PURE__*/React.createContext(undefined);
44
- if (process.env.NODE_ENV !== 'production') {
45
- GridOverflowContext.displayName = 'GridOverflowContext';
46
- }
47
- var useUtilityClasses = function useUtilityClasses(ownerState, theme) {
48
- var container = ownerState.container,
49
- direction = ownerState.direction,
50
- spacing = ownerState.spacing,
51
- wrap = ownerState.wrap,
52
- gridSize = ownerState.gridSize;
53
- var slots = {
54
- root: ['root', container && 'container', wrap !== 'wrap' && "wrap-xs-".concat(String(wrap))].concat(_toConsumableArray(generateDirectionClasses(direction)), _toConsumableArray(generateSizeClassNames(gridSize)), _toConsumableArray(container ? generateSpacingClassNames(spacing, theme.breakpoints.keys[0]) : []))
55
- };
56
- return composeClasses(slots, function (slot) {
57
- return generateUtilityClass(componentName, slot);
58
- }, {});
59
- };
60
- var GridRoot = createStyledComponent(generateGridColumnsStyles, generateGridColumnSpacingStyles, generateGridRowSpacingStyles, generateGridSizeStyles, generateGridDirectionStyles, generateGridStyles, generateGridOffsetStyles);
61
- var Grid = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
62
- var _inProps$columns, _inProps$spacing, _ref3, _inProps$rowSpacing, _ref4, _inProps$columnSpacin, _ref5, _disableEqualOverflow;
63
- var theme = useTheme();
64
- var themeProps = useThemeProps(inProps);
65
- var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
66
- var overflow = React.useContext(GridOverflowContext);
67
- var className = props.className,
68
- children = props.children,
69
- _props$columns = props.columns,
70
- columnsProp = _props$columns === void 0 ? 12 : _props$columns,
71
- _props$container = props.container,
72
- container = _props$container === void 0 ? false : _props$container,
73
- _props$component = props.component,
74
- component = _props$component === void 0 ? 'div' : _props$component,
75
- _props$direction = props.direction,
76
- direction = _props$direction === void 0 ? 'row' : _props$direction,
77
- _props$wrap = props.wrap,
78
- wrap = _props$wrap === void 0 ? 'wrap' : _props$wrap,
79
- _props$spacing = props.spacing,
80
- spacingProp = _props$spacing === void 0 ? 0 : _props$spacing,
81
- _props$rowSpacing = props.rowSpacing,
82
- rowSpacingProp = _props$rowSpacing === void 0 ? spacingProp : _props$rowSpacing,
83
- _props$columnSpacing = props.columnSpacing,
84
- columnSpacingProp = _props$columnSpacing === void 0 ? spacingProp : _props$columnSpacing,
85
- themeDisableEqualOverflow = props.disableEqualOverflow,
86
- _props$unstable_level = props.unstable_level,
87
- level = _props$unstable_level === void 0 ? 0 : _props$unstable_level,
88
- rest = _objectWithoutProperties(props, ["className", "children", "columns", "container", "component", "direction", "wrap", "spacing", "rowSpacing", "columnSpacing", "disableEqualOverflow", "unstable_level"]); // Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
89
- var disableEqualOverflow = themeDisableEqualOverflow;
90
- if (level && themeDisableEqualOverflow !== undefined) {
91
- disableEqualOverflow = inProps.disableEqualOverflow;
92
- }
93
- // collect breakpoints related props because they can be customized from the theme.
94
- var gridSize = {};
95
- var gridOffset = {};
96
- var other = {};
97
- Object.entries(rest).forEach(function (_ref) {
98
- var _ref2 = _slicedToArray(_ref, 2),
99
- key = _ref2[0],
100
- val = _ref2[1];
101
- if (theme.breakpoints.values[key] !== undefined) {
102
- gridSize[key] = val;
103
- } else if (theme.breakpoints.values[key.replace('Offset', '')] !== undefined) {
104
- gridOffset[key.replace('Offset', '')] = val;
105
- } else {
106
- other[key] = val;
107
- }
108
- });
109
- var columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : level ? undefined : columnsProp;
110
- var spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : level ? undefined : spacingProp;
111
- var rowSpacing = (_ref3 = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref3 : level ? undefined : rowSpacingProp;
112
- var columnSpacing = (_ref4 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref4 : level ? undefined : columnSpacingProp;
113
- var ownerState = _extends({}, props, {
114
- level: level,
115
- columns: columns,
116
- container: container,
117
- direction: direction,
118
- wrap: wrap,
119
- spacing: spacing,
120
- rowSpacing: rowSpacing,
121
- columnSpacing: columnSpacing,
122
- gridSize: gridSize,
123
- gridOffset: gridOffset,
124
- disableEqualOverflow: (_ref5 = (_disableEqualOverflow = disableEqualOverflow) != null ? _disableEqualOverflow : overflow) != null ? _ref5 : false,
125
- // use context value if exists.
126
- parentDisableEqualOverflow: overflow // for nested grid
127
- });
128
- var classes = useUtilityClasses(ownerState, theme);
129
- var result = /*#__PURE__*/_jsx(GridRoot, _extends({
130
- ref: ref,
131
- as: component,
132
- ownerState: ownerState,
133
- className: clsx(classes.root, className)
134
- }, other, {
135
- children: React.Children.map(children, function (child) {
136
- if ( /*#__PURE__*/React.isValidElement(child) && isMuiElement(child, ['Grid'])) {
137
- var _child$props$unstable;
138
- return /*#__PURE__*/React.cloneElement(child, {
139
- unstable_level: (_child$props$unstable = child.props.unstable_level) != null ? _child$props$unstable : level + 1
140
- });
141
- }
142
- return child;
143
- })
144
- }));
145
- if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow != null ? overflow : false)) {
146
- // There are 2 possibilities that should wrap with the GridOverflowContext to communicate with the nested grids:
147
- // 1. It is the root grid with `disableEqualOverflow`.
148
- // 2. It is a nested grid with different `disableEqualOverflow` from the context.
149
- result = /*#__PURE__*/_jsx(GridOverflowContext.Provider, {
150
- value: disableEqualOverflow,
151
- children: result
152
- });
153
- }
154
- return result;
155
- });
156
- process.env.NODE_ENV !== "production" ? Grid.propTypes /* remove-proptypes */ = {
157
- children: PropTypes.node,
158
- className: PropTypes.string,
159
- columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
160
- columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
161
- component: PropTypes.elementType,
162
- container: PropTypes.bool,
163
- direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
164
- disableEqualOverflow: PropTypes.bool,
165
- lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
166
- lgOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
167
- md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
168
- mdOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
169
- rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
170
- sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
171
- smOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
172
- spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
173
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
174
- wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
175
- xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
176
- xlOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
177
- xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
178
- xsOffset: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number])
179
- } : void 0;
180
-
181
- // @ts-ignore internal logic for nested grid
182
- Grid.muiName = 'Grid';
183
- return Grid;
184
- }