UNPKG

@deck.gl/core

Version:

deck.gl core library

80 lines 3.52 kB
import type Deck from "./deck.js"; import type Viewport from "../viewports/viewport.js"; import type { PickingInfo } from "./picking/pick-info.js"; import type { MjolnirPointerEvent, MjolnirGestureEvent } from 'mjolnir.js'; import type Layer from "./layer.js"; import type { WidgetManager, WidgetPlacement } from "./widget-manager.js"; import type { ViewOrViews } from "./view-manager.js"; export type WidgetProps = { id?: string; /** CSS inline style overrides. */ style?: Partial<CSSStyleDeclaration>; /** Additional CSS class. */ className?: string; }; export declare abstract class Widget<PropsT extends WidgetProps = WidgetProps, ViewsT extends ViewOrViews = null> { static defaultProps: Required<WidgetProps>; /** Unique identifier of the widget. */ id: string; /** Widget props, with defaults applied */ props: Required<PropsT>; /** * The view id that this widget is being attached to. Default `null`. * If assigned, this widget will only respond to events occurred inside the specific view that matches this id. */ viewId?: string | null; /** Widget positioning within the view. Default 'top-left'. */ abstract placement: WidgetPlacement; /** Class name for this widget */ abstract className: string; widgetManager?: WidgetManager; deck?: Deck<ViewsT>; rootElement?: HTMLDivElement | null; constructor(props: PropsT); /** Called to update widget options */ setProps(props: Partial<PropsT>): void; /** Update the HTML to reflect latest props and state */ updateHTML(): void; /** * Common utility to create the root DOM element for this widget * Configures the top-level styles and adds basic class names for theming * @returns an UI element that should be appended to the Deck container */ protected onCreateRootElement(): HTMLDivElement; /** Called to render HTML into the root element */ abstract onRenderHTML(rootElement: HTMLElement): void; /** Internal API called by Deck when the widget is first added to a Deck instance */ _onAdd(params: { deck: Deck<any>; viewId: string | null; }): HTMLDivElement; /** Overridable by subclass - called when the widget is first added to a Deck instance * @returns an optional UI element that should be appended to the Deck container */ onAdd(params: { /** The Deck instance that the widget is attached to */ deck: Deck<any>; /** The id of the view that the widget is attached to */ viewId: string | null; }): HTMLDivElement | void; /** Called when the widget is removed */ onRemove(): void; /** Called when the containing view is changed */ onViewportChange(viewport: Viewport): void; /** Called when the containing view is redrawn */ onRedraw(params: { viewports: Viewport[]; layers: Layer[]; }): void; /** Called when a hover event occurs */ onHover(info: PickingInfo, event: MjolnirPointerEvent): void; /** Called when a click event occurs */ onClick(info: PickingInfo, event: MjolnirGestureEvent): void; /** Called when a drag event occurs */ onDrag(info: PickingInfo, event: MjolnirGestureEvent): void; /** Called when a dragstart event occurs */ onDragStart(info: PickingInfo, event: MjolnirGestureEvent): void; /** Called when a dragend event occurs */ onDragEnd(info: PickingInfo, event: MjolnirGestureEvent): void; } //# sourceMappingURL=widget.d.ts.map