import { ContentTabItem } from '../components/ContentTab'; import { SearchEntry } from '../helpers/searchIndex'; export interface SchemaFocusTarget { tokens: string[]; id: string; } export interface LayoutSection { id: TabKey | "servers"; /** Config `show` flag for this section: a hidden section reads back a null selection. */ visible: boolean; } export interface SpecLayoutControllerOptions { /** Content tabs currently visible (already filtered by config.show). */ tabs: ContentTabItem[]; /** Tab to fall back to when no tabs are visible or the stored tab gets hidden. */ defaultTab: TabKey; isTabKey: (value: string) => value is TabKey; /** * Selectable sections in nav priority order: the tab keys, then "servers". * Must keep a constant length across renders (it feeds a hook dependency list). */ sections: readonly LayoutSection[]; /** Current search input, used to tag highlights and clear them when it empties. */ searchQuery: string; } /** * Owns the tab/selection/search-focus state machine shared by the AsyncAPI and * OpenAPI layouts, which previously duplicated it verbatim. Each layout * supplies only its tab definitions, section visibility, and content * renderers; everything about "what is selected where, and what should scroll * into view" lives here. */ export declare function useSpecLayoutController({ tabs, defaultTab, isTabKey, sections, searchQuery, }: SpecLayoutControllerOptions): { effectiveTab: TabKey; focusTab: (tab: TabKey) => void; /** What the sidebar nav should show as active: the focused section, falling back to the content tab. */ navActiveSection: "servers" | TabKey; /** Per-section selections, clamped to visible sections. */ selected: Record<"servers" | TabKey, string | null>; setSelectedKey: (section: "servers" | TabKey, key: string | null) => void; selectedNavItem: { tab: "servers" | TabKey; key: NonNullable["servers" | TabKey]>; } | null; handleSearchSelect: (entry: SearchEntry) => void; handleNavItemSelect: (tab: TabKey, key: string) => void; handleNavServerSelect: (key: string) => void; handleContentTabChange: (id: string) => void; focusSection: string | null; schemaFocusTarget: SchemaFocusTarget | null; };