import React from 'react';
import { InputNumber } from 'antd';
import { useNumberInputState } from '@pisell/utils';
/**
 * PisellNumber 编辑态视图组件
 * 
 * 负责渲染编辑态的输入框，基于 Ant Design InputNumber 组件
 * 
 * 功能：
 * - 数值输入
 * - 实时或失焦校验
 * - 错误提示展示
 * - 步进器调节
 * - 前后缀、前后置标签
 * 
 * @param props 组件 Props
 */
var EditView = function EditView(props) {
  var min = props.min,
    max = props.max,
    step = props.step,
    precision = props.precision,
    formatter = props.formatter,
    parser = props.parser,
    _props$placeholder = props.placeholder,
    placeholder = _props$placeholder === void 0 ? '请输入数字' : _props$placeholder,
    prefix = props.prefix,
    suffix = props.suffix,
    addonBefore = props.addonBefore,
    addonAfter = props.addonAfter,
    disabled = props.disabled,
    autoFocus = props.autoFocus,
    size = props.size,
    keyboard = props.keyboard,
    controls = props.controls,
    className = props.className,
    style = props.style,
    ariaLabel = props['aria-label'],
    ariaDescribedBy = props['aria-describedby'],
    id = props.id,
    name = props.name,
    _onPressEnter = props.onPressEnter;

  // 使用状态管理 hook
  var _useNumberInputState = useNumberInputState(props),
    value = _useNumberInputState.value,
    isValid = _useNumberInputState.isValid,
    errors = _useNumberInputState.errors,
    handleChange = _useNumberInputState.handleChange,
    handleBlur = _useNumberInputState.handleBlur,
    handleFocus = _useNumberInputState.handleFocus;
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-number pisell-number-edit ".concat(className || '')
  }, /*#__PURE__*/React.createElement(InputNumber, {
    value: value !== null && value !== void 0 ? value : undefined,
    onChange: handleChange,
    onBlur: handleBlur,
    onFocus: handleFocus,
    onPressEnter: function onPressEnter() {
      return _onPressEnter === null || _onPressEnter === void 0 ? void 0 : _onPressEnter(value !== null && value !== void 0 ? value : null);
    },
    min: min,
    max: max,
    step: step,
    precision: precision,
    formatter: formatter,
    parser: parser,
    placeholder: placeholder,
    prefix: prefix,
    addonBefore: addonBefore,
    addonAfter: addonAfter,
    disabled: disabled,
    autoFocus: autoFocus,
    size: size,
    keyboard: keyboard,
    controls: controls,
    status: isValid ? undefined : 'error',
    style: style,
    "aria-label": ariaLabel,
    "aria-describedby": ariaDescribedBy,
    id: id,
    name: name
  }), !isValid && errors.length > 0 && /*#__PURE__*/React.createElement("div", {
    className: "pisell-number-error"
  }, errors[0]));
};
export default EditView;