import type { InputNumberProps as AntInputNumberProps } from 'antd';
import { Form, InputNumber as AntInputNumber } from 'antd';
import type { BaseElementProps } from './types';

const { Item: FormItem } = Form;

export default function InputNumber({
  setValue,
  status,
  isValid,
  help,
  ...props
}: BaseElementProps<number>) {
  return (
    <FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
      <AntInputNumber
        onChange={setValue}
        disabled={status === 'Disabled'}
        style={{
          width: '100%',
        }}
        {...props}
      />
    </FormItem>
  );
}

type InputNumberProps = AntInputNumberProps<number>;

export type { InputNumberProps };
