@tanstack/table-core 8.4.0 → 8.5.0
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/columnHelper.js +2 -1
- package/build/cjs/columnHelper.js.map +1 -1
- package/build/cjs/features/Filters.js +6 -2
- package/build/cjs/features/Filters.js.map +1 -1
- package/build/cjs/features/Grouping.js +3 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Sorting.js +3 -1
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/esm/index.js +14 -5
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +316 -316
- package/build/types/index.d.ts +26 -7
- package/build/umd/index.development.js +14 -5
- 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/columnHelper.ts +7 -0
- package/src/features/Filters.ts +13 -5
- package/src/features/Grouping.ts +15 -4
- package/src/features/Sorting.ts +20 -6
- package/src/types.ts +4 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/table-core",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.5.0",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for TS/JS.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
package/src/columnHelper.ts
CHANGED
|
@@ -59,6 +59,12 @@ export type ColumnHelper<TData extends RowData> = {
|
|
|
59
59
|
'id'
|
|
60
60
|
>
|
|
61
61
|
) => ColumnDef<TData, unknown>
|
|
62
|
+
group: (
|
|
63
|
+
column: RequiredKeys<
|
|
64
|
+
Omit<ColumnDef<TData, unknown>, 'accessorKey' | 'accessorFn'>,
|
|
65
|
+
'id' | 'columns'
|
|
66
|
+
>
|
|
67
|
+
) => ColumnDef<TData, unknown>
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
export function createColumnHelper<
|
|
@@ -77,5 +83,6 @@ export function createColumnHelper<
|
|
|
77
83
|
}
|
|
78
84
|
},
|
|
79
85
|
display: column => column as ColumnDef<TData, unknown>,
|
|
86
|
+
group: column => column as ColumnDef<TData, unknown>,
|
|
80
87
|
}
|
|
81
88
|
}
|
package/src/features/Filters.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Updater,
|
|
10
10
|
RowData,
|
|
11
11
|
FilterMeta,
|
|
12
|
+
FilterFns,
|
|
12
13
|
} from '../types'
|
|
13
14
|
import { functionalUpdate, isFunction, makeStateUpdater } from '../utils'
|
|
14
15
|
|
|
@@ -60,6 +61,7 @@ export type CustomFilterFns<TData extends RowData> = Record<
|
|
|
60
61
|
export type FilterFnOption<TData extends RowData> =
|
|
61
62
|
| 'auto'
|
|
62
63
|
| BuiltInFilterFn
|
|
64
|
+
| keyof FilterFns
|
|
63
65
|
| FilterFn<TData>
|
|
64
66
|
|
|
65
67
|
export type FiltersColumnDef<TData extends RowData> = {
|
|
@@ -119,7 +121,13 @@ export type FiltersOptions<TData extends RowData> = {
|
|
|
119
121
|
table: Table<TData>,
|
|
120
122
|
columnId: string
|
|
121
123
|
) => () => undefined | [number, number]
|
|
122
|
-
}
|
|
124
|
+
} & (keyof FilterFns extends never
|
|
125
|
+
? {
|
|
126
|
+
filterFns?: Record<string, FilterFn<any>>
|
|
127
|
+
}
|
|
128
|
+
: {
|
|
129
|
+
filterFns: Record<keyof FilterFns, FilterFn<any>>
|
|
130
|
+
})
|
|
123
131
|
|
|
124
132
|
export type FiltersInstance<TData extends RowData> = {
|
|
125
133
|
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void
|
|
@@ -219,9 +227,8 @@ export const Filters: TableFeature = {
|
|
|
219
227
|
? column.columnDef.filterFn
|
|
220
228
|
: column.columnDef.filterFn === 'auto'
|
|
221
229
|
? column.getAutoFilterFn()
|
|
222
|
-
:
|
|
223
|
-
|
|
224
|
-
] as FilterFn<TData>)
|
|
230
|
+
: table.options.filterFns?.[column.columnDef.filterFn as string] ??
|
|
231
|
+
filterFns[column.columnDef.filterFn as BuiltInFilterFn]
|
|
225
232
|
},
|
|
226
233
|
getCanFilter: () => {
|
|
227
234
|
return (
|
|
@@ -352,7 +359,8 @@ export const Filters: TableFeature = {
|
|
|
352
359
|
? globalFilterFn
|
|
353
360
|
: globalFilterFn === 'auto'
|
|
354
361
|
? table.getGlobalAutoFilterFn()
|
|
355
|
-
:
|
|
362
|
+
: table.options.filterFns?.[globalFilterFn as string] ??
|
|
363
|
+
filterFns[globalFilterFn as BuiltInFilterFn]
|
|
356
364
|
},
|
|
357
365
|
|
|
358
366
|
setColumnFilters: (updater: Updater<ColumnFiltersState>) => {
|
package/src/features/Grouping.ts
CHANGED
|
@@ -10,8 +10,9 @@ import {
|
|
|
10
10
|
Updater,
|
|
11
11
|
ColumnDefTemplate,
|
|
12
12
|
RowData,
|
|
13
|
+
AggregationFns,
|
|
13
14
|
} from '../types'
|
|
14
|
-
import { isFunction, makeStateUpdater
|
|
15
|
+
import { isFunction, makeStateUpdater } from '../utils'
|
|
15
16
|
|
|
16
17
|
export type GroupingState = string[]
|
|
17
18
|
|
|
@@ -29,6 +30,7 @@ export type CustomAggregationFns = Record<string, AggregationFn<any>>
|
|
|
29
30
|
|
|
30
31
|
export type AggregationFnOption<TData extends RowData> =
|
|
31
32
|
| 'auto'
|
|
33
|
+
| keyof AggregationFns
|
|
32
34
|
| BuiltInAggregationFn
|
|
33
35
|
| AggregationFn<TData>
|
|
34
36
|
|
|
@@ -75,7 +77,13 @@ export type GroupingOptions = {
|
|
|
75
77
|
enableGrouping?: boolean
|
|
76
78
|
getGroupedRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
77
79
|
groupedColumnMode?: false | 'reorder' | 'remove'
|
|
78
|
-
}
|
|
80
|
+
} & (keyof AggregationFns extends never
|
|
81
|
+
? {
|
|
82
|
+
aggregationFns?: Record<string, AggregationFn<any>>
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
aggregationFns: Record<keyof AggregationFns, AggregationFn<any>>
|
|
86
|
+
})
|
|
79
87
|
|
|
80
88
|
export type GroupingColumnMode = false | 'reorder' | 'remove'
|
|
81
89
|
|
|
@@ -178,9 +186,12 @@ export const Grouping: TableFeature = {
|
|
|
178
186
|
? column.columnDef.aggregationFn
|
|
179
187
|
: column.columnDef.aggregationFn === 'auto'
|
|
180
188
|
? column.getAutoAggregationFn()
|
|
181
|
-
:
|
|
189
|
+
: table.options.aggregationFns?.[
|
|
190
|
+
column.columnDef.aggregationFn as string
|
|
191
|
+
] ??
|
|
192
|
+
aggregationFns[
|
|
182
193
|
column.columnDef.aggregationFn as BuiltInAggregationFn
|
|
183
|
-
]
|
|
194
|
+
]
|
|
184
195
|
},
|
|
185
196
|
}
|
|
186
197
|
},
|
package/src/features/Sorting.ts
CHANGED
|
@@ -6,9 +6,17 @@ import {
|
|
|
6
6
|
sortingFns,
|
|
7
7
|
} from '../sortingFns'
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
Column,
|
|
11
|
+
OnChangeFn,
|
|
12
|
+
Table,
|
|
13
|
+
Row,
|
|
14
|
+
Updater,
|
|
15
|
+
RowData,
|
|
16
|
+
SortingFns,
|
|
17
|
+
} from '../types'
|
|
10
18
|
|
|
11
|
-
import { isFunction, makeStateUpdater
|
|
19
|
+
import { isFunction, makeStateUpdater } from '../utils'
|
|
12
20
|
|
|
13
21
|
export type SortDirection = 'asc' | 'desc'
|
|
14
22
|
|
|
@@ -34,6 +42,7 @@ export type CustomSortingFns<TData extends RowData> = Record<
|
|
|
34
42
|
|
|
35
43
|
export type SortingFnOption<TData extends RowData> =
|
|
36
44
|
| 'auto'
|
|
45
|
+
| keyof SortingFns
|
|
37
46
|
| BuiltInSortingFn
|
|
38
47
|
| SortingFn<TData>
|
|
39
48
|
|
|
@@ -72,7 +81,13 @@ export type SortingOptions<TData extends RowData> = {
|
|
|
72
81
|
getSortedRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
73
82
|
maxMultiSortColCount?: number
|
|
74
83
|
isMultiSortEvent?: (e: unknown) => boolean
|
|
75
|
-
}
|
|
84
|
+
} & (keyof SortingFns extends never
|
|
85
|
+
? {
|
|
86
|
+
sortingFns?: Record<string, SortingFn<any>>
|
|
87
|
+
}
|
|
88
|
+
: {
|
|
89
|
+
sortingFns: Record<keyof SortingFns, SortingFn<any>>
|
|
90
|
+
})
|
|
76
91
|
|
|
77
92
|
export type SortingInstance<TData extends RowData> = {
|
|
78
93
|
setSorting: (updater: Updater<SortingState>) => void
|
|
@@ -161,9 +176,8 @@ export const Sorting: TableFeature = {
|
|
|
161
176
|
? column.columnDef.sortingFn
|
|
162
177
|
: column.columnDef.sortingFn === 'auto'
|
|
163
178
|
? column.getAutoSortingFn()
|
|
164
|
-
:
|
|
165
|
-
|
|
166
|
-
] as SortingFn<TData>)
|
|
179
|
+
: table.options.sortingFns?.[column.columnDef.sortingFn as string] ??
|
|
180
|
+
sortingFns[column.columnDef.sortingFn as BuiltInSortingFn]
|
|
167
181
|
},
|
|
168
182
|
toggleSorting: (desc, multi) => {
|
|
169
183
|
// if (column.columns.length) {
|
package/src/types.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from './features/Pinning'
|
|
24
24
|
import { CoreHeader, CoreHeaderGroup, HeadersInstance } from './core/headers'
|
|
25
25
|
import {
|
|
26
|
+
FilterFn,
|
|
26
27
|
FiltersColumn,
|
|
27
28
|
FiltersColumnDef,
|
|
28
29
|
FiltersInstance,
|
|
@@ -80,6 +81,9 @@ import { CoreCell } from './core/cell'
|
|
|
80
81
|
export interface TableMeta<TData extends RowData> {}
|
|
81
82
|
export interface ColumnMeta<TData extends RowData, TValue> {}
|
|
82
83
|
export interface FilterMeta {}
|
|
84
|
+
export interface FilterFns {}
|
|
85
|
+
export interface SortingFns {}
|
|
86
|
+
export interface AggregationFns {}
|
|
83
87
|
|
|
84
88
|
export type Updater<T> = T | ((old: T) => T)
|
|
85
89
|
export type OnChangeFn<T> = (updaterOrValue: Updater<T>) => void
|