Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions renderers/lit/src/0.8/ui/text-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ export class TextField extends Root {
return;
}

this.dispatchEvent(
Comment thread
dmandar marked this conversation as resolved.
new CustomEvent("a2ui-validation-input", {
Comment thread
dmandar marked this conversation as resolved.
Outdated
bubbles: true,
composed: true,
detail: {
componentId: this.id,
value: evt.target.value,
valid: evt.target.checkValidity(),
},
})
);
Comment thread
dmandar marked this conversation as resolved.

this.#setBoundValue(evt.target.value);
}}
name="data"
Expand Down
24 changes: 24 additions & 0 deletions samples/client/lit/component_gallery/component-gallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,40 @@ export class A2UIComponentGallery extends SignalWatcher(LitElement) {

async connectedCallback() {
super.connectedCallback();
this.addEventListener("a2ui-validation-input", this.#handleValidationInput);
await this.#initiateSession();
}

override disconnectedCallback() {
super.disconnectedCallback();
this.removeEventListener("a2ui-validation-input", this.#handleValidationInput);
}

async #initiateSession() {
const message: v0_8.Types.A2UIClientEventMessage = {
request: "START_GALLERY"
};
await this.#sendAndProcessMessage(message);
}

// Debug Validation Events
#handleValidationInput = (e: Event) => {
const detail = (e as CustomEvent).detail;
Comment thread
dmandar marked this conversation as resolved.
Outdated

// Log to Console
console.log(
`%c[Validation] Component: ${detail.componentId} | Valid: ${detail.valid} | Value: "${detail.value}"`,
detail.valid ? "color: green" : "color: red; font-weight: bold"
);

// Log to Debug Panel
this.#log(
"info",
`Validation: ${detail.componentId} is ${detail.valid ? "VALID" : "INVALID"}`,
detail
);
Comment thread
dmandar marked this conversation as resolved.
Outdated
};

render() {
return html`
<header>
Expand Down
Loading