@opensig/opendesign
Version:
175 lines (174 loc) • 4.92 kB
TypeScript
import { Component, ExtractPropTypes, PropType } from 'vue';
export interface UploadRequestT {
abort: () => void;
}
export declare const UploadFileStatusTypes: readonly ["pending", "uploading", "finished", "failed"];
export type UploadFileStatusT = (typeof UploadFileStatusTypes)[number];
export interface UploadFileT {
id: string | number;
name: string;
file?: File;
status?: UploadFileStatusT;
message?: string;
messageClass?: string;
retry?: boolean;
percent?: number;
request?: UploadRequestT;
icon?: string | boolean | Component;
imgUrl?: string;
}
export interface UploadRequestOptionT {
onProgress: (percent: number, event?: ProgressEvent) => void;
onSuccess: (response?: {
messages?: string;
[k: string]: unknown;
}) => void;
onError: (response?: {
messages?: string;
[k: string]: unknown;
}, retry?: boolean) => void;
file: UploadFileT;
}
export declare const UploadListTypes: readonly ["text", "picture", "picture-card"];
export type UploadListTypeT = (typeof UploadListTypes)[number];
export declare const uploadProps: {
/**
* @zh-CN 文件列表(受控)
* @en-US File List (Controlled).
*/
modelValue: {
type: PropType<UploadFileT[]>;
};
/**
* @zh-CN 文件列表(非受控)
* @en-US File list (uncontrolled).
*/
defaultFileList: {
type: PropType<UploadFileT[]>;
};
/**
* @zh-CN 文件选择,MIME类型:image/jpeg;image/jpg;image/png;image/gif;video/mp4
* @en-US File selection, MIME type: image/jpeg; image/jpg; image/png; image/gif; video/mp4.
*/
accept: {
type: StringConstructor;
};
/**
* @zh-CN 是否为禁用状态
* @en-US Disable uploading.
*/
disabled: {
type: BooleanConstructor;
};
/**
* @zh-CN 是否支持多文件上传
* @en-US Support multi-file upload.
*/
multiple: {
type: BooleanConstructor;
};
/**
* @zh-CN 选择文件前回调,根据返回值判断是否继续选择文件
* @en-US Before selecting a file, there is a callback. Based on the return value, determine whether to continue selecting the file.
*/
beforeSelect: {
type: PropType<(value: UploadFileT[]) => Promise<boolean> | boolean>;
};
/**
* @zh-CN 选择后触发
* @en-US Triggered after selection.
*/
onAfterSelect: {
type: PropType<(fileList: FileList) => Promise<Array<UploadFileT>>>;
};
/**
* @zh-CN 下载文件
* @en-US Download the file.
* @since 1.2.1
*/
downloadFile: {
type: PropType<(file: File) => void>;
};
/**
* @zh-CN 上传按钮文本
* @en-US Upload button text.
*/
btnLabel: {
type: StringConstructor;
};
/**
* @zh-CN 自定义上传请求
* @en-US Customize upload requests.
*/
uploadRequest: {
type: PropType<(options: UploadRequestOptionT) => UploadRequestT>;
};
/**
* @zh-CN true 选择完成后,手动触发上传;false 选择完成后自动上传
* @en-US After the true selection is completed, manually trigger the upload. false: Automatically upload after selection is completed.
*/
lazyUpload: {
type: BooleanConstructor;
};
/**
* @zh-CN 上传前触发
* @en-US Triggered before upload.
*/
onBeforeUpload: {
type: PropType<(file: UploadFileT) => Promise<boolean | File>>;
};
/**
* @zh-CN 删除前触发
* @en-US Triggered before deletion.
*/
onBeforeRemove: {
type: PropType<(file: UploadFileT) => Promise<boolean>>;
};
/**
* @zh-CN 支持拖拽上传
* @en-US Supports drag-and-drop upload.
*/
draggable: {
type: BooleanConstructor;
};
/**
* @zh-CN 拖拽区域上传提示文本
* @en-US Drag the area to upload the prompt text.
*/
dragLabel: {
type: StringConstructor;
};
/**
* @zh-CN 拖拽区域拖拽中的提示文本
* @en-US The prompt text in the drag-and-drop area.
*/
dragHoverLabel: {
type: StringConstructor;
};
/**
* @zh-CN 文件列表类型
* @en-US File list type.
* @default 'text'
*/
listType: {
type: PropType<"text" | "picture" | "picture-card">;
default: string;
};
/**
* @zh-CN 生成缩略图
* @en-US Generate thumbnails.
*/
createThumbnail: {
type: PropType<(file: File) => Promise<string>>;
};
/**
* @zh-CN 文件上传中是否展示进度条
* @en-US Whether to display a progress bar during file upload.
* @since 1.2.0
*/
showProgress: {
type: BooleanConstructor;
default: boolean;
};
};
export type UploadPropsT = ExtractPropTypes<typeof uploadProps>;