/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The links layer's drawing (`Plan links.html`, #1258), shared by Plan's * links and the Allocation's (#1321): each host lays its links out from its * own model (`routeRibbon`, `ribbonWeight`, `placeCaptions`) and hands them * here, in the coordinates of the box the layer fills. * * Every link is stroked at its weight in the muted ink over a paper CASING * one px either side, so it reads over anything it crosses; every link's * casing lies under every link's ink, and the lit link — the one under the * pointer — is drawn last, over the others, its two ends haloed 1px four * outside them. A caption sits on a paper knockout 12 tall, 4 either side of * its text, fitted once the text is drawn and again once the fonts come in. * A link's hit area is its stroke and 5 either side; the host names what a hit * on it is (`hit`). The clip keeps a halo or a casing inside the bounds the * routes keep to. An end past a window edge lands in a dashed slot. * * What a host may add, unused unless it opts in: a SELECTED link, its caption * outlined, carrying a × in its own 16px target whose pointer-down is stopped * (never a drag) and whose click unlinks (A68) — or several selected at once, * each outlined and none with a × (#1541, U10); a link DRAG's preview — the * moved link faded to its `was` line, and the new line to the pointer (A69); * a GRIP on a link's line and its caption, the host's component drawn in their * place to spread its drag handle on them (`grip`, A69); thin GUIDES from the * pointer into rows (`guides`, A30); captions that take the pointer as the line * does, lighting it (`caption`); a link's tone (`data-tone`: a draft's, a * drag's verdict) on its group, its casing and its caption alike, so a host * may draw a tone outlined; links that light nothing while a drag is under way * (`lights={false}`); and the lit link reported (`onLit`), for a host that * rings the ends itself (`halo={false}`), as the Allocation rings its bin card * and its resource's load bar (A67). The preview and the guides follow the * pointer wherever it is, so the bounds' clip does not cut them: the host's box * does, and they draw over the captions. And boxes the links stand back from * (`standBack`, #1680's review): the labels of the elements under them, each * with the room its element pads it with, as the host's model lays them out, * cut out of every link's casing and ink — so a run-out, a turn or a lane * passing a bar never hides its label. The captions are not cut. * * Its measures are the links' look's (`look.ts`), which the Schematic's * Canvas2D painter (`canvas.ts`, #1403) draws with too. * * The DOM's vocabulary is Plan's, where these parts began (`data-plan-link`, * `data-plan-ribbon-band`, `data-plan-casing`, …), so Plan's tests and its * responsive invariants read it unchanged; the theme's shared `linkRibbons` * part styles it in every host. * * @packageDocumentation */ import { type ComponentType, type KeyboardEvent, type PointerEvent, type ReactNode, type SVGProps } from "react"; import { type RibbonEdgeSlot, type RibbonEnd, type RibbonPath } from "./geometry.js"; /** One link the layer draws: its route, its ends and its caption. */ export interface LinkRibbon extends RibbonPath { /** Its identity in the layer. */ id: number; /** Its source's rect, as the route met it. */ from: RibbonEnd; /** Its destination's rect. */ to: RibbonEnd; /** Its caption — also its hit area's label; `undefined` for none. */ label: string | undefined; /** Its tone, which the host's recipe draws (`data-tone`): a draft's. */ tone?: string | undefined; } /** A line the layer draws beside the links: its path, and its head. */ export interface LinkLine { stroke: string; head: string; } /** A link drag's preview (A69). */ export interface LinkPreview { /** The link being moved, drawn as its faded `was` line; `undefined` for a new link. */ was: number | undefined; /** The new line, from its source to the pointer; `undefined` while it has nowhere to go. */ line: LinkLine | undefined; } /** What a grip spreads on the part it holds: its ref, the handlers that pick a drag up, its role and its marks. */ export interface LinkGripHandle { ref?: ((el: SVGElement | null) => void) | undefined; onPointerDown?: ((event: PointerEvent) => void) | undefined; onKeyDown?: ((event: KeyboardEvent) => void) | undefined; role?: string | undefined; tabIndex?: number | undefined; "aria-roledescription"?: string | undefined; "aria-describedby"?: string | undefined; "aria-disabled"?: boolean | undefined; "aria-pressed"?: boolean | undefined; [mark: `data-${string}`]: string | undefined; } /** What a host's grip is handed (A69): the link, the part it holds, and the part to draw with the grip's handle on it. */ export interface LinkGripProps { ribbon: LinkRibbon; /** Its line's hit area, or its caption. */ part: "line" | "caption"; /** Draws the part, the handle spread on it. */ render: (handle: LinkGripHandle) => ReactNode; } /** What the layer draws. */ export interface LinksLayerProps { /** The routed links, in drawing order. */ ribbons: readonly LinkRibbon[]; /** The slots ends past a window edge land in. */ edgeSlots?: readonly RibbonEdgeSlot[] | undefined; /** The layer's width and height, in its box's px. */ width: number | undefined; height: number; /** The bounds nothing of a link crosses: the clip. */ clip: { left: number; width: number; }; /** What the hit area of a link carries beyond its geometry: its attributes and its click. */ hit: (ribbon: LinkRibbon) => SVGProps; /** * The selected link (A68): its caption outlined, with a × that unlinks — or the selected links, several at once * (#1541, U10): each drawn selected, and none with a ×, which is one link's control. */ selected?: number | readonly number[] | undefined; /** Unlinks a link: the selected caption's ×. */ onUnlink?: ((id: number) => void) | undefined; /** The ×'s words for a link (`Unlink LD-2210 · Delete`). */ unlinkLabel?: ((ribbon: LinkRibbon) => string) | undefined; /** A link drag's preview (A69). */ preview?: LinkPreview | undefined; /** Thin lines from the pointer into rows, drawn as the preview is (A30). */ guides?: readonly LinkLine[] | undefined; /** What a caption carries when it takes the pointer as its line does: its attributes, its handlers and its tooltip. Omitted, captions only label. */ caption?: ((ribbon: LinkRibbon) => SVGProps & { title?: string | undefined; }) | undefined; /** * A host's grip on each link's line and on each caption that takes the pointer (A69): a component the layer draws in their * place, which spreads its drag handle on them. It keeps one identity — the layer remounts nothing for it — so a drag it * starts outlives the render that started it. */ grip?: ComponentType | undefined; /** Whether a link under the pointer lights (true by default); a host passes false while a drag is under way, and the lit link goes out. */ lights?: boolean | undefined; /** Hears which link is lit, as it changes; `null` for none. */ onLit?: ((id: number | null) => void) | undefined; /** Whether the layer rings a lit link's ends itself (true by default); a host that rings them passes false. */ halo?: boolean | undefined; /** * The boxes the links stand back from (#1680's review), in the layer's coordinates — the labels of the elements under * them, each with the room its element pads it with, as the host's model lays them out. Every link's casing and ink is * cut out of them; the captions are not. Omitted, nothing is cut. */ standBack?: readonly LinkBox[] | undefined; } /** A box in the layer's coordinates. */ export interface LinkBox { x: number; y: number; width: number; height: number; } /** * The links layer's SVG — inside the host's box, in its coordinates. * * @param props - The routed links and what the host adds * @returns The SVG, or nothing when there is nothing to draw */ export declare function LinksLayer({ ribbons, edgeSlots, width, height, clip, hit, selected, onUnlink, unlinkLabel, preview, guides, caption, grip: Grip, lights, onLit, halo, standBack, }: LinksLayerProps): ReactNode; //# sourceMappingURL=layer.d.ts.map