mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-10-23 18:23:15 +02:00
62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import * as React from "react";
|
|
import { useTheme } from "@mui/material/styles";
|
|
import Box from "@mui/material/Box";
|
|
import IconButton from "@mui/material/IconButton";
|
|
import FirstPageIcon from "@mui/icons-material/FirstPage";
|
|
import KeyboardArrowLeft from "@mui/icons-material/KeyboardArrowLeft";
|
|
import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight";
|
|
import LastPageIcon from "@mui/icons-material/LastPage";
|
|
|
|
interface TablePaginationActionsProps {
|
|
count: number;
|
|
page: number;
|
|
rowsPerPage: number;
|
|
onPageChange: (event: React.MouseEvent<HTMLButtonElement>, newPage: number) => void;
|
|
}
|
|
|
|
export function TablePaginationActionsAll(props: TablePaginationActionsProps): React.ReactElement {
|
|
const theme = useTheme();
|
|
const { count, page, rowsPerPage, onPageChange } = props;
|
|
|
|
const handleFirstPageButtonClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
onPageChange(event, 0);
|
|
};
|
|
|
|
const handleBackButtonClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
onPageChange(event, page - 1);
|
|
};
|
|
|
|
const handleNextButtonClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
onPageChange(event, page + 1);
|
|
};
|
|
|
|
const handleLastPageButtonClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
|
|
};
|
|
|
|
return (
|
|
<Box sx={{ flexShrink: 0, ml: 2.5 }}>
|
|
<IconButton onClick={handleFirstPageButtonClick} disabled={page === 0} aria-label="first page">
|
|
{theme.direction === "rtl" ? <LastPageIcon /> : <FirstPageIcon />}
|
|
</IconButton>
|
|
<IconButton onClick={handleBackButtonClick} disabled={page === 0} aria-label="previous page">
|
|
{theme.direction === "rtl" ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
|
|
</IconButton>
|
|
<IconButton
|
|
onClick={handleNextButtonClick}
|
|
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
|
|
aria-label="next page"
|
|
>
|
|
{theme.direction === "rtl" ? <KeyboardArrowLeft /> : <KeyboardArrowRight />}
|
|
</IconButton>
|
|
<IconButton
|
|
onClick={handleLastPageButtonClick}
|
|
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
|
|
aria-label="last page"
|
|
>
|
|
{theme.direction === "rtl" ? <FirstPageIcon /> : <LastPageIcon />}
|
|
</IconButton>
|
|
</Box>
|
|
);
|
|
}
|