material-react-table 0.19.0-alpha.1 → 0.21.0
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/MaterialReactTable.d.ts +5 -2
- package/dist/material-react-table.cjs.development.js +13 -6
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +13 -6
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +6 -2
- package/src/body/MRT_TableBody.tsx +17 -10
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.21.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/styled": "^11.9.3",
|
|
62
62
|
"@faker-js/faker": "^7.3.0",
|
|
63
63
|
"@mui/icons-material": "^5.8.4",
|
|
64
|
-
"@mui/material": "^5.8.
|
|
64
|
+
"@mui/material": "^5.8.7",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
66
|
"@storybook/addon-a11y": "^6.5.9",
|
|
67
67
|
"@storybook/addon-actions": "^6.5.9",
|
|
@@ -46,6 +46,8 @@ import { MRT_TableRoot } from './table/MRT_TableRoot';
|
|
|
46
46
|
import { MRT_FilterFns } from './filtersFns';
|
|
47
47
|
import { MRT_SortingFns } from './sortingFns';
|
|
48
48
|
|
|
49
|
+
type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
|
50
|
+
|
|
49
51
|
export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
|
|
50
52
|
Omit<
|
|
51
53
|
TableOptions<D>,
|
|
@@ -206,7 +208,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
206
208
|
*
|
|
207
209
|
* @example accessorKey: 'username'
|
|
208
210
|
*/
|
|
209
|
-
accessorKey?: keyof D
|
|
211
|
+
accessorKey?: LiteralUnion<string & keyof D>;
|
|
210
212
|
/**
|
|
211
213
|
* Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
|
|
212
214
|
* Leave this blank if you are just creating a normal data column.
|
|
@@ -229,12 +231,14 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
229
231
|
header: string;
|
|
230
232
|
/**
|
|
231
233
|
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
|
234
|
+
*
|
|
232
235
|
* If you have also specified an `accessorFn`, MRT still needs to have a valid `id` to be able to identify the column uniquely.
|
|
236
|
+
*
|
|
233
237
|
* `id` defaults to the `accessorKey` or `header` if not specified.
|
|
234
238
|
*
|
|
235
239
|
* @default gets set to the same value as `accessorKey` by default
|
|
236
240
|
*/
|
|
237
|
-
id?: string
|
|
241
|
+
id?: LiteralUnion<string & keyof D>;
|
|
238
242
|
muiTableBodyCellCopyButtonProps?:
|
|
239
243
|
| ButtonProps
|
|
240
244
|
| (({
|
|
@@ -2,8 +2,8 @@ import React, { FC, RefObject, useMemo } from 'react';
|
|
|
2
2
|
import { useVirtual } from 'react-virtual';
|
|
3
3
|
import { TableBody } from '@mui/material';
|
|
4
4
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
5
|
-
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
6
5
|
import { rankGlobalFuzzy } from '../sortingFns';
|
|
6
|
+
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
table: MRT_TableInstance;
|
|
@@ -62,19 +62,27 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
62
62
|
|
|
63
63
|
const rowVirtualizer = enableRowVirtualization
|
|
64
64
|
? useVirtual({
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// estimateSize: () => (density === 'compact' ? 25 : 50),
|
|
66
|
+
overscan: density === 'compact' ? 30 : 10,
|
|
67
67
|
parentRef: tableContainerRef,
|
|
68
|
+
size: rows.length,
|
|
68
69
|
...virtualizerProps,
|
|
69
70
|
})
|
|
70
71
|
: ({} as any);
|
|
71
72
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const virtualRows = enableRowVirtualization
|
|
74
|
+
? rowVirtualizer.virtualItems
|
|
75
|
+
: [];
|
|
76
|
+
|
|
77
|
+
let paddingTop = 0;
|
|
78
|
+
let paddingBottom = 0;
|
|
79
|
+
if (enableRowVirtualization) {
|
|
80
|
+
paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
|
|
81
|
+
paddingBottom =
|
|
82
|
+
virtualRows.length > 0
|
|
83
|
+
? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
|
|
84
|
+
: 0;
|
|
85
|
+
}
|
|
78
86
|
|
|
79
87
|
return (
|
|
80
88
|
<TableBody {...tableBodyProps}>
|
|
@@ -83,7 +91,6 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
83
91
|
<td style={{ height: `${paddingTop}px` }} />
|
|
84
92
|
</tr>
|
|
85
93
|
)}
|
|
86
|
-
{/* @ts-ignore */}
|
|
87
94
|
{(enableRowVirtualization ? virtualRows : rows).map(
|
|
88
95
|
(rowOrVirtualRow: any, rowIndex: number) => {
|
|
89
96
|
const row = enableRowVirtualization
|