material-react-table 1.0.0-beta.4 → 1.0.0-beta.5

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.
package/dist/index.d.ts CHANGED
@@ -154,6 +154,8 @@ interface MRT_Localization {
154
154
  max: string;
155
155
  min: string;
156
156
  move: string;
157
+ noRecordsToDisplay: string;
158
+ noResultsFound: string;
157
159
  or: string;
158
160
  pinToLeft: string;
159
161
  pinToRight: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.4",
2
+ "version": "1.0.0-beta.5",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -1,7 +1,7 @@
1
1
  import React, { FC, useMemo } from 'react';
2
2
  import { useVirtual } from 'react-virtual'; //stuck on v2 for now
3
3
  // import { useVirtualizer, Virtualizer } from '@tanstack/react-virtual';
4
- import { TableBody } from '@mui/material';
4
+ import { Box, TableBody, TableCell, TableRow } from '@mui/material';
5
5
  import { MRT_TableBodyRow } from './MRT_TableBodyRow';
6
6
  import { rankGlobalFuzzy } from '../sortingFns';
7
7
  import type { MRT_Row, MRT_TableInstance } from '..';
@@ -19,6 +19,7 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
19
19
  enableGlobalFilterRankedResults,
20
20
  enablePagination,
21
21
  enableRowVirtualization,
22
+ localization,
22
23
  manualFiltering,
23
24
  manualSorting,
24
25
  muiTableBodyProps,
@@ -27,7 +28,7 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
27
28
  },
28
29
  refs: { tableContainerRef },
29
30
  } = table;
30
- const { globalFilter, pagination, sorting } = getState();
31
+ const { columnFilters, globalFilter, pagination, sorting } = getState();
31
32
 
32
33
  const tableBodyProps =
33
34
  muiTableBodyProps instanceof Function
@@ -116,33 +117,54 @@ export const MRT_TableBody: FC<Props> = ({ table }) => {
116
117
 
117
118
  return (
118
119
  <TableBody {...tableBodyProps}>
119
- {enableRowVirtualization && paddingTop > 0 && (
120
- <tr>
121
- <td style={{ height: `${paddingTop}px` }} />
122
- </tr>
123
- )}
124
- {(enableRowVirtualization ? virtualRows : rows).map(
125
- (rowOrVirtualRow: any, rowIndex: number) => {
126
- const row = enableRowVirtualization
127
- ? (rows[rowOrVirtualRow.index] as MRT_Row)
128
- : (rowOrVirtualRow as MRT_Row);
129
- return (
130
- <MRT_TableBodyRow
131
- key={row.id}
132
- row={row}
133
- rowIndex={
134
- enableRowVirtualization ? rowOrVirtualRow.index : rowIndex
135
- }
136
- table={table}
137
- virtualRow={enableRowVirtualization ? rowOrVirtualRow : null}
138
- />
139
- );
140
- },
141
- )}
142
- {enableRowVirtualization && paddingBottom > 0 && (
143
- <tr>
144
- <td style={{ height: `${paddingBottom}px` }} />
145
- </tr>
120
+ {!rows.length ? (
121
+ <TableRow>
122
+ <TableCell colSpan={table.getVisibleLeafColumns().length}>
123
+ <Box
124
+ sx={{
125
+ maxWidth: '100vw',
126
+ py: '2rem',
127
+ textAlign: 'center',
128
+ width: '100%',
129
+ }}
130
+ >
131
+ {globalFilter || columnFilters.length
132
+ ? localization.noResultsFound
133
+ : localization.noRecordsToDisplay}
134
+ </Box>
135
+ </TableCell>
136
+ </TableRow>
137
+ ) : (
138
+ <>
139
+ {enableRowVirtualization && paddingTop > 0 && (
140
+ <tr>
141
+ <td style={{ height: `${paddingTop}px` }} />
142
+ </tr>
143
+ )}
144
+ {(enableRowVirtualization ? virtualRows : rows).map(
145
+ (rowOrVirtualRow: any, rowIndex: number) => {
146
+ const row = enableRowVirtualization
147
+ ? (rows[rowOrVirtualRow.index] as MRT_Row)
148
+ : (rowOrVirtualRow as MRT_Row);
149
+ return (
150
+ <MRT_TableBodyRow
151
+ key={row.id}
152
+ row={row}
153
+ rowIndex={
154
+ enableRowVirtualization ? rowOrVirtualRow.index : rowIndex
155
+ }
156
+ table={table}
157
+ virtualRow={enableRowVirtualization ? rowOrVirtualRow : null}
158
+ />
159
+ );
160
+ },
161
+ )}
162
+ {enableRowVirtualization && paddingBottom > 0 && (
163
+ <tr>
164
+ <td style={{ height: `${paddingBottom}px` }} />
165
+ </tr>
166
+ )}
167
+ </>
146
168
  )}
147
169
  </TableBody>
148
170
  );
@@ -47,6 +47,8 @@ export interface MRT_Localization {
47
47
  max: string;
48
48
  min: string;
49
49
  move: string;
50
+ noRecordsToDisplay: string;
51
+ noResultsFound: string;
50
52
  or: string;
51
53
  pinToLeft: string;
52
54
  pinToRight: string;
@@ -129,6 +131,8 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
129
131
  max: 'Max',
130
132
  min: 'Min',
131
133
  move: 'Move',
134
+ noRecordsToDisplay: 'No records to display',
135
+ noResultsFound: 'No results found',
132
136
  or: 'or',
133
137
  pinToLeft: 'Pin to left',
134
138
  pinToRight: 'Pin to right',