"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.ComponentCombinator = void 0;var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));


var _createPropsGetter = require("../lib/createPropsGetter");


var _ComponentTable = require("./ComponentTable");var










ComponentCombinator = exports.ComponentCombinator = /*#__PURE__*/function (_React$Component) {function ComponentCombinator() {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;_this.












    getProps = (0, _createPropsGetter.createPropsGetter)(ComponentCombinator.defaultProps);_this.

    state = {
      page: 0
    };_this.













































    prevPage = function () {
      _this.setState(function (_ref) {var page = _ref.page;return {
          page: page - 1
        };});
    };_this.

    nextPage = function () {
      _this.setState(function (_ref2) {var page = _ref2.page;return {
          page: page + 1
        };});
    };return _this;}(0, _inheritsLoose2.default)(ComponentCombinator, _React$Component);var _proto = ComponentCombinator.prototype;_proto.render = function render() {var _ref3;var page = this.state.page;var _this$props = this.props,combinations = _this$props.combinations,Component = _this$props.Component;var _this$getProps = this.getProps(),presetProps = _this$getProps.presetProps,presetState = _this$getProps.presetState;var pages = [];var row = 0;var sizes = combinations.map(function (c) {return c.length;});var flatCombinations = (_ref3 = []).concat.apply(_ref3, combinations);for (var j = 0; j < sizes.length - 1; j++) {pages.push({ offsetX: row, offsetY: row += sizes[j] });}var pageOffsets = pages[page];return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", { id: "paginator", style: { marginBottom: 5 } }, /*#__PURE__*/_react.default.createElement("button", { disabled: page === 0, id: "prev-page", onClick: this.prevPage }, "Prev"), ' ', /*#__PURE__*/_react.default.createElement("small", null, page + 1 + " / " + pages.length), ' ', /*#__PURE__*/_react.default.createElement("button", { disabled: page + 1 >= pages.length, id: "next-page", onClick: this.nextPage }, "Next")), /*#__PURE__*/_react.default.createElement("div", null, pageOffsets && /*#__PURE__*/_react.default.createElement(_ComponentTable.ComponentTable, { key: page, Component: Component, presetProps: presetProps, presetState: presetState, rows: flatCombinations.slice(pageOffsets.offsetY, flatCombinations.length), cols: flatCombinations.slice(pageOffsets.offsetX, pageOffsets.offsetY) })));};return ComponentCombinator;}(_react.default.Component);ComponentCombinator.defaultProps = { presetProps: {}, presetState: {} };