/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Schematic's canvas (#1387): the 2D world-coordinate drawing in its * frame's main — a Canvas2D paint layer and a DOM card layer under one camera, * the minimap and the scale bar at its foot, the minimap the whole drawing, * wherever the view is (`minimap.ts`, #1393). It holds no control of its own: * the frame's toolbar holds the tools, the zoom, Fit, Find and the steps, and * drives the camera through this canvas's handle ({@link SchematicCanvasHandle}); * the tool held and the link kind Connect draws are the frame's. What it draws * is its reader's (`data.ts`), each kind's rows as their roles give them, the * editing session's drafts in place (`drafted.ts`, #1388); what its layers * hide, lock and dim is the frame's (`layers.ts`). Every colour and font it * draws is the design system's, read through the theme bridge (`theme.tsx`). * Each card is a component of its own (`card.tsx`), told how it stands in * values, so a camera move — which renders the canvas a frame at a time — * renders no card whose standing holds (#1393). * Every gesture that writes — Move, Connect and its Shift session, Retarget, * Extend and Del — is one step of the editing's history: the gesture's edits * (`edits.ts`) recorded through the frame's editing, nothing held here but a * Move's preview while its drag is under way. The library's Index (#1389) * flies to a zone or an item and selects it through the handle, and hears * the canvas's selection and the zone its viewport is in. The inspector * (#1391) selects through it what Details and Issues name — a link or a net, * a net's leg among them — hears the selection with the leg a stub's tap * selected, and is opened on Details by Enter, or a double-click on an * entity. * * Where a tab of the library drops (#1390), the canvas is one drop cell of the * shared drag layer, on the frame's drop target (`use-drop.ts`): it works out * where a drag rests from its own drawing (`drop.ts`' `restsAt`) — the point * under the pointer, at the screen's resolution, for a card that adds or * places an item; the entity of the card's kind under it, never a locked * layer's, for one that lands on an entity — and, while the drop there lands, * marks it: a ring at the point, or the entity's drop mark. An item a drop * adds or places comes back through the handle's `select`, selected where it * stands; a card's ⏎ asks it for the view's centre. A Connect's new link or * net takes its other fields from the template of its kind the library has * selected (§4.3). * * Its links and nets draw in the shared links look (#1403): each ends on the * edges of the items it joins where they draw at the zoom — a card's side, as * the page lays the card out, a labelled pin's edge, a dot's rim — and the one * under the pointer lights, named in `data-lit-link`, while no gesture is under * way; a tap, a hover, a drop and a selected link's handles — named in * `data-link-handles` while they draw — meet each one's route as the painter * draws it, searched through the links' R-tree. * * Below 480px of main (#1394, D15) the canvas pans, pinches and selects: the * frame holds no Move or Connect and gives it no drop cell, and a selected * link draws no handle — the inspector moves, connects, re-targets, places and * deletes. The frame measures main by the canvas's element, which fills it. * * While a read is in flight (#1398) it washes the area the reads have not * drawn yet, under its grid, with no item's shape in it (CL2); a card whose * details are read keeps the places of the roles they give, a placeholder in * each, and a marker whose status is unread draws in the placeholders' fill — * each on its builder's reveal clock (CL4), which the painter hears with no * render; and a read that failed is said once, at the top-left in view of the * area it failed reading, with Retry (CL11). While what it draws stands in for * a new narrowing (CL8) it is kept — its grid's rules dashed, its words in the * third ink, its items' edges and marks as they were — and retained: * `aria-disabled`, panning and selecting, and taking no gesture that edits. * * Its gestures, its selection funnels, its camera and its paint path are the * ones `CLAUDE.md` holds to its invariants: no render-phase ref write, one * commit-phase snapshot, the paint's identity short-circuit, the fly before * the commit, and hit-testing that is the drawing. * * Each is a part of its own, holding the state it owns: the camera * (`use-camera.ts`), the gestures (`use-gestures.ts`), the selection * (`use-canvas-selection.ts`), the drop's cell (`use-canvas-drop.ts`), the * commit-phase snapshot and the painter's call (`use-paint.ts`) and the card * layer (`card-layer.tsx`). The snapshot reads every part's state, and every * part's behaviour reads the snapshot: this component makes each part's state * before the snapshot and its behaviour after it, over what the parts share — * the items a hidden layer leaves, their culling and their tiers, the links' * R-tree, the narrowing's look and a failed read's box. * * @packageDocumentation */ import { type KeyboardEvent, type Ref } from "react"; import { type option } from "@elaraai/east"; import { type Origin } from "@elaraai/east-ui-components"; import { type WorldBox } from "./model"; import { type SchematicDrawn } from "./drawn"; import type { SchematicLayerState } from "./layers"; import { type SchematicStanding } from "./use-canvas-selection"; import type { SchematicDensity, SchematicViewportStore } from "../area.js"; import { type SchematicValue } from "../data.js"; import { type SchematicCanvasDrop, type SchematicDropPoint } from "../drop.js"; import type { SchematicMove, SchematicNewKey } from "../editing.js"; import type { NetLeg, SchematicEdit, SchematicKeyRefusal } from "../edits.js"; import type { SchematicWords } from "../messages.js"; import type { SchematicNarrowedLook } from "../narrowing.js"; import type { SchematicTool } from "../tools.js"; import type { ZoomRange } from "../../shared/schedule/zoom.js"; /** What the rail's narrowing does on the canvas (#1392, §10.3), each entity by its id. */ export interface SchematicCanvasNarrowing { /** What draws as context: faded, drained of colour or a bare marker. */ readonly context: ReadonlySet; /** What never selects, by any path: the context, and a link or a net whose ends the narrowing hides. */ readonly out: ReadonlySet; /** The matches: what emphasis rings, the frame boxes and fit flies to. */ readonly matches: ReadonlySet; /** How context draws, and what the matches take. */ readonly look: SchematicNarrowedLook; } /** * How the canvas records its gestures (#1388): the Schematic's editing, which * writes each gesture's edits as one step of its history. */ export interface SchematicCanvasEditing { /** * Records one gesture's edits as one step. * * @param edits - The rows it changes, and how * @param origin - The gesture * @param label - Its label in the history * @returns The rows it moved under the keys their fields build (#1549) — none for a step that moves none; `undefined` * where nothing was recorded */ readonly record: (edits: readonly SchematicEdit[], origin: Origin, label: string) => readonly SchematicMove[] | undefined; /** * A new row's key, as its kind makes one from the edit making it (`editing.ts`' `newKey`, #1549). * * @param made - The edit making the row, under any key * @param minted - The keys the gesture has made already * @returns The key, or why there is none; `undefined` while it is still to be read */ readonly newKey: (made: SchematicEdit, minted?: ReadonlySet) => SchematicNewKey | undefined; /** * Says why a gesture records nothing, its new row's key refused (#1549), in the footer. * * @param refusal - Why */ readonly keyRefused: (refusal: SchematicKeyRefusal) => void; } /** What the frame drives the camera and the selection by: its toolbar's zoom, Fit, Find and steps, and the library's Index. */ export interface SchematicCanvasHandle { /** Zooms about the canvas's middle by a factor. */ zoomBy(factor: number): void; /** Fits the drawing in view. */ fit(): void; /** Steps the selection to the previous item, or the next, flying to it. */ step(delta: 1 | -1): void; /** * Flies to an entity, by its id, and selects it alone: Find's pick and the Index's (#1389) — an item or a zone — * and the inspector's (#1391), which also names a link or a net, and a net's leg with it. `undefined` selects * nothing, the camera where it is. `avoid` is a box on the page over the canvas — a conflicts popover open from * the toolbar — the flight lands beside, in the part of the view it leaves clear. */ reveal(id: string | undefined, leg?: NetLeg, avoid?: DOMRectReadOnly): void; /** * Selects an entity alone, by its id, once the drawing draws it — the item a drop added or placed (#1390), and what * Find's pick or Go to issue finds off the drawing, the choices that hid it cleared (#1404, #1391): an item, a zone, * or a link or a net, selected where it stands, the camera where it is. One the next drawing doesn't draw — its layer * hidden, the rail narrowing it out — selects nothing. */ select(id: string): void; /** The view's centre, at the screen's resolution: where a card's ⏎ adds or places an item (#1390); `undefined` while the canvas has no size. */ centre(): SchematicDropPoint | undefined; /** * Flies to a world point, framing the 8 × 6 units a fly to an item frames about it, and selects nothing: where Find's * pick lands on an item the canvas doesn't draw as itself — the rail's filters hide it, or its layer does (#1404). */ look(x: number, y: number): void; /** * Hears a key from inside the frame as it leaves it — the frame's own keys first (#1398): Space, Ctrl, Del and Esc, * the canvas's while the pointer is over it (invariant 16), each it acts on taken there, going no further. */ key(event: KeyboardEvent): void; } /** Props of {@link SchematicCanvas}. */ export interface SchematicCanvasProps { /** The payload, decoded. */ readonly value: SchematicValue; /** What the canvas draws: its reader's stored rows, the editing session's drafts in place (#1388). */ readonly data: SchematicDrawn; /** What the layers hide, lock and dim. */ readonly layers: SchematicLayerState; /** What the rail's narrowing does (#1392): what draws as context, what never selects, and the matches. */ readonly narrowing: SchematicCanvasNarrowing; /** The items holding a conflict not yet chosen, by key: each wears the conflicts' warn ring. None by default. */ readonly conflicted?: ReadonlySet | undefined; /** The items whose rows break their fields' bounds (#1585), stored or changed, by key: each wears the same warn ring. None by default. */ readonly bounded?: ReadonlySet | undefined; /** The tool held. */ readonly tool: SchematicTool; /** The link kind Connect draws; `undefined` where no link kind is editable. */ readonly linkKind: string | undefined; /** The Schematic's words. */ readonly words: SchematicWords; /** How the canvas records its gestures; `undefined` where no record is edited. */ readonly editing: SchematicCanvasEditing | undefined; /** Told why a gesture was refused — a Delete a read-only link or net blocks — or, `undefined`, that one has been recorded since. */ readonly onRefused: (words: string | undefined) => void; /** * Told as the viewer acts on the canvas: a press on it, or a move of its camera — a pan, the wheel, a pinch, a zoom, * Fit, the minimap, a fly. A resize is no action: the camera it moves tells nothing. The frame hears it while the footer * says why a gesture was refused, the words going at the viewer's next action (hand retest, 27 Oct 2026). */ readonly onAction?: (() => void) | undefined; /** * Told what is selected — the items, the zones, and the link or the net — by their ids, and the net's leg when a * stub is selected (#1391), as that changes. */ readonly onSelection: (ids: ReadonlySet, leg: NetLeg | null) => void; /** Told when Enter, or a double-click on an entity, opens the selection in the inspector's Details (#1391, D34); `undefined` with no inspector. */ readonly onOpen?: (() => void) | undefined; /** Told the zone the viewport is in, by its id — `undefined` for none — as that changes (#1389): the Index marks it. */ readonly onZoneInView?: ((zone: string | undefined) => void) | undefined; /** The canvas's drop cell, where a tab of the library drops (#1390); `undefined`, it takes no drop. */ readonly drop?: SchematicCanvasDrop | undefined; /** * What a Connect's new link or net takes its other fields from, by its kind's slot (§4.3, #1390): the values of the * template of that kind the library has selected; `none`, their types' defaults. */ readonly connectValues: (slot: string) => option; /** * Where the canvas writes its viewport as its camera comes to rest (#1393): what a kind read by area reads its window * around; `undefined`, it writes nowhere. */ readonly viewport?: SchematicViewportStore | undefined; /** Each kind read by area drawing its density in place of its items (D25), by its slot: the raster painted under them. */ readonly density?: ReadonlyMap | undefined; /** Each kind read by area's whole drawing's density, by its slot: what the minimap draws of it, wherever the view is (#1393). */ readonly overview?: ReadonlyMap | undefined; /** Whether a read the drawing needs is in flight: an item a drop or a pick asks to select is waited for until it lands. */ readonly reading?: boolean | undefined; /** * What is selected that the drawing doesn't draw and still stands (#1393): each row of a kind read by area its window * doesn't hold, read by its key — kept selected, never heard of as a camera moves, and deleted by Del with the rest. */ readonly standing?: SchematicStanding | undefined; /** What `fit` flies the camera to as the narrowing changes (§10.3): keyed on the narrowing itself, a kind read by area by its box. */ readonly fit?: SchematicCanvasFit | undefined; /** What the reads in flight have not drawn yet, in world units, as disjoint boxes (#1398, CL2): washed, under the grid, until they land. */ readonly unread?: readonly WorldBox[] | undefined; /** A read that failed, said once where it happened (CL11), with Retry; `undefined` while none has. */ readonly failure?: SchematicCanvasFailure | undefined; /** * Whether what it draws stands in for a new narrowing while that is read (#1398, the loading design's retained card): * kept — its grid's rules dashed and its words, a card's, a pin's and a caption's, in the third ink — its items' edges * and marks as they were. */ readonly stale?: boolean | undefined; /** * Whether what it draws is retained (#1398, CL8): readable, focusable and selectable — a press pans and a tap selects * — and taking no gesture that edits: no Move, Connect, re-target or Del, a selected link's handles gone, and no drop * on its cell. It is `aria-disabled` but while a read's failure is said on it, its Retry in it. */ readonly retained?: boolean | undefined; /** Told whether the zoom stands at Fit and at its limit, as either changes (#1393): the toolbar's Zoom out and Zoom in take no press there. */ readonly onZoomRange?: ((range: ZoomRange) => void) | undefined; /** * Whether main is below 480px (#1394, D15): the canvas pans, pinches and selects, and a selected link draws no handle * and takes no re-target's drag — the inspector's ends re-target it. The frame offers no Move or Connect there, and * gives the canvas no drop cell. */ readonly narrow?: boolean | undefined; /** Hears the canvas's element as it mounts, and `null` as it goes (#1394): the canvas fills main, whose width the frame measures by it. */ readonly onElement?: ((element: HTMLDivElement | null) => void) | undefined; /** The canvas's handle, the frame's. */ readonly ref?: Ref | undefined; } /** * A read that failed, as the canvas says it once where it happened (#1398, CL11): in the message box, at the top-left in * view of the area it failed reading, with Retry. */ export interface SchematicCanvasFailure { /** Its words: `Couldn't read this area`, or the kind's or the drawing's, `Couldn't read racks`. */ readonly message: string; /** Asks it again. */ readonly retry: () => void; /** The area it failed reading, in world units; `undefined` for a kind read whole, or the drawing's read — said at the canvas's top-left. */ readonly area: readonly WorldBox[] | undefined; } /** * What `fit` flies the camera to (§10.3, #1393): the narrowing it is keyed on — each source's choices, printed — and * whether what it flies to is read, and the box each kind read by area's narrowing's rows stand in, as its area index * answers it: never what its window draws. */ export interface SchematicCanvasFit { /** The narrowing the fly is keyed on; `undefined` while nothing narrows, or the Schematic takes no `fit`. */ readonly key: string | undefined; /** Whether what it flies to is read: the drawing, a source's matches, a kind read by area's box. */ readonly reading: boolean; /** The box the kinds read by area's narrowing's rows stand in, in world units; `undefined` for none. */ readonly box: WorldBox | undefined; } /** * The Schematic's canvas (see the module docs): map-grade navigation — wheel * zoom about the cursor, drag pan, animated fly-to, semantic zoom (status dots * ⇢ labelled dots ⇢ full cards), rbush viewport culling, an adaptive scale bar * and a minimap with a draggable viewport — and its gestures, each one step of * the editing's history. */ export declare const SchematicCanvas: import("react").MemoExoticComponent<({ value, data, layers, narrowing, conflicted, bounded, tool, linkKind, words, editing, onRefused, onAction, onSelection, onOpen, onZoneInView, drop, connectValues, viewport, density, overview, reading, standing, fit, unread, failure, stale, retained, onZoomRange, narrow, onElement, ref, }: SchematicCanvasProps) => import("react/jsx-runtime").JSX.Element>; //# sourceMappingURL=view.d.ts.map