Page MenuHomeSealhub

textarea.ts
No OneTemporary

textarea.ts

import { Context } from "koa";
import { FlatTemplatable, tempstream } from "tempstream";
import { attribute } from "../../sanitize";
import { getRequiredClass, inputWrapper } from "../../utils/input-wrapper";
import { FormField } from "../fields/field";
import { FormDataValue } from "../form";
import { FormFieldControl } from "./form-field-control";
export class Textarea extends FormFieldControl {
constructor(
public field: FormField,
public options: { label?: string; rows?: number; cols?: number } = {}
) {
super([field]);
}
async render(
ctx: Context,
data: Record<string, FormDataValue>
): Promise<FlatTemplatable> {
const { raw } = await this.field.getValue(ctx, data);
const { name, required } = this.field;
return inputWrapper(
[name, getRequiredClass(required)],
/* HTML */ ` <label for="${name}"
>${this.options.label != undefined
? this.options.label
: name}</label
>
<textarea
name="${name}"
id="${name}"
rows="${this.options.rows || 5}"
cols="${this.options.cols || 33}"
>
${attribute((raw || "").toString())}</textarea
>`
);
}
}

File Metadata

Mime Type
text/x-java
Expires
Tue, May 27, 23:47 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
704728
Default Alt Text
textarea.ts (1 KB)

Event Timeline