Page MenuHomeSealhub

radio.ts
No OneTemporary

radio.ts

import { Context } from "koa";
import { FormField } from "../fields/field.js";
import { FormDataValue } from "../form-types.js";
import { Tickable } from "./tickable.js";
export class Radio extends Tickable<string> {
type = <const>"radio";
constructor(
public field: FormField<boolean, string>,
public value: string,
options: { label?: string }
) {
super(field, { default_value: "", ...options });
}
makeInputID(): string {
return this.field.name + "-" + this.value.replaceAll(/\W/g, "-");
}
getValueAttribute(): string {
return this.value;
}
getWrapperClasses(
ctx: Context,
data: Record<string, FormDataValue>,
value: string
): string[] {
return [
...super.getWrapperClasses(ctx, data, value),
this.value.replaceAll(/\W/g, "-"),
];
}
isChecked(
_ctx: Context,
_data: Record<string, FormDataValue>,
value: string
): boolean {
return this.value === value;
}
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Jul 8, 07:53 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625612
Default Alt Text
radio.ts (916 B)

Event Timeline