import { Component, ElementRef, Input, OnInit, OnDestroy, ViewChild, AfterViewInit, } from "@angular/core"; import { getWidget } from "../core/registry"; @Component({ selector: "halo-widget", template: "
", standalone: true, }) export class WidgetComponent implements AfterViewInit, OnDestroy { @ViewChild("container", { static: false }) container!: ElementRef; @Input() widgetId!: string; @Input() config!: Record; private instance: { destroy?: () => void } | null = null; ngAfterViewInit() { if (!this.container?.nativeElement) return; const widget = getWidget(this.widgetId); const result = widget.init(this.container.nativeElement, this.config); this.instance = result || null; } ngOnDestroy() { this.instance?.destroy?.(); } }