import React from "react"; import { useTheme, makeStyles, Theme, createStyles, } from "@material-ui/core/styles"; import IconButton from "@material-ui/core/IconButton"; import FirstPageIcon from "@material-ui/icons/FirstPage"; import KeyboardArrowLeft from "@material-ui/icons/KeyboardArrowLeft"; import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; import LastPageIcon from "@material-ui/icons/LastPage"; const useStyles = makeStyles((theme: Theme) => createStyles({ root: { flexShrink: 0, marginLeft: theme.spacing(2.5), }, }) ); interface TablePaginationActionsProps { count: number; page: number; rowsPerPage: number; onChangePage: ( event: React.MouseEvent, newPage: number ) => void; } function TablePaginationActions(props: TablePaginationActionsProps) { const classes = useStyles(); const theme = useTheme(); const { count, page, rowsPerPage, onChangePage } = props; const handleFirstPageButtonClick = ( event: React.MouseEvent ) => { onChangePage(event, 0); }; const handleBackButtonClick = ( event: React.MouseEvent ) => { onChangePage(event, page - 1); }; const handleNextButtonClick = ( event: React.MouseEvent ) => { onChangePage(event, page + 1); }; const handleLastPageButtonClick = ( event: React.MouseEvent ) => { onChangePage(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1)); }; return (
{theme.direction === "rtl" ? : } {theme.direction === "rtl" ? ( ) : ( )} = Math.ceil(count / rowsPerPage) - 1} aria-label="next page" > {theme.direction === "rtl" ? ( ) : ( )} = Math.ceil(count / rowsPerPage) - 1} aria-label="last page" > {theme.direction === "rtl" ? : }
); } export default TablePaginationActions; export const rowsPerPageOptions = [10, 20, 30, 60, 100]; export const defaultPageSize = 20;