import { BimViewer } from "../core/BimViewer"; import { ContextMenuId } from "./ContextMenu.config"; /** * Context for ContextMenu. * We usually need to include a viewer (the BimViewer, etc.), so that it can call it's methods in the action callback. * It may include "hasSelectedFamilyInstance", so we can show different context menu according to what is clicked on. */ export interface Context { bimViewer: BimViewer; hasSelectedFamilyInstance: boolean; } /** * Context menu config. * With this config, user can customize a context menu. S/he can define what menu items * are included, menu item order, etc. */ export interface ContextMenuConfig { context: Context; id?: string; container?: HTMLElement; menuCfg?: { [key in ContextMenuId]?: Pick; }; items: ContextMenuId[][]; hideOnMouseDown?: boolean; } /** * Context menu item config. * Used to define a menu item's title, visibility, callback, etc. */ export interface ContextMenuItemConfig { title?: string; enabled?: boolean; shown?: boolean; getTitle?: (context: Context) => string; getEnabled?: (context: Context) => boolean; getShown?: (context: Context) => boolean; doAction?: (context: Context) => Promise; actionCallback?: (res: any) => void; } /** * ContextMenu class. * @internal */ export declare class ContextMenu { private id; private container; private element; private handleClick; private menuItemGroup; context: Context; itemList: Map; menuConfig: { [key in ContextMenuId]: ContextMenuItemConfig; }; constructor(cfg: ContextMenuConfig); private initMenuConfig; private createMenu; private createMenuGroup; private createMenuItem; private updateMenuItems; private showMenuElement; show(pageX: number, pageY: number): void; hide(): void; destroy(): void; } /** * @internal */ export declare class ContextMenuItem { readonly config: ContextMenuItemConfig; private readonly context; element: HTMLElement; constructor(id: ContextMenuId, config: ContextMenuItemConfig, context: Context); private isEnabled; private isShown; private getTitle; private createItem; updateItem(): void; }