import { NumberField } from "../fields/number.js"; import { FormControlContext } from "./form-control.js"; import { SimpleInput, SimpleInputOptions } from "./simple-input.js"; export type NumberOptions = SimpleInputOptions & Partial<{ step: number }>; export class Number extends SimpleInput { field: NumberField; options: NumberOptions; constructor(field: NumberField, options: NumberOptions) { super(field, options); } getType() { return "number"; } async getInputAttributes( fctx: FormControlContext ): Promise> { 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]] : []), ]), } as Record; } }