import type { Snippet } from 'svelte';
import type { HTMLAttributes } from 'svelte/elements';
import type { MintProp } from '../../mint/index.js';
import type { FileUploadSlots, FileUploadVariants } from './fileUpload.variants.js';
import type { FileIntakeRejection as FileRejection, FileIntakeError as FileUploadError, FileIntakeErrorCode as FileUploadErrorCode, FileIntakeEntry as FileUploadFile, FileIntakeStatus as FileUploadStatus } from '../../utils/file-intake.js';
export type { FileRejection, FileUploadError, FileUploadErrorCode, FileUploadFile, FileUploadStatus };
export declare const IMAGE_MIME_TYPES: string[];
export declare const PDF_MIME_TYPE: string[];
export declare const VIDEO_MIME_TYPES: string[];
export declare const AUDIO_MIME_TYPES: string[];
export interface FileItemContext {
/** The file entry. */
fileEntry: FileUploadFile;
/** Remove this file from the list. */
remove: () => void;
}
/** Slot names for `slotClasses` — derived from the `tv()` config (single source of truth). */
export type FileUploadSlotName = FileUploadSlots;
/**
* @summary Drop files here: validation, previews and progress included.
* @description Drag-and-drop file upload with validation, image previews, progress tracking, and animated file list.
* @tag form
* @related Input
* @related Button
* @related Progress
*
* @example
* ```svelte
*
* ```
*
* @example
* ```svelte
* console.log('Rejected:', rejections)}
* />
* ```
*/
export interface FileUploadProps extends Omit, Omit, 'children'> {
/** Default slot for fully custom dropzone content. */
children?: Snippet;
/** Custom file item renderer. Receives file entry and remove callback. */
fileItem?: Snippet<[FileItemContext]>;
/** Custom dropzone icon snippet. */
dropzoneIcon?: Snippet;
/** Dropzone title text. */
title?: string;
/** Dropzone description text (accepted types, limits). */
description?: string;
/** Accepted MIME types or file extensions (e.g. 'image/*', '.pdf'). */
accept?: string | string[];
/** Maximum number of files. */
maxFiles?: number;
/** Maximum file size in bytes. */
maxFileSize?: number;
/** Minimum file size in bytes. */
minFileSize?: number;
/** Allow selecting multiple files. */
multiple?: boolean;
/** Custom validation function. Return errors array or null. */
validate?: (file: File) => FileUploadError[] | null;
/** Enable drag-and-drop. @default true */
allowDrop?: boolean;
/** Enable paste from clipboard. @default false */
allowPaste?: boolean;
/** Prevent browser navigation when files are dropped outside the zone. @default true */
preventDocumentDrop?: boolean;
/** Disable all interaction. */
disabled?: boolean;
/** Mark as required for form validation. */
required?: boolean;
/**
* Shared `name` for native form submission. When set, the underlying
* hidden `` carries the current file list — including
* files added via drag/drop, paste, or programmatic `bind:files`, not
* just files picked through the file dialog. Submits as a `File[]` under
* `{name}` in the FormData payload.
*/
name?: string;
/** Current file list. Supports two-way binding. */
files?: FileUploadFile[];
/**
* Convenience binding for single-file uses. Two-way:
* - Reads as `files[0]?.file ?? null`.
* - Setting to a `File` replaces the current selection (object URLs are
* revoked, no validation re-runs — assumes the caller already validated).
* - Setting to `null` clears the list.
*
* Recommended when `maxFiles === 1` (e.g. logo / avatar uploads). Use
* `bind:files` instead when you need progress, errors, or status metadata.
*/
file?: File | null;
/** Fires when valid files are accepted. */
onFileAccept?: (files: FileUploadFile[]) => void;
/** Fires when files are rejected by validation. */
onFileReject?: (rejections: FileRejection[]) => void;
/** Fires when the file list changes (add or remove). */
onFilesChange?: (files: FileUploadFile[]) => void;
/** Fires when a file is removed. */
onFileRemove?: (file: FileUploadFile) => void;
/**
* Micro-interaction preset applied to the dropzone. Only applies while
* not disabled.
* @default 'none'
*/
mint?: MintProp;
/** Additional CSS class for the root element. */
class?: string;
/** Strip all default styles. */
unstyled?: boolean;
/** Per-slot class overrides. */
slotClasses?: Partial>;
/**
* Apply a named preset registered via ``.
* Prefer this over `class` overrides when the requested look falls outside the
* semantic intent palette — presets keep hover/active/dark-mode logic coherent
* and make the custom look reusable across the project.
*/
preset?: string;
}
export { default as FileUpload } from './FileUpload.svelte';
export { type FileUploadVariants, fileUploadVariants } from './fileUpload.variants.js';