"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _antd = require("antd");
var _icons = require("@ant-design/icons");
var _FieldComponent = _interopRequireDefault(require("../FieldComponent"));
var _excluded = ["key", "name"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var CustomFormList = function CustomFormList(props) {
  var filedName = props.filedName,
    fieldName = props.fieldName,
    rules = props.rules;
  return /*#__PURE__*/_react.default.createElement(_antd.Form.List, {
    name: filedName || fieldName,
    rules: rules
  }, function (fields, _ref, _ref2) {
    var add = _ref.add,
      remove = _ref.remove;
    var errors = _ref2.errors;
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, fields.map(function (_ref3) {
      var key = _ref3.key,
        name = _ref3.name,
        restField = _objectWithoutProperties(_ref3, _excluded);
      return /*#__PURE__*/_react.default.createElement(_antd.Space, {
        key: key,
        align: "baseline"
      }, /*#__PURE__*/_react.default.createElement(_antd.Form.Item, _extends({}, restField, {
        label: "\u9009\u9879\u503C",
        name: [name, 'optionValue'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/_react.default.createElement(_FieldComponent.default, {
        type: 'input'
      })), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, _extends({}, restField, {
        label: "\u9009\u9879\u540D\u79F0",
        name: [name, 'optionName'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/_react.default.createElement(_FieldComponent.default, {
        type: 'input'
      })), /*#__PURE__*/_react.default.createElement(_antd.Form.Item, _extends({}, restField, {
        label: "\u5916\u90E8\u9009\u9879\u503C",
        name: [name, 'optionValueExtend'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/_react.default.createElement(_FieldComponent.default, {
        type: 'input'
      })), /*#__PURE__*/_react.default.createElement(_icons.MinusCircleOutlined, {
        onClick: function onClick() {
          return remove(name);
        }
      }));
    }), /*#__PURE__*/_react.default.createElement(_antd.Button, {
      type: "dashed",
      onClick: function onClick() {
        return add();
      },
      block: true
    }, "+ \u6DFB\u52A0\u9009\u9879"), /*#__PURE__*/_react.default.createElement(_antd.Form.ErrorList, {
      errors: errors
    }));
  });
};
var _default = exports.default = CustomFormList;