import { type UploadItemStatus, type UploadMode, type UploadSize } from '@mezzanine-ui/core/upload'; import { type ReactNode } from 'react'; import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types'; import type { UploaderProps } from './Uploader'; import type { UploadPictureCardAriaLabels } from './UploadPictureCard'; export interface UploadFile { /** * The file object. * Required when uploading new files. * Optional when `url` is provided for already uploaded files. */ file?: File; /** * The URL of the uploaded file. * When provided, this will be used to display files that have already been uploaded to the server. * Useful for loading file lists from the backend. */ url?: string; /** * The unique id of the file. */ id: string; /** * The upload status of the file. * @default 'loading' */ status: UploadItemStatus; /** * The upload progress percentage (0-100). * @default 0 */ progress?: number; /** * Error message to display when status is 'error'. * If not provided, the default error message from Upload component will be used. */ errorMessage?: string; /** * Error icon to display when status is 'error'. * If not provided, the default error icon from Upload component will be used. */ errorIcon?: ReactNode; } export interface UploadProps extends Omit, 'onChange'> { /** * The accept attributes of native input element. * @example 'image/*', '.pdf,.doc,.docx' */ accept?: string; /** * Whether the upload is disabled. * @default false */ disabled?: boolean; /** * Hints passed into the Uploader dropzone area. Only visible in dropzone modes (`list`, `card-wall`). */ dropzoneHints?: UploaderProps['hints']; /** * Controlled file list for the upload component. * Provide this along with `onChange` to fully control the file state. */ files?: UploadFile[]; /** * Array of hints displayed outside the uploader area. Visible in all modes. */ hints?: UploaderProps['hints']; /** * Icon configuration for different actions and states. */ uploaderIcon?: UploaderProps['icon']; /** * The id of input element. */ id?: string; /** * Since at Mezzanine we use a host element to wrap our input, most derived props will be passed to the host element. * If you need direct control to the input element, use this prop to provide to it. */ inputProps?: UploaderProps['inputProps']; /** * The react ref passed to input element. */ inputRef?: UploaderProps['inputRef']; /** * Maximum number of files allowed to upload. * If exceeded, the excess files will be ignored. */ maxFiles?: number; /** * The display mode for the upload component. * - 'list': Display files as a list using UploadItem (with dropzone) * - 'basic-list': Display files as a list without drag-and-drop * - 'button-list': Display uploader as a button with files in list format * - 'cards': Display image files as picture cards using UploadPictureCard * - 'card-wall': Display uploader at top with image files as picture cards below * @default 'list' */ mode?: UploadMode; /** * Whether can select multiple files to upload. * @default false */ multiple?: boolean; /** * The name attribute of the input element. */ name?: string; /** * The size of the upload component. * @default 'main' */ size?: UploadSize; /** * Whether to show file size in list mode. * @default true */ showFileSize?: boolean; /** * Label configuration for different states. */ uploaderLabel?: UploaderProps['label']; /** * Default error message to display when upload fails. * This will be used when a file's status becomes 'error' and no errorMessage is provided. */ errorMessage?: string; /** * Default error icon to display when upload fails. * This will be used when a file's status becomes 'error' and no errorIcon is provided. */ errorIcon?: ReactNode; /** * Aria labels passed to picture cards in `cards` / `card-wall` mode. * Useful for customizing text such as "Click to Replace". */ ariaLabels?: UploadPictureCardAriaLabels; /** * Fired when files list changes. */ onChange?: (files: UploadFile[]) => void; /** * Fired when a file is deleted. */ onDelete?: (fileId: string, file: File) => void; /** * Fired when a file is downloaded (done state). */ onDownload?: (fileId: string, file: File) => void; /** * Fired when the maximum number of files is exceeded. * @param maxFiles - The maximum number of files allowed * @param selectedCount - The number of files selected * @param currentCount - The current number of files in the list */ onMaxFilesExceeded?: (maxFiles: number, selectedCount: number, currentCount: number) => void; /** * Fired when a file upload is retried (error state). */ onReload?: (fileId: string, file: File) => void; /** * Fired when files are selected for upload. * @param files - The files to upload * @param setProgress - Callback to update upload progress for a specific file (file index, progress 0-100) * @returns Can return: * - UploadFile[]: Full file objects with backend-provided IDs and status * - { id: string }[]: Array of objects with backend-provided IDs (status will be set to 'done') * - void/Promise: For backward compatibility (status will be set to 'done') */ onUpload?: (files: File[], setProgress?: (fileIndex: number, progress: number) => void) => Promise | UploadFile[] | Promise> | Array<{ id: string; }> | Promise | void; /** * Fired when zoom in is clicked on a picture card (done state). */ onZoomIn?: (fileId: string, file: File) => void; } declare const Upload: import("react").ForwardRefExoticComponent>; export default Upload;