var _excluded = ["key", "name"];
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; }
import React from 'react';
import { Form, Space, Button } from 'antd';
import { MinusCircleOutlined } from '@ant-design/icons';
import Field from "../FieldComponent";
var CustomFormList = function CustomFormList(props) {
  var filedName = props.filedName,
    fieldName = props.fieldName,
    rules = props.rules;
  return /*#__PURE__*/React.createElement(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.createElement(React.Fragment, null, fields.map(function (_ref3) {
      var key = _ref3.key,
        name = _ref3.name,
        restField = _objectWithoutProperties(_ref3, _excluded);
      return /*#__PURE__*/React.createElement(Space, {
        key: key,
        align: "baseline"
      }, /*#__PURE__*/React.createElement(Form.Item, _extends({}, restField, {
        label: "\u9009\u9879\u503C",
        name: [name, 'optionValue'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/React.createElement(Field, {
        type: 'input'
      })), /*#__PURE__*/React.createElement(Form.Item, _extends({}, restField, {
        label: "\u9009\u9879\u540D\u79F0",
        name: [name, 'optionName'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/React.createElement(Field, {
        type: 'input'
      })), /*#__PURE__*/React.createElement(Form.Item, _extends({}, restField, {
        label: "\u5916\u90E8\u9009\u9879\u503C",
        name: [name, 'optionValueExtend'],
        rules: [{
          required: true,
          message: '请输入'
        }]
      }), /*#__PURE__*/React.createElement(Field, {
        type: 'input'
      })), /*#__PURE__*/React.createElement(MinusCircleOutlined, {
        onClick: function onClick() {
          return remove(name);
        }
      }));
    }), /*#__PURE__*/React.createElement(Button, {
      type: "dashed",
      onClick: function onClick() {
        return add();
      },
      block: true
    }, "+ \u6DFB\u52A0\u9009\u9879"), /*#__PURE__*/React.createElement(Form.ErrorList, {
      errors: errors
    }));
  });
};
export default CustomFormList;