import { AcApContext, AcApPlugin, AcEdCommandStack, type AcEdUiLayoutKind } from '@mlightcad/cad-simple-viewer'; import { AcUiDockPanelSide, AcUiPluginLayoutMode, AcUiSimpleUiPluginOptions, AcUiToolbarItem, AcUiToolbarItemsInput, AcUiToolbarPlacement } from './config/types'; import { type AcUiDockPanelTab } from './ui/AcUiDockPanel'; /** * CAD viewer plugin that adds a framework-agnostic toolbar, layer manager, and * review palette. * * Registers the `layer`, `markuppanel`, and `measurementpanel` commands when * the toolbar includes those buttons, injects shared UI styles, and keeps * theme and locale in sync * with {@link AcApI18n} and the `COLORTHEME` system variable. * * Supports responsive chrome via {@link AcUiSimpleUiPluginOptions.layout} and * {@link AcUiSimpleUiPluginOptions.layouts}: phone (bottom full-width bar), * pad, and desktop (default right-side toolbar). Use {@link getLayout} and * {@link setLayout} to read or override the active layout at runtime. */ export declare class AcApSimpleUiPlugin implements AcApPlugin { private readonly options; /** {@link SIMPLE_UI_PLUGIN_NAME} */ name: string; /** Plugin semver string. */ version: string; /** Human-readable plugin summary. */ description: string; /** Layer list view mounted in the dock panel layers tab. */ private layerListView?; /** Review palette view mounted in the dock panel review tab. */ private reviewPaletteView?; /** Measurement list view mounted in the dock panel measurements tab. */ private measurementPaletteView?; /** Chrome DevTools-style dock panel container. */ private dockPanel?; /** Dock-mode layer controller (for cleanup). */ private layerDockController?; /** Mutable delegate for the registered `layer` command. */ private readonly layerUiControllerHolder; /** Configurable toolbar instance. */ private toolbar?; /** Cleanup for {@link acapBindToolbarDocState}. */ private toolbarDocUnbind?; /** Scoped i18n helper for plugin strings. */ private i18n?; /** Syncs UI theme with host attribute and database sysvar. */ private themeSync?; /** Viewer host element receiving UI chrome. */ private hostEl?; /** Explicit dock mount override from plugin options. */ private dockPanelMountTargetOption?; /** Resolved toolbar items before layer action wiring. */ private baseToolbarItems; /** Raw toolbar items configuration last applied via {@link setToolbarItems}. */ private toolbarItemsInput; /** * When true, {@link setToolbarItems} replaced the layout-derived item list. * Layout switches still update chrome (placement, size, labels) but keep * this item list until the next {@link setToolbarItems} call. */ private toolbarItemsOverridden; /** Optional layout-switcher button prepended by the last {@link setToolbarItems}. */ private toolbarLayoutSwitcher?; /** Command stack reference for dynamic layer command registration. */ private commandManager?; /** Whether the toolbar includes a layer button. */ private hasLayerToolbarItem; /** Whether the toolbar includes a markup panel / review button. */ private hasMarkupPanelToolbarItem; /** Whether the toolbar includes a measurement panel button. */ private hasMeasurementPanelToolbarItem; /** Whether {@link dockPanel} was explicitly enabled in options. */ private dockPanelExplicitlyEnabled; /** Normalized dock panel defaults from plugin options. */ private dockPanelDefaults?; /** Current toolbar edge placement (mutable via toolbar settings button). */ private toolbarPlacement; /** Whether the viewer toolbar supports collapse/expand. */ private toolbarCollapsible; /** Canvas element receiving the floating viewer toolbar. */ private toolbarMountEl?; /** Explicit toolbar mount override from plugin options. */ private toolbarMountTargetOption?; /** Inset of the viewer toolbar from the canvas edge in px. */ private toolbarEdgeOffset; /** Cross-axis inset of the viewer toolbar from host edges in px. */ private toolbarSideOffset; /** * When true, the toolbar is a flex sibling of the canvas in the canvas parent. */ private toolbarInCanvasParent; /** Whether the main toolbar shows labels below icons. */ private toolbarShowLabels; /** Whether parent buttons with children show a corner triangle. */ private toolbarShowChildrenIndicator; /** Whether the toolbar container border is shown. */ private toolbarShowBorder; /** Whether each toolbar button draws a permanent outer border. */ private toolbarShowButtonBorder; /** Whether toolbar separator dividers are shown. */ private toolbarShowSeparators; /** Toolbar sizing along the layout axis (`auto` or `stretch`). */ private toolbarSize; /** Overflow behavior when buttons exceed host bounds. */ private toolbarOverflow; /** Sub-toolbar chrome overrides. */ private toolbarSubToolbar?; /** Layout mode from plugin options (`auto` or forced kind). */ private layoutMode; /** Active resolved layout kind after merging defaults. */ private activeLayoutKind; /** Unsubscribe from viewport layout media queries. */ private unsubscribeLayout?; /** Commands registered during {@link onLoad} for cleanup on unload. */ private registeredCommands; /** Refreshes toolbar, layer, and review UI when the app locale changes. */ private handleLocaleChanged; /** Re-resolves mount targets after the viewer view becomes available. */ private handleDocumentActivatedForDock; /** * @param options - Toolbar, layer manager, dock panel, and host configuration. */ constructor(options?: AcUiSimpleUiPluginOptions); /** * Adds a tab to the dock panel and opens it. * Creates the dock panel container when it does not exist yet. * * @param tab - Tab definition. * @returns Whether the tab was added. */ addDockPanelTab(tab: AcUiDockPanelTab): boolean; /** Whether the dock panel is open. */ isDockPanelOpen(): boolean; /** Whether a dock panel tab with the given id is registered. */ hasDockPanelTab(tabId: string): boolean; /** * Opens the dock panel and activates a tab, or closes the panel when that tab * is already active. * * @param tabId - Tab to toggle. * @returns `true` when applied; `false` when the tab or dock panel is unavailable. */ toggleDockPanelTab(tabId: string): boolean; /** * Opens or closes the dock panel. * * @param open - Target open state. * @returns `true` when applied; `false` when the dock panel is unavailable. */ setDockPanelOpen(open: boolean): boolean; /** Returns the dock panel side, if the dock panel exists. */ getDockPanelSide(): AcUiDockPanelSide | undefined; /** Returns the dock panel size in px, if the dock panel exists. */ getDockPanelSize(): number | undefined; /** * Sets the dock panel width or height in px. * * @param size - Target size in px. * @returns `true` when applied; `false` when the dock panel is unavailable. */ setDockPanelSize(size: number): boolean; /** Returns the toolbar item configuration last passed to {@link setToolbarItems}. */ getToolbarItems(): AcUiToolbarItemsInput; /** * Replaces the entire toolbar item list at runtime. * * Unlike `toolbar.appendItems`, this replaces the full `items` collection. * Preset references and `'default'` are resolved using the same rules as * initial plugin load. Subsequent {@link setLayout} / auto viewport switches * keep this list and only update toolbar chrome. * * @param items - Full toolbar layout definition. * @param layoutSwitcher - Optional layout submenu button prepended before `items`. */ setToolbarItems(items: AcUiToolbarItemsInput, layoutSwitcher?: AcUiToolbarItem): void; /** Returns the viewer toolbar edge placement. */ getToolbarPlacement(): AcUiToolbarPlacement; /** * Moves the viewer toolbar to another host edge. * * @param placement - Target edge placement. * @returns `true` when applied; `false` when the toolbar is unavailable. */ setToolbarPlacement(placement: AcUiToolbarPlacement): boolean; /** Whether the viewer toolbar is visible. */ isToolbarVisible(): boolean; /** * Shows or hides the viewer toolbar. * * @param visible - Target visibility. * @returns `true` when applied; `false` when the toolbar is unavailable. */ setToolbarVisible(visible: boolean): boolean; /** Whether the viewer toolbar is collapsed to its toggle button. */ isToolbarCollapsed(): boolean; /** * Collapses or expands the viewer toolbar when {@link toolbar.collapsible} is enabled. * * @param collapsed - Target collapsed state. * @returns `true` when applied; `false` when the toolbar is unavailable or not collapsible. */ setToolbarCollapsed(collapsed: boolean): boolean; /** Returns the viewer toolbar inset from the canvas edge in px. */ getToolbarEdgeOffset(): number; /** Returns the active UI layout kind (`phone`, `pad`, or `desktop`). */ getLayout(): AcEdUiLayoutKind; /** * Sets layout mode and reapplies toolbar chrome for the target kind. * * When `mode` is `'auto'`, subscribes to viewport media queries via * {@link acedSubscribeUiLayout} and switches toolbar configuration when * {@link acedGetUiLayout} changes. Forced modes stop auto subscription. * * @param mode - `'auto'` or a fixed {@link AcEdUiLayoutKind}. * @returns `true` when the mode was stored or applied; `false` when the * toolbar is unavailable and the mode could not be applied (except when only * updating stored mode before toolbar creation). */ setLayout(mode: AcUiPluginLayoutMode): boolean; /** * Sets the viewer toolbar inset from the canvas edge. * * @param offset - Distance in px (clamped to >= 0). * @returns `true` when applied; `false` when the toolbar is unavailable. */ setToolbarEdgeOffset(offset: number): boolean; /** * Creates UI components, registers commands, and starts theme sync. * * @param _context - Application context (unused). * @param commandManager - Command stack used to register `layer`, `markuppanel`, and `measurementpanel`. */ onLoad(_context: AcApContext, commandManager: AcEdCommandStack): void; /** Whether viewer toolbar creation is allowed (only explicit `false` disables). */ private isViewerToolbarEnabled; /** * Creates the floating toolbar when enabled and not already present. * * @param host - Plugin theme host; defaults to {@link hostEl}. */ private ensureViewerToolbar; /** Resolves the canvas element that receives the viewer toolbar. */ private getToolbarMountEl; /** * Moves the toolbar from a host or inner-canvas fallback to the preferred * mount (typically the canvas parent) once the view is available. */ private tryUpgradeToolbarMountTarget; /** * Merges built-in, top-level, and per-layout toolbar options for a kind. * * @param kind - Layout kind to resolve options for. * @returns Merged {@link AcUiToolbarOptions} used by {@link applyLayoutKind}. */ private getMergedToolbarOptions; /** * Applies toolbar configuration for a layout kind and refreshes dock wiring. * * Chrome always comes from merged layout options. Item lists come from those * options unless {@link setToolbarItems} has replaced them at runtime. * * @param kind - Target layout kind. * @param options - When `skipToolbarApply` is true, only updates resolved state. */ private applyLayoutKind; /** Context passed when resolving default toolbar presets. */ private getToolbarContext; /** * Resolves {@link baseToolbarItems} from a runtime override or layout options. * * @param kind - Layout kind used for `'default'` and preset expansion. * @param toolbarOpts - Merged options for `kind`; fetched when omitted. */ private rebuildToolbarItems; /** Resolves raw toolbar input into concrete toolbar items. */ private resolveBaseToolbarItems; /** Applies {@link baseToolbarItems} to the toolbar. */ private renderToolbarItems; /** Mounts or tears down layer UI when the layer toolbar button is added or removed. */ private syncLayerToolbarItem; /** Mounts or tears down review UI when the markup panel button is added or removed. */ private syncReviewToolbarItem; /** Mounts or tears down measurement UI when the panel button is added or removed. */ private syncMeasurementToolbarItem; /** Removes the `layer` command when the layer toolbar button is removed at runtime. */ private unregisterLayerCommand; /** Registers the `layer` command when a layer button appears at runtime. */ private ensureLayerCommandRegistered; /** Removes the `markuppanel` command when the review toolbar button is removed. */ private unregisterMarkupPanelCommand; /** Registers the `markuppanel` command when a review button appears at runtime. */ private ensureMarkupPanelCommandRegistered; /** Removes the `measurementpanel` command when the measurement panel button is removed. */ private unregisterMeasurementPanelCommand; /** Registers the `measurementpanel` command when a panel button appears at runtime. */ private ensureMeasurementPanelCommandRegistered; /** Registers the `layer` command with dock preparation wired in. */ private registerLayerCommand; /** Creates the `layer` command that prepares the dock panel before opening layers. */ private createLayerCommand; /** Ensures the dock panel and layers tab exist for the `layer` command. */ private prepareLayerDockForCommand; /** Registers the `markuppanel` command with dock preparation wired in. */ private registerMarkupPanelCommand; /** Creates the `markuppanel` command that prepares the dock panel before opening review. */ private createMarkupPanelCommand; /** Ensures the dock panel and review tab exist for the `markuppanel` command. */ private prepareReviewDockForCommand; /** Registers the `measurementpanel` command with dock preparation wired in. */ private registerMeasurementPanelCommand; /** Creates the `measurementpanel` command that prepares the dock before opening. */ private createMeasurementPanelCommand; /** Ensures the dock panel and measurements tab exist for the command. */ private prepareMeasurementDockForCommand; /** Ensures the dock panel exists, tabs are mounted, and mount target is current. */ private ensureDockReady; /** Ensures the dock panel exists, is mounted on the current target, and has tabs when applicable. */ private prepareDockPanel; /** Closes open sub-toolbars when {@link AcUiSubToolbarOptions.replaceOnNested} is set. */ private dismissStripsForDockPanel; /** Closes the dock panel when {@link AcUiSubToolbarOptions.replaceOnNested} is set. */ private dismissDockForExclusiveChrome; /** Ensures the dock panel container exists. */ private ensureDockPanel; /** Resolves the dock mount element (lazy; canvas parent may appear after load). */ private getDockMountEl; /** * Moves the dock panel from a host fallback to the canvas parent once available. */ private tryUpgradeDockMountTarget; /** Rebinds the layer dock controller after the dock panel moves. */ private refreshLayerDockController; /** Mounts the layer list in the dock panel layers tab. */ private mountLayerDockUi; /** Tears down active layer UI without removing the dock shell when other tabs remain. */ private teardownLayerUi; /** Mounts the review palette in the dock panel review tab. */ private mountReviewDockUi; /** Tears down review UI without removing the dock shell when other tabs remain. */ private teardownReviewUi; /** Mounts the measurement list in the dock panel measurements tab. */ private mountMeasurementDockUi; /** Tears down measurement UI without removing the dock shell when other tabs remain. */ private teardownMeasurementUi; /** Closes and optionally destroys the dock panel when it has no remaining tabs. */ private destroyDockIfUnused; /** * Re-resolves the toolbar mount after dock wrap/unwrap, which can detach a * stale `dock-main` host or change `canvas.parentElement`. */ private syncToolbarMountAfterDockChange; /** Updates toolbar placement. */ private applyToolbarPlacement; /** * Tears down UI, unregisters commands, and removes injected styles if unused. * * @param _context - Application context (unused). * @param commandManager - Command stack used to remove registered commands. */ onUnload(_context: AcApContext, commandManager: AcEdCommandStack): void; /** Sets {@link AcApI18n.currentLocale} to one of the supported locales. */ private setLocale; } /** * Factory for {@link AcApSimpleUiPlugin}. * * @param options - Plugin configuration. * @returns A new plugin instance ready for {@link AcApPluginManager.loadPlugin}. */ export declare function acuiCreateSimpleUiPlugin(options?: AcUiSimpleUiPluginOptions): AcApSimpleUiPlugin; //# sourceMappingURL=createSimpleUiPlugin.d.ts.map