2017-11-17 14:38:54 +08:00
|
|
|
import * as React from 'react';
|
2016-08-01 16:35:01 +08:00
|
|
|
|
2017-03-23 21:15:49 +08:00
|
|
|
export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
|
2016-08-01 16:35:01 +08:00
|
|
|
|
|
|
|
export interface HttpRequestHeader {
|
|
|
|
[key: string]: string;
|
|
|
|
}
|
|
|
|
|
2018-04-19 11:54:28 +08:00
|
|
|
export interface RcFile extends File {
|
2018-08-02 17:34:55 +08:00
|
|
|
uid: string;
|
2019-05-29 13:52:35 +08:00
|
|
|
readonly lastModifiedDate: Date;
|
|
|
|
readonly webkitRelativePath: string;
|
2018-04-19 11:54:28 +08:00
|
|
|
}
|
|
|
|
|
2017-08-12 13:56:57 +08:00
|
|
|
export interface UploadFile {
|
2018-08-02 17:34:55 +08:00
|
|
|
uid: string;
|
2016-08-01 16:35:01 +08:00
|
|
|
size: number;
|
|
|
|
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;
|
2019-07-01 17:52:37 +08:00
|
|
|
originFileObj?: File | Blob;
|
2017-09-07 15:12:13 +08:00
|
|
|
response?: any;
|
2017-02-15 20:58:40 +08:00
|
|
|
error?: any;
|
2017-10-18 00:05:10 +08:00
|
|
|
linkProps?: any;
|
2017-11-20 16:43:25 +08:00
|
|
|
type: string;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|
|
|
|
|
2019-04-28 20:49:58 +08:00
|
|
|
export interface UploadChangeParam<T extends object = UploadFile> {
|
|
|
|
// https://github.com/ant-design/ant-design/issues/14420
|
|
|
|
file: T;
|
2017-08-12 13:56:57 +08:00
|
|
|
fileList: Array<UploadFile>;
|
2016-08-01 16:35:01 +08:00
|
|
|
event?: { percent: number };
|
|
|
|
}
|
|
|
|
|
2017-01-10 20:15:02 +08:00
|
|
|
export interface ShowUploadListInterface {
|
|
|
|
showRemoveIcon?: boolean;
|
|
|
|
showPreviewIcon?: boolean;
|
|
|
|
}
|
|
|
|
|
2017-02-28 18:43:22 +08:00
|
|
|
export interface UploadLocale {
|
|
|
|
uploading?: string;
|
|
|
|
removeFile?: string;
|
|
|
|
uploadError?: string;
|
|
|
|
previewFile?: string;
|
|
|
|
}
|
|
|
|
|
2018-04-16 10:58:17 +08:00
|
|
|
export type UploadType = 'drag' | 'select';
|
|
|
|
export type UploadListType = 'text' | 'picture' | 'picture-card';
|
|
|
|
|
2019-05-06 12:04:39 +08:00
|
|
|
type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
|
|
|
|
|
2016-08-01 16:35:01 +08:00
|
|
|
export interface UploadProps {
|
2018-04-16 10:58:17 +08:00
|
|
|
type?: UploadType;
|
2016-08-01 16:35:01 +08:00
|
|
|
name?: string;
|
2017-08-12 13:56:57 +08:00
|
|
|
defaultFileList?: Array<UploadFile>;
|
|
|
|
fileList?: Array<UploadFile>;
|
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;
|
2019-06-16 20:51:47 +08:00
|
|
|
data?: object | ((file: UploadFile) => object);
|
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;
|
2019-06-16 20:51:47 +08:00
|
|
|
beforeUpload?: (file: RcFile, FileList: RcFile[]) => boolean | PromiseLike<void>;
|
2016-08-01 16:35:01 +08:00
|
|
|
onChange?: (info: UploadChangeParam) => void;
|
2018-04-16 10:58:17 +08:00
|
|
|
listType?: UploadListType;
|
2016-08-01 16:35:01 +08:00
|
|
|
className?: string;
|
2017-08-12 13:56:57 +08:00
|
|
|
onPreview?: (file: UploadFile) => void;
|
2019-05-13 23:59:40 +08:00
|
|
|
onRemove?: (file: UploadFile) => 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;
|
2019-06-16 20:51:47 +08:00
|
|
|
customRequest?: (option: object) => 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;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|
|
|
|
|
2017-11-20 16:31:41 +08:00
|
|
|
export interface UploadState {
|
|
|
|
fileList: UploadFile[];
|
|
|
|
dragState: string;
|
|
|
|
}
|
|
|
|
|
2016-08-01 16:35:01 +08:00
|
|
|
export interface UploadListProps {
|
2018-04-16 10:58:17 +08:00
|
|
|
listType?: UploadListType;
|
2017-08-12 13:56:57 +08:00
|
|
|
onPreview?: (file: UploadFile) => void;
|
|
|
|
onRemove?: (file: UploadFile) => void | boolean;
|
|
|
|
items?: Array<UploadFile>;
|
2016-08-01 16:35:01 +08:00
|
|
|
progressAttr?: Object;
|
2016-09-14 16:18:33 +08:00
|
|
|
prefixCls?: string;
|
2017-01-10 20:15:02 +08:00
|
|
|
showRemoveIcon?: boolean;
|
|
|
|
showPreviewIcon?: boolean;
|
2017-02-28 18:43:22 +08:00
|
|
|
locale: UploadLocale;
|
2019-05-06 12:04:39 +08:00
|
|
|
previewFile?: PreviewFileHandler;
|
2016-08-01 16:35:01 +08:00
|
|
|
}
|