aboutsummaryrefslogtreecommitdiff
path: root/static/widgets/editable/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/widgets/editable/index.js')
-rw-r--r--static/widgets/editable/index.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/static/widgets/editable/index.js b/static/widgets/editable/index.js
index 8a72aff..0c93c4e 100644
--- a/static/widgets/editable/index.js
+++ b/static/widgets/editable/index.js
@@ -13,6 +13,8 @@ export default class Editable extends sfw.element.Container {
constructor() {
super({ css });
+ this.onupdate = () => {};
+
this.body.append(
Div.new({
id: 'container',
@@ -24,6 +26,7 @@ export default class Editable extends sfw.element.Container {
if (e.key === 'Enter') {
this.#input.readOnly = true;
this.#update()
+ this.onupdate();
}
},
}),
@@ -33,6 +36,10 @@ export default class Editable extends sfw.element.Container {
onclick: () => {
this.#input.readOnly = !this.#input.readOnly;
this.#update();
+
+ if (this.#input.readOnly) {
+ this.onupdate();
+ }
}
}),
],
@@ -59,6 +66,10 @@ export default class Editable extends sfw.element.Container {
this.#input.value = value;
}
+ get value() {
+ return this.#input.value;
+ }
+
set type(type) {
this.#input.type = type;
}