upload.d.ts
3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { ElementUIComponent } from './component'
export type ListType = 'text' | 'picture' | 'picture-card'
export type FileUploadStatus = 'ready' | 'uploading' | 'success' | 'fail'
export interface FileListItem {
name: string,
url: string,
status?: FileUploadStatus
}
export interface ElUploadInternalRawFile extends File {
uid: number
}
export interface ElUploadInternalFileDetail {
status: FileUploadStatus,
name: string,
size: number,
percentage: number,
uid: number,
raw: ElUploadInternalRawFile,
url?: string
}
export interface ElUploadProgressEvent extends ProgressEvent {
percent: number
}
export interface HttpRequestOptions {
headers: object,
withCredentials: boolean,
file: ElUploadInternalFileDetail,
data: object,
filename: string,
action: string,
onProgress: (e: ElUploadProgressEvent) => void,
onSuccess: (response: any) => void,
onError: (err: ErrorEvent) => void
}
/** Upload Component */
export declare class ElUpload extends ElementUIComponent {
/** Request URL (required) */
action: string
/** Request headers */
headers: object
/** Whether uploading multiple files is permitted */
multiple: boolean
/** Additions options of request */
data: object
/** Key name for uploaded file */
name: string
/** Whether cookies are sent */
withCredentials: boolean
/** Whether to show the uploaded file list */
showFileList: boolean
/** Whether to activate drag and drop mode */
drag: boolean
/** Accepted file types, will not work when thumbnail-mode is true */
accept: string
/** Hook function when clicking the uploaded files */
onPreview: (file: ElUploadInternalFileDetail) => void
/** Hook function when files are removed */
onRemove: (file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail[]) => void
/** Hook function when uploaded successfully */
onSuccess: (response: any, file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail) => void
/** Hook function when some errors occurs */
onError: (err: ErrorEvent, file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail) => void
/** Hook function when some progress occurs */
onProgress: (event: ElUploadProgressEvent, file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail) => void
/** Hook function when file status change */
onChange: (file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail[]) => void
/** Hook function before uploading with the file to be uploaded as its parameter. If false or a Promise is returned, uploading will be aborted */
beforeUpload: (file: ElUploadInternalRawFile) => boolean | Promise<File | Blob | boolean>
/** Whether thumbnail is displayed */
thumbnailMode: boolean
/** Default uploaded files */
fileList: FileListItem[]
/** Type of fileList */
listType: ListType
/** Whether to auto upload file */
autoUpload: boolean
/** Override default xhr behavior, allowing you to implement your own upload-file's request */
httpRequest: (options: HttpRequestOptions) => void
/** Whether to disable upload */
disabled: boolean
/** Maximum number of uploads allowed */
limit: number
/** Hook function when limit is exceeded */
onExceed: (file: ElUploadInternalFileDetail, fileList: ElUploadInternalFileDetail[]) => void
/** Clear the upload file list */
clearFiles (): void;
/** Abort specified file */
abort (file: ElUploadInternalFileDetail): void
/** Upload the file list manually */
submit ():void;
}