/** * dock-model - the pure, immutable tree behind . A docking layout * is a tree of two node kinds: * * group a row/column of children (nested groups or tab-leaves), each holding * a normalized `size` weight, with resizable splitters between them. * tabs a leaf: one or more panes shown as tabs (only `active` is visible). * * Every restructuring a user does by dragging - dock a pane to a neighbour's * edge (split) or centre (add as a tab), close a pane, drag a splitter - is a * pure transform here that returns a NEW tree. The Svelte view owns the DOM and * the drag gestures; all the tree surgery lives here so it is unit-testable * without a browser. Modelled on Smart's `smart-layout` group/item structure. */ export type DockPane = { id: string; title: string; /** Show a close (x) affordance on the tab. Default true. */ closable?: boolean; /** Minimum size (px) for this pane's leaf along the split axis. */ minSize?: number; }; /** A leaf: a stack of panes rendered as tabs (`active` is the visible one). */ export type DockTabs = { type: 'tabs'; id: string; panes: DockPane[]; active: number; }; /** A row (side-by-side) or column (stacked) of children with per-child sizes. */ export type DockGroup = { type: 'group'; id: string; direction: 'row' | 'column'; children: DockNode[]; /** Size weight per child; parallel to `children`, normalized to sum ~1. */ sizes: number[]; }; export type DockNode = DockGroup | DockTabs; /** Where a dragged pane lands relative to a target leaf. */ export type DockZone = 'left' | 'right' | 'top' | 'bottom' | 'center'; export type IdGen = () => string; export declare function pane(id: string, title: string, closable?: boolean): DockPane; /** Largest per-pane `minSize` in a leaf (0 if none). Used by splitter clamping. */ export declare function leafMinSize(node: DockTabs): number; export declare function tabs(genId: IdGen, panes: DockPane[], active?: number): DockTabs; export declare function group(genId: IdGen, direction: 'row' | 'column', children: DockNode[], sizes?: number[]): DockGroup; /** Return sizes summing to 1, padded/trimmed to `count`. Even split when absent. */ export declare function normalizeSizes(sizes: number[] | undefined, count: number): number[]; /** The tabs leaf that holds `paneId`, or null. */ export declare function findTabsWithPane(root: DockNode, paneId: string): DockTabs | null; /** Every pane id in the tree, in document order. */ export declare function allPaneIds(root: DockNode): string[]; /** * Collapse the tree after edits: drop empty tabs and empty groups, unwrap a * group that has a single child, and flatten a child group into its parent when * they share a direction (so repeated docking never nests infinitely deep). * Returns the tidied node, or null when nothing is left. */ export declare function normalize(node: DockNode): DockNode | null; /** Set the active tab index of a tabs leaf. */ export declare function setActive(root: DockNode, tabsId: string, active: number): DockNode; /** Replace a group's size weights (e.g. after a splitter drag). */ export declare function setSizes(root: DockNode, groupId: string, sizes: number[]): DockNode; /** * Reorder a pane WITHIN its tabs leaf (dragging a tab along the strip). `active` * follows the pane that was showing. No-op if the indices are out of range. */ export declare function reorderPane(root: DockNode, tabsId: string, from: number, to: number): DockNode; /** * Remove a pane. Returns the tidied tree (or null if it emptied) plus the pane * that was pulled out, so a caller can re-dock it elsewhere. */ export declare function removePane(root: DockNode, paneId: string): { root: DockNode | null; pane: DockPane | null; }; /** * Dock `movingPane` relative to the leaf `targetTabsId`. `center` adds it as a * tab; an edge splits: the target is wrapped in (or extended into) a group whose * direction matches the edge, with the new pane on the requested side. */ export declare function dockInto(root: DockNode, targetTabsId: string, movingPane: DockPane, zone: DockZone, genId: IdGen): DockNode; /** Pull a whole tabs leaf out of the tree (for auto-hide). Returns the tidied * tree (or null) plus the extracted leaf. */ export declare function removeLeaf(root: DockNode, tabsId: string): { root: DockNode | null; leaf: DockTabs | null; }; /** Dock a whole leaf against an EDGE of the entire tree (for pinning an * auto-hidden panel back in). Wraps the root in a new group as needed; the * pinned leaf takes `fraction` of that axis (clamped 0.1..0.6), the rest keeps * the existing content. */ export declare function dockLeafToEdge(root: DockNode | null, leaf: DockTabs, side: Exclude, genId: IdGen, fraction?: number): DockNode; /** Move an existing pane to a new dock position (remove then dock). */ export declare function movePane(root: DockNode, paneId: string, targetTabsId: string, zone: DockZone, genId: IdGen): DockNode; /** A pane (tab). Alias of `pane`, named for the public builder set. */ export declare function dockPane(id: string, title: string, opts?: boolean | { closable?: boolean; minSize?: number; }): DockPane; /** A tab-leaf holding one or more panes. */ export declare function dockTabs(panes: DockPane[], active?: number): DockTabs; /** A row (side-by-side) or column (stacked) of children. */ export declare function dockGroup(direction: 'row' | 'column', children: DockNode[], sizes?: number[]): DockGroup;