/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type ValueTypeOf } from "@elaraai/east"; import { type PlanPayloadType, type planKeys } from "@elaraai/e3-ui/internal"; import { type DragEventValue } from "@elaraai/east-ui-components"; import { type PlanRowValue } from "../model.js"; import type { RowKey } from "../plan-state.js"; import { type PlanLandingValue } from "../root/landings.js"; import type { PlanRowMove } from "../rows/SpanRow.js"; import type { PlanScale } from "../scale.js"; import type { PlanWords } from "../words.js"; import type { PlanEventEditing } from "./events.js"; import type { PlanEditStore, PlanMovable, PlanProposal, PlanSpan } from "./store.js"; import { type PlanMoveRequest } from "./use-carry.js"; import { type PlanVeto } from "./candidate.js"; import type { ConnectVetoOf } from "../../shared/links/veto.js"; import { type PlanLinkKindValue } from "../links/kinds.js"; type PlanPayloadValue = ValueTypeOf; /** One event kind, as the payload carries it. */ type PlanEventKindValue = PlanPayloadValue["events"][number]; /** One of the library's tabs, as the payload carries it. */ type PlanLibraryTabValue = PlanPayloadValue["library"][number]; /** The names a Plan keeps its viewer's state under. */ type PlanKeys = ReturnType; /** The item type an event kind's element carries: a row takes it by the event's kind, never by an item type, and no printed type reads so. */ export declare const PLAN_EVENT_ITEMS = "#event"; /** What a row of the event kinds' stands for. */ export type PlanEventTarget = /** A resource: the series it is a row of, its key's text, the row's path to it, the way the row draws, and its series as the payload has it. */ { readonly kind: "resource"; readonly slot: string; readonly key: string; readonly path: readonly string[]; readonly draw: string; readonly landing: PlanLandingValue; } /** An event kind's events on no resource: its slot, and the way the row draws. */ | { readonly kind: "unassigned"; readonly event: string; readonly draw: string; }; /** The event kinds' verdict over a drop where a drag rests. */ export interface PlanEventVerdict { /** Whether it lands. */ readonly allowed: boolean; /** What the ghost says: what lands where, or — refused — why not; `undefined`, nothing. */ readonly caption: string | undefined; /** The extent it lands at, or lands on — what the row's landing band spans. */ readonly span: PlanSpan | undefined; } /** * What Connect draws while its tool is held (#1541, U10): the link kind its menu chose, and the Plan's veto over a * connection, asked by the kind's slot and the two events' keys on the canvas. */ export interface PlanConnecting { /** The link kind Connect draws. */ readonly kind: PlanLinkKindValue; /** The Plan's `canConnect`, as its routes ask it: its words refusing a pair, or `undefined` allowing it. */ readonly veto: ConnectVetoOf; } /** * How the canvas answers a drop, as the drag layer hears it (`DragTargetConfig.onDrag`): whether it took it, or — a * drop that did something else than land where it was dropped — the words it is announced by (#1680's review). */ export type PlanDropAnswer = boolean | { readonly said: string; }; /** The event a link runs from, as a route that draws one names it: its element's key, and the row it is on, where it is known. */ export interface PlanLinkSource { /** Its element's key. */ readonly key: string; /** The row it is on: where the new link is selected from. */ readonly rowKey: RowKey | undefined; } /** The event kinds' drag and drop, as the canvas's rows, its drop target and its carry ask it — see the module docs. */ export interface PlanEventDrop { /** The libraries whose cards the event kinds take: the Events tab's, the Backlog tab's, and each author's tab's with a `drop` or a `create`. */ readonly libraries: readonly string[]; /** The Backlog tab's library: where an element returns to be unscheduled. */ readonly backlog: string; /** * Whether Connect is held (#1541, U10): an element's drag draws a link to the event under the pointer, in place of * moving it, and no element is resized. */ readonly connecting: boolean; /** * What a row stands for. * * @param row - The row * @returns Its resource, or its kind's events on none; `undefined` for a row no event kind draws on */ target(row: PlanRowValue): PlanEventTarget | undefined; /** * How a row's elements move: an event kind's row's, by their events. * * @param row - The row * @returns Its elements' moves — a bar's and a chip's with their ends; `undefined` for no event kind's row */ rowMove(row: PlanRowValue): PlanRowMove | undefined; /** * Whether an element is an event kind's. * * @param movable - The element */ isEvent(movable: PlanMovable): boolean; /** * Whether a row draws an element's kind — its resource's row of the way the * kind draws, or the kind's own Unassigned row: where the keyboard carries it. * * @param row - The row * @param movable - The element */ drawsKind(row: PlanRowValue, movable: PlanMovable): boolean; /** * Whether a row of the event kinds' takes a card of a library at all. * * @param library - The card's library */ takesCard(library: string): boolean; /** * Whether a card of a library lands on the event under the pointer, rather than at a bucket: an author's card with a `drop`. * * @param library - The card's library */ landsOnEvent(library: string): boolean; /** * A row's resource by name, as the ghost and the announcements say it. * * @param row - The row * @returns Its resource's name, or `Unassigned`; `undefined` for no event kind's row */ where(row: PlanRowValue): string | undefined; /** * The verdict over a card where the drag rests on a row. * * @param row - The row * @param from - The card: its library and its key * @param slot - The bucket under the pointer, as the drag grammar spells it (`""`, none) * @param event - The element under the pointer, by its key, when there is one * @returns The verdict */ card(row: PlanRowValue, from: { readonly library: string; readonly key: string; }, slot: string, event: string | undefined): PlanEventVerdict; /** * The verdict over an element landing on a row. * * @param row - The row * @param movable - The element * @param to - Where its row's landing put it; `undefined` before it has rested on the row, which then answers by the kinds alone * @returns The verdict */ element(row: PlanRowValue, movable: PlanMovable, to: PlanProposal | undefined): PlanEventVerdict; /** * The verdict over the link Connect would draw from an element to the event under the pointer (#1541, U10). * * @param movable - The element the drag runs from * @param event - The element under the pointer, by its key, when there is one * @returns The verdict: nothing said over no event, or over the event it runs from; the link's kind and its two * events where it lands; else why not — its kind's end, or the Plan's `canConnect` */ connect(movable: PlanMovable, event: string | undefined): PlanEventVerdict; /** * The verdict over an element returned to a library: unscheduled, on the Backlog tab. * * @param event - The return, a `remove` to its `source` * @param library - The library it is dropped on * @returns The verdict */ returning(event: DragEventValue, library: string): PlanEventVerdict; /** * A card dropped on a row — a template's `create`, a backlog event's `place`, or an author's card's fields. * * @param event - The drop, an `add` * @returns Whether it was recorded */ dropCard(event: DragEventValue): boolean; /** * An element moved or resized: its event placed, and a selection with it. * * @param request - The move * @returns Whether it was recorded */ moveElement(request: PlanMoveRequest): boolean; /** * An element dropped on a library: unscheduled, on the Backlog tab. * * @param event - The return, a `remove` to its `source` * @param library - The library it was dropped on * @returns Whether it was recorded */ returnElement(event: DragEventValue, library: string): boolean; /** * Connect's drop (#1541, U10): the link drawn from an element to the event it was dropped on, a draft of its * kind's session, and selected. * * @param movable - The element the drag ran from * @param event - The element it was dropped on, by its key, when there is one * @returns `false` where nothing was recorded; recorded, the words its drop is announced by — the link drawn, never * the element dropped (#1680's review) */ connectElement(movable: PlanMovable, event: string | undefined): PlanDropAnswer; /** * The verdict over a link of a kind from one event to another, whatever tool is held (#1541, U10): what the * inspector's Connect to… asks, by the same rules as Connect's drag. * * @param kind - The link kind * @param from - The event it runs from: its element's key, and the row it is on * @param to - The event it runs to, by its element's key * @returns The verdict */ link(kind: PlanLinkKindValue, from: PlanLinkSource, to: string): PlanEventVerdict; /** * A link of a kind drawn from one event to another: a draft of its kind's session, and selected. * * @param kind - The link kind * @param from - The event it runs from * @param to - The event it runs to, by its element's key * @returns Whether it was recorded */ linkEvents(kind: PlanLinkKindValue, from: PlanLinkSource, to: string): boolean; } /** What {@link usePlanEventDrag} reads — the latest render's. */ export interface PlanEventDragArgs { /** The event kinds; none, no drag of theirs. */ kinds: readonly PlanEventKindValue[]; /** The series the event kinds land on (#1541): what a row stands for, and each by name. */ landings: readonly PlanLandingValue[]; /** The library's tabs: the author's tabs' cards and the kinds their patches land on. */ tabs: readonly PlanLibraryTabValue[]; /** The names the Plan keeps its viewer's state under: the libraries the cards drag from. */ keys: PlanKeys; /** The event kinds' editing: their drafts, the new keys, and the recorder. */ editing: PlanEventEditing; /** The Plan's veto over what a drop would do (#1541, U7), when it has a check. */ veto: PlanVeto | undefined; /** What Connect draws while its tool is held (#1541, U10); `undefined` while Select is. */ connect: PlanConnecting | undefined; /** The Plan's `canConnect`, as its routes ask it (#1541, U10): what a link is held to, whatever tool is held. */ connectVeto: ConnectVetoOf; /** The values of the template the library holds for a link kind, by its slot, as bytes (#1541, U10): what a new link's other fields take; `undefined` for none held. */ linkValues: (slot: string) => Uint8Array | undefined; /** A resource's landing row on the canvas, where it holds it: the row a candidate names for an event that keeps its resource. */ resource: (ref: { readonly kind: string; readonly key: string; }) => PlanRowValue | undefined; /** The shared scale: a time scale beside event kinds. */ scale: PlanScale | undefined; /** The canvas's words. */ words: PlanWords; /** The moves in flight. */ store: PlanEditStore; /** A row on the canvas, by its key. */ rowOf: (key: RowKey) => PlanRowValue | undefined; /** The events selected on the canvas, by their elements' keys. */ selected: () => readonly string[]; /** Selects events, on the row given — a template's new event. */ select: (keys: readonly string[], row: RowKey | undefined) => void; } /** * The event kinds with an element drawn on rows of theirs: where an author's * card whose patch lands on one of them has an event to land on (#1196, PB63). * * @param rows - The rows on the canvas * @param drop - The event kinds' drag and drop: which rows are theirs * @returns The kinds' slots */ export declare function drawnKinds(rows: readonly PlanRowValue[], drop: PlanEventDrop): ReadonlySet; /** * The event kinds' drag and drop over the latest kinds, drafts and selection — * see the module docs. * * @param args - What it reads, the latest render's * @returns Its answers and its gestures, the same object while the libraries hold; `undefined` for a Plan without event kinds */ export declare function usePlanEventDrag(args: PlanEventDragArgs): PlanEventDrop | undefined; export {}; //# sourceMappingURL=event-drag.d.ts.map