import React from 'react';
import { Input } from 'antd';
import { useTextInputState } from '@pisell/utils';
var TextArea = Input.TextArea;

/**
 * PisellLongText 编辑态视图组件
 * 
 * 负责渲染编辑态的多行输入框，基于 Ant Design TextArea 组件
 * 
 * 功能：
 * - 多行文本输入
 * - 自动高度调整（autoSize）
 * - 实时或失焦校验
 * - 错误提示展示
 * - 字数统计
 * - 清空按钮
 * 
 * @param props 组件 Props
 */
var EditView = function EditView(props) {
  var _useTextInputState = useTextInputState(props),
    value = _useTextInputState.value,
    isValid = _useTextInputState.isValid,
    errors = _useTextInputState.errors,
    handleChange = _useTextInputState.handleChange,
    handleBlur = _useTextInputState.handleBlur,
    handleFocus = _useTextInputState.handleFocus;

  // 计算 autoSize 配置
  var autoSizeConfig = props.autoSize ? props.autoSize : props.minRows || props.maxRows ? {
    minRows: props.minRows,
    maxRows: props.maxRows
  } : false;
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-long-text-edit"
  }, /*#__PURE__*/React.createElement(TextArea, {
    value: value,
    onChange: function onChange(e) {
      return handleChange(e.target.value);
    },
    onBlur: handleBlur,
    onFocus: handleFocus,
    onPressEnter: props.onPressEnter,
    placeholder: props.placeholder,
    maxLength: props.maxLength,
    showCount: props.showCount,
    allowClear: props.allowClear,
    rows: props.rows || 3,
    autoSize: autoSizeConfig,
    disabled: props.disabled,
    autoFocus: props.autoFocus,
    status: isValid ? undefined : 'error',
    className: props.className,
    style: props.style,
    "aria-label": props['aria-label'],
    "aria-describedby": props['aria-describedby']
  }), !isValid && errors.length > 0 && /*#__PURE__*/React.createElement("div", {
    className: "pisell-long-text-error"
  }, errors[0]));
};
export default EditView;