import "antd/es/form/style";
import _Form from "antd/es/form";
import React from 'react';
import { useMemoDeep } from '@parallel-line/hooks';
import Input from '../input';
import Button from '../button';
import Select from '../select';
import CitySelect from '../city-select';
import InputNumber from '../input-number';
import DateRangePicker from '../table/DateRangePicker';

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 = useMemoDeep(function () {
    var componentMap = {
      Text: Input,
      Enum: Select,
      Tag: Input,
      Date: DateRangePicker,
      Link: Input,
      City: CitySelect,
      Number: Input,
      Numbering: InputNumber
    };
    var formItem = filter.map(function (item) {
      var Component = componentMap[item.type];
      if (Component == null) return null;
      return /*#__PURE__*/React.createElement(_Form.Item, {
        key: item.name,
        name: item.name,
        label: item.label
      }, /*#__PURE__*/React.createElement(Component, Object.assign({}, item.props)));
    });
    return formItem;
  }, [filter]);
  return /*#__PURE__*/React.createElement(_Form, {
    colon: false,
    layout: "inline",
    form: form,
    className: prefixCls
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-items")
  }, renderFormItem), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-buttons")
  }, /*#__PURE__*/React.createElement(Button, {
    onClick: onReset,
    loading: loading
  }, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement(Button, {
    type: "primary",
    loading: loading,
    onClick: onSubmit
  }, "\u67E5\u8BE2")));
};

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