@tanstack/svelte-table 8.8.0 → 8.8.1
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.
|
@@ -2833,13 +2833,13 @@
|
|
|
2833
2833
|
return cell;
|
|
2834
2834
|
}
|
|
2835
2835
|
|
|
2836
|
-
const createRow = (table, id, original, rowIndex, depth, subRows,
|
|
2836
|
+
const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
2837
2837
|
let row = {
|
|
2838
2838
|
id,
|
|
2839
2839
|
index: rowIndex,
|
|
2840
2840
|
original,
|
|
2841
2841
|
depth,
|
|
2842
|
-
|
|
2842
|
+
parentId,
|
|
2843
2843
|
_valuesCache: {},
|
|
2844
2844
|
_uniqueValuesCache: {},
|
|
2845
2845
|
getValue: columnId => {
|
|
@@ -2874,6 +2874,18 @@
|
|
|
2874
2874
|
},
|
|
2875
2875
|
subRows: subRows != null ? subRows : [],
|
|
2876
2876
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
2877
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
|
|
2878
|
+
getParentRows: () => {
|
|
2879
|
+
let parentRows = [];
|
|
2880
|
+
let currentRow = row;
|
|
2881
|
+
while (true) {
|
|
2882
|
+
const parentRow = currentRow.getParentRow();
|
|
2883
|
+
if (!parentRow) break;
|
|
2884
|
+
parentRows.push(parentRow);
|
|
2885
|
+
currentRow = parentRow;
|
|
2886
|
+
}
|
|
2887
|
+
return parentRows.reverse();
|
|
2888
|
+
},
|
|
2877
2889
|
getAllCells: memo(() => [table.getAllLeafColumns()], leafColumns => {
|
|
2878
2890
|
return leafColumns.map(column => {
|
|
2879
2891
|
return createCell(table, row, column, column.id);
|
|
@@ -2983,7 +2995,7 @@
|
|
|
2983
2995
|
// }
|
|
2984
2996
|
|
|
2985
2997
|
// Make the row
|
|
2986
|
-
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow);
|
|
2998
|
+
const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, undefined, parentRow == null ? void 0 : parentRow.id);
|
|
2987
2999
|
|
|
2988
3000
|
// Keep track of every row in a flat array
|
|
2989
3001
|
rowModel.flatRows.push(row);
|
|
@@ -3030,7 +3042,7 @@
|
|
|
3030
3042
|
const newFilteredFlatRows = [];
|
|
3031
3043
|
const newFilteredRowsById = {};
|
|
3032
3044
|
const maxDepth = (_table$options$maxLea = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea : 100;
|
|
3033
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3045
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3034
3046
|
if (depth === void 0) {
|
|
3035
3047
|
depth = 0;
|
|
3036
3048
|
}
|
|
@@ -3040,10 +3052,10 @@
|
|
|
3040
3052
|
for (let i = 0; i < rowsToFilter.length; i++) {
|
|
3041
3053
|
var _row$subRows;
|
|
3042
3054
|
let row = rowsToFilter[i];
|
|
3043
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3055
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3044
3056
|
newRow.columnFilters = row.columnFilters;
|
|
3045
3057
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length && depth < maxDepth) {
|
|
3046
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3058
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3047
3059
|
row = newRow;
|
|
3048
3060
|
if (filterRow(row) && !newRow.subRows.length) {
|
|
3049
3061
|
rows.push(row);
|
|
@@ -3081,7 +3093,7 @@
|
|
|
3081
3093
|
const maxDepth = (_table$options$maxLea2 = table.options.maxLeafRowFilterDepth) != null ? _table$options$maxLea2 : 100;
|
|
3082
3094
|
|
|
3083
3095
|
// Filters top level and nested rows
|
|
3084
|
-
const recurseFilterRows = function (rowsToFilter, depth
|
|
3096
|
+
const recurseFilterRows = function (rowsToFilter, depth) {
|
|
3085
3097
|
if (depth === void 0) {
|
|
3086
3098
|
depth = 0;
|
|
3087
3099
|
}
|
|
@@ -3096,8 +3108,8 @@
|
|
|
3096
3108
|
if (pass) {
|
|
3097
3109
|
var _row$subRows2;
|
|
3098
3110
|
if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length && depth < maxDepth) {
|
|
3099
|
-
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined,
|
|
3100
|
-
newRow.subRows = recurseFilterRows(row.subRows, depth + 1
|
|
3111
|
+
const newRow = createRow(table, row.id, row.original, row.index, row.depth, undefined, row.parentId);
|
|
3112
|
+
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3101
3113
|
row = newRow;
|
|
3102
3114
|
}
|
|
3103
3115
|
rows.push(row);
|
|
@@ -3408,7 +3420,7 @@
|
|
|
3408
3420
|
// const nonGroupedRowsById: Record<RowId, Row> = {};
|
|
3409
3421
|
|
|
3410
3422
|
// Recursively group the data
|
|
3411
|
-
const groupUpRecursively = function (rows, depth,
|
|
3423
|
+
const groupUpRecursively = function (rows, depth, parentId) {
|
|
3412
3424
|
if (depth === void 0) {
|
|
3413
3425
|
depth = 0;
|
|
3414
3426
|
}
|
|
@@ -3420,7 +3432,7 @@
|
|
|
3420
3432
|
groupedFlatRows.push(row);
|
|
3421
3433
|
groupedRowsById[row.id] = row;
|
|
3422
3434
|
if (row.subRows) {
|
|
3423
|
-
row.subRows = groupUpRecursively(row.subRows, depth + 1, row);
|
|
3435
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
3424
3436
|
}
|
|
3425
3437
|
return row;
|
|
3426
3438
|
});
|
|
@@ -3437,11 +3449,11 @@
|
|
|
3437
3449
|
id = parentId ? `${parentId}>${id}` : id;
|
|
3438
3450
|
|
|
3439
3451
|
// First, Recurse to group sub rows before aggregation
|
|
3440
|
-
const subRows = groupUpRecursively(groupedRows, depth + 1,
|
|
3452
|
+
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3441
3453
|
|
|
3442
3454
|
// Flatten the leaf rows of the rows in this group
|
|
3443
3455
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|
|
3444
|
-
const row = createRow(table, id, leafRows[0].original, index, depth, undefined,
|
|
3456
|
+
const row = createRow(table, id, leafRows[0].original, index, depth, undefined, parentId);
|
|
3445
3457
|
Object.assign(row, {
|
|
3446
3458
|
groupingColumnId: columnId,
|
|
3447
3459
|
groupingValue,
|
|
@@ -3488,7 +3500,7 @@
|
|
|
3488
3500
|
});
|
|
3489
3501
|
return aggregatedGroupedRows;
|
|
3490
3502
|
};
|
|
3491
|
-
const groupedRows = groupUpRecursively(rowModel.rows, 0
|
|
3503
|
+
const groupedRows = groupUpRecursively(rowModel.rows, 0);
|
|
3492
3504
|
groupedRows.forEach(subRow => {
|
|
3493
3505
|
groupedFlatRows.push(subRow);
|
|
3494
3506
|
groupedRowsById[subRow.id] = subRow;
|