"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireWildcard(require("react"));
var _elementReact = require("element-react");
var _indexModule = _interopRequireDefault(require("./index.module.scss"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var EditorAdd = /*#__PURE__*/function (_Component) {
  (0, _inheritsLoose2["default"])(EditorAdd, _Component);
  function EditorAdd() {
    return _Component.apply(this, arguments) || this;
  }
  var _proto = EditorAdd.prototype;
  _proto.render = function render() {
    // eslint-disable-next-line react/prop-types
    var addFormIem = this.props.addFormIem;
    var contents = {
      base: [{
        type: 'input',
        label: '',
        pattern: '',
        icon: 'xt-tianxiexiang',
        required: false
      }, {
        type: 'radio',
        label: '',
        pattern: '',
        options: [{
          value: '选项',
          image: ''
        }],
        icon: 'xt-biaodan-danxuan',
        required: false
      }, {
        type: 'checkbox',
        label: '',
        pattern: '',
        options: [{
          value: '选项',
          image: ''
        }],
        icon: 'xt-biaodan-duoxuan',
        required: false
      }, {
        type: 'upload',
        label: '',
        pattern: '',
        icon: 'xt-gongjulan-xinzeng-chatu',
        required: false
      }, {
        type: 'address',
        label: '',
        pattern: '',
        icon: 'xt-location',
        required: false
      }],
      other: [{
        type: 'input',
        label: '姓名',
        pattern: '',
        required: false
      }, {
        type: 'input',
        label: '手机号',
        pattern: "" + new RegExp(/^1[3-57-9]\d{9}$/),
        required: false
      }, {
        type: 'input',
        label: '身份证号',
        pattern: "" + new RegExp(/^((11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|50|51|52|53|54|61|62|63|64|65|71|81|82|91)\d{4})(19|20)(\d{2}(((0[13578]|1[02])(0[1-9]|[12]\d|3[01]))|((0[469]|11)(0[1-9]|[12]\d|30))|(02(0[1-9]|1\d|2[0-8])))|000229)(\d{3}[\d|x])$/),
        required: false
      }, {
        type: 'input',
        label: '地址',
        pattern: '',
        required: false
      }, {
        type: 'radio',
        label: '性别',
        pattern: '',
        options: [{
          value: '男'
        }, {
          value: '女'
        }],
        required: false
      }, {
        type: 'input',
        label: '微信号',
        pattern: "" + new RegExp(/(^[a-z][-\w]{5,}$)|(^(\+\d{1,4})?(0?(1([3-57-9]\d)|(6[1-79]))(\d{4})(\d{4}))$)/i),
        required: false
      }, {
        type: 'input',
        label: '民族',
        pattern: '',
        required: false
      }]
    };
    var addFormItem = function addFormItem(item) {
      // 添加动态 key
      item.key = Date.now().toString(32) + Math.random().toString(32).slice(1);
      item.options && item.options.map(function (opt) {
        opt.key = Date.now().toString(32) + Math.random().toString(32).slice(1);
        return opt;
      });

      // 添加数据项
      addFormIem(item);
    };
    return /*#__PURE__*/_react["default"].createElement(_elementReact.Popover, {
      placement: "bottom",
      title: "\u65B0\u589E\u8868\u5355\u9879",
      width: "300",
      trigger: "click",
      className: _indexModule["default"]['editor-add'],
      content: /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['editor-add-content']
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['editor-base']
      }, contents.base.map(function (res, idx) {
        return /*#__PURE__*/_react["default"].createElement("span", {
          className: _indexModule["default"]['editor-base-item'] + " xiatu-rich " + res.icon,
          key: idx,
          onClick: function onClick() {
            return addFormItem(res);
          }
        });
      })), /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['editor-other']
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['editor-other-title']
      }, "\u6DFB\u52A0\u5E38\u7528\u586B\u5199\u4FE1\u606F"), /*#__PURE__*/_react["default"].createElement("div", {
        className: _indexModule["default"]['editor-other-list']
      }, contents.other.map(function (res, idx) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: _indexModule["default"]['editor-other-list-item'],
          key: idx,
          onClick: function onClick() {
            return addFormItem(res);
          }
        }, res.label);
      }))))
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: "xiatu-rich xt-xinzeng"
    }));
  };
  return EditorAdd;
}(_react.Component);
exports["default"] = EditorAdd;