@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.cjs.js
CHANGED
|
@@ -9,11 +9,10 @@ var React = require('react');
|
|
|
9
9
|
var reactRouterDom = require('react-router-dom');
|
|
10
10
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
11
11
|
var reactTableBaseComponents = require('@trackunit/react-table-base-components');
|
|
12
|
+
var reactDom = require('react-dom');
|
|
12
13
|
var reactFormComponents = require('@trackunit/react-form-components');
|
|
13
14
|
var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
|
|
14
15
|
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
16
|
function _interopNamespace(e) {
|
|
18
17
|
if (e && e.__esModule) return e;
|
|
19
18
|
var n = Object.create(null);
|
|
@@ -33,7 +32,6 @@ function _interopNamespace(e) {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
37
35
|
|
|
38
36
|
var defaultTranslations = {
|
|
39
37
|
"table.actionsheet.selected": "selected",
|
|
@@ -45,6 +43,7 @@ var defaultTranslations = {
|
|
|
45
43
|
"table.sorting.toolip": "Adjust sorting and direction",
|
|
46
44
|
"table.columnFilters.columns": "Columns",
|
|
47
45
|
"table.columnFilters.hiddenColumnCount": "{{count}} column hidden",
|
|
46
|
+
"table.columnFilters.hiddenColumnsCount": "{{count}} columns hidden",
|
|
48
47
|
"table.columnFilters.title": "Visible values",
|
|
49
48
|
"table.columnFilters.tooltip": "Customize visible values",
|
|
50
49
|
"table.exportFileName": "exported-data",
|
|
@@ -230,7 +229,7 @@ function flattenBy(arr, getChildren) {
|
|
|
230
229
|
recurse(arr);
|
|
231
230
|
return flat;
|
|
232
231
|
}
|
|
233
|
-
function memo(getDeps, fn, opts) {
|
|
232
|
+
function memo$1(getDeps, fn, opts) {
|
|
234
233
|
let deps = [];
|
|
235
234
|
let result;
|
|
236
235
|
return () => {
|
|
@@ -311,7 +310,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
311
310
|
depth,
|
|
312
311
|
columnDef: resolvedColumnDef,
|
|
313
312
|
columns: [],
|
|
314
|
-
getFlatColumns: memo(() => [true], () => {
|
|
313
|
+
getFlatColumns: memo$1(() => [true], () => {
|
|
315
314
|
var _column$columns;
|
|
316
315
|
return [column, ...((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(d => d.getFlatColumns()))];
|
|
317
316
|
}, {
|
|
@@ -321,7 +320,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
321
320
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugColumns;
|
|
322
321
|
}
|
|
323
322
|
}),
|
|
324
|
-
getLeafColumns: memo(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
323
|
+
getLeafColumns: memo$1(() => [table._getOrderColumnsFn()], orderColumns => {
|
|
325
324
|
var _column$columns2;
|
|
326
325
|
if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
|
|
327
326
|
let leafColumns = column.columns.flatMap(column => column.getLeafColumns());
|
|
@@ -387,7 +386,7 @@ const Headers = {
|
|
|
387
386
|
return {
|
|
388
387
|
// Header Groups
|
|
389
388
|
|
|
390
|
-
getHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
389
|
+
getHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
391
390
|
var _left$map$filter, _right$map$filter;
|
|
392
391
|
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
393
392
|
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
@@ -401,7 +400,7 @@ const Headers = {
|
|
|
401
400
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugHeaders;
|
|
402
401
|
}
|
|
403
402
|
}),
|
|
404
|
-
getCenterHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
403
|
+
getCenterHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
405
404
|
leafColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
406
405
|
return buildHeaderGroups(allColumns, leafColumns, table, 'center');
|
|
407
406
|
}, {
|
|
@@ -411,7 +410,7 @@ const Headers = {
|
|
|
411
410
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugHeaders;
|
|
412
411
|
}
|
|
413
412
|
}),
|
|
414
|
-
getLeftHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
413
|
+
getLeftHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
415
414
|
var _left$map$filter2;
|
|
416
415
|
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
417
416
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left');
|
|
@@ -422,7 +421,7 @@ const Headers = {
|
|
|
422
421
|
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugHeaders;
|
|
423
422
|
}
|
|
424
423
|
}),
|
|
425
|
-
getRightHeaderGroups: memo(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
424
|
+
getRightHeaderGroups: memo$1(() => [table.getAllColumns(), table.getVisibleLeafColumns(), table.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
426
425
|
var _right$map$filter2;
|
|
427
426
|
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
428
427
|
return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right');
|
|
@@ -435,7 +434,7 @@ const Headers = {
|
|
|
435
434
|
}),
|
|
436
435
|
// Footer Groups
|
|
437
436
|
|
|
438
|
-
getFooterGroups: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
437
|
+
getFooterGroups: memo$1(() => [table.getHeaderGroups()], headerGroups => {
|
|
439
438
|
return [...headerGroups].reverse();
|
|
440
439
|
}, {
|
|
441
440
|
key: process.env.NODE_ENV === 'development' && 'getFooterGroups',
|
|
@@ -444,7 +443,7 @@ const Headers = {
|
|
|
444
443
|
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugHeaders;
|
|
445
444
|
}
|
|
446
445
|
}),
|
|
447
|
-
getLeftFooterGroups: memo(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
446
|
+
getLeftFooterGroups: memo$1(() => [table.getLeftHeaderGroups()], headerGroups => {
|
|
448
447
|
return [...headerGroups].reverse();
|
|
449
448
|
}, {
|
|
450
449
|
key: process.env.NODE_ENV === 'development' && 'getLeftFooterGroups',
|
|
@@ -453,7 +452,7 @@ const Headers = {
|
|
|
453
452
|
return (_table$options$debugA6 = table.options.debugAll) != null ? _table$options$debugA6 : table.options.debugHeaders;
|
|
454
453
|
}
|
|
455
454
|
}),
|
|
456
|
-
getCenterFooterGroups: memo(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
455
|
+
getCenterFooterGroups: memo$1(() => [table.getCenterHeaderGroups()], headerGroups => {
|
|
457
456
|
return [...headerGroups].reverse();
|
|
458
457
|
}, {
|
|
459
458
|
key: process.env.NODE_ENV === 'development' && 'getCenterFooterGroups',
|
|
@@ -462,7 +461,7 @@ const Headers = {
|
|
|
462
461
|
return (_table$options$debugA7 = table.options.debugAll) != null ? _table$options$debugA7 : table.options.debugHeaders;
|
|
463
462
|
}
|
|
464
463
|
}),
|
|
465
|
-
getRightFooterGroups: memo(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
464
|
+
getRightFooterGroups: memo$1(() => [table.getRightHeaderGroups()], headerGroups => {
|
|
466
465
|
return [...headerGroups].reverse();
|
|
467
466
|
}, {
|
|
468
467
|
key: process.env.NODE_ENV === 'development' && 'getRightFooterGroups',
|
|
@@ -473,7 +472,7 @@ const Headers = {
|
|
|
473
472
|
}),
|
|
474
473
|
// Flat Headers
|
|
475
474
|
|
|
476
|
-
getFlatHeaders: memo(() => [table.getHeaderGroups()], headerGroups => {
|
|
475
|
+
getFlatHeaders: memo$1(() => [table.getHeaderGroups()], headerGroups => {
|
|
477
476
|
return headerGroups.map(headerGroup => {
|
|
478
477
|
return headerGroup.headers;
|
|
479
478
|
}).flat();
|
|
@@ -484,7 +483,7 @@ const Headers = {
|
|
|
484
483
|
return (_table$options$debugA9 = table.options.debugAll) != null ? _table$options$debugA9 : table.options.debugHeaders;
|
|
485
484
|
}
|
|
486
485
|
}),
|
|
487
|
-
getLeftFlatHeaders: memo(() => [table.getLeftHeaderGroups()], left => {
|
|
486
|
+
getLeftFlatHeaders: memo$1(() => [table.getLeftHeaderGroups()], left => {
|
|
488
487
|
return left.map(headerGroup => {
|
|
489
488
|
return headerGroup.headers;
|
|
490
489
|
}).flat();
|
|
@@ -495,7 +494,7 @@ const Headers = {
|
|
|
495
494
|
return (_table$options$debugA10 = table.options.debugAll) != null ? _table$options$debugA10 : table.options.debugHeaders;
|
|
496
495
|
}
|
|
497
496
|
}),
|
|
498
|
-
getCenterFlatHeaders: memo(() => [table.getCenterHeaderGroups()], left => {
|
|
497
|
+
getCenterFlatHeaders: memo$1(() => [table.getCenterHeaderGroups()], left => {
|
|
499
498
|
return left.map(headerGroup => {
|
|
500
499
|
return headerGroup.headers;
|
|
501
500
|
}).flat();
|
|
@@ -506,7 +505,7 @@ const Headers = {
|
|
|
506
505
|
return (_table$options$debugA11 = table.options.debugAll) != null ? _table$options$debugA11 : table.options.debugHeaders;
|
|
507
506
|
}
|
|
508
507
|
}),
|
|
509
|
-
getRightFlatHeaders: memo(() => [table.getRightHeaderGroups()], left => {
|
|
508
|
+
getRightFlatHeaders: memo$1(() => [table.getRightHeaderGroups()], left => {
|
|
510
509
|
return left.map(headerGroup => {
|
|
511
510
|
return headerGroup.headers;
|
|
512
511
|
}).flat();
|
|
@@ -519,7 +518,7 @@ const Headers = {
|
|
|
519
518
|
}),
|
|
520
519
|
// Leaf Headers
|
|
521
520
|
|
|
522
|
-
getCenterLeafHeaders: memo(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
521
|
+
getCenterLeafHeaders: memo$1(() => [table.getCenterFlatHeaders()], flatHeaders => {
|
|
523
522
|
return flatHeaders.filter(header => {
|
|
524
523
|
var _header$subHeaders;
|
|
525
524
|
return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
|
|
@@ -531,7 +530,7 @@ const Headers = {
|
|
|
531
530
|
return (_table$options$debugA13 = table.options.debugAll) != null ? _table$options$debugA13 : table.options.debugHeaders;
|
|
532
531
|
}
|
|
533
532
|
}),
|
|
534
|
-
getLeftLeafHeaders: memo(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
533
|
+
getLeftLeafHeaders: memo$1(() => [table.getLeftFlatHeaders()], flatHeaders => {
|
|
535
534
|
return flatHeaders.filter(header => {
|
|
536
535
|
var _header$subHeaders2;
|
|
537
536
|
return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
|
|
@@ -543,7 +542,7 @@ const Headers = {
|
|
|
543
542
|
return (_table$options$debugA14 = table.options.debugAll) != null ? _table$options$debugA14 : table.options.debugHeaders;
|
|
544
543
|
}
|
|
545
544
|
}),
|
|
546
|
-
getRightLeafHeaders: memo(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
545
|
+
getRightLeafHeaders: memo$1(() => [table.getRightFlatHeaders()], flatHeaders => {
|
|
547
546
|
return flatHeaders.filter(header => {
|
|
548
547
|
var _header$subHeaders3;
|
|
549
548
|
return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
|
|
@@ -555,7 +554,7 @@ const Headers = {
|
|
|
555
554
|
return (_table$options$debugA15 = table.options.debugAll) != null ? _table$options$debugA15 : table.options.debugHeaders;
|
|
556
555
|
}
|
|
557
556
|
}),
|
|
558
|
-
getLeafHeaders: memo(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
557
|
+
getLeafHeaders: memo$1(() => [table.getLeftHeaderGroups(), table.getCenterHeaderGroups(), table.getRightHeaderGroups()], (left, center, right) => {
|
|
559
558
|
var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
|
|
560
559
|
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 => {
|
|
561
560
|
return header.getLeafHeaders();
|
|
@@ -1648,7 +1647,7 @@ const Ordering = {
|
|
|
1648
1647
|
var _table$initialState$c;
|
|
1649
1648
|
table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
|
|
1650
1649
|
},
|
|
1651
|
-
_getOrderColumnsFn: memo(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1650
|
+
_getOrderColumnsFn: memo$1(() => [table.getState().columnOrder, table.getState().grouping, table.options.groupedColumnMode], (columnOrder, grouping, groupedColumnMode) => columns => {
|
|
1652
1651
|
// Sort grouped columns to the start of the column list
|
|
1653
1652
|
// before the headers are built
|
|
1654
1653
|
let orderedColumns = [];
|
|
@@ -1782,7 +1781,7 @@ const Pagination = {
|
|
|
1782
1781
|
pageCount: newPageCount
|
|
1783
1782
|
};
|
|
1784
1783
|
}),
|
|
1785
|
-
getPageOptions: memo(() => [table.getPageCount()], pageCount => {
|
|
1784
|
+
getPageOptions: memo$1(() => [table.getPageCount()], pageCount => {
|
|
1786
1785
|
let pageOptions = [];
|
|
1787
1786
|
if (pageCount && pageCount > 0) {
|
|
1788
1787
|
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
@@ -1905,7 +1904,7 @@ const Pinning = {
|
|
|
1905
1904
|
},
|
|
1906
1905
|
createRow: (row, table) => {
|
|
1907
1906
|
return {
|
|
1908
|
-
getCenterVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1907
|
+
getCenterVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allCells, left, right) => {
|
|
1909
1908
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1910
1909
|
return allCells.filter(d => !leftAndRight.includes(d.column.id));
|
|
1911
1910
|
}, {
|
|
@@ -1915,7 +1914,7 @@ const Pinning = {
|
|
|
1915
1914
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
1916
1915
|
}
|
|
1917
1916
|
}),
|
|
1918
|
-
getLeftVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
|
|
1917
|
+
getLeftVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.left,,], (allCells, left) => {
|
|
1919
1918
|
const cells = (left != null ? left : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1920
1919
|
...d,
|
|
1921
1920
|
position: 'left'
|
|
@@ -1928,7 +1927,7 @@ const Pinning = {
|
|
|
1928
1927
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugRows;
|
|
1929
1928
|
}
|
|
1930
1929
|
}),
|
|
1931
|
-
getRightVisibleCells: memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1930
|
+
getRightVisibleCells: memo$1(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
|
|
1932
1931
|
const cells = (right != null ? right : []).map(columnId => allCells.find(cell => cell.column.id === columnId)).filter(Boolean).map(d => ({
|
|
1933
1932
|
...d,
|
|
1934
1933
|
position: 'right'
|
|
@@ -1959,7 +1958,7 @@ const Pinning = {
|
|
|
1959
1958
|
}
|
|
1960
1959
|
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
1961
1960
|
},
|
|
1962
|
-
getLeftLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1961
|
+
getLeftLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
|
|
1963
1962
|
return (left != null ? left : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1964
1963
|
}, {
|
|
1965
1964
|
key: process.env.NODE_ENV === 'development' && 'getLeftLeafColumns',
|
|
@@ -1968,7 +1967,7 @@ const Pinning = {
|
|
|
1968
1967
|
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
1969
1968
|
}
|
|
1970
1969
|
}),
|
|
1971
|
-
getRightLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1970
|
+
getRightLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
|
|
1972
1971
|
return (right != null ? right : []).map(columnId => allColumns.find(column => column.id === columnId)).filter(Boolean);
|
|
1973
1972
|
}, {
|
|
1974
1973
|
key: process.env.NODE_ENV === 'development' && 'getRightLeafColumns',
|
|
@@ -1977,7 +1976,7 @@ const Pinning = {
|
|
|
1977
1976
|
return (_table$options$debugA5 = table.options.debugAll) != null ? _table$options$debugA5 : table.options.debugColumns;
|
|
1978
1977
|
}
|
|
1979
1978
|
}),
|
|
1980
|
-
getCenterLeafColumns: memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1979
|
+
getCenterLeafColumns: memo$1(() => [table.getAllLeafColumns(), table.getState().columnPinning.left, table.getState().columnPinning.right], (allColumns, left, right) => {
|
|
1981
1980
|
const leftAndRight = [...(left != null ? left : []), ...(right != null ? right : [])];
|
|
1982
1981
|
return allColumns.filter(d => !leftAndRight.includes(d.id));
|
|
1983
1982
|
}, {
|
|
@@ -2113,7 +2112,7 @@ const RowSelection = {
|
|
|
2113
2112
|
// table.setRowSelection(selectedRowIds)
|
|
2114
2113
|
// },
|
|
2115
2114
|
getPreSelectedRowModel: () => table.getCoreRowModel(),
|
|
2116
|
-
getSelectedRowModel: memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
2115
|
+
getSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
|
|
2117
2116
|
if (!Object.keys(rowSelection).length) {
|
|
2118
2117
|
return {
|
|
2119
2118
|
rows: [],
|
|
@@ -2129,7 +2128,7 @@ const RowSelection = {
|
|
|
2129
2128
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugTable;
|
|
2130
2129
|
}
|
|
2131
2130
|
}),
|
|
2132
|
-
getFilteredSelectedRowModel: memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2131
|
+
getFilteredSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
|
|
2133
2132
|
if (!Object.keys(rowSelection).length) {
|
|
2134
2133
|
return {
|
|
2135
2134
|
rows: [],
|
|
@@ -2145,7 +2144,7 @@ const RowSelection = {
|
|
|
2145
2144
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugTable;
|
|
2146
2145
|
}
|
|
2147
2146
|
}),
|
|
2148
|
-
getGroupedSelectedRowModel: memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2147
|
+
getGroupedSelectedRowModel: memo$1(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
|
|
2149
2148
|
if (!Object.keys(rowSelection).length) {
|
|
2150
2149
|
return {
|
|
2151
2150
|
rows: [],
|
|
@@ -2728,7 +2727,7 @@ const Visibility = {
|
|
|
2728
2727
|
},
|
|
2729
2728
|
createRow: (row, table) => {
|
|
2730
2729
|
return {
|
|
2731
|
-
_getAllVisibleCells: memo(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
2730
|
+
_getAllVisibleCells: memo$1(() => [row.getAllCells(), table.getState().columnVisibility], cells => {
|
|
2732
2731
|
return cells.filter(cell => cell.column.getIsVisible());
|
|
2733
2732
|
}, {
|
|
2734
2733
|
key: process.env.NODE_ENV === 'production' && 'row._getAllVisibleCells',
|
|
@@ -2737,7 +2736,7 @@ const Visibility = {
|
|
|
2737
2736
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
2738
2737
|
}
|
|
2739
2738
|
}),
|
|
2740
|
-
getVisibleCells: memo(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2739
|
+
getVisibleCells: memo$1(() => [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()], (left, center, right) => [...left, ...center, ...right], {
|
|
2741
2740
|
key: process.env.NODE_ENV === 'development' && 'row.getVisibleCells',
|
|
2742
2741
|
debug: () => {
|
|
2743
2742
|
var _table$options$debugA2;
|
|
@@ -2748,7 +2747,7 @@ const Visibility = {
|
|
|
2748
2747
|
},
|
|
2749
2748
|
createTable: table => {
|
|
2750
2749
|
const makeVisibleColumnsMethod = (key, getColumns) => {
|
|
2751
|
-
return memo(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2750
|
+
return memo$1(() => [getColumns(), getColumns().filter(d => d.getIsVisible()).map(d => d.id).join('_')], columns => {
|
|
2752
2751
|
return columns.filter(d => d.getIsVisible == null ? void 0 : d.getIsVisible());
|
|
2753
2752
|
}, {
|
|
2754
2753
|
key,
|
|
@@ -2887,7 +2886,7 @@ function createTable(options) {
|
|
|
2887
2886
|
}
|
|
2888
2887
|
return row;
|
|
2889
2888
|
},
|
|
2890
|
-
_getDefaultColumnDef: memo(() => [table.options.defaultColumn], defaultColumn => {
|
|
2889
|
+
_getDefaultColumnDef: memo$1(() => [table.options.defaultColumn], defaultColumn => {
|
|
2891
2890
|
var _defaultColumn;
|
|
2892
2891
|
defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
|
|
2893
2892
|
return {
|
|
@@ -2919,7 +2918,7 @@ function createTable(options) {
|
|
|
2919
2918
|
key: process.env.NODE_ENV === 'development' && 'getDefaultColumnDef'
|
|
2920
2919
|
}),
|
|
2921
2920
|
_getColumnDefs: () => table.options.columns,
|
|
2922
|
-
getAllColumns: memo(() => [table._getColumnDefs()], columnDefs => {
|
|
2921
|
+
getAllColumns: memo$1(() => [table._getColumnDefs()], columnDefs => {
|
|
2923
2922
|
const recurseColumns = function (columnDefs, parent, depth) {
|
|
2924
2923
|
if (depth === void 0) {
|
|
2925
2924
|
depth = 0;
|
|
@@ -2939,7 +2938,7 @@ function createTable(options) {
|
|
|
2939
2938
|
return (_table$options$debugA2 = table.options.debugAll) != null ? _table$options$debugA2 : table.options.debugColumns;
|
|
2940
2939
|
}
|
|
2941
2940
|
}),
|
|
2942
|
-
getAllFlatColumns: memo(() => [table.getAllColumns()], allColumns => {
|
|
2941
|
+
getAllFlatColumns: memo$1(() => [table.getAllColumns()], allColumns => {
|
|
2943
2942
|
return allColumns.flatMap(column => {
|
|
2944
2943
|
return column.getFlatColumns();
|
|
2945
2944
|
});
|
|
@@ -2950,7 +2949,7 @@ function createTable(options) {
|
|
|
2950
2949
|
return (_table$options$debugA3 = table.options.debugAll) != null ? _table$options$debugA3 : table.options.debugColumns;
|
|
2951
2950
|
}
|
|
2952
2951
|
}),
|
|
2953
|
-
_getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2952
|
+
_getAllFlatColumnsById: memo$1(() => [table.getAllFlatColumns()], flatColumns => {
|
|
2954
2953
|
return flatColumns.reduce((acc, column) => {
|
|
2955
2954
|
acc[column.id] = column;
|
|
2956
2955
|
return acc;
|
|
@@ -2962,7 +2961,7 @@ function createTable(options) {
|
|
|
2962
2961
|
return (_table$options$debugA4 = table.options.debugAll) != null ? _table$options$debugA4 : table.options.debugColumns;
|
|
2963
2962
|
}
|
|
2964
2963
|
}),
|
|
2965
|
-
getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2964
|
+
getAllLeafColumns: memo$1(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
|
|
2966
2965
|
let leafColumns = allColumns.flatMap(column => column.getLeafColumns());
|
|
2967
2966
|
return orderColumns(leafColumns);
|
|
2968
2967
|
}, {
|
|
@@ -2998,7 +2997,7 @@ function createCell(table, row, column, columnId) {
|
|
|
2998
2997
|
column,
|
|
2999
2998
|
getValue: () => row.getValue(columnId),
|
|
3000
2999
|
renderValue: getRenderValue,
|
|
3001
|
-
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
3000
|
+
getContext: memo$1(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
3002
3001
|
table,
|
|
3003
3002
|
column,
|
|
3004
3003
|
row,
|
|
@@ -3069,7 +3068,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
3069
3068
|
}
|
|
3070
3069
|
return parentRows.reverse();
|
|
3071
3070
|
},
|
|
3072
|
-
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
3071
|
+
getAllCells: memo$1(() => [table.getAllLeafColumns()], leafColumns => {
|
|
3073
3072
|
return leafColumns.map(column => {
|
|
3074
3073
|
return createCell(table, row, column, column.id);
|
|
3075
3074
|
});
|
|
@@ -3080,7 +3079,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
3080
3079
|
return (_table$options$debugA = table.options.debugAll) != null ? _table$options$debugA : table.options.debugRows;
|
|
3081
3080
|
}
|
|
3082
3081
|
}),
|
|
3083
|
-
_getAllCellsByColumnId: memo(() => [row.getAllCells()], allCells => {
|
|
3082
|
+
_getAllCellsByColumnId: memo$1(() => [row.getAllCells()], allCells => {
|
|
3084
3083
|
return allCells.reduce((acc, cell) => {
|
|
3085
3084
|
acc[cell.column.id] = cell;
|
|
3086
3085
|
return acc;
|
|
@@ -3157,7 +3156,7 @@ function createColumnHelper() {
|
|
|
3157
3156
|
}
|
|
3158
3157
|
|
|
3159
3158
|
function getCoreRowModel() {
|
|
3160
|
-
return table => memo(() => [table.options.data], data => {
|
|
3159
|
+
return table => memo$1(() => [table.options.data], data => {
|
|
3161
3160
|
const rowModel = {
|
|
3162
3161
|
rows: [],
|
|
3163
3162
|
flatRows: [],
|
|
@@ -3214,7 +3213,7 @@ function getCoreRowModel() {
|
|
|
3214
3213
|
}
|
|
3215
3214
|
|
|
3216
3215
|
function getSortedRowModel() {
|
|
3217
|
-
return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3216
|
+
return table => memo$1(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
|
|
3218
3217
|
if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
|
|
3219
3218
|
return rowModel;
|
|
3220
3219
|
}
|
|
@@ -3379,463 +3378,660 @@ function useReactTable(options) {
|
|
|
3379
3378
|
*
|
|
3380
3379
|
* @license MIT
|
|
3381
3380
|
*/
|
|
3381
|
+
function _extends$1() {
|
|
3382
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
3383
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3384
|
+
var source = arguments[i];
|
|
3385
|
+
for (var key in source) {
|
|
3386
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3387
|
+
target[key] = source[key];
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
return target;
|
|
3392
|
+
};
|
|
3393
|
+
return _extends$1.apply(this, arguments);
|
|
3394
|
+
}
|
|
3382
3395
|
|
|
3396
|
+
/**
|
|
3397
|
+
* virtual-core
|
|
3398
|
+
*
|
|
3399
|
+
* Copyright (c) TanStack
|
|
3400
|
+
*
|
|
3401
|
+
* This source code is licensed under the MIT license found in the
|
|
3402
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3403
|
+
*
|
|
3404
|
+
* @license MIT
|
|
3405
|
+
*/
|
|
3383
3406
|
function _extends() {
|
|
3384
|
-
_extends = Object.assign
|
|
3407
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
3385
3408
|
for (var i = 1; i < arguments.length; i++) {
|
|
3386
3409
|
var source = arguments[i];
|
|
3387
|
-
|
|
3388
3410
|
for (var key in source) {
|
|
3389
3411
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3390
3412
|
target[key] = source[key];
|
|
3391
3413
|
}
|
|
3392
3414
|
}
|
|
3393
3415
|
}
|
|
3394
|
-
|
|
3395
3416
|
return target;
|
|
3396
3417
|
};
|
|
3397
|
-
|
|
3398
3418
|
return _extends.apply(this, arguments);
|
|
3399
3419
|
}
|
|
3400
3420
|
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
var
|
|
3417
|
-
|
|
3418
|
-
var
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
}
|
|
3422
|
-
|
|
3423
|
-
if (b === void 0) {
|
|
3424
|
-
b = {};
|
|
3425
|
-
}
|
|
3426
|
-
|
|
3427
|
-
return props.some(function (prop) {
|
|
3428
|
-
return a[prop] !== b[prop];
|
|
3429
|
-
});
|
|
3430
|
-
};
|
|
3431
|
-
|
|
3432
|
-
var observedNodes = /*#__PURE__*/new Map();
|
|
3433
|
-
var rafId;
|
|
3434
|
-
|
|
3435
|
-
var run = function run() {
|
|
3436
|
-
var changedStates = [];
|
|
3437
|
-
observedNodes.forEach(function (state, node) {
|
|
3438
|
-
var newRect = node.getBoundingClientRect();
|
|
3439
|
-
|
|
3440
|
-
if (rectChanged(newRect, state.rect)) {
|
|
3441
|
-
state.rect = newRect;
|
|
3442
|
-
changedStates.push(state);
|
|
3443
|
-
}
|
|
3444
|
-
});
|
|
3445
|
-
changedStates.forEach(function (state) {
|
|
3446
|
-
state.callbacks.forEach(function (cb) {
|
|
3447
|
-
return cb(state.rect);
|
|
3421
|
+
/**
|
|
3422
|
+
* virtual-core
|
|
3423
|
+
*
|
|
3424
|
+
* Copyright (c) TanStack
|
|
3425
|
+
*
|
|
3426
|
+
* This source code is licensed under the MIT license found in the
|
|
3427
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3428
|
+
*
|
|
3429
|
+
* @license MIT
|
|
3430
|
+
*/
|
|
3431
|
+
function memo(getDeps, fn, opts) {
|
|
3432
|
+
var _opts$initialDeps;
|
|
3433
|
+
var deps = (_opts$initialDeps = opts.initialDeps) != null ? _opts$initialDeps : [];
|
|
3434
|
+
var result;
|
|
3435
|
+
return function () {
|
|
3436
|
+
var depTime;
|
|
3437
|
+
if (opts.key && opts.debug != null && opts.debug()) depTime = Date.now();
|
|
3438
|
+
var newDeps = getDeps();
|
|
3439
|
+
var depsChanged = newDeps.length !== deps.length || newDeps.some(function (dep, index) {
|
|
3440
|
+
return deps[index] !== dep;
|
|
3448
3441
|
});
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
};
|
|
3452
|
-
|
|
3453
|
-
function observeRect(node, cb) {
|
|
3454
|
-
return {
|
|
3455
|
-
observe: function observe() {
|
|
3456
|
-
var wasEmpty = observedNodes.size === 0;
|
|
3457
|
-
|
|
3458
|
-
if (observedNodes.has(node)) {
|
|
3459
|
-
observedNodes.get(node).callbacks.push(cb);
|
|
3460
|
-
} else {
|
|
3461
|
-
observedNodes.set(node, {
|
|
3462
|
-
rect: undefined,
|
|
3463
|
-
hasRectChanged: false,
|
|
3464
|
-
callbacks: [cb]
|
|
3465
|
-
});
|
|
3466
|
-
}
|
|
3467
|
-
|
|
3468
|
-
if (wasEmpty) run();
|
|
3469
|
-
},
|
|
3470
|
-
unobserve: function unobserve() {
|
|
3471
|
-
var state = observedNodes.get(node);
|
|
3472
|
-
|
|
3473
|
-
if (state) {
|
|
3474
|
-
// Remove the callback
|
|
3475
|
-
var index = state.callbacks.indexOf(cb);
|
|
3476
|
-
if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
|
|
3477
|
-
|
|
3478
|
-
if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
|
|
3479
|
-
|
|
3480
|
-
if (!observedNodes.size) cancelAnimationFrame(rafId);
|
|
3481
|
-
}
|
|
3442
|
+
if (!depsChanged) {
|
|
3443
|
+
return result;
|
|
3482
3444
|
}
|
|
3445
|
+
deps = newDeps;
|
|
3446
|
+
var resultTime;
|
|
3447
|
+
if (opts.key && opts.debug != null && opts.debug()) resultTime = Date.now();
|
|
3448
|
+
result = fn.apply(void 0, newDeps);
|
|
3449
|
+
if (opts.key && opts.debug != null && opts.debug()) {
|
|
3450
|
+
var depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
|
|
3451
|
+
var resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
|
|
3452
|
+
var resultFpsPercentage = resultEndTime / 16;
|
|
3453
|
+
var pad = function pad(str, num) {
|
|
3454
|
+
str = String(str);
|
|
3455
|
+
while (str.length < num) {
|
|
3456
|
+
str = ' ' + str;
|
|
3457
|
+
}
|
|
3458
|
+
return str;
|
|
3459
|
+
};
|
|
3460
|
+
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);
|
|
3461
|
+
}
|
|
3462
|
+
opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
|
|
3463
|
+
return result;
|
|
3483
3464
|
};
|
|
3484
3465
|
}
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
if (state.height !== rect.height || state.width !== rect.width) {
|
|
3492
|
-
return rect;
|
|
3466
|
+
function notUndefined(value, msg) {
|
|
3467
|
+
if (value === undefined) {
|
|
3468
|
+
throw new Error("Unexpected undefined" + (msg ? ": " + msg : ''));
|
|
3469
|
+
} else {
|
|
3470
|
+
return value;
|
|
3493
3471
|
}
|
|
3494
|
-
|
|
3495
|
-
return state;
|
|
3496
3472
|
}
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
if (initialRect === void 0) {
|
|
3500
|
-
initialRect = {
|
|
3501
|
-
width: 0,
|
|
3502
|
-
height: 0
|
|
3503
|
-
};
|
|
3504
|
-
}
|
|
3505
|
-
|
|
3506
|
-
var _React$useState = React__default["default"].useState(nodeRef.current),
|
|
3507
|
-
element = _React$useState[0],
|
|
3508
|
-
setElement = _React$useState[1];
|
|
3509
|
-
|
|
3510
|
-
var _React$useReducer = React__default["default"].useReducer(rectReducer, initialRect),
|
|
3511
|
-
rect = _React$useReducer[0],
|
|
3512
|
-
dispatch = _React$useReducer[1];
|
|
3513
|
-
|
|
3514
|
-
var initialRectSet = React__default["default"].useRef(false);
|
|
3515
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3516
|
-
if (nodeRef.current !== element) {
|
|
3517
|
-
setElement(nodeRef.current);
|
|
3518
|
-
}
|
|
3519
|
-
});
|
|
3520
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3521
|
-
if (element && !initialRectSet.current) {
|
|
3522
|
-
initialRectSet.current = true;
|
|
3523
|
-
|
|
3524
|
-
var _rect = element.getBoundingClientRect();
|
|
3525
|
-
|
|
3526
|
-
dispatch({
|
|
3527
|
-
rect: _rect
|
|
3528
|
-
});
|
|
3529
|
-
}
|
|
3530
|
-
}, [element]);
|
|
3531
|
-
React__default["default"].useEffect(function () {
|
|
3532
|
-
if (!element) {
|
|
3533
|
-
return;
|
|
3534
|
-
}
|
|
3535
|
-
|
|
3536
|
-
var observer = observeRect(element, function (rect) {
|
|
3537
|
-
dispatch({
|
|
3538
|
-
rect: rect
|
|
3539
|
-
});
|
|
3540
|
-
});
|
|
3541
|
-
observer.observe();
|
|
3542
|
-
return function () {
|
|
3543
|
-
observer.unobserve();
|
|
3544
|
-
};
|
|
3545
|
-
}, [element]);
|
|
3546
|
-
return rect;
|
|
3473
|
+
var approxEqual = function approxEqual(a, b) {
|
|
3474
|
+
return Math.abs(a - b) < 1;
|
|
3547
3475
|
};
|
|
3548
3476
|
|
|
3549
|
-
|
|
3477
|
+
/**
|
|
3478
|
+
* virtual-core
|
|
3479
|
+
*
|
|
3480
|
+
* Copyright (c) TanStack
|
|
3481
|
+
*
|
|
3482
|
+
* This source code is licensed under the MIT license found in the
|
|
3483
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
3484
|
+
*
|
|
3485
|
+
* @license MIT
|
|
3486
|
+
*/
|
|
3487
|
+
|
|
3488
|
+
//
|
|
3550
3489
|
|
|
3551
|
-
|
|
3552
|
-
return 50;
|
|
3553
|
-
};
|
|
3490
|
+
//
|
|
3554
3491
|
|
|
3555
3492
|
var defaultKeyExtractor = function defaultKeyExtractor(index) {
|
|
3556
3493
|
return index;
|
|
3557
3494
|
};
|
|
3558
|
-
|
|
3559
|
-
var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
|
|
3560
|
-
var key = horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
3561
|
-
return el[key];
|
|
3562
|
-
};
|
|
3563
|
-
|
|
3564
3495
|
var defaultRangeExtractor = function defaultRangeExtractor(range) {
|
|
3565
|
-
var start = Math.max(range.
|
|
3566
|
-
var end = Math.min(range.
|
|
3496
|
+
var start = Math.max(range.startIndex - range.overscan, 0);
|
|
3497
|
+
var end = Math.min(range.endIndex + range.overscan, range.count - 1);
|
|
3567
3498
|
var arr = [];
|
|
3568
|
-
|
|
3569
3499
|
for (var _i = start; _i <= end; _i++) {
|
|
3570
3500
|
arr.push(_i);
|
|
3571
3501
|
}
|
|
3572
|
-
|
|
3573
3502
|
return arr;
|
|
3574
3503
|
};
|
|
3575
|
-
var
|
|
3576
|
-
var
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
var sizeKey = horizontal ? 'width' : 'height';
|
|
3603
|
-
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
3604
|
-
var latestRef = React__namespace.useRef({
|
|
3605
|
-
outerSize: 0,
|
|
3606
|
-
scrollOffset: 0,
|
|
3607
|
-
measurements: [],
|
|
3608
|
-
totalSize: 0
|
|
3504
|
+
var observeElementRect = function observeElementRect(instance, cb) {
|
|
3505
|
+
var element = instance.scrollElement;
|
|
3506
|
+
if (!element) {
|
|
3507
|
+
return;
|
|
3508
|
+
}
|
|
3509
|
+
var handler = function handler(rect) {
|
|
3510
|
+
var width = rect.width,
|
|
3511
|
+
height = rect.height;
|
|
3512
|
+
cb({
|
|
3513
|
+
width: Math.round(width),
|
|
3514
|
+
height: Math.round(height)
|
|
3515
|
+
});
|
|
3516
|
+
};
|
|
3517
|
+
handler(element.getBoundingClientRect());
|
|
3518
|
+
var observer = new ResizeObserver(function (entries) {
|
|
3519
|
+
var entry = entries[0];
|
|
3520
|
+
if (entry != null && entry.borderBoxSize) {
|
|
3521
|
+
var box = entry.borderBoxSize[0];
|
|
3522
|
+
if (box) {
|
|
3523
|
+
handler({
|
|
3524
|
+
width: box.inlineSize,
|
|
3525
|
+
height: box.blockSize
|
|
3526
|
+
});
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
handler(element.getBoundingClientRect());
|
|
3609
3531
|
});
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
var
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
var
|
|
3623
|
-
|
|
3624
|
-
|
|
3532
|
+
observer.observe(element, {
|
|
3533
|
+
box: 'border-box'
|
|
3534
|
+
});
|
|
3535
|
+
return function () {
|
|
3536
|
+
observer.unobserve(element);
|
|
3537
|
+
};
|
|
3538
|
+
};
|
|
3539
|
+
var observeElementOffset = function observeElementOffset(instance, cb) {
|
|
3540
|
+
var element = instance.scrollElement;
|
|
3541
|
+
if (!element) {
|
|
3542
|
+
return;
|
|
3543
|
+
}
|
|
3544
|
+
var handler = function handler() {
|
|
3545
|
+
cb(element[instance.options.horizontal ? 'scrollLeft' : 'scrollTop']);
|
|
3546
|
+
};
|
|
3547
|
+
handler();
|
|
3548
|
+
element.addEventListener('scroll', handler, {
|
|
3549
|
+
passive: true
|
|
3550
|
+
});
|
|
3551
|
+
return function () {
|
|
3552
|
+
element.removeEventListener('scroll', handler);
|
|
3553
|
+
};
|
|
3554
|
+
};
|
|
3555
|
+
var measureElement = function measureElement(element, entry, instance) {
|
|
3556
|
+
if (entry != null && entry.borderBoxSize) {
|
|
3557
|
+
var box = entry.borderBoxSize[0];
|
|
3558
|
+
if (box) {
|
|
3559
|
+
var size = Math.round(box[instance.options.horizontal ? 'inlineSize' : 'blockSize']);
|
|
3560
|
+
return size;
|
|
3625
3561
|
}
|
|
3626
|
-
}
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3562
|
+
}
|
|
3563
|
+
return Math.round(element.getBoundingClientRect()[instance.options.horizontal ? 'width' : 'height']);
|
|
3564
|
+
};
|
|
3565
|
+
var elementScroll = function elementScroll(offset, _ref2, instance) {
|
|
3566
|
+
var _instance$scrollEleme3, _instance$scrollEleme4;
|
|
3567
|
+
var _ref2$adjustments = _ref2.adjustments,
|
|
3568
|
+
adjustments = _ref2$adjustments === void 0 ? 0 : _ref2$adjustments,
|
|
3569
|
+
behavior = _ref2.behavior;
|
|
3570
|
+
var toOffset = offset + adjustments;
|
|
3571
|
+
(_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));
|
|
3572
|
+
};
|
|
3573
|
+
var Virtualizer = function Virtualizer(_opts) {
|
|
3574
|
+
var _this = this;
|
|
3575
|
+
this.unsubs = [];
|
|
3576
|
+
this.scrollElement = null;
|
|
3577
|
+
this.isScrolling = false;
|
|
3578
|
+
this.isScrollingTimeoutId = null;
|
|
3579
|
+
this.scrollToIndexTimeoutId = null;
|
|
3580
|
+
this.measurementsCache = [];
|
|
3581
|
+
this.itemSizeCache = new Map();
|
|
3582
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
3583
|
+
this.scrollDirection = null;
|
|
3584
|
+
this.scrollAdjustments = 0;
|
|
3585
|
+
this.measureElementCache = new Map();
|
|
3586
|
+
this.observer = function () {
|
|
3587
|
+
var _ro = null;
|
|
3588
|
+
var get = function get() {
|
|
3589
|
+
if (_ro) {
|
|
3590
|
+
return _ro;
|
|
3591
|
+
} else if (typeof ResizeObserver !== 'undefined') {
|
|
3592
|
+
return _ro = new ResizeObserver(function (entries) {
|
|
3593
|
+
entries.forEach(function (entry) {
|
|
3594
|
+
_this._measureElement(entry.target, entry);
|
|
3595
|
+
});
|
|
3596
|
+
});
|
|
3597
|
+
} else {
|
|
3598
|
+
return null;
|
|
3599
|
+
}
|
|
3600
|
+
};
|
|
3601
|
+
return {
|
|
3602
|
+
disconnect: function disconnect() {
|
|
3603
|
+
var _get;
|
|
3604
|
+
return (_get = get()) == null ? void 0 : _get.disconnect();
|
|
3605
|
+
},
|
|
3606
|
+
observe: function observe(target) {
|
|
3607
|
+
var _get2;
|
|
3608
|
+
return (_get2 = get()) == null ? void 0 : _get2.observe(target, {
|
|
3609
|
+
box: 'border-box'
|
|
3610
|
+
});
|
|
3611
|
+
},
|
|
3612
|
+
unobserve: function unobserve(target) {
|
|
3613
|
+
var _get3;
|
|
3614
|
+
return (_get3 = get()) == null ? void 0 : _get3.unobserve(target);
|
|
3615
|
+
}
|
|
3616
|
+
};
|
|
3617
|
+
}();
|
|
3618
|
+
this.range = null;
|
|
3619
|
+
this.setOptions = function (opts) {
|
|
3620
|
+
Object.entries(opts).forEach(function (_ref3) {
|
|
3621
|
+
var key = _ref3[0],
|
|
3622
|
+
value = _ref3[1];
|
|
3623
|
+
if (typeof value === 'undefined') delete opts[key];
|
|
3624
|
+
});
|
|
3625
|
+
_this.options = _extends({
|
|
3626
|
+
debug: false,
|
|
3627
|
+
initialOffset: 0,
|
|
3628
|
+
overscan: 1,
|
|
3629
|
+
paddingStart: 0,
|
|
3630
|
+
paddingEnd: 0,
|
|
3631
|
+
scrollPaddingStart: 0,
|
|
3632
|
+
scrollPaddingEnd: 0,
|
|
3633
|
+
horizontal: false,
|
|
3634
|
+
getItemKey: defaultKeyExtractor,
|
|
3635
|
+
rangeExtractor: defaultRangeExtractor,
|
|
3636
|
+
onChange: function onChange() {},
|
|
3637
|
+
measureElement: measureElement,
|
|
3638
|
+
initialRect: {
|
|
3639
|
+
width: 0,
|
|
3640
|
+
height: 0
|
|
3641
|
+
},
|
|
3642
|
+
scrollMargin: 0,
|
|
3643
|
+
scrollingDelay: 150,
|
|
3644
|
+
indexAttribute: 'data-index',
|
|
3645
|
+
initialMeasurementsCache: [],
|
|
3646
|
+
lanes: 1
|
|
3647
|
+
}, opts);
|
|
3648
|
+
};
|
|
3649
|
+
this.notify = function (sync) {
|
|
3650
|
+
_this.options.onChange == null ? void 0 : _this.options.onChange(_this, sync);
|
|
3651
|
+
};
|
|
3652
|
+
this.maybeNotify = memo(function () {
|
|
3653
|
+
_this.calculateRange();
|
|
3654
|
+
return [_this.isScrolling, _this.range ? _this.range.startIndex : null, _this.range ? _this.range.endIndex : null];
|
|
3655
|
+
}, function (isScrolling) {
|
|
3656
|
+
_this.notify(isScrolling);
|
|
3657
|
+
}, {
|
|
3658
|
+
key: process.env.NODE_ENV !== 'production' && 'maybeNotify',
|
|
3659
|
+
debug: function debug() {
|
|
3660
|
+
return _this.options.debug;
|
|
3661
|
+
},
|
|
3662
|
+
initialDeps: [this.isScrolling, this.range ? this.range.startIndex : null, this.range ? this.range.endIndex : null]
|
|
3663
|
+
});
|
|
3664
|
+
this.cleanup = function () {
|
|
3665
|
+
_this.unsubs.filter(Boolean).forEach(function (d) {
|
|
3666
|
+
return d();
|
|
3667
|
+
});
|
|
3668
|
+
_this.unsubs = [];
|
|
3669
|
+
_this.scrollElement = null;
|
|
3670
|
+
};
|
|
3671
|
+
this._didMount = function () {
|
|
3672
|
+
_this.measureElementCache.forEach(_this.observer.observe);
|
|
3673
|
+
return function () {
|
|
3674
|
+
_this.observer.disconnect();
|
|
3675
|
+
_this.cleanup();
|
|
3676
|
+
};
|
|
3677
|
+
};
|
|
3678
|
+
this._willUpdate = function () {
|
|
3679
|
+
var scrollElement = _this.options.getScrollElement();
|
|
3680
|
+
if (_this.scrollElement !== scrollElement) {
|
|
3681
|
+
_this.cleanup();
|
|
3682
|
+
_this.scrollElement = scrollElement;
|
|
3683
|
+
_this._scrollToOffset(_this.scrollOffset, {
|
|
3684
|
+
adjustments: undefined,
|
|
3685
|
+
behavior: undefined
|
|
3686
|
+
});
|
|
3687
|
+
_this.unsubs.push(_this.options.observeElementRect(_this, function (rect) {
|
|
3688
|
+
_this.scrollRect = rect;
|
|
3689
|
+
_this.maybeNotify();
|
|
3690
|
+
}));
|
|
3691
|
+
_this.unsubs.push(_this.options.observeElementOffset(_this, function (offset) {
|
|
3692
|
+
_this.scrollAdjustments = 0;
|
|
3693
|
+
if (_this.scrollOffset === offset) {
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
if (_this.isScrollingTimeoutId !== null) {
|
|
3697
|
+
clearTimeout(_this.isScrollingTimeoutId);
|
|
3698
|
+
_this.isScrollingTimeoutId = null;
|
|
3699
|
+
}
|
|
3700
|
+
_this.isScrolling = true;
|
|
3701
|
+
_this.scrollDirection = _this.scrollOffset < offset ? 'forward' : 'backward';
|
|
3702
|
+
_this.scrollOffset = offset;
|
|
3703
|
+
_this.maybeNotify();
|
|
3704
|
+
_this.isScrollingTimeoutId = setTimeout(function () {
|
|
3705
|
+
_this.isScrollingTimeoutId = null;
|
|
3706
|
+
_this.isScrolling = false;
|
|
3707
|
+
_this.scrollDirection = null;
|
|
3708
|
+
_this.maybeNotify();
|
|
3709
|
+
}, _this.options.scrollingDelay);
|
|
3710
|
+
}));
|
|
3711
|
+
}
|
|
3712
|
+
};
|
|
3713
|
+
this.getSize = function () {
|
|
3714
|
+
return _this.scrollRect[_this.options.horizontal ? 'width' : 'height'];
|
|
3715
|
+
};
|
|
3716
|
+
this.memoOptions = memo(function () {
|
|
3717
|
+
return [_this.options.count, _this.options.paddingStart, _this.options.scrollMargin, _this.options.getItemKey];
|
|
3718
|
+
}, function (count, paddingStart, scrollMargin, getItemKey) {
|
|
3719
|
+
_this.pendingMeasuredCacheIndexes = [];
|
|
3720
|
+
return {
|
|
3721
|
+
count: count,
|
|
3722
|
+
paddingStart: paddingStart,
|
|
3723
|
+
scrollMargin: scrollMargin,
|
|
3724
|
+
getItemKey: getItemKey
|
|
3725
|
+
};
|
|
3726
|
+
}, {
|
|
3727
|
+
key: false
|
|
3728
|
+
});
|
|
3729
|
+
this.getFurthestMeasurement = function (measurements, index) {
|
|
3730
|
+
var furthestMeasurementsFound = new Map();
|
|
3731
|
+
var furthestMeasurements = new Map();
|
|
3732
|
+
for (var m = index - 1; m >= 0; m--) {
|
|
3733
|
+
var measurement = measurements[m];
|
|
3734
|
+
if (furthestMeasurementsFound.has(measurement.lane)) {
|
|
3735
|
+
continue;
|
|
3736
|
+
}
|
|
3737
|
+
var previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
|
|
3738
|
+
if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) {
|
|
3739
|
+
furthestMeasurements.set(measurement.lane, measurement);
|
|
3740
|
+
} else if (measurement.end < previousFurthestMeasurement.end) {
|
|
3741
|
+
furthestMeasurementsFound.set(measurement.lane, true);
|
|
3742
|
+
}
|
|
3743
|
+
if (furthestMeasurementsFound.size === _this.options.lanes) {
|
|
3744
|
+
break;
|
|
3745
|
+
}
|
|
3746
|
+
}
|
|
3747
|
+
return furthestMeasurements.size === _this.options.lanes ? Array.from(furthestMeasurements.values()).sort(function (a, b) {
|
|
3748
|
+
return a.end - b.end;
|
|
3749
|
+
})[0] : undefined;
|
|
3750
|
+
};
|
|
3751
|
+
this.getMeasurements = memo(function () {
|
|
3752
|
+
return [_this.memoOptions(), _this.itemSizeCache];
|
|
3753
|
+
}, function (_ref4, itemSizeCache) {
|
|
3754
|
+
var count = _ref4.count,
|
|
3755
|
+
paddingStart = _ref4.paddingStart,
|
|
3756
|
+
scrollMargin = _ref4.scrollMargin,
|
|
3757
|
+
getItemKey = _ref4.getItemKey;
|
|
3758
|
+
var min = _this.pendingMeasuredCacheIndexes.length > 0 ? Math.min.apply(Math, _this.pendingMeasuredCacheIndexes) : 0;
|
|
3759
|
+
_this.pendingMeasuredCacheIndexes = [];
|
|
3760
|
+
var measurements = _this.measurementsCache.slice(0, min);
|
|
3761
|
+
for (var _i2 = min; _i2 < count; _i2++) {
|
|
3762
|
+
var key = getItemKey(_i2);
|
|
3763
|
+
var furthestMeasurement = _this.options.lanes === 1 ? measurements[_i2 - 1] : _this.getFurthestMeasurement(measurements, _i2);
|
|
3764
|
+
var start = furthestMeasurement ? furthestMeasurement.end : paddingStart + scrollMargin;
|
|
3765
|
+
var measuredSize = itemSizeCache.get(key);
|
|
3766
|
+
var size = typeof measuredSize === 'number' ? measuredSize : _this.options.estimateSize(_i2);
|
|
3767
|
+
var end = start + size;
|
|
3768
|
+
var lane = furthestMeasurement ? furthestMeasurement.lane : _i2 % _this.options.lanes;
|
|
3655
3769
|
measurements[_i2] = {
|
|
3656
3770
|
index: _i2,
|
|
3657
|
-
start:
|
|
3658
|
-
size:
|
|
3659
|
-
end:
|
|
3660
|
-
key: key
|
|
3771
|
+
start: start,
|
|
3772
|
+
size: size,
|
|
3773
|
+
end: end,
|
|
3774
|
+
key: key,
|
|
3775
|
+
lane: lane
|
|
3661
3776
|
};
|
|
3662
3777
|
}
|
|
3663
|
-
|
|
3778
|
+
_this.measurementsCache = measurements;
|
|
3664
3779
|
return measurements;
|
|
3665
|
-
},
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
var element = onScrollElement ? onScrollElement.current : parentRef.current;
|
|
3670
|
-
var scrollOffsetFnRef = React__namespace.useRef(scrollOffsetFn);
|
|
3671
|
-
scrollOffsetFnRef.current = scrollOffsetFn;
|
|
3672
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
3673
|
-
if (!element) {
|
|
3674
|
-
setScrollOffset(0);
|
|
3675
|
-
return;
|
|
3780
|
+
}, {
|
|
3781
|
+
key: process.env.NODE_ENV !== 'production' && 'getMeasurements',
|
|
3782
|
+
debug: function debug() {
|
|
3783
|
+
return _this.options.debug;
|
|
3676
3784
|
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
}
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
var indexes = React__namespace.useMemo(function () {
|
|
3698
|
-
return rangeExtractor({
|
|
3699
|
-
start: start,
|
|
3700
|
-
end: end,
|
|
3785
|
+
});
|
|
3786
|
+
this.calculateRange = memo(function () {
|
|
3787
|
+
return [_this.getMeasurements(), _this.getSize(), _this.scrollOffset];
|
|
3788
|
+
}, function (measurements, outerSize, scrollOffset) {
|
|
3789
|
+
return _this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
|
|
3790
|
+
measurements: measurements,
|
|
3791
|
+
outerSize: outerSize,
|
|
3792
|
+
scrollOffset: scrollOffset
|
|
3793
|
+
}) : null;
|
|
3794
|
+
}, {
|
|
3795
|
+
key: process.env.NODE_ENV !== 'production' && 'calculateRange',
|
|
3796
|
+
debug: function debug() {
|
|
3797
|
+
return _this.options.debug;
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
this.getIndexes = memo(function () {
|
|
3801
|
+
return [_this.options.rangeExtractor, _this.calculateRange(), _this.options.overscan, _this.options.count];
|
|
3802
|
+
}, function (rangeExtractor, range, overscan, count) {
|
|
3803
|
+
return range === null ? [] : rangeExtractor(_extends({}, range, {
|
|
3701
3804
|
overscan: overscan,
|
|
3702
|
-
|
|
3703
|
-
});
|
|
3704
|
-
},
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
pendingMeasuredCacheIndexesRef.current.push(i);
|
|
3727
|
-
setMeasuredCache(function (old) {
|
|
3728
|
-
var _extends2;
|
|
3729
|
-
|
|
3730
|
-
return _extends({}, old, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
|
|
3731
|
-
});
|
|
3732
|
-
}
|
|
3733
|
-
}
|
|
3805
|
+
count: count
|
|
3806
|
+
}));
|
|
3807
|
+
}, {
|
|
3808
|
+
key: process.env.NODE_ENV !== 'production' && 'getIndexes',
|
|
3809
|
+
debug: function debug() {
|
|
3810
|
+
return _this.options.debug;
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
this.indexFromElement = function (node) {
|
|
3814
|
+
var attributeName = _this.options.indexAttribute;
|
|
3815
|
+
var indexStr = node.getAttribute(attributeName);
|
|
3816
|
+
if (!indexStr) {
|
|
3817
|
+
console.warn("Missing attribute name '" + attributeName + "={index}' on measured element.");
|
|
3818
|
+
return -1;
|
|
3819
|
+
}
|
|
3820
|
+
return parseInt(indexStr, 10);
|
|
3821
|
+
};
|
|
3822
|
+
this._measureElement = function (node, entry) {
|
|
3823
|
+
var item = _this.measurementsCache[_this.indexFromElement(node)];
|
|
3824
|
+
if (!item || !node.isConnected) {
|
|
3825
|
+
_this.measureElementCache.forEach(function (cached, key) {
|
|
3826
|
+
if (cached === node) {
|
|
3827
|
+
_this.observer.unobserve(node);
|
|
3828
|
+
_this.measureElementCache["delete"](key);
|
|
3734
3829
|
}
|
|
3735
3830
|
});
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
var prevNode = _this.measureElementCache.get(item.key);
|
|
3834
|
+
if (prevNode !== node) {
|
|
3835
|
+
if (prevNode) {
|
|
3836
|
+
_this.observer.unobserve(prevNode);
|
|
3837
|
+
}
|
|
3838
|
+
_this.observer.observe(node);
|
|
3839
|
+
_this.measureElementCache.set(item.key, node);
|
|
3840
|
+
}
|
|
3841
|
+
var measuredItemSize = _this.options.measureElement(node, entry, _this);
|
|
3842
|
+
_this.resizeItem(item, measuredItemSize);
|
|
3843
|
+
};
|
|
3844
|
+
this.resizeItem = function (item, size) {
|
|
3845
|
+
var _this$itemSizeCache$g;
|
|
3846
|
+
var itemSize = (_this$itemSizeCache$g = _this.itemSizeCache.get(item.key)) != null ? _this$itemSizeCache$g : item.size;
|
|
3847
|
+
var delta = size - itemSize;
|
|
3848
|
+
if (delta !== 0) {
|
|
3849
|
+
if (item.start < _this.scrollOffset) {
|
|
3850
|
+
if (process.env.NODE_ENV !== 'production' && _this.options.debug) {
|
|
3851
|
+
console.info('correction', delta);
|
|
3852
|
+
}
|
|
3853
|
+
_this._scrollToOffset(_this.scrollOffset, {
|
|
3854
|
+
adjustments: _this.scrollAdjustments += delta,
|
|
3855
|
+
behavior: undefined
|
|
3856
|
+
});
|
|
3857
|
+
}
|
|
3858
|
+
_this.pendingMeasuredCacheIndexes.push(item.index);
|
|
3859
|
+
_this.itemSizeCache = new Map(_this.itemSizeCache.set(item.key, size));
|
|
3860
|
+
_this.notify(false);
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
this.measureElement = function (node) {
|
|
3864
|
+
if (!node) {
|
|
3865
|
+
return;
|
|
3866
|
+
}
|
|
3867
|
+
_this._measureElement(node, undefined);
|
|
3868
|
+
};
|
|
3869
|
+
this.getVirtualItems = memo(function () {
|
|
3870
|
+
return [_this.getIndexes(), _this.getMeasurements()];
|
|
3871
|
+
}, function (indexes, measurements) {
|
|
3872
|
+
var virtualItems = [];
|
|
3740
3873
|
for (var k = 0, len = indexes.length; k < len; k++) {
|
|
3741
|
-
|
|
3874
|
+
var _i3 = indexes[k];
|
|
3875
|
+
var measurement = measurements[_i3];
|
|
3876
|
+
virtualItems.push(measurement);
|
|
3742
3877
|
}
|
|
3743
|
-
|
|
3744
3878
|
return virtualItems;
|
|
3745
|
-
},
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
setMeasuredCache({});
|
|
3879
|
+
}, {
|
|
3880
|
+
key: process.env.NODE_ENV !== 'production' && 'getIndexes',
|
|
3881
|
+
debug: function debug() {
|
|
3882
|
+
return _this.options.debug;
|
|
3750
3883
|
}
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
var _latestRef$current = latestRef.current,
|
|
3761
|
-
scrollOffset = _latestRef$current.scrollOffset,
|
|
3762
|
-
outerSize = _latestRef$current.outerSize;
|
|
3763
|
-
|
|
3884
|
+
});
|
|
3885
|
+
this.getVirtualItemForOffset = function (offset) {
|
|
3886
|
+
var measurements = _this.getMeasurements();
|
|
3887
|
+
return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, function (index) {
|
|
3888
|
+
return notUndefined(measurements[index]).start;
|
|
3889
|
+
}, offset)]);
|
|
3890
|
+
};
|
|
3891
|
+
this.getOffsetForAlignment = function (toOffset, align) {
|
|
3892
|
+
var size = _this.getSize();
|
|
3764
3893
|
if (align === 'auto') {
|
|
3765
|
-
if (toOffset <= scrollOffset) {
|
|
3894
|
+
if (toOffset <= _this.scrollOffset) {
|
|
3766
3895
|
align = 'start';
|
|
3767
|
-
} else if (toOffset >= scrollOffset +
|
|
3896
|
+
} else if (toOffset >= _this.scrollOffset + size) {
|
|
3768
3897
|
align = 'end';
|
|
3769
3898
|
} else {
|
|
3770
3899
|
align = 'start';
|
|
3771
3900
|
}
|
|
3772
3901
|
}
|
|
3773
|
-
|
|
3774
3902
|
if (align === 'start') {
|
|
3775
|
-
|
|
3903
|
+
toOffset = toOffset;
|
|
3776
3904
|
} else if (align === 'end') {
|
|
3777
|
-
|
|
3905
|
+
toOffset = toOffset - size;
|
|
3778
3906
|
} else if (align === 'center') {
|
|
3779
|
-
|
|
3780
|
-
}
|
|
3781
|
-
}, [scrollTo]);
|
|
3782
|
-
var tryScrollToIndex = React__namespace.useCallback(function (index, _temp2) {
|
|
3783
|
-
var _ref3 = _temp2 === void 0 ? {
|
|
3784
|
-
align: 'auto'
|
|
3785
|
-
} : _temp2,
|
|
3786
|
-
align = _ref3.align,
|
|
3787
|
-
rest = _objectWithoutPropertiesLoose$1(_ref3, _excluded$1);
|
|
3788
|
-
|
|
3789
|
-
var _latestRef$current2 = latestRef.current,
|
|
3790
|
-
measurements = _latestRef$current2.measurements,
|
|
3791
|
-
scrollOffset = _latestRef$current2.scrollOffset,
|
|
3792
|
-
outerSize = _latestRef$current2.outerSize;
|
|
3793
|
-
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
3794
|
-
|
|
3795
|
-
if (!measurement) {
|
|
3796
|
-
return;
|
|
3907
|
+
toOffset = toOffset - size / 2;
|
|
3797
3908
|
}
|
|
3798
|
-
|
|
3909
|
+
var scrollSizeProp = _this.options.horizontal ? 'scrollWidth' : 'scrollHeight';
|
|
3910
|
+
var scrollSize = _this.scrollElement ? 'document' in _this.scrollElement ? _this.scrollElement.document.documentElement[scrollSizeProp] : _this.scrollElement[scrollSizeProp] : 0;
|
|
3911
|
+
var maxOffset = scrollSize - _this.getSize();
|
|
3912
|
+
return Math.max(Math.min(maxOffset, toOffset), 0);
|
|
3913
|
+
};
|
|
3914
|
+
this.getOffsetForIndex = function (index, align) {
|
|
3915
|
+
if (align === void 0) {
|
|
3916
|
+
align = 'auto';
|
|
3917
|
+
}
|
|
3918
|
+
index = Math.max(0, Math.min(index, _this.options.count - 1));
|
|
3919
|
+
var measurement = notUndefined(_this.getMeasurements()[index]);
|
|
3799
3920
|
if (align === 'auto') {
|
|
3800
|
-
if (measurement.end >= scrollOffset +
|
|
3921
|
+
if (measurement.end >= _this.scrollOffset + _this.getSize() - _this.options.scrollPaddingEnd) {
|
|
3801
3922
|
align = 'end';
|
|
3802
|
-
} else if (measurement.start <= scrollOffset) {
|
|
3923
|
+
} else if (measurement.start <= _this.scrollOffset + _this.options.scrollPaddingStart) {
|
|
3803
3924
|
align = 'start';
|
|
3804
3925
|
} else {
|
|
3805
|
-
return;
|
|
3926
|
+
return [_this.scrollOffset, align];
|
|
3806
3927
|
}
|
|
3807
3928
|
}
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
}
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3929
|
+
var toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
|
|
3930
|
+
return [_this.getOffsetForAlignment(toOffset, align), align];
|
|
3931
|
+
};
|
|
3932
|
+
this.isDynamicMode = function () {
|
|
3933
|
+
return _this.measureElementCache.size > 0;
|
|
3934
|
+
};
|
|
3935
|
+
this.cancelScrollToIndex = function () {
|
|
3936
|
+
if (_this.scrollToIndexTimeoutId !== null) {
|
|
3937
|
+
clearTimeout(_this.scrollToIndexTimeoutId);
|
|
3938
|
+
_this.scrollToIndexTimeoutId = null;
|
|
3939
|
+
}
|
|
3940
|
+
};
|
|
3941
|
+
this.scrollToOffset = function (toOffset, _temp) {
|
|
3942
|
+
var _ref5 = _temp === void 0 ? {} : _temp,
|
|
3943
|
+
_ref5$align = _ref5.align,
|
|
3944
|
+
align = _ref5$align === void 0 ? 'start' : _ref5$align,
|
|
3945
|
+
behavior = _ref5.behavior;
|
|
3946
|
+
_this.cancelScrollToIndex();
|
|
3947
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3948
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
3949
|
+
}
|
|
3950
|
+
_this._scrollToOffset(_this.getOffsetForAlignment(toOffset, align), {
|
|
3951
|
+
adjustments: undefined,
|
|
3952
|
+
behavior: behavior
|
|
3953
|
+
});
|
|
3954
|
+
};
|
|
3955
|
+
this.scrollToIndex = function (index, _temp2) {
|
|
3956
|
+
var _ref6 = _temp2 === void 0 ? {} : _temp2,
|
|
3957
|
+
_ref6$align = _ref6.align,
|
|
3958
|
+
initialAlign = _ref6$align === void 0 ? 'auto' : _ref6$align,
|
|
3959
|
+
behavior = _ref6.behavior;
|
|
3960
|
+
index = Math.max(0, Math.min(index, _this.options.count - 1));
|
|
3961
|
+
_this.cancelScrollToIndex();
|
|
3962
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3963
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
3964
|
+
}
|
|
3965
|
+
var _this$getOffsetForInd = _this.getOffsetForIndex(index, initialAlign),
|
|
3966
|
+
toOffset = _this$getOffsetForInd[0],
|
|
3967
|
+
align = _this$getOffsetForInd[1];
|
|
3968
|
+
_this._scrollToOffset(toOffset, {
|
|
3969
|
+
adjustments: undefined,
|
|
3970
|
+
behavior: behavior
|
|
3971
|
+
});
|
|
3972
|
+
if (behavior !== 'smooth' && _this.isDynamicMode()) {
|
|
3973
|
+
_this.scrollToIndexTimeoutId = setTimeout(function () {
|
|
3974
|
+
_this.scrollToIndexTimeoutId = null;
|
|
3975
|
+
var elementInDOM = _this.measureElementCache.has(_this.options.getItemKey(index));
|
|
3976
|
+
if (elementInDOM) {
|
|
3977
|
+
var _this$getOffsetForInd2 = _this.getOffsetForIndex(index, align),
|
|
3978
|
+
_toOffset = _this$getOffsetForInd2[0];
|
|
3979
|
+
if (!approxEqual(_toOffset, _this.scrollOffset)) {
|
|
3980
|
+
_this.scrollToIndex(index, {
|
|
3981
|
+
align: align,
|
|
3982
|
+
behavior: behavior
|
|
3983
|
+
});
|
|
3984
|
+
}
|
|
3985
|
+
} else {
|
|
3986
|
+
_this.scrollToIndex(index, {
|
|
3987
|
+
align: align,
|
|
3988
|
+
behavior: behavior
|
|
3989
|
+
});
|
|
3990
|
+
}
|
|
3991
|
+
});
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
this.scrollBy = function (delta, _temp3) {
|
|
3995
|
+
var _ref7 = _temp3 === void 0 ? {} : _temp3,
|
|
3996
|
+
behavior = _ref7.behavior;
|
|
3997
|
+
_this.cancelScrollToIndex();
|
|
3998
|
+
if (behavior === 'smooth' && _this.isDynamicMode()) {
|
|
3999
|
+
console.warn('The `smooth` scroll behavior is not fully supported with dynamic size.');
|
|
4000
|
+
}
|
|
4001
|
+
_this._scrollToOffset(_this.scrollOffset + delta, {
|
|
4002
|
+
adjustments: undefined,
|
|
4003
|
+
behavior: behavior
|
|
3823
4004
|
});
|
|
3824
|
-
}, [tryScrollToIndex]);
|
|
3825
|
-
return {
|
|
3826
|
-
virtualItems: virtualItems,
|
|
3827
|
-
totalSize: totalSize,
|
|
3828
|
-
scrollToOffset: scrollToOffset,
|
|
3829
|
-
scrollToIndex: scrollToIndex,
|
|
3830
|
-
measure: measure
|
|
3831
4005
|
};
|
|
4006
|
+
this.getTotalSize = function () {
|
|
4007
|
+
var _this$getMeasurements;
|
|
4008
|
+
return (((_this$getMeasurements = _this.getMeasurements()[_this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || _this.options.paddingStart) - _this.options.scrollMargin + _this.options.paddingEnd;
|
|
4009
|
+
};
|
|
4010
|
+
this._scrollToOffset = function (offset, _ref8) {
|
|
4011
|
+
var adjustments = _ref8.adjustments,
|
|
4012
|
+
behavior = _ref8.behavior;
|
|
4013
|
+
_this.options.scrollToFn(offset, {
|
|
4014
|
+
behavior: behavior,
|
|
4015
|
+
adjustments: adjustments
|
|
4016
|
+
}, _this);
|
|
4017
|
+
};
|
|
4018
|
+
this.measure = function () {
|
|
4019
|
+
_this.itemSizeCache = new Map();
|
|
4020
|
+
_this.notify(false);
|
|
4021
|
+
};
|
|
4022
|
+
this.setOptions(_opts);
|
|
4023
|
+
this.scrollRect = this.options.initialRect;
|
|
4024
|
+
this.scrollOffset = this.options.initialOffset;
|
|
4025
|
+
this.measurementsCache = this.options.initialMeasurementsCache;
|
|
4026
|
+
this.measurementsCache.forEach(function (item) {
|
|
4027
|
+
_this.itemSizeCache.set(item.key, item.size);
|
|
4028
|
+
});
|
|
4029
|
+
this.maybeNotify();
|
|
3832
4030
|
};
|
|
3833
|
-
|
|
3834
4031
|
var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
|
|
3835
4032
|
while (low <= high) {
|
|
3836
4033
|
var middle = (low + high) / 2 | 0;
|
|
3837
4034
|
var currentValue = getCurrentValue(middle);
|
|
3838
|
-
|
|
3839
4035
|
if (currentValue < value) {
|
|
3840
4036
|
low = middle + 1;
|
|
3841
4037
|
} else if (currentValue > value) {
|
|
@@ -3844,37 +4040,80 @@ var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCur
|
|
|
3844
4040
|
return middle;
|
|
3845
4041
|
}
|
|
3846
4042
|
}
|
|
3847
|
-
|
|
3848
4043
|
if (low > 0) {
|
|
3849
4044
|
return low - 1;
|
|
3850
4045
|
} else {
|
|
3851
4046
|
return 0;
|
|
3852
4047
|
}
|
|
3853
4048
|
};
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
var size = measurements.length - 1;
|
|
3860
|
-
|
|
4049
|
+
function calculateRange(_ref9) {
|
|
4050
|
+
var measurements = _ref9.measurements,
|
|
4051
|
+
outerSize = _ref9.outerSize,
|
|
4052
|
+
scrollOffset = _ref9.scrollOffset;
|
|
4053
|
+
var count = measurements.length - 1;
|
|
3861
4054
|
var getOffset = function getOffset(index) {
|
|
3862
4055
|
return measurements[index].start;
|
|
3863
4056
|
};
|
|
3864
|
-
|
|
3865
|
-
var
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
while (end < size && measurements[end].end < scrollOffset + outerSize) {
|
|
3869
|
-
end++;
|
|
4057
|
+
var startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
|
|
4058
|
+
var endIndex = startIndex;
|
|
4059
|
+
while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
|
|
4060
|
+
endIndex++;
|
|
3870
4061
|
}
|
|
3871
|
-
|
|
3872
4062
|
return {
|
|
3873
|
-
|
|
3874
|
-
|
|
4063
|
+
startIndex: startIndex,
|
|
4064
|
+
endIndex: endIndex
|
|
3875
4065
|
};
|
|
3876
4066
|
}
|
|
3877
4067
|
|
|
4068
|
+
/**
|
|
4069
|
+
* react-virtual
|
|
4070
|
+
*
|
|
4071
|
+
* Copyright (c) TanStack
|
|
4072
|
+
*
|
|
4073
|
+
* This source code is licensed under the MIT license found in the
|
|
4074
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
4075
|
+
*
|
|
4076
|
+
* @license MIT
|
|
4077
|
+
*/
|
|
4078
|
+
|
|
4079
|
+
//
|
|
4080
|
+
|
|
4081
|
+
var useIsomorphicLayoutEffect$1 = typeof document !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
4082
|
+
function useVirtualizerBase(options) {
|
|
4083
|
+
var rerender = React__namespace.useReducer(function () {
|
|
4084
|
+
return {};
|
|
4085
|
+
}, {})[1];
|
|
4086
|
+
var resolvedOptions = _extends$1({}, options, {
|
|
4087
|
+
onChange: function onChange(instance, sync) {
|
|
4088
|
+
if (sync) {
|
|
4089
|
+
reactDom.flushSync(rerender);
|
|
4090
|
+
} else {
|
|
4091
|
+
rerender();
|
|
4092
|
+
}
|
|
4093
|
+
options.onChange == null ? void 0 : options.onChange(instance, sync);
|
|
4094
|
+
}
|
|
4095
|
+
});
|
|
4096
|
+
var _React$useState = React__namespace.useState(function () {
|
|
4097
|
+
return new Virtualizer(resolvedOptions);
|
|
4098
|
+
}),
|
|
4099
|
+
instance = _React$useState[0];
|
|
4100
|
+
instance.setOptions(resolvedOptions);
|
|
4101
|
+
React__namespace.useEffect(function () {
|
|
4102
|
+
return instance._didMount();
|
|
4103
|
+
}, []);
|
|
4104
|
+
useIsomorphicLayoutEffect$1(function () {
|
|
4105
|
+
return instance._willUpdate();
|
|
4106
|
+
});
|
|
4107
|
+
return instance;
|
|
4108
|
+
}
|
|
4109
|
+
function useVirtualizer(options) {
|
|
4110
|
+
return useVirtualizerBase(_extends$1({
|
|
4111
|
+
observeElementRect: observeElementRect,
|
|
4112
|
+
observeElementOffset: observeElementOffset,
|
|
4113
|
+
scrollToFn: elementScroll
|
|
4114
|
+
}, options));
|
|
4115
|
+
}
|
|
4116
|
+
|
|
3878
4117
|
/**
|
|
3879
4118
|
* Custom hook for implementing infinite scrolling in a table.
|
|
3880
4119
|
*
|
|
@@ -3892,7 +4131,6 @@ function calculateRange(_ref4) {
|
|
|
3892
4131
|
* });
|
|
3893
4132
|
*/
|
|
3894
4133
|
const useInfiniteScroll = (props) => {
|
|
3895
|
-
var _a, _b;
|
|
3896
4134
|
//called on scroll and possibly on mount to fetch more data as the user scrolls and reaches bottom of table
|
|
3897
4135
|
const fetchMoreOnBottomReached = React.useCallback((containerRefElement) => {
|
|
3898
4136
|
var _a;
|
|
@@ -3906,21 +4144,23 @@ const useInfiniteScroll = (props) => {
|
|
|
3906
4144
|
}
|
|
3907
4145
|
}
|
|
3908
4146
|
}, [props.pagination]);
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
4147
|
+
const rowVirtualizer = useVirtualizer({
|
|
4148
|
+
count: props.rowSize,
|
|
4149
|
+
getScrollElement: () => props.containerRef.current,
|
|
4150
|
+
estimateSize: React.useCallback((i) => props.rowHeight, [props.rowHeight]),
|
|
3913
4151
|
overscan: 10,
|
|
3914
4152
|
});
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
4153
|
+
React.useEffect(() => {
|
|
4154
|
+
// this ensures the cache is cleared if the rowHeight changes
|
|
4155
|
+
if (props.rowHeight) {
|
|
4156
|
+
rowVirtualizer.measure();
|
|
4157
|
+
}
|
|
4158
|
+
}, [props.rowHeight, rowVirtualizer]);
|
|
4159
|
+
const { getVirtualItems, getTotalSize } = rowVirtualizer;
|
|
3918
4160
|
return {
|
|
3919
|
-
paddingTop,
|
|
3920
|
-
paddingBottom,
|
|
3921
4161
|
fetchMoreOnBottomReached,
|
|
3922
|
-
|
|
3923
|
-
|
|
4162
|
+
getTotalSize,
|
|
4163
|
+
getVirtualItems,
|
|
3924
4164
|
};
|
|
3925
4165
|
};
|
|
3926
4166
|
|
|
@@ -3931,19 +4171,23 @@ const useInfiniteScroll = (props) => {
|
|
|
3931
4171
|
* @returns {JSX.Element} Table component
|
|
3932
4172
|
*/
|
|
3933
4173
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3934
|
-
const Table = (
|
|
3935
|
-
var
|
|
4174
|
+
const Table = (_a) => {
|
|
4175
|
+
var _b, _c;
|
|
4176
|
+
var { rowHeight = 75 } = _a, props = __rest(_a, ["rowHeight"]);
|
|
3936
4177
|
//we need a reference to the scrolling element for logic down below
|
|
3937
4178
|
const tableContainerRef = React.useRef(null);
|
|
3938
4179
|
const [t] = useTranslation();
|
|
3939
|
-
const { fetchMoreOnBottomReached,
|
|
4180
|
+
const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize } = useInfiniteScroll({
|
|
3940
4181
|
pagination: props.pagination,
|
|
3941
4182
|
containerRef: tableContainerRef,
|
|
3942
4183
|
rowSize: props.getRowModel().rows.length || 0,
|
|
4184
|
+
rowHeight,
|
|
3943
4185
|
});
|
|
3944
4186
|
const hasResults = props.getRowModel().rows.length > 0;
|
|
3945
|
-
return (jsxRuntime.jsxs(reactComponents.Card, { className: `flex flex-col overflow-hidden ${props.className || ""}`, dataTestId: props.dataTestId, children: [(props.headerLeftActions || props.headerRightActions) && (jsxRuntime.jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsxRuntime.jsx("div", { className: "flex", children: props.headerLeftActions }), jsxRuntime.jsx("div", { className: "flex", children: props.headerRightActions })] })), jsxRuntime.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),
|
|
3946
|
-
|
|
4187
|
+
return (jsxRuntime.jsxs(reactComponents.Card, { className: `flex flex-col overflow-hidden ${props.className || ""}`, dataTestId: props.dataTestId, children: [(props.headerLeftActions || props.headerRightActions) && (jsxRuntime.jsxs("div", { className: "z-default flex justify-between gap-2 p-2", children: [jsxRuntime.jsx("div", { className: "flex", children: props.headerLeftActions }), jsxRuntime.jsx("div", { className: "flex", children: props.headerRightActions })] })), jsxRuntime.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: jsxRuntime.jsxs(reactTableBaseComponents.TableRoot, { style: {
|
|
4188
|
+
height: getTotalSize(),
|
|
4189
|
+
width: "100%",
|
|
4190
|
+
position: "relative",
|
|
3947
4191
|
}, children: [jsxRuntime.jsx(reactTableBaseComponents.Thead, { className: "z-default", children: props.getHeaderGroups().map(headerGroup => (jsxRuntime.jsx(reactTableBaseComponents.Tr, { className: "flex", children: headerGroup.headers.map(header => {
|
|
3948
4192
|
var _a, _b, _c, _d;
|
|
3949
4193
|
return (jsxRuntime.jsxs(reactTableBaseComponents.Th, { style: {
|
|
@@ -3952,25 +4196,28 @@ const Table = (props) => {
|
|
|
3952
4196
|
maxWidth: header.column.columnDef.maxSize,
|
|
3953
4197
|
}, className: "relative", children: [header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: `${header.column.getCanSort() ? "cursor-pointer select-none" : ""} flex items-center gap-2 py-2 overflow-hidden pr-3`,
|
|
3954
4198
|
onClick: header.column.getToggleSortingHandler(), children: [jsxRuntime.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) ? (jsxRuntime.jsx(reactComponents.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() ? (jsxRuntime.jsx(reactTableBaseComponents.SortIndicator, { sortingState: header.column.getIsSorted() })) : null] })), header.column.getCanResize() ? (jsxRuntime.jsx(reactTableBaseComponents.ResizeHandle, { isResizing: header.column.getIsResizing(), onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })) : null] }, header.id));
|
|
3955
|
-
}) }, headerGroup.id))) }), hasResults ? (jsxRuntime.
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
4199
|
+
}) }, headerGroup.id))) }), hasResults ? (jsxRuntime.jsx(reactTableBaseComponents.Tbody, { className: "text-sm font-normal", children: getVirtualItems().map((virtualRow, index) => {
|
|
4200
|
+
const row = props.getRowModel().rows[virtualRow.index];
|
|
4201
|
+
if (!row) {
|
|
4202
|
+
return null;
|
|
4203
|
+
}
|
|
4204
|
+
else {
|
|
4205
|
+
return (jsxRuntime.jsx(reactTableBaseComponents.Tr, { layout: "flex", style: {
|
|
4206
|
+
height: `${virtualRow.size}px`,
|
|
4207
|
+
transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`,
|
|
4208
|
+
}, 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 => {
|
|
4209
|
+
return (jsxRuntime.jsx(reactTableBaseComponents.Td, { key: cell.id,
|
|
4210
|
+
style: {
|
|
4211
|
+
width: cell.column.getSize(),
|
|
4212
|
+
minWidth: cell.column.columnDef.minSize,
|
|
4213
|
+
maxWidth: cell.column.columnDef.maxSize,
|
|
4214
|
+
}, children: jsxRuntime.jsx("div", { className: "grid h-full items-center", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }) }));
|
|
4215
|
+
}) }, row.id));
|
|
4216
|
+
}
|
|
4217
|
+
}) })) : (jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { className: "b-0", children: (props === null || props === void 0 ? void 0 : props.noDataMessage) ? (props.noDataMessage) : (jsxRuntime.jsx(reactComponents.EmptyState, { image: "ROAD_BLOCK", description: t("table.noResults"), className: "absolute inset-0", loading: props === null || props === void 0 ? void 0 : props.loading })) }) }) }))] }) }), jsxRuntime.jsxs("div", { className: "flex items-center p-2", children: [jsxRuntime.jsx("div", { className: "whitespace-nowrap text-xs font-medium text-neutral-600", children: t("table.pagination.full", {
|
|
3971
4218
|
count: props.getRowModel().rows.length,
|
|
3972
|
-
total: ((
|
|
3973
|
-
}) }), props.footerRightActions && jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })] })] }));
|
|
4219
|
+
total: ((_c = (_b = props.pagination) === null || _b === void 0 ? void 0 : _b.pageInfo) === null || _c === void 0 ? void 0 : _c.count) || 0,
|
|
4220
|
+
}) }), props.pagination.isLoading ? (jsxRuntime.jsx("span", { className: "ml-2", children: jsxRuntime.jsx(reactComponents.Spinner, { size: "small" }) })) : null, props.footerRightActions && jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: props.footerRightActions })] })] }));
|
|
3974
4221
|
};
|
|
3975
4222
|
|
|
3976
4223
|
function getDefaultExportFromCjs (x) {
|
|
@@ -8967,9 +9214,16 @@ const ColumnFilter = ({ columns, setColumnOrder, defaultColumnOrder, columnOrder
|
|
|
8967
9214
|
if (!columns) {
|
|
8968
9215
|
return null;
|
|
8969
9216
|
}
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
9217
|
+
const getColumnButtonText = () => {
|
|
9218
|
+
if (numberOfHiddenColumns > 1) {
|
|
9219
|
+
return t("table.columnFilters.hiddenColumnsCount", { count: numberOfHiddenColumns });
|
|
9220
|
+
}
|
|
9221
|
+
if (numberOfHiddenColumns === 1) {
|
|
9222
|
+
return t("table.columnFilters.hiddenColumnCount", { count: numberOfHiddenColumns });
|
|
9223
|
+
}
|
|
9224
|
+
return t("table.columnFilters.columns");
|
|
9225
|
+
};
|
|
9226
|
+
return (jsxRuntime.jsx(DndProvider, { backend: HTML5Backend, children: jsxRuntime.jsx(reactComponents.Tooltip, { label: t("table.columnFilters.tooltip"), placement: "bottom-start", children: jsxRuntime.jsxs(reactComponents.Popover, { placement: "bottom-start", children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: jsxRuntime.jsx(reactComponents.Button, { prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "ViewColumns", size: "small" }), color: "secondary", variant: "transparent", size: "small", children: jsxRuntime.jsx("span", { className: "hidden sm:block", children: getColumnButtonText() }) }) }), jsxRuntime.jsx(reactComponents.PopoverContent, { children: () => (jsxRuntime.jsxs(reactComponents.MenuList, { className: "relative max-h-[55vh] w-72 overflow-y-auto pr-4", children: [jsxRuntime.jsxs("div", { className: "mb-2 flex items-center justify-between", children: [jsxRuntime.jsx(reactComponents.Text, { subtle: true, size: "small", children: t("table.columnFilters.title") }), jsxRuntime.jsx(reactComponents.Button, { className: "p-0", color: "secondary", variant: "transparent", size: "small", onClick: () => resetHiddenColumns(), children: t("layout.actions.reset") })] }), jsxRuntime.jsx(ColumnFiltersDragAndDrop, { columns: sortedColumns, setColumnOrder: setColumnOrder, onUserEvent: onUserEvent })] })) })] }) }) }));
|
|
8973
9227
|
};
|
|
8974
9228
|
const ColumnFiltersDragAndDrop = ({ columns, setColumnOrder, onUserEvent, }) => {
|
|
8975
9229
|
const [localColumns, setLocalColumns] = React__namespace.useState(columns);
|