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 { type = "checkbox"; constructor( public field: FormField, options: Partial> = {} ) { super(field, { ...options, default_value: options.default_value == undefined ? false : options.default_value, }); } isChecked( _ctx: Context, _data: Record, value: boolean ): boolean { return value; } getValueAttribute(): string { return ""; } } export class CheckboxWithValue extends Checkbox { constructor( public field: FormField, options: TickableOptions, public value: string ) { super(field, options); } getValueAttribute(): string { return this.value; } }