UNPKG

@skillpet/circuit

Version:

Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components

67 lines (66 loc) 2.2 kB
import { type CircuitJson, type RenderOptions } from "./render.js"; import { type Theme } from "./theme.js"; import type { ElementInfo, DrawingInfo, EventMap } from "./types.js"; type EventName = keyof EventMap; /** * Interactive controller wrapping a rendered circuit SVG. * Created via {@link mountFromJson}. */ export declare class SchemdrawController { private _container; private _json; private _opts; private _svg; private _elementMap; private _listeners; private _selectedId; private _theme; private _destroyed; private _tooltipEl; private _autoObserver; private _mediaQuery; private _mediaHandler; private _boundClick; private _boundMouseover; private _boundMouseout; private _boundContextmenu; private _boundMousemove; constructor(container: HTMLElement, json: CircuitJson, opts: RenderOptions); private _isAutoTheme; private _initAutoTheme; private _teardownAutoTheme; private _render; private _initTooltip; private _applyTooltipTheme; private _showTooltip; private _hideTooltip; private _bindEvents; private _unbindEvents; private _closestGroup; private _svgPoint; private _getInfoForGroup; private _onClick; private _onMouseover; private _onMousemove; private _onMouseout; private _onContextmenu; private _clearSelectedClass; private _emit; on<K extends EventName>(event: K, handler: EventMap[K]): this; off<K extends EventName>(event: K, handler?: EventMap[K]): this; highlight(id: string, color?: string): void; clearHighlight(): void; setTheme(theme: string | Partial<Theme>): void; update(json: CircuitJson | string): void; destroy(): void; get svgElement(): SVGSVGElement; getElementInfo(id: string): ElementInfo | undefined; getAllElements(): ElementInfo[]; getDrawingInfo(): DrawingInfo; } /** * Mount a circuit JSON into a container element, returning an interactive controller. * Requires a browser environment with DOM access. */ export declare function mountFromJson(container: HTMLElement, json: CircuitJson | string, opts?: RenderOptions): SchemdrawController; export {};