2023-08-28 19:38:03 +08:00
|
|
|
import type * as React from 'react';
|
2022-04-25 18:46:53 +08:00
|
|
|
import type {
|
2021-03-13 23:46:32 +08:00
|
|
|
RcFile as OriRcFile,
|
2022-06-22 14:57:09 +08:00
|
|
|
UploadRequestOption as RcCustomRequestOptions,
|
2023-05-31 20:36:29 +08:00
|
|
|
UploadProps as RcUploadProps,
|
2021-03-13 23:46:32 +08:00
|
|
|
} from 'rc-upload/lib/interface';
|
2023-08-28 19:38:03 +08:00
|
|
|
|
2023-05-31 20:36:29 +08:00
|
|
|
import type { ProgressAriaProps, ProgressProps } from '../progress';
|
2016-08-01 16:35:01 +08:00
|
|
|
|
2021-03-13 23:46:32 +08:00
|
|
|
export interface RcFile extends OriRcFile {
|
|
|
|
readonly lastModifiedDate: Date;
|
|
|
|
}
|
|
|
|
|
2023-08-28 19:38:03 +08:00
|
|
|
export type UploadFileStatus = 'error' | 'done' | 'uploading' | 'removed';
|
2016-08-01 16:35:01 +08:00
|
|
|
|
|
|
|
export interface HttpRequestHeader {
|
|
|
|
[key: string]: string;
|
|
|
|
}
|
|
|
|
|
2023-05-31 20:36:29 +08:00
|
|
|
export interface UploadFile<T = any> extends ProgressAriaProps {
|
2018-08-02 17:34:55 +08:00
|
|
|
uid: string;
|
2021-04-28 22:52:31 +08:00
|
|
|
size?: number;
|
2016-08-01 16:35:01 +08:00
|
|
|
name: string;
|
2018-08-02 17:34:55 +08:00
|
|
|
fileName?: string;
|
2018-04-19 11:54:28 +08:00
|
|
|
lastModified?: number;
|
2018-05-01 00:11:18 +08:00
|
|
|
lastModifiedDate?: Date;
|
2016-08-01 16:35:01 +08:00
|
|
|
url?: string;
|
|
|
|
status?: UploadFileStatus;
|
|
|
|
percent?: number;
|
|
|
|
thumbUrl?: string;
|
2022-04-12 12:03:46 +08:00
|
|
|
crossOrigin?: React.ImgHTMLAttributes<HTMLImageElement>['crossOrigin'];
|
2021-04-28 22:52:31 +08:00
|
|
|
originFileObj?: RcFile;
|
2019-10-21 19:07:02 +08:00
|
|
|
response?: T;
|
2017-02-15 20:58:40 +08:00
|
|
|
error?: any;
|
2017-10-18 00:05:10 +08:00
|
|
|
linkProps?: any;
|
2021-04-28 22:52:31 +08:00
|
|
|
type?: string;
|
2019-11-04 10:44:43 +08:00
|
|
|
xhr?: T;
|
2019-10-30 20:40:57 +08:00
|
|
|
preview?: string;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|
|
|
|
|
2021-04-28 22:52:31 +08:00
|
|
|
export interface InternalUploadFile<T = any> extends UploadFile<T> {
|
|
|
|
originFileObj: RcFile;
|
|
|
|
}
|
|
|
|
|
2022-01-05 19:15:28 +08:00
|
|
|
export interface UploadChangeParam<T = UploadFile> {
|
2019-04-28 20:49:58 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/14420
|
|
|
|
file: T;
|
2022-04-22 22:33:05 +08:00
|
|
|
fileList: T[];
|
2016-08-01 16:35:01 +08:00
|
|
|
event?: { percent: number };
|
|
|
|
}
|
|
|
|
|
2023-02-08 19:00:25 +08:00
|
|
|
export interface ShowUploadListInterface<T = any> {
|
2017-01-10 20:15:02 +08:00
|
|
|
showRemoveIcon?: boolean;
|
|
|
|
showPreviewIcon?: boolean;
|
2019-09-11 21:46:56 +08:00
|
|
|
showDownloadIcon?: boolean;
|
2023-02-08 19:00:25 +08:00
|
|
|
removeIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
|
|
|
downloadIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
|
|
|
previewIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
2017-01-10 20:15:02 +08:00
|
|
|
}
|
|
|
|
|
2017-02-28 18:43:22 +08:00
|
|
|
export interface UploadLocale {
|
|
|
|
uploading?: string;
|
|
|
|
removeFile?: string;
|
2019-09-11 21:46:56 +08:00
|
|
|
downloadFile?: string;
|
2017-02-28 18:43:22 +08:00
|
|
|
uploadError?: string;
|
|
|
|
previewFile?: string;
|
|
|
|
}
|
|
|
|
|
2018-04-16 10:58:17 +08:00
|
|
|
export type UploadType = 'drag' | 'select';
|
2023-01-31 14:31:34 +08:00
|
|
|
export type UploadListType = 'text' | 'picture' | 'picture-card' | 'picture-circle';
|
2020-05-20 22:29:45 +08:00
|
|
|
export type UploadListProgressProps = Omit<ProgressProps, 'percent' | 'type'>;
|
2018-04-16 10:58:17 +08:00
|
|
|
|
2020-11-21 19:00:11 +08:00
|
|
|
export type ItemRender<T = any> = (
|
|
|
|
originNode: React.ReactElement,
|
2023-02-08 19:00:25 +08:00
|
|
|
file: UploadFile<T>,
|
2021-05-06 14:12:26 +08:00
|
|
|
fileList: Array<UploadFile<T>>,
|
|
|
|
actions: {
|
|
|
|
download: () => void;
|
|
|
|
preview: () => void;
|
|
|
|
remove: () => void;
|
|
|
|
},
|
2020-11-21 19:00:11 +08:00
|
|
|
) => React.ReactNode;
|
|
|
|
|
2019-05-06 12:04:39 +08:00
|
|
|
type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
|
2019-09-04 22:48:32 +08:00
|
|
|
type TransformFileHandler = (
|
|
|
|
file: RcFile,
|
|
|
|
) => string | Blob | File | PromiseLike<string | Blob | File>;
|
2021-04-30 08:59:18 +08:00
|
|
|
type BeforeUploadValueType = void | boolean | string | Blob | File;
|
2019-05-06 12:04:39 +08:00
|
|
|
|
2023-12-30 15:21:52 +08:00
|
|
|
export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture' | 'hasControlInside'> {
|
2018-04-16 10:58:17 +08:00
|
|
|
type?: UploadType;
|
2016-08-01 16:35:01 +08:00
|
|
|
name?: string;
|
2020-04-05 22:26:13 +08:00
|
|
|
defaultFileList?: Array<UploadFile<T>>;
|
|
|
|
fileList?: Array<UploadFile<T>>;
|
2019-05-29 13:53:33 +08:00
|
|
|
action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike<string>);
|
2018-06-12 16:03:54 +08:00
|
|
|
directory?: boolean;
|
2021-12-07 21:45:11 +08:00
|
|
|
data?:
|
|
|
|
| Record<string, unknown>
|
|
|
|
| ((file: UploadFile<T>) => Record<string, unknown> | Promise<Record<string, unknown>>);
|
2020-06-12 10:31:07 +08:00
|
|
|
method?: 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
|
2016-08-01 16:35:01 +08:00
|
|
|
headers?: HttpRequestHeader;
|
2017-01-10 20:15:02 +08:00
|
|
|
showUploadList?: boolean | ShowUploadListInterface;
|
2016-08-01 16:35:01 +08:00
|
|
|
multiple?: boolean;
|
|
|
|
accept?: string;
|
2021-04-30 22:11:31 +08:00
|
|
|
beforeUpload?: (
|
|
|
|
file: RcFile,
|
|
|
|
FileList: RcFile[],
|
2021-04-30 08:59:18 +08:00
|
|
|
) => BeforeUploadValueType | Promise<BeforeUploadValueType>;
|
2022-02-23 18:44:26 +08:00
|
|
|
onChange?: (info: UploadChangeParam<UploadFile<T>>) => void;
|
2021-04-30 22:11:31 +08:00
|
|
|
onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
|
2018-04-16 10:58:17 +08:00
|
|
|
listType?: UploadListType;
|
2016-08-01 16:35:01 +08:00
|
|
|
className?: string;
|
2023-08-07 18:04:44 +08:00
|
|
|
rootClassName?: string;
|
2020-04-05 22:26:13 +08:00
|
|
|
onPreview?: (file: UploadFile<T>) => void;
|
|
|
|
onDownload?: (file: UploadFile<T>) => void;
|
|
|
|
onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>;
|
2016-08-01 16:35:01 +08:00
|
|
|
supportServerRender?: boolean;
|
|
|
|
style?: React.CSSProperties;
|
2016-08-16 18:07:37 +08:00
|
|
|
disabled?: boolean;
|
2016-09-14 16:18:33 +08:00
|
|
|
prefixCls?: string;
|
2024-04-24 23:57:43 +08:00
|
|
|
customRequest?: (options: RcCustomRequestOptions<T>) => void;
|
2017-02-24 16:06:57 +08:00
|
|
|
withCredentials?: boolean;
|
2018-09-21 15:04:51 +08:00
|
|
|
openFileDialogOnClick?: boolean;
|
2017-02-28 18:43:22 +08:00
|
|
|
locale?: UploadLocale;
|
2019-02-11 20:29:43 +08:00
|
|
|
id?: string;
|
2019-05-06 12:04:39 +08:00
|
|
|
previewFile?: PreviewFileHandler;
|
2020-12-15 15:56:35 +08:00
|
|
|
/** @deprecated Please use `beforeUpload` directly */
|
2019-08-04 12:18:46 +08:00
|
|
|
transformFile?: TransformFileHandler;
|
2020-04-05 22:26:13 +08:00
|
|
|
iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
2023-02-08 19:00:25 +08:00
|
|
|
isImageUrl?: (file: UploadFile<T>) => boolean;
|
2020-05-20 22:29:45 +08:00
|
|
|
progress?: UploadListProgressProps;
|
2020-11-21 19:00:11 +08:00
|
|
|
itemRender?: ItemRender<T>;
|
2020-12-15 17:09:52 +08:00
|
|
|
/** Config max count of `fileList`. Will replace current one when `maxCount` is 1 */
|
|
|
|
maxCount?: number;
|
2022-04-08 22:55:42 +08:00
|
|
|
children?: React.ReactNode;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|
|
|
|
|
2020-04-05 22:26:13 +08:00
|
|
|
export interface UploadState<T = any> {
|
|
|
|
fileList: UploadFile<T>[];
|
2017-11-20 16:31:41 +08:00
|
|
|
dragState: string;
|
|
|
|
}
|
|
|
|
|
2020-04-05 22:26:13 +08:00
|
|
|
export interface UploadListProps<T = any> {
|
2018-04-16 10:58:17 +08:00
|
|
|
listType?: UploadListType;
|
2020-04-05 22:26:13 +08:00
|
|
|
onPreview?: (file: UploadFile<T>) => void;
|
|
|
|
onDownload?: (file: UploadFile<T>) => void;
|
|
|
|
onRemove?: (file: UploadFile<T>) => void | boolean;
|
|
|
|
items?: Array<UploadFile<T>>;
|
2020-05-20 22:29:45 +08:00
|
|
|
progress?: UploadListProgressProps;
|
2016-09-14 16:18:33 +08:00
|
|
|
prefixCls?: string;
|
2022-04-25 18:46:53 +08:00
|
|
|
className?: string;
|
2017-01-10 20:15:02 +08:00
|
|
|
showRemoveIcon?: boolean;
|
2019-09-11 21:46:56 +08:00
|
|
|
showDownloadIcon?: boolean;
|
2017-01-10 20:15:02 +08:00
|
|
|
showPreviewIcon?: boolean;
|
2024-04-25 14:22:35 +08:00
|
|
|
removeIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
|
|
|
downloadIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
|
|
|
previewIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
2017-02-28 18:43:22 +08:00
|
|
|
locale: UploadLocale;
|
2019-05-06 12:04:39 +08:00
|
|
|
previewFile?: PreviewFileHandler;
|
2020-04-05 22:26:13 +08:00
|
|
|
iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
2023-02-08 19:00:25 +08:00
|
|
|
isImageUrl?: (file: UploadFile<T>) => boolean;
|
2020-08-24 16:33:24 +08:00
|
|
|
appendAction?: React.ReactNode;
|
2022-01-25 11:20:46 +08:00
|
|
|
appendActionVisible?: boolean;
|
2020-11-21 19:00:11 +08:00
|
|
|
itemRender?: ItemRender<T>;
|
2023-05-04 17:03:04 +08:00
|
|
|
/**
|
|
|
|
* @internal Only the internal remove button is provided for use
|
|
|
|
*/
|
|
|
|
disabled?: boolean;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|