Allow to restore the selection by setting the value.

This commit is contained in:
2025-11-08 17:35:22 +01:00
parent 64ba82fc9d
commit 840a4e8d89
2 changed files with 11 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@tp/tp-multi-toggle",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"main": "tp-multi-toggle.js",
"scripts": {

View File

@@ -62,6 +62,16 @@ class TpMultiToggle extends FormElement(LitElement) {
}
}
set value(val) {
this.querySelectorAll('tp-button').forEach(el => {
if (el.getAttribute(this.attr || 'id') === val) {
el.setAttribute('selected', '');
} else {
el.removeAttribute('selected');
}
});
}
constructor() {
super();
this.boundClick = this.onClick.bind(this);