diff --git a/renderers/lit/src/0.8/ui/root.ts b/renderers/lit/src/0.8/ui/root.ts index de5f357e9..03499e382 100644 --- a/renderers/lit/src/0.8/ui/root.ts +++ b/renderers/lit/src/0.8/ui/root.ts @@ -30,7 +30,7 @@ import { map } from "lit/directives/map.js"; import { effect } from "signal-utils/subtle/microtask-effect"; import { A2uiMessageProcessor } from "@a2ui/web_core/data/model-processor"; import { StringValue } from "@a2ui/web_core/types/primitives"; -import { AnyComponentNode, SurfaceID, Theme } from "@a2ui/web_core/types/types"; +import { AnyComponentNode, DataValue, SurfaceID, Theme } from "@a2ui/web_core/types/types"; import { themeContext } from "./context/theme.js"; import { structuralStyles } from "./styles.js"; import { componentRegistry } from "./component-registry.js"; @@ -76,6 +76,19 @@ export class Root extends SignalWatcher(LitElement) { #weight: string | number = 1; + protected updateBoundData(relativePath: string, value: DataValue) { + if (!this.processor) { + return; + } + this.processor.setData( + this.component, + relativePath, + value, + this.surfaceId ?? A2uiMessageProcessor.DEFAULT_SURFACE_ID + ); + this.requestUpdate(); + } + static styles = [ structuralStyles, css` diff --git a/renderers/lit/src/0.8/ui/slider.ts b/renderers/lit/src/0.8/ui/slider.ts index 791279a71..994813b76 100644 --- a/renderers/lit/src/0.8/ui/slider.ts +++ b/renderers/lit/src/0.8/ui/slider.ts @@ -19,7 +19,6 @@ import { customElement, property } from "lit/decorators.js"; import { Root } from "./root.js"; import { A2uiMessageProcessor } from "@a2ui/web_core/data/model-processor"; import * as Primitives from "@a2ui/web_core/types/primitives"; -import * as Types from "@a2ui/web_core/types/types"; import { classMap } from "lit/directives/class-map.js"; import { styleMap } from "lit/directives/style-map.js"; import { structuralStyles } from "./styles.js"; @@ -62,24 +61,10 @@ export class Slider extends Root { ]; #setBoundValue(value: string) { - if (!this.value || !this.processor) { + if (!this.value || !("path" in this.value) || !this.value.path) { return; } - - if (!("path" in this.value)) { - return; - } - - if (!this.value.path) { - return; - } - - this.processor.setData( - this.component, - this.value.path, - value, - this.surfaceId ?? A2uiMessageProcessor.DEFAULT_SURFACE_ID - ); + this.updateBoundData(this.value.path, value); } #renderField(value: string | number) {