@tanstack/table-core 8.0.0-alpha.85 → 8.0.0-alpha.88
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/core/cell.js +9 -7
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/core/column.js +1 -1
- package/build/cjs/core/column.js.map +1 -1
- package/build/cjs/features/Expanding.js +6 -3
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/features/Visibility.js +2 -7
- package/build/cjs/features/Visibility.js.map +1 -1
- package/build/cjs/sortingFns.js +53 -51
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +4 -8
- package/build/cjs/utils/getCoreRowModel.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/getPaginationRowModel.js +1 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +78 -80
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +322 -322
- package/build/types/features/Expanding.d.ts +0 -1
- package/build/types/features/Sorting.d.ts +3 -3
- package/build/types/features/Visibility.d.ts +5 -6
- package/build/types/index.d.ts +0 -2
- package/build/types/sortingFns.d.ts +7 -14
- package/build/umd/index.development.js +78 -80
- 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 +4 -4
- package/src/core/cell.ts +4 -3
- package/src/core/column.ts +0 -1
- package/src/features/Expanding.ts +6 -4
- package/src/features/Sorting.ts +4 -4
- package/src/features/Visibility.ts +10 -25
- package/src/index.ts +0 -2
- package/src/sortingFns.ts +59 -81
- package/src/utils/getCoreRowModel.ts +8 -11
- package/src/utils/getExpandedRowModel.ts +1 -5
|
@@ -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;
|
|
@@ -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>[];
|
package/build/types/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from './core/column';
|
|
|
5
5
|
export * from './core/headers';
|
|
6
6
|
export * from './core/row';
|
|
7
7
|
export * from './features/ColumnSizing';
|
|
8
|
-
export * from './features/ColumnSizing';
|
|
9
8
|
export * from './features/Expanding';
|
|
10
9
|
export * from './features/Filters';
|
|
11
10
|
export * from './features/Grouping';
|
|
@@ -15,7 +14,6 @@ export * from './features/Pinning';
|
|
|
15
14
|
export * from './features/RowSelection';
|
|
16
15
|
export * from './features/Sorting';
|
|
17
16
|
export * from './features/Visibility';
|
|
18
|
-
export * from './features/Expanding';
|
|
19
17
|
export * from './filterFns';
|
|
20
18
|
export * from './sortingFns';
|
|
21
19
|
export * from './aggregationFns';
|
|
@@ -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 {};
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
let column = {
|
|
117
|
+
let column = {
|
|
118
118
|
id: "" + id,
|
|
119
119
|
accessorFn,
|
|
120
120
|
parent: parent,
|
|
@@ -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
|
},
|
|
@@ -879,8 +878,12 @@
|
|
|
879
878
|
getIsAllRowsExpanded: () => {
|
|
880
879
|
const expanded = instance.getState().expanded; // If expanded is true, save some cycles and return true
|
|
881
880
|
|
|
882
|
-
if (expanded ===
|
|
883
|
-
return true;
|
|
881
|
+
if (typeof expanded === 'boolean') {
|
|
882
|
+
return expanded === true;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
if (!Object.keys(expanded).length) {
|
|
886
|
+
return false;
|
|
884
887
|
} // If any row is not expanded, return false
|
|
885
888
|
|
|
886
889
|
|
|
@@ -2335,21 +2338,54 @@
|
|
|
2335
2338
|
}
|
|
2336
2339
|
|
|
2337
2340
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2338
|
-
const sortingFns = {
|
|
2339
|
-
alphanumeric,
|
|
2340
|
-
alphanumericCaseSensitive,
|
|
2341
|
-
text,
|
|
2342
|
-
textCaseSensitive,
|
|
2343
|
-
datetime,
|
|
2344
|
-
basic
|
|
2345
|
-
};
|
|
2346
2341
|
|
|
2347
|
-
|
|
2342
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2348
2343
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2349
|
-
}
|
|
2344
|
+
};
|
|
2350
2345
|
|
|
2351
|
-
|
|
2346
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2352
2347
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2348
|
+
}; // The text filter is more basic (less numeric support)
|
|
2349
|
+
// but is much faster
|
|
2350
|
+
|
|
2351
|
+
|
|
2352
|
+
const text = (rowA, rowB, columnId) => {
|
|
2353
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2354
|
+
}; // The text filter is more basic (less numeric support)
|
|
2355
|
+
// but is much faster
|
|
2356
|
+
|
|
2357
|
+
|
|
2358
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2359
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2363
|
+
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2367
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2368
|
+
}; // Utils
|
|
2369
|
+
|
|
2370
|
+
|
|
2371
|
+
function compareBasic(a, b) {
|
|
2372
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
function toString(a) {
|
|
2376
|
+
if (typeof a === 'number') {
|
|
2377
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2378
|
+
return '';
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
return String(a);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
if (typeof a === 'string') {
|
|
2385
|
+
return a;
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
return '';
|
|
2353
2389
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2354
2390
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2355
2391
|
// null, undefined, and Infinity
|
|
@@ -2396,48 +2432,17 @@
|
|
|
2396
2432
|
}
|
|
2397
2433
|
|
|
2398
2434
|
return a.length - b.length;
|
|
2399
|
-
} //
|
|
2400
|
-
// but is much faster
|
|
2435
|
+
} // Exports
|
|
2401
2436
|
|
|
2402
2437
|
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2413
|
-
function datetime(rowA, rowB, columnId) {
|
|
2414
|
-
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
function basic(rowA, rowB, columnId) {
|
|
2418
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2419
|
-
} // Utils
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
function compareBasic(a, b) {
|
|
2423
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
function toString(a) {
|
|
2427
|
-
if (typeof a === 'number') {
|
|
2428
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2429
|
-
return '';
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
return String(a);
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
if (typeof a === 'string') {
|
|
2436
|
-
return a;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
return '';
|
|
2440
|
-
}
|
|
2438
|
+
const sortingFns = {
|
|
2439
|
+
alphanumeric,
|
|
2440
|
+
alphanumericCaseSensitive,
|
|
2441
|
+
text,
|
|
2442
|
+
textCaseSensitive,
|
|
2443
|
+
datetime,
|
|
2444
|
+
basic
|
|
2445
|
+
};
|
|
2441
2446
|
|
|
2442
2447
|
//
|
|
2443
2448
|
const Sorting = {
|
|
@@ -2661,11 +2666,6 @@
|
|
|
2661
2666
|
onColumnVisibilityChange: makeStateUpdater('columnVisibility', instance)
|
|
2662
2667
|
};
|
|
2663
2668
|
},
|
|
2664
|
-
getDefaultColumnDef: () => {
|
|
2665
|
-
return {
|
|
2666
|
-
defaultIsVisible: true
|
|
2667
|
-
};
|
|
2668
|
-
},
|
|
2669
2669
|
createColumn: (column, instance) => {
|
|
2670
2670
|
return {
|
|
2671
2671
|
toggleVisibility: value => {
|
|
@@ -2694,8 +2694,8 @@
|
|
|
2694
2694
|
},
|
|
2695
2695
|
createRow: (row, instance) => {
|
|
2696
2696
|
return {
|
|
2697
|
-
_getAllVisibleCells: memo(() => [row.getAllCells()
|
|
2698
|
-
return
|
|
2697
|
+
_getAllVisibleCells: memo(() => [row.getAllCells(), instance.getState().columnVisibility], cells => {
|
|
2698
|
+
return cells.filter(cell => cell.column.getIsVisible());
|
|
2699
2699
|
}, {
|
|
2700
2700
|
key: "development" === 'production' ,
|
|
2701
2701
|
debug: () => {
|
|
@@ -3046,13 +3046,15 @@
|
|
|
3046
3046
|
row,
|
|
3047
3047
|
column,
|
|
3048
3048
|
getValue: () => row.getValue(columnId),
|
|
3049
|
-
renderCell: () =>
|
|
3050
|
-
instance,
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3049
|
+
renderCell: () => {
|
|
3050
|
+
return column.columnDef.cell ? instance._render(column.columnDef.cell, {
|
|
3051
|
+
instance,
|
|
3052
|
+
column,
|
|
3053
|
+
row,
|
|
3054
|
+
cell: cell,
|
|
3055
|
+
getValue: cell.getValue
|
|
3056
|
+
}) : null;
|
|
3057
|
+
}
|
|
3056
3058
|
};
|
|
3057
3059
|
|
|
3058
3060
|
instance._features.forEach(feature => {
|
|
@@ -3127,27 +3129,23 @@
|
|
|
3127
3129
|
flatRows: [],
|
|
3128
3130
|
rowsById: {}
|
|
3129
3131
|
};
|
|
3130
|
-
let rows;
|
|
3131
|
-
let row;
|
|
3132
|
-
let originalRow;
|
|
3133
3132
|
|
|
3134
3133
|
const accessRows = function (originalRows, depth, parent) {
|
|
3135
3134
|
if (depth === void 0) {
|
|
3136
3135
|
depth = 0;
|
|
3137
3136
|
}
|
|
3138
3137
|
|
|
3139
|
-
rows = [];
|
|
3138
|
+
const rows = [];
|
|
3140
3139
|
|
|
3141
3140
|
for (let i = 0; i < originalRows.length; i++) {
|
|
3142
|
-
|
|
3141
|
+
// This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3143
3142
|
// if (!id) {
|
|
3144
3143
|
// if ("development" !== 'production') {
|
|
3145
3144
|
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3146
3145
|
// }
|
|
3147
3146
|
// }
|
|
3148
3147
|
// Make the row
|
|
3149
|
-
|
|
3150
|
-
row = createRow(instance, instance._getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3148
|
+
const row = createRow(instance, instance._getRowId(originalRows[i], i, parent), originalRows[i], i, depth); // Keep track of every row in a flat array
|
|
3151
3149
|
|
|
3152
3150
|
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3153
3151
|
|
|
@@ -3158,7 +3156,7 @@
|
|
|
3158
3156
|
if (instance.options.getSubRows) {
|
|
3159
3157
|
var _row$originalSubRows;
|
|
3160
3158
|
|
|
3161
|
-
row.originalSubRows = instance.options.getSubRows(
|
|
3159
|
+
row.originalSubRows = instance.options.getSubRows(originalRows[i], i); // Then recursively access them
|
|
3162
3160
|
|
|
3163
3161
|
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3164
3162
|
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
@@ -3739,7 +3737,7 @@
|
|
|
3739
3737
|
return rowModel;
|
|
3740
3738
|
}
|
|
3741
3739
|
|
|
3742
|
-
return expandRows(rowModel
|
|
3740
|
+
return expandRows(rowModel);
|
|
3743
3741
|
}, {
|
|
3744
3742
|
key: 'getExpandedRowModel',
|
|
3745
3743
|
debug: () => {
|
|
@@ -3757,7 +3755,7 @@
|
|
|
3757
3755
|
|
|
3758
3756
|
expandedRows.push(row);
|
|
3759
3757
|
|
|
3760
|
-
if (
|
|
3758
|
+
if ((_row$subRows = row.subRows) != null && _row$subRows.length && row.getIsExpanded()) {
|
|
3761
3759
|
row.subRows.forEach(handleRow);
|
|
3762
3760
|
}
|
|
3763
3761
|
};
|
|
@@ -3794,7 +3792,7 @@
|
|
|
3794
3792
|
rows,
|
|
3795
3793
|
flatRows,
|
|
3796
3794
|
rowsById
|
|
3797
|
-
}
|
|
3795
|
+
});
|
|
3798
3796
|
}
|
|
3799
3797
|
|
|
3800
3798
|
return {
|