Provides managed control of the Foundry globalThis.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 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 FVTTFilePickerControl.browse see 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 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: 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:

  • TJSFileButton - A standard form button element.
  • TJSFileIconButton - Uses TJSIconButton for display.
  • TJSFileSlotButton - Provides a slotted button where you can provide any containing content.

Constructors

Accessors

Methods

Constructors

Accessors

  • get canBrowse(): boolean
  • Returns boolean

    Test if the current user can browse files.

Methods

  • Brings any non-modal / glasspane file picker to top. Returning if it is the active file picker.

    Parameters

    • Optionalid: string

      The ID of the file picker app.

    Returns boolean

    Whether the file picker app is brought to top.

  • Creates a new Foundry FilePicker app to browse and return a file path selection.

    Parameters

    Returns Promise<string>

    The file picker / browse result.

  • 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.

    Parameters

    • Optionalid: string | Iterable<string, any, any>

      Specific IDs to match against any current visible file picker app.

    Returns void