@trackunit/react-table 0.0.74-alpha-8c607117a7.0 → 0.0.75
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/index.cjs.js +738 -484
- package/index.esm.js +741 -484
- package/package.json +13 -13
- package/src/Table.d.ts +2 -1
- package/src/translation.d.ts +2 -2
- package/src/useInfiniteScroll.d.ts +3 -4
package/index.esm.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { useContainerProps, IconButton, Icon, Text, MoreMenu, MenuList, Button, Card, EmptyState, Tooltip, Popover, PopoverTrigger, PopoverContent } from '@trackunit/react-components';
|
|
3
|
+
import { useContainerProps, IconButton, Icon, Text, MoreMenu, MenuList, Button, Card, EmptyState, Spinner, Tooltip, Popover, PopoverTrigger, PopoverContent } from '@trackunit/react-components';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import { useState, useEffect, useCallback, useRef, createContext, memo as memo$2, isValidElement, cloneElement, useLayoutEffect, useMemo, useContext } from 'react';
|
|
6
6
|
import { Link } from 'react-router-dom';
|
|
7
7
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
8
8
|
import { TableRoot, Thead, Tr, Th, SortIndicator, ResizeHandle, Tbody, Td } from '@trackunit/react-table-base-components';
|
|
9
|
+
import { flushSync } from 'react-dom';
|
|
9
10
|
import { Toggle, RadioGroup, RadioItem } from '@trackunit/react-form-components';
|
|
10
11
|
import { SortOrder, validateStringAsAssetSortByProperty } from '@trackunit/react-core-contexts-api';
|
|
11
12
|
|
|
@@ -19,6 +20,7 @@ var defaultTranslations = {
|
|
|
19
20
|
"table.sorting.toolip": "Adjust sorting and direction",
|
|
20
21
|
"table.columnFilters.columns": "Columns",
|
|
21
22
|
"table.columnFilters.hiddenColumnCount": "{{count}} column hidden",
|
|
23
|
+
"table.columnFilters.hiddenColumnsCount": "{{count}} columns hidden",
|
|
22
24
|
"table.columnFilters.title": "Visible values",
|
|
23
25
|
"table.columnFilters.tooltip": "Customize visible values",
|
|
24
26
|
"table.exportFileName": "exported-data",
|
|
@@ -204,7 +206,7 @@ function flattenBy(arr, getChildren) {
|
|
|
204
206
|
recurse(arr);
|
|
205
207
|
return flat;
|
|
206
208
|
}
|
|
207
|
-
function memo(getDeps, fn, opts) {
|
|
209
|
+
function memo$1(getDeps, fn, opts) {
|
|
208
210
|
let deps = [];
|
|
209
211
|
let result;
|
|
210
212
|
return () => {
|
|
@@ -285,7 +287,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
285
287
|
depth,
|
|
286
288
|
columnDef: resolvedColumnDef,
|
|
287
289
|
columns: [],
|
|
288
|
-
getFlatColumns: memo(() => [true], () => {
|
|
290
|
+
getFlatColumns: memo$1(() => [true], () => {
|
|
289
291
|
var _column$columns;
|
|
290
292
|
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
291
293
|
}, {
|
|
@@ -295,7 +297,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
295
297
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugColumns;
|
|
296
298
|
}
|
|
297
299
|
}),
|
|
298
|
-
getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
300
|
+
getLeafColumns: memo$1(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
299
301
|
var _column$columns2;
|
|
300
302
|
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
301
303
|
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
@@ -361,7 +363,7 @@ const Headers = {
|
|
|
361
363
|
return {
|
|
362
364
|
// Header Groups
|
|
363
365
|
|
|
364
|
-
getHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
366
|
+
getHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
365
367
|
var _left$map$filter, _right$map$filter;
|
|
366
368
|
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
367
369
|
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
@@ -375,7 +377,7 @@ const Headers = {
|
|
|
375
377
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugHeaders;
|
|
376
378
|
}
|
|
377
379
|
}),
|
|
378
|
-
getCenterHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
380
|
+
getCenterHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
379
381
|
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
380
382
|
return buildHeaderGroups(allColumns, leafColumns, table, 'center');
|
|
381
383
|
}, {
|
|
@@ -385,7 +387,7 @@ const Headers = {
|
|
|
385
387
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugHeaders;
|
|
386
388
|
}
|
|
387
389
|
}),
|
|
388
|
-
getLeftHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
390
|
+
getLeftHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
389
391
|
var _left$map$filter2;
|
|
390
392
|
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
391
393
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
|
|
@@ -396,7 +398,7 @@ const Headers = {
|
|
|
396
398
|
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugHeaders;
|
|
397
399
|
}
|
|
398
400
|
}),
|
|
399
|
-
getRightHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
401
|
+
getRightHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
400
402
|
var _right$map$filter2;
|
|
401
403
|
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
402
404
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
|
|
@@ -409,7 +411,7 @@ const Headers = {
|
|
|
409
411
|
}),
|
|
410
412
|
// Footer Groups
|
|
411
413
|
|
|
412
|
-
getFooterGroups: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
414
|
+
getFooterGroups: memo$1(() => [table.getHeaderGroups()], headerGroups => {
|
|
413
415
|
return [...headerGroups].reverse();
|
|
414
416
|
}, {
|
|
415
417
|
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
@@ -418,7 +420,7 @@ const Headers = {
|
|
|
418
420
|
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugHeaders;
|
|
419
421
|
}
|
|
420
422
|
}),
|
|
421
|
-
getLeftFooterGroups: memo(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
423
|
+
getLeftFooterGroups: memo$1(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
422
424
|
return [...headerGroups].reverse();
|
|
423
425
|
}, {
|
|
424
426
|
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
@@ -427,7 +429,7 @@ const Headers = {
|
|
|
427
429
|
return (_table$options$debugA6 = table.options.debugAll) != null ? _table$options$debugA6 : table.options.debugHeaders;
|
|
428
430
|
}
|
|
429
431
|
}),
|
|
430
|
-
getCenterFooterGroups: memo(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
432
|
+
getCenterFooterGroups: memo$1(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
431
433
|
return [...headerGroups].reverse();
|
|
432
434
|
}, {
|
|
433
435
|
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
@@ -436,7 +438,7 @@ const Headers = {
|
|
|
436
438
|
return (_table$options$debugA7 = table.options.debugAll) != null ? _table$options$debugA7 : table.options.debugHeaders;
|
|
437
439
|
}
|
|
438
440
|
}),
|
|
439
|
-
getRightFooterGroups: memo(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
441
|
+
getRightFooterGroups: memo$1(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
440
442
|
return [...headerGroups].reverse();
|
|
441
443
|
}, {
|
|
442
444
|
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
@@ -447,7 +449,7 @@ const Headers = {
|
|
|
447
449
|
}),
|
|
448
450
|
// Flat Headers
|
|
449
451
|
|
|
450
|
-
getFlatHeaders: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
452
|
+
getFlatHeaders: memo$1(() => [table.getHeaderGroups()], headerGroups => {
|
|
451
453
|
return headerGroups.map(headerGroup => {
|
|
452
454
|
return headerGroup.headers;
|
|
453
455
|
}).flat();
|
|
@@ -458,7 +460,7 @@ const Headers = {
|
|
|
458
460
|
return (_table$options$debugA9 = table.options.debugAll) != null ? _table$options$debugA9 : table.options.debugHeaders;
|
|
459
461
|
}
|
|
460
462
|
}),
|
|
461
|
-
getLeftFlatHeaders: memo(() => [table.getLeftHeaderGroups()], left => {
|
|
463
|
+
getLeftFlatHeaders: memo$1(() => [table.getLeftHeaderGroups()], left => {
|
|
462
464
|
return left.map(headerGroup => {
|
|
463
465
|
return headerGroup.headers;
|
|
464
466
|
}).flat();
|
|
@@ -469,7 +471,7 @@ const Headers = {
|
|
|
469
471
|
return (_table$options$debugA10 = table.options.debugAll) != null ? _table$options$debugA10 : table.options.debugHeaders;
|
|
470
472
|
}
|
|
471
473
|
}),
|
|
472
|
-
getCenterFlatHeaders: memo(() => [table.getCenterHeaderGroups()], left => {
|
|
474
|
+
getCenterFlatHeaders: memo$1(() => [table.getCenterHeaderGroups()], left => {
|
|
473
475
|
return left.map(headerGroup => {
|
|
474
476
|
return headerGroup.headers;
|
|
475
477
|
}).flat();
|
|
@@ -480,7 +482,7 @@ const Headers = {
|
|
|
480
482
|
return (_table$options$debugA11 = table.options.debugAll) != null ? _table$options$debugA11 : table.options.debugHeaders;
|
|
481
483
|
}
|
|
482
484
|
}),
|
|
483
|
-
getRightFlatHeaders: memo(() => [table.getRightHeaderGroups()], left => {
|
|
485
|
+
getRightFlatHeaders: memo$1(() => [table.getRightHeaderGroups()], left => {
|
|
484
486
|
return left.map(headerGroup => {
|
|
485
487
|
return headerGroup.headers;
|
|
486
488
|
}).flat();
|
|
@@ -493,7 +495,7 @@ const Headers = {
|
|
|
493
495
|
}),
|
|
494
496
|
// Leaf Headers
|
|
495
497
|
|
|
496
|
-
getCenterLeafHeaders: memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
498
|
+
getCenterLeafHeaders: memo$1(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
497
499
|
return flatHeaders.filter(header => {
|
|
498
500
|
var _header$subHeaders;
|
|
499
501
|
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
@@ -505,7 +507,7 @@ const Headers = {
|
|
|
505
507
|
return (_table$options$debugA13 = table.options.debugAll) != null ? _table$options$debugA13 : table.options.debugHeaders;
|
|
506
508
|
}
|
|
507
509
|
}),
|
|
508
|
-
getLeftLeafHeaders: memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
510
|
+
getLeftLeafHeaders: memo$1(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
509
511
|
return flatHeaders.filter(header => {
|
|
510
512
|
var _header$subHeaders2;
|
|
511
513
|
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
@@ -517,7 +519,7 @@ const Headers = {
|
|
|
517
519
|
return (_table$options$debugA14 = table.options.debugAll) != null ? _table$options$debugA14 : table.options.debugHeaders;
|
|
518
520
|
}
|
|
519
521
|
}),
|
|
520
|
-
getRightLeafHeaders: memo(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
522
|
+
getRightLeafHeaders: memo$1(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
521
523
|
return flatHeaders.filter(header => {
|
|
522
524
|
var _header$subHeaders3;
|
|
523
525
|
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
@@ -529,7 +531,7 @@ const Headers = {
|
|
|
529
531
|
return (_table$options$debugA15 = table.options.debugAll) != null ? _table$options$debugA15 : table.options.debugHeaders;
|
|
530
532
|
}
|
|
531
533
|
}),
|
|
532
|
-
getLeafHeaders: memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
534
|
+
getLeafHeaders: memo$1(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
533
535
|
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
534
536
|
return [...((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : []), ...((_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : []), ...((_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : [])].map(header => {
|
|
535
537
|
return header.getLeafHeaders();
|
|
@@ -1622,7 +1624,7 @@ const Ordering = {
|
|
|
1622
1624
|
var _table$initialState$c;
|
|
1623
1625
|
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1624
1626
|
},
|
|
1625
|
-
_getOrderColumnsFn: memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1627
|
+
_getOrderColumnsFn: memo$1(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1626
1628
|
// Sort grouped columns to the start of the column list
|
|
1627
1629
|
// before the headers are built
|
|
1628
1630
|
let orderedColumns = [];
|
|
@@ -1756,7 +1758,7 @@ const Pagination = {
|
|
|
1756
1758
|
pageCount: newPageCount
|
|
1757
1759
|
};
|
|
1758
1760
|
}),
|
|
1759
|
-
getPageOptions: memo(() => [table.getPageCount()], pageCount => {
|
|
1761
|
+
getPageOptions: memo$1(() => [table.getPageCount()], pageCount => {
|
|
1760
1762
|
let pageOptions = [];
|
|
1761
1763
|
if (pageCount && pageCount > 0) {
|
|
1762
1764
|
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
@@ -1879,7 +1881,7 @@ const Pinning = {
|
|
|
1879
1881
|
},
|
|
1880
1882
|
createRow: (row, table) => {
|
|
1881
1883
|
return {
|
|
1882
|
-
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1884
|
+
getCenterVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1883
1885
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1884
1886
|
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1885
1887
|
}, {
|
|
@@ -1889,7 +1891,7 @@ const Pinning = {
|
|
|
1889
1891
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
1890
1892
|
}
|
|
1891
1893
|
}),
|
|
1892
|
-
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
|
|
1894
|
+
getLeftVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
|
|
1893
1895
|
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1894
1896
|
...d,
|
|
1895
1897
|
position: 'left'
|
|
@@ -1902,7 +1904,7 @@ const Pinning = {
|
|
|
1902
1904
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugRows;
|
|
1903
1905
|
}
|
|
1904
1906
|
}),
|
|
1905
|
-
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1907
|
+
getRightVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1906
1908
|
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1907
1909
|
...d,
|
|
1908
1910
|
position: 'right'
|
|
@@ -1933,7 +1935,7 @@ const Pinning = {
|
|
|
1933
1935
|
}
|
|
1934
1936
|
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1935
1937
|
},
|
|
1936
|
-
getLeftLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1938
|
+
getLeftLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1937
1939
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1938
1940
|
}, {
|
|
1939
1941
|
key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
|
|
@@ -1942,7 +1944,7 @@ const Pinning = {
|
|
|
1942
1944
|
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
1943
1945
|
}
|
|
1944
1946
|
}),
|
|
1945
|
-
getRightLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1947
|
+
getRightLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1946
1948
|
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1947
1949
|
}, {
|
|
1948
1950
|
key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
|
|
@@ -1951,7 +1953,7 @@ const Pinning = {
|
|
|
1951
1953
|
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugColumns;
|
|
1952
1954
|
}
|
|
1953
1955
|
}),
|
|
1954
|
-
getCenterLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1956
|
+
getCenterLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1955
1957
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1956
1958
|
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1957
1959
|
}, {
|
|
@@ -2087,7 +2089,7 @@ const RowSelection = {
|
|
|
2087
2089
|
// table.setRowSelection(selectedRowIds)
|
|
2088
2090
|
// },
|
|
2089
2091
|
getPreSelectedRowModel: () => table.getCoreRowModel(),
|
|
2090
|
-
getSelectedRowModel: memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
2092
|
+
getSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
2091
2093
|
if (!Object.keys(rowSelection).length) {
|
|
2092
2094
|
return {
|
|
2093
2095
|
rows: [],
|
|
@@ -2103,7 +2105,7 @@ const RowSelection = {
|
|
|
2103
2105
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
2104
2106
|
}
|
|
2105
2107
|
}),
|
|
2106
|
-
getFilteredSelectedRowModel: memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2108
|
+
getFilteredSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2107
2109
|
if (!Object.keys(rowSelection).length) {
|
|
2108
2110
|
return {
|
|
2109
2111
|
rows: [],
|
|
@@ -2119,7 +2121,7 @@ const RowSelection = {
|
|
|
2119
2121
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugTable;
|
|
2120
2122
|
}
|
|
2121
2123
|
}),
|
|
2122
|
-
getGroupedSelectedRowModel: memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2124
|
+
getGroupedSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2123
2125
|
if (!Object.keys(rowSelection).length) {
|
|
2124
2126
|
return {
|
|
2125
2127
|
rows: [],
|
|
@@ -2702,7 +2704,7 @@ const Visibility = {
|
|
|
2702
2704
|
},
|
|
2703
2705
|
createRow: (row, table) => {
|
|
2704
2706
|
return {
|
|
2705
|
-
_getAllVisibleCells: memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
2707
|
+
_getAllVisibleCells: memo$1(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
2706
2708
|
return cells.filter(cell => cell.column.getIsVisible());
|
|
2707
2709
|
}, {
|
|
2708
2710
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
@@ -2711,7 +2713,7 @@ const Visibility = {
|
|
|
2711
2713
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
2712
2714
|
}
|
|
2713
2715
|
}),
|
|
2714
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2716
|
+
getVisibleCells: memo$1(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2715
2717
|
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2716
2718
|
debug: () => {
|
|
2717
2719
|
var _table$options$debugA2;
|
|
@@ -2722,7 +2724,7 @@ const Visibility = {
|
|
|
2722
2724
|
},
|
|
2723
2725
|
createTable: table => {
|
|
2724
2726
|
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2725
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2727
|
+
return memo$1(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2726
2728
|
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2727
2729
|
}, {
|
|
2728
2730
|
key,
|
|
@@ -2861,7 +2863,7 @@ function createTable(options) {
|
|
|
2861
2863
|
}
|
|
2862
2864
|
return row;
|
|
2863
2865
|
},
|
|
2864
|
-
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2866
|
+
_getDefaultColumnDef: memo$1(() => [table.options.defaultColumn], defaultColumn => {
|
|
2865
2867
|
var _defaultColumn;
|
|
2866
2868
|
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2867
2869
|
return {
|
|
@@ -2893,7 +2895,7 @@ function createTable(options) {
|
|
|
2893
2895
|
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
2894
2896
|
}),
|
|
2895
2897
|
_getColumnDefs: () => table.options.columns,
|
|
2896
|
-
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
|
2898
|
+
getAllColumns: memo$1(() => [table._getColumnDefs()], columnDefs => {
|
|
2897
2899
|
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2898
2900
|
if (depth === void 0) {
|
|
2899
2901
|
depth = 0;
|
|
@@ -2913,7 +2915,7 @@ function createTable(options) {
|
|
|
2913
2915
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugColumns;
|
|
2914
2916
|
}
|
|
2915
2917
|
}),
|
|
2916
|
-
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2918
|
+
getAllFlatColumns: memo$1(() => [table.getAllColumns()], allColumns => {
|
|
2917
2919
|
return allColumns.flatMap(column => {
|
|
2918
2920
|
return column.getFlatColumns();
|
|
2919
2921
|
});
|
|
@@ -2924,7 +2926,7 @@ function createTable(options) {
|
|
|
2924
2926
|
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugColumns;
|
|
2925
2927
|
}
|
|
2926
2928
|
}),
|
|
2927
|
-
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2929
|
+
_getAllFlatColumnsById: memo$1(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2928
2930
|
return flatColumns.reduce((acc, column) => {
|
|
2929
2931
|
acc[column.id] = column;
|
|
2930
2932
|
return acc;
|
|
@@ -2936,7 +2938,7 @@ function createTable(options) {
|
|
|
2936
2938
|
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
2937
2939
|
}
|
|
2938
2940
|
}),
|
|
2939
|
-
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2941
|
+
getAllLeafColumns: memo$1(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2940
2942
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2941
2943
|
return orderColumns(leafColumns);
|
|
2942
2944
|
}, {
|
|
@@ -2972,7 +2974,7 @@ function createCell(table, row, column, columnId) {
|
|
|
2972
2974
|
column,
|
|
2973
2975
|
getValue: () => row.getValue(columnId),
|
|
2974
2976
|
renderValue: getRenderValue,
|
|
2975
|
-
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
2977
|
+
getContext: memo$1(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
2976
2978
|
table,
|
|
2977
2979
|
column,
|
|
2978
2980
|
row,
|
|
@@ -3043,7 +3045,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
3043
3045
|
}
|
|
3044
3046
|
return parentRows.reverse();
|
|
3045
3047
|
},
|
|
3046
|
-
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
3048
|
+
getAllCells: memo$1(() => [table.getAllLeafColumns()], leafColumns => {
|
|
3047
3049
|
return leafColumns.map(column => {
|
|
3048
3050
|
return createCell(table, row, column, column.id);
|
|
3049
3051
|
});
|
|
@@ -3054,7 +3056,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
3054
3056
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
3055
3057
|
}
|
|
3056
3058
|
}),
|
|
3057
|
-
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3059
|
+
_getAllCellsByColumnId: memo$1(() => [row.getAllCells()], allCells => {
|
|
3058
3060
|
return allCells.reduce((acc, cell) => {
|
|
3059
3061
|
acc[cell.column.id] = cell;
|
|
3060
3062
|
return acc;
|
|
@@ -3131,7 +3133,7 @@ function createColumnHelper() {
|
|
|
3131
3133
|
}
|
|
3132
3134
|
|
|
3133
3135
|
function getCoreRowModel() {
|
|
3134
|
-
return table => memo(() => [table.options.data], data => {
|
|
3136
|
+
return table => memo$1(() => [table.options.data], data => {
|
|
3135
3137
|
const rowModel = {
|
|
3136
3138
|
rows: [],
|
|
3137
3139
|
flatRows: [],
|
|
@@ -3188,7 +3190,7 @@ function getCoreRowModel() {
|
|
|
3188
3190
|
}
|
|
3189
3191
|
|
|
3190
3192
|
function getSortedRowModel() {
|
|
3191
|
-
return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3193
|
+
return table => memo$1(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3192
3194
|
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
3193
3195
|
return rowModel;
|
|
3194
3196
|
}
|
|
@@ -3353,463 +3355,660 @@ function useReactTable(options) {
|
|
|
3353
3355
|
*
|
|
3354
3356
|
* @license MIT
|
|
3355
3357
|
*/
|
|
3358
|
+
function _extends$1() {
|
|
3359
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
3360
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3361
|
+
var source = arguments[i];
|
|
3362
|
+
for (var key in source) {
|
|
3363
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3364
|
+
target[key] = source[key];
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
return target;
|
|
3369
|
+
};
|
|
3370
|
+
return _extends$1.apply(this, arguments);
|
|
3371
|
+
}
|
|
3356
3372
|
|
|
3373
|
+
/**
|
|
3374
|
+
* virtual-core
|
|
3375
|
+
*
|
|
3376
|
+
* Copyright (c) TanStack
|
|
3377
|
+
*
|
|
3378
|
+
* This source code is licensed under the MIT license found in the
|
|
3379
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3380
|
+
*
|
|
3381
|
+
* @license MIT
|
|
3382
|
+
*/
|
|
3357
3383
|
function _extends() {
|
|
3358
|
-
_extends = Object.assign
|
|
3384
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3359
3385
|
for (var i = 1; i < arguments.length; i++) {
|
|
3360
3386
|
var source = arguments[i];
|
|
3361
|
-
|
|
3362
3387
|
for (var key in source) {
|
|
3363
3388
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3364
3389
|
target[key] = source[key];
|
|
3365
3390
|
}
|
|
3366
3391
|
}
|
|
3367
3392
|
}
|
|
3368
|
-
|
|
3369
3393
|
return target;
|
|
3370
3394
|
};
|
|
3371
|
-
|
|
3372
3395
|
return _extends.apply(this, arguments);
|
|
3373
3396
|
}
|
|
3374
3397
|
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
var
|
|
3391
|
-
|
|
3392
|
-
var
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
}
|
|
3396
|
-
|
|
3397
|
-
if (b === void 0) {
|
|
3398
|
-
b = {};
|
|
3399
|
-
}
|
|
3400
|
-
|
|
3401
|
-
return props.some(function (prop) {
|
|
3402
|
-
return a[prop] !== b[prop];
|
|
3403
|
-
});
|
|
3404
|
-
};
|
|
3405
|
-
|
|
3406
|
-
var observedNodes = /*#__PURE__*/new Map();
|
|
3407
|
-
var rafId;
|
|
3408
|
-
|
|
3409
|
-
var run = function run() {
|
|
3410
|
-
var changedStates = [];
|
|
3411
|
-
observedNodes.forEach(function (state, node) {
|
|
3412
|
-
var newRect = node.getBoundingClientRect();
|
|
3413
|
-
|
|
3414
|
-
if (rectChanged(newRect, state.rect)) {
|
|
3415
|
-
state.rect = newRect;
|
|
3416
|
-
changedStates.push(state);
|
|
3417
|
-
}
|
|
3418
|
-
});
|
|
3419
|
-
changedStates.forEach(function (state) {
|
|
3420
|
-
state.callbacks.forEach(function (cb) {
|
|
3421
|
-
return cb(state.rect);
|
|
3398
|
+
/**
|
|
3399
|
+
* virtual-core
|
|
3400
|
+
*
|
|
3401
|
+
* Copyright (c) TanStack
|
|
3402
|
+
*
|
|
3403
|
+
* This source code is licensed under the MIT license found in the
|
|
3404
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3405
|
+
*
|
|
3406
|
+
* @license MIT
|
|
3407
|
+
*/
|
|
3408
|
+
function memo(getDeps, fn, opts) {
|
|
3409
|
+
var _opts$initialDeps;
|
|
3410
|
+
var deps = (_opts$initialDeps = opts.initialDeps) != null ? _opts$initialDeps : [];
|
|
3411
|
+
var result;
|
|
3412
|
+
return function () {
|
|
3413
|
+
var depTime;
|
|
3414
|
+
if (opts.key && opts.debug != null && opts.debug()) depTime = Date.now();
|
|
3415
|
+
var newDeps = getDeps();
|
|
3416
|
+
var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
|
|
3417
|
+
return deps[index] !== dep;
|
|
3422
3418
|
});
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
};
|
|
3426
|
-
|
|
3427
|
-
function observeRect(node, cb) {
|
|
3428
|
-
return {
|
|
3429
|
-
observe: function observe() {
|
|
3430
|
-
var wasEmpty = observedNodes.size === 0;
|
|
3431
|
-
|
|
3432
|
-
if (observedNodes.has(node)) {
|
|
3433
|
-
observedNodes.get(node).callbacks.push(cb);
|
|
3434
|
-
} else {
|
|
3435
|
-
observedNodes.set(node, {
|
|
3436
|
-
rect: undefined,
|
|
3437
|
-
hasRectChanged: false,
|
|
3438
|
-
callbacks: [cb]
|
|
3439
|
-
});
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3442
|
-
if (wasEmpty) run();
|
|
3443
|
-
},
|
|
3444
|
-
unobserve: function unobserve() {
|
|
3445
|
-
var state = observedNodes.get(node);
|
|
3446
|
-
|
|
3447
|
-
if (state) {
|
|
3448
|
-
// Remove the callback
|
|
3449
|
-
var index = state.callbacks.indexOf(cb);
|
|
3450
|
-
if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
|
|
3451
|
-
|
|
3452
|
-
if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
|
|
3453
|
-
|
|
3454
|
-
if (!observedNodes.size) cancelAnimationFrame(rafId);
|
|
3455
|
-
}
|
|
3419
|
+
if (!depsChanged) {
|
|
3420
|
+
return result;
|
|
3456
3421
|
}
|
|
3422
|
+
deps = newDeps;
|
|
3423
|
+
var resultTime;
|
|
3424
|
+
if (opts.key && opts.debug != null && opts.debug()) resultTime = Date.now();
|
|
3425
|
+
result = fn.apply(void 0, newDeps);
|
|
3426
|
+
if (opts.key && opts.debug != null && opts.debug()) {
|
|
3427
|
+
var depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
3428
|
+
var resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
3429
|
+
var resultFpsPercentage = resultEndTime / 16;
|
|
3430
|
+
var pad = function pad(str, num) {
|
|
3431
|
+
str = String(str);
|
|
3432
|
+
while (str.length < num) {
|
|
3433
|
+
str = ' ' + str;
|
|
3434
|
+
}
|
|
3435
|
+
return str;
|
|
3436
|
+
};
|
|
3437
|
+
console.info("%c\u23F1 " + pad(resultEndTime, 5) + " /" + pad(depEndTime, 5) + " ms", "\n font-size: .6rem;\n font-weight: bold;\n color: hsl(" + Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120)) + "deg 100% 31%);", opts == null ? void 0 : opts.key);
|
|
3438
|
+
}
|
|
3439
|
+
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
|
|
3440
|
+
return result;
|
|
3457
3441
|
};
|
|
3458
3442
|
}
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
if (state.height !== rect.height || state.width !== rect.width) {
|
|
3466
|
-
return rect;
|
|
3443
|
+
function notUndefined(value, msg) {
|
|
3444
|
+
if (value === undefined) {
|
|
3445
|
+
throw new Error("Unexpected undefined" + (msg ? ": " + msg : ''));
|
|
3446
|
+
} else {
|
|
3447
|
+
return value;
|
|
3467
3448
|
}
|
|
3468
|
-
|
|
3469
|
-
return state;
|
|
3470
3449
|
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
if (initialRect === void 0) {
|
|
3474
|
-
initialRect = {
|
|
3475
|
-
width: 0,
|
|
3476
|
-
height: 0
|
|
3477
|
-
};
|
|
3478
|
-
}
|
|
3479
|
-
|
|
3480
|
-
var _React$useState = React__default.useState(nodeRef.current),
|
|
3481
|
-
element = _React$useState[0],
|
|
3482
|
-
setElement = _React$useState[1];
|
|
3483
|
-
|
|
3484
|
-
var _React$useReducer = React__default.useReducer(rectReducer, initialRect),
|
|
3485
|
-
rect = _React$useReducer[0],
|
|
3486
|
-
dispatch = _React$useReducer[1];
|
|
3487
|
-
|
|
3488
|
-
var initialRectSet = React__default.useRef(false);
|
|
3489
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3490
|
-
if (nodeRef.current !== element) {
|
|
3491
|
-
setElement(nodeRef.current);
|
|
3492
|
-
}
|
|
3493
|
-
});
|
|
3494
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3495
|
-
if (element && !initialRectSet.current) {
|
|
3496
|
-
initialRectSet.current = true;
|
|
3497
|
-
|
|
3498
|
-
var _rect = element.getBoundingClientRect();
|
|
3499
|
-
|
|
3500
|
-
dispatch({
|
|
3501
|
-
rect: _rect
|
|
3502
|
-
});
|
|
3503
|
-
}
|
|
3504
|
-
}, [element]);
|
|
3505
|
-
React__default.useEffect(function () {
|
|
3506
|
-
if (!element) {
|
|
3507
|
-
return;
|
|
3508
|
-
}
|
|
3509
|
-
|
|
3510
|
-
var observer = observeRect(element, function (rect) {
|
|
3511
|
-
dispatch({
|
|
3512
|
-
rect: rect
|
|
3513
|
-
});
|
|
3514
|
-
});
|
|
3515
|
-
observer.observe();
|
|
3516
|
-
return function () {
|
|
3517
|
-
observer.unobserve();
|
|
3518
|
-
};
|
|
3519
|
-
}, [element]);
|
|
3520
|
-
return rect;
|
|
3450
|
+
var approxEqual = function approxEqual(a, b) {
|
|
3451
|
+
return Math.abs(a - b) < 1;
|
|
3521
3452
|
};
|
|
3522
3453
|
|
|
3523
|
-
|
|
3454
|
+
/**
|
|
3455
|
+
* virtual-core
|
|
3456
|
+
*
|
|
3457
|
+
* Copyright (c) TanStack
|
|
3458
|
+
*
|
|
3459
|
+
* This source code is licensed under the MIT license found in the
|
|
3460
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3461
|
+
*
|
|
3462
|
+
* @license MIT
|
|
3463
|
+
*/
|
|
3464
|
+
|
|
3465
|
+
//
|
|
3524
3466
|
|
|
3525
|
-
|
|
3526
|
-
return 50;
|
|
3527
|
-
};
|
|
3467
|
+
//
|
|
3528
3468
|
|
|
3529
3469
|
var defaultKeyExtractor = function defaultKeyExtractor(index) {
|
|
3530
3470
|
return index;
|
|
3531
3471
|
};
|
|
3532
|
-
|
|
3533
|
-
var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
|
|
3534
|
-
var key = horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
3535
|
-
return el[key];
|
|
3536
|
-
};
|
|
3537
|
-
|
|
3538
3472
|
var defaultRangeExtractor = function defaultRangeExtractor(range) {
|
|
3539
|
-
var start = Math.max(range.
|
|
3540
|
-
var end = Math.min(range.
|
|
3473
|
+
var start = Math.max(range.startIndex - range.overscan, 0);
|
|
3474
|
+
var end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
3541
3475
|
var arr = [];
|
|
3542
|
-
|
|
3543
3476
|
for (var _i = start; _i <= end; _i++) {
|
|
3544
3477
|
arr.push(_i);
|
|
3545
3478
|
}
|
|
3546
|
-
|
|
3547
3479
|
return arr;
|
|
3548
3480
|
};
|
|
3549
|
-
var
|
|
3550
|
-
var
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
var sizeKey = horizontal ? 'width' : 'height';
|
|
3577
|
-
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
3578
|
-
var latestRef = React.useRef({
|
|
3579
|
-
outerSize: 0,
|
|
3580
|
-
scrollOffset: 0,
|
|
3581
|
-
measurements: [],
|
|
3582
|
-
totalSize: 0
|
|
3481
|
+
var observeElementRect = function observeElementRect(instance, cb) {
|
|
3482
|
+
var element = instance.scrollElement;
|
|
3483
|
+
if (!element) {
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
var handler = function handler(rect) {
|
|
3487
|
+
var width = rect.width,
|
|
3488
|
+
height = rect.height;
|
|
3489
|
+
cb({
|
|
3490
|
+
width: Math.round(width),
|
|
3491
|
+
height: Math.round(height)
|
|
3492
|
+
});
|
|
3493
|
+
};
|
|
3494
|
+
handler(element.getBoundingClientRect());
|
|
3495
|
+
var observer = new ResizeObserver(function (entries) {
|
|
3496
|
+
var entry = entries[0];
|
|
3497
|
+
if (entry != null && entry.borderBoxSize) {
|
|
3498
|
+
var box = entry.borderBoxSize[0];
|
|
3499
|
+
if (box) {
|
|
3500
|
+
handler({
|
|
3501
|
+
width: box.inlineSize,
|
|
3502
|
+
height: box.blockSize
|
|
3503
|
+
});
|
|
3504
|
+
return;
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
handler(element.getBoundingClientRect());
|
|
3583
3508
|
});
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
var
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
var
|
|
3597
|
-
|
|
3598
|
-
|
|
3509
|
+
observer.observe(element, {
|
|
3510
|
+
box: 'border-box'
|
|
3511
|
+
});
|
|
3512
|
+
return function () {
|
|
3513
|
+
observer.unobserve(element);
|
|
3514
|
+
};
|
|
3515
|
+
};
|
|
3516
|
+
var observeElementOffset = function observeElementOffset(instance, cb) {
|
|
3517
|
+
var element = instance.scrollElement;
|
|
3518
|
+
if (!element) {
|
|
3519
|
+
return;
|
|
3520
|
+
}
|
|
3521
|
+
var handler = function handler() {
|
|
3522
|
+
cb(element[instance.options.horizontal ? 'scrollLeft' : 'scrollTop']);
|
|
3523
|
+
};
|
|
3524
|
+
handler();
|
|
3525
|
+
element.addEventListener('scroll', handler, {
|
|
3526
|
+
passive: true
|
|
3527
|
+
});
|
|
3528
|
+
return function () {
|
|
3529
|
+
element.removeEventListener('scroll', handler);
|
|
3530
|
+
};
|
|
3531
|
+
};
|
|
3532
|
+
var measureElement = function measureElement(element, entry, instance) {
|
|
3533
|
+
if (entry != null && entry.borderBoxSize) {
|
|
3534
|
+
var box = entry.borderBoxSize[0];
|
|
3535
|
+
if (box) {
|
|
3536
|
+
var size = Math.round(box[instance.options.horizontal ? 'inlineSize' : 'blockSize']);
|
|
3537
|
+
return size;
|
|
3599
3538
|
}
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3539
|
+
}
|
|
3540
|
+
return Math.round(element.getBoundingClientRect()[instance.options.horizontal ? 'width' : 'height']);
|
|
3541
|
+
};
|
|
3542
|
+
var elementScroll = function elementScroll(offset, _ref2, instance) {
|
|
3543
|
+
var _instance$scrollEleme3, _instance$scrollEleme4;
|
|
3544
|
+
var _ref2$adjustments = _ref2.adjustments,
|
|
3545
|
+
adjustments = _ref2$adjustments === void 0 ? 0 : _ref2$adjustments,
|
|
3546
|
+
behavior = _ref2.behavior;
|
|
3547
|
+
var toOffset = offset + adjustments;
|
|
3548
|
+
(_instance$scrollEleme3 = instance.scrollElement) == null ? void 0 : _instance$scrollEleme3.scrollTo == null ? void 0 : _instance$scrollEleme3.scrollTo((_instance$scrollEleme4 = {}, _instance$scrollEleme4[instance.options.horizontal ? 'left' : 'top'] = toOffset, _instance$scrollEleme4.behavior = behavior, _instance$scrollEleme4));
|
|
3549
|
+
};
|
|
3550
|
+
var Virtualizer = function Virtualizer(_opts) {
|
|
3551
|
+
var _this = this;
|
|
3552
|
+
this.unsubs = [];
|
|
3553
|
+
this.scrollElement = null;
|
|
3554
|
+
this.isScrolling = false;
|
|
3555
|
+
this.isScrollingTimeoutId = null;
|
|
3556
|
+
this.scrollToIndexTimeoutId = null;
|
|
3557
|
+
this.measurementsCache = [];
|
|
3558
|
+
this.itemSizeCache = new Map();
|
|
3559
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
3560
|
+
this.scrollDirection = null;
|
|
3561
|
+
this.scrollAdjustments = 0;
|
|
3562
|
+
this.measureElementCache = new Map();
|
|
3563
|
+
this.observer = function () {
|
|
3564
|
+
var _ro = null;
|
|
3565
|
+
var get = function get() {
|
|
3566
|
+
if (_ro) {
|
|
3567
|
+
return _ro;
|
|
3568
|
+
} else if (typeof ResizeObserver !== 'undefined') {
|
|
3569
|
+
return _ro = new ResizeObserver(function (entries) {
|
|
3570
|
+
entries.forEach(function (entry) {
|
|
3571
|
+
_this._measureElement(entry.target, entry);
|
|
3572
|
+
});
|
|
3573
|
+
});
|
|
3574
|
+
} else {
|
|
3575
|
+
return null;
|
|
3576
|
+
}
|
|
3577
|
+
};
|
|
3578
|
+
return {
|
|
3579
|
+
disconnect: function disconnect() {
|
|
3580
|
+
var _get;
|
|
3581
|
+
return (_get = get()) == null ? void 0 : _get.disconnect();
|
|
3582
|
+
},
|
|
3583
|
+
observe: function observe(target) {
|
|
3584
|
+
var _get2;
|
|
3585
|
+
return (_get2 = get()) == null ? void 0 : _get2.observe(target, {
|
|
3586
|
+
box: 'border-box'
|
|
3587
|
+
});
|
|
3588
|
+
},
|
|
3589
|
+
unobserve: function unobserve(target) {
|
|
3590
|
+
var _get3;
|
|
3591
|
+
return (_get3 = get()) == null ? void 0 : _get3.unobserve(target);
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
}();
|
|
3595
|
+
this.range = null;
|
|
3596
|
+
this.setOptions = function (opts) {
|
|
3597
|
+
Object.entries(opts).forEach(function (_ref3) {
|
|
3598
|
+
var key = _ref3[0],
|
|
3599
|
+
value = _ref3[1];
|
|
3600
|
+
if (typeof value === 'undefined') delete opts[key];
|
|
3601
|
+
});
|
|
3602
|
+
_this.options = _extends({
|
|
3603
|
+
debug: false,
|
|
3604
|
+
initialOffset: 0,
|
|
3605
|
+
overscan: 1,
|
|
3606
|
+
paddingStart: 0,
|
|
3607
|
+
paddingEnd: 0,
|
|
3608
|
+
scrollPaddingStart: 0,
|
|
3609
|
+
scrollPaddingEnd: 0,
|
|
3610
|
+
horizontal: false,
|
|
3611
|
+
getItemKey: defaultKeyExtractor,
|
|
3612
|
+
rangeExtractor: defaultRangeExtractor,
|
|
3613
|
+
onChange: function onChange() {},
|
|
3614
|
+
measureElement: measureElement,
|
|
3615
|
+
initialRect: {
|
|
3616
|
+
width: 0,
|
|
3617
|
+
height: 0
|
|
3618
|
+
},
|
|
3619
|
+
scrollMargin: 0,
|
|
3620
|
+
scrollingDelay: 150,
|
|
3621
|
+
indexAttribute: 'data-index',
|
|
3622
|
+
initialMeasurementsCache: [],
|
|
3623
|
+
lanes: 1
|
|
3624
|
+
}, opts);
|
|
3625
|
+
};
|
|
3626
|
+
this.notify = function (sync) {
|
|
3627
|
+
_this.options.onChange == null ? void 0 : _this.options.onChange(_this, sync);
|
|
3628
|
+
};
|
|
3629
|
+
this.maybeNotify = memo(function () {
|
|
3630
|
+
_this.calculateRange();
|
|
3631
|
+
return [_this.isScrolling, _this.range ? _this.range.startIndex : null, _this.range ? _this.range.endIndex : null];
|
|
3632
|
+
}, function (isScrolling) {
|
|
3633
|
+
_this.notify(isScrolling);
|
|
3634
|
+
}, {
|
|
3635
|
+
key: process.env.NODE_ENV !== 'production' && 'maybeNotify',
|
|
3636
|
+
debug: function debug() {
|
|
3637
|
+
return _this.options.debug;
|
|
3638
|
+
},
|
|
3639
|
+
initialDeps: [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null]
|
|
3640
|
+
});
|
|
3641
|
+
this.cleanup = function () {
|
|
3642
|
+
_this.unsubs.filter(Boolean).forEach(function (d) {
|
|
3643
|
+
return d();
|
|
3644
|
+
});
|
|
3645
|
+
_this.unsubs = [];
|
|
3646
|
+
_this.scrollElement = null;
|
|
3647
|
+
};
|
|
3648
|
+
this._didMount = function () {
|
|
3649
|
+
_this.measureElementCache.forEach(_this.observer.observe);
|
|
3650
|
+
return function () {
|
|
3651
|
+
_this.observer.disconnect();
|
|
3652
|
+
_this.cleanup();
|
|
3653
|
+
};
|
|
3654
|
+
};
|
|
3655
|
+
this._willUpdate = function () {
|
|
3656
|
+
var scrollElement = _this.options.getScrollElement();
|
|
3657
|
+
if (_this.scrollElement !== scrollElement) {
|
|
3658
|
+
_this.cleanup();
|
|
3659
|
+
_this.scrollElement = scrollElement;
|
|
3660
|
+
_this._scrollToOffset(_this.scrollOffset, {
|
|
3661
|
+
adjustments: undefined,
|
|
3662
|
+
behavior: undefined
|
|
3663
|
+
});
|
|
3664
|
+
_this.unsubs.push(_this.options.observeElementRect(_this, function (rect) {
|
|
3665
|
+
_this.scrollRect = rect;
|
|
3666
|
+
_this.maybeNotify();
|
|
3667
|
+
}));
|
|
3668
|
+
_this.unsubs.push(_this.options.observeElementOffset(_this, function (offset) {
|
|
3669
|
+
_this.scrollAdjustments = 0;
|
|
3670
|
+
if (_this.scrollOffset === offset) {
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
if (_this.isScrollingTimeoutId !== null) {
|
|
3674
|
+
clearTimeout(_this.isScrollingTimeoutId);
|
|
3675
|
+
_this.isScrollingTimeoutId = null;
|
|
3676
|
+
}
|
|
3677
|
+
_this.isScrolling = true;
|
|
3678
|
+
_this.scrollDirection = _this.scrollOffset < offset ? 'forward' : 'backward';
|
|
3679
|
+
_this.scrollOffset = offset;
|
|
3680
|
+
_this.maybeNotify();
|
|
3681
|
+
_this.isScrollingTimeoutId = setTimeout(function () {
|
|
3682
|
+
_this.isScrollingTimeoutId = null;
|
|
3683
|
+
_this.isScrolling = false;
|
|
3684
|
+
_this.scrollDirection = null;
|
|
3685
|
+
_this.maybeNotify();
|
|
3686
|
+
}, _this.options.scrollingDelay);
|
|
3687
|
+
}));
|
|
3688
|
+
}
|
|
3689
|
+
};
|
|
3690
|
+
this.getSize = function () {
|
|
3691
|
+
return _this.scrollRect[_this.options.horizontal ? 'width' : 'height'];
|
|
3692
|
+
};
|
|
3693
|
+
this.memoOptions = memo(function () {
|
|
3694
|
+
return [_this.options.count, _this.options.paddingStart, _this.options.scrollMargin, _this.options.getItemKey];
|
|
3695
|
+
}, function (count, paddingStart, scrollMargin, getItemKey) {
|
|
3696
|
+
_this.pendingMeasuredCacheIndexes = [];
|
|
3697
|
+
return {
|
|
3698
|
+
count: count,
|
|
3699
|
+
paddingStart: paddingStart,
|
|
3700
|
+
scrollMargin: scrollMargin,
|
|
3701
|
+
getItemKey: getItemKey
|
|
3702
|
+
};
|
|
3703
|
+
}, {
|
|
3704
|
+
key: false
|
|
3705
|
+
});
|
|
3706
|
+
this.getFurthestMeasurement = function (measurements, index) {
|
|
3707
|
+
var furthestMeasurementsFound = new Map();
|
|
3708
|
+
var furthestMeasurements = new Map();
|
|
3709
|
+
for (var m = index - 1; m >= 0; m--) {
|
|
3710
|
+
var measurement = measurements[m];
|
|
3711
|
+
if (furthestMeasurementsFound.has(measurement.lane)) {
|
|
3712
|
+
continue;
|
|
3713
|
+
}
|
|
3714
|
+
var previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
|
|
3715
|
+
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
|
|
3716
|
+
furthestMeasurements.set(measurement.lane, measurement);
|
|
3717
|
+
} else if (measurement.end < previousFurthestMeasurement.end) {
|
|
3718
|
+
furthestMeasurementsFound.set(measurement.lane, true);
|
|
3719
|
+
}
|
|
3720
|
+
if (furthestMeasurementsFound.size === _this.options.lanes) {
|
|
3721
|
+
break;
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
return furthestMeasurements.size === _this.options.lanes ? Array.from(furthestMeasurements.values()).sort(function (a, b) {
|
|
3725
|
+
return a.end - b.end;
|
|
3726
|
+
})[0] : undefined;
|
|
3727
|
+
};
|
|
3728
|
+
this.getMeasurements = memo(function () {
|
|
3729
|
+
return [_this.memoOptions(), _this.itemSizeCache];
|
|
3730
|
+
}, function (_ref4, itemSizeCache) {
|
|
3731
|
+
var count = _ref4.count,
|
|
3732
|
+
paddingStart = _ref4.paddingStart,
|
|
3733
|
+
scrollMargin = _ref4.scrollMargin,
|
|
3734
|
+
getItemKey = _ref4.getItemKey;
|
|
3735
|
+
var min = _this.pendingMeasuredCacheIndexes.length > 0 ? Math.min.apply(Math, _this.pendingMeasuredCacheIndexes) : 0;
|
|
3736
|
+
_this.pendingMeasuredCacheIndexes = [];
|
|
3737
|
+
var measurements = _this.measurementsCache.slice(0, min);
|
|
3738
|
+
for (var _i2 = min; _i2 < count; _i2++) {
|
|
3739
|
+
var key = getItemKey(_i2);
|
|
3740
|
+
var furthestMeasurement = _this.options.lanes === 1 ? measurements[_i2 - 1] : _this.getFurthestMeasurement(measurements, _i2);
|
|
3741
|
+
var start = furthestMeasurement ? furthestMeasurement.end : paddingStart + scrollMargin;
|
|
3742
|
+
var measuredSize = itemSizeCache.get(key);
|
|
3743
|
+
var size = typeof measuredSize === 'number' ? measuredSize : _this.options.estimateSize(_i2);
|
|
3744
|
+
var end = start + size;
|
|
3745
|
+
var lane = furthestMeasurement ? furthestMeasurement.lane : _i2 % _this.options.lanes;
|
|
3629
3746
|
measurements[_i2] = {
|
|
3630
3747
|
index: _i2,
|
|
3631
|
-
start:
|
|
3632
|
-
size:
|
|
3633
|
-
end:
|
|
3634
|
-
key: key
|
|
3748
|
+
start: start,
|
|
3749
|
+
size: size,
|
|
3750
|
+
end: end,
|
|
3751
|
+
key: key,
|
|
3752
|
+
lane: lane
|
|
3635
3753
|
};
|
|
3636
3754
|
}
|
|
3637
|
-
|
|
3755
|
+
_this.measurementsCache = measurements;
|
|
3638
3756
|
return measurements;
|
|
3639
|
-
},
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
var element = onScrollElement ? onScrollElement.current : parentRef.current;
|
|
3644
|
-
var scrollOffsetFnRef = React.useRef(scrollOffsetFn);
|
|
3645
|
-
scrollOffsetFnRef.current = scrollOffsetFn;
|
|
3646
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3647
|
-
if (!element) {
|
|
3648
|
-
setScrollOffset(0);
|
|
3649
|
-
return;
|
|
3757
|
+
}, {
|
|
3758
|
+
key: process.env.NODE_ENV !== 'production' && 'getMeasurements',
|
|
3759
|
+
debug: function debug() {
|
|
3760
|
+
return _this.options.debug;
|
|
3650
3761
|
}
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
var indexes = React.useMemo(function () {
|
|
3672
|
-
return rangeExtractor({
|
|
3673
|
-
start: start,
|
|
3674
|
-
end: end,
|
|
3762
|
+
});
|
|
3763
|
+
this.calculateRange = memo(function () {
|
|
3764
|
+
return [_this.getMeasurements(), _this.getSize(), _this.scrollOffset];
|
|
3765
|
+
}, function (measurements, outerSize, scrollOffset) {
|
|
3766
|
+
return _this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
3767
|
+
measurements: measurements,
|
|
3768
|
+
outerSize: outerSize,
|
|
3769
|
+
scrollOffset: scrollOffset
|
|
3770
|
+
}) : null;
|
|
3771
|
+
}, {
|
|
3772
|
+
key: process.env.NODE_ENV !== 'production' && 'calculateRange',
|
|
3773
|
+
debug: function debug() {
|
|
3774
|
+
return _this.options.debug;
|
|
3775
|
+
}
|
|
3776
|
+
});
|
|
3777
|
+
this.getIndexes = memo(function () {
|
|
3778
|
+
return [_this.options.rangeExtractor, _this.calculateRange(), _this.options.overscan, _this.options.count];
|
|
3779
|
+
}, function (rangeExtractor, range, overscan, count) {
|
|
3780
|
+
return range === null ? [] : rangeExtractor(_extends({}, range, {
|
|
3675
3781
|
overscan: overscan,
|
|
3676
|
-
|
|
3677
|
-
});
|
|
3678
|
-
},
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
pendingMeasuredCacheIndexesRef.current.push(i);
|
|
3701
|
-
setMeasuredCache(function (old) {
|
|
3702
|
-
var _extends2;
|
|
3703
|
-
|
|
3704
|
-
return _extends({}, old, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
|
|
3705
|
-
});
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3782
|
+
count: count
|
|
3783
|
+
}));
|
|
3784
|
+
}, {
|
|
3785
|
+
key: process.env.NODE_ENV !== 'production' && 'getIndexes',
|
|
3786
|
+
debug: function debug() {
|
|
3787
|
+
return _this.options.debug;
|
|
3788
|
+
}
|
|
3789
|
+
});
|
|
3790
|
+
this.indexFromElement = function (node) {
|
|
3791
|
+
var attributeName = _this.options.indexAttribute;
|
|
3792
|
+
var indexStr = node.getAttribute(attributeName);
|
|
3793
|
+
if (!indexStr) {
|
|
3794
|
+
console.warn("Missing attribute name '" + attributeName + "={index}' on measured element.");
|
|
3795
|
+
return -1;
|
|
3796
|
+
}
|
|
3797
|
+
return parseInt(indexStr, 10);
|
|
3798
|
+
};
|
|
3799
|
+
this._measureElement = function (node, entry) {
|
|
3800
|
+
var item = _this.measurementsCache[_this.indexFromElement(node)];
|
|
3801
|
+
if (!item || !node.isConnected) {
|
|
3802
|
+
_this.measureElementCache.forEach(function (cached, key) {
|
|
3803
|
+
if (cached === node) {
|
|
3804
|
+
_this.observer.unobserve(node);
|
|
3805
|
+
_this.measureElementCache["delete"](key);
|
|
3708
3806
|
}
|
|
3709
3807
|
});
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3808
|
+
return;
|
|
3809
|
+
}
|
|
3810
|
+
var prevNode = _this.measureElementCache.get(item.key);
|
|
3811
|
+
if (prevNode !== node) {
|
|
3812
|
+
if (prevNode) {
|
|
3813
|
+
_this.observer.unobserve(prevNode);
|
|
3814
|
+
}
|
|
3815
|
+
_this.observer.observe(node);
|
|
3816
|
+
_this.measureElementCache.set(item.key, node);
|
|
3817
|
+
}
|
|
3818
|
+
var measuredItemSize = _this.options.measureElement(node, entry, _this);
|
|
3819
|
+
_this.resizeItem(item, measuredItemSize);
|
|
3820
|
+
};
|
|
3821
|
+
this.resizeItem = function (item, size) {
|
|
3822
|
+
var _this$itemSizeCache$g;
|
|
3823
|
+
var itemSize = (_this$itemSizeCache$g = _this.itemSizeCache.get(item.key)) != null ? _this$itemSizeCache$g : item.size;
|
|
3824
|
+
var delta = size - itemSize;
|
|
3825
|
+
if (delta !== 0) {
|
|
3826
|
+
if (item.start < _this.scrollOffset) {
|
|
3827
|
+
if (process.env.NODE_ENV !== 'production' && _this.options.debug) {
|
|
3828
|
+
console.info('correction', delta);
|
|
3829
|
+
}
|
|
3830
|
+
_this._scrollToOffset(_this.scrollOffset, {
|
|
3831
|
+
adjustments: _this.scrollAdjustments += delta,
|
|
3832
|
+
behavior: undefined
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3835
|
+
_this.pendingMeasuredCacheIndexes.push(item.index);
|
|
3836
|
+
_this.itemSizeCache = new Map(_this.itemSizeCache.set(item.key, size));
|
|
3837
|
+
_this.notify(false);
|
|
3838
|
+
}
|
|
3839
|
+
};
|
|
3840
|
+
this.measureElement = function (node) {
|
|
3841
|
+
if (!node) {
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
_this._measureElement(node, undefined);
|
|
3845
|
+
};
|
|
3846
|
+
this.getVirtualItems = memo(function () {
|
|
3847
|
+
return [_this.getIndexes(), _this.getMeasurements()];
|
|
3848
|
+
}, function (indexes, measurements) {
|
|
3849
|
+
var virtualItems = [];
|
|
3714
3850
|
for (var k = 0, len = indexes.length; k < len; k++) {
|
|
3715
|
-
|
|
3851
|
+
var _i3 = indexes[k];
|
|
3852
|
+
var measurement = measurements[_i3];
|
|
3853
|
+
virtualItems.push(measurement);
|
|
3716
3854
|
}
|
|
3717
|
-
|
|
3718
3855
|
return virtualItems;
|
|
3719
|
-
},
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
setMeasuredCache({});
|
|
3856
|
+
}, {
|
|
3857
|
+
key: process.env.NODE_ENV !== 'production' && 'getIndexes',
|
|
3858
|
+
debug: function debug() {
|
|
3859
|
+
return _this.options.debug;
|
|
3724
3860
|
}
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
var _latestRef$current = latestRef.current,
|
|
3735
|
-
scrollOffset = _latestRef$current.scrollOffset,
|
|
3736
|
-
outerSize = _latestRef$current.outerSize;
|
|
3737
|
-
|
|
3861
|
+
});
|
|
3862
|
+
this.getVirtualItemForOffset = function (offset) {
|
|
3863
|
+
var measurements = _this.getMeasurements();
|
|
3864
|
+
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, function (index) {
|
|
3865
|
+
return notUndefined(measurements[index]).start;
|
|
3866
|
+
}, offset)]);
|
|
3867
|
+
};
|
|
3868
|
+
this.getOffsetForAlignment = function (toOffset, align) {
|
|
3869
|
+
var size = _this.getSize();
|
|
3738
3870
|
if (align === 'auto') {
|
|
3739
|
-
if (toOffset <= scrollOffset) {
|
|
3871
|
+
if (toOffset <= _this.scrollOffset) {
|
|
3740
3872
|
align = 'start';
|
|
3741
|
-
} else if (toOffset >= scrollOffset +
|
|
3873
|
+
} else if (toOffset >= _this.scrollOffset + size) {
|
|
3742
3874
|
align = 'end';
|
|
3743
3875
|
} else {
|
|
3744
3876
|
align = 'start';
|
|
3745
3877
|
}
|
|
3746
3878
|
}
|
|
3747
|
-
|
|
3748
3879
|
if (align === 'start') {
|
|
3749
|
-
|
|
3880
|
+
toOffset = toOffset;
|
|
3750
3881
|
} else if (align === 'end') {
|
|
3751
|
-
|
|
3882
|
+
toOffset = toOffset - size;
|
|
3752
3883
|
} else if (align === 'center') {
|
|
3753
|
-
|
|
3754
|
-
}
|
|
3755
|
-
}, [scrollTo]);
|
|
3756
|
-
var tryScrollToIndex = React.useCallback(function (index, _temp2) {
|
|
3757
|
-
var _ref3 = _temp2 === void 0 ? {
|
|
3758
|
-
align: 'auto'
|
|
3759
|
-
} : _temp2,
|
|
3760
|
-
align = _ref3.align,
|
|
3761
|
-
rest = _objectWithoutPropertiesLoose$1(_ref3, _excluded$1);
|
|
3762
|
-
|
|
3763
|
-
var _latestRef$current2 = latestRef.current,
|
|
3764
|
-
measurements = _latestRef$current2.measurements,
|
|
3765
|
-
scrollOffset = _latestRef$current2.scrollOffset,
|
|
3766
|
-
outerSize = _latestRef$current2.outerSize;
|
|
3767
|
-
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
3768
|
-
|
|
3769
|
-
if (!measurement) {
|
|
3770
|
-
return;
|
|
3884
|
+
toOffset = toOffset - size / 2;
|
|
3771
3885
|
}
|
|
3772
|
-
|
|
3886
|
+
var scrollSizeProp = _this.options.horizontal ? 'scrollWidth' : 'scrollHeight';
|
|
3887
|
+
var scrollSize = _this.scrollElement ? 'document' in _this.scrollElement ? _this.scrollElement.document.documentElement[scrollSizeProp] : _this.scrollElement[scrollSizeProp] : 0;
|
|
3888
|
+
var maxOffset = scrollSize - _this.getSize();
|
|
3889
|
+
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
3890
|
+
};
|
|
3891
|
+
this.getOffsetForIndex = function (index, align) {
|
|
3892
|
+
if (align === void 0) {
|
|
3893
|
+
align = 'auto';
|
|
3894
|
+
}
|
|
3895
|
+
index = Math.max(0, Math.min(index, _this.options.count - 1));
|
|
3896
|
+
var measurement = notUndefined(_this.getMeasurements()[index]);
|
|
3773
3897
|
if (align === 'auto') {
|
|
3774
|
-
if (measurement.end >= scrollOffset +
|
|
3898
|
+
if (measurement.end >= _this.scrollOffset + _this.getSize() - _this.options.scrollPaddingEnd) {
|
|
3775
3899
|
align = 'end';
|
|
3776
|
-
} else if (measurement.start <= scrollOffset) {
|
|
3900
|
+
} else if (measurement.start <= _this.scrollOffset + _this.options.scrollPaddingStart) {
|
|
3777
3901
|
align = 'start';
|
|
3778
3902
|
} else {
|
|
3779
|
-
return;
|
|
3903
|
+
return [_this.scrollOffset, align];
|
|
3780
3904
|
}
|
|
3781
3905
|
}
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
}
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3906
|
+
var toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
|
|
3907
|
+
return [_this.getOffsetForAlignment(toOffset, align), align];
|
|
3908
|
+
};
|
|
3909
|
+
this.isDynamicMode = function () {
|
|
3910
|
+
return _this.measureElementCache.size > 0;
|
|
3911
|
+
};
|
|
3912
|
+
this.cancelScrollToIndex = function () {
|
|
3913
|
+
if (_this.scrollToIndexTimeoutId !== null) {
|
|
3914
|
+
clearTimeout(_this.scrollToIndexTimeoutId);
|
|
3915
|
+
_this.scrollToIndexTimeoutId = null;
|
|
3916
|
+
}
|
|
3917
|
+
};
|
|
3918
|
+
this.scrollToOffset = function (toOffset, _temp) {
|
|
3919
|
+
var _ref5 = _temp === void 0 ? {} : _temp,
|
|
3920
|
+
_ref5$align = _ref5.align,
|
|
3921
|
+
align = _ref5$align === void 0 ? 'start' : _ref5$align,
|
|
3922
|
+
behavior = _ref5.behavior;
|
|
3923
|
+
_this.cancelScrollToIndex();
|
|
3924
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3925
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
3926
|
+
}
|
|
3927
|
+
_this._scrollToOffset(_this.getOffsetForAlignment(toOffset, align), {
|
|
3928
|
+
adjustments: undefined,
|
|
3929
|
+
behavior: behavior
|
|
3797
3930
|
});
|
|
3798
|
-
}, [tryScrollToIndex]);
|
|
3799
|
-
return {
|
|
3800
|
-
virtualItems: virtualItems,
|
|
3801
|
-
totalSize: totalSize,
|
|
3802
|
-
scrollToOffset: scrollToOffset,
|
|
3803
|
-
scrollToIndex: scrollToIndex,
|
|
3804
|
-
measure: measure
|
|
3805
3931
|
};
|
|
3932
|
+
this.scrollToIndex = function (index, _temp2) {
|
|
3933
|
+
var _ref6 = _temp2 === void 0 ? {} : _temp2,
|
|
3934
|
+
_ref6$align = _ref6.align,
|
|
3935
|
+
initialAlign = _ref6$align === void 0 ? 'auto' : _ref6$align,
|
|
3936
|
+
behavior = _ref6.behavior;
|
|
3937
|
+
index = Math.max(0, Math.min(index, _this.options.count - 1));
|
|
3938
|
+
_this.cancelScrollToIndex();
|
|
3939
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3940
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
3941
|
+
}
|
|
3942
|
+
var _this$getOffsetForInd = _this.getOffsetForIndex(index, initialAlign),
|
|
3943
|
+
toOffset = _this$getOffsetForInd[0],
|
|
3944
|
+
align = _this$getOffsetForInd[1];
|
|
3945
|
+
_this._scrollToOffset(toOffset, {
|
|
3946
|
+
adjustments: undefined,
|
|
3947
|
+
behavior: behavior
|
|
3948
|
+
});
|
|
3949
|
+
if (behavior !== 'smooth' && _this.isDynamicMode()) {
|
|
3950
|
+
_this.scrollToIndexTimeoutId = setTimeout(function () {
|
|
3951
|
+
_this.scrollToIndexTimeoutId = null;
|
|
3952
|
+
var elementInDOM = _this.measureElementCache.has(_this.options.getItemKey(index));
|
|
3953
|
+
if (elementInDOM) {
|
|
3954
|
+
var _this$getOffsetForInd2 = _this.getOffsetForIndex(index, align),
|
|
3955
|
+
_toOffset = _this$getOffsetForInd2[0];
|
|
3956
|
+
if (!approxEqual(_toOffset, _this.scrollOffset)) {
|
|
3957
|
+
_this.scrollToIndex(index, {
|
|
3958
|
+
align: align,
|
|
3959
|
+
behavior: behavior
|
|
3960
|
+
});
|
|
3961
|
+
}
|
|
3962
|
+
} else {
|
|
3963
|
+
_this.scrollToIndex(index, {
|
|
3964
|
+
align: align,
|
|
3965
|
+
behavior: behavior
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
});
|
|
3969
|
+
}
|
|
3970
|
+
};
|
|
3971
|
+
this.scrollBy = function (delta, _temp3) {
|
|
3972
|
+
var _ref7 = _temp3 === void 0 ? {} : _temp3,
|
|
3973
|
+
behavior = _ref7.behavior;
|
|
3974
|
+
_this.cancelScrollToIndex();
|
|
3975
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3976
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
3977
|
+
}
|
|
3978
|
+
_this._scrollToOffset(_this.scrollOffset + delta, {
|
|
3979
|
+
adjustments: undefined,
|
|
3980
|
+
behavior: behavior
|
|
3981
|
+
});
|
|
3982
|
+
};
|
|
3983
|
+
this.getTotalSize = function () {
|
|
3984
|
+
var _this$getMeasurements;
|
|
3985
|
+
return (((_this$getMeasurements = _this.getMeasurements()[_this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || _this.options.paddingStart) - _this.options.scrollMargin + _this.options.paddingEnd;
|
|
3986
|
+
};
|
|
3987
|
+
this._scrollToOffset = function (offset, _ref8) {
|
|
3988
|
+
var adjustments = _ref8.adjustments,
|
|
3989
|
+
behavior = _ref8.behavior;
|
|
3990
|
+
_this.options.scrollToFn(offset, {
|
|
3991
|
+
behavior: behavior,
|
|
3992
|
+
adjustments: adjustments
|
|
3993
|
+
}, _this);
|
|
3994
|
+
};
|
|
3995
|
+
this.measure = function () {
|
|
3996
|
+
_this.itemSizeCache = new Map();
|
|
3997
|
+
_this.notify(false);
|
|
3998
|
+
};
|
|
3999
|
+
this.setOptions(_opts);
|
|
4000
|
+
this.scrollRect = this.options.initialRect;
|
|
4001
|
+
this.scrollOffset = this.options.initialOffset;
|
|
4002
|
+
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
4003
|
+
this.measurementsCache.forEach(function (item) {
|
|
4004
|
+
_this.itemSizeCache.set(item.key, item.size);
|
|
4005
|
+
});
|
|
4006
|
+
this.maybeNotify();
|
|
3806
4007
|
};
|
|
3807
|
-
|
|
3808
4008
|
var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
|
|
3809
4009
|
while (low <= high) {
|
|
3810
4010
|
var middle = (low + high) / 2 | 0;
|
|
3811
4011
|
var currentValue = getCurrentValue(middle);
|
|
3812
|
-
|
|
3813
4012
|
if (currentValue < value) {
|
|
3814
4013
|
low = middle + 1;
|
|
3815
4014
|
} else if (currentValue > value) {
|
|
@@ -3818,37 +4017,80 @@ var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCur
|
|
|
3818
4017
|
return middle;
|
|
3819
4018
|
}
|
|
3820
4019
|
}
|
|
3821
|
-
|
|
3822
4020
|
if (low > 0) {
|
|
3823
4021
|
return low - 1;
|
|
3824
4022
|
} else {
|
|
3825
4023
|
return 0;
|
|
3826
4024
|
}
|
|
3827
4025
|
};
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
var size = measurements.length - 1;
|
|
3834
|
-
|
|
4026
|
+
function calculateRange(_ref9) {
|
|
4027
|
+
var measurements = _ref9.measurements,
|
|
4028
|
+
outerSize = _ref9.outerSize,
|
|
4029
|
+
scrollOffset = _ref9.scrollOffset;
|
|
4030
|
+
var count = measurements.length - 1;
|
|
3835
4031
|
var getOffset = function getOffset(index) {
|
|
3836
4032
|
return measurements[index].start;
|
|
3837
4033
|
};
|
|
3838
|
-
|
|
3839
|
-
var
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
while (end < size && measurements[end].end < scrollOffset + outerSize) {
|
|
3843
|
-
end++;
|
|
4034
|
+
var startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
|
|
4035
|
+
var endIndex = startIndex;
|
|
4036
|
+
while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
4037
|
+
endIndex++;
|
|
3844
4038
|
}
|
|
3845
|
-
|
|
3846
4039
|
return {
|
|
3847
|
-
|
|
3848
|
-
|
|
4040
|
+
startIndex: startIndex,
|
|
4041
|
+
endIndex: endIndex
|
|
3849
4042
|
};
|
|
3850
4043
|
}
|
|
3851
4044
|
|
|
4045
|
+
/**
|
|
4046
|
+
* react-virtual
|
|
4047
|
+
*
|
|
4048
|
+
* Copyright (c) TanStack
|
|
4049
|
+
*
|
|
4050
|
+
* This source code is licensed under the MIT license found in the
|
|
4051
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
4052
|
+
*
|
|
4053
|
+
* @license MIT
|
|
4054
|
+
*/
|
|
4055
|
+
|
|
4056
|
+
//
|
|
4057
|
+
|
|
4058
|
+
var useIsomorphicLayoutEffect$1 = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
4059
|
+
function useVirtualizerBase(options) {
|
|
4060
|
+
var rerender = React.useReducer(function () {
|
|
4061
|
+
return {};
|
|
4062
|
+
}, {})[1];
|
|
4063
|
+
var resolvedOptions = _extends$1({}, options, {
|
|
4064
|
+
onChange: function onChange(instance, sync) {
|
|
4065
|
+
if (sync) {
|
|
4066
|
+
flushSync(rerender);
|
|
4067
|
+
} else {
|
|
4068
|
+
rerender();
|
|
4069
|
+
}
|
|
4070
|
+
options.onChange == null ? void 0 : options.onChange(instance, sync);
|
|
4071
|
+
}
|
|
4072
|
+
});
|
|
4073
|
+
var _React$useState = React.useState(function () {
|
|
4074
|
+
return new Virtualizer(resolvedOptions);
|
|
4075
|
+
}),
|
|
4076
|
+
instance = _React$useState[0];
|
|
4077
|
+
instance.setOptions(resolvedOptions);
|
|
4078
|
+
React.useEffect(function () {
|
|
4079
|
+
return instance._didMount();
|
|
4080
|
+
}, []);
|
|
4081
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
4082
|
+
return instance._willUpdate();
|
|
4083
|
+
});
|
|
4084
|
+
return instance;
|
|
4085
|
+
}
|
|
4086
|
+
function useVirtualizer(options) {
|
|
4087
|
+
return useVirtualizerBase(_extends$1({
|
|
4088
|
+
observeElementRect: observeElementRect,
|
|
4089
|
+
observeElementOffset: observeElementOffset,
|
|
4090
|
+
scrollToFn: elementScroll
|
|
4091
|
+
}, options));
|
|
4092
|
+
}
|
|
4093
|
+
|
|
3852
4094
|
/**
|
|
3853
4095
|
* Custom hook for implementing infinite scrolling in a table.
|
|
3854
4096
|
*
|
|
@@ -3866,7 +4108,6 @@ function calculateRange(_ref4) {
|
|
|
3866
4108
|
* });
|
|
3867
4109
|
*/
|
|
3868
4110
|
const useInfiniteScroll = (props) => {
|
|
3869
|
-
var _a, _b;
|
|
3870
4111
|
//called on scroll and possibly on mount to fetch more data as the user scrolls and reaches bottom of table
|
|
3871
4112
|
const fetchMoreOnBottomReached = useCallback((containerRefElement) => {
|
|
3872
4113
|
var _a;
|
|
@@ -3880,21 +4121,23 @@ const useInfiniteScroll = (props) => {
|
|
|
3880
4121
|
}
|
|
3881
4122
|
}
|
|
3882
4123
|
}, [props.pagination]);
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
4124
|
+
const rowVirtualizer = useVirtualizer({
|
|
4125
|
+
count: props.rowSize,
|
|
4126
|
+
getScrollElement: () => props.containerRef.current,
|
|
4127
|
+
estimateSize: useCallback((i) => props.rowHeight, [props.rowHeight]),
|
|
3887
4128
|
overscan: 10,
|
|
3888
4129
|
});
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
4130
|
+
useEffect(() => {
|
|
4131
|
+
// this ensures the cache is cleared if the rowHeight changes
|
|
4132
|
+
if (props.rowHeight) {
|
|
4133
|
+
rowVirtualizer.measure();
|
|
4134
|
+
}
|
|
4135
|
+
}, [props.rowHeight, rowVirtualizer]);
|
|
4136
|
+
const { getVirtualItems, getTotalSize } = rowVirtualizer;
|
|
3892
4137
|
return {
|
|
3893
|
-
paddingTop,
|
|
3894
|
-
paddingBottom,
|
|
3895
4138
|
fetchMoreOnBottomReached,
|
|
3896
|
-
|
|
3897
|
-
|
|
4139
|
+
getTotalSize,
|
|
4140
|
+
getVirtualItems,
|
|
3898
4141
|
};
|
|
3899
4142
|
};
|
|
3900
4143
|
|
|
@@ -3905,19 +4148,23 @@ const useInfiniteScroll = (props) => {
|
|
|
3905
4148
|
* @returns {JSX.Element} Table component
|
|
3906
4149
|
*/
|
|
3907
4150
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3908
|
-
const Table = (
|
|
3909
|
-
var
|
|
4151
|
+
const Table = (_a) => {
|
|
4152
|
+
var _b, _c;
|
|
4153
|
+
var { rowHeight = 75 } = _a, props = __rest(_a, ["rowHeight"]);
|
|
3910
4154
|
//we need a reference to the scrolling element for logic down below
|
|
3911
4155
|
const tableContainerRef = useRef(null);
|
|
3912
4156
|
const [t] = useTranslation();
|
|
3913
|
-
const { fetchMoreOnBottomReached,
|
|
4157
|
+
const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize } = useInfiniteScroll({
|
|
3914
4158
|
pagination: props.pagination,
|
|
3915
4159
|
containerRef: tableContainerRef,
|
|
3916
4160
|
rowSize: props.getRowModel().rows.length || 0,
|
|
4161
|
+
rowHeight,
|
|
3917
4162
|
});
|
|
3918
4163
|
const hasResults = props.getRowModel().rows.length > 0;
|
|
3919
|
-
return (jsxs(Card, { className: `flex flex-col overflow-hidden ${props.className || ""}`, dataTestId: props.dataTestId, children: [(props.headerLeftActions || props.headerRightActions) && (jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsx("div", { className: "flex", children: props.headerLeftActions }), jsx("div", { className: "flex", children: props.headerRightActions })] })), jsx("div", { className: "min-h[500px] h-full overflow-x-auto overflow-y-scroll border-b border-t border-gray-300", onScroll: e => fetchMoreOnBottomReached(e.target),
|
|
3920
|
-
|
|
4164
|
+
return (jsxs(Card, { className: `flex flex-col overflow-hidden ${props.className || ""}`, dataTestId: props.dataTestId, children: [(props.headerLeftActions || props.headerRightActions) && (jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsx("div", { className: "flex", children: props.headerLeftActions }), jsx("div", { className: "flex", children: props.headerRightActions })] })), jsx("div", { className: "min-h[500px] h-full overflow-x-auto overflow-y-scroll border-b border-t border-gray-300", ref: tableContainerRef, onScroll: e => fetchMoreOnBottomReached(e.target), children: jsxs(TableRoot, { style: {
|
|
4165
|
+
height: getTotalSize(),
|
|
4166
|
+
width: "100%",
|
|
4167
|
+
position: "relative",
|
|
3921
4168
|
}, children: [jsx(Thead, { className: "z-default", children: props.getHeaderGroups().map(headerGroup => (jsx(Tr, { className: "flex", children: headerGroup.headers.map(header => {
|
|
3922
4169
|
var _a, _b, _c, _d;
|
|
3923
4170
|
return (jsxs(Th, { style: {
|
|
@@ -3926,25 +4173,28 @@ const Table = (props) => {
|
|
|
3926
4173
|
maxWidth: header.column.columnDef.maxSize,
|
|
3927
4174
|
}, className: "relative", children: [header.isPlaceholder ? null : (jsxs("div", { className: `${header.column.getCanSort() ? "cursor-pointer select-none" : ""} flex items-center gap-2 py-2 overflow-hidden pr-3`,
|
|
3928
4175
|
onClick: header.column.getToggleSortingHandler(), children: [jsxs("span", { className: "overflow-hidden text-ellipsis whitespace-nowrap", children: [flexRender(header.column.columnDef.header, header.getContext()), ((_b = (_a = header.column.columnDef) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.subHeader) ? (jsx(Text, { size: "small", subtle: true, children: (_d = (_c = header.column.columnDef) === null || _c === void 0 ? void 0 : _c.meta) === null || _d === void 0 ? void 0 : _d.subHeader })) : null] }), header.column.getCanSort() ? (jsx(SortIndicator, { sortingState: header.column.getIsSorted() })) : null] })), header.column.getCanResize() ? (jsx(ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null] }, header.id));
|
|
3929
|
-
}) }, headerGroup.id))) }), hasResults ? (
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
4176
|
+
}) }, headerGroup.id))) }), hasResults ? (jsx(Tbody, { className: "text-sm font-normal", children: getVirtualItems().map((virtualRow, index) => {
|
|
4177
|
+
const row = props.getRowModel().rows[virtualRow.index];
|
|
4178
|
+
if (!row) {
|
|
4179
|
+
return null;
|
|
4180
|
+
}
|
|
4181
|
+
else {
|
|
4182
|
+
return (jsx(Tr, { layout: "flex", style: {
|
|
4183
|
+
height: `${virtualRow.size}px`,
|
|
4184
|
+
transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`,
|
|
4185
|
+
}, onClick: () => (props.onRowClick ? props.onRowClick(row) : row.getToggleSelectedHandler()), className: `${(props.onRowClick || row.getCanSelect()) && "cursor-pointer"} hover:bg-neutral-100`, dataTestId: `table-body-row-${virtualRow.index}`, children: row === null || row === void 0 ? void 0 : row.getVisibleCells().map(cell => {
|
|
4186
|
+
return (jsx(Td, { key: cell.id,
|
|
4187
|
+
style: {
|
|
4188
|
+
width: cell.column.getSize(),
|
|
4189
|
+
minWidth: cell.column.columnDef.minSize,
|
|
4190
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
4191
|
+
}, children: jsx("div", { className: "grid h-full items-center", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }) }));
|
|
4192
|
+
}) }, row.id));
|
|
4193
|
+
}
|
|
4194
|
+
}) })) : (jsx("tbody", { children: jsx("tr", { children: jsx("td", { className: "b-0", children: (props === null || props === void 0 ? void 0 : props.noDataMessage) ? (props.noDataMessage) : (jsx(EmptyState, { image: "ROAD_BLOCK", description: t("table.noResults"), className: "absolute inset-0", loading: props === null || props === void 0 ? void 0 : props.loading })) }) }) }))] }) }), jsxs("div", { className: "flex items-center p-2", children: [jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: t("table.pagination.full", {
|
|
3945
4195
|
count: props.getRowModel().rows.length,
|
|
3946
|
-
total: ((
|
|
3947
|
-
}) }), props.footerRightActions && jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })] })] }));
|
|
4196
|
+
total: ((_c = (_b = props.pagination) === null || _b === void 0 ? void 0 : _b.pageInfo) === null || _c === void 0 ? void 0 : _c.count) || 0,
|
|
4197
|
+
}) }), props.pagination.isLoading ? (jsx("span", { className: "ml-2", children: jsx(Spinner, { size: "small" }) })) : null, props.footerRightActions && jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })] })] }));
|
|
3948
4198
|
};
|
|
3949
4199
|
|
|
3950
4200
|
function getDefaultExportFromCjs (x) {
|
|
@@ -6273,7 +6523,7 @@ var INSTANCE_SYM = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__');
|
|
|
6273
6523
|
* A React component that provides the React-DnD context
|
|
6274
6524
|
*/
|
|
6275
6525
|
|
|
6276
|
-
var DndProvider = memo$
|
|
6526
|
+
var DndProvider = memo$2(function DndProvider(_ref) {
|
|
6277
6527
|
var children = _ref.children,
|
|
6278
6528
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
6279
6529
|
|
|
@@ -8941,9 +9191,16 @@ const ColumnFilter = ({ columns, setColumnOrder, defaultColumnOrder, columnOrder
|
|
|
8941
9191
|
if (!columns) {
|
|
8942
9192
|
return null;
|
|
8943
9193
|
}
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
9194
|
+
const getColumnButtonText = () => {
|
|
9195
|
+
if (numberOfHiddenColumns > 1) {
|
|
9196
|
+
return t("table.columnFilters.hiddenColumnsCount", { count: numberOfHiddenColumns });
|
|
9197
|
+
}
|
|
9198
|
+
if (numberOfHiddenColumns === 1) {
|
|
9199
|
+
return t("table.columnFilters.hiddenColumnCount", { count: numberOfHiddenColumns });
|
|
9200
|
+
}
|
|
9201
|
+
return t("table.columnFilters.columns");
|
|
9202
|
+
};
|
|
9203
|
+
return (jsx(DndProvider, { backend: HTML5Backend, children: jsx(Tooltip, { label: t("table.columnFilters.tooltip"), placement: "bottom-start", children: jsxs(Popover, { placement: "bottom-start", children: [jsx(PopoverTrigger, { children: jsx(Button, { prefix: jsx(Icon, { name: "ViewColumns", size: "small" }), color: "secondary", variant: "transparent", size: "small", children: jsx("span", { className: "hidden sm:block", children: getColumnButtonText() }) }) }), jsx(PopoverContent, { children: () => (jsxs(MenuList, { className: "relative max-h-[55vh] w-72 overflow-y-auto pr-4", children: [jsxs("div", { className: "mb-2 flex items-center justify-between", children: [jsx(Text, { subtle: true, size: "small", children: t("table.columnFilters.title") }), jsx(Button, { className: "p-0", color: "secondary", variant: "transparent", size: "small", onClick: () => resetHiddenColumns(), children: t("layout.actions.reset") })] }), jsx(ColumnFiltersDragAndDrop, { columns: sortedColumns, setColumnOrder: setColumnOrder, onUserEvent: onUserEvent })] })) })] }) }) }));
|
|
8947
9204
|
};
|
|
8948
9205
|
const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, }) => {
|
|
8949
9206
|
const [localColumns, setLocalColumns] = React.useState(columns);
|