1 | 'use client';
|
2 |
|
3 | import composeClasses from '@mui/utils/composeClasses';
|
4 | import clsx from 'clsx';
|
5 | import PropTypes from 'prop-types';
|
6 | import * as React from 'react';
|
7 | import { styled } from "../zero-styled/index.js";
|
8 | import memoTheme from "../utils/memoTheme.js";
|
9 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
10 | import capitalize from "../utils/capitalize.js";
|
11 | import { getImageListItemBarUtilityClass } from "./imageListItemBarClasses.js";
|
12 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | classes,
|
16 | position,
|
17 | actionIcon,
|
18 | actionPosition
|
19 | } = ownerState;
|
20 | const slots = {
|
21 | root: ['root', `position${capitalize(position)}`, `actionPosition${capitalize(actionPosition)}`],
|
22 | titleWrap: ['titleWrap', `titleWrap${capitalize(position)}`, actionIcon && `titleWrapActionPos${capitalize(actionPosition)}`],
|
23 | title: ['title'],
|
24 | subtitle: ['subtitle'],
|
25 | actionIcon: ['actionIcon', `actionIconActionPos${capitalize(actionPosition)}`]
|
26 | };
|
27 | return composeClasses(slots, getImageListItemBarUtilityClass, classes);
|
28 | };
|
29 | const ImageListItemBarRoot = styled('div', {
|
30 | name: 'MuiImageListItemBar',
|
31 | slot: 'Root',
|
32 | overridesResolver: (props, styles) => {
|
33 | const {
|
34 | ownerState
|
35 | } = props;
|
36 | return [styles.root, styles[`position${capitalize(ownerState.position)}`]];
|
37 | }
|
38 | })(memoTheme(({
|
39 | theme
|
40 | }) => {
|
41 | return {
|
42 | position: 'absolute',
|
43 | left: 0,
|
44 | right: 0,
|
45 | background: 'rgba(0, 0, 0, 0.5)',
|
46 | display: 'flex',
|
47 | alignItems: 'center',
|
48 | fontFamily: theme.typography.fontFamily,
|
49 | variants: [{
|
50 | props: {
|
51 | position: 'bottom'
|
52 | },
|
53 | style: {
|
54 | bottom: 0
|
55 | }
|
56 | }, {
|
57 | props: {
|
58 | position: 'top'
|
59 | },
|
60 | style: {
|
61 | top: 0
|
62 | }
|
63 | }, {
|
64 | props: {
|
65 | position: 'below'
|
66 | },
|
67 | style: {
|
68 | position: 'relative',
|
69 | background: 'transparent',
|
70 | alignItems: 'normal'
|
71 | }
|
72 | }]
|
73 | };
|
74 | }));
|
75 | const ImageListItemBarTitleWrap = styled('div', {
|
76 | name: 'MuiImageListItemBar',
|
77 | slot: 'TitleWrap',
|
78 | overridesResolver: (props, styles) => {
|
79 | const {
|
80 | ownerState
|
81 | } = props;
|
82 | return [styles.titleWrap, styles[`titleWrap${capitalize(ownerState.position)}`], ownerState.actionIcon && styles[`titleWrapActionPos${capitalize(ownerState.actionPosition)}`]];
|
83 | }
|
84 | })(memoTheme(({
|
85 | theme
|
86 | }) => {
|
87 | return {
|
88 | flexGrow: 1,
|
89 | padding: '12px 16px',
|
90 | color: (theme.vars || theme).palette.common.white,
|
91 | overflow: 'hidden',
|
92 | variants: [{
|
93 | props: {
|
94 | position: 'below'
|
95 | },
|
96 | style: {
|
97 | padding: '6px 0 12px',
|
98 | color: 'inherit'
|
99 | }
|
100 | }, {
|
101 | props: ({
|
102 | ownerState
|
103 | }) => ownerState.actionIcon && ownerState.actionPosition === 'left',
|
104 | style: {
|
105 | paddingLeft: 0
|
106 | }
|
107 | }, {
|
108 | props: ({
|
109 | ownerState
|
110 | }) => ownerState.actionIcon && ownerState.actionPosition === 'right',
|
111 | style: {
|
112 | paddingRight: 0
|
113 | }
|
114 | }]
|
115 | };
|
116 | }));
|
117 | const ImageListItemBarTitle = styled('div', {
|
118 | name: 'MuiImageListItemBar',
|
119 | slot: 'Title',
|
120 | overridesResolver: (props, styles) => styles.title
|
121 | })(memoTheme(({
|
122 | theme
|
123 | }) => {
|
124 | return {
|
125 | fontSize: theme.typography.pxToRem(16),
|
126 | lineHeight: '24px',
|
127 | textOverflow: 'ellipsis',
|
128 | overflow: 'hidden',
|
129 | whiteSpace: 'nowrap'
|
130 | };
|
131 | }));
|
132 | const ImageListItemBarSubtitle = styled('div', {
|
133 | name: 'MuiImageListItemBar',
|
134 | slot: 'Subtitle',
|
135 | overridesResolver: (props, styles) => styles.subtitle
|
136 | })(memoTheme(({
|
137 | theme
|
138 | }) => {
|
139 | return {
|
140 | fontSize: theme.typography.pxToRem(12),
|
141 | lineHeight: 1,
|
142 | textOverflow: 'ellipsis',
|
143 | overflow: 'hidden',
|
144 | whiteSpace: 'nowrap'
|
145 | };
|
146 | }));
|
147 | const ImageListItemBarActionIcon = styled('div', {
|
148 | name: 'MuiImageListItemBar',
|
149 | slot: 'ActionIcon',
|
150 | overridesResolver: (props, styles) => {
|
151 | const {
|
152 | ownerState
|
153 | } = props;
|
154 | return [styles.actionIcon, styles[`actionIconActionPos${capitalize(ownerState.actionPosition)}`]];
|
155 | }
|
156 | })({
|
157 | variants: [{
|
158 | props: {
|
159 | actionPosition: 'left'
|
160 | },
|
161 | style: {
|
162 | order: -1
|
163 | }
|
164 | }]
|
165 | });
|
166 | const ImageListItemBar = React.forwardRef(function ImageListItemBar(inProps, ref) {
|
167 | const props = useDefaultProps({
|
168 | props: inProps,
|
169 | name: 'MuiImageListItemBar'
|
170 | });
|
171 | const {
|
172 | actionIcon,
|
173 | actionPosition = 'right',
|
174 | className,
|
175 | subtitle,
|
176 | title,
|
177 | position = 'bottom',
|
178 | ...other
|
179 | } = props;
|
180 | const ownerState = {
|
181 | ...props,
|
182 | position,
|
183 | actionPosition
|
184 | };
|
185 | const classes = useUtilityClasses(ownerState);
|
186 | return _jsxs(ImageListItemBarRoot, {
|
187 | ownerState: ownerState,
|
188 | className: clsx(classes.root, className),
|
189 | ref: ref,
|
190 | ...other,
|
191 | children: [_jsxs(ImageListItemBarTitleWrap, {
|
192 | ownerState: ownerState,
|
193 | className: classes.titleWrap,
|
194 | children: [_jsx(ImageListItemBarTitle, {
|
195 | className: classes.title,
|
196 | children: title
|
197 | }), subtitle ? _jsx(ImageListItemBarSubtitle, {
|
198 | className: classes.subtitle,
|
199 | children: subtitle
|
200 | }) : null]
|
201 | }), actionIcon ? _jsx(ImageListItemBarActionIcon, {
|
202 | ownerState: ownerState,
|
203 | className: classes.actionIcon,
|
204 | children: actionIcon
|
205 | }) : null]
|
206 | });
|
207 | });
|
208 | process.env.NODE_ENV !== "production" ? ImageListItemBar.propTypes = {
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | |
214 |
|
215 |
|
216 |
|
217 | actionIcon: PropTypes.node,
|
218 | |
219 |
|
220 |
|
221 |
|
222 | actionPosition: PropTypes.oneOf(['left', 'right']),
|
223 | |
224 |
|
225 |
|
226 | children: PropTypes.node,
|
227 | |
228 |
|
229 |
|
230 | classes: PropTypes.object,
|
231 | |
232 |
|
233 |
|
234 | className: PropTypes.string,
|
235 | |
236 |
|
237 |
|
238 |
|
239 | position: PropTypes.oneOf(['below', 'bottom', 'top']),
|
240 | |
241 |
|
242 |
|
243 | subtitle: PropTypes.node,
|
244 | |
245 |
|
246 |
|
247 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
248 | |
249 |
|
250 |
|
251 | title: PropTypes.node
|
252 | } : void 0;
|
253 | export default ImageListItemBar; |
\ | No newline at end of file |