import _Input from "@alifd/next/es/input";
import React, { useState } from 'react';
var CommonInput = function CommonInput(_ref) {
  var value = _ref.value,
    maxLength = _ref.maxLength,
    placeholder = _ref.placeholder,
    defaultValue = _ref.defaultValue,
    isDisabled = _ref.isDisabled,
    hasLimitHint = _ref.hasLimitHint,
    _ref$isPreview = _ref.isPreview,
    isPreview = _ref$isPreview === void 0 ? false : _ref$isPreview,
    onChange = _ref.onChange;
  React.useEffect(function () {
    setValue(value);
  }, [value]);
  // const isEdit: any = !isPreview
  var _useState = useState(value),
    inputValue = _useState[0],
    setValue = _useState[1];
  var onInputChange = function onInputChange(value) {
    onChange && onChange(value);
    setValue(value);
  };
  return /*#__PURE__*/React.createElement(_Input, {
    hasClear: true,
    value: inputValue,
    defaultValue: defaultValue,
    maxLength: maxLength,
    placeholder: placeholder,
    disabled: isDisabled,
    hasLimitHint: hasLimitHint,
    isPreview: isPreview,
    onChange: function onChange(e) {
      return onInputChange(e);
    }
  });
};
CommonInput.displayName = 'CommonInput';
export default CommonInput;