import React from 'react';
import { Input } from 'antd';
import { useTextInputState } from '@pisell/utils';
/**
 * PisellSingleLineText 编辑态视图组件
 * 
 * 负责渲染编辑态的输入框，基于 Ant Design Input 组件
 * 
 * 功能：
 * - 文本输入
 * - 实时或失焦校验
 * - 错误提示展示
 * - 字数统计
 * - 清空按钮
 * - 前后缀、前后置标签
 * 
 * @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;
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-single-line-text-edit"
  }, /*#__PURE__*/React.createElement(Input, {
    value: value,
    onChange: function onChange(e) {
      return handleChange(e.target.value);
    },
    onBlur: handleBlur,
    onFocus: handleFocus,
    onPressEnter: function onPressEnter(e) {
      var _props$onPressEnter;
      return (_props$onPressEnter = props.onPressEnter) === null || _props$onPressEnter === void 0 ? void 0 : _props$onPressEnter.call(props, e.currentTarget.value);
    },
    placeholder: props.placeholder,
    maxLength: props.maxLength,
    showCount: props.showCount,
    allowClear: props.allowClear,
    prefix: props.prefix,
    suffix: props.suffix,
    addonBefore: props.addonBefore,
    addonAfter: props.addonAfter,
    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-single-line-text-error"
  }, errors[0]));
};
export default EditView;