/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { DragEventValue, DropVeto } from "@elaraai/east-ui-components"; import type { PlanRowValue, VisibleRow } from "../model.js"; import type { RowKey } from "../plan-state.js"; import type { PlanScale } from "../scale.js"; import type { PlanWords } from "../words.js"; import type { PlanEditStore, PlanMovable, PlanProposal, PlanSpan } from "./store.js"; /** One move, as the editing session writes it. */ export interface PlanMoveRequest { /** The element's key — its item's. */ key: string; /** The row it leaves. */ from: RowKey; /** The row it lands on (`from` for a move along its row, or a resize). */ to: RowKey; /** Its extent there. */ span: PlanSpan; /** Whether it moved, or only an end did. */ origin: "move" | "resize"; /** Its name, for the transaction's label. */ label: string; /** The element as it was picked up (#1196): an event kind's moves its event, and a selection with it. */ element?: PlanMovable | undefined; /** The units it moved by — the buckets crossed, or the keyboard's steps (#1196). */ units?: number | undefined; /** Whether `units` are Shift's finer ones. */ fine?: boolean | undefined; } /** A landing judged by the event kinds' drag (#1196): whether it is taken, and why not. */ export interface PlanCarryVerdict { /** Whether it lands. */ readonly allowed: boolean; /** Why it does not — what its ghost says, in red. */ readonly reason: string | undefined; } /** What a gesture did — moved the element, or only one of its ends. */ export type PlanMoveOrigin = { kind: "move"; } | { kind: "resize"; edge: "start" | "end"; }; /** * Whether a landing is where the element already is — nothing to write. * * @param movable - The element * @param to - Where it lands * @returns Whether nothing moved */ export declare function unmoved(movable: PlanMovable, to: PlanProposal): boolean; /** * What a landing does: a resize when the element stays on its row and only * one end moved, else a move. * * @param movable - The element * @param to - Where it lands * @returns The gesture's kind */ export declare function originOf(movable: PlanMovable, to: PlanProposal): PlanMoveOrigin; /** * Whether a row draws an element keyed `key` — a run, chip, tile or mark. A * row's items keep their keys unique (a move finds its item by key), so a * moved element lands on ANOTHER row only where none of its elements has the * key: the write would refuse it, and the drag says so before the drop. * * @param row - The row, as the canvas draws it (its drafts included) * @param key - The moved element's key * @returns Whether one of the row's elements has the key */ export declare function holdsKey(row: PlanRowValue, key: string): boolean; /** * The drag event a landing would deliver — what the canvas's `canDrop` is * asked: a `move` from the element's start bucket to its new start's, or a * `resize` naming the moved end's bucket. * * @param surface - The canvas's drag surface * @param scale - The shared scale * @param movable - The element * @param to - Where it lands * @returns The candidate event */ export declare function candidateOf(surface: string, scale: PlanScale, movable: PlanMovable, to: PlanProposal): DragEventValue; /** What the carry reads of the canvas. */ export interface PlanCarryDeps { /** The moves in flight. */ store: PlanEditStore; /** The shared scale. */ scale: PlanScale | undefined; /** The canvas's words. */ words: PlanWords; /** The canvas's drag surface — `undefined` while nothing can move. */ surface: string | undefined; /** The canvas's veto over a drop (`canDrop`). */ veto: DropVeto | undefined; /** The rows as the canvas draws them — ↑ / ↓ walk them. */ rows: readonly VisibleRow[]; /** Whether a row takes the moved element: one of its item type, or an event kind's on a resource its kind takes (#1196). */ takes: (row: PlanRowValue, movable: PlanMovable) => boolean; /** * The event kinds' verdict over an event kind's element landing (#1196); * `undefined` for an element of `data`'s, which `veto` vets. */ judge?: ((movable: PlanMovable, to: PlanProposal) => PlanCarryVerdict | undefined) | undefined; /** A row's name. */ labelOf: (rowKey: RowKey) => string; /** Write a move as one gesture — whether it was drafted. */ move: (m: PlanMoveRequest) => boolean; /** Bring a row into view. */ reveal: (rowKey: RowKey) => void; /** Focus an element where it is now. */ focus: (rowKey: RowKey, key: string) => void; } /** What {@link usePlanCarry} gives the canvas. */ export interface PlanCarryKeys { /** Pick up the element a node is — whether it moves. */ start(node: Element): boolean; /** A key while carrying — whether the carry took it. */ keys(e: { key: string; shiftKey: boolean; altKey: boolean; ctrlKey: boolean; metaKey: boolean; preventDefault(): void; }): boolean; /** End a carry without a drop, leaving focus where it went — the reader left the canvas. */ cancel(): void; } /** * The keyboard's move — see the module docs. * * @param deps - What the carry reads of the canvas (the latest render's) * @returns Its start and its keys, stable */ export declare function usePlanCarry(deps: PlanCarryDeps): PlanCarryKeys; //# sourceMappingURL=use-carry.d.ts.map