/* * Copyright (C) 2019-2025 CZ.NIC z.s.p.o. (https://www.nic.cz/) * * This is free software, licensed under the GNU General Public License v3. * See /LICENSE for more information. */ import React, { useMemo } from "react"; import { faAngleLeft, faAnglesLeft, faAngleRight, faAnglesRight, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import propTypes from "prop-types"; RichTablePagination.propTypes = { table: propTypes.shape({ getState: propTypes.func.isRequired, getCanPreviousPage: propTypes.func.isRequired, getCanNextPage: propTypes.func.isRequired, firstPage: propTypes.func.isRequired, previousPage: propTypes.func.isRequired, nextPage: propTypes.func.isRequired, lastPage: propTypes.func.isRequired, setPageSize: propTypes.func.isRequired, getPageCount: propTypes.func.isRequired, }).isRequired, tablePageSize: propTypes.number, allRows: propTypes.number, }; function RichTablePagination({ table, tablePageSize, allRows }) { const { pagination } = table.getState(); const prevPagBtnDisabled = !table.getCanPreviousPage(); const nextPagBtnDisabled = !table.getCanNextPage(); const pageSizes = useMemo(() => { return [tablePageSize ?? 5, 10, 25].filter( (value, index, self) => self.indexOf(value) === index ); }, [tablePageSize]); const renderPaginationButton = (icon, ariaLabel, onClick, disabled) => (