UNPKG

5.1 kBJavaScriptView Raw
1import * as React from 'react';
2import clsx from 'clsx';
3import PropTypes from 'prop-types';
4// @ts-ignore
5import Grid from '@mui/material-pigment-css/Grid';
6import composeClasses from '@mui/utils/composeClasses';
7import generateUtilityClass from '@mui/utils/generateUtilityClass';
8import { generateDirectionClasses, generateSizeClassNames, generateSpacingClassNames } from '@mui/system/Grid/gridGenerator';
9import { jsx as _jsx } from "react/jsx-runtime";
10const useUtilityClasses = ownerState => {
11 const {
12 container,
13 direction,
14 size,
15 spacing
16 } = ownerState;
17 let gridSize = {};
18 if (size) {
19 if (Array.isArray(size)) {
20 size.forEach((value, index) => {
21 gridSize = {
22 ...gridSize,
23 [index]: value
24 };
25 });
26 }
27 if (typeof size === 'object') {
28 gridSize = size;
29 }
30 }
31 const slots = {
32 root: ['root', container && 'container', ...generateDirectionClasses(direction), ...generateSizeClassNames(gridSize), ...(container ? generateSpacingClassNames(spacing) : [])]
33 };
34 return composeClasses(slots, slot => generateUtilityClass('MuiGrid2', slot), {});
35};
36/**
37 *
38 * Demos:
39 *
40 * - [Grid version 2](https://mui.com/material-ui/react-grid2/)
41 *
42 * API:
43 *
44 * - [PigmentGrid API](https://mui.com/material-ui/api/pigment-grid/)
45 */
46const PigmentGrid = /*#__PURE__*/React.forwardRef(function PigmentGrid(props, ref) {
47 const {
48 className,
49 ...other
50 } = props;
51 const classes = useUtilityClasses(props);
52 return /*#__PURE__*/_jsx(Grid, {
53 ref: ref,
54 className: clsx(classes.root, className),
55 ...other
56 });
57});
58process.env.NODE_ENV !== "production" ? PigmentGrid.propTypes /* remove-proptypes */ = {
59 // ┌────────────────────────────── Warning ──────────────────────────────┐
60 // │ These PropTypes are generated from the TypeScript type definitions. │
61 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
62 // └─────────────────────────────────────────────────────────────────────┘
63 /**
64 * The content of the component.
65 */
66 children: PropTypes.node,
67 /**
68 * @ignore
69 */
70 className: PropTypes.string,
71 /**
72 * The number of columns.
73 * @default 12
74 */
75 columns: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
76 /**
77 * Defines the horizontal space between the type `item` components.
78 * It overrides the value of the `spacing` prop.
79 */
80 columnSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.object, PropTypes.string]),
81 /**
82 * If `true`, the component will have the flex *container* behavior.
83 * You should be wrapping *items* with a *container*.
84 * @default false
85 */
86 container: PropTypes.bool,
87 /**
88 * Defines the `flex-direction` style property.
89 * It is applied for all screen sizes.
90 * @default 'row'
91 */
92 direction: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['column', 'column-reverse', 'row', 'row-reverse']), PropTypes.arrayOf(PropTypes.oneOf(['column', 'column-reverse', 'row', 'row-reverse'])), PropTypes.object]),
93 /**
94 * Defines the offset of the grid.
95 */
96 offset: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
97 /**
98 * Defines the vertical space between the type `item` components.
99 * It overrides the value of the `spacing` prop.
100 */
101 rowSpacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.object, PropTypes.string]),
102 /**
103 * Defines the column size of the grid.
104 */
105 size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
106 /**
107 * Defines the space between the type `item` components.
108 * It can only be used on a type `container` component.
109 * @default 0
110 */
111 spacing: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.object, PropTypes.string]),
112 /**
113 * @ignore
114 */
115 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
116 /**
117 * Defines the `flex-wrap` style property.
118 * It's applied for all screen sizes.
119 * @default 'wrap'
120 */
121 wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap'])
122} : void 0;
123
124// @ts-ignore internal logic for nested grid
125PigmentGrid.muiName = 'Grid';
126export default PigmentGrid;
\No newline at end of file