From 19a23409daf78ec0331dbb129fd4db231163eff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Erbsh=C3=A4u=C3=9Fer?= Date: Sun, 24 May 2026 09:31:07 +0200 Subject: [PATCH] add input component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Erbshäußer --- frontend/src/components/input.njk | 59 +++++++++++++++++++++++++++++++ frontend/src/components/input.ts | 34 ++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 frontend/src/components/input.njk create mode 100644 frontend/src/components/input.ts diff --git a/frontend/src/components/input.njk b/frontend/src/components/input.njk new file mode 100644 index 0000000..feaebda --- /dev/null +++ b/frontend/src/components/input.njk @@ -0,0 +1,59 @@ + + + diff --git a/frontend/src/components/input.ts b/frontend/src/components/input.ts new file mode 100644 index 0000000..44e078e --- /dev/null +++ b/frontend/src/components/input.ts @@ -0,0 +1,34 @@ +import {TesoftComponent} from "../scripts/main.ts"; + +export class TesoftInput extends TesoftComponent { + private readonly input: HTMLInputElement; + + constructor() { + super(); + + const template = document.getElementById("tesoft-input-template") as HTMLTemplateElement; + const templateContent = template.content; + + const shadowRoot = this.attachShadow({mode: "open"}); + shadowRoot.appendChild(templateContent.cloneNode(true)); + + this.input = shadowRoot.querySelector("input")!; + + this.input.addEventListener("focusin", () => { + this.setAttribute("focused", ""); + }); + this.input.addEventListener("focusout", () => { + this.removeAttribute("focused"); + }); + } + + focus() { + this.input.focus(); + } + + set value(value: string) { + this.input.value = value; + } +} + +customElements.define("tesoft-input", TesoftInput);