4
4
5
5
import { AntdComponent } from './component' ;
6
6
7
+ export interface HttpRequestHeader {
8
+ [ key : string ] : string ;
9
+ }
10
+
7
11
export interface VcFile extends File {
8
12
uid : string ;
9
13
readonly lastModifiedDate : Date ;
@@ -30,7 +34,25 @@ export interface UploadFile<T = any> {
30
34
preview ?: string ;
31
35
}
32
36
33
- export interface ShowUploadList {
37
+ export interface UploadChangeParam < T extends object = UploadFile > {
38
+ file : T ;
39
+ fileList : UploadFile [ ] ;
40
+ event ?: { percent : number } ;
41
+ }
42
+
43
+ export interface VcCustomRequestOptions {
44
+ onProgress : ( event : { percent : number } , file : File ) => void ;
45
+ onError : ( error : Error ) => void ;
46
+ onSuccess : ( response : object , file : File ) => void ;
47
+ data : object ;
48
+ filename : string ;
49
+ file : File ;
50
+ withCredentials : boolean ;
51
+ action : string ;
52
+ headers : object ;
53
+ }
54
+
55
+ export interface ShowUploadListInterface {
34
56
showRemoveIcon ?: boolean ;
35
57
showPreviewIcon ?: boolean ;
36
58
showDownloadIcon ?: boolean ;
@@ -66,7 +88,7 @@ export declare class Upload extends AntdComponent {
66
88
* Uploading URL
67
89
* @type string | Function
68
90
*/
69
- action ?: string | Function ;
91
+ action ?: string | ( ( file : VcFile ) => string ) | ( ( file : VcFile ) => PromiseLike < string > ) ;
70
92
71
93
/**
72
94
* support upload whole directory
@@ -81,19 +103,41 @@ export declare class Upload extends AntdComponent {
81
103
* Warning:this function is not supported in IE9.
82
104
* @type Function
83
105
*/
84
- beforeUpload ?: ( file : any , fileList : UploadFile [ ] ) => boolean | Promise < boolean > ;
106
+ beforeUpload ?: ( file : VcFile , fileList : VcFile [ ] ) => boolean | Promise < boolean > ;
107
+
108
+ /**
109
+ * A callback function, can be executed when uploading state is changing.
110
+ */
111
+ onChange ?: ( info : UploadChangeParam ) => void ;
112
+
113
+ /**
114
+ * A callback function, will be executed when file link or preview icon is clicked.
115
+ */
116
+ onPreview ?: ( file : UploadFile ) => void ;
117
+
118
+ /**
119
+ * Click the method to download the file, pass the method to perform the method logic, do not pass the default jump to the new TAB.
120
+ */
121
+ onDownload ?: ( file : UploadFile ) => void ;
122
+
123
+ /**
124
+ * A callback function, will be executed when removing file button is clicked,
125
+ * remove event will be prevented when return value is false or a Promise which resolve(false) or reject.
126
+ * @type Function
127
+ */
128
+ onRemove ?: ( file : UploadFile ) => boolean | Promise < boolean > ;
85
129
86
130
/**
87
131
* override for the default xhr behavior allowing for additional customization and ability to implement your own XMLHttpRequest
88
132
* @type Function
89
133
*/
90
- customRequest ?: Function ;
134
+ customRequest ?: ( options : VcCustomRequestOptions ) => void ;
91
135
92
136
/**
93
137
* Uploading params or function which can return uploading params.
94
138
* @type object | Function
95
139
*/
96
- data ?: object | Function ;
140
+ data ?: object | ( ( file : UploadFile ) => object ) ;
97
141
/**
98
142
* http method of upload request
99
143
*/
@@ -122,7 +166,7 @@ export declare class Upload extends AntdComponent {
122
166
* Set request headers, valid above IE10.
123
167
* @type object
124
168
*/
125
- headers ?: object ;
169
+ headers ?: HttpRequestHeader ;
126
170
127
171
/**
128
172
* Built-in stylesheets, support for three types: text, picture or picture-card
@@ -149,9 +193,9 @@ export declare class Upload extends AntdComponent {
149
193
/**
150
194
* Whether to show default upload list, could be an object to specify showPreviewIcon and showRemoveIcon individually
151
195
* @default true
152
- * @type boolean | ShowUploadList
196
+ * @type boolean | ShowUploadListInterface
153
197
*/
154
- showUploadList ?: boolean | ShowUploadList ;
198
+ showUploadList ?: boolean | ShowUploadListInterface ;
155
199
156
200
/**
157
201
* Need to be turned on while the server side is rendering.
@@ -174,13 +218,6 @@ export declare class Upload extends AntdComponent {
174
218
*/
175
219
openFileDialogOnClick ?: boolean ;
176
220
177
- /**
178
- * A callback function, will be executed when removing file button is clicked,
179
- * remove event will be prevented when return value is false or a Promise which resolve(false) or reject.
180
- * @type Function
181
- */
182
- remove ?: ( file : any ) => boolean | Promise < boolean > ;
183
-
184
221
locale ?: UploadLocale ;
185
222
id ?: string ;
186
223
/**
@@ -191,6 +228,5 @@ export declare class Upload extends AntdComponent {
191
228
* Customize transform file before request (1.5.0)
192
229
*/
193
230
transformFile ?: TransformFileHandler ;
194
- }
195
-
231
+ } ;
196
232
}
0 commit comments