'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var index = require('../../utils/index.js');
var Pagination_tokens = require('../../Pagination.tokens.js');
var PaginationSelectPerPage_styles = require('./PaginationSelectPerPage.styles.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var _excluded = ["perPageValue", "perPageList", "textPerPage", "onChangeValue", "size", "listWidth"];
var PaginationSelectPerPage = function PaginationSelectPerPage(_ref) {
  var perPageValue = _ref.perPageValue,
    _ref$perPageList = _ref.perPageList,
    perPageList = _ref$perPageList === void 0 ? index.defaultValues.perPageList : _ref$perPageList,
    _ref$textPerPage = _ref.textPerPage,
    textPerPage = _ref$textPerPage === void 0 ? index.defaultValues.textPerPage : _ref$textPerPage,
    onChangeValue = _ref.onChangeValue,
    size = _ref.size,
    listWidth = _ref.listWidth,
    rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
  var handleSelectChange = function handleSelectChange(newValue) {
    if (newValue && !Array.isArray(newValue) && onChangeValue) {
      onChangeValue(Number(newValue));
    }
  };
  var transformedList = perPageList.map(function (num) {
    return {
      label: num.toString(),
      value: num.toString()
    };
  });
  return /*#__PURE__*/React__default.default.createElement(PaginationSelectPerPage_styles.SelectPerPageRoot, rest, /*#__PURE__*/React__default.default.createElement(PaginationSelectPerPage_styles.SelectPerPageTypography, null, textPerPage), /*#__PURE__*/React__default.default.createElement(PaginationSelectPerPage_styles.SelectPerPageSelect, {
    className: Pagination_tokens.classes.selectWrapper,
    items: transformedList,
    value: perPageValue === null || perPageValue === void 0 ? void 0 : perPageValue.toString(),
    onChange: handleSelectChange,
    target: "button-like",
    size: size,
    listWidth: listWidth,
    flip: true,
    shift: true
  }));
};

exports.PaginationSelectPerPage = PaginationSelectPerPage;
