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