import type { TabSwitcherConfig, IDynamicTabSwitcherModel, TabContainerModelPersistOptions } from '@xh/hoist/cmp/tab/Types'; import { HoistModel, RefreshContextModel, RefreshMode, RenderMode } from '@xh/hoist/core'; import { ReactNode } from 'react'; import { TabConfig, TabModel } from './TabModel'; /** * Configuration for a {@link TabContainerModel} - the primary tabbed navigation container * in Hoist. Supports routing, lazy rendering/refresh strategies, and optional persistence * of the active tab. * * @see TabContainerModel * @see TabConfig */ export interface TabContainerConfig { /** Tabs to be displayed. */ tabs: TabConfig[]; /** * ID of Tab to be shown initially if routing does not specify otherwise. If not set, * will default to first tab in the provided collection. */ defaultTabId?: string; /** * Base route name for this container. If set, this container will be route-enabled, with the * route for each tab being "[route]/[tab.id]". */ route?: string; /** * Specification for type of switcher. Specify `dynamic` or config for user-configurable tabs. * Default `{mode: 'static'}` for simple, static switcher. */ switcher?: TabSwitcherConfig; /** * True to enable activity tracking of tab views (default false). Viewing of each tab will * be tracked with the `oncePerSession` flag, to avoid duplication. */ track?: boolean; /** * Strategy for rendering child tabs. Can be set per-tab via `TabModel.renderMode`. See enum * for description of supported modes. */ renderMode?: RenderMode; /** * Strategy for refreshing child tabs. Can be set per-tab via `TabModel.refreshMode`. * See enum for description of supported modes. */ refreshMode?: RefreshMode; /** * Options governing persistence. Tab containers can persist their last-active tab as well * as favorite tabs for the dynamic `switcher` option. Note that this must be left unset or * its nested `persistActiveTabId` option must be set to false if also using `route`, to avoid * a possible conflict between an initial route and persisted last active tab. */ persistWith?: TabContainerModelPersistOptions; /** * Placeholder to display if no tabs are provided or all tabs have been removed via * their `omit` config. */ emptyText?: ReactNode; /** @internal */ xhImpl?: boolean; } /** * Model for a TabContainer, representing its layout/contents and the currently displayed Tab. * * This object provides support for routing based navigation, customizable (lazy) mounting and * unmounting of inactive tabs, and customizable refreshing of tabs via a built-in RefreshContextModel. * * Note: Routing is currently enabled for desktop applications only. * * See the tab package README (`cmp/tab/README.md`) for render/refresh mode options, routing * configuration, and usage patterns. * * @mcpHint model for tabbed container with routing and refresh support */ export declare class TabContainerModel extends HoistModel { config: TabContainerConfig; tabs: TabModel[]; activeTabId: string; depth: number; route: string; defaultTabId: string; track: boolean; renderMode: RenderMode; refreshMode: RefreshMode; emptyText: ReactNode; switcherConfig: TabSwitcherConfig; refreshContextModel: RefreshContextModel; dynamicTabSwitcherModel: IDynamicTabSwitcherModel; protected lastActiveTabId: string; /** * @param config - TabContainer configuration. * @param depth - Depth in hierarchy of nested TabContainerModels. Not for application use. */ constructor({ tabs, defaultTabId, route, track, renderMode, refreshMode, persistWith, emptyText, xhImpl, switcher }: TabContainerConfig, depth?: number); /** Set/replace all tabs within the container. */ setTabs(tabs: Array): void; /** Add a single tab to the container. */ addTab(tab: TabModel | TabConfig, opts?: AddTabOptions): TabModel; /** * Remove a single tab from the container. * Supported for tabs that are immediate children of this container. */ removeTab(tab: TabModel | string): void; /** * Update the title of an existing tab. * Supported for tabs that are immediate children of this container. * Logs failures quietly on debug if not found. * */ setTabTitle(tabId: string, title: ReactNode): void; /** Find a tab that is an immediate child of this container. */ findTab(id: string): TabModel; get activeTab(): TabModel; /** The visitable tab immediately before the active tab in the model's tab list. */ get prevTab(): TabModel; /** The visitable tab immediately after the active tab in the model's tab list. */ get nextTab(): TabModel; /** * Set the currently active Tab by ID. * * This method may be bound directly to a UI control (e.g., a SegmentedControl). It handles * routing-aware navigation: if this container is route-enabled, the tab will only be updated * once the router state changes. Otherwise, the active Tab will be updated immediately. * * @param id - ID of TabModel to be activated. */ setActiveTabId(id: string): void; /** * Set the currently active Tab. Convenience for {@link setActiveTabId} that also accepts a * TabModel instance directly. * * @param tab - TabModel or id of TabModel to be activated. */ activateTab(tab: TabModel | string): void; /** * Navigate to the first enabled tab before the currently active tab, if any. * @param cycle - true to loop back to last tab if necessary. */ activatePrevTab(cycle?: boolean): void; /** * Navigate to the next enabled tab after the currently active tab, if any. * @param cycle - true to loop back to first tab if necessary. */ activateNextTab(cycle?: boolean): void; protected setActiveTabIdInternal(id: any): void; protected syncWithRouter(): void; protected forwardRouterToTab(id: any): void; protected calculateActiveTabId(tabs: any): any; private parseSwitcher; private initPersist; } export interface AddTabOptions { /** Index in tab collection where tab is to be added. */ index?: number; /** True to immediately activate new tab. */ activateImmediately?: boolean; }