import type { BaseContext } from "koa"; import { TempstreamJSX } from "tempstream"; import type { ComponentArgument, List } from "@sealcode/jdd"; import type { JDDPageState } from "./jdd-page.js"; import type { StatefulPage } from "@sealcode/sealgen"; import { ComponentInput } from "./component-input.js"; import type { ComponentPreviewActions } from "./component-preview-actions.js"; export async function ComponentInputList< State extends JDDPageState, T extends ComponentArgument >({ state, ctx, arg_path, arg, value, page, }: { state: State; ctx: BaseContext; arg_path: string[]; // eslint-disable-next-line @typescript-eslint/no-explicit-any arg: List; value: T[]; page: StatefulPage; }): Promise { if (!value) { value = []; } return (
{arg_path.at(-1)} {value.map((value, i) => (
{page.makeActionButton( state, { action: "remove_array_item", label: "❌" }, arg_path, i )}
))} {page.makeActionButton( state, { action: "add_array_item", label: "➕", }, arg_path )}
); }