@tanstack/table-core 8.14.0 → 8.15.1
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/core/row.d.ts +1 -1
- package/build/lib/core/table.js +5 -2
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnFaceting.d.ts +6 -6
- package/build/lib/features/ColumnFaceting.js.map +1 -1
- package/build/lib/features/ColumnFiltering.d.ts +48 -48
- package/build/lib/features/ColumnFiltering.js.map +1 -1
- package/build/lib/features/GlobalFaceting.d.ts +26 -0
- package/build/lib/features/GlobalFaceting.js +42 -0
- package/build/lib/features/GlobalFaceting.js.map +1 -0
- package/build/lib/features/GlobalFiltering.d.ts +21 -42
- package/build/lib/features/GlobalFiltering.js +1 -23
- package/build/lib/features/GlobalFiltering.js.map +1 -1
- package/build/lib/index.d.ts +1 -0
- package/build/lib/index.esm.js +34 -26
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +2 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +34 -26
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/types.d.ts +3 -2
- package/build/umd/index.development.js +34 -25
- 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/core/table.ts +3 -1
- package/src/features/ColumnFaceting.ts +6 -6
- package/src/features/ColumnFiltering.ts +48 -48
- package/src/features/GlobalFaceting.ts +66 -0
- package/src/features/GlobalFiltering.ts +22 -78
- package/src/index.ts +1 -0
- package/src/types.ts +6 -2
package/package.json
CHANGED
package/src/core/table.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { ColumnOrdering } from '../features/ColumnOrdering'
|
|
|
30
30
|
import { ColumnPinning } from '../features/ColumnPinning'
|
|
31
31
|
import { ColumnSizing } from '../features/ColumnSizing'
|
|
32
32
|
import { ColumnVisibility } from '../features/ColumnVisibility'
|
|
33
|
+
import { GlobalFaceting } from '../features/GlobalFaceting'
|
|
33
34
|
import { GlobalFiltering } from '../features/GlobalFiltering'
|
|
34
35
|
import { RowExpanding } from '../features/RowExpanding'
|
|
35
36
|
import { RowPagination } from '../features/RowPagination'
|
|
@@ -44,7 +45,8 @@ const builtInFeatures = [
|
|
|
44
45
|
ColumnPinning,
|
|
45
46
|
ColumnFaceting,
|
|
46
47
|
ColumnFiltering,
|
|
47
|
-
|
|
48
|
+
GlobalFaceting, //depends on ColumnFaceting
|
|
49
|
+
GlobalFiltering, //depends on ColumnFiltering
|
|
48
50
|
RowSorting,
|
|
49
51
|
ColumnGrouping, //depends on RowSorting
|
|
50
52
|
RowExpanding,
|
|
@@ -8,22 +8,22 @@ export interface FacetedColumn<TData extends RowData> {
|
|
|
8
8
|
/**
|
|
9
9
|
* A function that **computes and returns** a min/max tuple derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.
|
|
10
10
|
* > ⚠️ Requires that you pass a valid `getFacetedMinMaxValues` function to `options.getFacetedMinMaxValues`. A default implementation is provided via the exported `getFacetedMinMaxValues` function.
|
|
11
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
12
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
11
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedminmaxvalues)
|
|
12
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
|
|
13
13
|
*/
|
|
14
14
|
getFacetedMinMaxValues: () => undefined | [number, number]
|
|
15
15
|
/**
|
|
16
16
|
* Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts.
|
|
17
17
|
* > ⚠️ Requires that you pass a valid `getFacetedRowModel` function to `options.facetedRowModel`. A default implementation is provided via the exported `getFacetedRowModel` function.
|
|
18
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
19
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
18
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedrowmodel)
|
|
19
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
|
|
20
20
|
*/
|
|
21
21
|
getFacetedRowModel: () => RowModel<TData>
|
|
22
22
|
/**
|
|
23
23
|
* A function that **computes and returns** a `Map` of unique values and their occurrences derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.
|
|
24
24
|
* > ⚠️ Requires that you pass a valid `getFacetedUniqueValues` function to `options.getFacetedUniqueValues`. A default implementation is provided via the exported `getFacetedUniqueValues` function.
|
|
25
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
26
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
25
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfaceteduniquevalues)
|
|
26
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)
|
|
27
27
|
*/
|
|
28
28
|
getFacetedUniqueValues: () => Map<any, number>
|
|
29
29
|
}
|
|
@@ -65,14 +65,14 @@ export type FilterFnOption<TData extends RowData> =
|
|
|
65
65
|
export interface ColumnFiltersColumnDef<TData extends RowData> {
|
|
66
66
|
/**
|
|
67
67
|
* Enables/disables the **column** filter for this column.
|
|
68
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
69
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
68
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilter)
|
|
69
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
70
70
|
*/
|
|
71
71
|
enableColumnFilter?: boolean
|
|
72
72
|
/**
|
|
73
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/
|
|
75
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
74
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfn)
|
|
75
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
76
76
|
*/
|
|
77
77
|
filterFn?: FilterFnOption<TData>
|
|
78
78
|
}
|
|
@@ -80,44 +80,44 @@ export interface ColumnFiltersColumnDef<TData extends RowData> {
|
|
|
80
80
|
export interface ColumnFiltersColumn<TData extends RowData> {
|
|
81
81
|
/**
|
|
82
82
|
* Returns an automatically calculated filter function for the column based off of the columns first known value.
|
|
83
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
84
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
83
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getautofilterfn)
|
|
84
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
85
85
|
*/
|
|
86
86
|
getAutoFilterFn: () => FilterFn<TData> | undefined
|
|
87
87
|
/**
|
|
88
88
|
* Returns whether or not the column can be **column** filtered.
|
|
89
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
90
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
89
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getcanfilter)
|
|
90
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
91
91
|
*/
|
|
92
92
|
getCanFilter: () => boolean
|
|
93
93
|
/**
|
|
94
94
|
* Returns the filter function (either user-defined or automatic, depending on configuration) for the columnId specified.
|
|
95
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
96
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
95
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterfn)
|
|
96
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
97
97
|
*/
|
|
98
98
|
getFilterFn: () => FilterFn<TData> | undefined
|
|
99
99
|
/**
|
|
100
100
|
* Returns the index (including `-1`) of the column filter in the table's `state.columnFilters` array.
|
|
101
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
102
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
101
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterindex)
|
|
102
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
103
103
|
*/
|
|
104
104
|
getFilterIndex: () => number
|
|
105
105
|
/**
|
|
106
106
|
* Returns the current filter value for the column.
|
|
107
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
108
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
107
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfiltervalue)
|
|
108
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
109
109
|
*/
|
|
110
110
|
getFilterValue: () => unknown
|
|
111
111
|
/**
|
|
112
112
|
* Returns whether or not the column is currently filtered.
|
|
113
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
114
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
113
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getisfiltered)
|
|
114
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
115
115
|
*/
|
|
116
116
|
getIsFiltered: () => boolean
|
|
117
117
|
/**
|
|
118
118
|
* A function that sets the current filter value for the column. You can pass it a value or an updater function for immutability-safe operations on existing values.
|
|
119
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
120
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
119
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setfiltervalue)
|
|
120
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
121
121
|
*/
|
|
122
122
|
setFilterValue: (updater: Updater<any>) => void
|
|
123
123
|
}
|
|
@@ -125,14 +125,14 @@ export interface ColumnFiltersColumn<TData extends RowData> {
|
|
|
125
125
|
export interface ColumnFiltersRow<TData extends RowData> {
|
|
126
126
|
/**
|
|
127
127
|
* The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
|
|
128
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
129
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
128
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfilters)
|
|
129
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
130
130
|
*/
|
|
131
131
|
columnFilters: Record<string, boolean>
|
|
132
132
|
/**
|
|
133
133
|
* The column filters meta map for the row. This object tracks any filter meta for a row as optionally provided during the filtering process.
|
|
134
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
135
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
134
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfiltersmeta)
|
|
135
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
136
136
|
*/
|
|
137
137
|
columnFiltersMeta: Record<string, FilterMeta>
|
|
138
138
|
}
|
|
@@ -140,48 +140,48 @@ export interface ColumnFiltersRow<TData extends RowData> {
|
|
|
140
140
|
interface ColumnFiltersOptionsBase<TData extends RowData> {
|
|
141
141
|
/**
|
|
142
142
|
* Enables/disables **column** filtering for all columns.
|
|
143
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
144
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
143
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilters)
|
|
144
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
145
145
|
*/
|
|
146
146
|
enableColumnFilters?: boolean
|
|
147
147
|
/**
|
|
148
148
|
* Enables/disables all filtering for the table.
|
|
149
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
150
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
149
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablefilters)
|
|
150
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
151
151
|
*/
|
|
152
152
|
enableFilters?: boolean
|
|
153
153
|
/**
|
|
154
154
|
* By default, filtering is done from parent rows down (so if a parent row is filtered out, all of its children will be filtered out as well). Setting this option to `true` will cause filtering to be done from leaf rows up (which means parent rows will be included so long as one of their child or grand-child rows is also included).
|
|
155
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
156
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
155
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfromleafrows)
|
|
156
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
157
157
|
*/
|
|
158
158
|
filterFromLeafRows?: boolean
|
|
159
159
|
/**
|
|
160
160
|
* If provided, this function is called **once** per table and should return a **new function** which will calculate and return the row model for the table when it's filtered.
|
|
161
161
|
* - For server-side filtering, this function is unnecessary and can be ignored since the server should already return the filtered row model.
|
|
162
162
|
* - For client-side filtering, this function is required. A default implementation is provided via any table adapter's `{ getFilteredRowModel }` export.
|
|
163
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
164
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
163
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)
|
|
164
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
165
165
|
*/
|
|
166
166
|
getFilteredRowModel?: (table: Table<any>) => () => RowModel<any>
|
|
167
167
|
/**
|
|
168
168
|
* Disables the `getFilteredRowModel` from being used to filter data. This may be useful if your table needs to dynamically support both client-side and server-side filtering.
|
|
169
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
170
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
169
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#manualfiltering)
|
|
170
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
171
171
|
*/
|
|
172
172
|
manualFiltering?: boolean
|
|
173
173
|
/**
|
|
174
174
|
* By default, filtering is done for all rows (max depth of 100), no matter if they are root level parent rows or the child leaf rows of a parent row. Setting this option to `0` will cause filtering to only be applied to the root level parent rows, with all sub-rows remaining unfiltered. Similarly, setting this option to `1` will cause filtering to only be applied to child leaf rows 1 level deep, and so on.
|
|
175
175
|
|
|
176
176
|
* This is useful for situations where you want a row's entire child hierarchy to be visible regardless of the applied filter.
|
|
177
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
178
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
177
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#maxleafrowfilterdepth)
|
|
178
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
179
179
|
*/
|
|
180
180
|
maxLeafRowFilterDepth?: number
|
|
181
181
|
/**
|
|
182
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.
|
|
183
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
184
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
183
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#oncolumnfilterschange)
|
|
184
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
185
185
|
*/
|
|
186
186
|
onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>
|
|
187
187
|
}
|
|
@@ -202,38 +202,38 @@ export interface ColumnFiltersInstance<TData extends RowData> {
|
|
|
202
202
|
_getFilteredRowModel?: () => RowModel<TData>
|
|
203
203
|
/**
|
|
204
204
|
* Returns the row model for the table after **column** filtering has been applied.
|
|
205
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
206
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
205
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)
|
|
206
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
207
207
|
*/
|
|
208
208
|
getFilteredRowModel: () => RowModel<TData>
|
|
209
209
|
/**
|
|
210
210
|
* Returns the row model for the table before any **column** filtering has been applied.
|
|
211
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
212
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
211
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getprefilteredrowmodel)
|
|
212
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
213
213
|
*/
|
|
214
214
|
getPreFilteredRowModel: () => RowModel<TData>
|
|
215
215
|
/**
|
|
216
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/
|
|
218
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
217
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetcolumnfilters)
|
|
218
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
219
219
|
*/
|
|
220
220
|
resetColumnFilters: (defaultState?: boolean) => void
|
|
221
221
|
/**
|
|
222
222
|
* Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.
|
|
223
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
224
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
223
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetglobalfilter)
|
|
224
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
225
225
|
*/
|
|
226
226
|
resetGlobalFilter: (defaultState?: boolean) => void
|
|
227
227
|
/**
|
|
228
228
|
* Sets or updates the `state.columnFilters` state.
|
|
229
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
230
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
229
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setcolumnfilters)
|
|
230
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
231
231
|
*/
|
|
232
232
|
setColumnFilters: (updater: Updater<ColumnFiltersState>) => void
|
|
233
233
|
/**
|
|
234
234
|
* Sets or updates the `state.globalFilter` state.
|
|
235
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
236
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
235
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setglobalfilter)
|
|
236
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)
|
|
237
237
|
*/
|
|
238
238
|
setGlobalFilter: (updater: Updater<any>) => void
|
|
239
239
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { RowModel } from '..'
|
|
2
|
+
import { Table, RowData, TableFeature } from '../types'
|
|
3
|
+
|
|
4
|
+
export interface GlobalFacetingInstance<TData extends RowData> {
|
|
5
|
+
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number]
|
|
6
|
+
_getGlobalFacetedRowModel?: () => RowModel<TData>
|
|
7
|
+
_getGlobalFacetedUniqueValues?: () => Map<any, number>
|
|
8
|
+
/**
|
|
9
|
+
* 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.
|
|
10
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalautofilterfn)
|
|
11
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
12
|
+
*/
|
|
13
|
+
getGlobalFacetedMinMaxValues: () => undefined | [number, number]
|
|
14
|
+
/**
|
|
15
|
+
* Returns the row model for the table after **global** filtering has been applied.
|
|
16
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfacetedrowmodel)
|
|
17
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
18
|
+
*/
|
|
19
|
+
getGlobalFacetedRowModel: () => RowModel<TData>
|
|
20
|
+
/**
|
|
21
|
+
* Returns the faceted unique values for the global filter.
|
|
22
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfaceteduniquevalues)
|
|
23
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
24
|
+
*/
|
|
25
|
+
getGlobalFacetedUniqueValues: () => Map<any, number>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
|
|
30
|
+
export const GlobalFaceting: TableFeature = {
|
|
31
|
+
createTable: <TData extends RowData>(table: Table<TData>): void => {
|
|
32
|
+
table._getGlobalFacetedRowModel =
|
|
33
|
+
table.options.getFacetedRowModel &&
|
|
34
|
+
table.options.getFacetedRowModel(table, '__global__')
|
|
35
|
+
|
|
36
|
+
table.getGlobalFacetedRowModel = () => {
|
|
37
|
+
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
38
|
+
return table.getPreFilteredRowModel()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return table._getGlobalFacetedRowModel()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
table._getGlobalFacetedUniqueValues =
|
|
45
|
+
table.options.getFacetedUniqueValues &&
|
|
46
|
+
table.options.getFacetedUniqueValues(table, '__global__')
|
|
47
|
+
table.getGlobalFacetedUniqueValues = () => {
|
|
48
|
+
if (!table._getGlobalFacetedUniqueValues) {
|
|
49
|
+
return new Map()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return table._getGlobalFacetedUniqueValues()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
table._getGlobalFacetedMinMaxValues =
|
|
56
|
+
table.options.getFacetedMinMaxValues &&
|
|
57
|
+
table.options.getFacetedMinMaxValues(table, '__global__')
|
|
58
|
+
table.getGlobalFacetedMinMaxValues = () => {
|
|
59
|
+
if (!table._getGlobalFacetedMinMaxValues) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return table._getGlobalFacetedMinMaxValues()
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterFn, FilterFnOption
|
|
1
|
+
import { FilterFn, FilterFnOption } from '..'
|
|
2
2
|
import { BuiltInFilterFn, filterFns } from '../filterFns'
|
|
3
3
|
import {
|
|
4
4
|
Column,
|
|
@@ -17,8 +17,8 @@ export interface GlobalFilterTableState {
|
|
|
17
17
|
export interface GlobalFilterColumnDef {
|
|
18
18
|
/**
|
|
19
19
|
* Enables/disables the **global** filter for this column.
|
|
20
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
21
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
20
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)
|
|
21
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
22
22
|
*/
|
|
23
23
|
enableGlobalFilter?: boolean
|
|
24
24
|
}
|
|
@@ -26,8 +26,8 @@ export interface GlobalFilterColumnDef {
|
|
|
26
26
|
export interface GlobalFilterColumn {
|
|
27
27
|
/**
|
|
28
28
|
* Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.
|
|
29
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
30
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
29
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcanglobalfilter)
|
|
30
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
31
31
|
*/
|
|
32
32
|
getCanGlobalFilter: () => boolean
|
|
33
33
|
}
|
|
@@ -35,16 +35,16 @@ export interface GlobalFilterColumn {
|
|
|
35
35
|
export interface GlobalFilterOptions<TData extends RowData> {
|
|
36
36
|
/**
|
|
37
37
|
* Enables/disables **global** filtering for all columns.
|
|
38
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
39
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
38
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)
|
|
39
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
40
40
|
*/
|
|
41
41
|
enableGlobalFilter?: boolean
|
|
42
42
|
/**
|
|
43
43
|
* 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.
|
|
44
44
|
*
|
|
45
45
|
* This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).
|
|
46
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
47
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
46
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcolumncanglobalfilter)
|
|
47
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
48
48
|
*/
|
|
49
49
|
getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean
|
|
50
50
|
/**
|
|
@@ -52,62 +52,41 @@ export interface GlobalFilterOptions<TData extends RowData> {
|
|
|
52
52
|
* - A `string` referencing a built-in filter function
|
|
53
53
|
* - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option
|
|
54
54
|
* - A custom filter function
|
|
55
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
56
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
55
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#globalfilterfn)
|
|
56
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
57
57
|
*/
|
|
58
58
|
globalFilterFn?: FilterFnOption<TData>
|
|
59
59
|
/**
|
|
60
60
|
* 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.
|
|
61
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
62
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
61
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#onglobalfilterchange)
|
|
62
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
63
63
|
*/
|
|
64
64
|
onGlobalFilterChange?: OnChangeFn<any>
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export interface GlobalFilterInstance<TData extends RowData> {
|
|
68
|
-
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number]
|
|
69
|
-
_getGlobalFacetedRowModel?: () => RowModel<TData>
|
|
70
|
-
_getGlobalFacetedUniqueValues?: () => Map<any, number>
|
|
71
68
|
/**
|
|
72
69
|
* 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.
|
|
73
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
74
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
70
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalautofilterfn)
|
|
71
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
75
72
|
*/
|
|
76
73
|
getGlobalAutoFilterFn: () => FilterFn<TData> | undefined
|
|
77
|
-
/**
|
|
78
|
-
* Returns the faceted min and max values for the global filter.
|
|
79
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedminmaxvalues)
|
|
80
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
81
|
-
*/
|
|
82
|
-
getGlobalFacetedMinMaxValues: () => undefined | [number, number]
|
|
83
|
-
/**
|
|
84
|
-
* Returns the row model for the table after **global** filtering has been applied.
|
|
85
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedrowmodel)
|
|
86
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
87
|
-
*/
|
|
88
|
-
getGlobalFacetedRowModel: () => RowModel<TData>
|
|
89
|
-
/**
|
|
90
|
-
* Returns the faceted unique values for the global filter.
|
|
91
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfaceteduniquevalues)
|
|
92
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
93
|
-
*/
|
|
94
|
-
getGlobalFacetedUniqueValues: () => Map<any, number>
|
|
95
74
|
/**
|
|
96
75
|
* Returns the filter function (either user-defined or automatic, depending on configuration) for the global filter.
|
|
97
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
98
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
76
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalfilterfn)
|
|
77
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
99
78
|
*/
|
|
100
79
|
getGlobalFilterFn: () => FilterFn<TData> | undefined
|
|
101
80
|
/**
|
|
102
81
|
* Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.
|
|
103
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
104
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
82
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#resetglobalfilter)
|
|
83
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
105
84
|
*/
|
|
106
85
|
resetGlobalFilter: (defaultState?: boolean) => void
|
|
107
86
|
/**
|
|
108
87
|
* Sets or updates the `state.globalFilter` state.
|
|
109
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
110
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
88
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#setglobalfilter)
|
|
89
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
111
90
|
*/
|
|
112
91
|
setGlobalFilter: (updater: Updater<any>) => void
|
|
113
92
|
}
|
|
@@ -166,8 +145,7 @@ export const GlobalFiltering: TableFeature = {
|
|
|
166
145
|
? globalFilterFn
|
|
167
146
|
: globalFilterFn === 'auto'
|
|
168
147
|
? table.getGlobalAutoFilterFn()
|
|
169
|
-
:
|
|
170
|
-
table.options.filterFns?.[globalFilterFn as string] ??
|
|
148
|
+
: table.options.filterFns?.[globalFilterFn as string] ??
|
|
171
149
|
filterFns[globalFilterFn as BuiltInFilterFn]
|
|
172
150
|
}
|
|
173
151
|
|
|
@@ -180,39 +158,5 @@ export const GlobalFiltering: TableFeature = {
|
|
|
180
158
|
defaultState ? undefined : table.initialState.globalFilter
|
|
181
159
|
)
|
|
182
160
|
}
|
|
183
|
-
|
|
184
|
-
table._getGlobalFacetedRowModel =
|
|
185
|
-
table.options.getFacetedRowModel &&
|
|
186
|
-
table.options.getFacetedRowModel(table, '__global__')
|
|
187
|
-
|
|
188
|
-
table.getGlobalFacetedRowModel = () => {
|
|
189
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
190
|
-
return table.getPreFilteredRowModel()
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return table._getGlobalFacetedRowModel()
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
table._getGlobalFacetedUniqueValues =
|
|
197
|
-
table.options.getFacetedUniqueValues &&
|
|
198
|
-
table.options.getFacetedUniqueValues(table, '__global__')
|
|
199
|
-
table.getGlobalFacetedUniqueValues = () => {
|
|
200
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
|
201
|
-
return new Map()
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return table._getGlobalFacetedUniqueValues()
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
table._getGlobalFacetedMinMaxValues =
|
|
208
|
-
table.options.getFacetedMinMaxValues &&
|
|
209
|
-
table.options.getFacetedMinMaxValues(table, '__global__')
|
|
210
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
|
211
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return table._getGlobalFacetedMinMaxValues()
|
|
216
|
-
}
|
|
217
161
|
},
|
|
218
162
|
}
|
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './features/ColumnOrdering'
|
|
|
17
17
|
export * from './features/ColumnPinning'
|
|
18
18
|
export * from './features/ColumnSizing'
|
|
19
19
|
export * from './features/ColumnVisibility'
|
|
20
|
+
export * from './features/GlobalFaceting'
|
|
20
21
|
export * from './features/GlobalFiltering'
|
|
21
22
|
export * from './features/RowExpanding'
|
|
22
23
|
export * from './features/RowPagination'
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
HeadersInstance,
|
|
35
35
|
} from './core/headers'
|
|
36
36
|
import { FacetedColumn, FacetedOptions } from './features/ColumnFaceting'
|
|
37
|
+
import { GlobalFacetingInstance } from './features/GlobalFaceting'
|
|
37
38
|
import {
|
|
38
39
|
ColumnFiltersColumn,
|
|
39
40
|
ColumnFiltersColumnDef,
|
|
@@ -142,6 +143,7 @@ export interface Table<TData extends RowData>
|
|
|
142
143
|
RowPinningInstance<TData>,
|
|
143
144
|
ColumnFiltersInstance<TData>,
|
|
144
145
|
GlobalFilterInstance<TData>,
|
|
146
|
+
GlobalFacetingInstance<TData>,
|
|
145
147
|
SortingInstance<TData>,
|
|
146
148
|
GroupingInstance<TData>,
|
|
147
149
|
ColumnSizingInstance,
|
|
@@ -291,8 +293,10 @@ export type GroupColumnDef<
|
|
|
291
293
|
TValue = unknown,
|
|
292
294
|
> = GroupColumnDefBase<TData, TValue> & ColumnIdentifiers<TData, TValue>
|
|
293
295
|
|
|
294
|
-
interface AccessorFnColumnDefBase<
|
|
295
|
-
extends
|
|
296
|
+
export interface AccessorFnColumnDefBase<
|
|
297
|
+
TData extends RowData,
|
|
298
|
+
TValue = unknown,
|
|
299
|
+
> extends ColumnDefBase<TData, TValue> {
|
|
296
300
|
accessorFn: AccessorFn<TData, TValue>
|
|
297
301
|
}
|
|
298
302
|
|