import InputAdornment from '@material-ui/core/InputAdornment'
import React, {FC} from 'react'
import type {TextFieldProps} from '../lib/TextFieldBase'
import {TextField} from '../TextField'

interface INumberFieldProps extends TextFieldProps {
  step?: string | number
}

export const NumberField: FC<INumberFieldProps> = ({
  step,
  endAdornment,
  inputProps,

  ...props
}) => (
  <TextField
    {...props}
    type="number"
    {...(step ? { inputProps: { step, ...inputProps } } : {})}
    endAdornment={endAdornment && <InputAdornment position="end">{endAdornment}</InputAdornment>}
  />
)

export default NumberField