@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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RowModel } from '..';
|
|
2
|
+
import { RowData, TableFeature } from '../types';
|
|
3
|
+
export interface GlobalFacetingInstance<TData extends RowData> {
|
|
4
|
+
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number];
|
|
5
|
+
_getGlobalFacetedRowModel?: () => RowModel<TData>;
|
|
6
|
+
_getGlobalFacetedUniqueValues?: () => Map<any, number>;
|
|
7
|
+
/**
|
|
8
|
+
* 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.
|
|
9
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalautofilterfn)
|
|
10
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
11
|
+
*/
|
|
12
|
+
getGlobalFacetedMinMaxValues: () => undefined | [number, number];
|
|
13
|
+
/**
|
|
14
|
+
* Returns the row model for the table after **global** filtering has been applied.
|
|
15
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfacetedrowmodel)
|
|
16
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
17
|
+
*/
|
|
18
|
+
getGlobalFacetedRowModel: () => RowModel<TData>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the faceted unique values for the global filter.
|
|
21
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfaceteduniquevalues)
|
|
22
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)
|
|
23
|
+
*/
|
|
24
|
+
getGlobalFacetedUniqueValues: () => Map<any, number>;
|
|
25
|
+
}
|
|
26
|
+
export declare const GlobalFaceting: TableFeature;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* table-core
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) TanStack
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
//
|
|
14
|
+
|
|
15
|
+
const GlobalFaceting = {
|
|
16
|
+
createTable: table => {
|
|
17
|
+
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
18
|
+
table.getGlobalFacetedRowModel = () => {
|
|
19
|
+
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
20
|
+
return table.getPreFilteredRowModel();
|
|
21
|
+
}
|
|
22
|
+
return table._getGlobalFacetedRowModel();
|
|
23
|
+
};
|
|
24
|
+
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
|
25
|
+
table.getGlobalFacetedUniqueValues = () => {
|
|
26
|
+
if (!table._getGlobalFacetedUniqueValues) {
|
|
27
|
+
return new Map();
|
|
28
|
+
}
|
|
29
|
+
return table._getGlobalFacetedUniqueValues();
|
|
30
|
+
};
|
|
31
|
+
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
|
32
|
+
table.getGlobalFacetedMinMaxValues = () => {
|
|
33
|
+
if (!table._getGlobalFacetedMinMaxValues) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
return table._getGlobalFacetedMinMaxValues();
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.GlobalFaceting = GlobalFaceting;
|
|
42
|
+
//# sourceMappingURL=GlobalFaceting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalFaceting.js","sources":["../../../src/features/GlobalFaceting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { Table, RowData, TableFeature } from '../types'\n\nexport interface GlobalFacetingInstance<TData extends RowData> {\n _getGlobalFacetedMinMaxValues?: () => undefined | [number, number]\n _getGlobalFacetedRowModel?: () => RowModel<TData>\n _getGlobalFacetedUniqueValues?: () => Map<any, number>\n /**\n * 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.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedMinMaxValues: () => undefined | [number, number]\n /**\n * Returns the row model for the table after **global** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfacetedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedRowModel: () => RowModel<TData>\n /**\n * Returns the faceted unique values for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-faceting#getglobalfaceteduniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-faceting)\n */\n getGlobalFacetedUniqueValues: () => Map<any, number>\n}\n\n//\n\nexport const GlobalFaceting: TableFeature = {\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table._getGlobalFacetedRowModel =\n table.options.getFacetedRowModel &&\n table.options.getFacetedRowModel(table, '__global__')\n\n table.getGlobalFacetedRowModel = () => {\n if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return table._getGlobalFacetedRowModel()\n }\n\n table._getGlobalFacetedUniqueValues =\n table.options.getFacetedUniqueValues &&\n table.options.getFacetedUniqueValues(table, '__global__')\n table.getGlobalFacetedUniqueValues = () => {\n if (!table._getGlobalFacetedUniqueValues) {\n return new Map()\n }\n\n return table._getGlobalFacetedUniqueValues()\n }\n\n table._getGlobalFacetedMinMaxValues =\n table.options.getFacetedMinMaxValues &&\n table.options.getFacetedMinMaxValues(table, '__global__')\n table.getGlobalFacetedMinMaxValues = () => {\n if (!table._getGlobalFacetedMinMaxValues) {\n return\n }\n\n return table._getGlobalFacetedMinMaxValues()\n }\n },\n}\n"],"names":["GlobalFaceting","createTable","table","_getGlobalFacetedRowModel","options","getFacetedRowModel","getGlobalFacetedRowModel","manualFiltering","getPreFilteredRowModel","_getGlobalFacetedUniqueValues","getFacetedUniqueValues","getGlobalFacetedUniqueValues","Map","_getGlobalFacetedMinMaxValues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AAA;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterFn, FilterFnOption
|
|
1
|
+
import { FilterFn, FilterFnOption } from '..';
|
|
2
2
|
import { Column, OnChangeFn, Updater, RowData, TableFeature } from '../types';
|
|
3
3
|
export interface GlobalFilterTableState {
|
|
4
4
|
globalFilter: any;
|
|
@@ -6,32 +6,32 @@ export interface GlobalFilterTableState {
|
|
|
6
6
|
export interface GlobalFilterColumnDef {
|
|
7
7
|
/**
|
|
8
8
|
* Enables/disables the **global** filter for this column.
|
|
9
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
10
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
9
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)
|
|
10
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
11
11
|
*/
|
|
12
12
|
enableGlobalFilter?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export interface GlobalFilterColumn {
|
|
15
15
|
/**
|
|
16
16
|
* Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.
|
|
17
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
18
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
17
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcanglobalfilter)
|
|
18
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
19
19
|
*/
|
|
20
20
|
getCanGlobalFilter: () => boolean;
|
|
21
21
|
}
|
|
22
22
|
export interface GlobalFilterOptions<TData extends RowData> {
|
|
23
23
|
/**
|
|
24
24
|
* Enables/disables **global** filtering for all columns.
|
|
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/global-filtering#enableglobalfilter)
|
|
26
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
27
27
|
*/
|
|
28
28
|
enableGlobalFilter?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* 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.
|
|
31
31
|
*
|
|
32
32
|
* This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).
|
|
33
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
34
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
33
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcolumncanglobalfilter)
|
|
34
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
35
35
|
*/
|
|
36
36
|
getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean;
|
|
37
37
|
/**
|
|
@@ -39,61 +39,40 @@ export interface GlobalFilterOptions<TData extends RowData> {
|
|
|
39
39
|
* - A `string` referencing a built-in filter function
|
|
40
40
|
* - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option
|
|
41
41
|
* - A custom filter function
|
|
42
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
43
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
42
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#globalfilterfn)
|
|
43
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
44
44
|
*/
|
|
45
45
|
globalFilterFn?: FilterFnOption<TData>;
|
|
46
46
|
/**
|
|
47
47
|
* 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.
|
|
48
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
49
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
48
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#onglobalfilterchange)
|
|
49
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
50
50
|
*/
|
|
51
51
|
onGlobalFilterChange?: OnChangeFn<any>;
|
|
52
52
|
}
|
|
53
53
|
export interface GlobalFilterInstance<TData extends RowData> {
|
|
54
|
-
_getGlobalFacetedMinMaxValues?: () => undefined | [number, number];
|
|
55
|
-
_getGlobalFacetedRowModel?: () => RowModel<TData>;
|
|
56
|
-
_getGlobalFacetedUniqueValues?: () => Map<any, number>;
|
|
57
54
|
/**
|
|
58
55
|
* 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.
|
|
59
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
60
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
56
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalautofilterfn)
|
|
57
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
61
58
|
*/
|
|
62
59
|
getGlobalAutoFilterFn: () => FilterFn<TData> | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Returns the faceted min and max values for the global filter.
|
|
65
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedminmaxvalues)
|
|
66
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
67
|
-
*/
|
|
68
|
-
getGlobalFacetedMinMaxValues: () => undefined | [number, number];
|
|
69
|
-
/**
|
|
70
|
-
* Returns the row model for the table after **global** filtering has been applied.
|
|
71
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedrowmodel)
|
|
72
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
73
|
-
*/
|
|
74
|
-
getGlobalFacetedRowModel: () => RowModel<TData>;
|
|
75
|
-
/**
|
|
76
|
-
* Returns the faceted unique values for the global filter.
|
|
77
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfaceteduniquevalues)
|
|
78
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)
|
|
79
|
-
*/
|
|
80
|
-
getGlobalFacetedUniqueValues: () => Map<any, number>;
|
|
81
60
|
/**
|
|
82
61
|
* Returns the filter function (either user-defined or automatic, depending on configuration) for the global filter.
|
|
83
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
84
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
62
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalfilterfn)
|
|
63
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
85
64
|
*/
|
|
86
65
|
getGlobalFilterFn: () => FilterFn<TData> | undefined;
|
|
87
66
|
/**
|
|
88
67
|
* Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.
|
|
89
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
90
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
68
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#resetglobalfilter)
|
|
69
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
91
70
|
*/
|
|
92
71
|
resetGlobalFilter: (defaultState?: boolean) => void;
|
|
93
72
|
/**
|
|
94
73
|
* Sets or updates the `state.globalFilter` state.
|
|
95
|
-
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/
|
|
96
|
-
* @link [Guide](https://tanstack.com/table/v8/docs/guide/
|
|
74
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#setglobalfilter)
|
|
75
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)
|
|
97
76
|
*/
|
|
98
77
|
setGlobalFilter: (updater: Updater<any>) => void;
|
|
99
78
|
}
|
|
@@ -48,8 +48,7 @@ const GlobalFiltering = {
|
|
|
48
48
|
const {
|
|
49
49
|
globalFilterFn: globalFilterFn
|
|
50
50
|
} = table.options;
|
|
51
|
-
return utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() :
|
|
52
|
-
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns.filterFns[globalFilterFn];
|
|
51
|
+
return utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns.filterFns[globalFilterFn];
|
|
53
52
|
};
|
|
54
53
|
table.setGlobalFilter = updater => {
|
|
55
54
|
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
@@ -57,27 +56,6 @@ const GlobalFiltering = {
|
|
|
57
56
|
table.resetGlobalFilter = defaultState => {
|
|
58
57
|
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
59
58
|
};
|
|
60
|
-
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
61
|
-
table.getGlobalFacetedRowModel = () => {
|
|
62
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
63
|
-
return table.getPreFilteredRowModel();
|
|
64
|
-
}
|
|
65
|
-
return table._getGlobalFacetedRowModel();
|
|
66
|
-
};
|
|
67
|
-
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
|
68
|
-
table.getGlobalFacetedUniqueValues = () => {
|
|
69
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
|
70
|
-
return new Map();
|
|
71
|
-
}
|
|
72
|
-
return table._getGlobalFacetedUniqueValues();
|
|
73
|
-
};
|
|
74
|
-
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
|
75
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
|
76
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
return table._getGlobalFacetedMinMaxValues();
|
|
80
|
-
};
|
|
81
59
|
}
|
|
82
60
|
};
|
|
83
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalFiltering.js","sources":["../../../src/features/GlobalFiltering.ts"],"sourcesContent":["import { FilterFn, FilterFnOption, RowModel } from '..'\nimport { BuiltInFilterFn, filterFns } from '../filterFns'\nimport {\n Column,\n OnChangeFn,\n Table,\n Updater,\n RowData,\n TableFeature,\n} from '../types'\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport interface GlobalFilterTableState {\n globalFilter: any\n}\n\nexport interface GlobalFilterColumnDef {\n /**\n * Enables/disables the **global** filter for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n enableGlobalFilter?: boolean\n}\n\nexport interface GlobalFilterColumn {\n /**\n * Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getcanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getCanGlobalFilter: () => boolean\n}\n\nexport interface GlobalFilterOptions<TData extends RowData> {\n /**\n * Enables/disables **global** filtering for all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n enableGlobalFilter?: boolean\n /**\n * 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.\n *\n * This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getcolumncanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean\n /**\n * The filter function to use for global filtering.\n * - A `string` referencing a built-in filter function\n * - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option\n * - A custom filter function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#globalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n globalFilterFn?: FilterFnOption<TData>\n /**\n * 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.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#onglobalfilterchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n onGlobalFilterChange?: OnChangeFn<any>\n}\n\nexport interface GlobalFilterInstance<TData extends RowData> {\n _getGlobalFacetedMinMaxValues?: () => undefined | [number, number]\n _getGlobalFacetedRowModel?: () => RowModel<TData>\n _getGlobalFacetedUniqueValues?: () => Map<any, number>\n /**\n * 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.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getGlobalAutoFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns the faceted min and max values for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedminmaxvalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getGlobalFacetedMinMaxValues: () => undefined | [number, number]\n /**\n * Returns the row model for the table after **global** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfacetedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getGlobalFacetedRowModel: () => RowModel<TData>\n /**\n * Returns the faceted unique values for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfaceteduniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getGlobalFacetedUniqueValues: () => Map<any, number>\n /**\n * Returns the filter function (either user-defined or automatic, depending on configuration) for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#getglobalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n getGlobalFilterFn: () => FilterFn<TData> | undefined\n /**\n * Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#resetglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n resetGlobalFilter: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.globalFilter` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/filters#setglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/filters)\n */\n setGlobalFilter: (updater: Updater<any>) => void\n}\n\n//\n\nexport const GlobalFiltering: TableFeature = {\n getInitialState: (state): GlobalFilterTableState => {\n return {\n globalFilter: undefined,\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): GlobalFilterOptions<TData> => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: column => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?._getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n } as GlobalFilterOptions<TData>\n },\n\n createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getCanGlobalFilter = () => {\n return (\n (column.columnDef.enableGlobalFilter ?? true) &&\n (table.options.enableGlobalFilter ?? true) &&\n (table.options.enableFilters ?? true) &&\n (table.options.getColumnCanGlobalFilter?.(column) ?? true) &&\n !!column.accessorFn\n )\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.getGlobalAutoFilterFn = () => {\n return filterFns.includesString\n }\n\n table.getGlobalFilterFn = () => {\n const { globalFilterFn: globalFilterFn } = table.options\n\n return isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table.getGlobalAutoFilterFn()\n : // @ts-ignore\n table.options.filterFns?.[globalFilterFn as string] ??\n filterFns[globalFilterFn as BuiltInFilterFn]\n }\n\n table.setGlobalFilter = updater => {\n table.options.onGlobalFilterChange?.(updater)\n }\n\n table.resetGlobalFilter = defaultState => {\n table.setGlobalFilter(\n defaultState ? undefined : table.initialState.globalFilter\n )\n }\n\n table._getGlobalFacetedRowModel =\n table.options.getFacetedRowModel &&\n table.options.getFacetedRowModel(table, '__global__')\n\n table.getGlobalFacetedRowModel = () => {\n if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return table._getGlobalFacetedRowModel()\n }\n\n table._getGlobalFacetedUniqueValues =\n table.options.getFacetedUniqueValues &&\n table.options.getFacetedUniqueValues(table, '__global__')\n table.getGlobalFacetedUniqueValues = () => {\n if (!table._getGlobalFacetedUniqueValues) {\n return new Map()\n }\n\n return table._getGlobalFacetedUniqueValues()\n }\n\n table._getGlobalFacetedMinMaxValues =\n table.options.getFacetedMinMaxValues &&\n table.options.getFacetedMinMaxValues(table, '__global__')\n table.getGlobalFacetedMinMaxValues = () => {\n if (!table._getGlobalFacetedMinMaxValues) {\n return\n }\n\n return table._getGlobalFacetedMinMaxValues()\n }\n },\n}\n"],"names":["GlobalFiltering","getInitialState","state","globalFilter","undefined","getDefaultOptions","table","onGlobalFilterChange","makeStateUpdater","globalFilterFn","getColumnCanGlobalFilter","column","_table$getCoreRowMode","value","getCoreRowModel","flatRows","_getAllCellsByColumnId","id","getValue","createColumn","getCanGlobalFilter","_column$columnDef$ena","_table$options$enable","_table$options$enable2","_table$options$getCol","columnDef","enableGlobalFilter","options","enableFilters","accessorFn","createTable","getGlobalAutoFilterFn","filterFns","includesString","getGlobalFilterFn","_table$options$filter","_table$options$filter2","isFunction","setGlobalFilter","updater","resetGlobalFilter","defaultState","initialState","_getGlobalFacetedRowModel","getFacetedRowModel","getGlobalFacetedRowModel","manualFiltering","getPreFilteredRowModel","_getGlobalFacetedUniqueValues","getFacetedUniqueValues","getGlobalFacetedUniqueValues","Map","_getGlobalFacetedMinMaxValues","getFacetedMinMaxValues","getGlobalFacetedMinMaxValues"],"mappings":";;;;;;;;;;;;;;;AAkHA;;AAEO,MAAMA,eAA6B,GAAG;EAC3CC,eAAe,EAAGC,KAAK,IAA6B;IAClD,OAAO;AACLC,MAAAA,YAAY,EAAEC,SAAS;MACvB,GAAGF,KAAAA;KACJ,CAAA;GACF;EAEDG,iBAAiB,EACfC,KAAmB,IACY;IAC/B,OAAO;AACLC,MAAAA,oBAAoB,EAAEC,sBAAgB,CAAC,cAAc,EAAEF,KAAK,CAAC;AAC7DG,MAAAA,cAAc,EAAE,MAAM;MACtBC,wBAAwB,EAAEC,MAAM,IAAI;AAAA,QAAA,IAAAC,qBAAA,CAAA;AAClC,QAAA,MAAMC,KAAK,GAAA,CAAAD,qBAAA,GAAGN,KAAK,CAChBQ,eAAe,EAAE,CACjBC,QAAQ,CAAC,CAAC,CAAC,KAAAH,IAAAA,IAAAA,CAAAA,qBAAA,GAFAA,qBAAA,CAEEI,sBAAsB,EAAE,CACrCL,MAAM,CAACM,EAAE,CAAC,KAHCL,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,qBAAA,CAGCM,QAAQ,EAAE,CAAA;QAEzB,OAAO,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,CAAA;AAC/D,OAAA;KACD,CAAA;GACF;AA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AAE,CAAA;AAClB,OAAA;AAEA,MAAA,OAAO7C,KAAK,CAAC0C,6BAA6B,EAAE,CAAA;KAC7C,CAAA;AAED1C,IAAAA,KAAK,CAAC8C,6BAA6B,GACjC9C,KAAK,CAACqB,OAAO,CAAC0B,sBAAsB,IACpC/C,KAAK,CAACqB,OAAO,CAAC0B,sBAAsB,CAAC/C,KAAK,EAAE,YAAY,CAAC,CAAA;IAC3DA,KAAK,CAACgD,4BAA4B,GAAG,MAAM;AACzC,MAAA,IAAI,CAAChD,KAAK,CAAC8C,6BAA6B,EAAE;AACxC,QAAA,OAAA;AACF,OAAA;AAEA,MAAA,OAAO9C,KAAK,CAAC8C,6BAA6B,EAAE,CAAA;KAC7C,CAAA;AACH,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"GlobalFiltering.js","sources":["../../../src/features/GlobalFiltering.ts"],"sourcesContent":["import { FilterFn, FilterFnOption } from '..'\nimport { BuiltInFilterFn, filterFns } from '../filterFns'\nimport {\n Column,\n OnChangeFn,\n Table,\n Updater,\n RowData,\n TableFeature,\n} from '../types'\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport interface GlobalFilterTableState {\n globalFilter: any\n}\n\nexport interface GlobalFilterColumnDef {\n /**\n * Enables/disables the **global** filter for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n enableGlobalFilter?: boolean\n}\n\nexport interface GlobalFilterColumn {\n /**\n * Returns whether or not the column can be **globally** filtered. Set to `false` to disable a column from being scanned during global filtering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getCanGlobalFilter: () => boolean\n}\n\nexport interface GlobalFilterOptions<TData extends RowData> {\n /**\n * Enables/disables **global** filtering for all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#enableglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n enableGlobalFilter?: boolean\n /**\n * 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.\n *\n * This is useful if the column can contain data that is not `string` or `number` (i.e. `undefined`).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getcolumncanglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getColumnCanGlobalFilter?: (column: Column<TData, unknown>) => boolean\n /**\n * The filter function to use for global filtering.\n * - A `string` referencing a built-in filter function\n * - A `string` that references a custom filter functions provided via the `tableOptions.filterFns` option\n * - A custom filter function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#globalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n globalFilterFn?: FilterFnOption<TData>\n /**\n * 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.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#onglobalfilterchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n onGlobalFilterChange?: OnChangeFn<any>\n}\n\nexport interface GlobalFilterInstance<TData extends RowData> {\n /**\n * 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.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getGlobalAutoFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns the filter function (either user-defined or automatic, depending on configuration) for the global filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#getglobalfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n getGlobalFilterFn: () => FilterFn<TData> | undefined\n /**\n * Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#resetglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n resetGlobalFilter: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.globalFilter` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/global-filtering#setglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/global-filtering)\n */\n setGlobalFilter: (updater: Updater<any>) => void\n}\n\n//\n\nexport const GlobalFiltering: TableFeature = {\n getInitialState: (state): GlobalFilterTableState => {\n return {\n globalFilter: undefined,\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): GlobalFilterOptions<TData> => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: column => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?._getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n } as GlobalFilterOptions<TData>\n },\n\n createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getCanGlobalFilter = () => {\n return (\n (column.columnDef.enableGlobalFilter ?? true) &&\n (table.options.enableGlobalFilter ?? true) &&\n (table.options.enableFilters ?? true) &&\n (table.options.getColumnCanGlobalFilter?.(column) ?? true) &&\n !!column.accessorFn\n )\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.getGlobalAutoFilterFn = () => {\n return filterFns.includesString\n }\n\n table.getGlobalFilterFn = () => {\n const { globalFilterFn: globalFilterFn } = table.options\n\n return isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table.getGlobalAutoFilterFn()\n : table.options.filterFns?.[globalFilterFn as string] ??\n filterFns[globalFilterFn as BuiltInFilterFn]\n }\n\n table.setGlobalFilter = updater => {\n table.options.onGlobalFilterChange?.(updater)\n }\n\n table.resetGlobalFilter = defaultState => {\n table.setGlobalFilter(\n defaultState ? undefined : table.initialState.globalFilter\n )\n }\n },\n}\n"],"names":["GlobalFiltering","getInitialState","state","globalFilter","undefined","getDefaultOptions","table","onGlobalFilterChange","makeStateUpdater","globalFilterFn","getColumnCanGlobalFilter","column","_table$getCoreRowMode","value","getCoreRowModel","flatRows","_getAllCellsByColumnId","id","getValue","createColumn","getCanGlobalFilter","_column$columnDef$ena","_table$options$enable","_table$options$enable2","_table$options$getCol","columnDef","enableGlobalFilter","options","enableFilters","accessorFn","createTable","getGlobalAutoFilterFn","filterFns","includesString","getGlobalFilterFn","_table$options$filter","_table$options$filter2","isFunction","setGlobalFilter","updater","resetGlobalFilter","defaultState","initialState"],"mappings":";;;;;;;;;;;;;;;AA6FA;;AAEO,MAAMA,eAA6B,GAAG;EAC3CC,eAAe,EAAGC,KAAK,IAA6B;IAClD,OAAO;AACLC,MAAAA,YAAY,EAAEC,SAAS;MACvB,GAAGF,KAAAA;KACJ,CAAA;GACF;EAEDG,iBAAiB,EACfC,KAAmB,IACY;IAC/B,OAAO;AACLC,MAAAA,oBAAoB,EAAEC,sBAAgB,CAAC,cAAc,EAAEF,KAAK,CAAC;AAC7DG,MAAAA,cAAc,EAAE,MAAM;MACtBC,wBAAwB,EAAEC,MAAM,IAAI;AAAA,QAAA,IAAAC,qBAAA,CAAA;AAClC,QAAA,MAAMC,KAAK,GAAA,CAAAD,qBAAA,GAAGN,KAAK,CAChBQ,eAAe,EAAE,CACjBC,QAAQ,CAAC,CAAC,CAAC,KAAAH,IAAAA,IAAAA,CAAAA,qBAAA,GAFAA,qBAAA,CAEEI,sBAAsB,EAAE,CACrCL,MAAM,CAACM,EAAE,CAAC,KAHCL,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,qBAAA,CAGCM,QAAQ,EAAE,CAAA;QAEzB,OAAO,OAAOL,KAAK,KAAK,QAAQ,IAAI,OAAO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CAAAA,sBAAA,GAC7B9B,KAAK,CAACqB,OAAO,CAACK,SAAS,KAAvBI,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,sBAAA,CAA0B3B,cAAc,CAAW,KAAA0B,IAAAA,GAAAA,qBAAA,GACnDH,mBAAS,CAACvB,cAAc,CAAoB,CAAA;KACnD,CAAA;AAEDH,IAAAA,KAAK,CAACgC,eAAe,GAAGC,OAAO,IAAI;AACjCjC,MAAAA,KAAK,CAACqB,OAAO,CAACpB,oBAAoB,IAAlCD,IAAAA,IAAAA,KAAK,CAACqB,OAAO,CAACpB,oBAAoB,CAAGgC,OAAO,CAAC,CAAA;KAC9C,CAAA;AAEDjC,IAAAA,KAAK,CAACkC,iBAAiB,GAAGC,YAAY,IAAI;AACxCnC,MAAAA,KAAK,CAACgC,eAAe,CACnBG,YAAY,GAAGrC,SAAS,GAAGE,KAAK,CAACoC,YAAY,CAACvC,YAChD,CAAC,CAAA;KACF,CAAA;AACH,GAAA;AACF;;;;"}
|
package/build/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './features/ColumnOrdering';
|
|
|
12
12
|
export * from './features/ColumnPinning';
|
|
13
13
|
export * from './features/ColumnSizing';
|
|
14
14
|
export * from './features/ColumnVisibility';
|
|
15
|
+
export * from './features/GlobalFaceting';
|
|
15
16
|
export * from './features/GlobalFiltering';
|
|
16
17
|
export * from './features/RowExpanding';
|
|
17
18
|
export * from './features/RowPagination';
|
package/build/lib/index.esm.js
CHANGED
|
@@ -1544,6 +1544,34 @@ function _getVisibleLeafColumns(table, position) {
|
|
|
1544
1544
|
|
|
1545
1545
|
//
|
|
1546
1546
|
|
|
1547
|
+
const GlobalFaceting = {
|
|
1548
|
+
createTable: table => {
|
|
1549
|
+
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
1550
|
+
table.getGlobalFacetedRowModel = () => {
|
|
1551
|
+
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
1552
|
+
return table.getPreFilteredRowModel();
|
|
1553
|
+
}
|
|
1554
|
+
return table._getGlobalFacetedRowModel();
|
|
1555
|
+
};
|
|
1556
|
+
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
|
1557
|
+
table.getGlobalFacetedUniqueValues = () => {
|
|
1558
|
+
if (!table._getGlobalFacetedUniqueValues) {
|
|
1559
|
+
return new Map();
|
|
1560
|
+
}
|
|
1561
|
+
return table._getGlobalFacetedUniqueValues();
|
|
1562
|
+
};
|
|
1563
|
+
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
|
1564
|
+
table.getGlobalFacetedMinMaxValues = () => {
|
|
1565
|
+
if (!table._getGlobalFacetedMinMaxValues) {
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
return table._getGlobalFacetedMinMaxValues();
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
|
|
1573
|
+
//
|
|
1574
|
+
|
|
1547
1575
|
const GlobalFiltering = {
|
|
1548
1576
|
getInitialState: state => {
|
|
1549
1577
|
return {
|
|
@@ -1577,8 +1605,7 @@ const GlobalFiltering = {
|
|
|
1577
1605
|
const {
|
|
1578
1606
|
globalFilterFn: globalFilterFn
|
|
1579
1607
|
} = table.options;
|
|
1580
|
-
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() :
|
|
1581
|
-
(_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
|
|
1608
|
+
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === 'auto' ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
|
|
1582
1609
|
};
|
|
1583
1610
|
table.setGlobalFilter = updater => {
|
|
1584
1611
|
table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
|
|
@@ -1586,27 +1613,6 @@ const GlobalFiltering = {
|
|
|
1586
1613
|
table.resetGlobalFilter = defaultState => {
|
|
1587
1614
|
table.setGlobalFilter(defaultState ? undefined : table.initialState.globalFilter);
|
|
1588
1615
|
};
|
|
1589
|
-
table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, '__global__');
|
|
1590
|
-
table.getGlobalFacetedRowModel = () => {
|
|
1591
|
-
if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) {
|
|
1592
|
-
return table.getPreFilteredRowModel();
|
|
1593
|
-
}
|
|
1594
|
-
return table._getGlobalFacetedRowModel();
|
|
1595
|
-
};
|
|
1596
|
-
table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, '__global__');
|
|
1597
|
-
table.getGlobalFacetedUniqueValues = () => {
|
|
1598
|
-
if (!table._getGlobalFacetedUniqueValues) {
|
|
1599
|
-
return new Map();
|
|
1600
|
-
}
|
|
1601
|
-
return table._getGlobalFacetedUniqueValues();
|
|
1602
|
-
};
|
|
1603
|
-
table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, '__global__');
|
|
1604
|
-
table.getGlobalFacetedMinMaxValues = () => {
|
|
1605
|
-
if (!table._getGlobalFacetedMinMaxValues) {
|
|
1606
|
-
return;
|
|
1607
|
-
}
|
|
1608
|
-
return table._getGlobalFacetedMinMaxValues();
|
|
1609
|
-
};
|
|
1610
1616
|
}
|
|
1611
1617
|
};
|
|
1612
1618
|
|
|
@@ -2735,8 +2741,10 @@ const RowSorting = {
|
|
|
2735
2741
|
}
|
|
2736
2742
|
};
|
|
2737
2743
|
|
|
2738
|
-
const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering,
|
|
2739
|
-
//depends on
|
|
2744
|
+
const builtInFeatures = [Headers, ColumnVisibility, ColumnOrdering, ColumnPinning, ColumnFaceting, ColumnFiltering, GlobalFaceting,
|
|
2745
|
+
//depends on ColumnFaceting
|
|
2746
|
+
GlobalFiltering,
|
|
2747
|
+
//depends on ColumnFiltering
|
|
2740
2748
|
RowSorting, ColumnGrouping,
|
|
2741
2749
|
//depends on RowSorting
|
|
2742
2750
|
RowExpanding, RowPagination, RowPinning, RowSelection, ColumnSizing];
|
|
@@ -3507,5 +3515,5 @@ function getSortedRowModel() {
|
|
|
3507
3515
|
}, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
|
|
3508
3516
|
}
|
|
3509
3517
|
|
|
3510
|
-
export { ColumnFaceting, ColumnFiltering, ColumnGrouping, ColumnOrdering, ColumnPinning, ColumnSizing, ColumnVisibility, GlobalFiltering, Headers, RowExpanding, RowPagination, RowPinning, RowSelection, RowSorting, _getVisibleLeafColumns, aggregationFns, buildHeaderGroups, createCell, createColumn, createColumnHelper, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getMemoOptions, getPaginationRowModel, getSortedRowModel, isFunction, isNumberArray, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
|
|
3518
|
+
export { ColumnFaceting, ColumnFiltering, ColumnGrouping, ColumnOrdering, ColumnPinning, ColumnSizing, ColumnVisibility, GlobalFaceting, GlobalFiltering, Headers, RowExpanding, RowPagination, RowPinning, RowSelection, RowSorting, _getVisibleLeafColumns, aggregationFns, buildHeaderGroups, createCell, createColumn, createColumnHelper, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getMemoOptions, getPaginationRowModel, getSortedRowModel, isFunction, isNumberArray, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
|
|
3511
3519
|
//# sourceMappingURL=index.esm.js.map
|