1 | import type * as React from 'react';
|
2 | import type { RcFile as OriRcFile, UploadRequestOption as RcCustomRequestOptions, UploadProps as RcUploadProps } from 'rc-upload/lib/interface';
|
3 | import type { ProgressAriaProps, ProgressProps } from '../progress';
|
4 | export interface RcFile extends OriRcFile {
|
5 | readonly lastModifiedDate: Date;
|
6 | }
|
7 | export type UploadFileStatus = 'error' | 'done' | 'uploading' | 'removed';
|
8 | export interface HttpRequestHeader {
|
9 | [key: string]: string;
|
10 | }
|
11 | export interface UploadFile<T = any> extends ProgressAriaProps {
|
12 | uid: string;
|
13 | size?: number;
|
14 | name: string;
|
15 | fileName?: string;
|
16 | lastModified?: number;
|
17 | lastModifiedDate?: Date;
|
18 | url?: string;
|
19 | status?: UploadFileStatus;
|
20 | percent?: number;
|
21 | thumbUrl?: string;
|
22 | crossOrigin?: React.ImgHTMLAttributes<HTMLImageElement>['crossOrigin'];
|
23 | originFileObj?: RcFile;
|
24 | response?: T;
|
25 | error?: any;
|
26 | linkProps?: any;
|
27 | type?: string;
|
28 | xhr?: T;
|
29 | preview?: string;
|
30 | }
|
31 | export interface InternalUploadFile<T = any> extends UploadFile<T> {
|
32 | originFileObj: RcFile;
|
33 | }
|
34 | export interface UploadChangeParam<T = UploadFile> {
|
35 | file: T;
|
36 | fileList: T[];
|
37 | event?: {
|
38 | percent: number;
|
39 | };
|
40 | }
|
41 | export interface ShowUploadListInterface<T = any> {
|
42 | showRemoveIcon?: boolean;
|
43 | showPreviewIcon?: boolean;
|
44 | showDownloadIcon?: boolean;
|
45 | removeIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
46 | downloadIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
47 | previewIcon?: React.ReactNode | ((file: UploadFile<T>) => React.ReactNode);
|
48 | }
|
49 | export interface UploadLocale {
|
50 | uploading?: string;
|
51 | removeFile?: string;
|
52 | downloadFile?: string;
|
53 | uploadError?: string;
|
54 | previewFile?: string;
|
55 | }
|
56 | export type UploadType = 'drag' | 'select';
|
57 | export type UploadListType = 'text' | 'picture' | 'picture-card' | 'picture-circle';
|
58 | export type UploadListProgressProps = Omit<ProgressProps, 'percent' | 'type'>;
|
59 | export type ItemRender<T = any> = (originNode: React.ReactElement, file: UploadFile<T>, fileList: Array<UploadFile<T>>, actions: {
|
60 | download: () => void;
|
61 | preview: () => void;
|
62 | remove: () => void;
|
63 | }) => React.ReactNode;
|
64 | type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
|
65 | type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
|
66 | type BeforeUploadValueType = void | boolean | string | Blob | File;
|
67 | export interface UploadProps<T = any> extends Pick<RcUploadProps, 'capture' | 'hasControlInside'> {
|
68 | type?: UploadType;
|
69 | name?: string;
|
70 | defaultFileList?: Array<UploadFile<T>>;
|
71 | fileList?: Array<UploadFile<T>>;
|
72 | action?: string | ((file: RcFile) => string) | ((file: RcFile) => PromiseLike<string>);
|
73 | directory?: boolean;
|
74 | data?: Record<string, unknown> | ((file: UploadFile<T>) => Record<string, unknown> | Promise<Record<string, unknown>>);
|
75 | method?: 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch';
|
76 | headers?: HttpRequestHeader;
|
77 | showUploadList?: boolean | ShowUploadListInterface;
|
78 | multiple?: boolean;
|
79 | accept?: string;
|
80 | beforeUpload?: (file: RcFile, FileList: RcFile[]) => BeforeUploadValueType | Promise<BeforeUploadValueType>;
|
81 | onChange?: (info: UploadChangeParam<UploadFile<T>>) => void;
|
82 | onDrop?: (event: React.DragEvent<HTMLDivElement>) => void;
|
83 | listType?: UploadListType;
|
84 | className?: string;
|
85 | rootClassName?: string;
|
86 | onPreview?: (file: UploadFile<T>) => void;
|
87 | onDownload?: (file: UploadFile<T>) => void;
|
88 | onRemove?: (file: UploadFile<T>) => void | boolean | Promise<void | boolean>;
|
89 | supportServerRender?: boolean;
|
90 | style?: React.CSSProperties;
|
91 | disabled?: boolean;
|
92 | prefixCls?: string;
|
93 | customRequest?: (options: RcCustomRequestOptions) => void;
|
94 | withCredentials?: boolean;
|
95 | openFileDialogOnClick?: boolean;
|
96 | locale?: UploadLocale;
|
97 | id?: string;
|
98 | previewFile?: PreviewFileHandler;
|
99 |
|
100 | transformFile?: TransformFileHandler;
|
101 | iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
102 | isImageUrl?: (file: UploadFile<T>) => boolean;
|
103 | progress?: UploadListProgressProps;
|
104 | itemRender?: ItemRender<T>;
|
105 |
|
106 | maxCount?: number;
|
107 | children?: React.ReactNode;
|
108 | }
|
109 | export interface UploadState<T = any> {
|
110 | fileList: UploadFile<T>[];
|
111 | dragState: string;
|
112 | }
|
113 | export interface UploadListProps<T = any> {
|
114 | listType?: UploadListType;
|
115 | onPreview?: (file: UploadFile<T>) => void;
|
116 | onDownload?: (file: UploadFile<T>) => void;
|
117 | onRemove?: (file: UploadFile<T>) => void | boolean;
|
118 | items?: Array<UploadFile<T>>;
|
119 | progress?: UploadListProgressProps;
|
120 | prefixCls?: string;
|
121 | className?: string;
|
122 | showRemoveIcon?: boolean;
|
123 | showDownloadIcon?: boolean;
|
124 | showPreviewIcon?: boolean;
|
125 | removeIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
126 | downloadIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
127 | previewIcon?: React.ReactNode | ((file: UploadFile) => React.ReactNode);
|
128 | locale: UploadLocale;
|
129 | previewFile?: PreviewFileHandler;
|
130 | iconRender?: (file: UploadFile<T>, listType?: UploadListType) => React.ReactNode;
|
131 | isImageUrl?: (file: UploadFile<T>) => boolean;
|
132 | appendAction?: React.ReactNode;
|
133 | appendActionVisible?: boolean;
|
134 | itemRender?: ItemRender<T>;
|
135 | }
|
136 | export {};
|