@tanstack/table-core 9.0.0-alpha.47 → 9.0.0-alpha.48
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/README.md +10 -0
- package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
- package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
- package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
- package/dist/core/columns/coreColumnsFeature.utils.cjs +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.js +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
- package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
- package/dist/core/headers/coreHeadersFeature.utils.cjs +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.js +23 -18
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
- package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs +34 -28
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.js +34 -28
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
- package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
- package/dist/core/table/coreTablesFeature.utils.cjs +2 -2
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
- package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
- package/dist/core/table/coreTablesFeature.utils.js +2 -2
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.js +111 -91
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +16 -13
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +16 -13
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +54 -42
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.js +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.js +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.js +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/fns/aggregationFns.cjs +33 -9
- package/dist/fns/aggregationFns.cjs.map +1 -1
- package/dist/fns/aggregationFns.d.cts +33 -9
- package/dist/fns/aggregationFns.d.ts +33 -9
- package/dist/fns/aggregationFns.js +33 -9
- package/dist/fns/aggregationFns.js.map +1 -1
- package/dist/fns/filterFns.cjs +48 -17
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.d.cts +42 -15
- package/dist/fns/filterFns.d.ts +42 -15
- package/dist/fns/filterFns.js +48 -17
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/helpers/columnHelper.cjs +9 -4
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +9 -4
- package/dist/helpers/columnHelper.d.ts +9 -4
- package/dist/helpers/columnHelper.js +9 -4
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/helpers/tableOptions.cjs.map +1 -1
- package/dist/helpers/tableOptions.d.cts +12 -9
- package/dist/helpers/tableOptions.d.ts +12 -9
- package/dist/helpers/tableOptions.js.map +1 -1
- package/dist/types/ColumnDef.d.cts +38 -0
- package/dist/types/ColumnDef.d.ts +38 -0
- package/dist/types/TableOptions.d.cts +15 -0
- package/dist/types/TableOptions.d.ts +15 -0
- package/dist/types/TableState.d.cts +12 -0
- package/dist/types/TableState.d.ts +12 -0
- package/package.json +5 -3
- package/skills/column-definitions/SKILL.md +333 -0
- package/skills/column-layout/SKILL.md +328 -0
- package/skills/column-layout/references/subsystems.md +220 -0
- package/skills/customizing-feature-behavior/SKILL.md +416 -0
- package/skills/filtering/SKILL.md +357 -0
- package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
- package/skills/grouping/SKILL.md +448 -0
- package/skills/migrate-v8-to-v9/SKILL.md +495 -0
- package/skills/pagination/SKILL.md +385 -0
- package/skills/row-expanding/SKILL.md +348 -0
- package/skills/row-pinning/SKILL.md +269 -0
- package/skills/row-selection/SKILL.md +391 -0
- package/skills/setup/SKILL.md +400 -0
- package/skills/sorting/SKILL.md +344 -0
- package/skills/state-management/SKILL.md +388 -0
- package/src/core/cells/coreCellsFeature.utils.ts +11 -8
- package/src/core/columns/coreColumnsFeature.types.ts +7 -6
- package/src/core/columns/coreColumnsFeature.utils.ts +37 -27
- package/src/core/headers/coreHeadersFeature.types.ts +6 -4
- package/src/core/headers/coreHeadersFeature.utils.ts +23 -18
- package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
- package/src/core/rows/coreRowsFeature.types.ts +4 -4
- package/src/core/rows/coreRowsFeature.utils.ts +34 -28
- package/src/core/table/coreTablesFeature.types.ts +6 -2
- package/src/core/table/coreTablesFeature.utils.ts +2 -2
- package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
- package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
- package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
- package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +30 -23
- package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
- package/src/features/column-pinning/columnPinningFeature.utils.ts +111 -91
- package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
- package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
- package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
- package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +16 -13
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +54 -42
- package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
- package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +56 -41
- package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
- package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
- package/src/features/row-pinning/rowPinningFeature.utils.ts +39 -29
- package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
- package/src/features/row-selection/rowSelectionFeature.utils.ts +89 -69
- package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
- package/src/features/row-sorting/rowSortingFeature.utils.ts +61 -44
- package/src/fns/aggregationFns.ts +33 -9
- package/src/fns/filterFns.ts +48 -17
- package/src/helpers/columnHelper.ts +9 -4
- package/src/helpers/tableOptions.ts +12 -9
- package/src/types/ColumnDef.ts +38 -0
- package/src/types/TableOptions.ts +15 -0
- package/src/types/TableState.ts +12 -0
|
@@ -6,64 +6,71 @@ import { Table_Internal } from "../../types/Table.js";
|
|
|
6
6
|
|
|
7
7
|
//#region src/features/column-filtering/columnFilteringFeature.utils.d.ts
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Creates the default column filter state.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* The feature default is an empty array, meaning no column filters are active.
|
|
12
|
+
* Reset APIs use this value when `defaultState` is `true`.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
15
|
-
* const
|
|
16
|
+
* const filters = getDefaultColumnFiltersState()
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
19
|
declare function getDefaultColumnFiltersState(): ColumnFiltersState;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Chooses a built-in filter function from the column's first core row value.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
+
* Strings use `includesString`, numbers use `inNumberRange`, booleans and
|
|
24
|
+
* objects use `equals`, arrays use `arrIncludes`, and unknown values fall back
|
|
25
|
+
* to `weakEquals`.
|
|
23
26
|
*
|
|
24
27
|
* @example
|
|
25
28
|
* ```ts
|
|
26
|
-
* const
|
|
29
|
+
* const filterFn = column_getAutoFilterFn(column)
|
|
27
30
|
* ```
|
|
28
31
|
*/
|
|
29
32
|
declare function column_getAutoFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): FilterFn<TFeatures, TData> | undefined;
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* Resolves the filter function configured for a column.
|
|
32
35
|
*
|
|
33
|
-
*
|
|
36
|
+
* Function-valued `columnDef.filterFn` is returned directly, `'auto'` delegates
|
|
37
|
+
* to `column_getAutoFilterFn`, and string values are looked up in the table's
|
|
38
|
+
* filter function registry.
|
|
34
39
|
*
|
|
35
40
|
* @example
|
|
36
41
|
* ```ts
|
|
37
|
-
* const
|
|
42
|
+
* const filterFn = column_getFilterFn(column)
|
|
38
43
|
* ```
|
|
39
44
|
*/
|
|
40
45
|
declare function column_getFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): FilterFn<TFeatures, TData> | undefined;
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
47
|
+
* Checks whether column filtering is enabled for this accessor column.
|
|
43
48
|
*
|
|
44
|
-
*
|
|
49
|
+
* The column must have an accessor and filtering must be enabled by the column
|
|
50
|
+
* definition, `enableColumnFilters`, and the table-wide `enableFilters` option.
|
|
45
51
|
*
|
|
46
52
|
* @example
|
|
47
53
|
* ```ts
|
|
48
|
-
* const
|
|
54
|
+
* const canFilter = column_getCanFilter(column)
|
|
49
55
|
* ```
|
|
50
56
|
*/
|
|
51
57
|
declare function column_getCanFilter<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): boolean;
|
|
52
58
|
/**
|
|
53
|
-
*
|
|
59
|
+
* Checks whether this column currently has an entry in `state.columnFilters`.
|
|
54
60
|
*
|
|
55
|
-
* This
|
|
61
|
+
* This only reflects filter state presence; it does not indicate whether the
|
|
62
|
+
* filter removes any rows.
|
|
56
63
|
*
|
|
57
64
|
* @example
|
|
58
65
|
* ```ts
|
|
59
|
-
* const
|
|
66
|
+
* const isFiltered = column_getIsFiltered(column)
|
|
60
67
|
* ```
|
|
61
68
|
*/
|
|
62
69
|
declare function column_getIsFiltered<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): boolean;
|
|
63
70
|
/**
|
|
64
|
-
*
|
|
71
|
+
* Reads this column's current filter value from `state.columnFilters`.
|
|
65
72
|
*
|
|
66
|
-
*
|
|
73
|
+
* Missing filter entries return `undefined`.
|
|
67
74
|
*
|
|
68
75
|
* @example
|
|
69
76
|
* ```ts
|
|
@@ -72,42 +79,46 @@ declare function column_getIsFiltered<TFeatures extends TableFeatures, TData ext
|
|
|
72
79
|
*/
|
|
73
80
|
declare function column_getFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): unknown;
|
|
74
81
|
/**
|
|
75
|
-
*
|
|
82
|
+
* Finds this column's position in the ordered `state.columnFilters` array.
|
|
76
83
|
*
|
|
77
|
-
*
|
|
84
|
+
* The result is `-1` when the column has no active filter.
|
|
78
85
|
*
|
|
79
86
|
* @example
|
|
80
87
|
* ```ts
|
|
81
|
-
* const
|
|
88
|
+
* const index = column_getFilterIndex(column)
|
|
82
89
|
* ```
|
|
83
90
|
*/
|
|
84
91
|
declare function column_getFilterIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): number;
|
|
85
92
|
/**
|
|
86
|
-
*
|
|
93
|
+
* Adds, updates, or removes this column's filter value.
|
|
87
94
|
*
|
|
88
|
-
*
|
|
95
|
+
* The incoming value may be an updater. After resolution, `autoRemove` rules
|
|
96
|
+
* decide whether the filter should be removed instead of stored.
|
|
89
97
|
*
|
|
90
98
|
* @example
|
|
91
99
|
* ```ts
|
|
92
|
-
* column_setFilterValue(column, (old) => old)
|
|
100
|
+
* column_setFilterValue(column, (old) => String(old ?? '').trim())
|
|
93
101
|
* ```
|
|
94
102
|
*/
|
|
95
103
|
declare function column_setFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>, value: any): void;
|
|
96
104
|
/**
|
|
97
|
-
*
|
|
105
|
+
* Routes a column filter updater through the table's filter change handler.
|
|
98
106
|
*
|
|
99
|
-
* The
|
|
107
|
+
* The resolved filters are cleaned before they are emitted: filters for known
|
|
108
|
+
* columns are removed when their filter function says the value should be
|
|
109
|
+
* auto-removed.
|
|
100
110
|
*
|
|
101
111
|
* @example
|
|
102
112
|
* ```ts
|
|
103
|
-
* table_setColumnFilters(table, (old) => old)
|
|
113
|
+
* table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))
|
|
104
114
|
* ```
|
|
105
115
|
*/
|
|
106
116
|
declare function table_setColumnFilters<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnFiltersState>): void;
|
|
107
117
|
/**
|
|
108
|
-
* Resets the
|
|
118
|
+
* Resets `columnFilters` to the configured initial state or feature default.
|
|
109
119
|
*
|
|
110
|
-
*
|
|
120
|
+
* With no argument, the reset clones `table.initialState.columnFilters` when it
|
|
121
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
111
122
|
*
|
|
112
123
|
* @example
|
|
113
124
|
* ```ts
|
|
@@ -2,26 +2,29 @@ import { cloneState, functionalUpdate, isFunction } from "../../utils.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/features/column-filtering/columnFilteringFeature.utils.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates the default column filter state.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* The feature default is an empty array, meaning no column filters are active.
|
|
8
|
+
* Reset APIs use this value when `defaultState` is `true`.
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
11
|
* ```ts
|
|
11
|
-
* const
|
|
12
|
+
* const filters = getDefaultColumnFiltersState()
|
|
12
13
|
* ```
|
|
13
14
|
*/
|
|
14
15
|
function getDefaultColumnFiltersState() {
|
|
15
16
|
return [];
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Chooses a built-in filter function from the column's first core row value.
|
|
19
20
|
*
|
|
20
|
-
*
|
|
21
|
+
* Strings use `includesString`, numbers use `inNumberRange`, booleans and
|
|
22
|
+
* objects use `equals`, arrays use `arrIncludes`, and unknown values fall back
|
|
23
|
+
* to `weakEquals`.
|
|
21
24
|
*
|
|
22
25
|
* @example
|
|
23
26
|
* ```ts
|
|
24
|
-
* const
|
|
27
|
+
* const filterFn = column_getAutoFilterFn(column)
|
|
25
28
|
* ```
|
|
26
29
|
*/
|
|
27
30
|
function column_getAutoFilterFn(column) {
|
|
@@ -36,13 +39,15 @@ function column_getAutoFilterFn(column) {
|
|
|
36
39
|
return filterFns === null || filterFns === void 0 ? void 0 : filterFns.weakEquals;
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
42
|
+
* Resolves the filter function configured for a column.
|
|
40
43
|
*
|
|
41
|
-
*
|
|
44
|
+
* Function-valued `columnDef.filterFn` is returned directly, `'auto'` delegates
|
|
45
|
+
* to `column_getAutoFilterFn`, and string values are looked up in the table's
|
|
46
|
+
* filter function registry.
|
|
42
47
|
*
|
|
43
48
|
* @example
|
|
44
49
|
* ```ts
|
|
45
|
-
* const
|
|
50
|
+
* const filterFn = column_getFilterFn(column)
|
|
46
51
|
* ```
|
|
47
52
|
*/
|
|
48
53
|
function column_getFilterFn(column) {
|
|
@@ -53,35 +58,37 @@ function column_getFilterFn(column) {
|
|
|
53
58
|
return filterFn;
|
|
54
59
|
}
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
61
|
+
* Checks whether column filtering is enabled for this accessor column.
|
|
57
62
|
*
|
|
58
|
-
*
|
|
63
|
+
* The column must have an accessor and filtering must be enabled by the column
|
|
64
|
+
* definition, `enableColumnFilters`, and the table-wide `enableFilters` option.
|
|
59
65
|
*
|
|
60
66
|
* @example
|
|
61
67
|
* ```ts
|
|
62
|
-
* const
|
|
68
|
+
* const canFilter = column_getCanFilter(column)
|
|
63
69
|
* ```
|
|
64
70
|
*/
|
|
65
71
|
function column_getCanFilter(column) {
|
|
66
72
|
return (column.columnDef.enableColumnFilter ?? true) && (column.table.options.enableColumnFilters ?? true) && (column.table.options.enableFilters ?? true) && !!column.accessorFn;
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
|
-
*
|
|
75
|
+
* Checks whether this column currently has an entry in `state.columnFilters`.
|
|
70
76
|
*
|
|
71
|
-
* This
|
|
77
|
+
* This only reflects filter state presence; it does not indicate whether the
|
|
78
|
+
* filter removes any rows.
|
|
72
79
|
*
|
|
73
80
|
* @example
|
|
74
81
|
* ```ts
|
|
75
|
-
* const
|
|
82
|
+
* const isFiltered = column_getIsFiltered(column)
|
|
76
83
|
* ```
|
|
77
84
|
*/
|
|
78
85
|
function column_getIsFiltered(column) {
|
|
79
86
|
return column_getFilterIndex(column) > -1;
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
82
|
-
*
|
|
89
|
+
* Reads this column's current filter value from `state.columnFilters`.
|
|
83
90
|
*
|
|
84
|
-
*
|
|
91
|
+
* Missing filter entries return `undefined`.
|
|
85
92
|
*
|
|
86
93
|
* @example
|
|
87
94
|
* ```ts
|
|
@@ -93,13 +100,13 @@ function column_getFilterValue(column) {
|
|
|
93
100
|
return (_column$table$atoms$c = column.table.atoms.columnFilters) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.get()) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.find((d) => d.id === column.id)) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c.value;
|
|
94
101
|
}
|
|
95
102
|
/**
|
|
96
|
-
*
|
|
103
|
+
* Finds this column's position in the ordered `state.columnFilters` array.
|
|
97
104
|
*
|
|
98
|
-
*
|
|
105
|
+
* The result is `-1` when the column has no active filter.
|
|
99
106
|
*
|
|
100
107
|
* @example
|
|
101
108
|
* ```ts
|
|
102
|
-
* const
|
|
109
|
+
* const index = column_getFilterIndex(column)
|
|
103
110
|
* ```
|
|
104
111
|
*/
|
|
105
112
|
function column_getFilterIndex(column) {
|
|
@@ -107,13 +114,14 @@ function column_getFilterIndex(column) {
|
|
|
107
114
|
return ((_column$table$atoms$c2 = column.table.atoms.columnFilters) === null || _column$table$atoms$c2 === void 0 || (_column$table$atoms$c2 = _column$table$atoms$c2.get()) === null || _column$table$atoms$c2 === void 0 ? void 0 : _column$table$atoms$c2.findIndex((d) => d.id === column.id)) ?? -1;
|
|
108
115
|
}
|
|
109
116
|
/**
|
|
110
|
-
*
|
|
117
|
+
* Adds, updates, or removes this column's filter value.
|
|
111
118
|
*
|
|
112
|
-
*
|
|
119
|
+
* The incoming value may be an updater. After resolution, `autoRemove` rules
|
|
120
|
+
* decide whether the filter should be removed instead of stored.
|
|
113
121
|
*
|
|
114
122
|
* @example
|
|
115
123
|
* ```ts
|
|
116
|
-
* column_setFilterValue(column, (old) => old)
|
|
124
|
+
* column_setFilterValue(column, (old) => String(old ?? '').trim())
|
|
117
125
|
* ```
|
|
118
126
|
*/
|
|
119
127
|
function column_setFilterValue(column, value) {
|
|
@@ -135,13 +143,15 @@ function column_setFilterValue(column, value) {
|
|
|
135
143
|
});
|
|
136
144
|
}
|
|
137
145
|
/**
|
|
138
|
-
*
|
|
146
|
+
* Routes a column filter updater through the table's filter change handler.
|
|
139
147
|
*
|
|
140
|
-
* The
|
|
148
|
+
* The resolved filters are cleaned before they are emitted: filters for known
|
|
149
|
+
* columns are removed when their filter function says the value should be
|
|
150
|
+
* auto-removed.
|
|
141
151
|
*
|
|
142
152
|
* @example
|
|
143
153
|
* ```ts
|
|
144
|
-
* table_setColumnFilters(table, (old) => old)
|
|
154
|
+
* table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))
|
|
145
155
|
* ```
|
|
146
156
|
*/
|
|
147
157
|
function table_setColumnFilters(table, updater) {
|
|
@@ -159,9 +169,10 @@ function table_setColumnFilters(table, updater) {
|
|
|
159
169
|
(_table$options$onColu = (_table$options = table.options).onColumnFiltersChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updateFn);
|
|
160
170
|
}
|
|
161
171
|
/**
|
|
162
|
-
* Resets the
|
|
172
|
+
* Resets `columnFilters` to the configured initial state or feature default.
|
|
163
173
|
*
|
|
164
|
-
*
|
|
174
|
+
* With no argument, the reset clones `table.initialState.columnFilters` when it
|
|
175
|
+
* exists. Passing `true` ignores initial state and resets to `[]`.
|
|
165
176
|
*
|
|
166
177
|
* @example
|
|
167
178
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnFilteringFeature.utils.js","names":[],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate, isFunction } from '../../utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\n/**\n * Returns the default column filters state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnFiltersState()\n * ```\n */\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return []\n}\n\n/**\n * Infers filter fn for a column.\n *\n * The inference uses the column definition, table options, and sampled row values when needed.\n *\n * @example\n * ```ts\n * const value = column_getAutoFilterFn(column)\n * ```\n */\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\n/**\n * Returns filter fn for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterFn(column)\n * ```\n */\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\n/**\n * Returns whether a column can use filter.\n *\n * This combines column options, table options, and any required accessor or feature state for the capability.\n *\n * @example\n * ```ts\n * const value = column_getCanFilter(column)\n * ```\n */\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Returns is filtered for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFiltered(column)\n * ```\n */\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\n/**\n * Returns filter value for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterValue(column)\n * ```\n */\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.atoms.columnFilters\n ?.get()\n ?.find((d) => d.id === column.id)?.value\n}\n\n/**\n * Returns filter index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterIndex(column)\n * ```\n */\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.atoms.columnFilters\n ?.get()\n ?.findIndex((d) => d.id === column.id) ?? -1\n )\n}\n\n/**\n * Updates filter value for a column.\n *\n * This delegates to the owning table state updater so external state, external atoms, and internal state stay synchronized.\n *\n * @example\n * ```ts\n * column_setFilterValue(column, (old) => old)\n * ```\n */\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\n/**\n * Updates the table's column filters state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnFilters(table, (old) => old)\n * ```\n */\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumnsById[filter.id]\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\n/**\n * Resets the table's column filters state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnFilters(table)\n * table_resetColumnFilters(table, true)\n * ```\n */\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : cloneState(table.initialState.columnFilters ?? []),\n )\n}\n\n/**\n * Returns whether a filter value should be removed from filter state.\n *\n * This checks the filter function's `autoRemove` hook and built-in empty-value rules.\n *\n * @example\n * ```ts\n * const removeFilter = shouldAutoRemoveFilter(filterFn, value, column)\n * ```\n */\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"columnFilteringFeature.utils.js","names":[],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate, isFunction } from '../../utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates the default column filter state.\n *\n * The feature default is an empty array, meaning no column filters are active.\n * Reset APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const filters = getDefaultColumnFiltersState()\n * ```\n */\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return []\n}\n\n/**\n * Chooses a built-in filter function from the column's first core row value.\n *\n * Strings use `includesString`, numbers use `inNumberRange`, booleans and\n * objects use `equals`, arrays use `arrIncludes`, and unknown values fall back\n * to `weakEquals`.\n *\n * @example\n * ```ts\n * const filterFn = column_getAutoFilterFn(column)\n * ```\n */\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\n/**\n * Resolves the filter function configured for a column.\n *\n * Function-valued `columnDef.filterFn` is returned directly, `'auto'` delegates\n * to `column_getAutoFilterFn`, and string values are looked up in the table's\n * filter function registry.\n *\n * @example\n * ```ts\n * const filterFn = column_getFilterFn(column)\n * ```\n */\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\n/**\n * Checks whether column filtering is enabled for this accessor column.\n *\n * The column must have an accessor and filtering must be enabled by the column\n * definition, `enableColumnFilters`, and the table-wide `enableFilters` option.\n *\n * @example\n * ```ts\n * const canFilter = column_getCanFilter(column)\n * ```\n */\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Checks whether this column currently has an entry in `state.columnFilters`.\n *\n * This only reflects filter state presence; it does not indicate whether the\n * filter removes any rows.\n *\n * @example\n * ```ts\n * const isFiltered = column_getIsFiltered(column)\n * ```\n */\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\n/**\n * Reads this column's current filter value from `state.columnFilters`.\n *\n * Missing filter entries return `undefined`.\n *\n * @example\n * ```ts\n * const value = column_getFilterValue(column)\n * ```\n */\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.atoms.columnFilters\n ?.get()\n ?.find((d) => d.id === column.id)?.value\n}\n\n/**\n * Finds this column's position in the ordered `state.columnFilters` array.\n *\n * The result is `-1` when the column has no active filter.\n *\n * @example\n * ```ts\n * const index = column_getFilterIndex(column)\n * ```\n */\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.atoms.columnFilters\n ?.get()\n ?.findIndex((d) => d.id === column.id) ?? -1\n )\n}\n\n/**\n * Adds, updates, or removes this column's filter value.\n *\n * The incoming value may be an updater. After resolution, `autoRemove` rules\n * decide whether the filter should be removed instead of stored.\n *\n * @example\n * ```ts\n * column_setFilterValue(column, (old) => String(old ?? '').trim())\n * ```\n */\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\n/**\n * Routes a column filter updater through the table's filter change handler.\n *\n * The resolved filters are cleaned before they are emitted: filters for known\n * columns are removed when their filter function says the value should be\n * auto-removed.\n *\n * @example\n * ```ts\n * table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))\n * ```\n */\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumnsById[filter.id]\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\n/**\n * Resets `columnFilters` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.columnFilters` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetColumnFilters(table)\n * table_resetColumnFilters(table, true)\n * ```\n */\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : cloneState(table.initialState.columnFilters ?? []),\n )\n}\n\n/**\n * Returns whether a filter value should be removed from filter state.\n *\n * This checks the filter function's `autoRemove` hook and built-in empty-value rules.\n *\n * @example\n * ```ts\n * const removeFilter = shouldAutoRemoveFilter(filterFn, value, column)\n * ```\n */\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,+BAAmD;CACjE,OAAO,EAAE;;;;;;;;;;;;;;AAeX,SAAgB,uBAId,QAAmD;CACnD,MAAM,YACJ,OAAO,MAAM,aAAa;CAE5B,MAAM,WAAW,OAAO,MAAM,iBAAiB,CAAC,SAAS;CAEzD,MAAM,QAAQ,WAAW,SAAS,SAAS,OAAO,GAAG,GAAG;CAExD,IAAI,OAAO,UAAU,UACnB,6DAAO,UAAW;CAGpB,IAAI,OAAO,UAAU,UACnB,6DAAO,UAAW;CAGpB,IAAI,OAAO,UAAU,WACnB,6DAAO,UAAW;CAGpB,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,6DAAO,UAAW;CAGpB,IAAI,MAAM,QAAQ,MAAM,EACtB,6DAAO,UAAW;CAGpB,6DAAO,UAAW;;;;;;;;;;;;;;AAepB,SAAgB,mBAKd,QACwC;CACxC,IAAI,WAAW;CACf,MAAM,YACJ,OAAO,MAAM,aAAa;CAC5B,WAAW,WAAW,OAAO,UAAU,SAAS,GAC5C,OAAO,UAAU,WACjB,OAAO,UAAU,aAAa,SAC5B,uBAAuB,OAAO,yDAC9B,UAAY,OAAO,UAAU;CAEnC,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,UAC7C,QAAQ,KACN,oEAAoE,OAAO,GAAG,GAC/E;CAGH,OAAO;;;;;;;;;;;;;AAcT,SAAgB,oBAId,QAAmD;CACnD,QACG,OAAO,UAAU,sBAAsB,UACvC,OAAO,MAAM,QAAQ,uBAAuB,UAC5C,OAAO,MAAM,QAAQ,iBAAiB,SACvC,CAAC,CAAC,OAAO;;;;;;;;;;;;;AAeb,SAAgB,qBAId,QAAmD;CACnD,OAAO,sBAAsB,OAAO,GAAG;;;;;;;;;;;;AAazC,SAAgB,sBAId,QAAmD;;CACnD,gCAAO,OAAO,MAAM,MAAM,8GACtB,KAAK,iGACL,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG,gFAAE;;;;;;;;;;;;AAavC,SAAgB,sBAId,QAA2D;;CAC3D,kCACE,OAAO,MAAM,MAAM,iHACf,KAAK,kFACL,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG,KAAI;;;;;;;;;;;;;AAehD,SAAgB,sBAId,QAAmD,OAAY;CAC/D,uBAAuB,OAAO,QAAQ,QAAQ;EAC5C,MAAM,WAAW,mBAAmB,OAAO;EAC3C,MAAM,iBAAiB,IAAI,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG;EAE1D,MAAM,YAAY,iBAChB,OACA,iBAAiB,eAAe,QAAQ,OACzC;EAED,IAAI,uBAAuB,UAAU,WAAW,OAAO,EACrD,OAAO,IAAI,QAAQ,MAAM,EAAE,OAAO,OAAO,GAAG;EAG9C,MAAM,eAAe;GAAE,IAAI,OAAO;GAAI,OAAO;GAAW;EAExD,IAAI,gBACF,OAAO,IAAI,KAAK,MAAM;GACpB,IAAI,EAAE,OAAO,OAAO,IAClB,OAAO;GAET,OAAO;IACP;EAGJ,IAAI,IAAI,QACN,OAAO,CAAC,GAAG,KAAK,aAAa;EAG/B,OAAO,CAAC,aAAa;GACrB;;;;;;;;;;;;;;AAeJ,SAAgB,uBAId,OACA,SACA;;CACA,MAAM,kBAAkB,MAAM,uBAAuB;CAErD,MAAM,YAAY,QAA4B;EAC5C,OAAO,iBAAiB,SAAS,IAAI,CAAC,QAAQ,WAAW;GACvD,MAAM,SAAS,gBAAgB,OAAO;GAEtC,IAAI,QAGF;QAAI,uBAFa,mBAAmB,OAED,EAAE,OAAO,OAAO,OAAO,EACxD,OAAO;;GAIX,OAAO;IACP;;CAGJ,iDAAM,SAAQ,kHAAwB,SAAS;;;;;;;;;;;;;;AAejD,SAAgB,yBAGd,OAAyC,cAAwB;CACjE,uBACE,OACA,eAAe,EAAE,GAAG,WAAW,MAAM,aAAa,iBAAiB,EAAE,CAAC,CACvE;;;;;;;;;;;;AAaH,SAAgB,uBAKd,UACA,OACA,QACA;CACA,QACG,YAAY,SAAS,aAClB,SAAS,WAAW,OAAO,OAAO,GAClC,UACJ,OAAO,UAAU,eAChB,OAAO,UAAU,YAAY,CAAC"}
|
|
@@ -29,7 +29,9 @@ interface ColumnDef_ColumnGrouping<TFeatures extends TableFeatures, TData extend
|
|
|
29
29
|
*/
|
|
30
30
|
aggregationFn?: AggregationFnOption<TFeatures, TData>;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Allows this column to be added to grouping state.
|
|
33
|
+
*
|
|
34
|
+
* Defaults to `true`; table-level `enableGrouping` must also allow grouping.
|
|
33
35
|
*/
|
|
34
36
|
enableGrouping?: boolean;
|
|
35
37
|
/**
|
|
@@ -47,15 +49,15 @@ interface Column_ColumnGrouping<TFeatures extends TableFeatures, TData extends R
|
|
|
47
49
|
*/
|
|
48
50
|
getAutoAggregationFn: () => AggregationFn<TFeatures, TData> | undefined;
|
|
49
51
|
/**
|
|
50
|
-
*
|
|
52
|
+
* Checks whether this column can currently be grouped.
|
|
51
53
|
*/
|
|
52
54
|
getCanGroup: () => boolean;
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* Finds this column's position in the ordered grouping state.
|
|
55
57
|
*/
|
|
56
58
|
getGroupedIndex: () => number;
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
60
|
+
* Checks whether this column id is present in grouping state.
|
|
59
61
|
*/
|
|
60
62
|
getIsGrouped: () => boolean;
|
|
61
63
|
/**
|
|
@@ -70,11 +72,11 @@ interface Column_ColumnGrouping<TFeatures extends TableFeatures, TData extends R
|
|
|
70
72
|
interface Row_ColumnGrouping {
|
|
71
73
|
_groupingValuesCache: Record<string, any>;
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
75
|
+
* Reads the value used to group this row for a column id.
|
|
74
76
|
*/
|
|
75
77
|
getGroupingValue: (columnId: string) => unknown;
|
|
76
78
|
/**
|
|
77
|
-
*
|
|
79
|
+
* Checks whether this row represents a grouped row.
|
|
78
80
|
*/
|
|
79
81
|
getIsGrouped: () => boolean;
|
|
80
82
|
/**
|
|
@@ -88,15 +90,15 @@ interface Row_ColumnGrouping {
|
|
|
88
90
|
}
|
|
89
91
|
interface Cell_ColumnGrouping {
|
|
90
92
|
/**
|
|
91
|
-
*
|
|
93
|
+
* Checks whether this cell should render an aggregated value.
|
|
92
94
|
*/
|
|
93
95
|
getIsAggregated: () => boolean;
|
|
94
96
|
/**
|
|
95
|
-
*
|
|
97
|
+
* Checks whether this cell represents the active grouping column.
|
|
96
98
|
*/
|
|
97
99
|
getIsGrouped: () => boolean;
|
|
98
100
|
/**
|
|
99
|
-
*
|
|
101
|
+
* Checks whether this cell is hidden as a grouping placeholder.
|
|
100
102
|
*/
|
|
101
103
|
getIsPlaceholder: () => boolean;
|
|
102
104
|
}
|
|
@@ -106,7 +108,7 @@ interface ColumnDefaultOptions {
|
|
|
106
108
|
}
|
|
107
109
|
interface TableOptions_ColumnGrouping {
|
|
108
110
|
/**
|
|
109
|
-
*
|
|
111
|
+
* Allows columns to be grouped for this table.
|
|
110
112
|
*/
|
|
111
113
|
enableGrouping?: boolean;
|
|
112
114
|
/**
|
|
@@ -127,21 +129,23 @@ interface TableOptions_ColumnGrouping {
|
|
|
127
129
|
type GroupingColumnMode = false | 'reorder' | 'remove';
|
|
128
130
|
interface Table_ColumnGrouping<TFeatures extends TableFeatures, TData extends RowData> {
|
|
129
131
|
/**
|
|
130
|
-
* Resets
|
|
132
|
+
* Resets `grouping` to `initialState.grouping`.
|
|
133
|
+
*
|
|
134
|
+
* Pass `true` to ignore initial state and reset to `[]`.
|
|
131
135
|
*/
|
|
132
136
|
resetGrouping: (defaultState?: boolean) => void;
|
|
133
137
|
/**
|
|
134
|
-
*
|
|
138
|
+
* Updates grouping state with a next ordered id array or updater function.
|
|
135
139
|
*/
|
|
136
140
|
setGrouping: (updater: Updater<GroupingState>) => void;
|
|
137
141
|
}
|
|
138
142
|
interface Table_RowModels_Grouped<TFeatures extends TableFeatures, TData extends RowData> {
|
|
139
143
|
/**
|
|
140
|
-
*
|
|
144
|
+
* Resolves the row model after grouping and aggregation have been applied.
|
|
141
145
|
*/
|
|
142
146
|
getGroupedRowModel: () => RowModel<TFeatures, TData>;
|
|
143
147
|
/**
|
|
144
|
-
*
|
|
148
|
+
* Reads the row model immediately before grouping.
|
|
145
149
|
*/
|
|
146
150
|
getPreGroupedRowModel: () => RowModel<TFeatures, TData>;
|
|
147
151
|
}
|
|
@@ -29,7 +29,9 @@ interface ColumnDef_ColumnGrouping<TFeatures extends TableFeatures, TData extend
|
|
|
29
29
|
*/
|
|
30
30
|
aggregationFn?: AggregationFnOption<TFeatures, TData>;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Allows this column to be added to grouping state.
|
|
33
|
+
*
|
|
34
|
+
* Defaults to `true`; table-level `enableGrouping` must also allow grouping.
|
|
33
35
|
*/
|
|
34
36
|
enableGrouping?: boolean;
|
|
35
37
|
/**
|
|
@@ -47,15 +49,15 @@ interface Column_ColumnGrouping<TFeatures extends TableFeatures, TData extends R
|
|
|
47
49
|
*/
|
|
48
50
|
getAutoAggregationFn: () => AggregationFn<TFeatures, TData> | undefined;
|
|
49
51
|
/**
|
|
50
|
-
*
|
|
52
|
+
* Checks whether this column can currently be grouped.
|
|
51
53
|
*/
|
|
52
54
|
getCanGroup: () => boolean;
|
|
53
55
|
/**
|
|
54
|
-
*
|
|
56
|
+
* Finds this column's position in the ordered grouping state.
|
|
55
57
|
*/
|
|
56
58
|
getGroupedIndex: () => number;
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
60
|
+
* Checks whether this column id is present in grouping state.
|
|
59
61
|
*/
|
|
60
62
|
getIsGrouped: () => boolean;
|
|
61
63
|
/**
|
|
@@ -70,11 +72,11 @@ interface Column_ColumnGrouping<TFeatures extends TableFeatures, TData extends R
|
|
|
70
72
|
interface Row_ColumnGrouping {
|
|
71
73
|
_groupingValuesCache: Record<string, any>;
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
75
|
+
* Reads the value used to group this row for a column id.
|
|
74
76
|
*/
|
|
75
77
|
getGroupingValue: (columnId: string) => unknown;
|
|
76
78
|
/**
|
|
77
|
-
*
|
|
79
|
+
* Checks whether this row represents a grouped row.
|
|
78
80
|
*/
|
|
79
81
|
getIsGrouped: () => boolean;
|
|
80
82
|
/**
|
|
@@ -88,15 +90,15 @@ interface Row_ColumnGrouping {
|
|
|
88
90
|
}
|
|
89
91
|
interface Cell_ColumnGrouping {
|
|
90
92
|
/**
|
|
91
|
-
*
|
|
93
|
+
* Checks whether this cell should render an aggregated value.
|
|
92
94
|
*/
|
|
93
95
|
getIsAggregated: () => boolean;
|
|
94
96
|
/**
|
|
95
|
-
*
|
|
97
|
+
* Checks whether this cell represents the active grouping column.
|
|
96
98
|
*/
|
|
97
99
|
getIsGrouped: () => boolean;
|
|
98
100
|
/**
|
|
99
|
-
*
|
|
101
|
+
* Checks whether this cell is hidden as a grouping placeholder.
|
|
100
102
|
*/
|
|
101
103
|
getIsPlaceholder: () => boolean;
|
|
102
104
|
}
|
|
@@ -106,7 +108,7 @@ interface ColumnDefaultOptions {
|
|
|
106
108
|
}
|
|
107
109
|
interface TableOptions_ColumnGrouping {
|
|
108
110
|
/**
|
|
109
|
-
*
|
|
111
|
+
* Allows columns to be grouped for this table.
|
|
110
112
|
*/
|
|
111
113
|
enableGrouping?: boolean;
|
|
112
114
|
/**
|
|
@@ -127,21 +129,23 @@ interface TableOptions_ColumnGrouping {
|
|
|
127
129
|
type GroupingColumnMode = false | 'reorder' | 'remove';
|
|
128
130
|
interface Table_ColumnGrouping<TFeatures extends TableFeatures, TData extends RowData> {
|
|
129
131
|
/**
|
|
130
|
-
* Resets
|
|
132
|
+
* Resets `grouping` to `initialState.grouping`.
|
|
133
|
+
*
|
|
134
|
+
* Pass `true` to ignore initial state and reset to `[]`.
|
|
131
135
|
*/
|
|
132
136
|
resetGrouping: (defaultState?: boolean) => void;
|
|
133
137
|
/**
|
|
134
|
-
*
|
|
138
|
+
* Updates grouping state with a next ordered id array or updater function.
|
|
135
139
|
*/
|
|
136
140
|
setGrouping: (updater: Updater<GroupingState>) => void;
|
|
137
141
|
}
|
|
138
142
|
interface Table_RowModels_Grouped<TFeatures extends TableFeatures, TData extends RowData> {
|
|
139
143
|
/**
|
|
140
|
-
*
|
|
144
|
+
* Resolves the row model after grouping and aggregation have been applied.
|
|
141
145
|
*/
|
|
142
146
|
getGroupedRowModel: () => RowModel<TFeatures, TData>;
|
|
143
147
|
/**
|
|
144
|
-
*
|
|
148
|
+
* Reads the row model immediately before grouping.
|
|
145
149
|
*/
|
|
146
150
|
getPreGroupedRowModel: () => RowModel<TFeatures, TData>;
|
|
147
151
|
}
|