@tanstack/table-core 8.0.0-alpha.84 → 8.0.0-alpha.87
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/aggregationFns.js +50 -51
- package/build/cjs/aggregationFns.js.map +1 -1
- package/build/cjs/features/Expanding.js +0 -1
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Filters.js +1 -2
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +5 -5
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +0 -5
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/index.js +0 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/sortingFns.js +53 -51
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +2 -2
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +5 -13
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +1 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +118 -131
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +324 -324
- package/build/types/aggregationFns.d.ts +10 -19
- package/build/types/features/Expanding.d.ts +0 -1
- package/build/types/features/Filters.d.ts +0 -2
- package/build/types/features/Grouping.d.ts +6 -8
- package/build/types/features/Sorting.d.ts +3 -3
- package/build/types/features/Visibility.d.ts +5 -6
- package/build/types/sortingFns.d.ts +7 -14
- package/build/umd/index.development.js +117 -131
- 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/aggregationFns.ts +44 -40
- package/src/features/Expanding.ts +0 -2
- package/src/features/Filters.ts +0 -5
- package/src/features/Grouping.ts +15 -18
- package/src/features/Sorting.ts +4 -4
- package/src/features/Visibility.ts +7 -16
- package/src/sortingFns.ts +59 -81
- package/src/utils/getExpandedRowModel.ts +1 -5
- package/src/utils/getGroupedRowModel.ts +8 -17
|
@@ -1,22 +1,13 @@
|
|
|
1
|
+
import { AggregationFn } from './features/Grouping';
|
|
1
2
|
export declare const aggregationFns: {
|
|
2
|
-
sum:
|
|
3
|
-
min:
|
|
4
|
-
max:
|
|
5
|
-
extent:
|
|
6
|
-
mean:
|
|
7
|
-
median:
|
|
8
|
-
unique:
|
|
9
|
-
uniqueCount:
|
|
10
|
-
count:
|
|
3
|
+
sum: AggregationFn<any>;
|
|
4
|
+
min: AggregationFn<any>;
|
|
5
|
+
max: AggregationFn<any>;
|
|
6
|
+
extent: AggregationFn<any>;
|
|
7
|
+
mean: AggregationFn<any>;
|
|
8
|
+
median: AggregationFn<any>;
|
|
9
|
+
unique: AggregationFn<any>;
|
|
10
|
+
uniqueCount: AggregationFn<any>;
|
|
11
|
+
count: AggregationFn<any>;
|
|
11
12
|
};
|
|
12
13
|
export declare type BuiltInAggregationFn = keyof typeof aggregationFns;
|
|
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
|
-
export 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
|
-
export {};
|
|
@@ -18,7 +18,6 @@ export declare type ExpandedOptions<TGenerics extends TableGenerics> = {
|
|
|
18
18
|
autoResetExpanded?: boolean;
|
|
19
19
|
enableExpanding?: boolean;
|
|
20
20
|
getExpandedRowModel?: (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics>;
|
|
21
|
-
expandSubRows?: boolean;
|
|
22
21
|
getIsRowExpanded?: (row: Row<TGenerics>) => boolean;
|
|
23
22
|
getRowCanExpand?: (row: Row<TGenerics>) => boolean;
|
|
24
23
|
paginateExpandedRows?: boolean;
|
|
@@ -32,7 +32,6 @@ export declare type FiltersColumnDef<TGenerics extends TableGenerics> = {
|
|
|
32
32
|
}>>;
|
|
33
33
|
enableColumnFilter?: boolean;
|
|
34
34
|
enableGlobalFilter?: boolean;
|
|
35
|
-
enableFaceting?: boolean;
|
|
36
35
|
};
|
|
37
36
|
export declare type FiltersColumn<TGenerics extends TableGenerics> = {
|
|
38
37
|
filterFn: FilterFnOption<Overwrite<TGenerics, {
|
|
@@ -56,7 +55,6 @@ export declare type FiltersColumn<TGenerics extends TableGenerics> = {
|
|
|
56
55
|
export declare type FiltersRow<TGenerics extends TableGenerics> = {
|
|
57
56
|
columnFilters: Record<string, boolean>;
|
|
58
57
|
columnFiltersMeta: Record<string, TGenerics['FilterMeta']>;
|
|
59
|
-
subRowsByFacetId: Record<string, Row<TGenerics>[]>;
|
|
60
58
|
};
|
|
61
59
|
export declare type FiltersOptions<TGenerics extends TableGenerics> = {
|
|
62
60
|
enableFilters?: boolean;
|
|
@@ -4,17 +4,16 @@ import { TableFeature } from '../core/instance';
|
|
|
4
4
|
import { Cell, Column, OnChangeFn, TableInstance, Row, Updater, Renderable, TableGenerics } from '../types';
|
|
5
5
|
import { Overwrite } from '../utils';
|
|
6
6
|
export declare type GroupingState = string[];
|
|
7
|
-
export declare type AggregationFn<TGenerics extends TableGenerics> = (getLeafValues: () => TGenerics['Value'][], getChildValues: () => TGenerics['Value'][]) => any;
|
|
8
|
-
export declare type CustomAggregationFns<TGenerics extends TableGenerics> = Record<string, AggregationFn<TGenerics>>;
|
|
9
|
-
export declare type AggregationFnOption<TGenerics extends TableGenerics> = 'auto' | BuiltInAggregationFn | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
|
|
10
7
|
export declare type GroupingTableState = {
|
|
11
8
|
grouping: GroupingState;
|
|
12
9
|
};
|
|
10
|
+
export declare type AggregationFn<TGenerics extends TableGenerics> = (columnId: string, leafRows: Row<TGenerics>[], childRows: Row<TGenerics>[]) => any;
|
|
11
|
+
export declare type CustomAggregationFns<TGenerics extends TableGenerics> = Record<string, AggregationFn<TGenerics>>;
|
|
12
|
+
export declare type AggregationFnOption<TGenerics extends TableGenerics> = 'auto' | BuiltInAggregationFn | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
|
|
13
13
|
export declare type GroupingColumnDef<TGenerics extends TableGenerics> = {
|
|
14
14
|
aggregationFn?: AggregationFnOption<Overwrite<TGenerics, {
|
|
15
15
|
Value: any;
|
|
16
16
|
}>>;
|
|
17
|
-
aggregateValue?: (columnValue: unknown) => any;
|
|
18
17
|
aggregatedCell?: Renderable<TGenerics, {
|
|
19
18
|
instance: TableInstance<TGenerics>;
|
|
20
19
|
row: Row<TGenerics>;
|
|
@@ -33,14 +32,14 @@ export declare type GroupingColumn<TGenerics extends TableGenerics> = {
|
|
|
33
32
|
getGroupedIndex: () => number;
|
|
34
33
|
toggleGrouping: () => void;
|
|
35
34
|
getToggleGroupingHandler: () => () => void;
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
getAutoAggregationFn: () => AggregationFn<TGenerics> | undefined;
|
|
36
|
+
getAggregationFn: () => AggregationFn<TGenerics> | undefined;
|
|
38
37
|
};
|
|
39
38
|
export declare type GroupingRow = {
|
|
40
39
|
groupingColumnId?: string;
|
|
41
40
|
groupingValue?: any;
|
|
42
41
|
getIsGrouped: () => boolean;
|
|
43
|
-
|
|
42
|
+
_groupingValuesCache: Record<string, any>;
|
|
44
43
|
};
|
|
45
44
|
export declare type GroupingCell<TGenerics extends TableGenerics> = {
|
|
46
45
|
getIsGrouped: () => boolean;
|
|
@@ -57,7 +56,6 @@ export declare type GroupingOptions<TGenerics extends TableGenerics> = {
|
|
|
57
56
|
aggregationFns?: TGenerics['AggregationFns'];
|
|
58
57
|
onGroupingChange?: OnChangeFn<GroupingState>;
|
|
59
58
|
enableGrouping?: boolean;
|
|
60
|
-
enableGroupingRemoval?: boolean;
|
|
61
59
|
getGroupedRowModel?: (instance: TableInstance<TGenerics>) => () => RowModel<TGenerics>;
|
|
62
60
|
groupedColumnMode?: false | 'reorder' | 'remove';
|
|
63
61
|
};
|
|
@@ -9,13 +9,13 @@ export declare type ColumnSort = {
|
|
|
9
9
|
desc: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare type SortingState = ColumnSort[];
|
|
12
|
+
export declare type SortingTableState = {
|
|
13
|
+
sorting: SortingState;
|
|
14
|
+
};
|
|
12
15
|
export declare type SortingFn<TGenerics extends TableGenerics> = {
|
|
13
16
|
(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
17
|
};
|
|
15
18
|
export declare type CustomSortingFns<TGenerics extends TableGenerics> = Record<string, SortingFn<TGenerics>>;
|
|
16
|
-
export declare type SortingTableState = {
|
|
17
|
-
sorting: SortingState;
|
|
18
|
-
};
|
|
19
19
|
export declare type SortingFnOption<TGenerics extends TableGenerics> = 'auto' | BuiltInSortingFn | keyof TGenerics['SortingFns'] | SortingFn<TGenerics>;
|
|
20
20
|
export declare type SortingColumnDef<TGenerics extends TableGenerics> = {
|
|
21
21
|
sortingFn?: SortingFnOption<Overwrite<TGenerics, {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { TableFeature } from '../core/instance';
|
|
2
2
|
import { Cell, Column, OnChangeFn, TableGenerics, Updater } from '../types';
|
|
3
|
+
export declare type VisibilityState = Record<string, boolean>;
|
|
4
|
+
export declare type VisibilityTableState = {
|
|
5
|
+
columnVisibility: VisibilityState;
|
|
6
|
+
};
|
|
3
7
|
export declare type VisibilityOptions = {
|
|
4
8
|
onColumnVisibilityChange?: OnChangeFn<VisibilityState>;
|
|
5
9
|
enableHiding?: boolean;
|
|
@@ -7,10 +11,6 @@ export declare type VisibilityOptions = {
|
|
|
7
11
|
export declare type VisibilityDefaultOptions = {
|
|
8
12
|
onColumnVisibilityChange: OnChangeFn<VisibilityState>;
|
|
9
13
|
};
|
|
10
|
-
export declare type VisibilityState = Record<string, boolean>;
|
|
11
|
-
export declare type VisibilityTableState = {
|
|
12
|
-
columnVisibility: VisibilityState;
|
|
13
|
-
};
|
|
14
14
|
export declare type VisibilityInstance<TGenerics extends TableGenerics> = {
|
|
15
15
|
getVisibleFlatColumns: () => Column<TGenerics>[];
|
|
16
16
|
getVisibleLeafColumns: () => Column<TGenerics>[];
|
|
@@ -22,11 +22,10 @@ export declare type VisibilityInstance<TGenerics extends TableGenerics> = {
|
|
|
22
22
|
toggleAllColumnsVisible: (value?: boolean) => void;
|
|
23
23
|
getIsAllColumnsVisible: () => boolean;
|
|
24
24
|
getIsSomeColumnsVisible: () => boolean;
|
|
25
|
-
getToggleAllColumnsVisibilityHandler: () =>
|
|
25
|
+
getToggleAllColumnsVisibilityHandler: () => (event: unknown) => void;
|
|
26
26
|
};
|
|
27
27
|
export declare type VisibilityColumnDef = {
|
|
28
28
|
enableHiding?: boolean;
|
|
29
|
-
defaultIsVisible?: boolean;
|
|
30
29
|
};
|
|
31
30
|
export declare type VisibilityRow<TGenerics extends TableGenerics> = {
|
|
32
31
|
_getAllVisibleCells: () => Cell<TGenerics>[];
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SortingFn } from './features/Sorting';
|
|
2
2
|
export declare const reSplitAlphaNumeric: RegExp;
|
|
3
3
|
export declare const sortingFns: {
|
|
4
|
-
alphanumeric:
|
|
5
|
-
alphanumericCaseSensitive:
|
|
6
|
-
text:
|
|
7
|
-
textCaseSensitive:
|
|
8
|
-
datetime:
|
|
9
|
-
basic:
|
|
4
|
+
alphanumeric: SortingFn<any>;
|
|
5
|
+
alphanumericCaseSensitive: SortingFn<any>;
|
|
6
|
+
text: SortingFn<any>;
|
|
7
|
+
textCaseSensitive: SortingFn<any>;
|
|
8
|
+
datetime: SortingFn<any>;
|
|
9
|
+
basic: SortingFn<any>;
|
|
10
10
|
};
|
|
11
11
|
export declare type BuiltInSortingFn = keyof typeof sortingFns;
|
|
12
|
-
declare function alphanumeric<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
13
|
-
declare function alphanumericCaseSensitive<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
|
-
declare function text<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
15
|
-
declare function textCaseSensitive<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
16
|
-
declare function datetime<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
17
|
-
declare function basic<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
18
|
-
export {};
|
|
@@ -819,7 +819,6 @@
|
|
|
819
819
|
return {
|
|
820
820
|
onExpandedChange: makeStateUpdater('expanded', instance),
|
|
821
821
|
autoResetExpanded: true,
|
|
822
|
-
expandSubRows: true,
|
|
823
822
|
paginateExpandedRows: true
|
|
824
823
|
};
|
|
825
824
|
},
|
|
@@ -1216,8 +1215,7 @@
|
|
|
1216
1215
|
createRow: (row, instance) => {
|
|
1217
1216
|
return {
|
|
1218
1217
|
columnFilters: {},
|
|
1219
|
-
columnFiltersMeta: {}
|
|
1220
|
-
subRowsByFacetId: {}
|
|
1218
|
+
columnFiltersMeta: {}
|
|
1221
1219
|
};
|
|
1222
1220
|
},
|
|
1223
1221
|
createInstance: instance => {
|
|
@@ -1308,53 +1306,42 @@
|
|
|
1308
1306
|
return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === 'undefined' || typeof value === 'string' && !value;
|
|
1309
1307
|
}
|
|
1310
1308
|
|
|
1311
|
-
const
|
|
1312
|
-
sum,
|
|
1313
|
-
min,
|
|
1314
|
-
max,
|
|
1315
|
-
extent,
|
|
1316
|
-
mean,
|
|
1317
|
-
median,
|
|
1318
|
-
unique,
|
|
1319
|
-
uniqueCount,
|
|
1320
|
-
count
|
|
1321
|
-
};
|
|
1322
|
-
|
|
1323
|
-
function sum(_getLeafValues, getChildValues) {
|
|
1309
|
+
const sum = (columnId, _leafRows, childRows) => {
|
|
1324
1310
|
// It's faster to just add the aggregations together instead of
|
|
1325
1311
|
// process leaf nodes individually
|
|
1326
|
-
return
|
|
1327
|
-
}
|
|
1312
|
+
return childRows.reduce((sum, next) => sum + (typeof next === 'number' ? next : 0), 0);
|
|
1313
|
+
};
|
|
1328
1314
|
|
|
1329
|
-
|
|
1315
|
+
const min = (columnId, _leafRows, childRows) => {
|
|
1330
1316
|
let min;
|
|
1317
|
+
childRows.forEach(row => {
|
|
1318
|
+
const value = row.getValue(columnId);
|
|
1331
1319
|
|
|
1332
|
-
for (const value of getChildValues()) {
|
|
1333
1320
|
if (value != null && (min > value || min === undefined && value >= value)) {
|
|
1334
1321
|
min = value;
|
|
1335
1322
|
}
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1323
|
+
});
|
|
1338
1324
|
return min;
|
|
1339
|
-
}
|
|
1325
|
+
};
|
|
1340
1326
|
|
|
1341
|
-
|
|
1327
|
+
const max = (columnId, _leafRows, childRows) => {
|
|
1342
1328
|
let max;
|
|
1329
|
+
childRows.forEach(row => {
|
|
1330
|
+
const value = row.getValue(columnId);
|
|
1343
1331
|
|
|
1344
|
-
for (const value of getChildValues()) {
|
|
1345
1332
|
if (value != null && (max < value || max === undefined && value >= value)) {
|
|
1346
1333
|
max = value;
|
|
1347
1334
|
}
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1335
|
+
});
|
|
1350
1336
|
return max;
|
|
1351
|
-
}
|
|
1337
|
+
};
|
|
1352
1338
|
|
|
1353
|
-
|
|
1339
|
+
const extent = (columnId, _leafRows, childRows) => {
|
|
1354
1340
|
let min;
|
|
1355
1341
|
let max;
|
|
1342
|
+
childRows.forEach(row => {
|
|
1343
|
+
const value = row.getValue(columnId);
|
|
1356
1344
|
|
|
1357
|
-
for (const value of getChildValues()) {
|
|
1358
1345
|
if (value != null) {
|
|
1359
1346
|
if (min === undefined) {
|
|
1360
1347
|
if (value >= value) min = max = value;
|
|
@@ -1363,54 +1350,65 @@
|
|
|
1363
1350
|
if (max < value) max = value;
|
|
1364
1351
|
}
|
|
1365
1352
|
}
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1353
|
+
});
|
|
1368
1354
|
return [min, max];
|
|
1369
|
-
}
|
|
1355
|
+
};
|
|
1370
1356
|
|
|
1371
|
-
|
|
1357
|
+
const mean = (columnId, leafRows) => {
|
|
1372
1358
|
let count = 0;
|
|
1373
1359
|
let sum = 0;
|
|
1360
|
+
leafRows.forEach(row => {
|
|
1361
|
+
let value = row.getValue(columnId);
|
|
1374
1362
|
|
|
1375
|
-
for (let value of getLeafValues()) {
|
|
1376
1363
|
if (value != null && (value = +value) >= value) {
|
|
1377
1364
|
++count, sum += value;
|
|
1378
1365
|
}
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1366
|
+
});
|
|
1381
1367
|
if (count) return sum / count;
|
|
1382
1368
|
return;
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
function median(getLeafValues) {
|
|
1386
|
-
const leafValues = getLeafValues();
|
|
1369
|
+
};
|
|
1387
1370
|
|
|
1388
|
-
|
|
1371
|
+
const median = (columnId, leafRows) => {
|
|
1372
|
+
if (!leafRows.length) {
|
|
1389
1373
|
return;
|
|
1390
1374
|
}
|
|
1391
1375
|
|
|
1392
1376
|
let min = 0;
|
|
1393
1377
|
let max = 0;
|
|
1394
|
-
|
|
1378
|
+
leafRows.forEach(row => {
|
|
1379
|
+
let value = row.getValue(columnId);
|
|
1380
|
+
|
|
1395
1381
|
if (typeof value === 'number') {
|
|
1396
1382
|
min = Math.min(min, value);
|
|
1397
1383
|
max = Math.max(max, value);
|
|
1398
1384
|
}
|
|
1399
1385
|
});
|
|
1400
1386
|
return (min + max) / 2;
|
|
1401
|
-
}
|
|
1387
|
+
};
|
|
1402
1388
|
|
|
1403
|
-
|
|
1404
|
-
return Array.from(new Set(
|
|
1405
|
-
}
|
|
1389
|
+
const unique = (columnId, leafRows) => {
|
|
1390
|
+
return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
|
|
1391
|
+
};
|
|
1406
1392
|
|
|
1407
|
-
|
|
1408
|
-
return new Set(
|
|
1409
|
-
}
|
|
1393
|
+
const uniqueCount = (columnId, leafRows) => {
|
|
1394
|
+
return new Set(leafRows.map(d => d.getValue(columnId))).size;
|
|
1395
|
+
};
|
|
1410
1396
|
|
|
1411
|
-
|
|
1412
|
-
return
|
|
1413
|
-
}
|
|
1397
|
+
const count = (_columnId, leafRows) => {
|
|
1398
|
+
return leafRows.length;
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1401
|
+
const aggregationFns = {
|
|
1402
|
+
sum,
|
|
1403
|
+
min,
|
|
1404
|
+
max,
|
|
1405
|
+
extent,
|
|
1406
|
+
mean,
|
|
1407
|
+
median,
|
|
1408
|
+
unique,
|
|
1409
|
+
uniqueCount,
|
|
1410
|
+
count
|
|
1411
|
+
};
|
|
1414
1412
|
|
|
1415
1413
|
//
|
|
1416
1414
|
const Grouping = {
|
|
@@ -1465,7 +1463,7 @@
|
|
|
1465
1463
|
column.toggleGrouping();
|
|
1466
1464
|
};
|
|
1467
1465
|
},
|
|
1468
|
-
|
|
1466
|
+
getAutoAggregationFn: () => {
|
|
1469
1467
|
const firstRow = instance.getCoreRowModel().flatRows[0];
|
|
1470
1468
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
1471
1469
|
|
|
@@ -1479,7 +1477,7 @@
|
|
|
1479
1477
|
|
|
1480
1478
|
return aggregationFns.count;
|
|
1481
1479
|
},
|
|
1482
|
-
|
|
1480
|
+
getAggregationFn: () => {
|
|
1483
1481
|
var _ref4;
|
|
1484
1482
|
|
|
1485
1483
|
const userAggregationFns = instance.options.aggregationFns;
|
|
@@ -1488,7 +1486,7 @@
|
|
|
1488
1486
|
throw new Error();
|
|
1489
1487
|
}
|
|
1490
1488
|
|
|
1491
|
-
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.
|
|
1489
|
+
return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
|
|
1492
1490
|
}
|
|
1493
1491
|
};
|
|
1494
1492
|
},
|
|
@@ -1514,10 +1512,10 @@
|
|
|
1514
1512
|
}
|
|
1515
1513
|
};
|
|
1516
1514
|
},
|
|
1517
|
-
createRow:
|
|
1515
|
+
createRow: row => {
|
|
1518
1516
|
return {
|
|
1519
1517
|
getIsGrouped: () => !!row.groupingColumnId,
|
|
1520
|
-
|
|
1518
|
+
_groupingValuesCache: {}
|
|
1521
1519
|
};
|
|
1522
1520
|
},
|
|
1523
1521
|
createCell: (cell, column, row, instance) => {
|
|
@@ -2336,21 +2334,54 @@
|
|
|
2336
2334
|
}
|
|
2337
2335
|
|
|
2338
2336
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2339
|
-
const sortingFns = {
|
|
2340
|
-
alphanumeric,
|
|
2341
|
-
alphanumericCaseSensitive,
|
|
2342
|
-
text,
|
|
2343
|
-
textCaseSensitive,
|
|
2344
|
-
datetime,
|
|
2345
|
-
basic
|
|
2346
|
-
};
|
|
2347
2337
|
|
|
2348
|
-
|
|
2338
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2349
2339
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2350
|
-
}
|
|
2340
|
+
};
|
|
2351
2341
|
|
|
2352
|
-
|
|
2342
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2353
2343
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2344
|
+
}; // The text filter is more basic (less numeric support)
|
|
2345
|
+
// but is much faster
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
const text = (rowA, rowB, columnId) => {
|
|
2349
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2350
|
+
}; // The text filter is more basic (less numeric support)
|
|
2351
|
+
// but is much faster
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2355
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2359
|
+
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2363
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2364
|
+
}; // Utils
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
function compareBasic(a, b) {
|
|
2368
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
function toString(a) {
|
|
2372
|
+
if (typeof a === 'number') {
|
|
2373
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2374
|
+
return '';
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
return String(a);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
if (typeof a === 'string') {
|
|
2381
|
+
return a;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
return '';
|
|
2354
2385
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2355
2386
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2356
2387
|
// null, undefined, and Infinity
|
|
@@ -2397,48 +2428,17 @@
|
|
|
2397
2428
|
}
|
|
2398
2429
|
|
|
2399
2430
|
return a.length - b.length;
|
|
2400
|
-
} //
|
|
2401
|
-
// but is much faster
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
function text(rowA, rowB, columnId) {
|
|
2405
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2406
|
-
} // The text filter is more basic (less numeric support)
|
|
2407
|
-
// but is much faster
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2411
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
function datetime(rowA, rowB, columnId) {
|
|
2415
|
-
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
function basic(rowA, rowB, columnId) {
|
|
2419
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2420
|
-
} // Utils
|
|
2431
|
+
} // Exports
|
|
2421
2432
|
|
|
2422
2433
|
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
}
|
|
2432
|
-
|
|
2433
|
-
return String(a);
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
if (typeof a === 'string') {
|
|
2437
|
-
return a;
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
return '';
|
|
2441
|
-
}
|
|
2434
|
+
const sortingFns = {
|
|
2435
|
+
alphanumeric,
|
|
2436
|
+
alphanumericCaseSensitive,
|
|
2437
|
+
text,
|
|
2438
|
+
textCaseSensitive,
|
|
2439
|
+
datetime,
|
|
2440
|
+
basic
|
|
2441
|
+
};
|
|
2442
2442
|
|
|
2443
2443
|
//
|
|
2444
2444
|
const Sorting = {
|
|
@@ -2662,11 +2662,6 @@
|
|
|
2662
2662
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2663
2663
|
};
|
|
2664
2664
|
},
|
|
2665
|
-
getDefaultColumnDef: () => {
|
|
2666
|
-
return {
|
|
2667
|
-
defaultIsVisible: true
|
|
2668
|
-
};
|
|
2669
|
-
},
|
|
2670
2665
|
createColumn: (column, instance) => {
|
|
2671
2666
|
return {
|
|
2672
2667
|
toggleVisibility: value => {
|
|
@@ -3650,25 +3645,17 @@
|
|
|
3650
3645
|
return row._valuesCache[columnId];
|
|
3651
3646
|
}
|
|
3652
3647
|
|
|
3653
|
-
if (row.
|
|
3654
|
-
return row.
|
|
3648
|
+
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
3649
|
+
return row._groupingValuesCache[columnId];
|
|
3655
3650
|
} // Aggregate the values
|
|
3656
3651
|
|
|
3657
3652
|
|
|
3658
3653
|
const column = instance.getColumn(columnId);
|
|
3659
|
-
const aggregateFn = column.
|
|
3654
|
+
const aggregateFn = column.getAggregationFn();
|
|
3660
3655
|
|
|
3661
3656
|
if (aggregateFn) {
|
|
3662
|
-
row.
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
if (!depth && column.columnDef.aggregateValue) {
|
|
3666
|
-
columnValue = column.columnDef.aggregateValue(columnValue);
|
|
3667
|
-
}
|
|
3668
|
-
|
|
3669
|
-
return columnValue;
|
|
3670
|
-
}), () => groupedRows.map(row => row.getValue(columnId)));
|
|
3671
|
-
return row.groupingValuesCache[columnId];
|
|
3657
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
3658
|
+
return row._groupingValuesCache[columnId];
|
|
3672
3659
|
} else if (column.aggregationFn) {
|
|
3673
3660
|
console.info({
|
|
3674
3661
|
column
|
|
@@ -3748,7 +3735,7 @@
|
|
|
3748
3735
|
return rowModel;
|
|
3749
3736
|
}
|
|
3750
3737
|
|
|
3751
|
-
return expandRows(rowModel
|
|
3738
|
+
return expandRows(rowModel);
|
|
3752
3739
|
}, {
|
|
3753
3740
|
key: 'getExpandedRowModel',
|
|
3754
3741
|
debug: () => {
|
|
@@ -3766,7 +3753,7 @@
|
|
|
3766
3753
|
|
|
3767
3754
|
expandedRows.push(row);
|
|
3768
3755
|
|
|
3769
|
-
if (
|
|
3756
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3770
3757
|
row.subRows.forEach(handleRow);
|
|
3771
3758
|
}
|
|
3772
3759
|
};
|
|
@@ -3803,7 +3790,7 @@
|
|
|
3803
3790
|
rows,
|
|
3804
3791
|
flatRows,
|
|
3805
3792
|
rowsById
|
|
3806
|
-
}
|
|
3793
|
+
});
|
|
3807
3794
|
}
|
|
3808
3795
|
|
|
3809
3796
|
return {
|
|
@@ -3855,7 +3842,6 @@
|
|
|
3855
3842
|
exports.isFunction = isFunction;
|
|
3856
3843
|
exports.isRowSelected = isRowSelected;
|
|
3857
3844
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3858
|
-
exports.mean = mean;
|
|
3859
3845
|
exports.memo = memo;
|
|
3860
3846
|
exports.noop = noop;
|
|
3861
3847
|
exports.orderColumns = orderColumns;
|