UNPKG

2.99 kBTypeScriptView Raw
1import { CSSProperties } from 'react';
2import { Area } from '../image-crop';
3export declare type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
4export interface HttpRequestHeader {
5 [key: string]: string;
6}
7export interface UploadFile {
8 uid: number;
9 size: number;
10 name: string;
11 filename?: string;
12 lastModified?: string;
13 lastModifiedDate?: Date | number;
14 url?: string;
15 status?: UploadFileStatus;
16 percent?: number;
17 thumbUrl?: string;
18 originFileObj?: File | Blob;
19 response?: any;
20 error?: any;
21 linkProps?: any;
22 type: string;
23 imageCropArea?: Area;
24}
25export interface UploadChangeParam {
26 file: UploadFile;
27 fileList: Array<UploadFile>;
28 event?: {
29 percent: number;
30 };
31}
32export interface ShowUploadListInterface {
33 showRemoveIcon?: boolean;
34 showPreviewIcon?: boolean;
35}
36export interface UploadLocale {
37 uploading?: string;
38 removeFile?: string;
39 uploadError?: string;
40 previewFile?: string;
41}
42export interface UploadProps {
43 type?: 'drag' | 'select';
44 name?: string;
45 defaultFileList?: Array<UploadFile>;
46 fileList?: Array<UploadFile>;
47 action?: string;
48 data?: Object | ((file: UploadFile) => any);
49 headers?: HttpRequestHeader;
50 showUploadList?: boolean | ShowUploadListInterface;
51 multiple?: boolean;
52 dragUploadList?: boolean;
53 accept?: string;
54 beforeUpload?: (file: UploadFile, FileList: UploadFile[]) => boolean | PromiseLike<any | Blob>;
55 onChange?: (info: UploadChangeParam) => void;
56 listType?: 'text' | 'picture' | 'picture-card';
57 className?: string;
58 onStart?: (file: UploadFile) => void;
59 onPreview?: (file: UploadFile) => void;
60 onDragEnd?: (files: UploadFile[]) => void | boolean;
61 onRemove?: (file: UploadFile) => void | boolean;
62 onSuccess?: (response: any, file: UploadFile) => void;
63 onProgress?: (e: {
64 percent: number;
65 }, file: UploadFile) => void;
66 onError?: (error: Error, response: any, file: UploadFile) => void;
67 supportServerRender?: boolean;
68 style?: CSSProperties;
69 disabled?: boolean;
70 prefixCls?: string;
71 customRequest?: (option: any) => void;
72 previewFile?: PreviewFileHandler;
73 withCredentials?: boolean;
74 locale?: UploadLocale;
75 requestFileKeys?: string[] | string;
76}
77export interface UploadState {
78 fileList: UploadFile[];
79 dragState: string;
80}
81declare type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
82export interface UploadListProps {
83 listType?: 'text' | 'picture' | 'picture-card';
84 onPreview?: (file: UploadFile) => void;
85 onRemove?: (file: UploadFile) => void | boolean;
86 onDragEnd: (files: UploadFile[]) => void | boolean;
87 items?: Array<UploadFile>;
88 progressAttr?: Object;
89 prefixCls?: string;
90 showRemoveIcon?: boolean;
91 dragUploadList?: boolean;
92 showPreviewIcon?: boolean;
93 locale: UploadLocale;
94 previewFile?: PreviewFileHandler;
95}
96export {};