UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

39 lines (38 loc) 1.26 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Group, SegmentedControl, Text } from '@mantine/core'; import { useMemo } from 'react'; import { useTableContext } from '../TableContext'; export const TablePerPage = ({ label = 'Results per page', values = [ 25, 50, 100 ], onPerPageChange })=>{ const { store, table } = useTableContext(); const choices = useMemo(()=>values.map((value)=>value.toString()), [ values ]); const updatePerPage = (newPerPage)=>{ onPerPageChange?.(Number(newPerPage)); store.setPagination({ pageIndex: 0, pageSize: parseInt(newPerPage, 10) }); }; return table.getPageCount() > 0 ? /*#__PURE__*/ _jsxs(Group, { gap: "sm", children: [ /*#__PURE__*/ _jsx(Text, { fw: 500, children: label }), /*#__PURE__*/ _jsx(SegmentedControl, { value: store.state.pagination.pageSize.toString() ?? choices[1] ?? choices[0], onChange: updatePerPage, data: choices, size: "sm" }) ] }) : null; }; TablePerPage.DEFAULT_SIZE = 50; //# sourceMappingURL=TablePerPage.js.map