1 | 'use client';
|
2 |
|
3 | import composeClasses from '@mui/utils/composeClasses';
|
4 | import integerPropType from '@mui/utils/integerPropType';
|
5 | import clsx from 'clsx';
|
6 | import PropTypes from 'prop-types';
|
7 | import * as React from 'react';
|
8 | import { styled } from "../zero-styled/index.js";
|
9 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
10 | import { getImageListUtilityClass } from "./imageListClasses.js";
|
11 | import ImageListContext from "./ImageListContext.js";
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | classes,
|
16 | variant
|
17 | } = ownerState;
|
18 | const slots = {
|
19 | root: ['root', variant]
|
20 | };
|
21 | return composeClasses(slots, getImageListUtilityClass, classes);
|
22 | };
|
23 | const ImageListRoot = styled('ul', {
|
24 | name: 'MuiImageList',
|
25 | slot: 'Root',
|
26 | overridesResolver: (props, styles) => {
|
27 | const {
|
28 | ownerState
|
29 | } = props;
|
30 | return [styles.root, styles[ownerState.variant]];
|
31 | }
|
32 | })({
|
33 | display: 'grid',
|
34 | overflowY: 'auto',
|
35 | listStyle: 'none',
|
36 | padding: 0,
|
37 |
|
38 | WebkitOverflowScrolling: 'touch',
|
39 | variants: [{
|
40 | props: {
|
41 | variant: 'masonry'
|
42 | },
|
43 | style: {
|
44 | display: 'block'
|
45 | }
|
46 | }]
|
47 | });
|
48 | const ImageList = React.forwardRef(function ImageList(inProps, ref) {
|
49 | const props = useDefaultProps({
|
50 | props: inProps,
|
51 | name: 'MuiImageList'
|
52 | });
|
53 | const {
|
54 | children,
|
55 | className,
|
56 | cols = 2,
|
57 | component = 'ul',
|
58 | rowHeight = 'auto',
|
59 | gap = 4,
|
60 | style: styleProp,
|
61 | variant = 'standard',
|
62 | ...other
|
63 | } = props;
|
64 | const contextValue = React.useMemo(() => ({
|
65 | rowHeight,
|
66 | gap,
|
67 | variant
|
68 | }), [rowHeight, gap, variant]);
|
69 | const style = variant === 'masonry' ? {
|
70 | columnCount: cols,
|
71 | columnGap: gap,
|
72 | ...styleProp
|
73 | } : {
|
74 | gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
75 | gap,
|
76 | ...styleProp
|
77 | };
|
78 | const ownerState = {
|
79 | ...props,
|
80 | component,
|
81 | gap,
|
82 | rowHeight,
|
83 | variant
|
84 | };
|
85 | const classes = useUtilityClasses(ownerState);
|
86 | return _jsx(ImageListRoot, {
|
87 | as: component,
|
88 | className: clsx(classes.root, classes[variant], className),
|
89 | ref: ref,
|
90 | style: style,
|
91 | ownerState: ownerState,
|
92 | ...other,
|
93 | children: _jsx(ImageListContext.Provider, {
|
94 | value: contextValue,
|
95 | children: children
|
96 | })
|
97 | });
|
98 | });
|
99 | process.env.NODE_ENV !== "production" ? ImageList.propTypes = {
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | |
105 |
|
106 |
|
107 | children: PropTypes .node.isRequired,
|
108 | |
109 |
|
110 |
|
111 | classes: PropTypes.object,
|
112 | |
113 |
|
114 |
|
115 | className: PropTypes.string,
|
116 | |
117 |
|
118 |
|
119 |
|
120 | cols: integerPropType,
|
121 | |
122 |
|
123 |
|
124 |
|
125 | component: PropTypes.elementType,
|
126 | |
127 |
|
128 |
|
129 |
|
130 | gap: PropTypes.number,
|
131 | |
132 |
|
133 |
|
134 |
|
135 | rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
|
136 | |
137 |
|
138 |
|
139 | style: PropTypes.object,
|
140 | |
141 |
|
142 |
|
143 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
144 | |
145 |
|
146 |
|
147 |
|
148 | variant: PropTypes .oneOfType([PropTypes.oneOf(['masonry', 'quilted', 'standard', 'woven']), PropTypes.string])
|
149 | } : void 0;
|
150 | export default ImageList; |
\ | No newline at end of file |