import _Input from "@alifd/next/es/input";
import React, { useState } from 'react';
var CommonTextArea = function CommonTextArea(_ref) {
  var rows = _ref.rows,
    value = _ref.value,
    placeholder = _ref.placeholder,
    defaultValue = _ref.defaultValue,
    maxLength = _ref.maxLength,
    hasLimitHint = _ref.hasLimitHint,
    isDisabled = _ref.isDisabled,
    _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(_Input.TextArea, {
    rows: rows,
    value: inputValue,
    placeholder: placeholder,
    maxLength: maxLength,
    defaultValue: defaultValue,
    hasLimitHint: hasLimitHint,
    disabled: isDisabled,
    isPreview: isPreview,
    onChange: function onChange(e) {
      return onInputChange(e);
    }
  });
};
CommonTextArea.displayName = 'CommonTextArea';
export default CommonTextArea;