import { Input } from '@citric/core'
import { FieldComponent } from '../../form/types'

export const IntField: FieldComponent<number, Record<string, never>> = ({ name, onChange, value, disabled, onBlur }) => (
  <Input
    type="number"
    value={value}
    onChange={e => onChange(e.target.value ? parseInt(e.target.value) : undefined)}
    name={name}
    disabled={disabled}
    onBlur={onBlur}
  />
)
