1 | import React from 'react';
|
2 | import type { ReactNode, InputHTMLAttributes, ReactElement } from 'react';
|
3 | import { NativeProps } from '../../utils/native-props';
|
4 | import type { ImageProps } from '../image';
|
5 | import { GridProps } from '../grid';
|
6 | export declare type TaskStatus = 'pending' | 'fail' | 'success';
|
7 | export interface ImageUploadItem {
|
8 | key?: string | number;
|
9 | url: string;
|
10 | thumbnailUrl?: string;
|
11 | extra?: any;
|
12 | }
|
13 | declare type Task = {
|
14 | id: number;
|
15 | url?: string;
|
16 | file: File;
|
17 | status: TaskStatus;
|
18 | };
|
19 | export declare type UploadTask = Pick<Task, 'id' | 'status'>;
|
20 | export declare type ImageUploaderProps = {
|
21 | defaultValue?: ImageUploadItem[];
|
22 | value?: ImageUploadItem[];
|
23 | columns?: GridProps['columns'];
|
24 | onChange?: (items: ImageUploadItem[]) => void;
|
25 | onUploadQueueChange?: (tasks: UploadTask[]) => void;
|
26 | accept?: string;
|
27 | multiple?: boolean;
|
28 | maxCount?: number;
|
29 | onCountExceed?: (exceed: number) => void;
|
30 | disableUpload?: boolean;
|
31 | showUpload?: boolean;
|
32 | deletable?: boolean;
|
33 | deleteIcon?: ReactNode;
|
34 | capture?: InputHTMLAttributes<unknown>['capture'];
|
35 | onPreview?: (index: number, item: ImageUploadItem) => void;
|
36 | beforeUpload?: (file: File, files: File[]) => Promise<File | null> | File | null;
|
37 | upload: (file: File) => Promise<ImageUploadItem>;
|
38 | onDelete?: (item: ImageUploadItem) => boolean | Promise<boolean> | void;
|
39 | preview?: boolean;
|
40 | showFailed?: boolean;
|
41 | imageFit?: ImageProps['fit'];
|
42 | children?: ReactNode;
|
43 | renderItem?: (originNode: ReactElement, file: ImageUploadItem, fileList: ImageUploadItem[]) => ReactNode;
|
44 | } & NativeProps<'--cell-size' | '--gap' | '--gap-vertical' | '--gap-horizontal'>;
|
45 | export interface ImageUploaderRef {
|
46 | nativeElement: HTMLInputElement | null;
|
47 | }
|
48 | export declare const ImageUploader: React.ForwardRefExoticComponent<{
|
49 | defaultValue?: ImageUploadItem[] | undefined;
|
50 | value?: ImageUploadItem[] | undefined;
|
51 | columns?: number | undefined;
|
52 | onChange?: ((items: ImageUploadItem[]) => void) | undefined;
|
53 | onUploadQueueChange?: ((tasks: UploadTask[]) => void) | undefined;
|
54 | accept?: string | undefined;
|
55 | multiple?: boolean | undefined;
|
56 | maxCount?: number | undefined;
|
57 | onCountExceed?: ((exceed: number) => void) | undefined;
|
58 | disableUpload?: boolean | undefined;
|
59 | showUpload?: boolean | undefined;
|
60 | deletable?: boolean | undefined;
|
61 | deleteIcon?: ReactNode;
|
62 | capture?: InputHTMLAttributes<unknown>['capture'];
|
63 | onPreview?: ((index: number, item: ImageUploadItem) => void) | undefined;
|
64 | beforeUpload?: ((file: File, files: File[]) => Promise<File | null> | File | null) | undefined;
|
65 | upload: (file: File) => Promise<ImageUploadItem>;
|
66 | onDelete?: ((item: ImageUploadItem) => boolean | Promise<boolean> | void) | undefined;
|
67 | preview?: boolean | undefined;
|
68 | showFailed?: boolean | undefined;
|
69 | imageFit?: ImageProps['fit'];
|
70 | children?: ReactNode;
|
71 | renderItem?: ((originNode: ReactElement, file: ImageUploadItem, fileList: ImageUploadItem[]) => ReactNode) | undefined;
|
72 | } & {
|
73 | className?: string | undefined;
|
74 | style?: (React.CSSProperties & Partial<Record<"--gap" | "--gap-vertical" | "--gap-horizontal" | "--cell-size", string>>) | undefined;
|
75 | tabIndex?: number | undefined;
|
76 | } & React.AriaAttributes & React.RefAttributes<ImageUploaderRef>>;
|
77 | export {};
|
78 |
|
\ | No newline at end of file |