"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

require("antd/es/form/style");

var _form = _interopRequireDefault(require("antd/es/form"));

var _react = _interopRequireDefault(require("react"));

var _hooks = require("@parallel-line/hooks");

var _input = _interopRequireDefault(require("../input"));

var _button = _interopRequireDefault(require("../button"));

var _select = _interopRequireDefault(require("../select"));

var _citySelect = _interopRequireDefault(require("../city-select"));

var _inputNumber = _interopRequireDefault(require("../input-number"));

var _DateRangePicker = _interopRequireDefault(require("../table/DateRangePicker"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var FormFilter = function FormFilter(props) {
  var form = props.form,
      filter = props.filter,
      loading = props.loading,
      onSubmit = props.onSubmit,
      onReset = props.onReset;
  var prefixCls = "".concat(props.prefixCls, "-pro-table-form");
  var renderFormItem = (0, _hooks.useMemoDeep)(function () {
    var componentMap = {
      Text: _input.default,
      Enum: _select.default,
      Tag: _input.default,
      Date: _DateRangePicker.default,
      Link: _input.default,
      City: _citySelect.default,
      Number: _input.default,
      Numbering: _inputNumber.default
    };
    var formItem = filter.map(function (item) {
      var Component = componentMap[item.type];
      if (Component == null) return null;
      return /*#__PURE__*/_react.default.createElement(_form.default.Item, {
        key: item.name,
        name: item.name,
        label: item.label
      }, /*#__PURE__*/_react.default.createElement(Component, Object.assign({}, item.props)));
    });
    return formItem;
  }, [filter]);
  return /*#__PURE__*/_react.default.createElement(_form.default, {
    colon: false,
    layout: "inline",
    form: form,
    className: prefixCls
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefixCls, "-items")
  }, renderFormItem), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefixCls, "-buttons")
  }, /*#__PURE__*/_react.default.createElement(_button.default, {
    onClick: onReset,
    loading: loading
  }, "\u91CD\u7F6E"), /*#__PURE__*/_react.default.createElement(_button.default, {
    type: "primary",
    loading: loading,
    onClick: onSubmit
  }, "\u67E5\u8BE2")));
};

FormFilter.defaultProps = {
  prefixCls: 'pxx',
  filter: []
};
var _default = FormFilter;
exports.default = _default;