import * as React from "react"; import Dragger from "./Dragger"; import { RcFile, UploadState, UploadFile, UploadChangeParam, UploadType, UploadListType, HttpRequestHeader, ShowUploadListInterface, RcCustomRequestOptions, PreviewFileHandler, TransformFileHandler } from "./interface"; import { T } from "./utils"; import { ConfigConsumerProps } from "../Config"; 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; } declare class Upload extends React.Component { static Dragger: typeof Dragger; static defaultProps: { type: UploadType; multiple: boolean; action: string; data: {}; accept: string; beforeUpload: typeof T; showUploadList: boolean; listType: UploadListType; className: string; disabled: boolean; supportServerRender: boolean; }; static getDerivedStateFromProps(nextProps: UploadProps): { fileList: UploadFile[]; } | null; recentUploadStatus: boolean | PromiseLike; progressTimer: any; upload: any; constructor(props: UploadProps); componentWillUnmount(): void; saveUpload: (node: any) => void; onStart: (file: RcFile) => void; onSuccess: (response: any, file: UploadFile, xhr: any) => void; onProgress: (e: { percent: number; }, file: UploadFile) => void; onError: (error: Error, response: any, file: UploadFile) => void; handleRemove: (file: UploadFile) => void; onChange: (info: UploadChangeParam) => void; onFileDrop: (e: React.DragEvent) => void; beforeUpload: (file: RcFile, fileList: RcFile[]) => boolean | PromiseLike; clearProgressTimer(): void; renderUploadList: (prefixCls: any) => JSX.Element; renderUpload: ({ getPrefixCls }: ConfigConsumerProps) => JSX.Element; render(): JSX.Element; } export default Upload;