diff --git a/web_source/src/lib/InspectorInput.svelte b/web_source/src/lib/InspectorInput.svelte index 0b0e037..64b2047 100644 --- a/web_source/src/lib/InspectorInput.svelte +++ b/web_source/src/lib/InspectorInput.svelte @@ -59,17 +59,18 @@ /> {/if} {:else if item.type === 'BOOLEAN'} + {@const isChecked = value === true || value === 'true' || value === 1 || value === '1'} {:else if item.type === 'COLOR'} | null = null private props = createPanelProps() private sidebarMode = false + private listening = false constructor() { // Don't mount automatically - wait for renderInto or show + this.setupChangeListener() + } + + /** + * Listen for API changes and update panel reactively + */ + private setupChangeListener(): void { + if (this.listening) return + this.listening = true + + window.addEventListener(MTB_API_CHANGED_EVENT, () => { + // Debounce updates slightly + requestAnimationFrame(() => { + this.updateContent() + }) + }) } /** diff --git a/web_source/src/mtb_api/widget-manager.ts b/web_source/src/mtb_api/widget-manager.ts index 71da4c5..2177dbd 100644 --- a/web_source/src/mtb_api/widget-manager.ts +++ b/web_source/src/mtb_api/widget-manager.ts @@ -8,6 +8,7 @@ import { $el } from '@/scripts/ui' import * as shared from '@mtb/shared' import { API_COLOR, OUTPUT_COLOR } from './constants' import { API_INPUT_TYPES, type APIInputType, type APINodeSettings, type MTBNode } from './types' +import { notifyAPIChanged } from './panel.svelte' import CSS from './api_nodes.css?inline' declare const LiteGraph: { @@ -199,6 +200,7 @@ export class APISettingsWidgetManager { }) contentContainer.classList.add('mtb_api_disabled') } + notifyAPIChanged() }) const title = document.createElement('span') @@ -236,6 +238,7 @@ export class APISettingsWidgetManager { this.applySettings(node, { inputs: { [widget.name]: { type: typeSelect.value as APIInputType } }, }) + notifyAPIChanged() }) // Name input @@ -252,6 +255,7 @@ export class APISettingsWidgetManager { this.applySettings(node, { inputs: { [widget.name]: { name: nameInput.value } }, }) + notifyAPIChanged() }) const separator = document.createElement('hr')