1 | import * as React from 'react';
|
2 | import { RcFile as OriRcFile, UploadRequestOption as RcCustomRequestOptions } from 'rc-upload/lib/interface';
|
3 | import { ProgressProps } from '../progress';
|
4 | export interface RcFile extends OriRcFile {
|
5 | readonly lastModifiedDate: Date;
|
6 | }
|
7 | export declare type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
|
8 | export interface HttpRequestHeader {
|
9 | [key: string]: string;
|
10 | }
|
11 | export interface UploadFile<T = any> {
|
12 | uid: string;
|
13 | size?: number;
|
14 | name: string;
|
15 | fileName?: string;
|
16 | lastModified?: number;
|
17 | lastModifiedDate?: Date;
|
18 | url?: string;
|
19 | status?: UploadFileStatus;
|
20 | percent?: number;
|
21 | thumbUrl?: string;
|
22 | originFileObj?: RcFile;
|
23 | response?: T;
|
24 | error?: any;
|
25 | linkProps?: any;
|
26 | type?: string;
|
27 | xhr?: T;
|
28 | preview?: string;
|
29 | }
|
30 | export interface InternalUploadFile<T = any> extends UploadFile<T> {
|
31 | originFileObj: RcFile;
|
32 | }
|
33 | export interface UploadChangeParam<T extends object = UploadFile> {
|
34 | file: T;
|
35 | fileList: UploadFile[];
|
36 | event?: {
|
37 | percent: number;
|
38 | };
|
39 | }
|
40 | export interface ShowUploadListInterface {
|
41 | showRemoveIcon?: boolean;
|
42 | showPreviewIcon?: boolean;
|
43 | showDownloadIcon?: boolean;
|
44 | removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
45 | downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
46 | }
|
47 | export interface UploadLocale {
|
48 | uploading?: string;
|
49 | removeFile?: string;
|
50 | downloadFile?: string;
|
51 | uploadError?: string;
|
52 | previewFile?: string;
|
53 | }
|
54 | export declare type UploadType = 'drag' | 'select';
|
55 | export declare type UploadListType = 'text' | 'picture' | 'picture-card';
|
56 | export declare type UploadListProgressProps = Omit<ProgressProps, 'percent' | 'type'>;
|
57 | export declare type ItemRender<T = any> = (originNode: React.ReactElement, file: UploadFile, fileList: Array<UploadFile<T>>, actions: {
|
58 | download: () => void;
|
59 | preview: () => void;
|
60 | remove: () => void;
|
61 | }) => React.ReactNode;
|
62 | declare type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
|
63 | declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
|
64 | declare type BeforeUploadValueType = void | boolean | string | Blob | File;
|
65 | export interface UploadProps<T = any> {
|
66 | type?: UploadType;
|
67 | name?: string;
|
68 | defaultFileList?: Array<UploadFile<T>>;
|
69 | fileList?: Array<UploadFile<T>>;
|
70 | action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike<string>);
|
71 | directory?: boolean;
|
72 | data?: object | ((file: UploadFile<T>) => object);
|
73 | method?: 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
|
74 | headers?: HttpRequestHeader;
|
75 | showUploadList?: boolean | ShowUploadListInterface;
|
76 | multiple?: boolean;
|
77 | accept?: string;
|
78 | beforeUpload?: (file: RcFile, FileList: RcFile[]) => BeforeUploadValueType | Promise<BeforeUploadValueType>;
|
79 | onChange?: (info: UploadChangeParam) => void;
|
80 | onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
|
81 | listType?: UploadListType;
|
82 | className?: string;
|
83 | onPreview?: (file: UploadFile<T>) => void;
|
84 | onDownload?: (file: UploadFile<T>) => void;
|
85 | onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>;
|
86 | supportServerRender?: boolean;
|
87 | style?: React.CSSProperties;
|
88 | disabled?: boolean;
|
89 | prefixCls?: string;
|
90 | customRequest?: (options: RcCustomRequestOptions) => void;
|
91 | withCredentials?: boolean;
|
92 | openFileDialogOnClick?: boolean;
|
93 | locale?: UploadLocale;
|
94 | id?: string;
|
95 | previewFile?: PreviewFileHandler;
|
96 |
|
97 | transformFile?: TransformFileHandler;
|
98 | iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
99 | isImageUrl?: (file: UploadFile) => boolean;
|
100 | progress?: UploadListProgressProps;
|
101 | itemRender?: ItemRender<T>;
|
102 |
|
103 | maxCount?: number;
|
104 | }
|
105 | export interface UploadState<T = any> {
|
106 | fileList: UploadFile<T>[];
|
107 | dragState: string;
|
108 | }
|
109 | export interface UploadListProps<T = any> {
|
110 | listType?: UploadListType;
|
111 | onPreview?: (file: UploadFile<T>) => void;
|
112 | onDownload?: (file: UploadFile<T>) => void;
|
113 | onRemove?: (file: UploadFile<T>) => void | boolean;
|
114 | items?: Array<UploadFile<T>>;
|
115 | progress?: UploadListProgressProps;
|
116 | prefixCls?: string;
|
117 | showRemoveIcon?: boolean;
|
118 | showDownloadIcon?: boolean;
|
119 | showPreviewIcon?: boolean;
|
120 | removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
121 | downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
122 | locale: UploadLocale;
|
123 | previewFile?: PreviewFileHandler;
|
124 | iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
125 | isImageUrl?: (file: UploadFile) => boolean;
|
126 | appendAction?: React.ReactNode;
|
127 | itemRender?: ItemRender<T>;
|
128 | }
|
129 | export {};
|