import { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; type $RestProps = SvelteHTMLElements["div"]; type $Props = { /** * Specify the file uploader status. * @default "uploading" */ status?: "uploading" | "edit" | "complete"; /** * Set to `true` to disable the file uploader * @default false */ disabled?: boolean; /** * Specify the accepted file types. * @default [] */ accept?: ReadonlyArray; /** * Specify the maximum file size in bytes. * Files exceeding this limit will be filtered out. * File sizes use binary (base 2) units: 1024 bytes = 1 KiB, not 1000 bytes. * @example * ```svelte * * * ``` * @default undefined */ maxFileSize?: number | undefined; /** * Obtain a reference to the uploaded files. * @default [] */ files?: ReadonlyArray; /** * Set to `true` to allow multiple files * @default false */ multiple?: boolean; /** * Set to `true` to reject files that match an already-selected file * (by name, size, and lastModified). Rejected duplicates are reported * via the `rejected` event with `reason: 'duplicate'`. * @default false */ preventDuplicate?: boolean; /** * Control how newly added files are ordered in the list. * - `"append"` (default): new files appear at the end * - `"prepend"`: new files appear at the beginning * - A custom function receiving (existingFiles, newFiles) that returns the merged array * @default "append" */ orderFiles?: | "append" | "prepend" | (( existing: ReadonlyArray, added: ReadonlyArray, ) => ReadonlyArray); /** * Specify the label title. * Alternatively, use the named slot "labelTitle". * @example * ```svelte * * Custom Label * * ``` * @default "" */ labelTitle?: string; /** * Specify the label description. * Alternatively, use the named slot "labelDescription". * @example * ```svelte * * Custom description text * * ``` * @default "" */ labelDescription?: string; /** * Specify the kind of file uploader button. * @default "primary" */ kind?: import("../Button/Button.svelte").ButtonProps["kind"]; /** * Specify the size of the file uploader button. * @default "small" */ size?: import("../Button/Button.svelte").ButtonProps["size"]; /** * Specify the button label * @default "" */ buttonLabel?: string; /** * Accessible label for file row status icons (spinner, remove control, checkmark). * Forwarded to `Filename`. Use a string, or a function with context `{ file, fileName, status, invalid }` * where `file` is the row's `File` (only set from `FileUploader`, not from `FileUploaderItem`). * When omitted or the resolved value is blank after trim, `Filename` uses built-in defaults. * @default undefined */ iconDescription?: | string | undefined | ((ctx: { file?: File; fileName: string; status: "uploading" | "edit" | "complete"; invalid: boolean; }) => string | undefined); /** * Specify a name attribute for the file button uploader input * @default "" */ name?: string; /** * Obtain a reference to the input HTML element. * @default null */ ref?: null | HTMLInputElement; [key: `data-${string}`]: unknown; }; export type FileUploaderProps = Omit<$RestProps, keyof $Props> & $Props; export default class FileUploader extends SvelteComponentTyped< FileUploaderProps, { add: CustomEvent>; change: CustomEvent>; clear: CustomEvent; click: WindowEventMap["click"]; keydown: WindowEventMap["keydown"]; mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; mouseover: WindowEventMap["mouseover"]; rejected: CustomEvent>; remove: CustomEvent>; }, { labelDescription: Record; labelTitle: Record } > { /** * Programmatically clear the uploaded files. * @example * ```svelte * * * ``` */ clearFiles: () => void; }