Page MenuHomeSealhub

field-group.ts
No OneTemporary

Authored By
Unknown
Size
807 B
Referenced Files
None
Subscribers
None

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
application/javascript
Expires
Sat, Nov 28, 03:28 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1201115
Default Alt Text
field-group.ts (807 B)

Event Timeline