UNPKG

@aliretail/react-materials-components

Version:
172 lines (171 loc) 4.3 kB
import React from 'react'; import CardUpload from './card'; export interface OssUploaderProps { /** * 值 */ value: Item[] | Item; /** * 上传类型 */ uploadType: 'image' | 'video' | 'xls' | 'all'; /** * 业务类型,应该从文件中心动态获取 */ bizType: 'articleMaterial' | 'frontImage' | 'brandLogo' | 'buyerProof' | 'sellerProof' | 'counselorProof' | 'merchantProof' | 'idcardImage' | 'itemImage' | 'itemVideo' | 'snapshot' | 'itemDescription' | 'CRDI'; /** * 上传提示信息 */ uploadHint: React.ReactElement; /** * 业务名称 (bizName) */ uploadScene: 'item' | 'category' | 'store' | 'reverse' | 'trade' | 'crm' | 'CRDI'; /** * 上传接口额外参数 */ data: any; /** * 文件上传名 */ name: string; /** * 文件数量限制,若为1,则value取数组第一个元素 */ limit: number; /** * 禁用状态 */ disabled: boolean; /** * 只读状态 */ readOnly: boolean; /** * 预览状态 */ isPreview: boolean; /** * 是否隐藏 */ hidden: boolean; /** * 只使用url */ onlyUrl: boolean; /** * 请求的baseURL */ baseURL: string; /** * 是否允许请求携带 cookie */ withCredentials: boolean; /** * class name */ className: string; /** * 卡片样式 */ style: React.CSSProperties; /** * 接受上传的文件类型 (image/png, image/jpg, .doc, .ppt) ,若未指定,则会从bizType或uploadType进行推断 */ accept: string; /** * 获取文件签名url */ getOssSignatureUrl: string; /** * 上传回调url */ uploadCallbackUrl: string; /** * css 前缀 */ prefix: string; /** * 上传前 hook */ beforeUpload: (file: File, options: { [key: string]: any; }) => boolean | { [key: string]: any; } | Promise<any>; /** * 删除回调 * @param {Item} info */ onRemove: (info: Item) => void; /** * 上传成功回调 * @param {Item} info */ onSuccess: (info: any) => void; /** * 上传失败回调 * @param {File} file * @param {Item[]} value */ onError: (file: File, value?: Item[]) => void; /** * @param {Item[] | Item} info */ onChange: (info: Item[] | Item) => void; /** * 组件初始化回调 */ onInit: () => void; /** * 数据格式化函数,配合自定义 action 使用,参数为服务器的响应数据,详见 Fusion Upload 组件的 formatter * response: {any} 接口返回 * file: {File} 文件对象 */ formatter: (response: any, file: File) => void; } export interface OssUploaderState { value: Item[]; cssPrefix: string; } export interface ItemObject { thumbUrl: string; downloadURL: string; name: string; size?: number; duration?: number; } export declare type Item = ItemObject | string; declare class OssUploader extends React.Component<OssUploaderProps, OssUploaderState> { cardUpload: CardUpload; static defaultProps: { uploadType: string; uploadScene: string; onlyUrl: boolean; limit: number; hidden: boolean; withCredentials: boolean; disabled: boolean; readOnly: boolean; isPreview: boolean; prefix: string; }; constructor(props: any); openUploadLayer(): void; isSameArray(arr1: any, arr2: any): boolean; UNSAFE_componentWillReceiveProps(nextProps: any): void; getContent: () => any; deleteImage: (item: any, index: any) => void; previewImage: (item?: ItemObject) => void; previewVideo: (item?: ItemObject) => void; fullScreenShow: (content: any) => void; normalizeInputValue: (value: any) => any; normalizeReturnValue: (value: any) => any; onUploadSuccess: (info: any) => void; onUploadError: (e: any) => void; renderCardItem: (item: ItemObject, index: any) => any; renderPreviewEmpty: () => JSX.Element; getAcceptFileType: () => string; render(): JSX.Element; } export default OssUploader;