UNPKG

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