/** * Dagre-based auto-layout for React Flow nodes. * * Reference: `docs/plans/20260501-universal-wysiwyg-schema-ux-v1.00W.md` §3.6 * item 3. Pinned config: `rankdir: 'LR'` (left-to-right), `ranker: * 'network-simplex'` (dagre default, minimises edge crossings), `nodesep: 60` * (vertical gap between sibling nodes in the same rank), `ranksep: 80` * (horizontal gap between successive ranks — tuned for our default entity-card * width of ~260 px so labels never overlap). * * Pure function with zero React deps so it is trivially unit-testable. */ import type { Edge, Node } from '@xyflow/react'; export interface AutoLayoutOptions { /** Direction of the layout. Defaults to 'LR' (left-to-right). */ rankdir?: 'LR' | 'TB' | 'RL' | 'BT'; /** Vertical gap between sibling nodes in the same rank. Default 60. */ nodesep?: number; /** Horizontal gap between successive ranks. Default 80. */ ranksep?: number; /** Fallback node width when React Flow hasn't measured the node yet. */ nodeWidth?: number; /** Fallback node height when React Flow hasn't measured the node yet. */ nodeHeight?: number; } /** * Run dagre against the given React Flow `nodes`/`edges` and return a new * `nodes` array with each node's `position` updated to the layout result. * * Dagre returns node coordinates as centres; React Flow wants the top-left * corner, so we subtract half-width/half-height to convert. * * Unrelated node properties (`id`, `type`, `data`, `width`, `height`, etc.) are * preserved. Nodes whose size is already known via `node.width` / `node.height` * use those dimensions for better layout quality; otherwise the fallback * `nodeWidth`/`nodeHeight` options are used. * * @returns a new array of nodes with updated `position` fields. Empty input * returns the input array as-is (short-circuit for performance + no-op * semantics). */ export declare function computeDagreLayout = Record>(nodes: Node[], edges: Edge[], options?: AutoLayoutOptions): Node[]; //# sourceMappingURL=autoLayout.d.ts.map