@tanstack/table-core 8.0.0-alpha.21 → 8.0.0-alpha.24
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/cjs/aggregationTypes.js +21 -19
- package/build/cjs/aggregationTypes.js.map +1 -1
- package/build/cjs/core.js +8 -8
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Expanding.js +1 -8
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +1 -1
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Pinning.js +6 -0
- package/build/cjs/features/Pinning.js.map +1 -1
- package/build/cjs/features/RowSelection.js +3 -3
- package/build/cjs/features/RowSelection.js.map +1 -1
- package/build/cjs/utils/columnFilterRowsFn.js +20 -78
- package/build/cjs/utils/columnFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +100 -0
- package/build/cjs/utils/filterRowsUtils.js.map +1 -0
- package/build/cjs/utils/globalFilterRowsFn.js +10 -62
- package/build/cjs/utils/globalFilterRowsFn.js.map +1 -1
- package/build/cjs/utils/groupRowsFn.js +15 -15
- package/build/cjs/utils/groupRowsFn.js.map +1 -1
- package/build/cjs/utils/sortRowsFn.js +1 -1
- package/build/cjs/utils/sortRowsFn.js.map +1 -1
- package/build/esm/index.js +163 -193
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +305 -272
- package/build/types/aggregationTypes.d.ts +9 -9
- package/build/types/core.d.ts +1 -1
- package/build/types/features/Filters.d.ts +1 -1
- package/build/types/features/Grouping.d.ts +1 -1
- package/build/types/features/Pinning.d.ts +1 -0
- package/build/types/utils/filterRowsUtils.d.ts +3 -0
- package/build/types/utils/sortRowsQuicksortFn.d.ts +11 -0
- package/build/umd/index.development.js +163 -193
- 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/aggregationTypes.ts +23 -19
- package/src/core.tsx +3 -5
- package/src/features/Expanding.ts +2 -10
- package/src/features/Filters.ts +2 -2
- package/src/features/Grouping.ts +3 -4
- package/src/features/Pinning.ts +7 -0
- package/src/features/RowSelection.ts +1 -3
- package/src/utils/columnFilterRowsFn.ts +12 -73
- package/src/utils/filterRowsUtils.ts +107 -0
- package/src/utils/globalFilterRowsFn.ts +10 -66
- package/src/utils/groupRowsFn.ts +14 -16
- package/src/utils/sortRowsFn.ts +6 -8
- package/src/utils/sortRowsQuicksortFn.ts +174 -0
|
@@ -10,13 +10,13 @@ export declare const aggregationTypes: {
|
|
|
10
10
|
count: typeof count;
|
|
11
11
|
};
|
|
12
12
|
export declare type BuiltInAggregationType = keyof typeof aggregationTypes;
|
|
13
|
-
declare function sum(
|
|
14
|
-
declare function min(
|
|
15
|
-
declare function max(
|
|
16
|
-
declare function extent(
|
|
17
|
-
declare function mean(
|
|
18
|
-
declare function median(
|
|
19
|
-
declare function unique<T>(
|
|
20
|
-
declare function uniqueCount(
|
|
21
|
-
declare function count(
|
|
13
|
+
declare function sum(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number;
|
|
14
|
+
declare function min(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number | undefined;
|
|
15
|
+
declare function max(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): number | undefined;
|
|
16
|
+
declare function extent(_getLeafValues: () => unknown[], getChildValues: () => unknown[]): (number | undefined)[];
|
|
17
|
+
declare function mean(getLeafValues: () => unknown[]): number | undefined;
|
|
18
|
+
declare function median(getLeafValues: () => unknown[]): number | undefined;
|
|
19
|
+
declare function unique<T>(getLeafValues: () => T[]): T[];
|
|
20
|
+
declare function uniqueCount(getLeafValues: () => unknown[]): number;
|
|
21
|
+
declare function count(getLeafValues: () => unknown[]): number;
|
|
22
22
|
export {};
|
package/build/types/core.d.ts
CHANGED
|
@@ -58,8 +58,8 @@ export declare type CoreRow<TGenerics extends PartialGenerics> = {
|
|
|
58
58
|
original?: TGenerics['Row'];
|
|
59
59
|
depth: number;
|
|
60
60
|
values: RowValues;
|
|
61
|
-
leafRows: Row<TGenerics>[];
|
|
62
61
|
subRows: Row<TGenerics>[];
|
|
62
|
+
getLeafRows: () => Row<TGenerics>[];
|
|
63
63
|
getRowProps: PropGetter<RowProps>;
|
|
64
64
|
originalSubRows?: TGenerics['Row'][];
|
|
65
65
|
getAllCells: () => Cell<TGenerics>[];
|
|
@@ -44,7 +44,7 @@ export declare type FiltersColumn<TGenerics extends PartialGenerics> = {
|
|
|
44
44
|
getPreFilteredMinMaxValues: () => [any, any];
|
|
45
45
|
};
|
|
46
46
|
export declare type FiltersOptions<TGenerics extends PartialGenerics> = {
|
|
47
|
-
|
|
47
|
+
filterFromLeafRows?: boolean;
|
|
48
48
|
filterTypes?: TGenerics['FilterFns'];
|
|
49
49
|
enableFilters?: boolean;
|
|
50
50
|
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>;
|
|
@@ -3,7 +3,7 @@ import { BuiltInAggregationType } from '../aggregationTypes';
|
|
|
3
3
|
import { Cell, Column, Getter, OnChangeFn, PropGetterValue, TableInstance, Row, Updater, PartialGenerics, Renderable, UseRenderer } from '../types';
|
|
4
4
|
import { Overwrite } from '../utils';
|
|
5
5
|
export declare type GroupingState = string[];
|
|
6
|
-
export declare type AggregationFn<TGenerics extends PartialGenerics> = (
|
|
6
|
+
export declare type AggregationFn<TGenerics extends PartialGenerics> = (getLeafValues: () => TGenerics['Row'][], getChildValues: () => TGenerics['Row'][]) => any;
|
|
7
7
|
export declare type CustomAggregationTypes<TGenerics extends PartialGenerics> = Record<string, AggregationFn<TGenerics>>;
|
|
8
8
|
export declare type AggregationType<TGenerics extends PartialGenerics> = 'auto' | BuiltInAggregationType | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
|
|
9
9
|
export declare type GroupingTableState = {
|
|
@@ -31,6 +31,7 @@ export declare type ColumnPinningInstance<TGenerics extends PartialGenerics> = {
|
|
|
31
31
|
getColumnCanPin: (columnId: string) => boolean;
|
|
32
32
|
getColumnIsPinned: (columnId: string) => ColumnPinningPosition;
|
|
33
33
|
getColumnPinnedIndex: (columnId: string) => number;
|
|
34
|
+
getIsSomeColumnsPinned: () => boolean;
|
|
34
35
|
};
|
|
35
36
|
export declare const Pinning: {
|
|
36
37
|
getInitialState: () => ColumnPinningTableState;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AnyGenerics, Row, RowModel, TableInstance } from '../types';
|
|
2
|
+
export declare function filterRowModelFromLeafs<TGenerics extends AnyGenerics>(rowsToFilter: Row<TGenerics>[], filterRows: (rowsToFilter: Row<TGenerics>[], depth: number) => Row<TGenerics>[], instance: TableInstance<TGenerics>): RowModel<TGenerics>;
|
|
3
|
+
export declare function filterRowModelFromRoot<TGenerics extends AnyGenerics>(rowsToFilter: Row<TGenerics>[], filterRows: (rowsToFilter: Row<TGenerics>[], depth: number) => Row<TGenerics>[], instance: TableInstance<TGenerics>): RowModel<TGenerics>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TableInstance, Row, RowModel, AnyGenerics } from '../types';
|
|
2
|
+
export declare function sortRowsFn<TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>, rowModel: RowModel<TGenerics>): RowModel<TGenerics>;
|
|
3
|
+
declare type Sorter<TGenerics extends AnyGenerics> = {
|
|
4
|
+
id: string;
|
|
5
|
+
compare: (a: Row<TGenerics>, b: Row<TGenerics>) => number;
|
|
6
|
+
desc?: boolean;
|
|
7
|
+
sortUndefined?: false | -1 | 1;
|
|
8
|
+
invertSorting?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function quicksort<TGenerics extends AnyGenerics>(rows: Row<TGenerics>[], sorters: Sorter<TGenerics>[]): Row<TGenerics>[];
|
|
11
|
+
export {};
|
|
@@ -388,18 +388,18 @@
|
|
|
388
388
|
count: count
|
|
389
389
|
};
|
|
390
390
|
|
|
391
|
-
function sum(
|
|
391
|
+
function sum(_getLeafValues, getChildValues) {
|
|
392
392
|
// It's faster to just add the aggregations together instead of
|
|
393
393
|
// process leaf nodes individually
|
|
394
|
-
return
|
|
394
|
+
return getChildValues().reduce(function (sum, next) {
|
|
395
395
|
return sum + (typeof next === 'number' ? next : 0);
|
|
396
396
|
}, 0);
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
function min(
|
|
399
|
+
function min(_getLeafValues, getChildValues) {
|
|
400
400
|
var min;
|
|
401
401
|
|
|
402
|
-
for (var _iterator = _createForOfIteratorHelperLoose(
|
|
402
|
+
for (var _iterator = _createForOfIteratorHelperLoose(getChildValues()), _step; !(_step = _iterator()).done;) {
|
|
403
403
|
var value = _step.value;
|
|
404
404
|
|
|
405
405
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
@@ -410,10 +410,10 @@
|
|
|
410
410
|
return min;
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
function max(
|
|
413
|
+
function max(_getLeafValues, getChildValues) {
|
|
414
414
|
var max;
|
|
415
415
|
|
|
416
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
416
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(getChildValues()), _step2; !(_step2 = _iterator2()).done;) {
|
|
417
417
|
var value = _step2.value;
|
|
418
418
|
|
|
419
419
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
@@ -424,11 +424,11 @@
|
|
|
424
424
|
return max;
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
function extent(
|
|
427
|
+
function extent(_getLeafValues, getChildValues) {
|
|
428
428
|
var min;
|
|
429
429
|
var max;
|
|
430
430
|
|
|
431
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
431
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(getChildValues()), _step3; !(_step3 = _iterator3()).done;) {
|
|
432
432
|
var value = _step3.value;
|
|
433
433
|
|
|
434
434
|
if (value != null) {
|
|
@@ -444,11 +444,11 @@
|
|
|
444
444
|
return [min, max];
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
function mean(
|
|
447
|
+
function mean(getLeafValues) {
|
|
448
448
|
var count = 0;
|
|
449
449
|
var sum = 0;
|
|
450
450
|
|
|
451
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(
|
|
451
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(getLeafValues()), _step4; !(_step4 = _iterator4()).done;) {
|
|
452
452
|
var value = _step4.value;
|
|
453
453
|
|
|
454
454
|
if (value != null && (value = +value) >= value) {
|
|
@@ -460,14 +460,16 @@
|
|
|
460
460
|
return;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
function median(
|
|
464
|
-
|
|
463
|
+
function median(getLeafValues) {
|
|
464
|
+
var leafValues = getLeafValues();
|
|
465
|
+
|
|
466
|
+
if (!leafValues.length) {
|
|
465
467
|
return;
|
|
466
468
|
}
|
|
467
469
|
|
|
468
470
|
var min = 0;
|
|
469
471
|
var max = 0;
|
|
470
|
-
|
|
472
|
+
leafValues.forEach(function (value) {
|
|
471
473
|
if (typeof value === 'number') {
|
|
472
474
|
min = Math.min(min, value);
|
|
473
475
|
max = Math.max(max, value);
|
|
@@ -476,16 +478,16 @@
|
|
|
476
478
|
return (min + max) / 2;
|
|
477
479
|
}
|
|
478
480
|
|
|
479
|
-
function unique(
|
|
480
|
-
return Array.from(new Set(
|
|
481
|
+
function unique(getLeafValues) {
|
|
482
|
+
return Array.from(new Set(getLeafValues()).values());
|
|
481
483
|
}
|
|
482
484
|
|
|
483
|
-
function uniqueCount(
|
|
484
|
-
return new Set(
|
|
485
|
+
function uniqueCount(getLeafValues) {
|
|
486
|
+
return new Set(getLeafValues()).size;
|
|
485
487
|
}
|
|
486
488
|
|
|
487
|
-
function count(
|
|
488
|
-
return
|
|
489
|
+
function count(getLeafValues) {
|
|
490
|
+
return getLeafValues().length;
|
|
489
491
|
}
|
|
490
492
|
|
|
491
493
|
//
|
|
@@ -568,7 +570,7 @@
|
|
|
568
570
|
throw new Error();
|
|
569
571
|
}
|
|
570
572
|
|
|
571
|
-
return isFunction(column.aggregationType) ? column.aggregationType : column.aggregationType === 'auto' ? instance.
|
|
573
|
+
return isFunction(column.aggregationType) ? column.aggregationType : column.aggregationType === 'auto' ? instance.getColumnAutoAggregationFn(columnId) : (_ref = userAggregationTypes == null ? void 0 : userAggregationTypes[column.aggregationType]) != null ? _ref : aggregationTypes[column.aggregationType];
|
|
572
574
|
},
|
|
573
575
|
setGrouping: function setGrouping(updater) {
|
|
574
576
|
return instance.options.onGroupingChange == null ? void 0 : instance.options.onGroupingChange(updater, functionalUpdate(updater, instance.getState().grouping));
|
|
@@ -899,6 +901,12 @@
|
|
|
899
901
|
|
|
900
902
|
var position = instance.getColumnIsPinned(columnId);
|
|
901
903
|
return position ? (_instance$getState$co2 = (_instance$getState$co3 = instance.getState().columnPinning) == null ? void 0 : (_instance$getState$co4 = _instance$getState$co3[position]) == null ? void 0 : _instance$getState$co4.indexOf(columnId)) != null ? _instance$getState$co2 : -1 : 0;
|
|
904
|
+
},
|
|
905
|
+
getIsSomeColumnsPinned: function getIsSomeColumnsPinned() {
|
|
906
|
+
var _instance$getState$co5 = instance.getState().columnPinning,
|
|
907
|
+
left = _instance$getState$co5.left,
|
|
908
|
+
right = _instance$getState$co5.right;
|
|
909
|
+
return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
|
|
902
910
|
}
|
|
903
911
|
};
|
|
904
912
|
}
|
|
@@ -1983,7 +1991,7 @@
|
|
|
1983
1991
|
onColumnFiltersChange: makeStateUpdater('columnFilters', instance),
|
|
1984
1992
|
onGlobalFilterChange: makeStateUpdater('globalFilter', instance),
|
|
1985
1993
|
autoResetColumnFilters: true,
|
|
1986
|
-
|
|
1994
|
+
filterFromLeafRows: true,
|
|
1987
1995
|
autoResetGlobalFilter: true,
|
|
1988
1996
|
globalFilterType: 'auto',
|
|
1989
1997
|
getColumnCanGlobalFilterFn: function getColumnCanGlobalFilterFn(column) {
|
|
@@ -2970,14 +2978,7 @@
|
|
|
2970
2978
|
return row.subRows && !!row.subRows.length;
|
|
2971
2979
|
},
|
|
2972
2980
|
getToggleExpandedProps: function getToggleExpandedProps(userProps) {
|
|
2973
|
-
|
|
2974
|
-
title: 'Toggle Row Expanded',
|
|
2975
|
-
onClick: function onClick(e) {
|
|
2976
|
-
e.stopPropagation();
|
|
2977
|
-
instance.toggleRowExpanded(row.id);
|
|
2978
|
-
}
|
|
2979
|
-
};
|
|
2980
|
-
return propGetter(initialProps, userProps);
|
|
2981
|
+
return instance.getToggleExpandedProps(row.id, userProps);
|
|
2981
2982
|
}
|
|
2982
2983
|
};
|
|
2983
2984
|
}
|
|
@@ -3204,10 +3205,10 @@
|
|
|
3204
3205
|
},
|
|
3205
3206
|
toggleAllRowsSelected: function toggleAllRowsSelected(value) {
|
|
3206
3207
|
instance.setRowSelection(function (old) {
|
|
3207
|
-
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
|
|
3208
|
-
|
|
3208
|
+
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
|
|
3209
|
+
|
|
3210
|
+
var rowSelection = _extends({}, old);
|
|
3209
3211
|
|
|
3210
|
-
var rowSelection = Object.assign({}, old);
|
|
3211
3212
|
var preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
|
|
3212
3213
|
// All of the rows are flat already, so it wouldn't be worth it
|
|
3213
3214
|
|
|
@@ -3949,7 +3950,11 @@
|
|
|
3949
3950
|
depth: depth,
|
|
3950
3951
|
values: values,
|
|
3951
3952
|
subRows: [],
|
|
3952
|
-
|
|
3953
|
+
getLeafRows: function getLeafRows() {
|
|
3954
|
+
return flattenBy(row.subRows, function (d) {
|
|
3955
|
+
return d.subRows;
|
|
3956
|
+
});
|
|
3957
|
+
},
|
|
3953
3958
|
getRowProps: function getRowProps(userProps) {
|
|
3954
3959
|
return instance.getRowProps(row.id, userProps);
|
|
3955
3960
|
},
|
|
@@ -4043,13 +4048,9 @@
|
|
|
4043
4048
|
|
|
4044
4049
|
for (var _i = 0; _i < row.originalSubRows.length; _i++) {
|
|
4045
4050
|
accessRow(row.originalSubRows[_i], _i, depth + 1, subRows, row);
|
|
4046
|
-
}
|
|
4047
|
-
|
|
4051
|
+
}
|
|
4048
4052
|
|
|
4049
4053
|
row.subRows = subRows;
|
|
4050
|
-
row.leafRows = flattenBy(subRows, function (d) {
|
|
4051
|
-
return d.leafRows;
|
|
4052
|
-
});
|
|
4053
4054
|
}
|
|
4054
4055
|
}
|
|
4055
4056
|
};
|
|
@@ -4071,9 +4072,9 @@
|
|
|
4071
4072
|
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugTable;
|
|
4072
4073
|
},
|
|
4073
4074
|
onChange: function onChange() {
|
|
4074
|
-
instance._notifyRowSelectionReset();
|
|
4075
|
-
|
|
4076
4075
|
instance._notifyFiltersReset();
|
|
4076
|
+
|
|
4077
|
+
instance._notifyRowSelectionReset();
|
|
4077
4078
|
}
|
|
4078
4079
|
}),
|
|
4079
4080
|
// The final calls start at the bottom of the model,
|
|
@@ -4235,126 +4236,147 @@
|
|
|
4235
4236
|
};
|
|
4236
4237
|
}
|
|
4237
4238
|
|
|
4238
|
-
function
|
|
4239
|
-
var columnFilters = instance.getState().columnFilters;
|
|
4239
|
+
function filterRowModelFromLeafs(rowsToFilter, filterRows, instance) {
|
|
4240
4240
|
var newFilteredFlatRows = [];
|
|
4241
4241
|
var newFilteredRowsById = {};
|
|
4242
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
4243
4242
|
|
|
4244
|
-
var
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
// Find the columnFilters column
|
|
4249
|
-
var column = instance.getColumn(columnId);
|
|
4243
|
+
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4244
|
+
if (depth === void 0) {
|
|
4245
|
+
depth = 0;
|
|
4246
|
+
}
|
|
4250
4247
|
|
|
4251
|
-
|
|
4252
|
-
{
|
|
4253
|
-
console.warn("Table: Could not find a column with id: " + columnId);
|
|
4254
|
-
}
|
|
4248
|
+
rowsToFilter = rowsToFilter.slice(); // Filter from children up first
|
|
4255
4249
|
|
|
4256
|
-
|
|
4257
|
-
|
|
4250
|
+
for (var i = 0; i < rowsToFilter.length; i++) {
|
|
4251
|
+
var _row$subRows;
|
|
4258
4252
|
|
|
4259
|
-
|
|
4260
|
-
var preFilteredRows = [].concat(rowsToFilter);
|
|
4253
|
+
var row = rowsToFilter[i];
|
|
4261
4254
|
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
};
|
|
4255
|
+
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4256
|
+
continue;
|
|
4265
4257
|
}
|
|
4266
4258
|
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
if (!filterFn) {
|
|
4270
|
-
{
|
|
4271
|
-
console.warn("Could not find a valid 'column.filterType' for column with the ID: " + column.id + ".");
|
|
4272
|
-
}
|
|
4259
|
+
rowsToFilter[i] = instance.createRow(row.id, row.original, row.index, row.depth, row.values);
|
|
4260
|
+
rowsToFilter[i].subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
4273
4261
|
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4262
|
+
if (!rowsToFilter[i].subRows.length) {
|
|
4263
|
+
rowsToFilter.splice(i, 1);
|
|
4264
|
+
i--;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4277
4267
|
|
|
4268
|
+
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4278
4269
|
|
|
4279
|
-
|
|
4270
|
+
rowsToFilter.forEach(function (row) {
|
|
4271
|
+
newFilteredFlatRows.push(row);
|
|
4272
|
+
newFilteredRowsById[row.id] = row;
|
|
4280
4273
|
});
|
|
4281
4274
|
return rowsToFilter;
|
|
4282
4275
|
};
|
|
4283
4276
|
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4295
|
-
return true;
|
|
4296
|
-
}
|
|
4297
|
-
|
|
4298
|
-
row.subRows = _recurseFilterRows(row.subRows, depth + 1);
|
|
4299
|
-
return row.subRows.length;
|
|
4300
|
-
});
|
|
4301
|
-
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4302
|
-
|
|
4303
|
-
rowsToFilter.forEach(function (row) {
|
|
4304
|
-
newFilteredFlatRows.push(row);
|
|
4305
|
-
newFilteredRowsById[row.id] = row;
|
|
4306
|
-
});
|
|
4307
|
-
return rowsToFilter;
|
|
4308
|
-
};
|
|
4309
|
-
|
|
4310
|
-
return {
|
|
4311
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
4312
|
-
flatRows: newFilteredFlatRows,
|
|
4313
|
-
rowsById: newFilteredRowsById
|
|
4314
|
-
};
|
|
4315
|
-
} // Filters top level and nested rows
|
|
4316
|
-
|
|
4277
|
+
return {
|
|
4278
|
+
rows: recurseFilterRows(rowsToFilter),
|
|
4279
|
+
flatRows: newFilteredFlatRows,
|
|
4280
|
+
rowsById: newFilteredRowsById
|
|
4281
|
+
};
|
|
4282
|
+
}
|
|
4283
|
+
function filterRowModelFromRoot(rowsToFilter, filterRows, instance) {
|
|
4284
|
+
var newFilteredFlatRows = [];
|
|
4285
|
+
var newFilteredRowsById = {}; // Filters top level and nested rows
|
|
4317
4286
|
|
|
4318
4287
|
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4319
4288
|
if (depth === void 0) {
|
|
4320
4289
|
depth = 0;
|
|
4321
4290
|
}
|
|
4322
4291
|
|
|
4323
|
-
// Filter from parents downward
|
|
4292
|
+
// Filter from parents downward first
|
|
4324
4293
|
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4325
|
-
// We technically could do this recursively in the above loop,
|
|
4326
|
-
// but that would severely hinder the API for the user, since they
|
|
4327
|
-
// would be required to do that recursion in some scenarios
|
|
4328
4294
|
|
|
4329
|
-
rowsToFilter.
|
|
4295
|
+
for (var i = 0; i < rowsToFilter.length; i++) {
|
|
4296
|
+
var _row$subRows2;
|
|
4297
|
+
|
|
4298
|
+
var row = rowsToFilter[i];
|
|
4330
4299
|
newFilteredFlatRows.push(row);
|
|
4331
4300
|
newFilteredRowsById[row.id] = row;
|
|
4332
4301
|
|
|
4333
|
-
if (!
|
|
4334
|
-
|
|
4302
|
+
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
4303
|
+
rowsToFilter.splice(i, 1);
|
|
4304
|
+
i--;
|
|
4305
|
+
continue;
|
|
4306
|
+
}
|
|
4335
4307
|
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4308
|
+
rowsToFilter[i] = instance.createRow(row.id, row.original, row.index, row.depth, row.values);
|
|
4309
|
+
rowsToFilter[i].subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
4310
|
+
}
|
|
4339
4311
|
|
|
4340
|
-
row.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
4341
|
-
}
|
|
4342
|
-
});
|
|
4343
4312
|
return rowsToFilter;
|
|
4344
4313
|
};
|
|
4345
4314
|
|
|
4346
4315
|
return {
|
|
4347
|
-
rows: recurseFilterRows(
|
|
4316
|
+
rows: recurseFilterRows(rowsToFilter),
|
|
4348
4317
|
flatRows: newFilteredFlatRows,
|
|
4349
4318
|
rowsById: newFilteredRowsById
|
|
4350
4319
|
};
|
|
4351
4320
|
}
|
|
4352
4321
|
|
|
4322
|
+
function columnFilterRowsFn(instance, rowModel) {
|
|
4323
|
+
var columnFilters = instance.getState().columnFilters;
|
|
4324
|
+
var filterFromLeafRows = instance.options.filterFromLeafRows;
|
|
4325
|
+
|
|
4326
|
+
var filterRows = function filterRows(rowsToFilter, depth) {
|
|
4327
|
+
for (var i = 0; i < columnFilters.length; i++) {
|
|
4328
|
+
var _columnFilters$i = columnFilters[i],
|
|
4329
|
+
columnId = _columnFilters$i.id,
|
|
4330
|
+
filterValue = _columnFilters$i.value; // Find the columnFilters column
|
|
4331
|
+
|
|
4332
|
+
var column = instance.getColumn(columnId);
|
|
4333
|
+
|
|
4334
|
+
if (!column) {
|
|
4335
|
+
{
|
|
4336
|
+
console.warn("Table: Could not find a column with id: " + columnId);
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
throw new Error();
|
|
4340
|
+
}
|
|
4341
|
+
|
|
4342
|
+
if (depth === 0) {
|
|
4343
|
+
(function () {
|
|
4344
|
+
var preFilteredRows = [].concat(rowsToFilter);
|
|
4345
|
+
|
|
4346
|
+
column.getPreFilteredRows = function () {
|
|
4347
|
+
return preFilteredRows;
|
|
4348
|
+
};
|
|
4349
|
+
})();
|
|
4350
|
+
}
|
|
4351
|
+
|
|
4352
|
+
var filterFn = instance.getColumnFilterFn(column.id);
|
|
4353
|
+
|
|
4354
|
+
if (!filterFn) {
|
|
4355
|
+
{
|
|
4356
|
+
console.warn("Could not find a valid 'column.filterType' for column with the ID: " + column.id + ".");
|
|
4357
|
+
}
|
|
4358
|
+
|
|
4359
|
+
continue;
|
|
4360
|
+
} // Pass the rows, id, filterValue and column to the filterFn
|
|
4361
|
+
// to get the filtered rows back
|
|
4362
|
+
|
|
4363
|
+
|
|
4364
|
+
rowsToFilter = filterFn(rowsToFilter, [columnId], filterValue);
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
return rowsToFilter;
|
|
4368
|
+
};
|
|
4369
|
+
|
|
4370
|
+
if (filterFromLeafRows) {
|
|
4371
|
+
return filterRowModelFromLeafs(rowModel.rows, filterRows, instance);
|
|
4372
|
+
}
|
|
4373
|
+
|
|
4374
|
+
return filterRowModelFromRoot(rowModel.rows, filterRows, instance);
|
|
4375
|
+
}
|
|
4376
|
+
|
|
4353
4377
|
function globalFilterRowsFn(instance, rowModel) {
|
|
4354
4378
|
var globalFilter = instance.getState().globalFilter;
|
|
4355
|
-
var
|
|
4356
|
-
var newFilteredRowsById = {};
|
|
4357
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
4379
|
+
var filterFromLeafRows = instance.options.filterFromLeafRows;
|
|
4358
4380
|
var filterFn = instance.getGlobalFilterFn();
|
|
4359
4381
|
|
|
4360
4382
|
if (!filterFn) {
|
|
@@ -4372,67 +4394,15 @@
|
|
|
4372
4394
|
return d.id;
|
|
4373
4395
|
});
|
|
4374
4396
|
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
// Filter from children up
|
|
4379
|
-
rowsToFilter = rowsToFilter.filter(function (row) {
|
|
4380
|
-
var _row$subRows;
|
|
4381
|
-
|
|
4382
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4383
|
-
return true;
|
|
4384
|
-
}
|
|
4385
|
-
|
|
4386
|
-
row.subRows = _recurseFilterRows(row.subRows);
|
|
4387
|
-
return row.subRows.length;
|
|
4388
|
-
});
|
|
4389
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
4390
|
-
|
|
4391
|
-
rowsToFilter.forEach(function (row) {
|
|
4392
|
-
newFilteredFlatRows.push(row);
|
|
4393
|
-
newFilteredRowsById[row.id] = row;
|
|
4394
|
-
});
|
|
4395
|
-
return rowsToFilter;
|
|
4396
|
-
};
|
|
4397
|
-
|
|
4398
|
-
return {
|
|
4399
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
4400
|
-
flatRows: newFilteredFlatRows,
|
|
4401
|
-
rowsById: newFilteredRowsById
|
|
4402
|
-
};
|
|
4403
|
-
} // Filters top level and nested rows
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4407
|
-
|
|
4408
|
-
// Filter from parents downward
|
|
4409
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
4410
|
-
// We technically could do this recursively in the above loop,
|
|
4411
|
-
// but that would severely hinder the API for the user, since they
|
|
4412
|
-
// would be required to do that recursion in some scenarios
|
|
4413
|
-
|
|
4414
|
-
rowsToFilter.forEach(function (row) {
|
|
4415
|
-
newFilteredFlatRows.push(row);
|
|
4416
|
-
newFilteredRowsById[row.id] = row;
|
|
4417
|
-
|
|
4418
|
-
if (!filterFromChildrenUp) {
|
|
4419
|
-
var _row$subRows2;
|
|
4420
|
-
|
|
4421
|
-
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
4422
|
-
return;
|
|
4423
|
-
}
|
|
4424
|
-
|
|
4425
|
-
row.subRows = recurseFilterRows(row.subRows);
|
|
4426
|
-
}
|
|
4427
|
-
});
|
|
4428
|
-
return rowsToFilter;
|
|
4397
|
+
var filterRows = function filterRows(rows) {
|
|
4398
|
+
return filterFn(rows, filterableColumnIds, globalFilter);
|
|
4429
4399
|
};
|
|
4430
4400
|
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4401
|
+
if (filterFromLeafRows) {
|
|
4402
|
+
filterRowModelFromLeafs(rowModel.rows, filterRows, instance);
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
return filterRowModelFromRoot(rowModel.rows, filterRows, instance);
|
|
4436
4406
|
}
|
|
4437
4407
|
|
|
4438
4408
|
function sortRowsFn(instance, rowModel) {
|
|
@@ -4471,7 +4441,7 @@
|
|
|
4471
4441
|
var bUndefined = typeof bValue === 'undefined';
|
|
4472
4442
|
|
|
4473
4443
|
if (aUndefined || bUndefined) {
|
|
4474
|
-
return aUndefined && bUndefined ? 0 : aUndefined ?
|
|
4444
|
+
return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
4475
4445
|
}
|
|
4476
4446
|
} // This function should always return in ascending order
|
|
4477
4447
|
|
|
@@ -4534,21 +4504,21 @@
|
|
|
4534
4504
|
var aggregateFn = instance.getColumnAggregationFn(column.id);
|
|
4535
4505
|
|
|
4536
4506
|
if (aggregateFn) {
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
}); // Get the columnValues to aggregate
|
|
4541
|
-
|
|
4542
|
-
var leafValues = leafRows.map(function (row) {
|
|
4543
|
-
var columnValue = row.values[column.id];
|
|
4507
|
+
values[column.id] = aggregateFn(function () {
|
|
4508
|
+
return leafRows.map(function (row) {
|
|
4509
|
+
var columnValue = row.values[column.id];
|
|
4544
4510
|
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4511
|
+
if (!depth && column.aggregateValue) {
|
|
4512
|
+
columnValue = column.aggregateValue(columnValue);
|
|
4513
|
+
}
|
|
4548
4514
|
|
|
4549
|
-
|
|
4515
|
+
return columnValue;
|
|
4516
|
+
});
|
|
4517
|
+
}, function () {
|
|
4518
|
+
return groupedRows.map(function (row) {
|
|
4519
|
+
return row.values[column.id];
|
|
4520
|
+
});
|
|
4550
4521
|
});
|
|
4551
|
-
values[column.id] = aggregateFn(leafValues, groupedValues);
|
|
4552
4522
|
} else if (column.aggregationType) {
|
|
4553
4523
|
console.info({
|
|
4554
4524
|
column: column
|
|
@@ -4591,7 +4561,7 @@
|
|
|
4591
4561
|
var subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
4592
4562
|
|
|
4593
4563
|
var leafRows = depth ? flattenBy(groupedRows, function (row) {
|
|
4594
|
-
return row.
|
|
4564
|
+
return row.subRows;
|
|
4595
4565
|
}) : groupedRows;
|
|
4596
4566
|
var values = aggregateRowsToValues(leafRows, groupedRows, depth);
|
|
4597
4567
|
var row = instance.createRow(id, undefined, index, depth, values);
|