UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

1 lines 4.44 kB
{"version":3,"file":"symbol.mjs","sources":["../../../components/upload/symbol.ts"],"sourcesContent":["import type { ComponentPublicInstance } from 'vue'\r\n\r\nexport type UploadListType = 'name' | 'detail' | 'thumbnail' | 'card'\r\nexport type UploadStatus = 'pending' | 'uploading' | 'fail' | 'success' | 'delete'\r\n\r\nexport type UploadSourceFile = File & { path?: string }\r\n\r\nexport type UploadHttpError = Error & {\r\n response: any,\r\n url: string,\r\n status: number,\r\n method: string,\r\n}\r\n\r\nexport const enum StatusType {\r\n PENDING = 'pending',\r\n UPLOADING = 'uploading',\r\n FAIL = 'fail',\r\n SUCCESS = 'success',\r\n DELETE = 'delete',\r\n}\r\n\r\nexport interface UploadFileState {\r\n id: string | number,\r\n name: string,\r\n size: number,\r\n type: string,\r\n base64: string | null,\r\n status: UploadStatus,\r\n percentage: number,\r\n source: UploadSourceFile | null,\r\n url: string | null,\r\n path: string,\r\n /**\r\n * @deprecated\r\n */\r\n xhr: XMLHttpRequest | null,\r\n response: any,\r\n error: UploadHttpError | null,\r\n abort: () => void,\r\n}\r\n\r\nexport type UploadFileOptions = Partial<Omit<UploadFileState, 'response' | 'error' | 'abort'>>\r\n\r\ntype MaybePromise<T> = T | Promise<T>\r\n\r\nexport type BeforeUpload = (\r\n file: UploadFileState,\r\n files: UploadFileState[],\r\n) => MaybePromise<boolean | Blob | UploadSourceFile | void>\r\nexport type BeforeSelect = (\r\n file: UploadFileState,\r\n files: UploadFileState[],\r\n) => MaybePromise<boolean | void>\r\nexport type RenderFn = (data: { file: UploadFileState }) => any\r\n\r\nexport interface UploadFetchOptions {\r\n url: string,\r\n file: UploadSourceFile,\r\n headers?: Record<string, string>,\r\n withCredentials?: boolean,\r\n data?: Record<string, string | Blob>,\r\n field?: string,\r\n pathField?: string,\r\n onProgress?: (percent: number) => void,\r\n onSuccess?: (response: any) => void,\r\n onError?: (error: UploadHttpError) => void,\r\n onAbort?: () => void,\r\n}\r\n\r\n/**\r\n * Should return an abort method.\r\n */\r\nexport type UploadFetchMethod = (options: UploadFetchOptions) => () => void\r\n\r\nexport interface DirectoryEntity {\r\n name: string,\r\n fullPath: string,\r\n isFile: boolean,\r\n isDirectory: boolean,\r\n file: (callback: (file: UploadSourceFile) => void) => void,\r\n\r\n createReader: () => DirectoryReader,\r\n}\r\n\r\nexport interface DirectoryReader {\r\n readEntries: (\r\n onSuccess: (entities: DirectoryEntity[]) => void,\r\n onError?: (errors: any) => void,\r\n ) => void,\r\n}\r\n\r\nexport interface UploadExposed extends ComponentPublicInstance {\r\n isDragOver: boolean,\r\n execute: () => Promise<false | any[]>,\r\n handleDelete: (file: UploadFileState) => void,\r\n focus: (options?: FocusOptions) => void,\r\n blur: () => void,\r\n}\r\n\r\nexport interface UploadListSlots {\r\n item?: (params: { file: UploadFileState, status: UploadStatus, percentage: number }) => any,\r\n icon?: (params: { file: UploadFileState, status: UploadStatus, percentage: number }) => any,\r\n suffix?: () => any,\r\n}\r\n\r\nexport interface UploadFileSlots {\r\n default?: (params: { file: UploadFileState, status: UploadStatus, percentage: number }) => any,\r\n icon?: (params: { file: UploadFileState, status: UploadStatus, percentage: number }) => any,\r\n}\r\n\r\nexport interface UploadSlots extends Omit<UploadListSlots, 'suffix'> {\r\n default?: (params: { isDragOver: boolean }) => any,\r\n tip?: () => any,\r\n cloud?: () => any,\r\n}\r\n\r\nexport const uploadListTypes = Object.freeze<UploadListType[]>([\r\n 'name',\r\n 'detail',\r\n 'thumbnail',\r\n 'card',\r\n])\r\n\r\n/**\r\n * @deprecated Use `UploadHttpError` to replace it\r\n */\r\nexport type HttpError = UploadHttpError\r\n/**\r\n * @deprecated Use `UploadSourceFile` to replace it\r\n */\r\nexport type SourceFile = UploadSourceFile\r\n/**\r\n * @deprecated Use `UploadFileState` to replace it\r\n */\r\nexport type FileState = UploadFileState\r\n/**\r\n * @deprecated Use `UploadFileOptions` to replace it\r\n */\r\nexport type FileOptions = UploadFileOptions\r\n"],"names":["StatusType","uploadListTypes"],"mappings":"AAckB,IAAAA,sBAAAA,OAChBA,EAAA,UAAU,WACVA,EAAA,YAAY,aACZA,EAAA,OAAO,QACPA,EAAA,UAAU,WACVA,EAAA,SAAS,UALOA,IAAAA,KAAA,CAAA,CAAA;AAuGL,MAAAC,IAAkB,OAAO,OAAyB;AAAA,EAC7D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;"}