@tanstack/table-core 8.0.0-alpha.46 → 8.0.0-alpha.47
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.map +1 -1
- package/build/cjs/createTable.js.map +1 -1
- package/build/cjs/features/Filters.js +6 -6
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +2 -2
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Sorting.js +2 -2
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/filterFns.js.map +1 -1
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/esm/index.js +10 -10
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +294 -294
- package/build/types/aggregationFns.d.ts +1 -1
- package/build/types/createTable.d.ts +4 -4
- package/build/types/features/Filters.d.ts +6 -6
- package/build/types/features/Grouping.d.ts +5 -5
- package/build/types/features/Sorting.d.ts +5 -5
- package/build/types/filterFns.d.ts +1 -1
- package/build/types/sortingFns.d.ts +1 -1
- package/build/umd/index.development.js +10 -10
- 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 +1 -1
- package/src/createTable.ts +6 -6
- package/src/features/Filters.ts +18 -18
- package/src/features/Grouping.ts +9 -9
- package/src/features/Sorting.ts +13 -9
- package/src/filterFns.ts +1 -1
- package/src/sortingFns.ts +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.47",
|
|
5
5
|
"description": "Hooks for building lightweight, fast and extendable datagrids for React",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
package/src/aggregationFns.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const aggregationFns = {
|
|
|
10
10
|
count,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export type
|
|
13
|
+
export type BuiltInAggregationFn = keyof typeof aggregationFns
|
|
14
14
|
|
|
15
15
|
function sum(_getLeafValues: () => unknown[], getChildValues: () => unknown[]) {
|
|
16
16
|
// It's faster to just add the aggregations together instead of
|
package/src/createTable.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AggregationFn,
|
|
3
|
-
import {
|
|
1
|
+
import { CustomFilterFns, FilterFn } from './features/Filters'
|
|
2
|
+
import { AggregationFn, CustomAggregationFns } from './features/Grouping'
|
|
3
|
+
import { CustomSortingFns, SortingFn } from './features/Sorting'
|
|
4
4
|
import { ColumnDef, AccessorFn, AnyRender, AnyGenerics, Options } from './types'
|
|
5
5
|
import { IfDefined, Overwrite, PartialKeys } from './utils'
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ export type TableFactory<TGenerics extends AnyGenerics> = () => Table<TGenerics>
|
|
|
8
8
|
|
|
9
9
|
export type CreateTableOptions<
|
|
10
10
|
TRender extends AnyRender,
|
|
11
|
-
TFilterFns extends
|
|
12
|
-
TSortingFns extends
|
|
13
|
-
TAggregationFns extends
|
|
11
|
+
TFilterFns extends CustomFilterFns<any>,
|
|
12
|
+
TSortingFns extends CustomSortingFns<any>,
|
|
13
|
+
TAggregationFns extends CustomAggregationFns<any>,
|
|
14
14
|
TGenerics extends AnyGenerics
|
|
15
15
|
> = Partial<
|
|
16
16
|
{
|
package/src/features/Filters.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowModel } from '..'
|
|
2
|
-
import {
|
|
2
|
+
import { BuiltInFilterFn, filterFns } from '../filterFns'
|
|
3
3
|
import {
|
|
4
4
|
Column,
|
|
5
5
|
OnChangeFn,
|
|
@@ -34,7 +34,7 @@ export type ColumnFilterAutoRemoveTestFn<TGenerics extends AnyGenerics> = (
|
|
|
34
34
|
column?: Column<TGenerics>
|
|
35
35
|
) => boolean
|
|
36
36
|
|
|
37
|
-
export type
|
|
37
|
+
export type CustomFilterFns<TGenerics extends AnyGenerics> = Record<
|
|
38
38
|
string,
|
|
39
39
|
FilterFn<TGenerics>
|
|
40
40
|
>
|
|
@@ -46,14 +46,14 @@ export type FiltersTableState = {
|
|
|
46
46
|
globalFilterProgress: number
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export type
|
|
49
|
+
export type FilterFnOption<TGenerics extends AnyGenerics> =
|
|
50
50
|
| 'auto'
|
|
51
|
-
|
|
|
51
|
+
| BuiltInFilterFn
|
|
52
52
|
| keyof TGenerics['FilterFns']
|
|
53
53
|
| FilterFn<TGenerics>
|
|
54
54
|
|
|
55
55
|
export type FiltersColumnDef<TGenerics extends AnyGenerics> = {
|
|
56
|
-
filterFn?:
|
|
56
|
+
filterFn?: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
57
57
|
enableAllFilters?: boolean
|
|
58
58
|
enableColumnFilter?: boolean
|
|
59
59
|
enableGlobalFilter?: boolean
|
|
@@ -63,7 +63,7 @@ export type FiltersColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export type FiltersColumn<TGenerics extends AnyGenerics> = {
|
|
66
|
-
filterFn:
|
|
66
|
+
filterFn: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
67
67
|
getCanColumnFilter: () => boolean
|
|
68
68
|
getCanGlobalFilter: () => boolean
|
|
69
69
|
getColumnFilterIndex: () => number
|
|
@@ -87,7 +87,7 @@ export type FiltersOptions<TGenerics extends AnyGenerics> = {
|
|
|
87
87
|
instance: TableInstance<TGenerics>
|
|
88
88
|
) => () => RowModel<TGenerics>
|
|
89
89
|
// Global
|
|
90
|
-
|
|
90
|
+
globalFilterFn?: FilterFnOption<TGenerics>
|
|
91
91
|
onGlobalFilterChange?: OnChangeFn<any>
|
|
92
92
|
autoResetGlobalFilter?: boolean
|
|
93
93
|
enableGlobalFilter?: boolean
|
|
@@ -161,7 +161,7 @@ export const Filters = {
|
|
|
161
161
|
autoResetColumnFilters: true,
|
|
162
162
|
filterFromLeafRows: true,
|
|
163
163
|
autoResetGlobalFilter: true,
|
|
164
|
-
|
|
164
|
+
globalFilterFn: 'auto',
|
|
165
165
|
getColumnCanGlobalFilterFn: column => {
|
|
166
166
|
const value = instance
|
|
167
167
|
.getCoreRowModel()
|
|
@@ -291,7 +291,7 @@ export const Filters = {
|
|
|
291
291
|
},
|
|
292
292
|
getColumnFilterFn: columnId => {
|
|
293
293
|
const column = instance.getColumn(columnId)
|
|
294
|
-
const
|
|
294
|
+
const userFilterFns = instance.options.filterFns
|
|
295
295
|
|
|
296
296
|
if (!column) {
|
|
297
297
|
throw new Error()
|
|
@@ -301,27 +301,27 @@ export const Filters = {
|
|
|
301
301
|
? column.filterFn
|
|
302
302
|
: column.filterFn === 'auto'
|
|
303
303
|
? instance.getColumnAutoFilterFn(columnId)
|
|
304
|
-
: (
|
|
304
|
+
: (userFilterFns as Record<string, any>)?.[
|
|
305
305
|
column.filterFn as string
|
|
306
306
|
] ??
|
|
307
307
|
(filterFns[
|
|
308
|
-
column.filterFn as
|
|
308
|
+
column.filterFn as BuiltInFilterFn
|
|
309
309
|
] as FilterFn<TGenerics>)
|
|
310
310
|
},
|
|
311
311
|
|
|
312
312
|
getGlobalFilterFn: () => {
|
|
313
|
-
const { filterFns:
|
|
313
|
+
const { filterFns: userFilterFns, globalFilterFn: globalFilterFn } =
|
|
314
314
|
instance.options
|
|
315
315
|
|
|
316
|
-
return isFunction(
|
|
317
|
-
?
|
|
318
|
-
:
|
|
316
|
+
return isFunction(globalFilterFn)
|
|
317
|
+
? globalFilterFn
|
|
318
|
+
: globalFilterFn === 'auto'
|
|
319
319
|
? instance.getGlobalAutoFilterFn()
|
|
320
|
-
: (
|
|
321
|
-
|
|
320
|
+
: (userFilterFns as Record<string, any>)?.[
|
|
321
|
+
globalFilterFn as string
|
|
322
322
|
] ??
|
|
323
323
|
(filterFns[
|
|
324
|
-
|
|
324
|
+
globalFilterFn as BuiltInFilterFn
|
|
325
325
|
] as FilterFn<TGenerics>)
|
|
326
326
|
},
|
|
327
327
|
|
package/src/features/Grouping.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RowModel } from '..'
|
|
2
|
-
import {
|
|
2
|
+
import { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'
|
|
3
3
|
import {
|
|
4
4
|
Cell,
|
|
5
5
|
Column,
|
|
@@ -30,14 +30,14 @@ export type AggregationFn<TGenerics extends AnyGenerics> = (
|
|
|
30
30
|
getChildValues: () => TGenerics['Row'][]
|
|
31
31
|
) => any
|
|
32
32
|
|
|
33
|
-
export type
|
|
33
|
+
export type CustomAggregationFns<TGenerics extends AnyGenerics> = Record<
|
|
34
34
|
string,
|
|
35
35
|
AggregationFn<TGenerics>
|
|
36
36
|
>
|
|
37
37
|
|
|
38
|
-
export type
|
|
38
|
+
export type AggregationFnOption<TGenerics extends AnyGenerics> =
|
|
39
39
|
| 'auto'
|
|
40
|
-
|
|
|
40
|
+
| BuiltInAggregationFn
|
|
41
41
|
| keyof TGenerics['AggregationFns']
|
|
42
42
|
| AggregationFn<TGenerics>
|
|
43
43
|
|
|
@@ -46,7 +46,7 @@ export type GroupingTableState = {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export type GroupingColumnDef<TGenerics extends AnyGenerics> = {
|
|
49
|
-
aggregationFn?:
|
|
49
|
+
aggregationFn?: AggregationFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
50
50
|
aggregateValue?: (columnValue: unknown) => any
|
|
51
51
|
aggregatedCell?: Renderable<
|
|
52
52
|
TGenerics,
|
|
@@ -63,7 +63,7 @@ export type GroupingColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export type GroupingColumn<TGenerics extends AnyGenerics> = {
|
|
66
|
-
aggregationFn?:
|
|
66
|
+
aggregationFn?: AggregationFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
67
67
|
getCanGroup: () => boolean
|
|
68
68
|
getIsGrouped: () => boolean
|
|
69
69
|
getGroupedIndex: () => number
|
|
@@ -221,7 +221,7 @@ export const Grouping = {
|
|
|
221
221
|
},
|
|
222
222
|
getColumnAggregationFn: columnId => {
|
|
223
223
|
const column = instance.getColumn(columnId)
|
|
224
|
-
const
|
|
224
|
+
const userAggregationFns = instance.options.aggregationFns
|
|
225
225
|
|
|
226
226
|
if (!column) {
|
|
227
227
|
throw new Error()
|
|
@@ -231,11 +231,11 @@ export const Grouping = {
|
|
|
231
231
|
? column.aggregationFn
|
|
232
232
|
: column.aggregationFn === 'auto'
|
|
233
233
|
? instance.getColumnAutoAggregationFn(columnId)
|
|
234
|
-
: (
|
|
234
|
+
: (userAggregationFns as Record<string, any>)?.[
|
|
235
235
|
column.aggregationFn as string
|
|
236
236
|
] ??
|
|
237
237
|
(aggregationFns[
|
|
238
|
-
column.aggregationFn as
|
|
238
|
+
column.aggregationFn as BuiltInAggregationFn
|
|
239
239
|
] as AggregationFn<TGenerics>)
|
|
240
240
|
},
|
|
241
241
|
|
package/src/features/Sorting.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { RowModel } from '..'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BuiltInSortingFn,
|
|
4
|
+
reSplitAlphaNumeric,
|
|
5
|
+
sortingFns,
|
|
6
|
+
} from '../sortingFns'
|
|
3
7
|
|
|
4
8
|
import {
|
|
5
9
|
Column,
|
|
@@ -36,7 +40,7 @@ export type SortingFn<TGenerics extends AnyGenerics> = {
|
|
|
36
40
|
(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
export type
|
|
43
|
+
export type CustomSortingFns<TGenerics extends AnyGenerics> = Record<
|
|
40
44
|
string,
|
|
41
45
|
SortingFn<TGenerics>
|
|
42
46
|
>
|
|
@@ -45,14 +49,14 @@ export type SortingTableState = {
|
|
|
45
49
|
sorting: SortingState
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
export type
|
|
52
|
+
export type SortingFnOption<TGenerics extends AnyGenerics> =
|
|
49
53
|
| 'auto'
|
|
50
|
-
|
|
|
54
|
+
| BuiltInSortingFn
|
|
51
55
|
| keyof TGenerics['SortingFns']
|
|
52
56
|
| SortingFn<TGenerics>
|
|
53
57
|
|
|
54
58
|
export type SortingColumnDef<TGenerics extends AnyGenerics> = {
|
|
55
|
-
sortingFn?:
|
|
59
|
+
sortingFn?: SortingFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
56
60
|
sortDescFirst?: boolean
|
|
57
61
|
enableSorting?: boolean
|
|
58
62
|
enableMultiSort?: boolean
|
|
@@ -62,7 +66,7 @@ export type SortingColumnDef<TGenerics extends AnyGenerics> = {
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
export type SortingColumn<TGenerics extends AnyGenerics> = {
|
|
65
|
-
sortingFn:
|
|
69
|
+
sortingFn: SortingFnOption<Overwrite<TGenerics, { Value: any }>>
|
|
66
70
|
getCanSort: () => boolean
|
|
67
71
|
getCanMultiSort: () => boolean
|
|
68
72
|
getSortIndex: () => number
|
|
@@ -236,7 +240,7 @@ export const Sorting = {
|
|
|
236
240
|
},
|
|
237
241
|
getColumnSortingFn: columnId => {
|
|
238
242
|
const column = instance.getColumn(columnId)
|
|
239
|
-
const
|
|
243
|
+
const userSortingFn = instance.options.sortingFns
|
|
240
244
|
|
|
241
245
|
if (!column) {
|
|
242
246
|
throw new Error()
|
|
@@ -246,11 +250,11 @@ export const Sorting = {
|
|
|
246
250
|
? column.sortingFn
|
|
247
251
|
: column.sortingFn === 'auto'
|
|
248
252
|
? instance.getColumnAutoSortingFn(columnId)
|
|
249
|
-
: (
|
|
253
|
+
: (userSortingFn as Record<string, any>)?.[
|
|
250
254
|
column.sortingFn as string
|
|
251
255
|
] ??
|
|
252
256
|
(sortingFns[
|
|
253
|
-
column.sortingFn as
|
|
257
|
+
column.sortingFn as BuiltInSortingFn
|
|
254
258
|
] as SortingFn<TGenerics>)
|
|
255
259
|
},
|
|
256
260
|
|
package/src/filterFns.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const filterFns = {
|
|
|
12
12
|
betweenNumberRange,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export type
|
|
15
|
+
export type BuiltInFilterFn = keyof typeof filterFns
|
|
16
16
|
|
|
17
17
|
function includesString<TGenerics extends AnyGenerics>(
|
|
18
18
|
rows: Row<TGenerics>[],
|
package/src/sortingFns.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyGenerics, Row } from './types'
|
|
2
2
|
|
|
3
3
|
export const reSplitAlphaNumeric = /([0-9]+)/gm
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ export const sortingFns = {
|
|
|
11
11
|
basic,
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type BuiltInSortingFn = keyof typeof sortingFns
|
|
15
15
|
|
|
16
16
|
function alphanumeric<TGenerics extends AnyGenerics>(
|
|
17
17
|
rowA: Row<TGenerics>,
|