summaryrefslogtreecommitdiff
path: root/packages/exchange-backoffice-ui/src/forms/InputInteger.tsx
blob: 49e6973fc7d3031fa35f7183f6f64f8c867ef76b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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}
    />
  );
}