@tanstack/table-core 8.0.0-alpha.78 → 8.0.0-alpha.82
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/createTable.js +1 -0
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/ColumnSizing.js +1 -1
- package/build/cjs/features/ColumnSizing.js.map +1 -1
- package/build/cjs/features/Filters.js +2 -1
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Rows.js +1 -1
- package/build/cjs/features/Rows.js.map +1 -1
- package/build/cjs/features/Sorting.js +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/index.js +8 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils/filterRowsUtils.js +1 -1
- package/build/cjs/utils/filterRowsUtils.js.map +1 -1
- package/build/cjs/utils/getFacetedRowModel.js +1 -1
- package/build/cjs/utils/getFacetedRowModel.js.map +1 -1
- package/build/cjs/utils/getFilteredRowModel.js +20 -9
- package/build/cjs/utils/getFilteredRowModel.js.map +1 -1
- package/build/esm/index.js +29 -16
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +327 -309
- package/build/types/createTable.d.ts +4 -1
- package/build/types/features/Filters.d.ts +3 -2
- package/build/types/features/Grouping.d.ts +1 -1
- package/build/types/index.d.ts +3 -0
- package/build/types/types.d.ts +1 -0
- package/build/umd/index.development.js +33 -15
- 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/createTable.ts +7 -3
- package/src/features/ColumnSizing.ts +1 -1
- package/src/features/Filters.ts +11 -3
- package/src/features/Grouping.ts +2 -2
- package/src/features/Rows.ts +5 -1
- package/src/features/Sorting.ts +1 -1
- package/src/index.ts +3 -0
- package/src/types.ts +1 -0
- package/src/utils/filterRowsUtils.ts +1 -1
- package/src/utils/getFacetedRowModel.ts +1 -1
- package/src/utils/getFilteredRowModel.ts +24 -13
|
@@ -23,7 +23,10 @@ export declare type Table<TGenerics extends TableGenerics> = {
|
|
|
23
23
|
setColumnMetaType: <TColumnMeta>() => Table<Overwrite<TGenerics, {
|
|
24
24
|
ColumnMeta: TColumnMeta;
|
|
25
25
|
}>>;
|
|
26
|
-
|
|
26
|
+
setFilterMetaType: <TFilterMeta>() => Table<Overwrite<TGenerics, {
|
|
27
|
+
FilterMeta: TFilterMeta;
|
|
28
|
+
}>>;
|
|
29
|
+
setOptions: <TFilterFns extends Record<string, FilterFn<TGenerics>>, TSortingFns extends Record<string, SortingFn<TGenerics>>, TAggregationFns extends Record<string, AggregationFn<TGenerics>>>(options: CreateTableOptions<any, TFilterFns, TSortingFns, TAggregationFns, TGenerics>) => Table<Overwrite<TGenerics, {
|
|
27
30
|
FilterFns: IfDefined<TFilterFns, TGenerics['FilterFns']>;
|
|
28
31
|
SortingFns: IfDefined<TSortingFns, TGenerics['SortingFns']>;
|
|
29
32
|
AggregationFns: IfDefined<TAggregationFns, TGenerics['AggregationFns']>;
|
|
@@ -17,7 +17,7 @@ export declare type ResolvedColumnFilter<TGenerics extends TableGenerics> = {
|
|
|
17
17
|
filterFn: FilterFn<TGenerics>;
|
|
18
18
|
};
|
|
19
19
|
export declare type FilterFn<TGenerics extends TableGenerics> = {
|
|
20
|
-
(row: Row<TGenerics>, columnId: string, filterValue: any): boolean;
|
|
20
|
+
(row: Row<TGenerics>, columnId: string, filterValue: any, addMeta: (meta: TGenerics['FilterMeta']) => void): boolean;
|
|
21
21
|
resolveFilterValue?: TransformFilterValueFn<TGenerics>;
|
|
22
22
|
autoRemove?: ColumnFilterAutoRemoveTestFn<TGenerics>;
|
|
23
23
|
};
|
|
@@ -53,7 +53,8 @@ export declare type FiltersColumn<TGenerics extends TableGenerics> = {
|
|
|
53
53
|
_getFacetedMinMaxValues?: () => undefined | [number, number];
|
|
54
54
|
};
|
|
55
55
|
export declare type FiltersRow<TGenerics extends TableGenerics> = {
|
|
56
|
-
|
|
56
|
+
columnFilters: Record<string, boolean>;
|
|
57
|
+
columnFiltersMeta: Record<string, TGenerics['FilterMeta']>;
|
|
57
58
|
subRowsByFacetId: Record<string, Row<TGenerics>[]>;
|
|
58
59
|
};
|
|
59
60
|
export declare type FiltersOptions<TGenerics extends TableGenerics> = {
|
|
@@ -3,7 +3,7 @@ import { BuiltInAggregationFn } from '../aggregationFns';
|
|
|
3
3
|
import { Cell, Column, OnChangeFn, TableInstance, Row, Updater, Renderable, TableGenerics, TableFeature } from '../types';
|
|
4
4
|
import { Overwrite } from '../utils';
|
|
5
5
|
export declare type GroupingState = string[];
|
|
6
|
-
export declare type AggregationFn<TGenerics extends TableGenerics> = (getLeafValues: () => TGenerics['
|
|
6
|
+
export declare type AggregationFn<TGenerics extends TableGenerics> = (getLeafValues: () => TGenerics['Value'][], getChildValues: () => TGenerics['Value'][]) => any;
|
|
7
7
|
export declare type CustomAggregationFns<TGenerics extends TableGenerics> = Record<string, AggregationFn<TGenerics>>;
|
|
8
8
|
export declare type AggregationFnOption<TGenerics extends TableGenerics> = 'auto' | BuiltInAggregationFn | keyof TGenerics['AggregationFns'] | AggregationFn<TGenerics>;
|
|
9
9
|
export declare type GroupingTableState = {
|
package/build/types/index.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export * from './features/RowSelection';
|
|
|
14
14
|
export * from './features/Sorting';
|
|
15
15
|
export * from './features/Visibility';
|
|
16
16
|
export * from './features/Expanding';
|
|
17
|
+
export * from './filterFns';
|
|
18
|
+
export * from './sortingFns';
|
|
19
|
+
export * from './aggregationFns';
|
|
17
20
|
export * from './utils';
|
|
18
21
|
export * from './utils/getCoreRowModel';
|
|
19
22
|
export * from './utils/getFilteredRowModel';
|
package/build/types/types.d.ts
CHANGED
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
const column = instance.getColumn(columnId);
|
|
291
291
|
|
|
292
292
|
if (!column.accessorFn) {
|
|
293
|
-
|
|
293
|
+
return undefined;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
row.valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
|
|
@@ -527,7 +527,7 @@
|
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
-
const startSize =
|
|
530
|
+
const startSize = header.getSize();
|
|
531
531
|
const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
|
|
532
532
|
const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
|
|
533
533
|
|
|
@@ -1081,7 +1081,8 @@
|
|
|
1081
1081
|
},
|
|
1082
1082
|
createRow: (row, instance) => {
|
|
1083
1083
|
return {
|
|
1084
|
-
|
|
1084
|
+
columnFilters: {},
|
|
1085
|
+
columnFiltersMeta: {},
|
|
1085
1086
|
subRowsByFacetId: {}
|
|
1086
1087
|
};
|
|
1087
1088
|
},
|
|
@@ -2323,7 +2324,7 @@
|
|
|
2323
2324
|
createColumn: (column, instance) => {
|
|
2324
2325
|
return {
|
|
2325
2326
|
getAutoSortingFn: () => {
|
|
2326
|
-
const firstRows = instance.getFilteredRowModel().flatRows.slice(
|
|
2327
|
+
const firstRows = instance.getFilteredRowModel().flatRows.slice(10);
|
|
2327
2328
|
let isString = false;
|
|
2328
2329
|
|
|
2329
2330
|
for (const row of firstRows) {
|
|
@@ -3171,6 +3172,7 @@
|
|
|
3171
3172
|
setRowType: () => table,
|
|
3172
3173
|
setTableMetaType: () => table,
|
|
3173
3174
|
setColumnMetaType: () => table,
|
|
3175
|
+
setFilterMetaType: () => table,
|
|
3174
3176
|
setOptions: newOptions => createTable(_, __, { ...options,
|
|
3175
3177
|
...newOptions
|
|
3176
3178
|
}),
|
|
@@ -3298,7 +3300,7 @@
|
|
|
3298
3300
|
|
|
3299
3301
|
if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
|
|
3300
3302
|
newRow = instance.createRow(row.id, row.original, row.index, row.depth);
|
|
3301
|
-
newRow.
|
|
3303
|
+
newRow.columnFilters = row.columnFilters;
|
|
3302
3304
|
newRow.subRows = recurseFilterRows(row.subRows, depth + 1);
|
|
3303
3305
|
|
|
3304
3306
|
if (!newRow.subRows.length) {
|
|
@@ -3371,6 +3373,11 @@
|
|
|
3371
3373
|
function getFilteredRowModel() {
|
|
3372
3374
|
return instance => memo(() => [instance.getPreFilteredRowModel(), instance.getState().columnFilters, instance.getState().globalFilter], (rowModel, columnFilters, globalFilter) => {
|
|
3373
3375
|
if (!rowModel.rows.length || !(columnFilters != null && columnFilters.length) && !globalFilter) {
|
|
3376
|
+
for (let i = 0; i < rowModel.flatRows.length; i++) {
|
|
3377
|
+
rowModel.flatRows[i].columnFilters = {};
|
|
3378
|
+
rowModel.flatRows[i].columnFiltersMeta = {};
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3374
3381
|
return rowModel;
|
|
3375
3382
|
}
|
|
3376
3383
|
|
|
@@ -3425,28 +3432,34 @@
|
|
|
3425
3432
|
|
|
3426
3433
|
for (let j = 0; j < rowModel.flatRows.length; j++) {
|
|
3427
3434
|
const row = rowModel.flatRows[j];
|
|
3428
|
-
row.
|
|
3435
|
+
row.columnFilters = {};
|
|
3429
3436
|
|
|
3430
3437
|
if (resolvedColumnFilters.length) {
|
|
3431
3438
|
for (let i = 0; i < resolvedColumnFilters.length; i++) {
|
|
3432
|
-
currentColumnFilter = resolvedColumnFilters[i];
|
|
3439
|
+
currentColumnFilter = resolvedColumnFilters[i];
|
|
3440
|
+
const id = currentColumnFilter.id; // Tag the row with the column filter state
|
|
3433
3441
|
|
|
3434
|
-
row.
|
|
3442
|
+
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, filterMeta => {
|
|
3443
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3444
|
+
});
|
|
3435
3445
|
}
|
|
3436
3446
|
}
|
|
3437
3447
|
|
|
3438
3448
|
if (resolvedGlobalFilters.length) {
|
|
3439
3449
|
for (let i = 0; i < resolvedGlobalFilters.length; i++) {
|
|
3440
|
-
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3450
|
+
currentGlobalFilter = resolvedGlobalFilters[i];
|
|
3451
|
+
const id = currentGlobalFilter.id; // Tag the row with the first truthy global filter state
|
|
3441
3452
|
|
|
3442
|
-
if (currentGlobalFilter.filterFn(row,
|
|
3443
|
-
row.
|
|
3453
|
+
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, filterMeta => {
|
|
3454
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
3455
|
+
})) {
|
|
3456
|
+
row.columnFilters.__global__ = true;
|
|
3444
3457
|
break;
|
|
3445
3458
|
}
|
|
3446
3459
|
}
|
|
3447
3460
|
|
|
3448
|
-
if (row.
|
|
3449
|
-
row.
|
|
3461
|
+
if (row.columnFilters.__global__ !== true) {
|
|
3462
|
+
row.columnFilters.__global__ = false;
|
|
3450
3463
|
}
|
|
3451
3464
|
}
|
|
3452
3465
|
}
|
|
@@ -3454,7 +3467,7 @@
|
|
|
3454
3467
|
const filterRowsImpl = row => {
|
|
3455
3468
|
// Horizontally filter rows through each column
|
|
3456
3469
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3457
|
-
if (row.
|
|
3470
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3458
3471
|
return false;
|
|
3459
3472
|
}
|
|
3460
3473
|
}
|
|
@@ -3488,7 +3501,7 @@
|
|
|
3488
3501
|
const filterRowsImpl = row => {
|
|
3489
3502
|
// Horizontally filter rows through each column
|
|
3490
3503
|
for (let i = 0; i < filterableIds.length; i++) {
|
|
3491
|
-
if (row.
|
|
3504
|
+
if (row.columnFilters[filterableIds[i]] === false) {
|
|
3492
3505
|
return false;
|
|
3493
3506
|
}
|
|
3494
3507
|
}
|
|
@@ -3907,11 +3920,13 @@
|
|
|
3907
3920
|
exports.RowSelection = RowSelection;
|
|
3908
3921
|
exports.Sorting = Sorting;
|
|
3909
3922
|
exports.Visibility = Visibility;
|
|
3923
|
+
exports.aggregationFns = aggregationFns;
|
|
3910
3924
|
exports.buildHeaderGroups = buildHeaderGroups;
|
|
3911
3925
|
exports.createTableFactory = createTableFactory;
|
|
3912
3926
|
exports.createTableInstance = createTableInstance;
|
|
3913
3927
|
exports.defaultColumnSizing = defaultColumnSizing;
|
|
3914
3928
|
exports.expandRows = expandRows;
|
|
3929
|
+
exports.filterFns = filterFns;
|
|
3915
3930
|
exports.flattenBy = flattenBy;
|
|
3916
3931
|
exports.functionalUpdate = functionalUpdate;
|
|
3917
3932
|
exports.getCoreRowModel = getCoreRowModel;
|
|
@@ -3926,12 +3941,15 @@
|
|
|
3926
3941
|
exports.isFunction = isFunction;
|
|
3927
3942
|
exports.isRowSelected = isRowSelected;
|
|
3928
3943
|
exports.makeStateUpdater = makeStateUpdater;
|
|
3944
|
+
exports.mean = mean;
|
|
3929
3945
|
exports.memo = memo;
|
|
3930
3946
|
exports.noop = noop;
|
|
3931
3947
|
exports.orderColumns = orderColumns;
|
|
3932
3948
|
exports.passiveEventSupported = passiveEventSupported;
|
|
3949
|
+
exports.reSplitAlphaNumeric = reSplitAlphaNumeric;
|
|
3933
3950
|
exports.selectRowsFn = selectRowsFn;
|
|
3934
3951
|
exports.shouldAutoRemoveFilter = shouldAutoRemoveFilter;
|
|
3952
|
+
exports.sortingFns = sortingFns;
|
|
3935
3953
|
|
|
3936
3954
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3937
3955
|
|