/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Flowchart's canvas (#1502, #1503, `Flowchart Records Spec.md` R6–R10, * R13, D4, D12) — the records drawn, with the canvas's options, in its frame's * main: lane bands, state cards, H/V-routed transitions, decision diamonds, * evidence badges, the legend and the minimap, with the dim ladder, the * selection, ⌥-click tracing and, where a kind edits, its gestures. The * dimensional contract (node 116×40 r6, 7px handle rings, fixed 6.5px * arrowheads butting the rings, dim ladder 1.0 / 0.45 / 0.15) lives in * `layout.ts` and the `flowchart` slot recipe, which stays in * east-ui-components' theme. Colours resolve through the recipe's `--fc-*` * variables (theme-aware, dark-mode overrides), which the Flowchart's root * sets. It draws no hover card: the inspector shows what is selected. * * - **The bands** are the model's: each lane of the app's, in its order; *No * lane*, last, holding the states naming no lane the Flowchart holds (D12); * or, given no lanes, one band holding every state. Only a lane of the * app's takes a gesture of its own — a click on its header selects it, a * double-click renames it, its × deletes it, its "+ STATE" adds a state to * it — and the one band of a Flowchart given no lanes takes "+ STATE". *No * lane* takes none: a state there is moved out of it. * - **A row the narrowing leaves out**, under `"dim"`, draws faded at the dim * ladder's last step, marked `data-context`: no click, hover, drag or key * reaches it, and no card lands on it (R6). * - **The selection** is the frame's (`selection.ts`): the canvas marks it and * tells the frame each click — a state's card, a transition, a decision's * diamond, or a lane's header; a shift-, ⌘- or Ctrl-click on a state puts it * into a selection of several, or takes it out; a click on the canvas where * nothing is, and Esc, select nothing. Esc is the canvas's from inside its * frame — heard as it leaves the frame (the handle's `key`), never in a * field being typed into nor from a layer portaled out of the frame — and * from the page itself, nothing focused, while the pointer is over the * canvas, at the window (`../shared/frame-keys.ts`). Every key the canvas * acts on goes no further than the Flowchart (`takeKey`, #1398). * - **The gestures** are the frame's `edit`, one member per gesture, each * there while its kind edits (R13); each is one step of the history: "+ * LANE" at the band row's tail; a lane's header double-clicked into its * rename in place, and its × — off while the lane holds states, its tooltip * saying why; the "+ STATE" ghost a hovered band parks under its last state, * which opens the inline editor — its key and its label, a key the Flowchart * holds already refused as it is typed, or its label alone where the states' * kind makes their keys (#1549); a state double-clicked into its * rename, its key shown fixed (R9); a state dragged to another lane, or — * where the states carry an `order` — between two cards, a line marking * where it lands (D4); a handle dragged to a state, which `canConnect` may * veto, a drop on the source its in-place transition, a drop that would * repeat a transition pulsing it instead; and Del — in the canvas, never in * a field being typed into — deleting the selected state or states with * their transitions, the transition, the decision, or the lane while it * holds no state. A drag is its pointer's (east-ui-components' * `followPointer`): no other pointer's moves carry it, and another finger's * lift neither ends it nor lands it. One the browser takes the pointer back * from, or the window loses the page under, lands nothing; one is in flight * at a time, a new press letting go of one still held. And the canvas * selects no text (the recipe's), so a card's drag never turns into the * browser's own drag of its words, however often it is carried. * - **Drops**: where a tab of the library drops, 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`' * `dropAtPoint`) — a band and the row a state takes there, a state, a * transition, a lane's header, the gap a lane lands in, a decision's diamond * — and, while the drop there lands, marks it: the band takes a wash and a * line marks where the state lands; a line marks the gap a lane lands in; * the state, the transition — the brand wash — or the diamond takes the * brand. The marks show only while the drag rests over the canvas and the * drop lands (the recipe's); a drag over the canvas raises no dimming and no * "+ STATE" ghost. * - **The details** (#1510, R22–R34, R39): where the app puts a state's reads * on the canvas, its card is 272 wide — its head, a rule, then the reads in * their order (`details-card.tsx`), its tag lists' words measured out of * sight as a card draws them, before the layout places it; a transition's * label draws its lines under its evidence, a placeholder bar each while its * row lands; and the legend adds a row for each figure, histogram and list * the cards and labels draw, and beside them, one over another, a group for * each tag list it lists (`details-draw.ts`), the layout keeping its height * under the drawing. * * A read that failed is said once on the canvas (R5): the shared failure box * (`LoadingFailedBox`) at its box's top-left, in view however the drawing * scrolls — its words and its Retry the footer's loading line's — over what the * canvas drew, which stays as it was read; and over nothing, where nothing was. * * The canvas fills main and scrolls both ways inside it: its lanes run the * whole of main's height, and a Flowchart larger than main scrolls in its own * box, the frame's toolbar and footer staying put — and the minimap with * them, in main's corner over the canvas. Its toolbar's items and its footer * are the frame's (`toolbar.tsx`, `footer.tsx`): the model and the * orientation come from the frame, and what the frame selects — Find's pick, a * drop, an issue's row — comes as a `reveal`, which selects it and scrolls it * into view. * * **The zoom** (#1519, R42): the canvas opens at the cards' own size, and the * frame zooms it through its handle (`zoomBy`, `fit`) — about the view's * middle, held as a share of the drawing's width and height — between Fit and * that size, hearing where it stands (`onZoomRange`). Fit is the whole * flowchart in view, taken from the layout's own size (`layoutExtent`), the * size it draws at with no room to fill; a zoom Fit or Zoom out puts there * follows Fit as the flowchart and main change, and a zoom below a new Fit * comes up to it. The layout is computed for main's size over the zoom, so the * lanes fill main at any zoom, and the drawing is scaled from its corner * inside a box of the size it is drawn at, which main scrolls. The pointer, * the drops and a reveal's scroll read the canvas through the zoom; the * minimap, the lane pager and a failed read's box keep their size. A phone's * window holds as many whole lanes as the zoom fits, each lane keeping its * width. The zoom is the viewer's while the canvas is drawn, never * remembered, as its scroll is not. * * @packageDocumentation */ import { type Ref } from "react"; import type { FlowchartWords } from "./messages.js"; import type { FlowchartCanvasValue, FlowchartModel } from "./model.js"; import { type FlowchartDetailsModel } from "./details.js"; import { type FlowchartCanvasDrop } from "./drop.js"; import { type FlowchartSelection } from "./selection.js"; import type { FlowchartOrientation } from "./toolbar.js"; import type { ZoomRange } from "../shared/schedule/zoom.js"; /** * What the frame asks the canvas to select and bring into view: a state Find * picked or a drop added, or what a click in the inspector names — a * transition in a state's Details, an issue's row — once per ask. */ export interface FlowchartReveal { /** What to select. */ readonly selection: FlowchartSelection; /** The ask's number: each a new one, so a second ask of one thing reveals it again. */ readonly seq: number; /** `false`: selected where it stands, never scrolled — a state dropped where the pointer is, a key edited in the inspector. */ readonly scroll?: boolean | undefined; } /** A read that failed, as the canvas says it (R5): the footer's loading line's words, and its Retry. */ export interface FlowchartCanvasFailure { /** Its words: `Couldn't read states`. */ readonly message: string; /** Asks again. */ readonly retry: () => void; } /** * The canvas's gestures, each one step of the history, made by the frame — * each there while the kind it writes edits (R13), and left out otherwise. The * canvas hands each what it gathered — keys, labels, bands — and the frame * records what it changes. */ export interface FlowchartCanvasEdit { /** "+ LANE": a lane at the band row's tail. */ readonly addLane?: (() => void) | undefined; /** A lane's header renamed. */ readonly renameLane?: ((key: string, label: string) => void) | undefined; /** A lane's ×: deleted, while it holds no state. */ readonly deleteLane?: ((key: string) => void) | undefined; /** * The "+ STATE" ghost's editor committed: a state at the end of its band, its key and its label as typed — its key * `undefined` where the editor types none, the kind making it (#1549); whether it was recorded. */ readonly addState?: ((band: string, key: string | undefined, label: string) => boolean) | undefined; /** * Whether the Flowchart holds a state of a key already: the "+ STATE" editor refuses it as it is typed. The editor * types a key only with it: without, the states' kind makes each one's (#1549). */ readonly stateKeyTaken?: ((key: string) => boolean) | undefined; /** * Why "+ STATE" or "+ LANE" adds nothing (#1549): its kind's keys are of a type the form can't type, and it builds * none — the control off, its tooltip saying why. */ readonly off?: { readonly states?: string | undefined; readonly lanes?: string | undefined; } | undefined; /** A state's editor committed: its label. */ readonly renameState?: ((key: string, label: string) => void) | undefined; /** States dragged to a band — and, where the states carry an `order`, to a place among its other states. */ readonly moveStates?: ((keys: readonly string[], band: string, at?: number) => void) | undefined; /** Del on the selected state or states: each deleted with its transitions. */ readonly deleteStates?: ((keys: readonly string[]) => void) | undefined; /** A handle dragged to a state; the state itself for an in-place transition. */ readonly connect?: ((from: string, to: string) => void) | undefined; /** Del on a selected transition. */ readonly deleteLink?: ((key: string) => void) | undefined; /** Del on a selected decision: cleared from the transitions it governs. */ readonly deleteDecision?: ((key: string) => void) | undefined; } /** What the frame hears the canvas's keys through (#1398), and zooms it through (R42). */ export interface FlowchartCanvasHandle { /** * Hears a key from inside the frame as it leaves it — after every part of it that takes keys of its own: Esc, the * canvas's, taken there where it acts, going no further. */ key(event: React.KeyboardEvent): void; /** * Zooms by a factor, never past Fit nor the cards' own size, bringing what is selected to the view's middle, and * about the view's middle when nothing is: Zoom out and Zoom in (R42). */ zoomBy(factor: number): void; /** Puts the whole flowchart in view, and keeps it there as the flowchart and main change: Fit (R42). */ fit(): void; } /** Props of {@link FlowchartCanvasView}. */ export interface FlowchartCanvasViewProps { /** What the canvas draws the records with. */ readonly canvas: FlowchartCanvasValue; /** The keys of the states holding a conflict not yet chosen: their nodes wear the warn ring. None by default. */ readonly conflicted?: ReadonlySet | undefined; /** * The keys of the states whose rows hold a number outside its field's bounds, stored or changed (#1585): their nodes * wear the warn ring too. None by default. */ readonly bounded?: ReadonlySet | undefined; /** The view model: the records, the drafts in place. */ readonly model: FlowchartModel; /** The details model: each card's size where the details draw on the cards, and each label's lines (R22, R32). */ readonly details: FlowchartDetailsModel; /** Left to right, or top down. */ readonly orientation: FlowchartOrientation; /** What the frame asked the canvas to select and bring into view last, or `null`. */ readonly reveal: FlowchartReveal | null; /** The gestures, where a kind edits; `undefined`, no kind edits, and the selection and the dim ladder stay. */ readonly edit: FlowchartCanvasEdit | undefined; /** The canvas's drop cell, where a tab of the library drops; `undefined`, it takes no drop. */ readonly drop?: FlowchartCanvasDrop | undefined; /** What is selected: the frame's, as the canvas draws the records. */ readonly selection: FlowchartSelection | null; /** Selects something, or nothing — a click, a shift-click, Esc, a click where nothing is: the frame's selection moves. */ readonly onSelect: (selection: FlowchartSelection | null) => void; /** The Flowchart's words: the gestures' names, and its counts in the app's locale. */ readonly words: FlowchartWords; /** The structural storage key. */ readonly storageKey: string; /** Hands the frame the canvas's element, which fills main: what the frame measures main's width by. */ readonly onElement?: ((element: HTMLDivElement | null) => void) | undefined; /** A read that failed, said once at the canvas's top-left with Retry; `undefined` while none has. */ readonly failure?: FlowchartCanvasFailure | undefined; /** The canvas's handle, the frame's: what a key from inside the frame reaches the canvas through, and what zooms it. */ readonly ref?: Ref | undefined; /** Told whether the zoom stands at Fit and at the cards' own size, as either changes (R42): the toolbar's Zoom out and Zoom in are off there. */ readonly onZoomRange?: ((range: ZoomRange) => void) | undefined; } /** * The canvas: the records, drawn with the canvas's options, filling its * frame's main — see the module docs. * * @param props - The canvas's options, the view model, the orientation, what to reveal, the gestures, the drop cell, the selection and what selects, the words, the storage key, the frame's handle and what hears the zoom * @returns The canvas's box, which scrolls the records inside it */ export declare function FlowchartCanvasView({ canvas, model, details, orientation, reveal, edit, drop, selection, onSelect, words, storageKey, onElement, failure, ref, conflicted, bounded, onZoomRange, }: FlowchartCanvasViewProps): import("react/jsx-runtime").JSX.Element; //# sourceMappingURL=canvas.d.ts.map