Files
element/types/upload.d.ts
Jingkun Hua 3b378ad58f Add TypeScript definitions (#3910)
* add typings into package.json

* add typings for global instance api

* add common component definition

* add layout components' definition

* add icons definition

* add component size definition

* add component description

* add button definition

* add radio definition

* add checkbox definition

* add input definitions

* add input-number definition

* add select definition

* add cascader definition

* add switch definition

* add slider definition

* add time picker definition

* add date picker definition

* add upload definition

* add rate definition

* add color picker definition

* add form definition

* add tooltip definition

* add table definition

* rename TextAlignment to Horizontal alignment

* add tag definition

* add progress definition

* add tree definition

* add pagination definition

* add badge definition

* add alert definition

* fix typo

* Loading: add definition

* Message: add definition

* Loading: remove unnecessary declare keyword

* MessageBox: add definition

* Notification: add definition

* Menu: add definition

* Tabs: add definition

* Breadcrumb: add definition

* Dropdown: add definition

* Steps: add definition

* Dialog: add definition

* Popover: add definition

* Card: add definition

* Carousel: add definition

* Collapse: add definition

* Loading: update description

* some $message method params should be optional

* Select: update definition

* DatePicker: update definition
2017-10-17 03:36:12 -05:00

103 lines
3.0 KiB
TypeScript

// TODO: need to check if the api matches
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 ElUploadInternalFileDetail {
status: FileUploadStatus,
name: string,
size: number,
percentage: number,
uid: number,
raw: File
}
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 */
showUploadList: 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: ElUploadInternalFileDetail) => boolean | Promise<File | 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
}