import { IFolder, INode } from '../../node/index.ts'; import { IView } from '../navigation/view.ts'; export interface ISidebarContext { /** * The active node in the sidebar */ node: INode; /** * The current open folder in the files app. * * Only set if the sidebar is rendered within the files app, * apps rendering the sidebar within their own app have no open folder. */ folder?: IFolder; /** * The currently active view. * * Only set if the sidebar is rendered within the files app, * apps rendering the sidebar within their own app have no active view. */ view?: IView; } /** * This component describes the custom web component that should be registered for a sidebar tab. * * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_components * @see https://vuejs.org/guide/extras/web-components#building-custom-elements-with-vue */ export interface SidebarTabComponent extends ISidebarContext { /** * The active state of the sidebar tab. * It will be set to true if this component is the currently active tab. */ active: boolean; } /** * The instance type of a sidebar tab web component. */ export type SidebarTabComponentInstance = SidebarTabComponent & HTMLElement; /** * Implementation of a custom sidebar tab within the files app. */ export interface ISidebarTab { /** * Unique id of the sidebar tab. * This has to conform to the HTML id attribute specification. */ id: string; /** * The localized name of the sidebar tab. */ displayName: string; /** * The icon, as SVG, of the sidebar tab. */ iconSvgInline: string; /** * The order of this tab. * Use a low number to make this tab ordered in front. */ order: number; /** * The tag name of the web component. * * The web component must be defined using this name with `CustomElementRegistry.define()`, * either on initialization or within the `onInit` callback (preferred). * When rendering the sidebar tab, the files app will wait for the component to be defined in the registry (`customElements.whenDefined()`). * * To avoid name clashes the name has to start with your appid (e.g. `your_app`). * So in addition with the web component naming rules a good name would be `your_app-files-sidebar-tab`. */ tagName: string; /** * Callback to check if the sidebar tab should be shown for the selected node. * * If not provided, the tab will always be shown. * * @param context - The current context of the files app */ enabled?: (context: ISidebarContext) => boolean; /** * Called when the sidebar tab is active and rendered the first time in the sidebar. * This should be used to register the web componen (`CustomElementRegistry.define()`). * * The sidebar itself will anyways wait for the component to be defined in the registry (`customElements.whenDefined()`). * But also will wait for the promise returned by this method to resolve before rendering the tab. */ onInit?: () => Promise; } /** * Register a new sidebar tab for the files app. * * @param tab - The sidebar tab to register * @throws {Error} If the provided tab is not a valid sidebar tab and thus cannot be registered. */ export declare function registerSidebarTab(tab: ISidebarTab): void; /** * Get all currently registered sidebar tabs. */ export declare function getSidebarTabs(): ISidebarTab[];