Page MenuHomeSealhub

checkbox.ts
No OneTemporary

checkbox.ts

import { Context } from "koa";
import { FormDataValue } from "../form-types.js";
import { Tickable, TickableOptions } from "./tickable.js";
import { FormField } from "../fields/field.js";
export class Checkbox extends Tickable<boolean> {
type = <const>"checkbox";
constructor(
public field: FormField<boolean, boolean>,
options: Partial<TickableOptions<boolean>> = {}
) {
super(field, {
...options,
default_value:
options.default_value == undefined
? false
: options.default_value,
});
}
isChecked(
_ctx: Context,
_data: Record<string, FormDataValue>,
value: boolean
): boolean {
return value;
}
getValueAttribute(): string {
return "";
}
}
export class CheckboxWithValue extends Checkbox {
constructor(
public field: FormField<boolean, boolean>,
options: TickableOptions<boolean>,
public value: string
) {
super(field, options);
}
getValueAttribute(): string {
return this.value;
}
}

File Metadata

Mime Type
text/x-java
Expires
Wed, May 7, 19:41 (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625151
Default Alt Text
checkbox.ts (953 B)

Event Timeline