import * as svelte from 'svelte'; import * as _runtime_svelte_application from '@typhonjs-fvtt/runtime/svelte/application'; import * as _runtime_svelte_util from '@typhonjs-fvtt/runtime/svelte/util'; /** * Provides the ability to mount and control Svelte component based sidebar panels & tabs in the Foundry sidebar. * * The nice aspect about FVTTSidebarControl is that all you have to provide is the sidebar component and the rest is * handled for you including automatically widening the width of the sidebar to fit the new sidebar tab. Also by default * an adhoc SvelteApp is configured to display the sidebar when popped out automatically without the need to * associate an app instance. * * ------------------------------------------------------------------------------------------------------------------- * * To add a new sidebar tab schedule one or more invocations of {@link FVTTSidebarControl.add} in a `setup` hook. You * must add all sidebars in the `setup` hook before the main Foundry sidebar renders. Please review all the expanded * options available in the configuration object passed to the `add` method. At minimum, you need to provide a unique * `id`, `icon`, and `svelte` configuration object. You almost always will want to provide `beforeId` referencing * another existing sidebar tab ID to place the tab button before. If undefined the tab is inserted at the end of * the sidebar tabs. The default Foundry sidebar tab IDs from left to right are: 'chat', 'combat', 'scenes', 'actors', * 'items', 'journal', 'tables', 'cards', 'playlists', 'compendium', and 'settings'. * * ------------------------------------------------------------------------------------------------------------------- * * Optionally: * - You can define the `icon` as a Svelte configuration object to load an interactive component instead of * using a FontAwesome icon. This allows you to dynamically show state similar to the chat log sidebar when activity * occurs or for other purposes. * * - You can provide `popoutOptions` overriding the default options passed to the default adhoc SvelteApp * rendered for the popout. * * - You can provide a class that extends from SvelteApp as `popoutApplication` to provide a fully customized * popout sidebar that you fully control. * * ------------------------------------------------------------------------------------------------------------------- * * There is a method to remove an existing stock Foundry sidebar {@link FVTTSidebarControl.remove}. It takes * an `id` field that must be one of the existing Foundry sidebar IDs to remove: chat', 'combat', 'scenes', * 'actors', 'items', 'journal', 'tables', 'cards', 'playlists', 'compendium', and 'settings'. * * ------------------------------------------------------------------------------------------------------------------- * * There is a method to replace an existing stock Foundry sidebar {@link FVTTSidebarControl.replace}. It takes * the same data as the `add` method, but `id` must be one of the existing Foundry sidebar IDs to replace: chat', * 'combat', 'scenes', 'actors', 'items', 'journal', 'tables', 'cards', 'playlists', 'compendium', and 'settings'. * * Both the `add` and `replace` methods have a data field `mergeAppImpl` that provides the base implementation for the * added / replaced object instance assigned to `globalThis.ui.`. When replacing Foundry core sidebar * panels like the {@link CombatTracker} there is additional API that you must handle found in the given core * sidebar app implementation. It is recommended that you implement this API as part of the control / model code passed * to the Svelte sidebar component and also set to `mergeAppImpl`. * * ------------------------------------------------------------------------------------------------------------------- * * The {@link FVTTSidebarControl.get} method allows you to retrieve the associated {@link FVTTSidebarEntry} for a given * sidebar by ID allowing access to the configuration data, popout app, and wrapper components that mount the sidebar. * * The {@link FVTTSidebarControl.wait} returns a Promise that is resolved after all sidebars have been initialized. * allowing handling any special setup as necessary. * * ------------------------------------------------------------------------------------------------------------------- * * @example Minimal setup * * Hooks.once('setup', () => * { * FVTTSidebarControl.add({ * beforeId: 'items', // Place new tab before the 'items' tab. * id: 'test', // A unique CSS ID. * icon: 'fas fa-dice-d10', // FontAwesome icon. * condition: () => game.user.isGM, // Optional boolean / function to conditionally run the sidebar action. * title: 'Test Directory', // Title of popout sidebar app; can be language string. * tooltip: 'Tests', // Tooltip for sidebar tab. * svelte: { // A Svelte configuration object. * class: TestTab // A Svelte component. * } * }); * }); */ declare class FVTTSidebarControl { /** * Adds a new Svelte powered sidebar tab / panel. * * @param {FVTTSidebarAddData} sidebarData - The configuration object for a Svelte sidebar, */ static add(sidebarData: FVTTSidebarAddData): void; /** * Returns a loaded and configured sidebar entry by ID. * * @param {string} id - The ID of the sidebar to retrieve. * * @returns {FVTTSidebarEntry} The sidebar entry. */ static get(id: string): FVTTSidebarEntry; /** * Removes an existing sidebar tab / panel. * * @param {FVTTSidebarRemoveData} sidebarData - The configuration object to remove a Svelte sidebar. */ static remove(sidebarData: FVTTSidebarRemoveData): void; /** * Replaces an existing sidebar tab / panel with a new Svelte powered sidebar. * * @param {FVTTSidebarReplaceData} sidebarData - The configuration object to replace a core sidebar with a Svelte * sidebar. */ static replace(sidebarData: FVTTSidebarReplaceData): void; /** * Provides a Promise that is resolved after all added sidebars are initialized. This is useful when additional * setup or configuration of sidebars needs to be performed after sidebar initialization. * * @returns {Promise} Initialization Promise. */ static wait(): Promise; } /** * The configuration object to add a Svelte sidebar. */ type FVTTSidebarAddData = { /** * The unique Sidebar ID / name. Used for CSS ID and retrieving the sidebar. */ id: string; /** * The FontAwesome icon css classes * _or_ a Svelte configuration object to load a custom Svelte component to use as the "icon". */ icon: string | _runtime_svelte_util.TJSSvelte.Config.Embed; /** * A Svelte configuration object. */ svelte: _runtime_svelte_util.TJSSvelte.Config.Embed; /** * The ID for the tab to place the new sidebar before. This must be an * existing sidebar tab ID. THe stock Foundry sidebar tab IDs from left to right are: */ beforeId?: string; /** * A boolean value or function to invoke that returns a * boolean value to control sidebar replacement. This is executed in the `renderSidebar` callback * internally. */ condition?: boolean | (() => boolean); /** * Provides a custom base implementation for the object instance * for this sidebar app stored in `globalThis.ui.`. */ mergeAppImpl?: object; /** * Provides a custom * SvelteApp class to instantiate for the popout sidebar. */ popoutApplication?: _runtime_svelte_application.SvelteApp; /** * Provides SvelteApp options overrides for the default popout sidebar. */ popoutOptions?: object; /** * The popout application title text or i18n lang key. */ title?: string; /** * The sidebar tab tooltip text or i18n lang key. */ tooltip?: string; }; type FVTTSidebarRemoveData = { /** * The ID for the sidebar tab to remove. This must be an existing sidebar tab ID. */ id: string; /** * A boolean value or function to invoke that returns a boolean * value to control sidebar replacement. This is executed in the `renderSidebar` callback internally. */ condition?: boolean | (() => boolean); }; /** * The configuration object to replace a core sidebar with a Svelte sidebar. */ type FVTTSidebarReplaceData = { /** * The FontAwesome icon css classes _or_ * a Svelte configuration object to load a custom Svelte component to use as the "icon". */ icon: string | _runtime_svelte_util.TJSSvelte.Config.Embed; /** * The ID for the sidebar to replace. This must be an existing sidebar tab ID. */ id: string; /** * A Svelte configuration object. */ svelte: _runtime_svelte_util.TJSSvelte.Config.Embed; /** * A boolean value or function to invoke that returns a boolean * value to control sidebar replacement. This is executed in the `renderSidebar` callback internally. */ condition?: boolean | (() => boolean); /** * Provides a custom base implementation for the object instance for this sidebar * app stored in `globalThis.ui.`. */ mergeAppImpl?: object; /** * Provides a custom * SvelteApp class to instantiate for the popout sidebar. */ popoutApplication?: _runtime_svelte_application.SvelteApp; /** * Provides SvelteApp options overrides for the default popout sidebar. */ popoutOptions?: object; /** * The popout application title text or i18n lang key. */ title?: string; /** * The sidebar tab tooltip text or i18n lang key. */ tooltip?: string; }; type FVTTSidebarEntry = { /** * The sidebar data that * configures a Svelte sidebar. */ data: FVTTSidebarAddData | FVTTSidebarRemoveData | FVTTSidebarReplaceData; /** * The sidebar popout application. */ popout: _runtime_svelte_application.SvelteApp; /** * The tab wrapper component. */ tab: svelte.SvelteComponent; /** * The sidebar wrapper component. */ wrapper: svelte.SvelteComponent; }; export { type FVTTSidebarAddData, FVTTSidebarControl, type FVTTSidebarEntry, type FVTTSidebarRemoveData, type FVTTSidebarReplaceData, };