import isString from 'lodash/isString'; import { m, AnimatePresence } from 'framer-motion'; // @mui import { alpha } from '@mui/material/styles'; import { List, Stack, Button, IconButton, ListItemText, ListItem } from '@mui/material'; // utils import { fData } from '../../utils/formatNumber'; // type import { UploadMultiFileProps, CustomFile } from './type'; // import Image from '../Image'; import Iconify from '../Iconify'; import { varFade } from '../animate'; // ---------------------------------------------------------------------- const getFileData = (file: CustomFile | string) => { if (typeof file === 'string') { return { key: file, }; } return { key: file.name, name: file.name, size: file.size, preview: file.preview, }; }; // ---------------------------------------------------------------------- export default function MultiFilePreview({ showPreview = false, files, onRemove, onRemoveAll, }: UploadMultiFileProps) { const hasFile = files.length > 0; return ( <> {files.map((file) => { const { key, name, size, preview } = getFileData(file as CustomFile); if (showPreview) { return ( `solid 1px ${theme.palette.divider}`, }} > preview onRemove(file)} sx={{ top: 6, p: '2px', right: 6, position: 'absolute', color: 'common.white', bgcolor: (theme) => alpha(theme.palette.grey[900], 0.72), '&:hover': { bgcolor: (theme) => alpha(theme.palette.grey[900], 0.48), }, }} > ); } return ( `solid 1px ${theme.palette.divider}`, }} > onRemove(file)}> ); })} {hasFile && ( )} ); }