"use strict";

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

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

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 _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

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

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

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

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

var _Pagination = _interopRequireWildcard(require("@instructure/ui-pagination/lib/components/Pagination"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-common/lib/format-message"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fVnQK',
  template: function template(theme) {
    return "\n\n.Paginator__styles__pagination {\n  padding-top: ".concat(theme.paginationPadding || 'inherit', ";\n}\n");
  },
  'pagination': 'Paginator__styles__pagination'
};
var Paginator = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(Paginator, _Component);

  function Paginator() {
    (0, _classCallCheck2.default)(this, Paginator);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Paginator).apply(this, arguments));
  }

  (0, _createClass2.default)(Paginator, [{
    key: "renderPagination",
    value: function renderPagination() {
      var _this = this;

      var paginationButtons = Array.from(Array(this.props.totalPages)).map(function (v, i) {
        var page = i + 1;
        return _react.default.createElement(_Pagination.PaginationButton, {
          key: i,
          current: page === _this.props.currentPage,
          onClick: _this.props.onPageChange.bind(null, page)
        }, page);
      });
      return _react.default.createElement("div", {
        className: styles.pagination
      }, _react.default.createElement(_Pagination.default, {
        labelNext: "Neste side",
        labelPrev: "Forrige side",
        variant: "compact"
      }, paginationButtons));
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", null, this.props.children, this.renderPagination());
    }
  }]);
  Paginator.displayName = "Paginator";
  return Paginator;
}(_react.Component), _class2.propTypes = {
  children: _propTypes.default.node.isRequired,
  currentPage: _propTypes.default.number.isRequired,
  onPageChange: _propTypes.default.func.isRequired,
  totalPages: _propTypes.default.number.isRequired
}, _temp)) || _class);
exports.default = Paginator;