Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 34x 204x 204x 204x 204x 204x 204x | import { Box, Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import React, { ReactElement, useState } from "react";
import ContextualMenu from "@shared/ContextualMenu/ContextualMenu";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { CaretDownIcon } from "@phosphor-icons/react";
import { useRowsPerPage } from "../hooks/useRowsPerPage";
interface TablePaginationMaxSelectProps {
storageKey?: string;
totalRows?: number;
page?: number;
setPageDispatcher?: React.Dispatch<React.SetStateAction<number>>;
}
const TablePaginationMaxSelect = ({
storageKey,
totalRows,
page,
setPageDispatcher,
}: TablePaginationMaxSelectProps): ReactElement => {
const { isMobileView } = useCustomThemeV2();
const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
const { rowsPerPage, setRowsPerPage } = useRowsPerPage(
storageKey || "",
totalRows,
page,
setPageDispatcher,
);
const handleCloseMenu = () => {
setMenuAnchorEl(null);
};
const menuOptions = [
{ text: "100", onClick: () => setRowsPerPage(100) },
{ text: "150", onClick: () => setRowsPerPage(150) },
{ text: "200", onClick: () => setRowsPerPage(200) },
];
return (
<>
<Stack direction="row" gap="8px" alignItems="center">
<GiveText variant="bodyS" color="secondary">
Rows per page:
</GiveText>
<Box
component="button"
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
setMenuAnchorEl(e.currentTarget);
}}
sx={{
display: "flex",
direction: "row",
alignItems: "center",
justifyContent: "center",
gap: "8px",
cursor: "pointer",
bgcolor: "transparent",
border: "none",
p: 0,
}}
>
<GiveText
variant="bodyS"
color="primary"
fontFamily="Give Whyte"
sx={{ minWidth: "28px" }}
>
{rowsPerPage}
</GiveText>
<CaretDownIcon
size={18}
style={{
flexShrink: 0,
transition: "transform 0.2s ease",
transform: menuAnchorEl ? "rotate(180deg)" : "rotate(0deg)",
}}
/>
</Box>
</Stack>
<ContextualMenu
menuWidth="fit-content"
anchorOrigin={{ vertical: -15, horizontal: "right" }}
transformOrigin={{ vertical: "bottom", horizontal: "right" }}
anchorEl={menuAnchorEl}
color="primary"
texture={isMobileView ? "solid" : "blurred"}
options={menuOptions}
handleClose={handleCloseMenu}
/>
</>
);
};
export default TablePaginationMaxSelect;
|