Page MenuHomeSealhub

number.ts
No OneTemporary

number.ts

import { Context } from "koa";
import { FlatTemplatable } from "tempstream";
import { FormField, NumberField } from "../fields/field";
import { FormDataValue } from "../form";
import { FormControlContext } from "./form-control";
import { SimpleInput, SimpleInputOptions } from "./simple-input";
export type NumberOptions = SimpleInputOptions & Partial<{ step: number }>;
export class Number extends SimpleInput<number | null> {
field: NumberField;
options: NumberOptions;
constructor(field: NumberField, options: NumberOptions) {
super(field, options);
}
getType() {
return "number";
}
async getInputAttributes(
fctx: FormControlContext
): Promise<Record<string, string | boolean>> {
const original = await super.getInputAttributes(fctx);
return {
...original,
...Object.fromEntries([
...(this.field.options.min
? [["min", this.field.options.min]]
: []),
...(this.field.options.max
? [["max", this.field.options.max]]
: []),
...(this.options.step ? [["step", this.options.step]] : []),
]),
};
}
}

File Metadata

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

Event Timeline