From ad2b4207d48fe19e501e0fac2c1139ce7ef4dea1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 1 Aug 2023 18:40:35 +0200 Subject: submit ui --- frontend/helper.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'frontend/helper.ts') diff --git a/frontend/helper.ts b/frontend/helper.ts index f47d131..2ecfc35 100644 --- a/frontend/helper.ts +++ b/frontend/helper.ts @@ -5,6 +5,8 @@ interface Opts { id?: string, src?: string, for?: string, + type?: string, + href?: string, onclick?: (e: E) => void, onchange?: (e: E) => void, } @@ -14,6 +16,8 @@ function apply_opts(e: E, o: Opts) { if (o.onclick) e.onclick = () => o.onclick!(e) if (o.onchange) e.onchange = () => o.onchange!(e) if (o.for) (e as unknown as HTMLLabelElement).htmlFor = o.for + if (o.type && e instanceof HTMLInputElement) e.type = o.type + if (o.href && e instanceof HTMLAnchorElement) e.href = o.href; if (typeof o?.class == "string") e.classList.add(o.class) if (typeof o?.class == "object") e.classList.add(...o.class) } -- cgit v1.2.3-70-g09d2