import { TextField as MuiTextField } from '@mui/material';
import { FieldComponentProps } from '../../types/overrides';

export default function NumberField({ field, value, onChange, disabled }: FieldComponentProps) {
  return (
    <MuiTextField
      fullWidth
      label={field.label}
      type="number"
      value={value === undefined || value === null ? '' : value}
      onChange={(e) => onChange(e.target.value === '' ? '' : Number(e.target.value))}
      disabled={disabled}
      required={field.required}
    />
  );
}
