import React from "react";
import { useTextInputState } from "@pisell/utils";
import { Input } from "antd";
//#region src/components/pisellSingleLineText/components/EditView.tsx
/**
* PisellSingleLineText 编辑态视图组件
* 
* 负责渲染编辑态的输入框，基于 Ant Design Input 组件
* 
* 功能：
* - 文本输入
* - 实时或失焦校验
* - 错误提示展示
* - 字数统计
* - 清空按钮
* - 前后缀、前后置标签
* 
* @param props 组件 Props
*/
const EditView = (props) => {
	const { value, isValid, errors, handleChange, handleBlur, handleFocus } = useTextInputState(props);
	return /* @__PURE__ */ React.createElement("div", { className: "pisell-single-line-text-edit" }, /* @__PURE__ */ React.createElement(Input, {
		value,
		onChange: (e) => handleChange(e.target.value),
		onBlur: handleBlur,
		onFocus: handleFocus,
		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 ? void 0 : "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]));
};
//#endregion
export { EditView as default };
