/* eslint-disable no-unused-vars */ import IconButton from "@mui/material/IconButton"; import { withStyles } from "@mui/styles"; import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; import PropTypes from "prop-types"; import * as React from "react"; /* eslint-enable no-unused-vars */ class MTablePaginationInner extends React.Component { handleFirstPageButtonClick = (event) => { this.props.onPageChange(event, 0); }; handleBackButtonClick = (event) => { this.props.onPageChange(event, this.props.page - 1); }; handleNextButtonClick = (event) => { this.props.onPageChange(event, this.props.page + 1); }; handleLastPageButtonClick = (event) => { this.props.onPageChange( event, Math.max(0, Math.ceil(this.props.count / this.props.rowsPerPage) - 1) ); }; render() { const { classes, count, page, rowsPerPage, theme, showFirstLastPageButtons, } = this.props; const localization = { ...MTablePaginationInner.defaultProps.localization, ...this.props.localization, }; return (
{showFirstLastPageButtons && ( {theme.direction === "rtl" ? ( ) : ( )} )} {theme.direction === "rtl" ? ( ) : ( )} {localization.labelDisplayedRows .replace( "{from}", this.props.count === 0 ? 0 : this.props.page * this.props.rowsPerPage + 1 ) .replace( "{to}", Math.min( (this.props.page + 1) * this.props.rowsPerPage, this.props.count ) ) .replace("{count}", this.props.count)} = Math.ceil(count / rowsPerPage) - 1} aria-label={localization.nextAriaLabel} size="large" > {theme.direction === "rtl" ? ( ) : ( )} {showFirstLastPageButtons && ( = Math.ceil(count / rowsPerPage) - 1} aria-label={localization.lastAriaLabel} size="large" > {theme.direction === "rtl" ? ( ) : ( )} )}
); } } const actionsStyles = (theme) => ({ root: { flexShrink: 0, color: theme.palette.text.secondary, display: "flex", // lineHeight: '48px' }, }); MTablePaginationInner.propTypes = { onPageChange: PropTypes.func, page: PropTypes.number, count: PropTypes.number, rowsPerPage: PropTypes.number, classes: PropTypes.object, localization: PropTypes.object, theme: PropTypes.any, showFirstLastPageButtons: PropTypes.bool, }; MTablePaginationInner.defaultProps = { showFirstLastPageButtons: true, localization: { firstTooltip: "First Page", previousTooltip: "Previous Page", nextTooltip: "Next Page", lastTooltip: "Last Page", labelDisplayedRows: "{from}-{to} of {count}", labelRowsPerPage: "Rows per page:", }, }; const MTablePagination = withStyles(actionsStyles, { withTheme: true })( MTablePaginationInner ); export default MTablePagination;