@tanstack/table-core 8.0.0-alpha.20 → 8.0.0-alpha.23
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 +5 -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.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 +166 -192
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +303 -270
- package/build/types/aggregationTypes.d.ts +9 -9
- package/build/types/core.d.ts +1 -1
- package/build/types/features/Expanding.d.ts +1 -0
- 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 +166 -192
- 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 +7 -10
- package/src/features/Filters.ts +2 -2
- package/src/features/Grouping.ts +2 -2
- 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>[];
|
|
@@ -37,6 +37,7 @@ export declare type ExpandedInstance<TGenerics extends PartialGenerics> = {
|
|
|
37
37
|
getIsRowExpanded: (rowId: string) => boolean;
|
|
38
38
|
getToggleExpandedProps: <TGetter extends Getter<ToggleExpandedProps>>(rowId: string, userProps?: TGetter) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>;
|
|
39
39
|
getToggleAllRowsExpandedProps: <TGetter extends Getter<ToggleExpandedProps>>(userProps?: TGetter) => undefined | PropGetterValue<ToggleExpandedProps, TGetter>;
|
|
40
|
+
getIsSomeRowsExpanded: () => boolean;
|
|
40
41
|
getIsAllRowsExpanded: () => boolean;
|
|
41
42
|
getExpandedDepth: () => number;
|
|
42
43
|
getExpandedRowModel: () => RowModel<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
|
//
|
|
@@ -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) {
|
|
@@ -2906,6 +2914,10 @@
|
|
|
2906
2914
|
};
|
|
2907
2915
|
return propGetter(initialProps, userProps);
|
|
2908
2916
|
},
|
|
2917
|
+
getIsSomeRowsExpanded: function getIsSomeRowsExpanded() {
|
|
2918
|
+
var expanded = instance.getState().expanded;
|
|
2919
|
+
return expanded === true || Object.values(expanded).some(Boolean);
|
|
2920
|
+
},
|
|
2909
2921
|
getIsAllRowsExpanded: function getIsAllRowsExpanded() {
|
|
2910
2922
|
var expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
2911
2923
|
|
|
@@ -2966,14 +2978,7 @@
|
|
|
2966
2978
|
return row.subRows && !!row.subRows.length;
|
|
2967
2979
|
},
|
|
2968
2980
|
getToggleExpandedProps: function getToggleExpandedProps(userProps) {
|
|
2969
|
-
|
|
2970
|
-
title: 'Toggle Row Expanded',
|
|
2971
|
-
onClick: function onClick(e) {
|
|
2972
|
-
e.stopPropagation();
|
|
2973
|
-
instance.toggleRowExpanded(row.id);
|
|
2974
|
-
}
|
|
2975
|
-
};
|
|
2976
|
-
return propGetter(initialProps, userProps);
|
|
2981
|
+
return instance.getToggleExpandedProps(row.id, userProps);
|
|
2977
2982
|
}
|
|
2978
2983
|
};
|
|
2979
2984
|
}
|
|
@@ -3200,10 +3205,10 @@
|
|
|
3200
3205
|
},
|
|
3201
3206
|
toggleAllRowsSelected: function toggleAllRowsSelected(value) {
|
|
3202
3207
|
instance.setRowSelection(function (old) {
|
|
3203
|
-
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
|
|
3204
|
-
|
|
3208
|
+
value = typeof value !== 'undefined' ? value : !instance.getIsAllRowsSelected();
|
|
3209
|
+
|
|
3210
|
+
var rowSelection = _extends({}, old);
|
|
3205
3211
|
|
|
3206
|
-
var rowSelection = Object.assign({}, old);
|
|
3207
3212
|
var preGroupedFlatRows = instance.getPreGroupedRowModel().flatRows; // We don't use `mutateRowIsSelected` here for performance reasons.
|
|
3208
3213
|
// All of the rows are flat already, so it wouldn't be worth it
|
|
3209
3214
|
|
|
@@ -3945,7 +3950,11 @@
|
|
|
3945
3950
|
depth: depth,
|
|
3946
3951
|
values: values,
|
|
3947
3952
|
subRows: [],
|
|
3948
|
-
|
|
3953
|
+
getLeafRows: function getLeafRows() {
|
|
3954
|
+
return flattenBy(row.subRows, function (d) {
|
|
3955
|
+
return d.subRows;
|
|
3956
|
+
});
|
|
3957
|
+
},
|
|
3949
3958
|
getRowProps: function getRowProps(userProps) {
|
|
3950
3959
|
return instance.getRowProps(row.id, userProps);
|
|
3951
3960
|
},
|
|
@@ -4039,13 +4048,9 @@
|
|
|
4039
4048
|
|
|
4040
4049
|
for (var _i = 0; _i < row.originalSubRows.length; _i++) {
|
|
4041
4050
|
accessRow(row.originalSubRows[_i], _i, depth + 1, subRows, row);
|
|
4042
|
-
}
|
|
4043
|
-
|
|
4051
|
+
}
|
|
4044
4052
|
|
|
4045
4053
|
row.subRows = subRows;
|
|
4046
|
-
row.leafRows = flattenBy(subRows, function (d) {
|
|
4047
|
-
return d.leafRows;
|
|
4048
|
-
});
|
|
4049
4054
|
}
|
|
4050
4055
|
}
|
|
4051
4056
|
};
|
|
@@ -4067,9 +4072,9 @@
|
|
|
4067
4072
|
return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugTable;
|
|
4068
4073
|
},
|
|
4069
4074
|
onChange: function onChange() {
|
|
4070
|
-
instance._notifyRowSelectionReset();
|
|
4071
|
-
|
|
4072
4075
|
instance._notifyFiltersReset();
|
|
4076
|
+
|
|
4077
|
+
instance._notifyRowSelectionReset();
|
|
4073
4078
|
}
|
|
4074
4079
|
}),
|
|
4075
4080
|
// The final calls start at the bottom of the model,
|
|
@@ -4231,126 +4236,147 @@
|
|
|
4231
4236
|
};
|
|
4232
4237
|
}
|
|
4233
4238
|
|
|
4234
|
-
function
|
|
4235
|
-
var columnFilters = instance.getState().columnFilters;
|
|
4239
|
+
function filterRowModelFromLeafs(rowsToFilter, filterRows, instance) {
|
|
4236
4240
|
var newFilteredFlatRows = [];
|
|
4237
4241
|
var newFilteredRowsById = {};
|
|
4238
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
4239
4242
|
|
|
4240
|
-
var
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
// Find the columnFilters column
|
|
4245
|
-
var column = instance.getColumn(columnId);
|
|
4243
|
+
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4244
|
+
if (depth === void 0) {
|
|
4245
|
+
depth = 0;
|
|
4246
|
+
}
|
|
4246
4247
|
|
|
4247
|
-
|
|
4248
|
-
{
|
|
4249
|
-
console.warn("Table: Could not find a column with id: " + columnId);
|
|
4250
|
-
}
|
|
4248
|
+
rowsToFilter = rowsToFilter.slice(); // Filter from children up first
|
|
4251
4249
|
|
|
4252
|
-
|
|
4253
|
-
|
|
4250
|
+
for (var i = 0; i < rowsToFilter.length; i++) {
|
|
4251
|
+
var _row$subRows;
|
|
4254
4252
|
|
|
4255
|
-
|
|
4256
|
-
var preFilteredRows = [].concat(rowsToFilter);
|
|
4253
|
+
var row = rowsToFilter[i];
|
|
4257
4254
|
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
};
|
|
4255
|
+
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4256
|
+
continue;
|
|
4261
4257
|
}
|
|
4262
4258
|
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
if (!filterFn) {
|
|
4266
|
-
{
|
|
4267
|
-
console.warn("Could not find a valid 'column.filterType' for column with the ID: " + column.id + ".");
|
|
4268
|
-
}
|
|
4259
|
+
rowsToFilter[i] = instance.createRow(row.id, row.original, row.index, row.depth, row.values);
|
|
4260
|
+
rowsToFilter[i].subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
4269
4261
|
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4262
|
+
if (!rowsToFilter[i].subRows.length) {
|
|
4263
|
+
rowsToFilter.splice(i, 1);
|
|
4264
|
+
i--;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4273
4267
|
|
|
4268
|
+
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4274
4269
|
|
|
4275
|
-
|
|
4270
|
+
rowsToFilter.forEach(function (row) {
|
|
4271
|
+
newFilteredFlatRows.push(row);
|
|
4272
|
+
newFilteredRowsById[row.id] = row;
|
|
4276
4273
|
});
|
|
4277
4274
|
return rowsToFilter;
|
|
4278
4275
|
};
|
|
4279
4276
|
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4291
|
-
return true;
|
|
4292
|
-
}
|
|
4293
|
-
|
|
4294
|
-
row.subRows = _recurseFilterRows(row.subRows, depth + 1);
|
|
4295
|
-
return row.subRows.length;
|
|
4296
|
-
});
|
|
4297
|
-
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4298
|
-
|
|
4299
|
-
rowsToFilter.forEach(function (row) {
|
|
4300
|
-
newFilteredFlatRows.push(row);
|
|
4301
|
-
newFilteredRowsById[row.id] = row;
|
|
4302
|
-
});
|
|
4303
|
-
return rowsToFilter;
|
|
4304
|
-
};
|
|
4305
|
-
|
|
4306
|
-
return {
|
|
4307
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
4308
|
-
flatRows: newFilteredFlatRows,
|
|
4309
|
-
rowsById: newFilteredRowsById
|
|
4310
|
-
};
|
|
4311
|
-
} // Filters top level and nested rows
|
|
4312
|
-
|
|
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
|
|
4313
4286
|
|
|
4314
4287
|
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4315
4288
|
if (depth === void 0) {
|
|
4316
4289
|
depth = 0;
|
|
4317
4290
|
}
|
|
4318
4291
|
|
|
4319
|
-
// Filter from parents downward
|
|
4292
|
+
// Filter from parents downward first
|
|
4320
4293
|
rowsToFilter = filterRows(rowsToFilter, depth); // Apply the filter to any subRows
|
|
4321
|
-
// We technically could do this recursively in the above loop,
|
|
4322
|
-
// but that would severely hinder the API for the user, since they
|
|
4323
|
-
// would be required to do that recursion in some scenarios
|
|
4324
4294
|
|
|
4325
|
-
rowsToFilter.
|
|
4295
|
+
for (var i = 0; i < rowsToFilter.length; i++) {
|
|
4296
|
+
var _row$subRows2;
|
|
4297
|
+
|
|
4298
|
+
var row = rowsToFilter[i];
|
|
4326
4299
|
newFilteredFlatRows.push(row);
|
|
4327
4300
|
newFilteredRowsById[row.id] = row;
|
|
4328
4301
|
|
|
4329
|
-
if (!
|
|
4330
|
-
|
|
4302
|
+
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
4303
|
+
rowsToFilter.splice(i, 1);
|
|
4304
|
+
i--;
|
|
4305
|
+
continue;
|
|
4306
|
+
}
|
|
4331
4307
|
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
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
|
+
}
|
|
4335
4311
|
|
|
4336
|
-
row.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
4337
|
-
}
|
|
4338
|
-
});
|
|
4339
4312
|
return rowsToFilter;
|
|
4340
4313
|
};
|
|
4341
4314
|
|
|
4342
4315
|
return {
|
|
4343
|
-
rows: recurseFilterRows(
|
|
4316
|
+
rows: recurseFilterRows(rowsToFilter),
|
|
4344
4317
|
flatRows: newFilteredFlatRows,
|
|
4345
4318
|
rowsById: newFilteredRowsById
|
|
4346
4319
|
};
|
|
4347
4320
|
}
|
|
4348
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
|
+
|
|
4349
4377
|
function globalFilterRowsFn(instance, rowModel) {
|
|
4350
4378
|
var globalFilter = instance.getState().globalFilter;
|
|
4351
|
-
var
|
|
4352
|
-
var newFilteredRowsById = {};
|
|
4353
|
-
var filterFromChildrenUp = instance.options.filterFromChildrenUp;
|
|
4379
|
+
var filterFromLeafRows = instance.options.filterFromLeafRows;
|
|
4354
4380
|
var filterFn = instance.getGlobalFilterFn();
|
|
4355
4381
|
|
|
4356
4382
|
if (!filterFn) {
|
|
@@ -4368,67 +4394,15 @@
|
|
|
4368
4394
|
return d.id;
|
|
4369
4395
|
});
|
|
4370
4396
|
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
// Filter from children up
|
|
4375
|
-
rowsToFilter = rowsToFilter.filter(function (row) {
|
|
4376
|
-
var _row$subRows;
|
|
4377
|
-
|
|
4378
|
-
if (!((_row$subRows = row.subRows) != null && _row$subRows.length)) {
|
|
4379
|
-
return true;
|
|
4380
|
-
}
|
|
4381
|
-
|
|
4382
|
-
row.subRows = _recurseFilterRows(row.subRows);
|
|
4383
|
-
return row.subRows.length;
|
|
4384
|
-
});
|
|
4385
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
4386
|
-
|
|
4387
|
-
rowsToFilter.forEach(function (row) {
|
|
4388
|
-
newFilteredFlatRows.push(row);
|
|
4389
|
-
newFilteredRowsById[row.id] = row;
|
|
4390
|
-
});
|
|
4391
|
-
return rowsToFilter;
|
|
4392
|
-
};
|
|
4393
|
-
|
|
4394
|
-
return {
|
|
4395
|
-
rows: _recurseFilterRows(rowModel.rows),
|
|
4396
|
-
flatRows: newFilteredFlatRows,
|
|
4397
|
-
rowsById: newFilteredRowsById
|
|
4398
|
-
};
|
|
4399
|
-
} // Filters top level and nested rows
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
var recurseFilterRows = function recurseFilterRows(rowsToFilter, depth) {
|
|
4403
|
-
|
|
4404
|
-
// Filter from parents downward
|
|
4405
|
-
rowsToFilter = filterFn(rowsToFilter, filterableColumnIds, globalFilter); // Apply the filter to any subRows
|
|
4406
|
-
// We technically could do this recursively in the above loop,
|
|
4407
|
-
// but that would severely hinder the API for the user, since they
|
|
4408
|
-
// would be required to do that recursion in some scenarios
|
|
4409
|
-
|
|
4410
|
-
rowsToFilter.forEach(function (row) {
|
|
4411
|
-
newFilteredFlatRows.push(row);
|
|
4412
|
-
newFilteredRowsById[row.id] = row;
|
|
4413
|
-
|
|
4414
|
-
if (!filterFromChildrenUp) {
|
|
4415
|
-
var _row$subRows2;
|
|
4416
|
-
|
|
4417
|
-
if (!((_row$subRows2 = row.subRows) != null && _row$subRows2.length)) {
|
|
4418
|
-
return;
|
|
4419
|
-
}
|
|
4420
|
-
|
|
4421
|
-
row.subRows = recurseFilterRows(row.subRows);
|
|
4422
|
-
}
|
|
4423
|
-
});
|
|
4424
|
-
return rowsToFilter;
|
|
4397
|
+
var filterRows = function filterRows(rows) {
|
|
4398
|
+
return filterFn(rows, filterableColumnIds, globalFilter);
|
|
4425
4399
|
};
|
|
4426
4400
|
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4401
|
+
if (filterFromLeafRows) {
|
|
4402
|
+
filterRowModelFromLeafs(rowModel.rows, filterRows, instance);
|
|
4403
|
+
}
|
|
4404
|
+
|
|
4405
|
+
return filterRowModelFromRoot(rowModel.rows, filterRows, instance);
|
|
4432
4406
|
}
|
|
4433
4407
|
|
|
4434
4408
|
function sortRowsFn(instance, rowModel) {
|
|
@@ -4467,7 +4441,7 @@
|
|
|
4467
4441
|
var bUndefined = typeof bValue === 'undefined';
|
|
4468
4442
|
|
|
4469
4443
|
if (aUndefined || bUndefined) {
|
|
4470
|
-
return aUndefined && bUndefined ? 0 : aUndefined ?
|
|
4444
|
+
return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
|
|
4471
4445
|
}
|
|
4472
4446
|
} // This function should always return in ascending order
|
|
4473
4447
|
|
|
@@ -4530,21 +4504,21 @@
|
|
|
4530
4504
|
var aggregateFn = instance.getColumnAggregationFn(column.id);
|
|
4531
4505
|
|
|
4532
4506
|
if (aggregateFn) {
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
}); // Get the columnValues to aggregate
|
|
4537
|
-
|
|
4538
|
-
var leafValues = leafRows.map(function (row) {
|
|
4539
|
-
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];
|
|
4540
4510
|
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4511
|
+
if (!depth && column.aggregateValue) {
|
|
4512
|
+
columnValue = column.aggregateValue(columnValue);
|
|
4513
|
+
}
|
|
4544
4514
|
|
|
4545
|
-
|
|
4515
|
+
return columnValue;
|
|
4516
|
+
});
|
|
4517
|
+
}, function () {
|
|
4518
|
+
return groupedRows.map(function (row) {
|
|
4519
|
+
return row.values[column.id];
|
|
4520
|
+
});
|
|
4546
4521
|
});
|
|
4547
|
-
values[column.id] = aggregateFn(leafValues, groupedValues);
|
|
4548
4522
|
} else if (column.aggregationType) {
|
|
4549
4523
|
console.info({
|
|
4550
4524
|
column: column
|
|
@@ -4587,7 +4561,7 @@
|
|
|
4587
4561
|
var subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
|
|
4588
4562
|
|
|
4589
4563
|
var leafRows = depth ? flattenBy(groupedRows, function (row) {
|
|
4590
|
-
return row.
|
|
4564
|
+
return row.subRows;
|
|
4591
4565
|
}) : groupedRows;
|
|
4592
4566
|
var values = aggregateRowsToValues(leafRows, groupedRows, depth);
|
|
4593
4567
|
var row = instance.createRow(id, undefined, index, depth, values);
|