UNPKG

@alifd/meet-react

Version:

Fusion Mobile React UI System Component

97 lines (96 loc) 2.86 kB
import { ReactNode } from 'react'; import { UploadResponseData } from '@uni/file/types/types'; import { ProgressProps } from '../progress'; import { LocaledComponentProps } from '../locale'; import { BaseComponentAttributes, BasicSizeType } from '../utils/types'; export interface FileItem { uid: string; name: string; state: 'selected' | 'uploading' | 'done' | 'error'; response: any; url: string; dataURL: string; file: string | File; imgURL?: string; isImage: boolean; downloadURL?: string; percent?: number; } export interface UploadOptions { action: string; data: any; headers: { [x: string]: any; }; } export interface LocaleType { reupload?: string; limit?: string; } export interface RequestResp { abort: () => void; } export interface RequestObject { onProgress: (event: { percent: number; }) => void; onError: (event: Error, body?: any) => void; onSuccess: (body: UploadResponseData) => void; fileType: 'image' | 'video' | 'audio'; data: any; filename: string; file: string | File; withCredentials: boolean; action: string; method: string; timeout: number; headers: { [x: string]: any; }; } export interface UploadProps extends BaseComponentAttributes, LocaledComponentProps<LocaleType> { action: string; withCredentials?: boolean; name?: string; fileKeyName?: string; data?: any | (() => any); headers?: { [x: string]: any; }; cols?: 2 | 3 | 4 | 5; label?: string; extraIcon?: string; previewClassName?: string; singleLimit?: number; filePicker?: () => Promise<{ data?: string[]; files?: FileItem[]; }>; value?: FileItem[]; defaultValue?: FileItem[]; listType?: 'image' | 'text' | 'card'; request?: (option: RequestObject) => RequestResp; formatter?: (response: UploadResponseData, file: FileItem) => any; size?: BasicSizeType; fileType?: 'image' | 'video' | 'audio'; showAddButton?: boolean; limit?: number; accept?: string; useDataURL?: boolean; disabled?: boolean; autoUpload?: boolean; hasRemove?: boolean; beforeUpload?: (file: FileItem, options: UploadOptions) => boolean | UploadOptions | Promise<UploadOptions>; onPreview?: (file?: FileItem, e?: any) => void; onProgress?: () => void; onSuccess?: (file: FileItem, value: FileItem[]) => void; onError?: (file: FileItem, value: FileItem[]) => void; onSelect?: () => void; onChange?: (info: FileItem[]) => void; onRemove?: (file: FileItem) => boolean | Promise<boolean>; afterSelect?: (file: FileItem) => boolean; progressProps?: ProgressProps; sizeType?: Array<'original' | 'compressed'>; sourceType?: Array<'camera' | 'album'>; children?: ReactNode; }