UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

44 lines (43 loc) 1.33 kB
import type { CleanupFunction } from '../__internal__/types.js'; type CreateFileDialogOptions = { /** * Whether to automatically clean up the event listeners or not. * @note If set to `true`, you must call `createFileDialog` in the component initialization lifecycle. * @default true */ autoCleanup?: boolean; /** @default '*' */ accept?: string; /** @default false */ multiple?: boolean; /** * Triggers when the file selection changes. * @default () => {} */ onChange?: (files: File[]) => void; /** * Triggers when the dialog is closed. * @default () => {} */ onCancel?: () => void; }; type CreateFileDialogReturn = { /** * A list of selected files. * @reactive */ readonly files: File[]; /** Opens the file dialog. */ open: () => void; /** Resets the file dialog. */ reset: () => void; /** Cleans up the input node and the event listeners. */ cleanup: CleanupFunction; }; /** * Creates a file dialog to interact with programatically. * @param options Additional options to customize the behavior. * @see https://svelte-librarian.github.io/sv-use/docs/core/create-file-dialog */ export declare function createFileDialog(options?: CreateFileDialogOptions): CreateFileDialogReturn; export {};