/** * 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 { 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"; type PlanPayloadValue = ValueTypeOf; /** One event kind, as the payload carries it. */ type PlanEventKindValue = PlanPayloadValue["events"][number]; /** One resource kind, as the payload carries it. */ type PlanResourceKindValue = PlanPayloadValue["resources"][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 Plan's drop veto over an event kind's drop (`Schedule.Types.Candidate` → `Option`), decoded. */ export type PlanEventCanDropFn = Extract["value"]; /** 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: its kind's slot, its key's text, the row's path to it, and the way the row draws. */ { readonly kind: "resource"; readonly slot: string; readonly key: string; readonly path: readonly string[]; readonly draw: string; } /** 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; } /** 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`. */ readonly libraries: readonly string[]; /** The Backlog tab's library: where an element returns to be unscheduled. */ readonly backlog: string; /** * 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 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; } /** What {@link usePlanEventDrag} reads — the latest render's. */ export interface PlanEventDragArgs { /** The event kinds; none, no drag of theirs. */ kinds: readonly PlanEventKindValue[]; /** The resource kinds: a row's resource by name, and a kind's by its slot. */ resources: readonly PlanResourceKindValue[]; /** 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 drop veto over an event kind's drop, when it has one. */ canDrop: PlanEventCanDropFn | 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