"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _tslib = require("tslib");

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

var _mobxReact = require("mobx-react");

var _noop = _interopRequireDefault(require("lodash/noop"));

var _utils = require("../../../../lib/configure/utils");

var _FilterSelect = _interopRequireDefault(require("./FilterSelect"));

var _ColumnFilter = _interopRequireDefault(require("./ColumnFilter"));

var _TableContext = _interopRequireDefault(require("../TableContext"));

var _localeContext = require("../../locale-context");

var TableFilterBar = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(TableFilterBar, _Component);

  var _super = (0, _createSuper2["default"])(TableFilterBar);

  function TableFilterBar() {
    (0, _classCallCheck2["default"])(this, TableFilterBar);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(TableFilterBar, [{
    key: "prefixCls",
    get: function get() {
      var prefixCls = this.props.prefixCls;
      var _this$context$tableSt = this.context.tableStore.getProPrefixCls,
          getProPrefixCls = _this$context$tableSt === void 0 ? _utils.getProPrefixCls : _this$context$tableSt;
      return getProPrefixCls('table', prefixCls);
    }
  }, {
    key: "renderSuffix",
    value: function renderSuffix() {
      var prefixCls = this.prefixCls;
      return /*#__PURE__*/_react["default"].createElement(_ColumnFilter["default"], {
        prefixCls: prefixCls
      });
    }
  }, {
    key: "getButtons",
    value: function getButtons() {
      var buttons = this.props.buttons;
      var prefixCls = this.prefixCls;

      if (buttons.length) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          key: "toolbar",
          className: "".concat(prefixCls, "-toolbar")
        }, /*#__PURE__*/_react["default"].createElement("span", {
          className: "".concat(prefixCls, "-toolbar-button-group")
        }, buttons));
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          dataSet = _this$props.dataSet,
          queryDataSet = _this$props.queryDataSet,
          paramName = _this$props.paramName,
          _this$props$placehold = _this$props.placeholder,
          placeholder = _this$props$placehold === void 0 ? (0, _localeContext.$l)('Table', 'filter_bar_placeholder') : _this$props$placehold,
          pagination = _this$props.pagination,
          _this$props$onQuery = _this$props.onQuery,
          onQuery = _this$props$onQuery === void 0 ? _noop["default"] : _this$props$onQuery,
          _this$props$onReset = _this$props.onReset,
          onReset = _this$props$onReset === void 0 ? _noop["default"] : _this$props$onReset,
          editable = _this$props.editable;
      var prefixCls = this.prefixCls;
      var buttons = this.getButtons();
      return [buttons, pagination, /*#__PURE__*/_react["default"].createElement(_FilterSelect["default"], {
        key: "filter",
        prefixCls: "".concat(prefixCls, "-filter-select"),
        optionDataSet: dataSet,
        queryDataSet: queryDataSet,
        placeholder: placeholder,
        suffix: this.renderSuffix(),
        paramName: paramName,
        onQuery: onQuery,
        onReset: onReset,
        editable: editable
      })];
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _TableContext["default"];
    }
  }]);
  return TableFilterBar;
}(_react.Component);

TableFilterBar.defaultProps = {
  paramName: 'params'
};
TableFilterBar = (0, _tslib.__decorate)([_mobxReact.observer], TableFilterBar);
var _default = TableFilterBar;
exports["default"] = _default;
//# sourceMappingURL=TableFilterBar.js.map
