import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { Component } from 'react';
import { Popover } from 'element-react';
import style from "./index.module.scss";
var EditorAdd = /*#__PURE__*/function (_Component) {
  _inheritsLoose(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.createElement(Popover, {
      placement: "bottom",
      title: "\u65B0\u589E\u8868\u5355\u9879",
      width: "300",
      trigger: "click",
      className: style['editor-add'],
      content: /*#__PURE__*/React.createElement("div", {
        className: style['editor-add-content']
      }, /*#__PURE__*/React.createElement("div", {
        className: style['editor-base']
      }, contents.base.map(function (res, idx) {
        return /*#__PURE__*/React.createElement("span", {
          className: style['editor-base-item'] + " xiatu-rich " + res.icon,
          key: idx,
          onClick: function onClick() {
            return addFormItem(res);
          }
        });
      })), /*#__PURE__*/React.createElement("div", {
        className: style['editor-other']
      }, /*#__PURE__*/React.createElement("div", {
        className: style['editor-other-title']
      }, "\u6DFB\u52A0\u5E38\u7528\u586B\u5199\u4FE1\u606F"), /*#__PURE__*/React.createElement("div", {
        className: style['editor-other-list']
      }, contents.other.map(function (res, idx) {
        return /*#__PURE__*/React.createElement("div", {
          className: style['editor-other-list-item'],
          key: idx,
          onClick: function onClick() {
            return addFormItem(res);
          }
        }, res.label);
      }))))
    }, /*#__PURE__*/React.createElement("span", {
      className: "xiatu-rich xt-xinzeng"
    }));
  };
  return EditorAdd;
}(Component);
export { EditorAdd as default };