|
@@ -1,7 +1,7 @@
|
|
|
import React from "react";
|
|
import React from "react";
|
|
|
import { FileItem } from '../upload/interface';
|
|
import { FileItem } from '../upload/interface';
|
|
|
import Image from '../image';
|
|
import Image from '../image';
|
|
|
-import { IconBriefStroked, IconClear } from '@douyinfe/semi-icons';
|
|
|
|
|
|
|
+import { IconAlertCircle, IconBriefStroked, IconClear } from '@douyinfe/semi-icons';
|
|
|
import { strings, cssClasses } from '@douyinfe/semi-foundation/chat/constants';
|
|
import { strings, cssClasses } from '@douyinfe/semi-foundation/chat/constants';
|
|
|
import cls from 'classnames';
|
|
import cls from 'classnames';
|
|
|
import { Progress } from "../index";
|
|
import { Progress } from "../index";
|
|
@@ -20,7 +20,7 @@ interface FileProps {
|
|
|
url?: string;
|
|
url?: string;
|
|
|
name?: string;
|
|
name?: string;
|
|
|
size?: string;
|
|
size?: string;
|
|
|
- type?: string;
|
|
|
|
|
|
|
+ type?: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const FileAttachment = React.memo((props: FileProps) => {
|
|
export const FileAttachment = React.memo((props: FileProps) => {
|
|
@@ -38,18 +38,18 @@ export const FileAttachment = React.memo((props: FileProps) => {
|
|
|
{type ? ' · ' : ''}{size}
|
|
{type ? ' · ' : ''}{size}
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
- </a>
|
|
|
|
|
-})
|
|
|
|
|
|
|
+ </a>;
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
export const ImageAttachment = React.memo((props: {src: string}) => {
|
|
export const ImageAttachment = React.memo((props: {src: string}) => {
|
|
|
const { src } = props;
|
|
const { src } = props;
|
|
|
return <Image
|
|
return <Image
|
|
|
- className={`${PREFIX_ATTACHMENT}-img`}
|
|
|
|
|
- width={60}
|
|
|
|
|
- height={60}
|
|
|
|
|
- src={src}
|
|
|
|
|
-/>
|
|
|
|
|
-})
|
|
|
|
|
|
|
+ className={`${PREFIX_ATTACHMENT}-img`}
|
|
|
|
|
+ width={60}
|
|
|
|
|
+ height={60}
|
|
|
|
|
+ src={src}
|
|
|
|
|
+ />;
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
const Attachment = React.memo((props: AttachmentProps) => {
|
|
const Attachment = React.memo((props: AttachmentProps) => {
|
|
|
const { attachment, onClear, showClear = true, className } = props;
|
|
const { attachment, onClear, showClear = true, className } = props;
|
|
@@ -64,7 +64,7 @@ const Attachment = React.memo((props: AttachmentProps) => {
|
|
|
const suffix = item?.name.split('.').pop();
|
|
const suffix = item?.name.split('.').pop();
|
|
|
const isImg = item?.fileInstance?.type?.startsWith(PIC_PREFIX) || PIC_SUFFIX_ARRAY.includes(suffix);
|
|
const isImg = item?.fileInstance?.type?.startsWith(PIC_PREFIX) || PIC_SUFFIX_ARRAY.includes(suffix);
|
|
|
const realType = suffix ?? item?.fileInstance?.type?.split('/').pop();
|
|
const realType = suffix ?? item?.fileInstance?.type?.split('/').pop();
|
|
|
- const showProcess = !(percent === 100 || typeof percent === 'undefined') && status === 'uploading';
|
|
|
|
|
|
|
+ const showProcess = !(percent === 100 || typeof percent === 'undefined') && status === strings.FILE_STATUS.UPLOADING;
|
|
|
return <div
|
|
return <div
|
|
|
className={`${PREFIX_ATTACHMENT}-item`}
|
|
className={`${PREFIX_ATTACHMENT}-item`}
|
|
|
key={item.uid}
|
|
key={item.uid}
|
|
@@ -82,11 +82,12 @@ const Attachment = React.memo((props: AttachmentProps) => {
|
|
|
{showClear && <IconClear
|
|
{showClear && <IconClear
|
|
|
size="large"
|
|
size="large"
|
|
|
className={`${PREFIX_ATTACHMENT}-clear`}
|
|
className={`${PREFIX_ATTACHMENT}-clear`}
|
|
|
- onClick={()=> {
|
|
|
|
|
|
|
+ onClick={() => {
|
|
|
onClear && onClear(item);
|
|
onClear && onClear(item);
|
|
|
}}
|
|
}}
|
|
|
/>}
|
|
/>}
|
|
|
- {showProcess && <Progress percent={percent} type="circle" size="small" width={30} className={`${PREFIX_ATTACHMENT}-process`} aria-label="upload progress" />}
|
|
|
|
|
|
|
+ {showProcess && <Progress percent={percent} type="circle" size="small" width={30} className={`${PREFIX_ATTACHMENT}-process`} aria-label="upload progress" />}
|
|
|
|
|
+ {[strings.FILE_STATUS.UPLOAD_FAIL, strings.FILE_STATUS.VALID_FAIL].includes(status) && <IconAlertCircle className={`${PREFIX_ATTACHMENT}-fail`} />}
|
|
|
</div>;
|
|
</div>;
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|