@tanstack/react-table 8.8.0 → 8.8.2
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.
|
@@ -2030,12 +2030,12 @@
|
|
|
2030
2030
|
return isAllRowsSelected;
|
|
2031
2031
|
},
|
|
2032
2032
|
getIsAllPageRowsSelected: () => {
|
|
2033
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
2033
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
|
|
2034
2034
|
const {
|
|
2035
2035
|
rowSelection
|
|
2036
2036
|
} = table.getState();
|
|
2037
2037
|
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2038
|
-
if (isAllPageRowsSelected && paginationFlatRows.some(row =>
|
|
2038
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
|
2039
2039
|
isAllPageRowsSelected = false;
|
|
2040
2040
|
}
|
|
2041
2041
|
return isAllPageRowsSelected;
|
|
@@ -2047,7 +2047,7 @@
|
|
|
2047
2047
|
},
|
|
2048
2048
|
getIsSomePageRowsSelected: () => {
|
|
2049
2049
|
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
2050
|
-
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
|
|
2050
|
+
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
|
|
2051
2051
|
},
|
|
2052
2052
|
getToggleAllRowsSelectedHandler: () => {
|
|
2053
2053
|
return e => {
|
|
@@ -2853,13 +2853,13 @@
|
|
|
2853
2853
|
return cell;
|
|
2854
2854
|
}
|
|
2855
2855
|
|
|
2856
|
-
const createRow = (table, id, original, rowIndex, depth, subRows,
|
|
2856
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
2857
2857
|
let row = {
|
|
2858
2858
|
id,
|
|
2859
2859
|
index: rowIndex,
|
|
2860
2860
|
original,
|
|
2861
2861
|
depth,
|
|
2862
|
-
|
|
2862
|
+
parentId,
|
|
2863
2863
|
_valuesCache: {},
|
|
2864
2864
|
_uniqueValuesCache: {},
|
|
2865
2865
|
getValue: columnId => {
|
|
@@ -2894,6 +2894,18 @@
|
|
|
2894
2894
|
},
|
|
2895
2895
|
subRows: subRows != null ? subRows : [],
|
|
2896
2896
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
2897
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
|
|
2898
|
+
getParentRows: () => {
|
|
2899
|
+
let parentRows = [];
|
|
2900
|
+
let currentRow = row;
|
|
2901
|
+
while (true) {
|
|
2902
|
+
const parentRow = currentRow.getParentRow();
|
|
2903
|
+
if (!parentRow) break;
|
|
2904
|
+
parentRows.push(parentRow);
|
|
2905
|
+
currentRow = parentRow;
|
|
2906
|
+
}
|
|
2907
|
+
return parentRows.reverse();
|
|
2908
|
+
},
|
|
2897
2909
|
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
2898
2910
|
return leafColumns.map(column => {
|
|
2899
2911
|
return createCell(table, row, column, column.id);
|
|
@@ -3003,7 +3015,7 @@
|
|
|
3003
3015
|
// }
|
|
3004
3016
|
|
|
3005
3017
|
// Make the row
|
|
3006
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow);
|
|
3018
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
|
|
3007
3019
|
|
|
3008
3020
|
// Keep track of every row in a flat array
|
|
3009
3021
|
rowModel.flatRows.push(row);
|
|
@@ -3050,7 +3062,7 @@
|
|
|
3050
3062
|
const newFilteredFlatRows = [];
|
|
3051
3063
|
const newFilteredRowsById = {};
|
|
3052
3064
|
const maxDepth = (_table$options$maxLea = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea : 100;
|
|
3053
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3065
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3054
3066
|
if (depth === void 0) {
|
|
3055
3067
|
depth = 0;
|
|
3056
3068
|
}
|
|
@@ -3060,10 +3072,10 @@
|
|
|
3060
3072
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3061
3073
|
var _row$subRows;
|
|
3062
3074
|
let row = rowsToFilter[i];
|
|
3063
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3075
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3064
3076
|
newRow.columnFilters = row.columnFilters;
|
|
3065
3077
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
|
|
3066
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3078
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3067
3079
|
row = newRow;
|
|
3068
3080
|
if (filterRow(row) && !newRow.subRows.length) {
|
|
3069
3081
|
rows.push(row);
|
|
@@ -3101,7 +3113,7 @@
|
|
|
3101
3113
|
const maxDepth = (_table$options$maxLea2 = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea2 : 100;
|
|
3102
3114
|
|
|
3103
3115
|
// Filters top level and nested rows
|
|
3104
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3116
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3105
3117
|
if (depth === void 0) {
|
|
3106
3118
|
depth = 0;
|
|
3107
3119
|
}
|
|
@@ -3116,8 +3128,8 @@
|
|
|
3116
3128
|
if (pass) {
|
|
3117
3129
|
var _row$subRows2;
|
|
3118
3130
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
|
|
3119
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3120
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3131
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3132
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3121
3133
|
row = newRow;
|
|
3122
3134
|
}
|
|
3123
3135
|
rows.push(row);
|
|
@@ -3428,7 +3440,7 @@
|
|
|
3428
3440
|
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
3429
3441
|
|
|
3430
3442
|
// Recursively group the data
|
|
3431
|
-
const groupUpRecursively = function (rows, depth,
|
|
3443
|
+
const groupUpRecursively = function (rows, depth, parentId) {
|
|
3432
3444
|
if (depth === void 0) {
|
|
3433
3445
|
depth = 0;
|
|
3434
3446
|
}
|
|
@@ -3440,7 +3452,7 @@
|
|
|
3440
3452
|
groupedFlatRows.push(row);
|
|
3441
3453
|
groupedRowsById[row.id] = row;
|
|
3442
3454
|
if (row.subRows) {
|
|
3443
|
-
row.subRows = groupUpRecursively(row.subRows, depth + 1, row);
|
|
3455
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
3444
3456
|
}
|
|
3445
3457
|
return row;
|
|
3446
3458
|
});
|
|
@@ -3457,11 +3469,11 @@
|
|
|
3457
3469
|
id = parentId ? `${parentId}>${id}` : id;
|
|
3458
3470
|
|
|
3459
3471
|
// First, Recurse to group sub rows before aggregation
|
|
3460
|
-
const subRows = groupUpRecursively(groupedRows, depth + 1,
|
|
3472
|
+
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3461
3473
|
|
|
3462
3474
|
// Flatten the leaf rows of the rows in this group
|
|
3463
3475
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3464
|
-
const row = createRow(table, id, leafRows[0].original, index, depth, undefined,
|
|
3476
|
+
const row = createRow(table, id, leafRows[0].original, index, depth, undefined, parentId);
|
|
3465
3477
|
Object.assign(row, {
|
|
3466
3478
|
groupingColumnId: columnId,
|
|
3467
3479
|
groupingValue,
|
|
@@ -3508,7 +3520,7 @@
|
|
|
3508
3520
|
});
|
|
3509
3521
|
return aggregatedGroupedRows;
|
|
3510
3522
|
};
|
|
3511
|
-
const groupedRows = groupUpRecursively(rowModel.rows, 0
|
|
3523
|
+
const groupedRows = groupUpRecursively(rowModel.rows, 0);
|
|
3512
3524
|
groupedRows.forEach(subRow => {
|
|
3513
3525
|
groupedFlatRows.push(subRow);
|
|
3514
3526
|
groupedRowsById[subRow.id] = subRow;
|