import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _Upload from "@alifd/next/es/upload";
import _Form from "@alifd/next/es/form";
import _Icon from "@alifd/next/es/icon";
import _Input from "@alifd/next/es/input";
var _excluded = ["columnComment", "columnType", "columnKeyType", "columnKeyTypeEnum", "isOnlyRead", "isRequired", "defaultValue", "guideWords", "onClick"];
import React, { useState } from 'react';
import "./form-item.scss";
var Input = _Input,
  Icon = _Icon,
  Form = _Form,
  Upload = _Upload;
var Item = Form.Item;
var DCFormItem = function DCFormItem(_ref) {
  var columnComment = _ref.columnComment,
    columnType = _ref.columnType,
    columnKeyType = _ref.columnKeyType,
    columnKeyTypeEnum = _ref.columnKeyTypeEnum,
    isOnlyRead = _ref.isOnlyRead,
    isRequired = _ref.isRequired,
    defaultValue = _ref.defaultValue,
    guideWords = _ref.guideWords,
    _ref$onClick = _ref.onClick,
    onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _otherProps = otherProps || {};
  console.log();
  // 使用 useState 来管理输入框的值
  var _useState = useState(defaultValue),
    value = _useState[0],
    setValue = _useState[1];

  // 动态渲染内容
  var renderContent = function renderContent() {
    switch (columnKeyTypeEnum.name) {
      case '单行文本':
      case '联系人':
      case '手机':
      case '邮箱':
        // 文本框
        return /*#__PURE__*/React.createElement(Input, {
          value: value,
          placeholder: guideWords || '请输入',
          onChange: function onChange(v, e) {
            return setValue(e.target.value);
          },
          style: {
            textAlign: 'right'
          }
        });
      case '图片':
        return /*#__PURE__*/React.createElement(Upload.Card, {
          listType: "card",
          action: "https://www.easy-mock.com/mock/5b713974309d0d7d107a74a3/alifd/upload",
          accept: "image/png, image/jpg, image/jpeg, image/gif, image/bmp",
          reUpload: true,
          style: {
            width: '90px',
            height: '90px'
          }
        });
      case '多行文本':
        return /*#__PURE__*/React.createElement(Input.TextArea, {
          value: value,
          placeholder: guideWords || '请输入'
        });
      default:
        return /*#__PURE__*/React.createElement("span", null, guideWords || '未定义的类型');
    }
  };
  return /*#__PURE__*/React.createElement("div", {
    "class": "form-item"
  }, /*#__PURE__*/React.cloneElement(renderContent()));
};
var RefDCFormItem = /*#__PURE__*/React.forwardRef(DCFormItem);
RefDCFormItem.displayName = 'DCFormItem';
RefDCFormItem.defaultProps = {};
RefDCFormItem.propTypes = {};
export default RefDCFormItem;