import { Model, TabNode, IJsonModel } from 'flexlayout-react'; import { ReactNode } from 'react'; /** * Config key under which a tab's reuse key is stored when it differs from its * component id. Stripped from the props the tab's component receives. */ export declare const REUSE_KEY_CONFIG = "_nexusReuseKey"; /** Options for {@link LayoutState.addTab}. */ export interface AddTabOptions { /** * Which existing tab counts as "the same tab". * * Defaults to the component id, so a tool opens once and is focused on * every later open — the behaviour almost every app wants from a dashboard, * a log or a settings page. Pass a string to key by something else (one tab * per document: `reuseKey: \`file:${path}\``), or `null` to always open a new * tab. */ reuseKey?: string | null; /** Select the tab. Defaults to `true`. */ focus?: boolean; /** * Where a *new* tab goes. `'active'` (the default) adds it to the active * tabset; `'right'` and `'bottom'` split the active tabset; `{ tabsetId }` * targets a specific tabset. Ignored when an existing tab is reused. */ location?: 'active' | 'right' | 'bottom' | { tabsetId: string; }; } /** * What to do with a persisted tab whose component is no longer registered. * * `'placeholder'` (the default) renders a notice in the tab; `'drop'` closes * such tabs when the shell mounts; a function renders whatever it returns. */ export type UnknownComponentPolicy = 'placeholder' | 'drop' | ((componentId: string) => ReactNode); /** * How persisted layouts evolve between releases of an app. * * Layouts are saved as JSON naming component ids. Rename a component, split * a tab in two or retire a view, and every user's saved layout still names * the old shape. Bump `version` and let `migrate` rewrite it — it runs on the * raw JSON, before FlexLayout parses it, for any layout saved under an older * version. Layouts saved before 0.3.0 count as version 0. * * For a plain rename, prefer `componentRegistry.alias(old, new)`. */ export interface LayoutOptions { /** The current layout schema version. Defaults to 0. */ version?: number; /** Rewrite a layout saved under `fromVersion` into the current shape. */ migrate?: (json: IJsonModel, fromVersion: number) => IJsonModel; /** See {@link UnknownComponentPolicy}. Defaults to `'placeholder'`. */ onUnknownComponent?: UnknownComponentPolicy; } interface LayoutState { model: Model; /** * Bumped on every change the shell knows about — the docking view's own * edits, and every `workspace` or `addTab` call. Subscribe to it to react to * layout changes. Raw `model.doAction` calls made by app code bypass it. */ revision: number; /** Whether the current model was restored from storage. */ restored: boolean; /** The layout `workspace.reset()` returns to. */ fallbackLayout: IJsonModel; /** Versioning and unknown-component policy; see {@link configureLayout}. */ options: LayoutOptions; dirtyTabs: Set; storageKey: string; disableLocalStorage: boolean; initLayout: (json: any, disableStorage?: boolean) => void; /** Record a change to the current model: bumps `revision` and persists. */ setModel: (model: Model) => void; /** Clear the persisted layout and return to the fallback layout. */ resetLayout: () => void; setStorageKey: (key: string, fallbackLayout?: IJsonModel) => void; /** * Open a tab, or focus it when one with the same reuse key is already open. * * When an existing tab is reused, a passed `title` renames it and a passed * `config` is merged into its config, so re-opening a tab is also how it is * pointed at something new. * * @returns The id of the opened or focused tab, or `null` when the layout * has nowhere to put one. */ addTab: (componentName: string, title?: string, config?: Record, options?: AddTabOptions) => string | null; setTabDirty: (tabId: string, dirty: boolean) => void; isTabDirty: (tabId: string) => boolean; } /** * The workspace an app gets when it supplies none: one empty tabset. * * Deliberately contains no tabs. A default tab would name a component the app * may never register, and render "Unknown Component" on every first run. Pass * `initialLayoutJson` to `ShellLayout` to choose what a first run shows. */ export declare const defaultLayout: IJsonModel; /** * A model from JSON, with empty borders hidden. * * The default layout has a left border for tabs to be docked into, and with * nothing docked it still drew a 30px blank strip down the edge of every app. * Auto-hide removes it while it is empty; a tab dragged to the edge docks as * before. Applied to stored layouts too, since those carry the border and * not the setting — an app that wants the strip says so with * `borderEnableAutoHide: false`. */ export declare const layoutFromJson: (json: IJsonModel) => Model; /** The reuse key a tab answers to. Aliased component ids resolve first. */ export declare const tabReuseKey: (tab: TabNode) => string | null; /** Every tab in the model, in visit order. */ export declare const allTabs: (model: Model) => TabNode[]; export declare const useLayoutStore: import('zustand').UseBoundStore>; /** * Configure layout versioning and the unknown-component policy, then reload * the persisted layout through them. * * Call before the shell renders — `initializeShell({ layout })` does. The * store reads storage when it is first imported, before any app code runs, * so configuring afterwards re-reads it with the migration applied. */ export declare const configureLayout: (options: LayoutOptions) => void; export {};