"use strict";

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

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

var _PaginationModule = _interopRequireDefault(require("./Pagination.module.css"));

var _Box = _interopRequireDefault(require("../layout/Box"));

var _Button = _interopRequireDefault(require("../button/Button"));

var _Box2 = _interopRequireDefault(require("../layout/Box.constantProps"));

var _Link = _interopRequireDefault(require("../link/Link"));

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

function _extends() { _extends = Object.assign || 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 Pagination(props) {
  var _this = this;

  var options = props.options,
      onClick = props.onClick,
      onNextClick = props.onNextClick,
      onPreviousClick = props.onPreviousClick,
      dataId = props.dataId,
      justifyContent = props.justifyContent,
      isStretch = props.isStretch,
      isNext = props.isNext,
      isPrevious = props.isPrevious,
      previousButtonOptions = props.previousButtonOptions,
      nextButtonOptions = props.nextButtonOptions;
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
    tagName: "ul",
    tagAttributeProps: {
      "data-id": dataId
    },
    isCover: false,
    direction: _Box2["default"].direction.row,
    justifyContent: justifyContent,
    isContainer: true,
    customClassName: _PaginationModule["default"].base
  }, isPrevious ? /*#__PURE__*/_react["default"].createElement(_Button["default"], _extends({
    onClick: onPreviousClick && onPreviousClick
  }, previousButtonOptions)) : null, options.length && options.map(function (obj, i) {
    var extraStyle = "".concat(obj.isSelected ? _PaginationModule["default"].itemHighlight : _PaginationModule["default"].item, " ").concat(obj.disabled ? _PaginationModule["default"].disabled : "");
    return /*#__PURE__*/_react["default"].createElement(_Box["default"], {
      key: i,
      tagName: "li",
      customClassName: extraStyle,
      flexible: isStretch,
      tagAttributeProps: {
        onClick: onClick && onClick.bind(_this, obj)
      }
    }, obj.href ? /*#__PURE__*/_react["default"].createElement(_Link["default"], {
      text: obj.name,
      target: "_blank",
      href: obj.href
    }) : obj.name);
  }), isNext ? /*#__PURE__*/_react["default"].createElement(_Button["default"], _extends({
    onClick: onNextClick && onNextClick
  }, nextButtonOptions)) : null);
}