@tanstack/table-core 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.
- package/build/lib/core/row.d.ts +4 -2
- package/build/lib/core/row.js +14 -2
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/features/RowSelection.js +3 -3
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/index.esm.js +29 -17
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +29 -17
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/filterRowsUtils.js +6 -6
- package/build/lib/utils/filterRowsUtils.js.map +1 -1
- package/build/lib/utils/getCoreRowModel.js +1 -1
- package/build/lib/utils/getCoreRowModel.js.map +1 -1
- package/build/lib/utils/getGroupedRowModel.js +5 -5
- package/build/lib/utils/getGroupedRowModel.js.map +1 -1
- package/build/umd/index.development.js +29 -17
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core/row.ts +17 -3
- package/src/features/RowSelection.ts +3 -3
- package/src/utils/filterRowsUtils.ts +6 -14
- package/src/utils/getCoreRowModel.ts +1 -1
- package/src/utils/getGroupedRowModel.ts +4 -10
package/build/lib/index.mjs
CHANGED
|
@@ -1995,12 +1995,12 @@ const RowSelection = {
|
|
|
1995
1995
|
return isAllRowsSelected;
|
|
1996
1996
|
},
|
|
1997
1997
|
getIsAllPageRowsSelected: () => {
|
|
1998
|
-
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
1998
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
|
|
1999
1999
|
const {
|
|
2000
2000
|
rowSelection
|
|
2001
2001
|
} = table.getState();
|
|
2002
2002
|
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
2003
|
-
if (isAllPageRowsSelected && paginationFlatRows.some(row =>
|
|
2003
|
+
if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
|
|
2004
2004
|
isAllPageRowsSelected = false;
|
|
2005
2005
|
}
|
|
2006
2006
|
return isAllPageRowsSelected;
|
|
@@ -2012,7 +2012,7 @@ const RowSelection = {
|
|
|
2012
2012
|
},
|
|
2013
2013
|
getIsSomePageRowsSelected: () => {
|
|
2014
2014
|
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
2015
|
-
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
|
|
2015
|
+
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
|
|
2016
2016
|
},
|
|
2017
2017
|
getToggleAllRowsSelectedHandler: () => {
|
|
2018
2018
|
return e => {
|
|
@@ -2819,13 +2819,13 @@ function createCell(table, row, column, columnId) {
|
|
|
2819
2819
|
return cell;
|
|
2820
2820
|
}
|
|
2821
2821
|
|
|
2822
|
-
const createRow = (table, id, original, rowIndex, depth, subRows,
|
|
2822
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
2823
2823
|
let row = {
|
|
2824
2824
|
id,
|
|
2825
2825
|
index: rowIndex,
|
|
2826
2826
|
original,
|
|
2827
2827
|
depth,
|
|
2828
|
-
|
|
2828
|
+
parentId,
|
|
2829
2829
|
_valuesCache: {},
|
|
2830
2830
|
_uniqueValuesCache: {},
|
|
2831
2831
|
getValue: columnId => {
|
|
@@ -2860,6 +2860,18 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentRow) =>
|
|
|
2860
2860
|
},
|
|
2861
2861
|
subRows: subRows != null ? subRows : [],
|
|
2862
2862
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
2863
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
|
|
2864
|
+
getParentRows: () => {
|
|
2865
|
+
let parentRows = [];
|
|
2866
|
+
let currentRow = row;
|
|
2867
|
+
while (true) {
|
|
2868
|
+
const parentRow = currentRow.getParentRow();
|
|
2869
|
+
if (!parentRow) break;
|
|
2870
|
+
parentRows.push(parentRow);
|
|
2871
|
+
currentRow = parentRow;
|
|
2872
|
+
}
|
|
2873
|
+
return parentRows.reverse();
|
|
2874
|
+
},
|
|
2863
2875
|
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
2864
2876
|
return leafColumns.map(column => {
|
|
2865
2877
|
return createCell(table, row, column, column.id);
|
|
@@ -2969,7 +2981,7 @@ function getCoreRowModel() {
|
|
|
2969
2981
|
// }
|
|
2970
2982
|
|
|
2971
2983
|
// Make the row
|
|
2972
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow);
|
|
2984
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
|
|
2973
2985
|
|
|
2974
2986
|
// Keep track of every row in a flat array
|
|
2975
2987
|
rowModel.flatRows.push(row);
|
|
@@ -3016,7 +3028,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
3016
3028
|
const newFilteredFlatRows = [];
|
|
3017
3029
|
const newFilteredRowsById = {};
|
|
3018
3030
|
const maxDepth = (_table$options$maxLea = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea : 100;
|
|
3019
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3031
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3020
3032
|
if (depth === void 0) {
|
|
3021
3033
|
depth = 0;
|
|
3022
3034
|
}
|
|
@@ -3026,10 +3038,10 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
3026
3038
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3027
3039
|
var _row$subRows;
|
|
3028
3040
|
let row = rowsToFilter[i];
|
|
3029
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3041
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3030
3042
|
newRow.columnFilters = row.columnFilters;
|
|
3031
3043
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
|
|
3032
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3044
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3033
3045
|
row = newRow;
|
|
3034
3046
|
if (filterRow(row) && !newRow.subRows.length) {
|
|
3035
3047
|
rows.push(row);
|
|
@@ -3067,7 +3079,7 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
|
3067
3079
|
const maxDepth = (_table$options$maxLea2 = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea2 : 100;
|
|
3068
3080
|
|
|
3069
3081
|
// Filters top level and nested rows
|
|
3070
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3082
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3071
3083
|
if (depth === void 0) {
|
|
3072
3084
|
depth = 0;
|
|
3073
3085
|
}
|
|
@@ -3082,8 +3094,8 @@ function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
|
3082
3094
|
if (pass) {
|
|
3083
3095
|
var _row$subRows2;
|
|
3084
3096
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
|
|
3085
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3086
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3097
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3098
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3087
3099
|
row = newRow;
|
|
3088
3100
|
}
|
|
3089
3101
|
rows.push(row);
|
|
@@ -3394,7 +3406,7 @@ function getGroupedRowModel() {
|
|
|
3394
3406
|
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
3395
3407
|
|
|
3396
3408
|
// Recursively group the data
|
|
3397
|
-
const groupUpRecursively = function (rows, depth,
|
|
3409
|
+
const groupUpRecursively = function (rows, depth, parentId) {
|
|
3398
3410
|
if (depth === void 0) {
|
|
3399
3411
|
depth = 0;
|
|
3400
3412
|
}
|
|
@@ -3406,7 +3418,7 @@ function getGroupedRowModel() {
|
|
|
3406
3418
|
groupedFlatRows.push(row);
|
|
3407
3419
|
groupedRowsById[row.id] = row;
|
|
3408
3420
|
if (row.subRows) {
|
|
3409
|
-
row.subRows = groupUpRecursively(row.subRows, depth + 1, row);
|
|
3421
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
3410
3422
|
}
|
|
3411
3423
|
return row;
|
|
3412
3424
|
});
|
|
@@ -3423,11 +3435,11 @@ function getGroupedRowModel() {
|
|
|
3423
3435
|
id = parentId ? `${parentId}>${id}` : id;
|
|
3424
3436
|
|
|
3425
3437
|
// First, Recurse to group sub rows before aggregation
|
|
3426
|
-
const subRows = groupUpRecursively(groupedRows, depth + 1,
|
|
3438
|
+
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3427
3439
|
|
|
3428
3440
|
// Flatten the leaf rows of the rows in this group
|
|
3429
3441
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3430
|
-
const row = createRow(table, id, leafRows[0].original, index, depth, undefined,
|
|
3442
|
+
const row = createRow(table, id, leafRows[0].original, index, depth, undefined, parentId);
|
|
3431
3443
|
Object.assign(row, {
|
|
3432
3444
|
groupingColumnId: columnId,
|
|
3433
3445
|
groupingValue,
|
|
@@ -3474,7 +3486,7 @@ function getGroupedRowModel() {
|
|
|
3474
3486
|
});
|
|
3475
3487
|
return aggregatedGroupedRows;
|
|
3476
3488
|
};
|
|
3477
|
-
const groupedRows = groupUpRecursively(rowModel.rows, 0
|
|
3489
|
+
const groupedRows = groupUpRecursively(rowModel.rows, 0);
|
|
3478
3490
|
groupedRows.forEach(subRow => {
|
|
3479
3491
|
groupedFlatRows.push(subRow);
|
|
3480
3492
|
groupedRowsById[subRow.id] = subRow;
|