bananas-commerce-admin
Version:
What's this, an admin for apes?
28 lines • 1.38 kB
JavaScript
// TODO: Sorting
import React, { useMemo } from "react";
import { Table as MuiTable, TableContainer as MuiTableContainer, } from "@mui/material";
import { TableContext } from "../../contexts/TableContext";
import TablePagination from "./TablePagination";
import { useTableSearchParams } from "./useTableSearchParams";
export const Table = ({ count, defaultPage, pagination, defaultRowsPerPage, rowsPerPageOptions, children, tableProps, tableContainerProps, }) => {
const searchParams = useTableSearchParams({
page: defaultPage,
rowsPerPage: defaultRowsPerPage,
});
const contextValues = useMemo(() => ({
count,
rowsPerPageOptions: rowsPerPageOptions ?? [50, 100, 200],
...searchParams,
}), [count, searchParams, rowsPerPageOptions]);
return (React.createElement(MuiTableContainer, { ...tableContainerProps, sx: {
"& .MuiTablePagination-toolbar": { pr: 1.5 },
"& .MuiTableCell-root:first-child": { pl: 3 },
"& .MuiTableCell-root:last-child": { pr: 3 },
...tableContainerProps?.sx,
} },
React.createElement(TableContext.Provider, { value: contextValues },
React.createElement(MuiTable, { ...tableProps }, children),
pagination && React.createElement(TablePagination, null))));
};
export default Table;
//# sourceMappingURL=index.js.map