@tanstack/table-core 8.13.1 → 8.14.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/lib/aggregationFns.d.ts +1 -1
- package/build/lib/aggregationFns.js.map +1 -1
- package/build/lib/core/column.js +1 -1
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.d.ts +1 -2
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.d.ts +7 -11
- package/build/lib/core/table.js +21 -13
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnFaceting.d.ts +34 -0
- package/build/lib/features/ColumnFaceting.js +42 -0
- package/build/lib/features/ColumnFaceting.js.map +1 -0
- package/build/lib/features/{Filters.d.ts → ColumnFiltering.d.ts} +29 -132
- package/build/lib/features/{Filters.js → ColumnFiltering.js} +8 -83
- package/build/lib/features/ColumnFiltering.js.map +1 -0
- package/build/lib/features/{Grouping.d.ts → ColumnGrouping.d.ts} +2 -3
- package/build/lib/features/{Grouping.js → ColumnGrouping.js} +3 -3
- package/build/lib/features/ColumnGrouping.js.map +1 -0
- package/build/lib/features/{Ordering.d.ts → ColumnOrdering.d.ts} +2 -3
- package/build/lib/features/{Ordering.js → ColumnOrdering.js} +9 -9
- package/build/lib/features/ColumnOrdering.js.map +1 -0
- package/build/lib/features/ColumnPinning.d.ts +126 -0
- package/build/lib/features/{Pinning.js → ColumnPinning.js} +4 -115
- package/build/lib/features/ColumnPinning.js.map +1 -0
- package/build/lib/features/ColumnSizing.d.ts +2 -3
- package/build/lib/features/ColumnSizing.js +3 -3
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/{Visibility.d.ts → ColumnVisibility.d.ts} +2 -3
- package/build/lib/features/{Visibility.js → ColumnVisibility.js} +3 -3
- package/build/lib/features/ColumnVisibility.js.map +1 -0
- package/build/lib/features/GlobalFiltering.d.ts +100 -0
- package/build/lib/features/GlobalFiltering.js +85 -0
- package/build/lib/features/GlobalFiltering.js.map +1 -0
- package/build/lib/features/{Expanding.d.ts → RowExpanding.d.ts} +2 -3
- package/build/lib/features/{Expanding.js → RowExpanding.js} +3 -3
- package/build/lib/features/RowExpanding.js.map +1 -0
- package/build/lib/features/{Pagination.d.ts → RowPagination.d.ts} +2 -3
- package/build/lib/features/{Pagination.js → RowPagination.js} +3 -3
- package/build/lib/features/RowPagination.js.map +1 -0
- package/build/lib/features/RowPinning.d.ts +98 -0
- package/build/lib/features/RowPinning.js +145 -0
- package/build/lib/features/RowPinning.js.map +1 -0
- package/build/lib/features/RowSelection.d.ts +1 -2
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/{Sorting.d.ts → RowSorting.d.ts} +5 -3
- package/build/lib/features/{Sorting.js → RowSorting.js} +3 -3
- package/build/lib/features/RowSorting.js.map +1 -0
- package/build/lib/filterFns.d.ts +1 -1
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.d.ts +21 -18
- package/build/lib/index.esm.js +1490 -1446
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +47 -41
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1490 -1446
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/sortingFns.d.ts +1 -1
- package/build/lib/sortingFns.js.map +1 -1
- package/build/lib/types.d.ts +30 -16
- package/build/lib/utils/getFilteredRowModel.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +1500 -1453
- 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/core/column.ts +2 -2
- package/src/core/headers.ts +9 -3
- package/src/core/row.ts +1 -1
- package/src/core/table.ts +40 -32
- package/src/features/ColumnFaceting.ts +84 -0
- package/src/features/{Filters.ts → ColumnFiltering.ts} +44 -279
- package/src/features/{Grouping.ts → ColumnGrouping.ts} +6 -6
- package/src/features/{Ordering.ts → ColumnOrdering.ts} +11 -5
- package/src/features/ColumnPinning.ts +336 -0
- package/src/features/ColumnSizing.ts +10 -3
- package/src/features/{Visibility.ts → ColumnVisibility.ts} +2 -2
- package/src/features/GlobalFiltering.ts +218 -0
- package/src/features/{Expanding.ts → RowExpanding.ts} +9 -3
- package/src/features/{Pagination.ts → RowPagination.ts} +9 -3
- package/src/features/RowPinning.ts +273 -0
- package/src/features/RowSelection.ts +9 -2
- package/src/features/{Sorting.ts → RowSorting.ts} +5 -2
- package/src/filterFns.ts +1 -1
- package/src/index.ts +30 -18
- package/src/sortingFns.ts +1 -1
- package/src/types.ts +60 -23
- package/src/utils/getFilteredRowModel.ts +1 -1
- package/src/utils/getSortedRowModel.ts +1 -1
- package/src/utils.ts +9 -11
- package/build/lib/features/Expanding.js.map +0 -1
- package/build/lib/features/Filters.js.map +0 -1
- package/build/lib/features/Grouping.js.map +0 -1
- package/build/lib/features/Ordering.js.map +0 -1
- package/build/lib/features/Pagination.js.map +0 -1
- package/build/lib/features/Pinning.d.ts +0 -222
- package/build/lib/features/Pinning.js.map +0 -1
- package/build/lib/features/Sorting.js.map +0 -1
- package/build/lib/features/Visibility.js.map +0 -1
- package/src/features/Pinning.ts +0 -573
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { RowModel } from '..'
|
|
2
|
-
import { TableFeature } from '../core/table'
|
|
3
2
|
import { BuiltInFilterFn, filterFns } from '../filterFns'
|
|
4
3
|
import {
|
|
5
4
|
Column,
|
|
5
|
+
FilterFns,
|
|
6
|
+
FilterMeta,
|
|
6
7
|
OnChangeFn,
|
|
7
|
-
Table,
|
|
8
8
|
Row,
|
|
9
|
-
Updater,
|
|
10
9
|
RowData,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Table,
|
|
11
|
+
TableFeature,
|
|
12
|
+
Updater,
|
|
13
13
|
} from '../types'
|
|
14
14
|
import { functionalUpdate, isFunction, makeStateUpdater } from '../utils'
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface ColumnFiltersTableState {
|
|
17
17
|
columnFilters: ColumnFiltersState
|
|
18
|
-
globalFilter: any
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export type ColumnFiltersState = ColumnFilter[]
|
|
@@ -26,9 +25,9 @@ export interface ColumnFilter {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
export interface ResolvedColumnFilter<TData extends RowData> {
|
|
28
|
+
filterFn: FilterFn<TData>
|
|
29
29
|
id: string
|
|
30
30
|
resolvedValue: unknown
|
|
31
|
-
filterFn: FilterFn<TData>
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
export interface FilterFn<TData extends RowData> {
|
|
@@ -38,9 +37,8 @@ export interface FilterFn<TData extends RowData> {
|
|
|
38
37
|
filterValue: any,
|
|
39
38
|
addMeta: (meta: FilterMeta) => void
|
|
40
39
|
): boolean
|
|
41
|
-
|
|
42
|
-
resolveFilterValue?: TransformFilterValueFn<TData>
|
|
43
40
|
autoRemove?: ColumnFilterAutoRemoveTestFn<TData>
|
|
41
|
+
resolveFilterValue?: TransformFilterValueFn<TData>
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export type TransformFilterValueFn<TData extends RowData> = (
|
|
@@ -64,13 +62,7 @@ export type FilterFnOption<TData extends RowData> =
|
|
|
64
62
|
| keyof FilterFns
|
|
65
63
|
| FilterFn<TData>
|
|
66
64
|
|
|
67
|
-
export interface
|
|
68
|
-
/**
|
|
69
|
-
* The filter function to use with this column. Can be the name of a built-in filter function or a custom filter function.
|
|
70
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#filterfn)
|
|
71
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
72
|
-
*/
|
|
73
|
-
filterFn?: FilterFnOption<TData>
|
|
65
|
+
export interface ColumnFiltersColumnDef<TData extends RowData> {
|
|
74
66
|
/**
|
|
75
67
|
* Enables/disables the **column** filter for this column.
|
|
76
68
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enablecolumnfilter)
|
|
@@ -78,17 +70,14 @@ export interface FiltersColumnDef<TData extends RowData> {
|
|
|
78
70
|
*/
|
|
79
71
|
enableColumnFilter?: boolean
|
|
80
72
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#
|
|
73
|
+
* The filter function to use with this column. Can be the name of a built-in filter function or a custom filter function.
|
|
74
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#filterfn)
|
|
83
75
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
84
76
|
*/
|
|
85
|
-
|
|
77
|
+
filterFn?: FilterFnOption<TData>
|
|
86
78
|
}
|
|
87
79
|
|
|
88
|
-
export interface
|
|
89
|
-
_getFacetedMinMaxValues?: () => undefined | [number, number]
|
|
90
|
-
_getFacetedRowModel?: () => RowModel<TData>
|
|
91
|
-
_getFacetedUniqueValues?: () => Map<any, number>
|
|
80
|
+
export interface ColumnFiltersColumn<TData extends RowData> {
|
|
92
81
|
/**
|
|
93
82
|
* Returns an automatically calculated filter function for the column based off of the columns first known value.
|
|
94
83
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getautofilterfn)
|
|
@@ -101,33 +90,6 @@ export interface FiltersColumn<TData extends RowData> {
|
|
|
101
90
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
102
91
|
*/
|
|
103
92
|
getCanFilter: () => boolean
|
|
104
|
-
/**
|
|
105
|
-
* Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.
|
|
106
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getcanglobalfilter)
|
|
107
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
108
|
-
*/
|
|
109
|
-
getCanGlobalFilter: () => boolean
|
|
110
|
-
/**
|
|
111
|
-
* A function that **computes and returns** a min/max tuple derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.
|
|
112
|
-
* > ⚠️ Requires that you pass a valid `getFacetedMinMaxValues` function to `options.getFacetedMinMaxValues`. A default implementation is provided via the exported `getFacetedMinMaxValues` function.
|
|
113
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getfacetedminmaxvalues)
|
|
114
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
115
|
-
*/
|
|
116
|
-
getFacetedMinMaxValues: () => undefined | [number, number]
|
|
117
|
-
/**
|
|
118
|
-
* Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts.
|
|
119
|
-
* > ⚠️ Requires that you pass a valid `getFacetedRowModel` function to `options.facetedRowModel`. A default implementation is provided via the exported `getFacetedRowModel` function.
|
|
120
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getfacetedrowmodel)
|
|
121
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
122
|
-
*/
|
|
123
|
-
getFacetedRowModel: () => RowModel<TData>
|
|
124
|
-
/**
|
|
125
|
-
* A function that **computes and returns** a `Map` of unique values and their occurrences derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.
|
|
126
|
-
* > ⚠️ Requires that you pass a valid `getFacetedUniqueValues` function to `options.getFacetedUniqueValues`. A default implementation is provided via the exported `getFacetedUniqueValues` function.
|
|
127
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getfaceteduniquevalues)
|
|
128
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
129
|
-
*/
|
|
130
|
-
getFacetedUniqueValues: () => Map<any, number>
|
|
131
93
|
/**
|
|
132
94
|
* Returns the filter function (either user-defined or automatic, depending on configuration) for the columnId specified.
|
|
133
95
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getfilterfn)
|
|
@@ -160,7 +122,7 @@ export interface FiltersColumn<TData extends RowData> {
|
|
|
160
122
|
setFilterValue: (updater: Updater<any>) => void
|
|
161
123
|
}
|
|
162
124
|
|
|
163
|
-
export interface
|
|
125
|
+
export interface ColumnFiltersRow<TData extends RowData> {
|
|
164
126
|
/**
|
|
165
127
|
* The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
|
|
166
128
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#columnfilters)
|
|
@@ -175,7 +137,13 @@ export interface FiltersRow<TData extends RowData> {
|
|
|
175
137
|
columnFiltersMeta: Record<string, FilterMeta>
|
|
176
138
|
}
|
|
177
139
|
|
|
178
|
-
interface
|
|
140
|
+
interface ColumnFiltersOptionsBase<TData extends RowData> {
|
|
141
|
+
/**
|
|
142
|
+
* Enables/disables **column** filtering for all columns.
|
|
143
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enablecolumnfilters)
|
|
144
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
145
|
+
*/
|
|
146
|
+
enableColumnFilters?: boolean
|
|
179
147
|
/**
|
|
180
148
|
* Enables/disables all filtering for the table.
|
|
181
149
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enablefilters)
|
|
@@ -210,65 +178,12 @@ interface FiltersOptionsBase<TData extends RowData> {
|
|
|
210
178
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
211
179
|
*/
|
|
212
180
|
maxLeafRowFilterDepth?: number
|
|
213
|
-
|
|
214
|
-
// Column
|
|
215
|
-
/**
|
|
216
|
-
* Enables/disables **column** filtering for all columns.
|
|
217
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enablecolumnfilters)
|
|
218
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
219
|
-
*/
|
|
220
|
-
enableColumnFilters?: boolean
|
|
221
181
|
/**
|
|
222
182
|
* If provided, this function will be called with an `updaterFn` when `state.columnFilters` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
|
|
223
183
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#oncolumnfilterschange)
|
|
224
184
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
225
185
|
*/
|
|
226
186
|
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>
|
|
227
|
-
|
|
228
|
-
// Global
|
|
229
|
-
/**
|
|
230
|
-
* Enables/disables **global** filtering for all columns.
|
|
231
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enableglobalfilter)
|
|
232
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
233
|
-
*/
|
|
234
|
-
enableGlobalFilter?: boolean
|
|
235
|
-
/**
|
|
236
|
-
* If provided, this function will be called with the column and should return `true` or `false` to indicate whether this column should be used for global filtering.
|
|
237
|
-
*
|
|
238
|
-
* This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).
|
|
239
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getcolumncanglobalfilter)
|
|
240
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
241
|
-
*/
|
|
242
|
-
getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean
|
|
243
|
-
/**
|
|
244
|
-
* The filter function to use for global filtering.
|
|
245
|
-
* - A `string` referencing a built-in filter function
|
|
246
|
-
* - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option
|
|
247
|
-
* - A custom filter function
|
|
248
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#globalfilterfn)
|
|
249
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
250
|
-
*/
|
|
251
|
-
globalFilterFn?: FilterFnOption<TData>
|
|
252
|
-
/**
|
|
253
|
-
* If provided, this function will be called with an `updaterFn` when `state.globalFilter` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
|
|
254
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#onglobalfilterchange)
|
|
255
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
256
|
-
*/
|
|
257
|
-
onGlobalFilterChange?: OnChangeFn<any>
|
|
258
|
-
|
|
259
|
-
// Faceting
|
|
260
|
-
getFacetedRowModel?: (
|
|
261
|
-
table: Table<TData>,
|
|
262
|
-
columnId: string
|
|
263
|
-
) => () => RowModel<TData>
|
|
264
|
-
getFacetedUniqueValues?: (
|
|
265
|
-
table: Table<TData>,
|
|
266
|
-
columnId: string
|
|
267
|
-
) => () => Map<any, number>
|
|
268
|
-
getFacetedMinMaxValues?: (
|
|
269
|
-
table: Table<TData>,
|
|
270
|
-
columnId: string
|
|
271
|
-
) => () => undefined | [number, number]
|
|
272
187
|
}
|
|
273
188
|
|
|
274
189
|
type ResolvedFilterFns = keyof FilterFns extends never
|
|
@@ -279,25 +194,11 @@ type ResolvedFilterFns = keyof FilterFns extends never
|
|
|
279
194
|
filterFns: Record<keyof FilterFns, FilterFn<any>>
|
|
280
195
|
}
|
|
281
196
|
|
|
282
|
-
export interface
|
|
283
|
-
extends
|
|
197
|
+
export interface ColumnFiltersOptions<TData extends RowData>
|
|
198
|
+
extends ColumnFiltersOptionsBase<TData>,
|
|
284
199
|
ResolvedFilterFns {}
|
|
285
200
|
|
|
286
|
-
export interface
|
|
287
|
-
/**
|
|
288
|
-
* Sets or updates the `state.columnFilters` state.
|
|
289
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#setcolumnfilters)
|
|
290
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
291
|
-
*/
|
|
292
|
-
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void
|
|
293
|
-
/**
|
|
294
|
-
* Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.
|
|
295
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#resetcolumnfilters)
|
|
296
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
297
|
-
*/
|
|
298
|
-
resetColumnFilters: (defaultState?: boolean) => void
|
|
299
|
-
|
|
300
|
-
// Column Filters
|
|
201
|
+
export interface ColumnFiltersInstance<TData extends RowData> {
|
|
301
202
|
_getFilteredRowModel?: () => RowModel<TData>
|
|
302
203
|
/**
|
|
303
204
|
* Returns the row model for the table after **column** filtering has been applied.
|
|
@@ -311,47 +212,24 @@ export interface FiltersInstance<TData extends RowData> {
|
|
|
311
212
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
312
213
|
*/
|
|
313
214
|
getPreFilteredRowModel: () => RowModel<TData>
|
|
314
|
-
|
|
315
|
-
// Global Filters
|
|
316
|
-
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number]
|
|
317
|
-
_getGlobalFacetedRowModel?: () => RowModel<TData>
|
|
318
|
-
_getGlobalFacetedUniqueValues?: () => Map<any, number>
|
|
319
|
-
/**
|
|
320
|
-
* Currently, this function returns the built-in `includesString` filter function. In future releases, it may return more dynamic filter functions based on the nature of the data provided.
|
|
321
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalautofilterfn)
|
|
322
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
323
|
-
*/
|
|
324
|
-
getGlobalAutoFilterFn: () => FilterFn<TData> | undefined
|
|
325
|
-
/**
|
|
326
|
-
* Returns the faceted min and max values for the global filter.
|
|
327
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedminmaxvalues)
|
|
328
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
329
|
-
*/
|
|
330
|
-
getGlobalFacetedMinMaxValues: () => undefined | [number, number]
|
|
331
|
-
/**
|
|
332
|
-
* Returns the row model for the table after **global** filtering has been applied.
|
|
333
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedrowmodel)
|
|
334
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
335
|
-
*/
|
|
336
|
-
getGlobalFacetedRowModel: () => RowModel<TData>
|
|
337
|
-
/**
|
|
338
|
-
* Returns the faceted unique values for the global filter.
|
|
339
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfaceteduniquevalues)
|
|
340
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
341
|
-
*/
|
|
342
|
-
getGlobalFacetedUniqueValues: () => Map<any, number>
|
|
343
215
|
/**
|
|
344
|
-
*
|
|
345
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#
|
|
216
|
+
* Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.
|
|
217
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#resetcolumnfilters)
|
|
346
218
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
347
219
|
*/
|
|
348
|
-
|
|
220
|
+
resetColumnFilters: (defaultState?: boolean) => void
|
|
349
221
|
/**
|
|
350
222
|
* Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.
|
|
351
223
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#resetglobalfilter)
|
|
352
224
|
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
353
225
|
*/
|
|
354
226
|
resetGlobalFilter: (defaultState?: boolean) => void
|
|
227
|
+
/**
|
|
228
|
+
* Sets or updates the `state.columnFilters` state.
|
|
229
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#setcolumnfilters)
|
|
230
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
231
|
+
*/
|
|
232
|
+
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void
|
|
355
233
|
/**
|
|
356
234
|
* Sets or updates the `state.globalFilter` state.
|
|
357
235
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#setglobalfilter)
|
|
@@ -362,41 +240,30 @@ export interface FiltersInstance<TData extends RowData> {
|
|
|
362
240
|
|
|
363
241
|
//
|
|
364
242
|
|
|
365
|
-
export const
|
|
366
|
-
getDefaultColumnDef: <
|
|
243
|
+
export const ColumnFiltering: TableFeature = {
|
|
244
|
+
getDefaultColumnDef: <
|
|
245
|
+
TData extends RowData,
|
|
246
|
+
>(): ColumnFiltersColumnDef<TData> => {
|
|
367
247
|
return {
|
|
368
248
|
filterFn: 'auto',
|
|
369
249
|
}
|
|
370
250
|
},
|
|
371
251
|
|
|
372
|
-
getInitialState: (state):
|
|
252
|
+
getInitialState: (state): ColumnFiltersTableState => {
|
|
373
253
|
return {
|
|
374
254
|
columnFilters: [],
|
|
375
|
-
globalFilter: undefined,
|
|
376
|
-
// filtersProgress: 1,
|
|
377
|
-
// facetProgress: {},
|
|
378
255
|
...state,
|
|
379
256
|
}
|
|
380
257
|
},
|
|
381
258
|
|
|
382
259
|
getDefaultOptions: <TData extends RowData>(
|
|
383
260
|
table: Table<TData>
|
|
384
|
-
):
|
|
261
|
+
): ColumnFiltersOptions<TData> => {
|
|
385
262
|
return {
|
|
386
263
|
onColumnFiltersChange: makeStateUpdater('columnFilters', table),
|
|
387
|
-
onGlobalFilterChange: makeStateUpdater('globalFilter', table),
|
|
388
264
|
filterFromLeafRows: false,
|
|
389
265
|
maxLeafRowFilterDepth: 100,
|
|
390
|
-
|
|
391
|
-
getColumnCanGlobalFilter: column => {
|
|
392
|
-
const value = table
|
|
393
|
-
.getCoreRowModel()
|
|
394
|
-
.flatRows[0]?._getAllCellsByColumnId()
|
|
395
|
-
[column.id]?.getValue()
|
|
396
|
-
|
|
397
|
-
return typeof value === 'string' || typeof value === 'number'
|
|
398
|
-
},
|
|
399
|
-
} as FiltersOptions<TData>
|
|
266
|
+
} as ColumnFiltersOptions<TData>
|
|
400
267
|
},
|
|
401
268
|
|
|
402
269
|
createColumn: <TData extends RowData>(
|
|
@@ -448,16 +315,6 @@ export const Filters: TableFeature = {
|
|
|
448
315
|
)
|
|
449
316
|
}
|
|
450
317
|
|
|
451
|
-
column.getCanGlobalFilter = () => {
|
|
452
|
-
return (
|
|
453
|
-
(column.columnDef.enableGlobalFilter ?? true) &&
|
|
454
|
-
(table.options.enableGlobalFilter ?? true) &&
|
|
455
|
-
(table.options.enableFilters ?? true) &&
|
|
456
|
-
(table.options.getColumnCanGlobalFilter?.(column) ?? true) &&
|
|
457
|
-
!!column.accessorFn
|
|
458
|
-
)
|
|
459
|
-
}
|
|
460
|
-
|
|
461
318
|
column.getIsFiltered = () => column.getFilterIndex() > -1
|
|
462
319
|
|
|
463
320
|
column.getFilterValue = () =>
|
|
@@ -469,11 +326,11 @@ export const Filters: TableFeature = {
|
|
|
469
326
|
column.setFilterValue = value => {
|
|
470
327
|
table.setColumnFilters(old => {
|
|
471
328
|
const filterFn = column.getFilterFn()
|
|
472
|
-
const
|
|
329
|
+
const previousFilter = old?.find(d => d.id === column.id)
|
|
473
330
|
|
|
474
331
|
const newFilter = functionalUpdate(
|
|
475
332
|
value,
|
|
476
|
-
|
|
333
|
+
previousFilter ? previousFilter.value : undefined
|
|
477
334
|
)
|
|
478
335
|
|
|
479
336
|
//
|
|
@@ -485,7 +342,7 @@ export const Filters: TableFeature = {
|
|
|
485
342
|
|
|
486
343
|
const newFilterObj = { id: column.id, value: newFilter }
|
|
487
344
|
|
|
488
|
-
if (
|
|
345
|
+
if (previousFilter) {
|
|
489
346
|
return (
|
|
490
347
|
old?.map(d => {
|
|
491
348
|
if (d.id === column.id) {
|
|
@@ -503,65 +360,17 @@ export const Filters: TableFeature = {
|
|
|
503
360
|
return [newFilterObj]
|
|
504
361
|
})
|
|
505
362
|
}
|
|
506
|
-
column._getFacetedRowModel =
|
|
507
|
-
table.options.getFacetedRowModel &&
|
|
508
|
-
table.options.getFacetedRowModel(table, column.id)
|
|
509
|
-
column.getFacetedRowModel = () => {
|
|
510
|
-
if (!column._getFacetedRowModel) {
|
|
511
|
-
return table.getPreFilteredRowModel()
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return column._getFacetedRowModel()
|
|
515
|
-
}
|
|
516
|
-
column._getFacetedUniqueValues =
|
|
517
|
-
table.options.getFacetedUniqueValues &&
|
|
518
|
-
table.options.getFacetedUniqueValues(table, column.id)
|
|
519
|
-
column.getFacetedUniqueValues = () => {
|
|
520
|
-
if (!column._getFacetedUniqueValues) {
|
|
521
|
-
return new Map()
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return column._getFacetedUniqueValues()
|
|
525
|
-
}
|
|
526
|
-
column._getFacetedMinMaxValues =
|
|
527
|
-
table.options.getFacetedMinMaxValues &&
|
|
528
|
-
table.options.getFacetedMinMaxValues(table, column.id)
|
|
529
|
-
column.getFacetedMinMaxValues = () => {
|
|
530
|
-
if (!column._getFacetedMinMaxValues) {
|
|
531
|
-
return undefined
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
return column._getFacetedMinMaxValues()
|
|
535
|
-
}
|
|
536
|
-
// () => [column.getFacetedRowModel()],
|
|
537
|
-
// facetedRowModel => getRowModelMinMaxValues(facetedRowModel, column.id),
|
|
538
363
|
},
|
|
539
364
|
|
|
540
365
|
createRow: <TData extends RowData>(
|
|
541
366
|
row: Row<TData>,
|
|
542
|
-
|
|
367
|
+
_table: Table<TData>
|
|
543
368
|
): void => {
|
|
544
369
|
row.columnFilters = {}
|
|
545
370
|
row.columnFiltersMeta = {}
|
|
546
371
|
},
|
|
547
372
|
|
|
548
373
|
createTable: <TData extends RowData>(table: Table<TData>): void => {
|
|
549
|
-
table.getGlobalAutoFilterFn = () => {
|
|
550
|
-
return filterFns.includesString
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
table.getGlobalFilterFn = () => {
|
|
554
|
-
const { globalFilterFn: globalFilterFn } = table.options
|
|
555
|
-
|
|
556
|
-
return isFunction(globalFilterFn)
|
|
557
|
-
? globalFilterFn
|
|
558
|
-
: globalFilterFn === 'auto'
|
|
559
|
-
? table.getGlobalAutoFilterFn()
|
|
560
|
-
: // @ts-ignore
|
|
561
|
-
table.options.filterFns?.[globalFilterFn as string] ??
|
|
562
|
-
filterFns[globalFilterFn as BuiltInFilterFn]
|
|
563
|
-
}
|
|
564
|
-
|
|
565
374
|
table.setColumnFilters = (updater: Updater<ColumnFiltersState>) => {
|
|
566
375
|
const leafColumns = table.getAllLeafColumns()
|
|
567
376
|
|
|
@@ -584,16 +393,6 @@ export const Filters: TableFeature = {
|
|
|
584
393
|
table.options.onColumnFiltersChange?.(updateFn)
|
|
585
394
|
}
|
|
586
395
|
|
|
587
|
-
table.setGlobalFilter = updater => {
|
|
588
|
-
table.options.onGlobalFilterChange?.(updater)
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
table.resetGlobalFilter = defaultState => {
|
|
592
|
-
table.setGlobalFilter(
|
|
593
|
-
defaultState ? undefined : table.initialState.globalFilter
|
|
594
|
-
)
|
|
595
|
-
}
|
|
596
|
-
|
|
597
396
|
table.resetColumnFilters = defaultState => {
|
|
598
397
|
table.setColumnFilters(
|
|
599
398
|
defaultState ? [] : table.initialState?.columnFilters ?? []
|
|
@@ -612,40 +411,6 @@ export const Filters: TableFeature = {
|
|
|
612
411
|
|
|
613
412
|
return table._getFilteredRowModel()
|
|
614
413
|
}
|
|
615
|
-
|
|
616
|
-
table._getGlobalFacetedRowModel =
|
|
617
|
-
table.options.getFacetedRowModel &&
|
|
618
|
-
table.options.getFacetedRowModel(table, '__global__')
|
|
619
|
-
|
|
620
|
-
table.getGlobalFacetedRowModel = () => {
|
|
621
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
622
|
-
return table.getPreFilteredRowModel()
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
return table._getGlobalFacetedRowModel()
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
table._getGlobalFacetedUniqueValues =
|
|
629
|
-
table.options.getFacetedUniqueValues &&
|
|
630
|
-
table.options.getFacetedUniqueValues(table, '__global__')
|
|
631
|
-
table.getGlobalFacetedUniqueValues = () => {
|
|
632
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
|
633
|
-
return new Map()
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
return table._getGlobalFacetedUniqueValues()
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
table._getGlobalFacetedMinMaxValues =
|
|
640
|
-
table.options.getFacetedMinMaxValues &&
|
|
641
|
-
table.options.getFacetedMinMaxValues(table, '__global__')
|
|
642
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
|
643
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
|
644
|
-
return
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
return table._getGlobalFacetedMinMaxValues()
|
|
648
|
-
}
|
|
649
414
|
},
|
|
650
415
|
}
|
|
651
416
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { RowModel } from '..'
|
|
2
2
|
import { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'
|
|
3
|
-
import { TableFeature } from '../core/table'
|
|
4
3
|
import {
|
|
4
|
+
AggregationFns,
|
|
5
5
|
Cell,
|
|
6
6
|
Column,
|
|
7
|
+
ColumnDefTemplate,
|
|
7
8
|
OnChangeFn,
|
|
8
|
-
Table,
|
|
9
9
|
Row,
|
|
10
|
-
Updater,
|
|
11
|
-
ColumnDefTemplate,
|
|
12
10
|
RowData,
|
|
13
|
-
|
|
11
|
+
Table,
|
|
12
|
+
TableFeature,
|
|
13
|
+
Updater,
|
|
14
14
|
} from '../types'
|
|
15
15
|
import { isFunction, makeStateUpdater } from '../utils'
|
|
16
16
|
|
|
@@ -239,7 +239,7 @@ export interface GroupingInstance<TData extends RowData> {
|
|
|
239
239
|
|
|
240
240
|
//
|
|
241
241
|
|
|
242
|
-
export const
|
|
242
|
+
export const ColumnGrouping: TableFeature = {
|
|
243
243
|
getDefaultColumnDef: <TData extends RowData>(): GroupingColumnDef<
|
|
244
244
|
TData,
|
|
245
245
|
unknown
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { getMemoOptions, makeStateUpdater, memo } from '../utils'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
Column,
|
|
5
|
+
OnChangeFn,
|
|
6
|
+
RowData,
|
|
7
|
+
Table,
|
|
8
|
+
TableFeature,
|
|
9
|
+
Updater,
|
|
10
|
+
} from '../types'
|
|
11
|
+
|
|
12
|
+
import { orderColumns } from './ColumnGrouping'
|
|
7
13
|
import { ColumnPinningPosition, _getVisibleLeafColumns } from '..'
|
|
8
14
|
|
|
9
15
|
export interface ColumnOrderTableState {
|
|
@@ -66,7 +72,7 @@ export interface ColumnOrderInstance<TData extends RowData> {
|
|
|
66
72
|
|
|
67
73
|
//
|
|
68
74
|
|
|
69
|
-
export const
|
|
75
|
+
export const ColumnOrdering: TableFeature = {
|
|
70
76
|
getInitialState: (state): ColumnOrderTableState => {
|
|
71
77
|
return {
|
|
72
78
|
columnOrder: [],
|