import * as React from "react"; export declare type UploadFileStatus = "error" | "success" | "done" | "uploading" | "removed"; export interface HttpRequestHeader { [key: string]: string; } export interface RcFile extends File { uid: string; readonly lastModifiedDate: Date; readonly webkitRelativePath: string; } export interface RcCustomRequestOptions { onProgress: (event: { percent: number; }, file: File) => void; onError: (error: Error) => void; onSuccess: (response: object, file: File) => void; data: object; filename: string; file: File; withCredentials: boolean; action: string; headers: object; } export interface UploadFile { uid: string; size?: number; name?: string; fileName?: string; lastModified?: number; lastModifiedDate?: Date; url?: string; status?: UploadFileStatus; percent?: number; thumbUrl?: string; originFileObj?: File | Blob; response?: T; error?: any; linkProps?: any; type?: string; xhr?: T; preview?: string; } export interface UploadChangeParam { file: T; fileList: Array; event?: { percent: number; }; } export interface ShowUploadListInterface { showRemoveIcon?: boolean; showPreviewIcon?: boolean; showDownloadIcon?: boolean; } export declare type UploadType = "drag" | "select"; export declare type UploadListType = "text" | "picture" | "picture-card"; export declare type PreviewFileHandler = (file: File | Blob) => PromiseLike; export declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike; export interface UploadProps { /** * 上传类型 "drag" | "select" * * @default **/ type?: UploadType; /** * 发到后台的文件参数名 * * @default 'file' **/ name?: string; /** * 默认已经上传的文件列表 * * @default **/ defaultFileList?: Array; /** * 已经上传的文件列表 * * @default **/ fileList?: Array; /** * 上传的地址 * * @default **/ action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike); /** * 支持上传文件夹 https://caniuse.com/#feat=input-file-directory * * @default false **/ directory?: boolean; /** * 上传所需额外参数或返回上传额外参数的方法 * * @default **/ data?: object | ((file: UploadFile) => object); /** * 上传请求的 http method * * @default 'post' **/ method?: "POST" | "PUT" | "post" | "put"; /** * 设置上传的请求头部,IE10 以上有效 * * @default **/ headers?: HttpRequestHeader; /** * 是否展示文件列表, * 可设为一个对象,用于单独设定 * showPreviewIcon, showRemoveIcon, showDownloadIcon, removeIcon 和 downloadIcon * * @default true **/ showUploadList?: boolean | ShowUploadListInterface; /** * 是否支持多选文件,ie10+ 支持。开启后按住 ctrl 可选择多个文件 * * @default false **/ multiple?: boolean; /** * 接受上传的文件类型 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept * * @default **/ accept?: string; /** * 上传文件之前的钩子,参数为上传的文件,若返回 false 则停止上传。 * 支持返回一个 Promise 对象, * Promise 对象 reject 时则停止上传, * resolve 时开始上传( resolve 传入 File 或 Blob 对象则上传 resolve 传入对象)。 * 注意:IE9 不支持该方法。 * * @default **/ beforeUpload?: (file: RcFile, FileList: RcFile[]) => boolean | PromiseLike; /** * 上传文件改变时的状态 * * @default **/ onChange?: (info: UploadChangeParam) => void; /** * 上传列表的内建样式,支持三种基本样式 text, picture 和 picture-card * * @default 'text' **/ listType?: UploadListType; /** * 自定义组件样式 * * @default **/ className?: string; /** * 自定义组件id * * @default **/ id?: string; /** * 点击文件链接或预览图标时的回调 * * @default **/ onPreview?: (file: UploadFile) => void; /** * 点击下载文件时的回调,如果没有指定,则默认跳转到文件 url 对应的标签页。 * * @default **/ onDownload?: (file: UploadFile) => void; /** * 点击移除文件时的回调,返回值为 false 时不移除。支持返回一个 Promise 对象,Promise 对象 resolve(false) 或 reject 时不移除。 * * @default **/ onRemove?: (file: UploadFile) => void | boolean | Promise; /** * 服务端渲染时需要打开这个 * * @default false **/ supportServerRender?: boolean; /** * 自定义样式 * * @default **/ style?: React.CSSProperties; /** * 是否禁用 * * @default false **/ disabled?: boolean; /** * 默认前缀 * * @default 'lg' **/ prefixCls?: string; /** * 通过覆盖默认的上传行为,可以自定义自己的上传实现 * * @default **/ customRequest?: (options: RcCustomRequestOptions) => void; /** * 上传请求时是否携带 cookie * * @default false **/ withCredentials?: boolean; /** * 点击打开文件对话框 * * @default true **/ openFileDialogOnClick?: boolean; /** * 自定义文件预览逻辑 * * @default **/ previewFile?: PreviewFileHandler; /** * 在上传之前转换文件。支持返回一个 Promise 对象 * * @default **/ transformFile?: TransformFileHandler; /** * 自定义显示 icon * * @default **/ iconRender?: (file: UploadFile, listType?: UploadListType) => React.ReactNode; } export interface UploadState { fileList: UploadFile[]; dragState: string; } export interface UploadListProps { listType?: UploadListType; onPreview?: (file: UploadFile) => void; onDownload?: (file: UploadFile) => void; onRemove?: (file: UploadFile) => void | boolean; items?: Array; progressAttr?: Object; prefixCls?: string; showRemoveIcon?: boolean; showDownloadIcon?: boolean; showPreviewIcon?: boolean; previewFile?: PreviewFileHandler; iconRender?: (file: UploadFile, listType?: UploadListType) => React.ReactNode; }