/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { SchematicValue } from "../data.js"; import type { NetLeg } from "../edits.js"; import { type DrawnItem, type DrawnZone, type SchematicDrawn, type SchematicRef } from "./drawn"; import type { SchematicLayerState } from "./layers"; import { type CameraMoves } from "./use-camera"; import type { Paint } from "./use-paint"; /** * What is selected that the drawing doesn't draw and still stands (#1393): each row of a kind read by area its window * doesn't hold, by its id — as its stored row draws it, `undefined` while it is first read. The selection keeps each, and * Del deletes each item with the rest. */ export interface SchematicStanding { /** The items, by id. */ readonly items: ReadonlyMap; /** The zones, by id. */ readonly zones: ReadonlyMap; } /** Nothing selected stands off the drawing. */ export declare const NO_STANDING: SchematicStanding; /** What {@link useCanvasSelection} reads. */ export interface CanvasSelectionProps { /** The payload, decoded: its `onSelect`, which hears the whole selection. */ readonly value: SchematicValue; /** Each entity's reference by its id on the canvas: what the host hears an entity named by (#1401, D34). */ readonly refById: ReadonlyMap; /** Told what is selected — the items, the zones, and the link or the net — by their ids, and the net's leg (#1391). */ readonly onSelection: (ids: ReadonlySet, leg: NetLeg | null) => void; } /** * What the canvas has selected, its funnels and its one report (see the module docs). * * @param props - The payload, each entity's reference, and what the frame is told * @returns The selection — the items and their anchor, the zones, the link or the net — the report's context, which * the commit-phase snapshot writes, and the funnels */ export declare function useCanvasSelection({ value, refById, onSelection }: CanvasSelectionProps): { zoneSelection: ReadonlySet; selectedLink: { key: string; leg: NetLeg | null; } | null; selection: { selected: ReadonlySet; anchor: string | null; }; setSelection: import("react").Dispatch; anchor: string | null; }>>; selected: ReadonlySet; commitCtx: { onSelect: ((inputs_0: { readonly kind: string; readonly key: string; }[]) => null) | undefined; refById: ReadonlyMap; }; commitCtxRef: import("react").RefObject<{ onSelect: ((inputs_0: { readonly kind: string; readonly key: string; }[]) => null) | undefined; refById: ReadonlyMap; }>; commitSelection: (next: ReadonlySet, opts?: { anchor?: string; }) => void; clearSelection: () => void; commitLinkSelection: (next: { key: string; leg: NetLeg | null; } | null) => void; commitZoneSelection: (next: ReadonlySet) => void; }; /** What the canvas has selected, its funnels and its one report: {@link useCanvasSelection}'s. */ export type CanvasSelection = ReturnType; /** What {@link useSelectionSteps} reads. */ export interface SelectionStepsProps { /** What the canvas draws: the links and nets a selected one is kept among, and the drawing a dropped item waits on. */ readonly data: SchematicDrawn; /** What the layers hide, lock and dim. */ readonly layers: SchematicLayerState; /** What never selects, by any path: a locked layer's entities, and what the narrowing takes out (SC27, #1392). */ readonly inertKeys: ReadonlySet; /** What the narrowing takes out of every list and of the selection, its context among it (#1392). */ readonly narrowedOut: ReadonlySet; /** The items drawn, a hidden layer's left out: what the selected items are kept among, and what the steps walk. */ readonly items: readonly DrawnItem[]; /** The zones drawn, a hidden layer's left out. */ readonly shownZones: readonly DrawnZone[]; /** What is selected that the drawing doesn't draw and still stands: rows of kinds read by area off their windows, kept selected. */ readonly standing: SchematicStanding; /** Whether a read the drawing needs is in flight: an item a drop asks to select is waited for until it lands. */ readonly reading: boolean; /** What is selected, and its funnels ({@link useCanvasSelection}'s). */ readonly canvasSelection: CanvasSelection; /** The commit-phase snapshot (`use-paint.ts`, invariant 1). */ readonly renderSnapRef: Paint["renderSnapRef"]; /** The fly (`use-camera.ts`), which a step's selection comes after (invariant 8). */ readonly flyTo: CameraMoves["flyTo"]; } /** * What keeps the selection to the drawing, and the steps through its items (see the module docs). * * @param props - The drawing and what never selects, what is selected and its funnels, the snapshot and the fly * @returns The zones' clear, the fly to an item that selects it, the steps, and an item a drop asks to select: where it * is asked, and what asks again */ export declare function useSelectionSteps({ data, layers, inertKeys, narrowedOut, items, shownZones, standing, reading, canvasSelection, renderSnapRef, flyTo }: SelectionStepsProps): { clearZoneSelection: () => void; flyToItem: (item: DrawnItem, clearRight?: number) => void; stepSelection: (delta: number) => void; pendingSelectRef: import("react").RefObject<{ readonly id: string; readonly seen: unknown; } | undefined>; setSelectAsked: import("react").Dispatch>; }; /** What keeps the selection to the drawing, and the steps: {@link useSelectionSteps}'s. */ export type SelectionSteps = ReturnType; //# sourceMappingURL=use-canvas-selection.d.ts.map