Page MenuHomeSealhub

component-input-structured.ts
No OneTemporary

component-input-structured.ts

import type { Context } from "koa";
import type { ComponentArgument, JDDContext, Structured } from "@sealcode/jdd";
import type { StatefulPage } from "@sealcode/sealgen";
import { ComponentInput } from "./component-input.js";
import type { JDDPageState } from "../jdd-page.js";
import type { ComponentPreviewActions } from "../component-preview-actions.js";
export async function ComponentInputStructured<
T extends Structured<Record<string, ComponentArgument<unknown>>>
>({
state,
ctx,
arg_path,
arg,
value,
page,
...rest
}: {
state: JDDPageState;
ctx: Context;
arg_path: string[];
arg: T;
value: Record<string, unknown>;
page: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;
makeJDDContext: (ctx: Context) => JDDContext;
makeAssetURL: (asset: string) => string;
}) {
return /* HTML */ `<fieldset
id="${`component-input-structured-${arg_path.join("-")}`}"
>
<legend>{arg_path.at(-1)}</legend>
${(
await Promise.all(
Object.entries(arg.structure).map(async ([arg_name, arg]) => {
const ret = `<div>
${await ComponentInput({
ctx,
state,
arg_path: [...arg_path, arg_name],
arg,
value: value[arg_name],
page,
...rest,
})}
</div>`;
return ret;
})
)
).join("")}
</fieldset>`;
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Dec 24, 14:05 (12 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557294
Default Alt Text
component-input-structured.ts (1 KB)

Event Timeline