"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TablePagination = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
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 Icon_1 = require("../Icon");
const icons_1 = require("../../theme/icons");
const TablePagination = ({ canPreviousPage, canNextPage, nextPage, previousPage, setPageSize, totalRows, pageIndex, pageSize, pageSizes, pageCount, gotoPage, label = 'Rows per page', }) => {
    // const buttonStyles = { minWidth: 50, padding: 0 };
    return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, Object.assign({ variant: "raw", justify: "end" }, { children: [pageSizes && setPageSize && ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, Object.assign({ variant: "raw", margin: "0 xxl 0 0" }, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, Object.assign({ variant: "span", format: "b2m", color: "gray2" }, { children: label }), void 0), (0, jsx_runtime_1.jsx)(Select_1.Select, { variant: "basic", options: pageSizes.map((size) => ({
                            label: String(size),
                            value: String(size),
                        })), value: {
                            label: String(pageSize),
                            value: String(pageSize),
                        }, onChange: (value) => {
                            setPageSize(value);
                        }, noIcon: true }, void 0)] }), void 0)), (0, jsx_runtime_1.jsx)(Box_1.Box, Object.assign({ variant: "raw", margin: "0 xxl 0 0" }, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, Object.assign({ variant: "span", format: "b2m", color: "gray1" }, { children: `${pageIndex * pageSize + 1}-${totalRows
                        ? Math.min(totalRows, (pageIndex + 1) * pageSize)
                        : (pageIndex + 1) * pageSize}${totalRows ? ` of ${totalRows}` : ''}` }), void 0) }), void 0), (0, jsx_runtime_1.jsxs)(Flex_1.Flex, Object.assign({ variant: "raw", margin: "0 s 0 0" }, { children: [gotoPage && pageCount && ((0, jsx_runtime_1.jsxs)(Button_1.Button, Object.assign({ variant: "tertiary", 
                        // style={buttonStyles}
                        onClick: () => gotoPage(0), disabled: !canPreviousPage }, { children: [(0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronLeft, size: "24px", color: "gray3" }, void 0), (0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronLeft, size: "24px", color: "gray3", margin: "0 0 0 -17px" }, void 0)] }), void 0)), (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "tertiary", 
                        // style={buttonStyles}
                        onClick: () => previousPage(), disabled: !canPreviousPage }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronLeft, size: "24px", color: "gray3" }, void 0) }), void 0), (0, jsx_runtime_1.jsx)(Button_1.Button, Object.assign({ variant: "tertiary", 
                        // style={buttonStyles}
                        onClick: () => nextPage(), disabled: !canNextPage }, { children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronRight, size: "24px", color: "gray3" }, void 0) }), void 0), gotoPage && pageCount && ((0, jsx_runtime_1.jsxs)(Button_1.Button, Object.assign({ variant: "tertiary", 
                        // style={buttonStyles}
                        onClick: () => gotoPage(pageCount - 1), disabled: !canNextPage }, { children: [(0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronRight, size: "24px", color: "gray3", margin: "0 -17px 0 0" }, void 0), (0, jsx_runtime_1.jsx)(Icon_1.Icon, { variant: "basic", icon: icons_1.polyIcons.ChevronRight, size: "24px", color: "gray3" }, void 0)] }), void 0))] }), void 0)] }), void 0));
};
exports.TablePagination = TablePagination;
//# sourceMappingURL=TablePagination.js.map