import * as _runtime_svelte_store_util from '@typhonjs-fvtt/runtime/svelte/store/util'; import * as _runtime_svelte_transition from '@typhonjs-fvtt/runtime/svelte/transition'; /** * Provides managed control of the Foundry {@link fvtt.FilePicker} app simplifying asynchronous use cases. While the stock * FilePicker provides a callback it is not easy to make it asynchronous given that a user can close the app. * FVTTFilePickerControl enables a fully asynchronous workflow controlling one FilePicker instance at a time. When * {@link FVTTFilePickerControl.browse} is invoked any previous FilePicker instance is closed and Promise resolved. * * Additionally, the file picker app is modified to work in modal context w/ TJSGlassPane along with any managing * associated dialog instances displayed. A very powerful capability is to display a modal FilePicker app instance. * * For extended options available for {@link FVTTFilePickerControl.browse} see {@link FVTTFilePickerBrowseOptions}. * It is highly recommended that you provide a unique CSS ID for each file picker instance invoked. * A use case where you should use FVTTFilePickerControl is to invoke {@link FVTTFilePickerControl.close} * in an `onDestroy` Svelte callback to close any open file picker apps associated w/ UI layout components you design. * * A demo example is available in `essential-svelte-esm`: * {@link https://github.com/typhonjs-fvtt-demo/essential-svelte-esm} * * Several ready-made Svelte components are available that are designed around FVTTFilePickerControl. * * Please see the following Svelte components that can be imported from `#standard/component/fvtt/filepicker/button`: * * @see TJSFileButton - A standard form button element. * @see TJSFileIconButton - Uses TJSIconButton for display. * @see TJSFileSlotButton - Provides a slotted button where you can provide any containing content. */ declare class FVTTFilePickerControl { /** * @returns {boolean} Test if the current user can browse files. */ static get canBrowse(): boolean; /** * Brings any non-modal / glasspane file picker to top. Returning if it is the active file picker. * * @param {string} [id] - The ID of the file picker app. * * @returns {boolean} Whether the file picker app is brought to top. */ static bringToTop(id?: string): boolean; /** * Creates a new Foundry FilePicker app to browse and return a file path selection. * * @param {FVTTFilePickerBrowseOptions} [options] - FVTTFilePickerControl browse options. This may also include any * Application options. * * @param {KeyboardEvent | MouseEvent} [event] - An event to inspect for focus management when a modal file picker * is launched. * * @returns {Promise} The file picker / browse result. */ static browse(options?: FVTTFilePickerBrowseOptions, event?: KeyboardEvent | MouseEvent): Promise; /** * Closes the file picker with optional `id` of a specific file picker app to close. You may also provide a list of * app IDs to close. When provided only the file picker app instance with a matching ID will be closed. * * Note: When `close` is invoked w/ no `id` parameter any current file picker app is closed. * * @param {string | Iterable} [id] - Specific IDs to match against any current visible file picker app. */ static close(id?: string | Iterable): void; } /** * - Foundry {@link fvtt.FilePicker} w/ expanded * FVTTFilePickerControl options. */ type FVTTFilePickerBrowseOptions = { /** * A type of file to target, in 'audio', 'image', 'video', 'imagevideo', * 'folder', 'font', 'graphics', 'text', or 'any'. */ type?: string; /** * The current file path being modified, if any. */ current?: string; /** * A current file source in 'data', 'public', or 's3'. */ activeSource?: string; /** * A callback function to trigger once a file has been selected. */ callback?: Function; /** * A flag which permits explicitly disallowing upload, true by default. */ allowUpload?: boolean; /** * A map of favorite folder configuration objects. */ favorites?: Map; /** * The picker display mode in FilePicker.DISPLAY_MODES. */ displayMode?: string; /** * Display the tile size configuration. */ tileSize?: boolean; /** * Redirect to the root directory rather than starting in the source directory * of one of these files. */ redirectToRoot?: string[]; /** * A specific unique CSS app ID. */ id?: string; /** * Provide the CSS ID of the glasspane to move the file picker app to after opening. */ glasspaneId?: string; /** * When true a modal file picker will be opened. */ modal?: boolean; /** * Options for the modal glasspane / TJSGlasspane component. */ modalOptions?: { background: string; closeOnInput: boolean; styles: { [key: string]: string | null; }; transition: _runtime_svelte_transition.TransitionFunction; transitionOptions: { [key: string]: any; }; }; /** * Optional function invoked when URL string changes. */ onURLString?: ({ urlString: string }: any) => void; /** * Optional validation function of * selected URL string. */ onValidateURLString?: ({ urlString: string }: any) => Promise; /** * A minimal writable store that is * set with result. */ store?: _runtime_svelte_store_util.MinimalWritable; /** * Provides an explicit `z-index` for the file picker app. */ zIndex?: number; }; export { type FVTTFilePickerBrowseOptions, FVTTFilePickerControl };