Page MenuHomeSealhub

field-group.ts
No OneTemporary

field-group.ts

import { Context } from "koa";
import { FlatTemplatable, tempstream } from "tempstream";
import { FormDataValue } from "../form";
import { FormControl } from "./form-control";
export class FieldGroup extends FormControl {
constructor(
public controls: FormControl[],
public options: { label?: string; classes?: string } = {}
) {
super();
}
async render(
ctx: Context,
data: Record<string, FormDataValue>
): Promise<FlatTemplatable> {
const { label, classes } = this.options;
return tempstream/* HTML */ `
<div class="field-group ${classes || ""}">
${label ? `<label>${label}</label>` : ""}
<div class="field-group__fields">
${this.controls.map((control) =>
control.render(ctx, data, [], "", "")
)}
</div>
</div>
`;
}
role = <const>"decoration";
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Sep 20, 14:20 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
929900
Default Alt Text
field-group.ts (807 B)

Event Timeline