@expofp/floorplan
Version:
Interactive floor plan library for expos and events
412 lines • 13.4 kB
TypeScript
import { type Config } from '@expofp/config';
import { type Camera, type ListPanel, type PlannerOptions } from '@expofp/schema';
/**
* Represents a floor plan.
*/
export interface FloorPlan {
readonly ready: Promise<void>;
readonly element: HTMLDivElement;
readonly eventId: string;
readonly noOverlay: boolean;
readonly offHistory: boolean;
/**
* @deprecated The consent decision lives on the config — set the `consent`
* option instead. `true` ⇄ `'granted'`, `false` ⇄ `'denied'`, `undefined` ⇄ `'ask'`.
*/
readonly allowConsent: boolean | undefined;
readonly onInit: (fp: FloorPlan) => void;
onBoothClick(e: FloorPlanBoothClickEvent): void;
onBookmarkClick(e: FloorPlanBookmarkClickEvent): void;
onVisitedClick(e: FloorPlanVisitedClickEvent): void;
onCategoryClick(e: FloorPlanCategoryClickEvent): void;
/**
* @deprecated
* The onFpConfigured method is deprecated. Use onInit instead.
*/
onFpConfigured(): void;
onDirection(e: FloorPlanDirectionEvent): void;
onDetails(e: FloorPlanDetailsEvent): void;
onExhibitorCustomButtonClick(e: FloorPlanCustomButtonEvent): void;
onGetCoordsClick(e: FloorPlanGetCoordsEvent): void;
onMarkerClick(e: FloorPlanMarkerEvent): void;
selectBooth(nameOrExternalId: string): void;
selectExhibitor(nameOrExternalId: string): void;
selectRoute(from: RouteWaypoint, to: RouteWaypoint): void;
selectRoute(waypoints: RouteWaypoint[]): void;
getOptimizedRoutes(waypoints: RouteWaypoint[]): RouteInfo[];
selectCurrentPosition(point: CurrentPosition, focus: boolean, icon?: number): void;
setBookmarks(bookmarks: {
name: string;
bookmarked: boolean;
}[]): void;
setEntitiesBookmarks(bookmarks: {
type: 'exhibitor' | 'event' | 'speaker' | 'booth';
name?: string;
externalId?: string;
bookmarked: boolean;
}[]): void;
setEntitiesVisited(entities: {
type: 'exhibitor' | 'event';
name?: string;
externalId?: string;
visited: boolean;
}[]): void;
setMarkers(markersData: MarkersData): void;
updateLayerVisibility(layer: string, visible: boolean): void;
getCenterCoordinates(): FloorPlanGetCoordsEvent;
applyParameters(queryRaw: string): void;
exhibitorsList(): FloorPlanExhibitor[];
boothsList(): FloorPlanBooth[];
categoriesList(): FloorPlanCategory[];
selectCategory(nameOrSlug?: string): void;
/**
* Opens whatever the slug or external id names — a booth, a schedule
* session, an exhibitor, a category or a speaker (checked in that order);
* anything else opens the search list with the value as the search text.
* The programmatic twin of the `?<slug>` deep link.
*/
select(slugOrExternalId: string): void;
/** Opens one of the named list panels (the `?bookmarks`, `?sessions`, … deep links). */
showList(list: ListPanel): void;
/** Launches the tour with the given id; unknown ids fall back to the tours list. */
selectTour(tourId: string): void;
/** Opens the route planner, optionally pre-filled with slugs or the visitor's bookmarks. */
openPlanner(options?: PlannerOptions): void;
/** Enters the interactive route-building mode. */
startBuildRoute(): void;
getVisibility(): Visibility;
setVisibility(visibility: Visibility): void;
findLocation(): void;
zoomIn(): void;
zoomOut(): void;
switchView(): void;
/**
* Moves the camera. Partial-merge semantics: only the fields present in
* `camera` change, omitted ones keep their current values — e.g.
* `setCamera({ bearing: 90 })` rotates the map without moving its center.
* The center is set either as floor-plan projected coordinates (`x`/`y`) or
* as GPS (`lat`/`lng`) — each is a pair, so both halves must be given.
* `floor` activates the named floor, `bearing` rotates the map (0–360°) and
* `zoomTime` sets the camera animation duration in milliseconds. Applied as
* soon as the renderer is ready. Also available as the `setCamera` intent
* (URL deep link).
*/
setCamera(camera: Camera): void;
/**
* The camera state last requested via {@link setCamera} (or the equivalent
* URL parameters) — not a live gesture-tracking camera: panning or zooming
* by hand does not update it.
*/
getCamera(): Camera;
zoomTo(selectors: POISelectors, options?: {
padding?: number;
}): void;
fitBounds(): void;
fitBounds(bounds: Bounds, options?: {
padding?: number;
}): void;
getBounds(selectors: POISelectors): Bounds | undefined;
getBoothRect(name: string): Rect;
convertToGeo(x: number, y: number): [number, number] | never;
getGeoConfig(): GeoConfig | null;
unstable_destroy(): void;
highlightExhibitors(externalIds: string[]): void;
highlightBooths(externalIds: string[]): void;
onCurrentPositionChanged(point: CurrentPosition): void;
onLeaveEvent?: () => void;
search(term: string): Promise<{
item: unknown;
score: number;
}[]>;
getFloors(): Floor[];
onFloorActivated(floor: Floor): void;
activateFloor(floorId: {
name?: string;
index?: number;
}): void;
showPathway(pathwayId: string, externalIds: string[]): void;
showPathwayOnly(pathwayId: string, floorId: string): void;
hidePathways(): void;
showSearch(): void;
changeLanguage(langId: string): void;
isGpsTrackingEnabled(): boolean;
setGpsTrackingEnabled(value: boolean): void;
deselectCurrentPosition(): void;
deselectRoute(): void;
reset(): void;
/**
* Same as {@link selectRoute}, but restricts the path to accessible segments only.
* @param waypoints - Ordered route stops (booth name/ID or `CurrentPosition`).
*/
selectAccessibleRoute(waypoints: RouteWaypoint[]): void;
}
/**
* Options for configuring the FloorPlan instance.
*/
export interface FloorPlanOptions {
element?: HTMLDivElement | string;
onBoothClick?: (e: FloorPlanBoothClickEvent) => void;
onBookmarkClick?: (e: FloorPlanBookmarkClickEvent) => void;
onVisitedClick?: (e: FloorPlanVisitedClickEvent) => void;
onCategoryClick?: (e: FloorPlanCategoryClickEvent) => void;
/**
* @deprecated
* The onFpConfigured method is deprecated. Use onInit instead.
*/
onFpConfigured?: () => void;
onDirection?: (e: FloorPlanDirectionEvent) => void;
onDetails?: (e: FloorPlanDetailsEvent) => void;
onExhibitorCustomButtonClick?: (e: FloorPlanCustomButtonEvent) => void;
onMarkerClick?: (e: FloorPlanMarkerEvent | undefined) => void;
onGetCoordsClick?: (e: FloorPlanGetCoordsEvent) => void;
onInit?: (fp: FloorPlan) => void;
onCurrentPositionChanged?: (point: CurrentPosition) => void;
onFloorActivated?: (floor: Floor) => void;
onLeaveEvent?: () => void;
}
/** MapLibre options — the config schema (`MapLibreConfigSchema`) is the single definition. */
export type MaplibreOptions = NonNullable<Config['maplibre']>;
export interface Layer {
name: string;
description: string;
}
export interface FloorPlanBoothBase {
id: number;
externalId: string;
name: string;
layer: Layer;
}
export interface FloorPlanBooth extends FloorPlanBoothBase {
id: number;
name: string;
externalId: string;
isSpecial: boolean;
exhibitors: number[];
layer: Layer;
meta: Record<string, string>;
description: string;
entity: Entity;
title?: string;
}
export interface FloorPlanBoothClickEvent {
target: FloorPlanBoothBase;
}
export interface Point {
x: number;
y: number;
}
export interface FloorPlanBookmarkClickEvent {
name: string;
bookmarked: boolean;
externalId: string;
}
export interface FloorPlanVisitedClickEvent {
name: string;
visited: boolean;
externalId: string;
}
type FloorPlanCategoryClickEvent = FloorPlanCategory;
export interface FloorPlanDirectionEvent {
from: FloorPlanBoothBase;
to: FloorPlanBoothBase;
/**
* Route polyline segments in walking order — from the origin (`from`) to the
* destination (`to`), each `p0 → p1` pointing forward along the route.
*
* Changed in v3.12.0: segments run source→target. Earlier versions emitted
* them reversed (target→source, with `p0`/`p1` swapped).
*/
lines: {
p0: Point;
p1: Point;
}[];
distance: string;
units: string;
time: number;
}
export interface FloorPlanDetailsEvent {
type: 'booth' | 'exhibitor' | 'route' | 'category';
id: string;
name: string;
externalId: string;
boothsNames: string[];
routeInfo?: Record<string, unknown>;
}
export interface FloorPlanCustomButtonEvent {
externalId: string;
buttonNumber: number;
buttonUrl: string;
preventDefault: () => void;
}
export interface FloorPlanGetCoordsEvent extends Point {
z: string | null;
}
export interface FloorPlanMarkerEvent extends Point {
id: string;
z?: number | string;
}
export interface FloorPlanExhibitor {
id: number;
name: string;
externalId: string;
booths: number[];
entity: Entity;
slug: string;
}
export interface FloorPlanCategory {
id: number;
name: string;
exhibitors: number[];
entity: Entity;
slug: string;
}
export type RouteWaypoint = string | CurrentPosition;
export interface RouteInfo {
waypoints: RouteWaypoint[];
}
export interface ExpoData {
booths: FloorPlanBooth[];
exhibitors: FloorPlanExhibitor[];
categories: FloorPlanCategory[];
}
export type FloorPlanIcon = 'departure' | 'departure_inactive' | 'destination' | 'direction' | 'transition' | 'transition_up' | 'transition_down' | 'kiosk' | 'yah';
export interface LayerPoint extends Point {
layer: string;
}
export interface Entity {
type: 'booth' | 'category' | 'exhibitor' | 'schedule' | 'language' | 'heatmap-yah' | 'route-cut-in';
variant?: 'regular' | 'special';
}
export interface FloorPlanSchedule {
id: number;
externalId: string;
boothId: number;
exhibitorId: number;
name: string;
description: string;
startDate: string;
endDate: string;
link: string;
entity: Entity;
isEnded: boolean;
}
/** One selectable UI language (as `utils/i18n.ts` serves them). */
export interface Language {
readonly id: string;
readonly name: string;
readonly entity: {
readonly type: 'language';
};
}
export interface FloorPlanHeatmapYah {
id: string;
name: string;
viewCount: number;
x: number;
y: number;
z: number | string;
entity: Entity;
}
export type FloorPlanEntity = FloorPlanBooth | FloorPlanCategory | FloorPlanExhibitor | FloorPlanSchedule | Language | FloorPlanHeatmapYah;
export interface Floor {
name: string;
shortName: string;
description: string;
active: boolean;
disabled: boolean;
index: number;
}
export interface CurrentPosition extends Point {
z?: number | string;
angle?: number;
lat?: number;
lng?: number;
}
export interface Marker extends CurrentPosition {
id: string;
icon: string;
selectedIcon: string;
position: 'centertop' | 'lefttop';
active?: boolean;
}
export interface MarkerIcon {
name: string;
content: string;
width: number;
height: number;
scale?: number;
}
export interface MarkersData {
icons: MarkerIcon[];
markers: Marker[];
}
export interface Visibility {
controls?: boolean;
levels?: boolean;
header?: boolean;
overlay?: boolean;
searchButtons?: boolean;
}
export interface Rect {
x1: number;
x2: number;
y1: number;
y2: number;
}
/**
* Defines a rectangular bounding box using two corner points.
*/
export interface Bounds {
/** Top-left corner of the bounding box */
leftTop: Point;
/** Bottom-right corner of the bounding box */
rightBottom: Point;
}
/**
* Selector for identifying a Point of Interest (POI) by name or external ID.
*/
export interface POISelector {
/** Name of the POI */
name?: string;
/** External identifier of the POI */
externalId?: string;
}
/**
* Collection of POI selectors for booths and exhibitors.
*/
export interface POISelectors {
/** Array of booth selectors */
booths?: POISelector[];
/** Array of exhibitor selectors */
exhibitors?: POISelector[];
}
/**
* Geographic anchor point that ties a floor plan coordinate to a real-world
* GPS location. Used to georeference the map.
*/
export interface GeoAnchor {
/** X coordinate in the floor plan coordinate system */
x: number;
/** Y coordinate in the floor plan coordinate system */
y: number;
/** Latitude in decimal degrees */
lat: number;
/** Longitude in decimal degrees */
lng: number;
}
/**
* Geographic configuration of the floor plan: its orientation and the anchor
* points that map local coordinates to GPS positions.
*/
export interface GeoConfig {
/** Bearing in degrees clockwise from true north; `0` when the map is north-aligned. */
bearing: number;
/** Primary anchor point. */
p0: GeoAnchor;
/** Optional secondary anchor point. */
p1?: GeoAnchor;
/** Tertiary anchor point. */
p2: GeoAnchor;
}
export {};
//# sourceMappingURL=types.d.ts.map