material-react-table 1.0.0-beta.15 → 1.0.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,10 +42,19 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
42
42
  >
43
43
  <Checkbox
44
44
  checked={
45
- selectAll ? table.getIsAllRowsSelected() : row?.getIsSelected()
45
+ selectAll
46
+ ? selectAllMode === 'page'
47
+ ? table.getIsAllPageRowsSelected()
48
+ : table.getIsAllRowsSelected()
49
+ : row?.getIsSelected()
46
50
  }
47
51
  indeterminate={
48
- selectAll ? table.getIsSomeRowsSelected() : row?.getIsSomeSelected()
52
+ selectAll
53
+ ? table.getIsSomeRowsSelected() &&
54
+ !(selectAllMode === 'page'
55
+ ? table.getIsAllPageRowsSelected()
56
+ : table.getIsAllRowsSelected())
57
+ : row?.getIsSomeSelected()
49
58
  }
50
59
  inputProps={{
51
60
  'aria-label': selectAll
@@ -3,8 +3,8 @@ import { TablePagination } from '@mui/material';
3
3
  import { MRT_TableInstance } from '..';
4
4
 
5
5
  interface Props<TData extends Record<string, any> = {}> {
6
- table: MRT_TableInstance<TData>;
7
6
  position: 'top' | 'bottom';
7
+ table: MRT_TableInstance<TData>;
8
8
  }
9
9
 
10
10
  export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
@@ -19,6 +19,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
19
19
  options: {
20
20
  muiTablePaginationProps,
21
21
  enableToolbarInternalActions,
22
+ localization,
22
23
  rowCount,
23
24
  },
24
25
  } = table;
@@ -41,12 +42,21 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
41
42
 
42
43
  return (
43
44
  <TablePagination
44
- SelectProps={{
45
- sx: { m: '0 1rem 0 1ch' },
46
- MenuProps: { MenuListProps: { disablePadding: true } },
47
- }}
48
45
  component="div"
49
46
  count={totalRowCount}
47
+ getItemAriaLabel={(type) =>
48
+ type === 'first'
49
+ ? localization.goToFirstPage
50
+ : type === 'last'
51
+ ? localization.goToLastPage
52
+ : type === 'next'
53
+ ? localization.goToNextPage
54
+ : localization.goToPreviousPage
55
+ }
56
+ labelDisplayedRows={({ from, to, count }) =>
57
+ `${from}-${to} ${localization.of} ${count}`
58
+ }
59
+ labelRowsPerPage={localization.rowsPerPage}
50
60
  onPageChange={(_: any, newPage: number) => setPageIndex(newPage)}
51
61
  onRowsPerPageChange={handleChangeRowsPerPage}
52
62
  page={pageIndex}
@@ -55,7 +65,31 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
55
65
  showFirstButton={showFirstLastPageButtons}
56
66
  showLastButton={showFirstLastPageButtons}
57
67
  {...tablePaginationProps}
68
+ SelectProps={{
69
+ sx: { m: '0 1rem 0 1ch' },
70
+ MenuProps: { MenuListProps: { disablePadding: true }, sx: { m: 0 } },
71
+ ...tablePaginationProps?.SelectProps,
72
+ }}
58
73
  sx={(theme) => ({
74
+ '& .MuiTablePagination-toolbar': {
75
+ display: 'flex',
76
+ alignItems: 'center',
77
+ },
78
+ '& .MuiTablePagination-selectLabel': {
79
+ m: '0 -1px',
80
+ },
81
+ '&. MuiInputBase-root': {
82
+ m: '0 1px',
83
+ },
84
+ '& . MuiTablePagination-select': {
85
+ m: '0 1px',
86
+ },
87
+ '& .MuiTablePagination-displayedRows': {
88
+ m: '0 1px',
89
+ },
90
+ '& .MuiTablePagination-actions': {
91
+ m: '0 1px',
92
+ },
59
93
  mt:
60
94
  position === 'top' &&
61
95
  enableToolbarInternalActions &&
@@ -20,6 +20,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
20
20
  muiToolbarAlertBannerProps,
21
21
  muiToolbarAlertBannerChipProps,
22
22
  positionToolbarAlertBanner,
23
+ rowCount,
23
24
  },
24
25
  } = table;
25
26
  const { grouping, showAlertBanner } = getState();
@@ -43,7 +44,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
43
44
  )
44
45
  ?.replace(
45
46
  '{rowCount}',
46
- getPrePaginationRowModel().rows.length.toString(),
47
+ (rowCount ?? getPrePaginationRowModel().rows.length).toString(),
47
48
  )
48
49
  : null;
49
50
 
@@ -1,2 +0,0 @@
1
- import { MRT_Localization } from '../MaterialReactTable';
2
- export declare const MRT_Localization_ES: MRT_Localization;
@@ -1,2 +0,0 @@
1
- import { MRT_Localization } from '../MaterialReactTable';
2
- export declare const MRT_Localization_ES: MRT_Localization;