Skip to content

Commit a7a04e6

Browse files
committed
release v2.0.4 - pagination rowsperpage select enhancements
1 parent ce8d5e3 commit a7a04e6

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

apps/material-react-table-docs/pages/changelog.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import Head from 'next/head';
1212

1313
### Version 2
1414

15+
#### Version 2.0.4 - 11-09-2023
16+
17+
- Add support for `'all'` rows pagination option
18+
- Added `muiPaginationProps.SelectProps` support back to allow for native select
19+
1520
#### Version 2.0.3 - 11-06-2023
1621

1722
- Locale updates

packages/material-react-table/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.3",
2+
"version": "2.0.4",
33
"license": "MIT",
44
"name": "material-react-table",
55
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",

packages/material-react-table/src/toolbar/MRT_TablePagination.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
6060
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
6161

6262
const {
63+
SelectProps,
6364
rowsPerPageOptions = defaultRowsPerPage,
6465
showFirstButton = showFirstLastPageButtons,
6566
showLastButton = showFirstLastPageButtons,
@@ -98,22 +99,29 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
9899
id="mrt-rows-per-page"
99100
inputProps={{ 'aria-label': localization.rowsPerPage }}
100101
label={localization.rowsPerPage}
101-
onChange={(event) => setPageSize(+event.target.value)}
102+
onChange={(event) => setPageSize(+(event.target.value as any))}
102103
sx={{ mb: 0 }}
103104
value={pageSize}
104105
variant="standard"
106+
{...SelectProps}
105107
>
106-
{rowsPerPageOptions.map((option) =>
107-
typeof option === 'number' ? (
108-
<MenuItem key={option} sx={{ m: 0 }} value={option}>
109-
{option}
110-
</MenuItem>
111-
) : (
112-
<MenuItem key={option.value} sx={{ m: 0 }} value={option.value}>
113-
{option.label}
114-
</MenuItem>
115-
),
116-
)}
108+
{rowsPerPageOptions.map((option) => {
109+
const value = typeof option !== 'number' ? option.value : option;
110+
const label =
111+
typeof option !== 'number' ? option.label : `${option}`;
112+
return (
113+
SelectProps?.children ??
114+
(SelectProps?.native ? (
115+
<option key={value} value={value}>
116+
{label}
117+
</option>
118+
) : (
119+
<MenuItem key={value} sx={{ m: 0 }} value={value}>
120+
{label}
121+
</MenuItem>
122+
))
123+
);
124+
})}
117125
</Select>
118126
</Box>
119127
)}

packages/material-react-table/src/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { type LinearProgressProps } from '@mui/material/LinearProgress';
5454
import { type PaginationProps } from '@mui/material/Pagination';
5555
import { type PaperProps } from '@mui/material/Paper';
5656
import { type RadioProps } from '@mui/material/Radio';
57+
import { type SelectProps } from '@mui/material/Select';
5758
import { type SkeletonProps } from '@mui/material/Skeleton';
5859
import { type SliderProps } from '@mui/material/Slider';
5960
import { type TableProps } from '@mui/material/Table';
@@ -904,13 +905,15 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
904905
muiPaginationProps?:
905906
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
906907
PaginationProps & {
907-
rowsPerPageOptions?: {label: string; value: number}[] | number[];
908+
SelectProps?: Partial<SelectProps>;
909+
rowsPerPageOptions?: { label: string; value: number }[] | number[];
908910
showRowsPerPage?: boolean;
909911
}
910912
>)
911913
| Partial<
912914
PaginationProps & {
913-
rowsPerPageOptions?: {label: string; value: number;}[] | number[];
915+
SelectProps?: Partial<SelectProps>;
916+
rowsPerPageOptions?: { label: string; value: number }[] | number[];
914917
showRowsPerPage?: boolean;
915918
}
916919
>;

packages/material-react-table/stories/features/Pagination.stories.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ export const PaginationEnabledDefaultNoRowsPerPage = () => (
8888
/>
8989
);
9090

91+
export const PaginationEnabledCustomizeRowsPerPage = () => (
92+
<MaterialReactTable
93+
columns={columns}
94+
data={data}
95+
muiPaginationProps={{
96+
SelectProps: {
97+
native: true,
98+
},
99+
}}
100+
/>
101+
);
102+
91103
export const PaginationPagesDisplayMode = () => (
92104
<MaterialReactTable
93105
columns={columns}

0 commit comments

Comments
 (0)