/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * ONE overlay layer for the whole canvas (#816) — a popover, a hover card and a * tooltip, each a single Zag machine that exists only while it is open, however * many elements the canvas mounts. * * Elements are plain DOM. Every element kind already names itself — * `data-run`, `data-event`, `data-chip`, `data-mark`, `data-cell` (the cell's * instant, `instantKey`-encoded) — and its row names it (`data-plan-row`, or a * narrow card's `data-plan-card`: the row's key, its id's canonical text), so * the element ref a resolver is called with is read back from the DOM, its row * parsed back to the typed id (#822). The canvas body listens once: * * - a click opens the popover (and a second click on the same element closes * it) — in the CAPTURE phase, because the elements stop their clicks from * reaching the row, and selection and `onElementClick` keep working as * before. A link ribbon (#824) names its ref in its hit path's attributes * (`data-link-key` and its two run refs) — a ribbon belongs to no row — and * opens the popover the same way; * - Enter on a focused element opens the popover, and Esc closes it and hands * focus back to the element — that Esc is the popover's, never also a rung * of the canvas's esc ladder (the popover's layer takes it first and * prevents it, and the canvas skips a prevented key); * - hovering an element opens the hover card after a short delay, on devices * that can hover; leaving it closes the card unless the pointer moved into * the card; * - hovering a labelled port, cell marker, link ribbon (#818) or row control * (#1258) shows its `aria-label` as a tooltip — a ribbon opens no hover * card: its caption is what hovering it says; * - hovering a bar, a chip, a tile or a rollup band whose label is hidden (too * narrow for a letter and the ellipsis) or ellipsized, or a heat or table * cell whose number its column has no room for, shows the whole label as a * tooltip (#1264, #1266, #1269) — read from what the page draws as the hover * lands — and a hover card open on the element says more, so the tooltip * gives way to it. * * The open element and its resolved body live in the controller; the DOM node * a surface anchors to lives here, out of the store. A surface anchors with * `positioning.getAnchorElement`, so it follows the element while the canvas * scrolls — and closes once the element leaves the viewport, or the canvas. A * tile its cell folds has no box to anchor to: its popover — a pick from the * cell's `+n` menu opens it — hangs from that chip (#1276). * * The tooltip's styles are made as the layer mounts, ahead of the hover that * first opens one (#1594): a tooltip opens a moment into a pointer's rest on a * bar — in the middle of its pick-up, where the pointer rests that long — and a * rule first added to the page's styles then has them worked out again in that * frame. * * @packageDocumentation */ import { type KeyboardEvent, type MouseEvent, type PointerEvent, type RefObject } from "react"; import type { PlanElementRefValue } from "../context.js"; import type { PlanController } from "../controller/index.js"; type Styles = Record>; /** The elements a popover or hover card opens from — every element kind's own attribute. */ export declare const PLAN_ELEMENT_SELECTOR = "[data-run],[data-event],[data-chip],[data-mark],[data-cell]"; /** A link ribbon's hit path (#824) — a click opens its popover; hovering it * shows its caption as a tooltip, never a hover card. */ export declare const PLAN_LINK_SELECTOR = "[data-link-key]"; /** The labelled marks a tooltip reads — their `aria-label` is its text: ports, * cell markers, link ribbons (#818) and a row's focus controls (#1258). */ export declare const PLAN_TIP_SELECTOR = "[data-port][aria-label],[data-marker][aria-label],[data-link][aria-label],[data-plan-control][aria-label]"; /** The elements whose label (`data-plan-label`) a tooltip says while it is * hidden or ellipsized: a bar, a chip and a rollup band (#1264), a tile * (#1266), and a heat or table cell's number (#1269). */ export declare const PLAN_LABELLED_SELECTOR = "[data-run],[data-chip],[data-event],[data-plan-band],[data-cell]"; /** Where the open surfaces anchor, and the hover timers — DOM facts, kept out of the store. */ export interface PlanOverlayAnchors { popover: HTMLElement | null; hover: HTMLElement | null; tooltip: HTMLElement | null; hoverOpen: ReturnType | undefined; hoverClose: ReturnType | undefined; tipOpen: ReturnType | undefined; /** Set by Esc: the closing popover hands focus back to its element. */ returnFocus: boolean; } /** * A canvas's anchor record — created once per mount. * * @returns An empty record */ export declare function createOverlayAnchors(): PlanOverlayAnchors; /** * The element ref a DOM element names — its kind attribute and its row, or a * link ribbon's key and its two run refs. * * @param el - An element matching {@link PLAN_ELEMENT_SELECTOR} or {@link PLAN_LINK_SELECTOR} * @returns The ref, or `undefined` when the element names none */ export declare function refOfElement(el: Element): PlanElementRefValue | undefined; /** What the root's element interactions can open. */ export interface PlanOverlayPresence { /** The root declares a popover resolver. */ popover: boolean; /** The root declares a hover resolver. */ hover: boolean; } /** The body's delegated listeners. */ export interface PlanOverlayHandlers { onClickCapture: (e: MouseEvent) => void; onPointerOver: (e: PointerEvent) => void; onPointerOut: (e: PointerEvent) => void; /** Enter on a focused element opens its popover, and Esc closes an open * one; `true` when the key was the layer's (the canvas then ignores it). */ onKeyDown: (e: KeyboardEvent) => boolean; /** Open an element's popover as Enter does — never a toggle, so a second * press keeps it open. The keyboard's activation of an element (#819); * `true` when the root declares a popover and the element names a ref. */ openAt: (el: HTMLElement) => boolean; } /** * The canvas body's delegated overlay listeners. * * @param bodyRef - The canvas body (the one element listening) * @param controller - The canvas controller (the open surfaces' state) * @param anchors - This canvas's anchor record * @param presence - Which resolvers the root declares * @returns The listeners to spread on the body */ export declare function usePlanOverlayHandlers(bodyRef: RefObject, controller: PlanController, anchors: PlanOverlayAnchors, presence: PlanOverlayPresence): PlanOverlayHandlers; /** * The layer's surfaces — mount once, inside the canvas's controller. * * @param props - The anchor record, the `plan` recipe styles and the storage prefix * @returns The open surfaces (nothing when none is open) */ export declare function PlanOverlays({ anchors, styles, storageKey }: { anchors: PlanOverlayAnchors; styles: Styles; storageKey: string; }): import("react/jsx-runtime").JSX.Element; export {}; //# sourceMappingURL=overlays.d.ts.map