import { NumberInput } from '@mantine/core';
import { useOptionsContext } from './Options.context';

export function OptionNumberInput({ path, disabled = false, ...rest }) {
  const { getOptions, updateOptions } = useOptionsContext();

  const handleChange = value => {
    updateOptions(path, value);
  };

  return (
    <NumberInput
      size="xs"
      disabled={disabled}
      onChange={handleChange}
      value={getOptions(path)}
      {...rest}
    />
  );
}
