"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TablePagination = void 0;
const react_1 = __importDefault(require("react"));
const Flex_1 = require("../Flex");
const Box_1 = require("../Box");
const Text_1 = require("../Text");
const Select_1 = require("../Select");
const Button_1 = require("../Button");
const theme_1 = require("../../styles/theme");
const Icon_1 = require("../Icon");
const icons = __importStar(require("../../assets/images/icons"));
exports.TablePagination = ({ canPreviousPage, canNextPage, nextPage, previousPage, setPageSize, totalRows, pageIndex, pageSize, pageSizes, pageCount, gotoPage, }) => {
    const buttonStyles = { minWidth: 50, padding: 0 };
    return (react_1.default.createElement(Flex_1.Flex, { justifyContent: "flex-end", lineHeight: "50px" },
        pageSizes && setPageSize && (react_1.default.createElement(Flex_1.Flex, { mr: "xxl" },
            react_1.default.createElement(Text_1.Text, { variant: "b2m", color: "gray.2" }, "Rows per page"),
            react_1.default.createElement(Select_1.Select, { variant: "ghost", options: pageSizes.map((size) => ({
                    label: size,
                    value: size,
                })), value: pageSize, onChange: (value) => {
                    setPageSize(value);
                }, styles: {
                    container: (provided) => (Object.assign(Object.assign({}, provided), { marginLeft: 10, marginTop: 2, width: 50 })),
                    singleValue: (provided) => (Object.assign(Object.assign({}, provided), { color: theme_1.theme.colors.highlightText, fontSize: theme_1.theme.fontSizes[1], fontWeight: theme_1.theme.fontWeights.semiBold, lineHeight: theme_1.theme.lineHeights.normal })),
                    menu: (provided) => (Object.assign(Object.assign({}, provided), { marginTop: -5, width: 50 })),
                }, noIcon: true }))),
        react_1.default.createElement(Box_1.Box, { mr: "xxl" },
            react_1.default.createElement(Text_1.Text, { variant: "b2m", color: "gray.1" }, `${pageIndex * pageSize + 1}-${totalRows
                ? Math.min(totalRows, (pageIndex + 1) * pageSize)
                : (pageIndex + 1) * pageSize}${totalRows ? ` of ${totalRows}` : ''}`)),
        react_1.default.createElement(Flex_1.Flex, { mr: "s" },
            gotoPage && pageCount && (react_1.default.createElement(Button_1.Button, { variant: "ghost", style: buttonStyles, onClick: () => gotoPage(0), disabled: !canPreviousPage },
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronLeft, width: 24, height: 24, color: "gray.3" }),
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronLeft, width: 24, height: 24, color: "gray.3", ml: "-17px" }))),
            react_1.default.createElement(Button_1.Button, { variant: "ghost", style: buttonStyles, onClick: () => previousPage(), disabled: !canPreviousPage },
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronLeft, width: 24, height: 24, color: "gray.3" })),
            react_1.default.createElement(Button_1.Button, { variant: "ghost", style: buttonStyles, onClick: () => nextPage(), disabled: !canNextPage },
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronRight, width: 24, height: 24, color: "gray.3" })),
            gotoPage && pageCount && (react_1.default.createElement(Button_1.Button, { variant: "ghost", style: buttonStyles, onClick: () => gotoPage(pageCount - 1), disabled: !canNextPage },
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronRight, width: 24, height: 24, color: "gray.3", mr: "-17px" }),
                react_1.default.createElement(Icon_1.Icon, { Asset: icons.SvgChevronRight, width: 24, height: 24, color: "gray.3" }))))));
};
//# sourceMappingURL=TablePagination.js.map