import { VNode, h } from "preact";
import { InputLine, UIFormProps } from "./InputLine.js";

export function InputInteger(props: UIFormProps<number>): VNode {
  return (
    <InputLine
      type="number"
      converter={{
        fromStringUI: (v) => {
          return !v ? 0 : Number.parseInt(v, 10);
        },
        toStringUI: (v?: number) => {
          return v === undefined ? "" : String(v);
        },
      }}
      {...props}
    />
  );
}
