1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { ReactNode, CSSProperties, MouseEvent } from 'react';
- import { BaseFileItem } from '@douyinfe/semi-foundation/upload/foundation';
- import { strings } from '@douyinfe/semi-foundation/upload/constants';
- import { ArrayElement } from '../_base/base';
- export type PromptPositionType = ArrayElement<typeof strings.PROMPT_POSITION>;
- export type UploadListType = ArrayElement<typeof strings.LIST_TYPE>;
- export interface BeforeUploadProps {
- file: FileItem;
- fileList: Array<FileItem>;
- }
- export interface AfterUploadProps {
- file: FileItem;
- fileList: Array<FileItem>;
- response: any;
- }
- export interface OnChangeProps {
- fileList: Array<FileItem>;
- currentFile: FileItem;
- }
- export interface customRequestArgs {
- fileName: string; // Current file name
- data: Record<string, any>; // User-set props.data
- file: FileItem;
- fileInstance: File; // Original File Object which extends to the blob, the file object actually acquired by the browser (https://developer.mozilla.org/zh-CN/docs/Web/API/File)
- onProgress: (event: { total: number; loaded: number }) => any; // The function that should be called during the upload process, the event needs to contain the total and loaded attributes
- onError: (userXhr: { status?: number }, e: Event) => any; // Functions to call in case of upload error
- onSuccess: (response: any, e: Event) => any; // The function that should be called after the upload is successful, the response is the request result after the upload is successful
- withCredentials: boolean; // User-set props.with Credentials
- action: string; // User-set props.action
- }
- export interface CustomError extends Error {
- status: number;
- method: string;
- url: string;
- }
- export interface FileItem extends BaseFileItem {
- validateMessage?: ReactNode;
- }
- export interface RenderFileItemProps extends FileItem {
- previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
- listType: UploadListType;
- onRemove: (props: RenderFileItemProps, e: MouseEvent) => void;
- onRetry: (props: RenderFileItemProps, e: MouseEvent) => void;
- onReplace: (props: RenderFileItemProps, e: MouseEvent) => void;
- key: string;
- showRetry: boolean;
- showReplace: boolean;
- style?: CSSProperties;
- disabled: boolean;
- onPreviewClick: () => void;
- }
|