"use strict";

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

exports.__esModule = true;
exports.ListLayout = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _CommonListLayout = require("../common/CommonListLayout");

var _Pagination = require("./Pagination");

var _StoreCounterText = require("./StoreCounterText");

var _CounterText = require("../CounterText");

var ListLayout =
/*#__PURE__*/
function (_React$Component) {
  (0, _inheritsLoose2.default)(ListLayout, _React$Component);

  function ListLayout() {
    var _this;

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCounterText", function () {
      var _this$props = _this.props,
          hasStoreCounterText = _this$props.hasStoreCounterText,
          store = _this$props.store,
          storeCounterText = _this$props.storeCounterText;

      if (!hasStoreCounterText) {
        return null;
      }

      return _react.default.createElement(_StoreCounterText.StoreCounterText, {
        store: store,
        template: storeCounterText
      });
    });
    (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderPagination", function (showPageSizeSelector) {
      if (showPageSizeSelector === void 0) {
        showPageSizeSelector = true;
      }

      var _this$props2 = _this.props,
          paginationProps = _this$props2.paginationProps,
          PaginationComponent = _this$props2.paginationComponent,
          store = _this$props2.store;
      return _react.default.createElement(PaginationComponent, (0, _extends2.default)({
        store: store,
        showPageSizeSelector: showPageSizeSelector
      }, paginationProps));
    });
    return _this;
  }

  var _proto = ListLayout.prototype;

  _proto.render = function render() {
    return _react.default.createElement(_CommonListLayout.CommonListLayout, (0, _extends2.default)({}, this.props, {
      renderCounterText: this.renderCounterText,
      renderPagination: this.renderPagination
    }));
  };

  return ListLayout;
}(_react.default.Component);

exports.ListLayout = ListLayout;
(0, _defineProperty2.default)(ListLayout, "propTypes", {
  store: _propTypes.default.object.isRequired,
  hasStoreCounterText: _propTypes.default.bool,
  storeCounterText: _propTypes.default.string,
  paginationProps: _propTypes.default.shape(_Pagination.Pagination.propTypes),
  paginationComponent: _propTypes.default.func
});
(0, _defineProperty2.default)(ListLayout, "defaultProps", {
  hasStoreCounterText: true,
  storeCounterText: _CounterText.CounterText.defaultProps.template,
  paginationProps: _Pagination.Pagination.defaultProps,
  paginationComponent: _Pagination.Pagination
});
(0, _defineProperty2.default)(ListLayout, "VIEW_MODE_DETAILS", _CommonListLayout.CommonListLayout.VIEW_MODE_DETAILS);
(0, _defineProperty2.default)(ListLayout, "VIEW_MODE_FULL", _CommonListLayout.CommonListLayout.VIEW_MODE_FULL);