'use strict';

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

var _tslib = require('../../../_virtual/_tslib.js');
var React = require('react');
var Dropdown = require('../../Field/dropdown/Dropdown.js');
var styles = require('../styles.js');
var utils = require('../utils.js');
var index = require('../../../utils/index.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

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

const NarrowPagination = (_a) => {
    var { totalItems, rowsPerPage, narrowPaginationText = {
        indicator: 'Page',
        preposition: 'of',
    }, currentPage, onChangePage } = _a, props = _tslib.__rest(_a, ["totalItems", "rowsPerPage", "narrowPaginationText", "currentPage", "onChangePage"]);
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-trackid']);
    const numberOfPages = utils.getNumberOfPages(totalItems, rowsPerPage);
    const pageNumbersMappedToOptions = React.useMemo(() => Array(numberOfPages)
        .fill(null)
        .map((_, i) => {
        const page = i + 1;
        return {
            value: page,
            label: page.toString(),
        };
    }), [numberOfPages]);
    return (React__default['default'].createElement(React__default['default'].Fragment, null,
        React__default['default'].createElement(styles.PaginationText, null, narrowPaginationText.indicator),
        React__default['default'].createElement(Dropdown.Dropdown, { variant: "small", options: pageNumbersMappedToOptions, onChange: (e) => onChangePage(Number(e.value)), value: { value: currentPage, label: currentPage.toString() }, noMargin: true, width: "82px", "data-testid": appendTestId(), "data-trackid": appendTrackId() }),
        React__default['default'].createElement(styles.PaginationText, null,
            narrowPaginationText.preposition,
            " ",
            numberOfPages)));
};

exports['default'] = NarrowPagination;
