feat: add clear button to autocomplete text widget and fix external value change sync

- Add clear button inside autocomplete text widget that shows when text exists
- Support both Canvas mode and Vue DOM mode with appropriate styling
- Fix clear button visibility when value is changed externally (e.g., via 'send lora to workflow')
- Implement dual notification mechanism: CustomEvent + onSetValue callback
- Update widget interface to include onSetValue property
This commit is contained in:
Will Miao
2026-02-06 09:15:16 +08:00
parent b313f36be9
commit 1606a3ff46
4 changed files with 317 additions and 53 deletions

View File

@@ -416,6 +416,14 @@ function createAutocompleteTextWidgetFactory(
setValue(v: string) {
if (widget.inputEl) {
widget.inputEl.value = v ?? ''
// Notify Vue component of value change via custom event
widget.inputEl.dispatchEvent(new CustomEvent('lora-manager:autocomplete-value-changed', {
detail: { value: v ?? '' }
}))
}
// Also call onSetValue if defined (for Vue component integration)
if (typeof widget.onSetValue === 'function') {
widget.onSetValue(v ?? '')
}
},
serialize: true,