@expofp/floorplan
Version:
Interactive floor plan library for expos and events
75 lines • 3.84 kB
TypeScript
import { type PointerEventData, type PointerMissedEventData, type ShapeDef } from '@expofp/renderer';
import { type Booth } from '../../store/BoothStore';
import { type FloorPlanMarkerEvent } from '../../types';
/** How a click on the plan resolves to a marker. See {@link setMarkerResolver}. */
export type MarkerResolver = (x: number, y: number) => FloorPlanMarkerEvent | null;
/**
* Registers a listener for every click that lands on the plan, hit or miss, before selection acts
* on it — the seam the kiosk setup screen and the route-authoring tool take their clicks from,
* which the imperative renderer served with its own `pointer:click` listeners.
*
* One listener at a time: the two consumers are modal and never active together.
* @param listener - Receives the plan point; omitted to unregister.
*/
export declare function setPlanClickListener(listener?: (point: {
x: number;
y: number;
}) => void): void;
/**
* Registers how a click resolves to a marker, for as long as markers are drawn.
*
* The same inversion {@link rememberBoothShapes} performs for booths, and for the same reason: this
* seam is reached from a click and must stay free of the modules that build defs — the marker hit
* test needs both the marker data and the pixel size their own layer is laid out at.
* @param resolve - Returns the marker under a plan point, or `null`; omitted to unregister.
*/
export declare function setMarkerResolver(resolve?: MarkerResolver): void;
/**
* Records which booth a set of background shapes belongs to, so a pointer hit can name it.
*
* A booth draws as one rect, or as several polygons when it comes from paths, and the renderer
* reports whichever def was hit. Registered where the defs are built rather than searched for later:
* the alternative is scanning every booth's shapes on every pointer move.
* @param booth - The booth the shapes draw.
* @param shapes - Its background shapes.
*/
export declare function rememberBoothShapes(booth: Booth, shapes: readonly ShapeDef[]): void;
/**
* The booth a hit def draws, if any.
* @param def - The def the renderer reported.
* @returns The booth, or `null` for a def that is not a booth background.
*/
export declare function boothOfShape(def: ShapeDef): Booth | null;
/**
* Tracks the booth under the pointer. Declared on the booth background layer, which is the only
* layer the plan picks in.
* @param event - The def under the pointer.
*/
export declare function hoverBooth(event: PointerEventData<ShapeDef>): void;
/**
* Clears the hovered booth as the pointer leaves it.
*/
export declare function clearHoveredBooth(): void;
/**
* Selects the booth that was clicked.
* @param event - The def that was clicked, and where on the plan.
*/
export declare function selectBooth(event: PointerEventData<ShapeDef>): void;
/**
* Handles a click that reached no booth — empty background, or a def in a layer the plan does not
* pick in — which deselects, exactly as clicking away from a booth always has.
* @param event - Where on the plan the click landed.
*/
export declare function clearSelection(event: PointerMissedEventData): void;
/**
* Calls the kiosk's idle-reset hook, if one is installed. A global (`window.__resett`), which is how
* the parts of the SDK that are not components reach the timer `init-ui` owns — and which an
* embedding page may install instead.
*
* Exported because the user moving the camera counts as activity too, not only a click: `MapCamera`
* calls it while the visitor has hold of the plan, as the imperative renderer's `navigation:change`
* listener did. A command is left out on purpose — the idle reset moves the camera itself, and would
* re-arm the timer it had just fired.
*/
export declare function resetExternalOverlay(): void;
//# sourceMappingURL=pointer.d.ts.map