import _NumberPicker from "@alifd/next/es/number-picker";
import React, { useState } from 'react';
var CommonNumberInput = function CommonInput(_ref) {
  var value = _ref.value,
    defaultValue = _ref.defaultValue,
    isDisabled = _ref.isDisabled,
    precision = _ref.precision,
    _ref$isPreview = _ref.isPreview,
    isPreview = _ref$isPreview === void 0 ? false : _ref$isPreview,
    onChange = _ref.onChange;
  React.useEffect(function () {
    setValue(value);
  }, [value]);
  var _useState = useState(value),
    inputValue = _useState[0],
    setValue = _useState[1];
  var onInputChange = function onInputChange(value) {
    onChange && onChange(value);
    setValue(value);
  };
  return /*#__PURE__*/React.createElement(_NumberPicker, {
    value: inputValue,
    defaultValue: defaultValue,
    disabled: isDisabled,
    precision: precision,
    isPreview: isPreview,
    onChange: function onChange(e) {
      return onInputChange(e);
    }
  });
};
CommonNumberInput.displayName = 'CommonNumberInput';
export default CommonNumberInput;