react-science 11.0.0 → 11.1.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/lib/components/logger/FifoLoggerDialog.d.ts.map +1 -1
- package/lib/components/logger/FifoLoggerDialog.js +2 -2
- package/lib/components/logger/FifoLoggerDialog.js.map +1 -1
- package/lib/components/table/table_body.d.ts +3 -0
- package/lib/components/table/table_body.d.ts.map +1 -1
- package/lib/components/table/table_body.js +33 -10
- package/lib/components/table/table_body.js.map +1 -1
- package/lib/components/table/table_root.d.ts +44 -1
- package/lib/components/table/table_root.d.ts.map +1 -1
- package/lib/components/table/table_root.js +33 -3
- package/lib/components/table/table_root.js.map +1 -1
- package/lib/components/table/table_row_cell.d.ts +1 -0
- package/lib/components/table/table_row_cell.d.ts.map +1 -1
- package/lib/components/table/table_row_cell.js +2 -2
- package/lib/components/table/table_row_cell.js.map +1 -1
- package/lib/components/table/table_utils.d.ts +3 -3
- package/lib/components/table/table_utils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/logger/FifoLoggerDialog.tsx +3 -4
- package/src/components/table/table_body.tsx +91 -17
- package/src/components/table/table_root.tsx +114 -13
- package/src/components/table/table_row_cell.tsx +3 -2
- package/src/components/table/table_utils.ts +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FifoLoggerDialog.d.ts","sourceRoot":"","sources":["../../../src/components/logger/FifoLoggerDialog.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAKtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA+B5C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAqCD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"FifoLoggerDialog.d.ts","sourceRoot":"","sources":["../../../src/components/logger/FifoLoggerDialog.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAKtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA+B5C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAqCD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,oDAyD5D"}
|
|
@@ -54,9 +54,9 @@ export function FifoLoggerDialog(props) {
|
|
|
54
54
|
min-height: 500px;
|
|
55
55
|
max-height: 80vh;
|
|
56
56
|
max-width: 1000px;
|
|
57
|
-
`, children: [_jsx(DialogBody, { children: _jsx(Table, { data: props.logs, columns: columns, compact: true, bordered: true, tableProps: { style: { width: '100%' } }, renderRowTr: (
|
|
57
|
+
`, children: [_jsx(DialogBody, { children: _jsx(Table, { data: props.logs, columns: columns, compact: true, bordered: true, tableProps: { style: { width: '100%' } }, renderRowTr: (trProps, row) => (_jsx("tr", { ...trProps, style: {
|
|
58
58
|
backgroundColor: rowBackgroundColor[row.original.levelLabel],
|
|
59
|
-
}
|
|
59
|
+
} })) }) }), _jsx(DialogFooter, { actions: _jsxs(ActionsFooter, { children: [_jsx(Button, { outlined: true, intent: "danger", icon: "trash", text: "Clear logs", onClick: () => logger.clear() }), _jsx(Button, { outlined: true, intent: "none", text: "Close", onClick: props.onClose })] }) })] }));
|
|
60
60
|
}
|
|
61
61
|
// "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent"
|
|
62
62
|
const rowBackgroundColor = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FifoLoggerDialog.js","sourceRoot":"","sources":["../../../src/components/logger/FifoLoggerDialog.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AAEtC,OAAO,EAA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AK,EAAE,WAAW;IAClB,MAAM,EAAE,WAAW;CACpB,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Row, RowData } from '@tanstack/react-table';
|
|
2
|
+
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
2
3
|
import type { TableRowTrRenderer } from './table_utils.js';
|
|
3
4
|
interface TableBodyProps<TData extends RowData> {
|
|
4
5
|
rows: Array<Row<TData>>;
|
|
5
6
|
renderRowTr: TableRowTrRenderer<TData> | undefined;
|
|
7
|
+
virtualizeRows?: boolean;
|
|
8
|
+
virtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
6
9
|
}
|
|
7
10
|
export declare function TableBody<TData extends RowData>(props: TableBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
8
11
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_body.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_body.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"table_body.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_body.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMxE,OAAO,KAAK,EAAmB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,UAAU,cAAc,CAAC,KAAK,SAAS,OAAO;IAC5C,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IACnD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;CACnD;AAED,wBAAgB,SAAS,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,2CAwD5E"}
|
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { notUndefined } from '@tanstack/react-virtual';
|
|
2
3
|
import { Fragment } from 'react';
|
|
3
4
|
import { TableRowCell } from './table_row_cell.js';
|
|
4
5
|
export function TableBody(props) {
|
|
5
|
-
const { rows, renderRowTr = defaultRenderRowTr } = props;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const { rows, renderRowTr = defaultRenderRowTr, virtualizer, virtualizeRows, } = props;
|
|
7
|
+
if (virtualizeRows) {
|
|
8
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
9
|
+
const [before, after] = virtualItems.length > 0
|
|
10
|
+
? [
|
|
11
|
+
virtualItems[0].start - virtualizer.options.scrollMargin,
|
|
12
|
+
virtualizer.getTotalSize() - notUndefined(virtualItems.at(-1)).end,
|
|
13
|
+
]
|
|
14
|
+
: [0, 0];
|
|
15
|
+
return (_jsxs("tbody", { children: [before > 0 && (_jsx("tr", { children: _jsx("td", { style: { height: before } }) })), virtualItems.map((virtualItem, index) => (_jsx(TableRow, { row: rows[virtualItem.index], renderRowTr: (row) => {
|
|
16
|
+
const trProps = getTrRenderProps(row, {
|
|
17
|
+
...virtualItem,
|
|
18
|
+
virtualIndex: index,
|
|
19
|
+
});
|
|
20
|
+
return renderRowTr(trProps, row);
|
|
21
|
+
} }, virtualItem.index))), after > 0 && (_jsx("tr", { children: _jsx("td", { style: { height: after } }) }))] }));
|
|
22
|
+
}
|
|
23
|
+
return (_jsx("tbody", { children: rows.map((row) => (_jsx(TableRow, { row: row, renderRowTr: (row) => renderRowTr(getTrRenderProps(row), row) }, row.id))) }));
|
|
12
24
|
}
|
|
13
|
-
function
|
|
14
|
-
return _jsx(
|
|
25
|
+
function TableRow({ row, renderRowTr, }) {
|
|
26
|
+
return _jsx(Fragment, { children: renderRowTr(row) });
|
|
27
|
+
}
|
|
28
|
+
const defaultRenderRowTr = (trProps) => (_jsx("tr", { ...trProps }));
|
|
29
|
+
function getTrRenderProps(row, virtualItem) {
|
|
30
|
+
const index = virtualItem ? virtualItem.index : row.index;
|
|
31
|
+
return {
|
|
32
|
+
// index is 0-indexed, so odd rows are even indices
|
|
33
|
+
className: index % 2 === 0 ? 'odd' : '',
|
|
34
|
+
children: row
|
|
35
|
+
.getVisibleCells()
|
|
36
|
+
.map((cell) => _jsx(TableRowCell, { cell: cell }, cell.id)),
|
|
37
|
+
};
|
|
15
38
|
}
|
|
16
39
|
//# sourceMappingURL=table_body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_body.js","sourceRoot":"","sources":["../../../src/components/table/table_body.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"table_body.js","sourceRoot":"","sources":["../../../src/components/table/table_body.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAUnD,MAAM,UAAU,SAAS,CAAwB,KAA4B;IAC3E,MAAM,EACJ,IAAI,EACJ,WAAW,GAAG,kBAA+C,EAC7D,WAAW,EACX,cAAc,GACf,GAAG,KAAK,CAAC;IAEV,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC;QACnD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnB,YAAY,CAAC,MAAM,GAAG,CAAC;YACrB,CAAC,CAAC;gBACE,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,WAAW,CAAC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E,WAAW,CAAC,GAAG,CAAC,GAAY,CAAC;AACjD,CAAC;AAED,MAAM,kBAAkB,GAAgC,CAAC,OAAO,EAAE,EAAE,CAAC,CACnE,gBAAQ,OAAO,GAAI,CACpB,CAAC;AASF,SAAS,gBAAgB,CACvB,GAAe,EACf,WAAkC;IAElC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAE1D,OAAO;QACL,mDAAmD;QACnD,SAAS,EAAE,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACvC,QAAQ,EAAE,GAAG;aACV,eAAe,EAAE;aACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,YAAY,IAAe,IAAI,EAAE,IAAI,IAAnB,IAAI,CAAC,EAAE,CAAgB,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -2,17 +2,60 @@
|
|
|
2
2
|
import type { RowData, TableOptions } from '@tanstack/react-table';
|
|
3
3
|
import type { TableHTMLAttributes } from 'react';
|
|
4
4
|
import type { TableColumnDef, TableRowTrRenderer } from './table_utils.js';
|
|
5
|
-
|
|
5
|
+
interface TableBaseProps<TData extends RowData> {
|
|
6
6
|
data: TData[];
|
|
7
|
+
/**
|
|
8
|
+
* Tanstack table definition of columns in the table.
|
|
9
|
+
*/
|
|
7
10
|
columns: Array<TableColumnDef<TData, any>>;
|
|
11
|
+
/**
|
|
12
|
+
* Show borders between each cell and row of the table.
|
|
13
|
+
*/
|
|
8
14
|
bordered?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Reduce the padding around table cells.
|
|
17
|
+
*/
|
|
9
18
|
compact?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When hovering over a row, change its background color and set the pointer
|
|
21
|
+
* to be a cursor.
|
|
22
|
+
*/
|
|
10
23
|
interactive?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Alternate between gray and white background for each row.
|
|
26
|
+
*/
|
|
11
27
|
striped?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Enable header rows which stick to the top of the table.
|
|
30
|
+
*/
|
|
12
31
|
stickyHeader?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Use virtualized rows to optimize rendering.
|
|
34
|
+
* When virtualizing rows, and in order to prevent layout shifts,
|
|
35
|
+
* it is recommended that all columns have a fixed width.
|
|
36
|
+
*/
|
|
37
|
+
virtualizeRows?: boolean;
|
|
13
38
|
reactTable?: Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel' | 'getSortedRowModel'>;
|
|
14
39
|
tableProps?: Omit<TableHTMLAttributes<HTMLTableElement>, 'children'>;
|
|
40
|
+
/**
|
|
41
|
+
* Override the default row rendering.
|
|
42
|
+
* Make sure to spread the passed `trProps` onto the rendered `<tr>` element.
|
|
43
|
+
*/
|
|
15
44
|
renderRowTr?: TableRowTrRenderer<TData>;
|
|
16
45
|
}
|
|
46
|
+
interface RegularTableProps<TData extends RowData> extends TableBaseProps<TData> {
|
|
47
|
+
virtualizeRows?: false | undefined;
|
|
48
|
+
}
|
|
49
|
+
interface VirtualizedTableProps<TData extends RowData> extends TableBaseProps<TData> {
|
|
50
|
+
virtualizeRows: true;
|
|
51
|
+
/**
|
|
52
|
+
* For virtualization of the table rows, provide an estimate of the height of each row.
|
|
53
|
+
* @param index The index of the row in the data array.
|
|
54
|
+
* @return The estimated height of the row at the given index.
|
|
55
|
+
*/
|
|
56
|
+
estimatedRowHeight: (index: number) => number;
|
|
57
|
+
}
|
|
58
|
+
export type TableProps<TData extends RowData> = RegularTableProps<TData> | VirtualizedTableProps<TData>;
|
|
17
59
|
export declare function Table<TData extends RowData>(props: TableProps<TData>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
60
|
+
export {};
|
|
18
61
|
//# sourceMappingURL=table_root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_root.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_root.tsx"],"names":[],"mappings":"AAAA,sCAAsC;
|
|
1
|
+
{"version":3,"file":"table_root.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_root.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AAItC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAOnE,OAAO,KAAK,EAAwB,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAKvE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAc3E,UAAU,cAAc,CAAC,KAAK,SAAS,OAAO;IAC5C,IAAI,EAAE,KAAK,EAAE,CAAC;IACd;;OAEG;IAEH,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,UAAU,CAAC,EAAE,IAAI,CACf,YAAY,CAAC,KAAK,CAAC,EACnB,MAAM,GAAG,SAAS,GAAG,iBAAiB,GAAG,mBAAmB,CAC7D,CAAC;IACF,UAAU,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,CAAC;IACrE;;;OAGG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;CACzC;AAED,UAAU,iBAAiB,CAAC,KAAK,SAAS,OAAO,CAC/C,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CACpC;AAED,UAAU,qBAAqB,CAAC,KAAK,SAAS,OAAO,CACnD,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC7B,cAAc,EAAE,IAAI,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C;AAED,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,OAAO,IACxC,iBAAiB,CAAC,KAAK,CAAC,GACxB,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAEjC,wBAAgB,KAAK,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,oDAwDpE"}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { HTMLTable } from '@blueprintjs/core';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import { getCoreRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
6
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
7
|
+
import { useRef } from 'react';
|
|
5
8
|
import { TableBody } from './table_body.js';
|
|
6
9
|
import { TableHeader } from './table_header.js';
|
|
7
10
|
import { useTableColumns } from './use_table_columns.js';
|
|
11
|
+
// Blueprint's HTMLTable `striped` prop's implementation is based on nth-child odd / even
|
|
12
|
+
// We cannot use that with virtualization, so we override its implementation here.
|
|
13
|
+
const CustomHTMLTable = styled(HTMLTable, {
|
|
14
|
+
shouldForwardProp: (prop) => prop !== 'striped',
|
|
15
|
+
}) `
|
|
16
|
+
tbody tr.odd td {
|
|
17
|
+
background: ${(props) => props.striped ? 'rgba(143, 153, 168, 0.15)' : 'inherit'};
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
8
20
|
export function Table(props) {
|
|
9
|
-
const { data, columns, bordered = false, compact = false, interactive = false, striped = false, stickyHeader = false, reactTable, tableProps, renderRowTr, } = props;
|
|
21
|
+
const { data, columns, bordered = false, compact = false, interactive = false, striped = false, stickyHeader = false, reactTable, tableProps, renderRowTr, virtualizeRows, } = props;
|
|
22
|
+
const scrollElementRef = useRef(null);
|
|
10
23
|
const columnDefs = useTableColumns(columns);
|
|
11
24
|
const table = useReactTable({
|
|
12
25
|
...reactTable,
|
|
@@ -15,6 +28,23 @@ export function Table(props) {
|
|
|
15
28
|
getCoreRowModel: getCoreRowModel(),
|
|
16
29
|
getSortedRowModel: getSortedRowModel(),
|
|
17
30
|
});
|
|
18
|
-
|
|
31
|
+
const tanstackVirtualizer = useVirtualizer({
|
|
32
|
+
enabled: virtualizeRows,
|
|
33
|
+
count: data.length,
|
|
34
|
+
getScrollElement: () => scrollElementRef.current,
|
|
35
|
+
estimateSize: (props.virtualizeRows && props.estimatedRowHeight) || (() => 0),
|
|
36
|
+
overscan: 5,
|
|
37
|
+
});
|
|
38
|
+
return (_jsx(Container, { virtualizeRows: virtualizeRows, scrollRef: scrollElementRef, children: _jsxs(CustomHTMLTable, { bordered: bordered, compact: compact, interactive: interactive, striped: striped, ...tableProps, children: [_jsx(TableHeader, { sticky: stickyHeader, headers: table.getFlatHeaders() }), _jsx(TableBody, { rows: table.getRowModel().rows, renderRowTr: renderRowTr, virtualizer: tanstackVirtualizer, virtualizeRows: virtualizeRows })] }) }));
|
|
39
|
+
}
|
|
40
|
+
const ScrollRefDiv = styled.div `
|
|
41
|
+
height: 100%;
|
|
42
|
+
overflow: auto;
|
|
43
|
+
`;
|
|
44
|
+
function Container({ virtualizeRows, scrollRef, children, }) {
|
|
45
|
+
if (virtualizeRows) {
|
|
46
|
+
return _jsx(ScrollRefDiv, { ref: scrollRef, children: children });
|
|
47
|
+
}
|
|
48
|
+
return _jsx(_Fragment, { children: children });
|
|
19
49
|
}
|
|
20
50
|
//# sourceMappingURL=table_root.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_root.js","sourceRoot":"","sources":["../../../src/components/table/table_root.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"table_root.js","sourceRoot":"","sources":["../../../src/components/table/table_root.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,yFAAyF;AACzF,kFAAkF;AAClF,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,EAAE;IACxC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS;CAChD,CAAC,CAAA;;kBAEgB,CAAC,KAAK,EAAE,EAAE,CACtB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,SAAS;;CAE5D,CAAC;AAqEF,MAAM,UAAU,KAAK,CAAwB,KAAwB;IACnE,MAAM,EACJ,IAAI,EACJ,OAAO,EAEP,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,EACf,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,KAAK,EAEpB,UAA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EACjB,cAAc,EACd,SAAS,EACT,QAAQ,GAKT;IACC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,KAAC,YAAY,IAAC,GAAG,EAAE,SAAS,YAAG,QAAQ,GAAgB,CAAC;IACjE,CAAC;IACD,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Cell, RowData } from '@tanstack/react-table';
|
|
2
2
|
interface TableRowCellProps<TData extends RowData> {
|
|
3
3
|
cell: Cell<TData, unknown>;
|
|
4
|
+
className?: string;
|
|
4
5
|
}
|
|
5
6
|
export declare function TableRowCell<TData extends RowData>(props: TableRowCellProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_row_cell.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_row_cell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG3D,UAAU,iBAAiB,CAAC,KAAK,SAAS,OAAO;IAC/C,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"table_row_cell.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_row_cell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG3D,UAAU,iBAAiB,CAAC,KAAK,SAAS,OAAO;IAC/C,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,OAAO,EAChD,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC,2CAShC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { flexRender } from '@tanstack/react-table';
|
|
3
3
|
export function TableRowCell(props) {
|
|
4
|
-
const { cell } = props;
|
|
5
|
-
return (_jsx("td", { style: { position: 'relative' }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
4
|
+
const { cell, className } = props;
|
|
5
|
+
return (_jsx("td", { style: { position: 'relative' }, className: className, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=table_row_cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_row_cell.js","sourceRoot":"","sources":["../../../src/components/table/table_row_cell.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"table_row_cell.js","sourceRoot":"","sources":["../../../src/components/table/table_row_cell.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAOnD,MAAM,UAAU,YAAY,CAC1B,KAA+B;IAE/B,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAElC,OAAO,CACL,aAAI,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,SAAS,YACtD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,GACvD,CACN,CAAC;AACJ,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { ColumnDef, Row, RowData } from '@tanstack/react-table';
|
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
export type TableColumnDef<TData extends RowData, TValue = unknown> = ColumnDef<TData, TValue>;
|
|
4
4
|
export declare function createTableColumnHelper<TData extends RowData>(): import("@tanstack/react-table").ColumnHelper<TData>;
|
|
5
|
-
export interface
|
|
6
|
-
|
|
5
|
+
export interface TableRowTrProps {
|
|
6
|
+
className: string;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
|
-
export type TableRowTrRenderer<TData extends RowData> = (
|
|
9
|
+
export type TableRowTrRenderer<TData extends RowData> = (trProps: TableRowTrProps, row: Row<TData>) => ReactNode;
|
|
10
10
|
//# sourceMappingURL=table_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table_utils.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,SAAS,CAC7E,KAAK,EACL,MAAM,CACP,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,OAAO,yDAE5D;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"table_utils.d.ts","sourceRoot":"","sources":["../../../src/components/table/table_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,SAAS,CAC7E,KAAK,EACL,MAAM,CACP,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,OAAO,yDAE5D;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,OAAO,IAAI,CACtD,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,KACZ,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-science",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "React components to build scientific applications UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@radix-ui/react-radio-group": "^1.2.1",
|
|
62
62
|
"@tanstack/react-query": "^5.61.5",
|
|
63
63
|
"@tanstack/react-table": "^8.20.5",
|
|
64
|
+
"@tanstack/react-virtual": "^3.10.9",
|
|
64
65
|
"d3-scale-chromatic": "^3.1.0",
|
|
65
66
|
"immer": "^10.1.1",
|
|
66
67
|
"lodash": "^4.17.21",
|
|
@@ -102,14 +102,13 @@ export function FifoLoggerDialog(props: FifoLoggerDialogProps) {
|
|
|
102
102
|
compact
|
|
103
103
|
bordered
|
|
104
104
|
tableProps={{ style: { width: '100%' } }}
|
|
105
|
-
renderRowTr={(
|
|
105
|
+
renderRowTr={(trProps, row) => (
|
|
106
106
|
<tr
|
|
107
|
+
{...trProps}
|
|
107
108
|
style={{
|
|
108
109
|
backgroundColor: rowBackgroundColor[row.original.levelLabel],
|
|
109
110
|
}}
|
|
110
|
-
|
|
111
|
-
{children}
|
|
112
|
-
</tr>
|
|
111
|
+
/>
|
|
113
112
|
)}
|
|
114
113
|
/>
|
|
115
114
|
</DialogBody>
|
|
@@ -1,37 +1,111 @@
|
|
|
1
1
|
import type { Row, RowData } from '@tanstack/react-table';
|
|
2
|
+
import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
|
3
|
+
import { notUndefined } from '@tanstack/react-virtual';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
import { Fragment } from 'react';
|
|
3
6
|
|
|
4
7
|
import { TableRowCell } from './table_row_cell.js';
|
|
5
|
-
import type {
|
|
6
|
-
TableRowTrRenderer,
|
|
7
|
-
TableRowTrRendererProps,
|
|
8
|
-
} from './table_utils.js';
|
|
8
|
+
import type { TableRowTrProps, TableRowTrRenderer } from './table_utils.js';
|
|
9
9
|
|
|
10
10
|
interface TableBodyProps<TData extends RowData> {
|
|
11
11
|
rows: Array<Row<TData>>;
|
|
12
12
|
renderRowTr: TableRowTrRenderer<TData> | undefined;
|
|
13
|
+
virtualizeRows?: boolean;
|
|
14
|
+
virtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export function TableBody<TData extends RowData>(props: TableBodyProps<TData>) {
|
|
16
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
rows,
|
|
20
|
+
renderRowTr = defaultRenderRowTr as TableRowTrRenderer<TData>,
|
|
21
|
+
virtualizer,
|
|
22
|
+
virtualizeRows,
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
if (virtualizeRows) {
|
|
26
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
27
|
+
const [before, after] =
|
|
28
|
+
virtualItems.length > 0
|
|
29
|
+
? [
|
|
30
|
+
virtualItems[0].start - virtualizer.options.scrollMargin,
|
|
31
|
+
virtualizer.getTotalSize() - notUndefined(virtualItems.at(-1)).end,
|
|
32
|
+
]
|
|
33
|
+
: [0, 0];
|
|
34
|
+
return (
|
|
35
|
+
<tbody>
|
|
36
|
+
{before > 0 && (
|
|
37
|
+
<tr>
|
|
38
|
+
<td style={{ height: before }} />
|
|
39
|
+
</tr>
|
|
40
|
+
)}
|
|
41
|
+
{virtualItems.map((virtualItem, index) => (
|
|
42
|
+
<TableRow
|
|
43
|
+
key={virtualItem.index}
|
|
44
|
+
row={rows[virtualItem.index]}
|
|
45
|
+
renderRowTr={(row) => {
|
|
46
|
+
const trProps = getTrRenderProps<TData>(row, {
|
|
47
|
+
...virtualItem,
|
|
48
|
+
virtualIndex: index,
|
|
49
|
+
});
|
|
50
|
+
return renderRowTr(trProps, row);
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
))}
|
|
54
|
+
{after > 0 && (
|
|
55
|
+
<tr>
|
|
56
|
+
<td style={{ height: after }} />
|
|
57
|
+
</tr>
|
|
58
|
+
)}
|
|
59
|
+
</tbody>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
17
62
|
return (
|
|
18
63
|
<tbody>
|
|
19
64
|
{rows.map((row) => (
|
|
20
|
-
<
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.map((cell) => <TableRowCell key={cell.id} cell={cell} />),
|
|
26
|
-
})}
|
|
27
|
-
</Fragment>
|
|
65
|
+
<TableRow
|
|
66
|
+
key={row.id}
|
|
67
|
+
row={row}
|
|
68
|
+
renderRowTr={(row) => renderRowTr(getTrRenderProps(row), row)}
|
|
69
|
+
/>
|
|
28
70
|
))}
|
|
29
71
|
</tbody>
|
|
30
72
|
);
|
|
31
73
|
}
|
|
32
74
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
75
|
+
type TableRowRenderer<TData extends RowData> = (row: Row<TData>) => ReactNode;
|
|
76
|
+
|
|
77
|
+
function TableRow<TData>({
|
|
78
|
+
row,
|
|
79
|
+
renderRowTr,
|
|
80
|
+
}: {
|
|
81
|
+
row: Row<TData>;
|
|
82
|
+
renderRowTr: TableRowRenderer<TData>;
|
|
83
|
+
}) {
|
|
84
|
+
return <Fragment>{renderRowTr(row)}</Fragment>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const defaultRenderRowTr: TableRowTrRenderer<unknown> = (trProps) => (
|
|
88
|
+
<tr {...trProps} />
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
type RenderRowVirtualItem = VirtualItem & {
|
|
92
|
+
/**
|
|
93
|
+
* The index of the element within the virtual list being currently rendered.
|
|
94
|
+
*/
|
|
95
|
+
virtualIndex: number;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
function getTrRenderProps<TData extends RowData>(
|
|
99
|
+
row: Row<TData>,
|
|
100
|
+
virtualItem?: RenderRowVirtualItem,
|
|
101
|
+
): TableRowTrProps {
|
|
102
|
+
const index = virtualItem ? virtualItem.index : row.index;
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
// index is 0-indexed, so odd rows are even indices
|
|
106
|
+
className: index % 2 === 0 ? 'odd' : '',
|
|
107
|
+
children: row
|
|
108
|
+
.getVisibleCells()
|
|
109
|
+
.map((cell) => <TableRowCell key={cell.id} cell={cell} />),
|
|
110
|
+
};
|
|
37
111
|
}
|
|
@@ -1,38 +1,100 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
|
|
3
3
|
import { HTMLTable } from '@blueprintjs/core';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import type { RowData, TableOptions } from '@tanstack/react-table';
|
|
5
6
|
import {
|
|
6
7
|
getCoreRowModel,
|
|
7
8
|
getSortedRowModel,
|
|
8
9
|
useReactTable,
|
|
9
10
|
} from '@tanstack/react-table';
|
|
10
|
-
import
|
|
11
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
12
|
+
import type { ReactNode, RefObject, TableHTMLAttributes } from 'react';
|
|
13
|
+
import { useRef } from 'react';
|
|
11
14
|
|
|
12
15
|
import { TableBody } from './table_body.js';
|
|
13
16
|
import { TableHeader } from './table_header.js';
|
|
14
17
|
import type { TableColumnDef, TableRowTrRenderer } from './table_utils.js';
|
|
15
18
|
import { useTableColumns } from './use_table_columns.js';
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
// Blueprint's HTMLTable `striped` prop's implementation is based on nth-child odd / even
|
|
21
|
+
// We cannot use that with virtualization, so we override its implementation here.
|
|
22
|
+
const CustomHTMLTable = styled(HTMLTable, {
|
|
23
|
+
shouldForwardProp: (prop) => prop !== 'striped',
|
|
24
|
+
})`
|
|
25
|
+
tbody tr.odd td {
|
|
26
|
+
background: ${(props) =>
|
|
27
|
+
props.striped ? 'rgba(143, 153, 168, 0.15)' : 'inherit'};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
interface TableBaseProps<TData extends RowData> {
|
|
18
32
|
data: TData[];
|
|
33
|
+
/**
|
|
34
|
+
* Tanstack table definition of columns in the table.
|
|
35
|
+
*/
|
|
19
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
37
|
columns: Array<TableColumnDef<TData, any>>;
|
|
21
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Show borders between each cell and row of the table.
|
|
40
|
+
*/
|
|
22
41
|
bordered?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Reduce the padding around table cells.
|
|
44
|
+
*/
|
|
23
45
|
compact?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* When hovering over a row, change its background color and set the pointer
|
|
48
|
+
* to be a cursor.
|
|
49
|
+
*/
|
|
24
50
|
interactive?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Alternate between gray and white background for each row.
|
|
53
|
+
*/
|
|
25
54
|
striped?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Enable header rows which stick to the top of the table.
|
|
57
|
+
*/
|
|
26
58
|
stickyHeader?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Use virtualized rows to optimize rendering.
|
|
61
|
+
* When virtualizing rows, and in order to prevent layout shifts,
|
|
62
|
+
* it is recommended that all columns have a fixed width.
|
|
63
|
+
*/
|
|
64
|
+
virtualizeRows?: boolean;
|
|
27
65
|
|
|
28
66
|
reactTable?: Omit<
|
|
29
67
|
TableOptions<TData>,
|
|
30
68
|
'data' | 'columns' | 'getCoreRowModel' | 'getSortedRowModel'
|
|
31
69
|
>;
|
|
32
70
|
tableProps?: Omit<TableHTMLAttributes<HTMLTableElement>, 'children'>;
|
|
71
|
+
/**
|
|
72
|
+
* Override the default row rendering.
|
|
73
|
+
* Make sure to spread the passed `trProps` onto the rendered `<tr>` element.
|
|
74
|
+
*/
|
|
33
75
|
renderRowTr?: TableRowTrRenderer<TData>;
|
|
34
76
|
}
|
|
35
77
|
|
|
78
|
+
interface RegularTableProps<TData extends RowData>
|
|
79
|
+
extends TableBaseProps<TData> {
|
|
80
|
+
virtualizeRows?: false | undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface VirtualizedTableProps<TData extends RowData>
|
|
84
|
+
extends TableBaseProps<TData> {
|
|
85
|
+
virtualizeRows: true;
|
|
86
|
+
/**
|
|
87
|
+
* For virtualization of the table rows, provide an estimate of the height of each row.
|
|
88
|
+
* @param index The index of the row in the data array.
|
|
89
|
+
* @return The estimated height of the row at the given index.
|
|
90
|
+
*/
|
|
91
|
+
estimatedRowHeight: (index: number) => number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type TableProps<TData extends RowData> =
|
|
95
|
+
| RegularTableProps<TData>
|
|
96
|
+
| VirtualizedTableProps<TData>;
|
|
97
|
+
|
|
36
98
|
export function Table<TData extends RowData>(props: TableProps<TData>) {
|
|
37
99
|
const {
|
|
38
100
|
data,
|
|
@@ -47,8 +109,11 @@ export function Table<TData extends RowData>(props: TableProps<TData>) {
|
|
|
47
109
|
reactTable,
|
|
48
110
|
tableProps,
|
|
49
111
|
renderRowTr,
|
|
112
|
+
|
|
113
|
+
virtualizeRows,
|
|
50
114
|
} = props;
|
|
51
115
|
|
|
116
|
+
const scrollElementRef = useRef<HTMLDivElement>(null);
|
|
52
117
|
const columnDefs = useTableColumns(columns);
|
|
53
118
|
const table = useReactTable<TData>({
|
|
54
119
|
...reactTable,
|
|
@@ -58,16 +123,52 @@ export function Table<TData extends RowData>(props: TableProps<TData>) {
|
|
|
58
123
|
getSortedRowModel: getSortedRowModel(),
|
|
59
124
|
});
|
|
60
125
|
|
|
126
|
+
const tanstackVirtualizer = useVirtualizer({
|
|
127
|
+
enabled: virtualizeRows,
|
|
128
|
+
count: data.length,
|
|
129
|
+
getScrollElement: () => scrollElementRef.current,
|
|
130
|
+
estimateSize:
|
|
131
|
+
(props.virtualizeRows && props.estimatedRowHeight) || (() => 0),
|
|
132
|
+
overscan: 5,
|
|
133
|
+
});
|
|
134
|
+
|
|
61
135
|
return (
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
136
|
+
<Container virtualizeRows={virtualizeRows} scrollRef={scrollElementRef}>
|
|
137
|
+
<CustomHTMLTable
|
|
138
|
+
bordered={bordered}
|
|
139
|
+
compact={compact}
|
|
140
|
+
interactive={interactive}
|
|
141
|
+
striped={striped}
|
|
142
|
+
{...tableProps}
|
|
143
|
+
>
|
|
144
|
+
<TableHeader sticky={stickyHeader} headers={table.getFlatHeaders()} />
|
|
145
|
+
<TableBody
|
|
146
|
+
rows={table.getRowModel().rows}
|
|
147
|
+
renderRowTr={renderRowTr}
|
|
148
|
+
virtualizer={tanstackVirtualizer}
|
|
149
|
+
virtualizeRows={virtualizeRows}
|
|
150
|
+
/>
|
|
151
|
+
</CustomHTMLTable>
|
|
152
|
+
</Container>
|
|
72
153
|
);
|
|
73
154
|
}
|
|
155
|
+
|
|
156
|
+
const ScrollRefDiv = styled.div`
|
|
157
|
+
height: 100%;
|
|
158
|
+
overflow: auto;
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
function Container({
|
|
162
|
+
virtualizeRows,
|
|
163
|
+
scrollRef,
|
|
164
|
+
children,
|
|
165
|
+
}: {
|
|
166
|
+
virtualizeRows?: boolean;
|
|
167
|
+
children: ReactNode;
|
|
168
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
169
|
+
}) {
|
|
170
|
+
if (virtualizeRows) {
|
|
171
|
+
return <ScrollRefDiv ref={scrollRef}>{children}</ScrollRefDiv>;
|
|
172
|
+
}
|
|
173
|
+
return <>{children}</>;
|
|
174
|
+
}
|
|
@@ -3,15 +3,16 @@ import { flexRender } from '@tanstack/react-table';
|
|
|
3
3
|
|
|
4
4
|
interface TableRowCellProps<TData extends RowData> {
|
|
5
5
|
cell: Cell<TData, unknown>;
|
|
6
|
+
className?: string;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export function TableRowCell<TData extends RowData>(
|
|
9
10
|
props: TableRowCellProps<TData>,
|
|
10
11
|
) {
|
|
11
|
-
const { cell } = props;
|
|
12
|
+
const { cell, className } = props;
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
|
-
<td style={{ position: 'relative' }}>
|
|
15
|
+
<td style={{ position: 'relative' }} className={className}>
|
|
15
16
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
16
17
|
</td>
|
|
17
18
|
);
|
|
@@ -11,10 +11,12 @@ export function createTableColumnHelper<TData extends RowData>() {
|
|
|
11
11
|
return createColumnHelper<TData>();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface
|
|
15
|
-
|
|
14
|
+
export interface TableRowTrProps {
|
|
15
|
+
className: string;
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
}
|
|
18
|
+
|
|
18
19
|
export type TableRowTrRenderer<TData extends RowData> = (
|
|
19
|
-
|
|
20
|
+
trProps: TableRowTrProps,
|
|
21
|
+
row: Row<TData>,
|
|
20
22
|
) => ReactNode;
|