Page MenuHomeSealhub

component-input-enum.ts
No OneTemporary

Authored By
Unknown
Size
861 B
Referenced Files
None
Subscribers
None

component-input-enum.ts

import type { Enum, JDDContext } from "@sealcode/jdd";
import { printArgPath } from "./print-arg-path.js";
import { htmlEscape } from "escape-goat";
export async function ComponentInputEnum<
State,
S extends string,
T extends Enum<S>,
>({
arg_path,
arg,
value,
jdd_context,
state,
}: {
state: State;
arg_path: string[];
arg: T;
value: string;
jdd_context: JDDContext;
}) {
return /* HTML */ `<div id=${`component-input-enum-${arg_path.join("-")}`}>
<label>
${arg_path.at(-1) || ""}
<select
name="${`$${printArgPath(arg_path)}`}"
data-controller="autosubmit"
>
${(await arg.getValues(jdd_context))
.map(
(v: S) =>
/* HTML */ `<option
value="${htmlEscape(v)}"
${value == v ? "selected" : ""}
>
${v}
</option>`
)
.join("")}
</select>
</label>
</div>`;
}

File Metadata

Mime Type
application/javascript
Expires
Fri, Nov 27, 18:17 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1214239
Default Alt Text
component-input-enum.ts (861 B)

Event Timeline