"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _upload = _interopRequireDefault(require("@alifd/next/lib/upload"));
var _form = _interopRequireDefault(require("@alifd/next/lib/form"));
var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _react = _interopRequireWildcard(require("react"));
require("./form-item.scss");
var _excluded = ["columnComment", "columnType", "columnKeyType", "columnKeyTypeEnum", "isOnlyRead", "isRequired", "defaultValue", "guideWords", "onClick"];
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var Input = _input["default"],
  Icon = _icon["default"],
  Form = _form["default"],
  Upload = _upload["default"];
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 = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _otherProps = otherProps || {};
  console.log();
  // 使用 useState 来管理输入框的值
  var _useState = (0, _react.useState)(defaultValue),
    value = _useState[0],
    setValue = _useState[1];

  // 动态渲染内容
  var renderContent = function renderContent() {
    switch (columnKeyTypeEnum.name) {
      case '单行文本':
      case '联系人':
      case '手机':
      case '邮箱':
        // 文本框
        return /*#__PURE__*/_react["default"].createElement(Input, {
          value: value,
          placeholder: guideWords || '请输入',
          onChange: function onChange(v, e) {
            return setValue(e.target.value);
          },
          style: {
            textAlign: 'right'
          }
        });
      case '图片':
        return /*#__PURE__*/_react["default"].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["default"].createElement(Input.TextArea, {
          value: value,
          placeholder: guideWords || '请输入'
        });
      default:
        return /*#__PURE__*/_react["default"].createElement("span", null, guideWords || '未定义的类型');
    }
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    "class": "form-item"
  }, /*#__PURE__*/_react["default"].cloneElement(renderContent()));
};
var RefDCFormItem = /*#__PURE__*/_react["default"].forwardRef(DCFormItem);
RefDCFormItem.displayName = 'DCFormItem';
RefDCFormItem.defaultProps = {};
RefDCFormItem.propTypes = {};
var _default = exports["default"] = RefDCFormItem;