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/cjs/index.js +15 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/localization.d.ts +2 -0
- package/dist/esm/localization.d.ts +2 -0
- package/dist/esm/material-react-table.esm.js +15 -4
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/body/MRT_TableBody.tsx +51 -29
- package/src/localization.ts +4 -0
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -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
|
-
{
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
);
|
package/src/localization.ts
CHANGED
|
@@ -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',
|