/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { CarrySteps, MoveMode, Span } from "../../shared/time/drag.js"; import { type PlanInstantValue } from "../instant.js"; import type { PlanRowValue } from "../model.js"; import type { RowKey } from "../plan-state.js"; import type { PlanRowMove } from "../rows/SpanRow.js"; import type { PlanScale } from "../scale.js"; import type { PlanWords } from "../words.js"; import type { PlanTyping } from "./typing.js"; /** An element's extent: a run's or a chip's two ends; a tile's or a mark's instant, twice. Moved by the time parts' arithmetic (`shared/time/drag.ts`, #1148). */ export type PlanSpan = Span; /** What a gesture moves: the whole element, or one of its ends. */ export type PlanMoveMode = MoveMode; /** What an element is, for its look in the ghost. */ export type PlanMovableKind = "run" | "chip" | "tile" | "mark"; /** An element that moves — what the canvas knows of it when it is picked up. */ export interface PlanMovable { /** Its row's key. */ readonly rowKey: RowKey; /** Its key — its item's id in the collection its series reads (#1436). */ readonly key: string; /** Its name, for the ghost and the announcements. */ readonly label: string; /** What it is. */ readonly kind: PlanMovableKind; /** Its extent — a point element's instant twice. */ readonly span: PlanSpan; /** Its row's item type, as the IR prints it — the rows it may move to share it. */ readonly items: string; /** Whether it has two ends to resize. */ readonly resize: boolean; /** The lane its tile sits in (#1541, U1), where its row has lanes and it is in one. */ readonly lane?: string | undefined; } /** A pointer drag of an element, from its press. */ export interface PlanGrab { /** The element. */ readonly movable: PlanMovable; /** What the drag moves — the element, or one end. */ readonly mode: PlanMoveMode; /** Where it was pressed, as a window fraction. */ readonly grabFrac: number; /** The element's node, as it was pressed: where Connect's draft line starts (#1541, U10). */ readonly node?: Element | undefined; } /** Connect's draft in flight (#1541, U10): where the line from the pressed element ends now. */ export interface PlanConnectDraft { /** The pointer, in client px. */ readonly x: number; readonly y: number; /** The element of the event the link may end at, under the pointer: the line snaps to it. `undefined` over none, and over one the link is refused at. */ readonly onto: Element | undefined; } /** Where a gesture would land now — the row, and the extent there. */ export interface PlanProposal { readonly rowKey: RowKey; readonly span: PlanSpan; /** * The units it moved by since it was picked up — the buckets the pointer * crossed, or the keyboard's steps — in Shift's finer unit when `fine` * (#1196): what an event kind's element moves its event's own times by, * and the other events selected with it. */ readonly units?: number | undefined; /** Whether `units` are Shift's finer ones. */ readonly fine?: boolean | undefined; /** A keyboard carry's steps since it was picked up — the whole element's and each end's — its extent counted from them. */ readonly steps?: CarrySteps | undefined; /** * The lane of the row it would sit in (#1541, U1): the one a pointer is over, where the row has lanes. A keyboard * carry names none, and the element keeps its own. */ readonly lane?: string | undefined; } /** A keyboard carry — the element, and where it would land now. */ export interface PlanCarry { readonly movable: PlanMovable; readonly to: PlanProposal; /** Whether the canvas's `canDrop` refuses it there. */ readonly refused: boolean; } /** Words for the live region, numbered so the same words said twice are said again. */ export interface PlanSaid { readonly text: string; readonly seq: number; } /** * Whether two lanes a gesture names are one, as East compares them: none and none, or the same lane. * * @param a - A lane, or none * @param b - Another, or none * @returns Whether they are one */ export declare function sameLane(a: string | undefined, b: string | undefined): boolean; /** * The canvas's moves in flight — see the module docs. */ export declare class PlanEditStore { /** The element a pointer press picked, while its drag may be in flight. */ grab: PlanGrab | null; /** Whether Shift is held during a pointer drag — the finer unit. */ shift: boolean; /** Where the pointer drag would land now. */ proposal: PlanProposal | null; /** The keyboard carry, while one lasts. */ carry: PlanCarry | null; /** The live region's last words. */ said: PlanSaid | null; /** Connect's draft, while its drag rests on a row (#1541, U10). */ connectDraft: PlanConnectDraft | null; /** * The lane a card dragged from a library rests in (#1541, U1), by the row the pointer is over: on a row with lanes, * the one the pointer is over; `undefined` on a row with none, and for a drag the keyboard carries. Read as the drop * on that row alone is judged and made — any other row's asks none — and let go as the drag ends (the canvas), so * the next drag begins with none. Never drawn from: nothing listens for it. */ cardLane: { readonly row: RowKey; readonly lane: string | undefined; } | null; /** Each element's movable, by its node — how a key finds what Space picks up. */ private readonly nodes; /** The element to focus once the canvas has drawn a keyboard drop. */ private focusAfter; private readonly listeners; /** Who draws Connect's draft: told on every step of the pointer, which no other listener hears. */ private readonly draftListeners; private release; /** Listen to every change. */ readonly subscribe: (listener: () => void) => (() => void); private emit; /** Listen to Connect's draft alone: it moves with every step of the pointer. */ readonly subscribeDraft: (listener: () => void) => (() => void); /** * Where Connect's draft line ends now (#1541, U10), or `null` once its drag is over. Heard only while a press * is down. * * @param draft - The pointer, and the element the line snaps to */ drawTo(draft: PlanConnectDraft | null): void; /** * A pointer pressed an element — arm its drag. Shift is followed from here * until the press ends. * * @param grab - The element, what it moves and where it was pressed * @param doc - The document the press is in */ arm(grab: PlanGrab, doc: Document): void; /** The drag ended — its grab and proposal go. */ disarm(): void; /** * Where the pointer drag would land now — told only when it moved. * * @param p - The row and the extent */ propose(p: PlanProposal): void; /** * Start, move or end the keyboard carry. * * @param carry - The carry, or `null` when it ends */ setCarry(carry: PlanCarry | null): void; /** * The carry, when it lands on this row — the row draws its landing band. * * @param rowKey - The row * @returns The carry, or `null` */ carryOn(rowKey: RowKey): PlanCarry | null; /** * Whether the keyboard carries this element now. * * @param rowKey - Its row * @param key - Its key * @returns Whether it is carried */ carries(rowKey: RowKey, key: string): boolean; /** * Put words in the live region. * * @param text - The words */ say(text: string): void; /** * Record an element's node, so a key pressed on it finds what it moves. * * @param node - The element's node * @param movable - What it moves */ register(node: Element, movable: PlanMovable): void; /** * What a node moves — `undefined` for a node that moves nothing. * * @param node - The focused node * @returns Its movable */ movableOf(node: Element): PlanMovable | undefined; /** * Ask for an element to be focused once the canvas has drawn — where a * keyboard drop leaves it. * * @param rowKey - Its row * @param key - Its key */ focusAfterDraw(rowKey: RowKey, key: string): void; /** * The element to focus now the canvas has drawn, once. * * @returns The element, or `null` */ takeFocus(): { rowKey: RowKey; key: string; } | null; } /** What the canvas's rows and elements need to move one (#825). */ export interface PlanEditContextValue { /** The moves in flight. */ store: PlanEditStore; /** The canvas's drag surface — `undefined` while nothing can move (no session, no id, the narrow layout). */ surface: string | undefined; /** Whether `data`'s rows take a move now: the root edits them, and its session takes a gesture (#880). */ dataMoves: boolean; /** * Typing a number into a table cell (#1436, #1438) — `undefined` while * `data`'s rows take no gesture: no session, or one that takes none now. */ typing: PlanTyping | undefined; /** * How an event kind's row's elements move (#1196) — `undefined` for a row * that is no event kind's, and while the canvas takes no event's drag. */ eventMove: ((row: PlanRowValue) => PlanRowMove | undefined) | undefined; /** * The link kind Connect draws while its tool is held (#1541, U10), by its name: an element's ghost says the link * it draws, where it says where a move would land — `undefined` while Select is held. */ connecting: string | undefined; /** The id of the words that tell a keyboard reader how to move an element. */ helpId: string; /** The Plan recipe's styles — the ghost's look. */ styles: Record>; /** The canvas's words. */ words: PlanWords; /** The shared scale. */ scale: PlanScale; } /** The canvas's moves (#825) — `null` outside a canvas that takes them. */ export declare const PlanEditContext: import("react").Context; /** * The canvas's moves. * * @returns What its rows and elements move with, or `null` */ export declare function usePlanEdit(): PlanEditContextValue | null; //# sourceMappingURL=store.d.ts.map