@tanstack/table-core 9.0.0-beta.15 → 9.0.0-beta.17
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/dist/core/cells/constructCell.d.cts +2 -2
- package/dist/core/cells/constructCell.d.ts +2 -2
- package/dist/core/cells/coreCellsFeature.types.d.cts +2 -2
- package/dist/core/cells/coreCellsFeature.types.d.ts +2 -2
- package/dist/core/cells/coreCellsFeature.utils.d.cts +2 -2
- package/dist/core/cells/coreCellsFeature.utils.d.ts +2 -2
- package/dist/core/columns/constructColumn.d.cts +2 -2
- package/dist/core/columns/constructColumn.d.ts +2 -2
- package/dist/core/columns/coreColumnsFeature.types.d.cts +2 -2
- package/dist/core/columns/coreColumnsFeature.types.d.ts +2 -2
- package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -2
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +8 -8
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +8 -8
- package/dist/core/columns/coreColumnsFeature.utils.js +3 -3
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +2 -2
- package/dist/core/headers/buildHeaderGroups.d.ts +2 -2
- package/dist/core/headers/constructHeader.d.cts +2 -2
- package/dist/core/headers/constructHeader.d.ts +2 -2
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +6 -6
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +13 -13
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +13 -13
- package/dist/core/row-models/createCoreRowModel.cjs +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
- package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
- package/dist/core/row-models/createCoreRowModel.js +2 -2
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +3 -2
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.d.cts +2 -2
- package/dist/core/rows/constructRow.d.ts +2 -2
- package/dist/core/rows/constructRow.js +4 -2
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +2 -2
- package/dist/core/rows/coreRowsFeature.types.d.ts +2 -2
- package/dist/core/rows/coreRowsFeature.utils.cjs +3 -3
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +3 -3
- package/dist/core/rows/coreRowsFeature.utils.d.ts +3 -3
- package/dist/core/rows/coreRowsFeature.utils.js +4 -4
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +1 -1
- package/dist/core/table/coreTablesFeature.types.d.ts +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +5 -5
- package/dist/core/table/coreTablesFeature.utils.d.ts +5 -5
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +8 -8
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +8 -8
- package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
- package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +12 -12
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +12 -12
- package/dist/features/column-filtering/createFilteredRowModel.cjs +8 -5
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +9 -6
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.js +3 -2
- package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +3 -3
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +11 -11
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +11 -11
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +4 -5
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +5 -6
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +9 -9
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +9 -9
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +29 -29
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +29 -29
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +2 -5
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.js +3 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -4
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +12 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +12 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.js +12 -5
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +12 -9
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +14 -14
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +14 -14
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +13 -10
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +6 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +6 -6
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +21 -12
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +22 -13
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +17 -17
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +17 -17
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +7 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +7 -7
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +15 -12
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +27 -15
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +27 -15
- package/dist/features/row-selection/rowSelectionFeature.utils.js +16 -13
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +2 -2
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +16 -16
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +16 -16
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/types/Column.d.cts +2 -4
- package/dist/types/Column.d.ts +2 -4
- package/dist/types/Table.d.cts +3 -16
- package/dist/types/Table.d.ts +3 -16
- package/dist/types/TableFeatures.d.cts +7 -7
- package/dist/types/TableFeatures.d.ts +7 -7
- package/dist/utils.cjs +24 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +16 -5
- package/dist/utils.d.ts +16 -5
- package/dist/utils.js +23 -3
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/core/columns/coreColumnsFeature.utils.ts +3 -3
- package/src/core/headers/coreHeadersFeature.types.ts +2 -2
- package/src/core/row-models/createCoreRowModel.ts +2 -2
- package/src/core/rows/constructRow.ts +3 -2
- package/src/core/rows/coreRowsFeature.utils.ts +4 -4
- package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
- package/src/features/column-filtering/createFilteredRowModel.ts +13 -10
- package/src/features/column-filtering/filterRowsUtils.ts +3 -2
- package/src/features/column-grouping/columnGroupingFeature.ts +2 -1
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -2
- package/src/features/column-grouping/createGroupedRowModel.ts +10 -5
- package/src/features/column-resizing/columnResizingFeature.utils.ts +5 -6
- package/src/features/column-sizing/columnSizingFeature.utils.ts +27 -5
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +31 -15
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
- package/src/features/row-selection/rowSelectionFeature.utils.ts +35 -13
- package/src/features/row-sorting/createSortedRowModel.ts +6 -9
- package/src/types/Column.ts +3 -1
- package/src/utils.ts +24 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CellData, RowData, Updater } from "../../types/type-utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Column } from "../../types/Column.js";
|
|
3
3
|
import { ColumnFiltersState, FilterFn } from "./columnFilteringFeature.types.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Table } from "../../types/Table.js";
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
6
|
|
|
7
7
|
//#region src/features/column-filtering/columnFilteringFeature.utils.d.ts
|
|
@@ -29,7 +29,7 @@ declare function getDefaultColumnFiltersState(): ColumnFiltersState;
|
|
|
29
29
|
* const filterFn = column_getAutoFilterFn(column)
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare function column_getAutoFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
32
|
+
declare function column_getAutoFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): FilterFn<TFeatures, TData> | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Resolves the filter function configured for a column.
|
|
35
35
|
*
|
|
@@ -42,7 +42,7 @@ declare function column_getAutoFilterFn<TFeatures extends TableFeatures, TData e
|
|
|
42
42
|
* const filterFn = column_getFilterFn(column)
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
declare function column_getFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
45
|
+
declare function column_getFilterFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): FilterFn<TFeatures, TData> | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* Checks whether column filtering is enabled for this accessor column.
|
|
48
48
|
*
|
|
@@ -54,7 +54,7 @@ declare function column_getFilterFn<TFeatures extends TableFeatures, TData exten
|
|
|
54
54
|
* const canFilter = column_getCanFilter(column)
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
declare function column_getCanFilter<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
57
|
+
declare function column_getCanFilter<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Checks whether this column currently has an entry in `state.columnFilters`.
|
|
60
60
|
*
|
|
@@ -66,7 +66,7 @@ declare function column_getCanFilter<TFeatures extends TableFeatures, TData exte
|
|
|
66
66
|
* const isFiltered = column_getIsFiltered(column)
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
declare function column_getIsFiltered<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
69
|
+
declare function column_getIsFiltered<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): boolean;
|
|
70
70
|
/**
|
|
71
71
|
* Reads this column's current filter value from `state.columnFilters`.
|
|
72
72
|
*
|
|
@@ -77,7 +77,7 @@ declare function column_getIsFiltered<TFeatures extends TableFeatures, TData ext
|
|
|
77
77
|
* const value = column_getFilterValue(column)
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
declare function column_getFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
80
|
+
declare function column_getFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): unknown;
|
|
81
81
|
/**
|
|
82
82
|
* Finds this column's position in the ordered `state.columnFilters` array.
|
|
83
83
|
*
|
|
@@ -88,7 +88,7 @@ declare function column_getFilterValue<TFeatures extends TableFeatures, TData ex
|
|
|
88
88
|
* const index = column_getFilterIndex(column)
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
|
-
declare function column_getFilterIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
91
|
+
declare function column_getFilterIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): number;
|
|
92
92
|
/**
|
|
93
93
|
* Adds, updates, or removes this column's filter value.
|
|
94
94
|
*
|
|
@@ -100,7 +100,7 @@ declare function column_getFilterIndex<TFeatures extends TableFeatures, TData ex
|
|
|
100
100
|
* column_setFilterValue(column, (old) => String(old ?? '').trim())
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
|
-
declare function column_setFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
103
|
+
declare function column_setFilterValue<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>, value: any): void;
|
|
104
104
|
/**
|
|
105
105
|
* Routes a column filter updater through the table's filter change handler.
|
|
106
106
|
*
|
|
@@ -113,7 +113,7 @@ declare function column_setFilterValue<TFeatures extends TableFeatures, TData ex
|
|
|
113
113
|
* table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))
|
|
114
114
|
* ```
|
|
115
115
|
*/
|
|
116
|
-
declare function table_setColumnFilters<TFeatures extends TableFeatures, TData extends RowData>(table:
|
|
116
|
+
declare function table_setColumnFilters<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<ColumnFiltersState>): void;
|
|
117
117
|
/**
|
|
118
118
|
* Resets `columnFilters` to the configured initial state or feature default.
|
|
119
119
|
*
|
|
@@ -126,7 +126,7 @@ declare function table_setColumnFilters<TFeatures extends TableFeatures, TData e
|
|
|
126
126
|
* table_resetColumnFilters(table, true)
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
-
declare function table_resetColumnFilters<TFeatures extends TableFeatures, TData extends RowData>(table:
|
|
129
|
+
declare function table_resetColumnFilters<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
|
|
130
130
|
/**
|
|
131
131
|
* Returns whether a filter value should be removed from filter state.
|
|
132
132
|
*
|
|
@@ -137,7 +137,7 @@ declare function table_resetColumnFilters<TFeatures extends TableFeatures, TData
|
|
|
137
137
|
* const removeFilter = shouldAutoRemoveFilter(filterFn, value, column)
|
|
138
138
|
* ```
|
|
139
139
|
*/
|
|
140
|
-
declare function shouldAutoRemoveFilter<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(filterFn?: FilterFn<TFeatures, TData>, value?: any, column?:
|
|
140
|
+
declare function shouldAutoRemoveFilter<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(filterFn?: FilterFn<TFeatures, TData>, value?: any, column?: Column<TFeatures, TData, TValue>): boolean;
|
|
141
141
|
//#endregion
|
|
142
142
|
export { column_getAutoFilterFn, column_getCanFilter, column_getFilterFn, column_getFilterIndex, column_getFilterValue, column_getIsFiltered, column_setFilterValue, getDefaultColumnFiltersState, shouldAutoRemoveFilter, table_resetColumnFilters, table_setColumnFilters };
|
|
143
143
|
//# sourceMappingURL=columnFilteringFeature.utils.d.ts.map
|
|
@@ -43,8 +43,8 @@ function _createFilteredRowModel(table) {
|
|
|
43
43
|
const flatRows = rowModel.flatRows;
|
|
44
44
|
for (let i = 0; i < flatRows.length; i++) {
|
|
45
45
|
const row = flatRows[i];
|
|
46
|
-
row.columnFilters =
|
|
47
|
-
row.columnFiltersMeta =
|
|
46
|
+
row.columnFilters = require_utils.makeObjectMap();
|
|
47
|
+
row.columnFiltersMeta = require_utils.makeObjectMap();
|
|
48
48
|
}
|
|
49
49
|
return rowModel;
|
|
50
50
|
}
|
|
@@ -78,12 +78,14 @@ function _createFilteredRowModel(table) {
|
|
|
78
78
|
const flatRows = rowModel.flatRows;
|
|
79
79
|
for (let i = 0; i < flatRows.length; i++) {
|
|
80
80
|
const row = flatRows[i];
|
|
81
|
-
row.columnFilters =
|
|
81
|
+
row.columnFilters = require_utils.makeObjectMap();
|
|
82
|
+
row.columnFiltersMeta = require_utils.makeObjectMap();
|
|
82
83
|
if (resolvedColumnFilters.length) for (let j = 0; j < resolvedColumnFilters.length; j++) {
|
|
83
84
|
const currentColumnFilter = resolvedColumnFilters[j];
|
|
84
85
|
const id = currentColumnFilter.id;
|
|
85
86
|
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, (filterMeta) => {
|
|
86
|
-
!row.columnFiltersMeta
|
|
87
|
+
if (!row.columnFiltersMeta) row.columnFiltersMeta = require_utils.makeObjectMap();
|
|
88
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
if (resolvedGlobalFilters.length) {
|
|
@@ -91,7 +93,8 @@ function _createFilteredRowModel(table) {
|
|
|
91
93
|
const currentGlobalFilter = resolvedGlobalFilters[j];
|
|
92
94
|
const id = currentGlobalFilter.id;
|
|
93
95
|
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, (filterMeta) => {
|
|
94
|
-
!row.columnFiltersMeta
|
|
96
|
+
if (!row.columnFiltersMeta) row.columnFiltersMeta = require_utils.makeObjectMap();
|
|
97
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
95
98
|
})) {
|
|
96
99
|
row.columnFilters.__global__ = true;
|
|
97
100
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFilteredRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","table_getColumn","column_getFilterFn","table_getGlobalFilterFn","column_getCanGlobalFilter","filterRows"],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n *\n * Register filter functions with the `filterFns` slot on the `features` option:\n * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`.\n */\nexport function createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters =
|
|
1
|
+
{"version":3,"file":"createFilteredRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","makeObjectMap","table_getColumn","column_getFilterFn","table_getGlobalFilterFn","column_getCanGlobalFilter","filterRows"],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { makeObjectMap, tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n *\n * Register filter functions with the `filterFns` slot on the `features` option:\n * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`.\n */\nexport function createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = makeObjectMap()\n row.columnFiltersMeta = makeObjectMap()\n }\n return rowModel\n }\n\n const resolvedColumnFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n const resolvedGlobalFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n\n columnFilters?.forEach((columnFilter) => {\n const column = table_getColumn(table, columnFilter.id)\n\n if (!column) {\n return\n }\n\n const filterFn = column_getFilterFn(column)!\n\n resolvedColumnFilters.push({\n id: columnFilter.id,\n filterFn,\n resolvedValue:\n filterFn.resolveFilterValue?.(columnFilter.value) ?? columnFilter.value,\n })\n })\n\n const filterableIds = columnFilters?.map((d) => d.id) ?? []\n\n const globalFilterFn = table_getGlobalFilterFn(table)\n\n const globallyFilterableColumns = table\n .getAllLeafColumns()\n .filter((column) => column_getCanGlobalFilter(column))\n\n if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {\n filterableIds.push('__global__')\n\n globallyFilterableColumns.forEach((column) => {\n resolvedGlobalFilters.push({\n id: column.id,\n filterFn: globalFilterFn,\n resolvedValue:\n globalFilterFn.resolveFilterValue?.(globalFilter) ?? globalFilter,\n })\n })\n }\n\n // Flag the pre-filtered row model with each filter state\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = makeObjectMap()\n row.columnFiltersMeta = makeObjectMap()\n\n if (resolvedColumnFilters.length) {\n for (let j = 0; j < resolvedColumnFilters.length; j++) {\n const currentColumnFilter = resolvedColumnFilters[j]!\n const id = currentColumnFilter.id\n\n // Tag the row with the column filter state\n row.columnFilters[id] = currentColumnFilter.filterFn(\n row,\n id,\n currentColumnFilter.resolvedValue,\n (filterMeta) => {\n if (!row.columnFiltersMeta) {\n row.columnFiltersMeta = makeObjectMap()\n }\n row.columnFiltersMeta[id] = filterMeta\n },\n )\n }\n }\n\n if (resolvedGlobalFilters.length) {\n for (let j = 0; j < resolvedGlobalFilters.length; j++) {\n const currentGlobalFilter = resolvedGlobalFilters[j]!\n const id = currentGlobalFilter.id\n // Tag the row with the first truthy global filter state\n if (\n currentGlobalFilter.filterFn(\n row,\n id,\n currentGlobalFilter.resolvedValue,\n (filterMeta) => {\n if (!row.columnFiltersMeta) {\n row.columnFiltersMeta = makeObjectMap()\n }\n row.columnFiltersMeta[id] = filterMeta\n },\n )\n ) {\n row.columnFilters.__global__ = true\n break\n }\n }\n\n if (row.columnFilters.__global__ !== true) {\n row.columnFilters.__global__ = false\n }\n }\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Row_ColumnFiltering<TFeatures, TData>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n // Filter final rows using all of the active filters\n return filterRows(rowModel.rows, filterRowsImpl as any, table)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;IAChC;;GACA,UAAU,wBAAwB,KAAK;GACvC,qBAAqBC,4DAAyB,KAAK;EACrD,CAAC;CACH;AACF;AAEA,SAAS,wBAGP,OAAqE;;CACrE,MAAM,WAAW,MAAM,uBAAuB;CAC9C,MAAM,0CAAgB,MAAM,MAAM,+FAAe,IAAI;CACrD,MAAM,yCAAe,MAAM,MAAM,8FAAc,IAAI;CAEnD,IAAI,CAAC,SAAS,K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cAAc,MAAM,oBAAoB,SAC1C,KACA,IACA,oBAAoB,gBACnB,eAAe;IACd,IAAI,CAAC,IAAI,mBACP,IAAI,oBAAoBA,4BAAc;IAExC,IAAI,kBAAkB,MAAM;GAC9B,CACF;EACF;EAGF,IAAI,sBAAsB,QAAQ;GAChC,KAAK,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;IACrD,MAAM,sBAAsB,sBAAsB;IAClD,MAAM,KAAK,oBAAoB;IAE/B,IACE,oBAAoB,SAClB,KACA,IACA,oBAAoB,gBACnB,eAAe;KACd,IAAI,CAAC,IAAI,mBACP,IAAI,oBAAoBA,4BAAc;KAExC,IAAI,kBAAkB,MAAM;IAC9B,CACF,GACA;KACA,IAAI,cAAc,aAAa;KAC/B;IACF;GACF;GAEA,IAAI,IAAI,cAAc,eAAe,MACnC,IAAI,cAAc,aAAa;EAEnC;CACF;CAEA,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,IAAI,cAAc,cAAc,QAAS,OAC3C,OAAO;EAGX,OAAO;CACT;CAGA,OAAOK,mCAAW,SAAS,MAAM,gBAAuB,KAAK;AAC/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tableMemo } from "../../utils.js";
|
|
1
|
+
import { makeObjectMap, tableMemo } from "../../utils.js";
|
|
2
2
|
import { table_getColumn } from "../../core/columns/coreColumnsFeature.utils.js";
|
|
3
3
|
import { table_autoResetPageIndex } from "../row-pagination/rowPaginationFeature.utils.js";
|
|
4
4
|
import { column_getFilterFn } from "./columnFilteringFeature.utils.js";
|
|
@@ -43,8 +43,8 @@ function _createFilteredRowModel(table) {
|
|
|
43
43
|
const flatRows = rowModel.flatRows;
|
|
44
44
|
for (let i = 0; i < flatRows.length; i++) {
|
|
45
45
|
const row = flatRows[i];
|
|
46
|
-
row.columnFilters =
|
|
47
|
-
row.columnFiltersMeta =
|
|
46
|
+
row.columnFilters = makeObjectMap();
|
|
47
|
+
row.columnFiltersMeta = makeObjectMap();
|
|
48
48
|
}
|
|
49
49
|
return rowModel;
|
|
50
50
|
}
|
|
@@ -78,12 +78,14 @@ function _createFilteredRowModel(table) {
|
|
|
78
78
|
const flatRows = rowModel.flatRows;
|
|
79
79
|
for (let i = 0; i < flatRows.length; i++) {
|
|
80
80
|
const row = flatRows[i];
|
|
81
|
-
row.columnFilters =
|
|
81
|
+
row.columnFilters = makeObjectMap();
|
|
82
|
+
row.columnFiltersMeta = makeObjectMap();
|
|
82
83
|
if (resolvedColumnFilters.length) for (let j = 0; j < resolvedColumnFilters.length; j++) {
|
|
83
84
|
const currentColumnFilter = resolvedColumnFilters[j];
|
|
84
85
|
const id = currentColumnFilter.id;
|
|
85
86
|
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, (filterMeta) => {
|
|
86
|
-
!row.columnFiltersMeta
|
|
87
|
+
if (!row.columnFiltersMeta) row.columnFiltersMeta = makeObjectMap();
|
|
88
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
if (resolvedGlobalFilters.length) {
|
|
@@ -91,7 +93,8 @@ function _createFilteredRowModel(table) {
|
|
|
91
93
|
const currentGlobalFilter = resolvedGlobalFilters[j];
|
|
92
94
|
const id = currentGlobalFilter.id;
|
|
93
95
|
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, (filterMeta) => {
|
|
94
|
-
!row.columnFiltersMeta
|
|
96
|
+
if (!row.columnFiltersMeta) row.columnFiltersMeta = makeObjectMap();
|
|
97
|
+
row.columnFiltersMeta[id] = filterMeta;
|
|
95
98
|
})) {
|
|
96
99
|
row.columnFilters.__global__ = true;
|
|
97
100
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFilteredRowModel.js","names":[],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n *\n * Register filter functions with the `filterFns` slot on the `features` option:\n * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`.\n */\nexport function createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters =
|
|
1
|
+
{"version":3,"file":"createFilteredRowModel.js","names":[],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { makeObjectMap, tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type {\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n *\n * Register filter functions with the `filterFns` slot on the `features` option:\n * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`.\n */\nexport function createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = makeObjectMap()\n row.columnFiltersMeta = makeObjectMap()\n }\n return rowModel\n }\n\n const resolvedColumnFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n const resolvedGlobalFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n\n columnFilters?.forEach((columnFilter) => {\n const column = table_getColumn(table, columnFilter.id)\n\n if (!column) {\n return\n }\n\n const filterFn = column_getFilterFn(column)!\n\n resolvedColumnFilters.push({\n id: columnFilter.id,\n filterFn,\n resolvedValue:\n filterFn.resolveFilterValue?.(columnFilter.value) ?? columnFilter.value,\n })\n })\n\n const filterableIds = columnFilters?.map((d) => d.id) ?? []\n\n const globalFilterFn = table_getGlobalFilterFn(table)\n\n const globallyFilterableColumns = table\n .getAllLeafColumns()\n .filter((column) => column_getCanGlobalFilter(column))\n\n if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {\n filterableIds.push('__global__')\n\n globallyFilterableColumns.forEach((column) => {\n resolvedGlobalFilters.push({\n id: column.id,\n filterFn: globalFilterFn,\n resolvedValue:\n globalFilterFn.resolveFilterValue?.(globalFilter) ?? globalFilter,\n })\n })\n }\n\n // Flag the pre-filtered row model with each filter state\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = makeObjectMap()\n row.columnFiltersMeta = makeObjectMap()\n\n if (resolvedColumnFilters.length) {\n for (let j = 0; j < resolvedColumnFilters.length; j++) {\n const currentColumnFilter = resolvedColumnFilters[j]!\n const id = currentColumnFilter.id\n\n // Tag the row with the column filter state\n row.columnFilters[id] = currentColumnFilter.filterFn(\n row,\n id,\n currentColumnFilter.resolvedValue,\n (filterMeta) => {\n if (!row.columnFiltersMeta) {\n row.columnFiltersMeta = makeObjectMap()\n }\n row.columnFiltersMeta[id] = filterMeta\n },\n )\n }\n }\n\n if (resolvedGlobalFilters.length) {\n for (let j = 0; j < resolvedGlobalFilters.length; j++) {\n const currentGlobalFilter = resolvedGlobalFilters[j]!\n const id = currentGlobalFilter.id\n // Tag the row with the first truthy global filter state\n if (\n currentGlobalFilter.filterFn(\n row,\n id,\n currentGlobalFilter.resolvedValue,\n (filterMeta) => {\n if (!row.columnFiltersMeta) {\n row.columnFiltersMeta = makeObjectMap()\n }\n row.columnFiltersMeta[id] = filterMeta\n },\n )\n ) {\n row.columnFilters.__global__ = true\n break\n }\n }\n\n if (row.columnFilters.__global__ !== true) {\n row.columnFilters.__global__ = false\n }\n }\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Row_ColumnFiltering<TFeatures, TData>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n // Filter final rows using all of the active filters\n return filterRows(rowModel.rows, filterRowsImpl as any, table)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,uBAAuB;8BAC7B,MAAM,MAAM,6FAAe,IAAI;8BAC/B,MAAM,MAAM,4FAAc,IAAI;IAChC;;GACA,UAAU,wBAAwB,KAAK;GACvC,qBAAqB,yBAAyB,KAAK;EACrD,CAAC;CACH;AACF;AAEA,SAAS,wBAGP,OAAqE;;CACrE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AsB,QACxB,KAAK,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;GACrD,MAAM,sBAAsB,sBAAsB;GAClD,MAAM,KAAK,oBAAoB;GAG/B,IAAI,cAAc,MAAM,oBAAoB,SAC1C,KACA,IACA,oBAAoB,gBACnB,eAAe;IACd,IAAI,CAAC,IAAI,mBACP,IAAI,oBAAoB,cAAc;IAExC,IAAI,kBAAkB,MAAM;GAC9B,CACF;EACF;EAGF,IAAI,sBAAsB,QAAQ;GAChC,KAAK,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;IACrD,MAAM,sBAAsB,sBAAsB;IAClD,MAAM,KAAK,oBAAoB;IAE/B,IACE,oBAAoB,SAClB,KACA,IACA,oBAAoB,gBACnB,eAAe;KACd,IAAI,CAAC,IAAI,mBACP,IAAI,oBAAoB,cAAc;KAExC,IAAI,kBAAkB,MAAM;IAC9B,CACF,GACA;KACA,IAAI,cAAc,aAAa;KAC/B;IACF;GACF;GAEA,IAAI,IAAI,cAAc,eAAe,MACnC,IAAI,cAAc,aAAa;EAEnC;CACF;CAEA,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,IAAI,cAAc,cAAc,QAAS,OAC3C,OAAO;EAGX,OAAO;CACT;CAGA,OAAO,WAAW,SAAS,MAAM,gBAAuB,KAAK;AAC/D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_utils = require('../../utils.cjs');
|
|
1
2
|
const require_constructRow = require('../../core/rows/constructRow.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/features/column-filtering/filterRowsUtils.ts
|
|
@@ -12,7 +13,7 @@ function filterRows(rows, filterRowImpl, table) {
|
|
|
12
13
|
}
|
|
13
14
|
function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
14
15
|
const newFilteredFlatRows = [];
|
|
15
|
-
const newFilteredRowsById =
|
|
16
|
+
const newFilteredRowsById = require_utils.makeObjectMap();
|
|
16
17
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
|
|
17
18
|
const recurseFilterRows = (rowsToFilter, depth = 0) => {
|
|
18
19
|
const filteredRows = [];
|
|
@@ -53,7 +54,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
53
54
|
}
|
|
54
55
|
function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
55
56
|
const newFilteredFlatRows = [];
|
|
56
|
-
const newFilteredRowsById =
|
|
57
|
+
const newFilteredRowsById = require_utils.makeObjectMap();
|
|
57
58
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
|
|
58
59
|
const recurseFilterRows = (rowsToFilter, depth = 0) => {
|
|
59
60
|
const filteredRows = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterRowsUtils.cjs","names":["constructRow"],"sources":["../../../src/features/column-filtering/filterRowsUtils.ts"],"sourcesContent":["import { constructRow } from '../../core/rows/constructRow'\nimport type { Row_ColumnFiltering } from './columnFilteringFeature.types'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Filters a row model with the supplied row predicate.\n *\n * The helper supports both filtering from leaf rows upward and filtering parents before descendants, depending on table options.\n */\nexport function filterRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rows: Array<Row<TFeatures, TData>>,\n filterRowImpl: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n) {\n if (table.options.filterFromLeafRows) {\n return filterRowModelFromLeafs(rows, filterRowImpl, table)\n }\n\n return filterRowModelFromRoot(rows, filterRowImpl, table)\n}\n\nfunction filterRowModelFromLeafs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (\n row: Row<TFeatures, TData>,\n ) => Array<Row<TFeatures, TData>> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById
|
|
1
|
+
{"version":3,"file":"filterRowsUtils.cjs","names":["makeObjectMap","constructRow"],"sources":["../../../src/features/column-filtering/filterRowsUtils.ts"],"sourcesContent":["import { constructRow } from '../../core/rows/constructRow'\nimport { makeObjectMap } from '../../utils'\nimport type { Row_ColumnFiltering } from './columnFilteringFeature.types'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Filters a row model with the supplied row predicate.\n *\n * The helper supports both filtering from leaf rows upward and filtering parents before descendants, depending on table options.\n */\nexport function filterRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rows: Array<Row<TFeatures, TData>>,\n filterRowImpl: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n) {\n if (table.options.filterFromLeafRows) {\n return filterRowModelFromLeafs(rows, filterRowImpl, table)\n }\n\n return filterRowModelFromRoot(rows, filterRowImpl, table)\n}\n\nfunction filterRowModelFromLeafs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (\n row: Row<TFeatures, TData>,\n ) => Array<Row<TFeatures, TData>> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()\n const maxDepth = table.options.maxLeafRowFilterDepth ?? 100\n\n const recurseFilterRows = (\n rowsToFilter: Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >,\n depth = 0,\n ) => {\n const filteredRows: Array<Row<TFeatures, TData>> &\n Partial<Row_ColumnFiltering<TFeatures, TData>> = []\n\n // Filter from children up first\n for (let row of rowsToFilter) {\n const newRow = constructRow(\n table,\n row.id,\n row.original,\n row.index,\n row.depth,\n undefined,\n row.parentId,\n ) as Row<TFeatures, TData> &\n Partial<Row_ColumnFiltering<TFeatures, TData>>\n newRow.columnFilters = row.columnFilters\n\n if (row.subRows.length && depth < maxDepth) {\n newRow.subRows = recurseFilterRows(row.subRows, depth + 1)\n row = newRow\n\n if (filterRow(row) && !newRow.subRows.length) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n continue\n }\n\n if (filterRow(row) || newRow.subRows.length) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n continue\n }\n } else {\n row = newRow\n if (filterRow(row)) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n }\n }\n }\n\n return filteredRows\n }\n\n return {\n rows: recurseFilterRows(rowsToFilter),\n flatRows: newFilteredFlatRows,\n rowsById: newFilteredRowsById,\n }\n}\n\nfunction filterRowModelFromRoot<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()\n const maxDepth = table.options.maxLeafRowFilterDepth ?? 100\n\n // Filters top level and nested rows\n const recurseFilterRows = (\n rowsToFilter: Array<Row<TFeatures, TData>>,\n depth = 0,\n ) => {\n // Filter from parents downward first\n\n const filteredRows: Array<Row<TFeatures, TData>> = []\n\n // Apply the filter to any subRows\n for (let row of rowsToFilter) {\n const pass = filterRow(row)\n\n if (pass) {\n if (row.subRows.length && depth < maxDepth) {\n const newRow = constructRow(\n table,\n row.id,\n row.original,\n row.index,\n row.depth,\n undefined,\n row.parentId,\n )\n newRow.subRows = recurseFilterRows(row.subRows, depth + 1)\n row = newRow\n }\n\n filteredRows.push(row)\n newFilteredFlatRows.push(row)\n newFilteredRowsById[row.id] = row\n }\n }\n\n return filteredRows\n }\n\n return {\n rows: recurseFilterRows(rowsToFilter),\n flatRows: newFilteredFlatRows,\n rowsById: newFilteredRowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,WAId,MACA,eACA,OACA;CACA,IAAI,MAAM,QAAQ,oBAChB,OAAO,wBAAwB,MAAM,eAAe,KAAK;CAG3D,OAAO,uBAAuB,MAAM,eAAe,KAAK;AAC1D;AAEA,SAAS,wBAIP,cACA,WAGA,OAC4B;CAC5B,MAAM,sBAAoD,CAAC;CAC3D,MAAM,sBAAsBA,4BAAqC;CACjE,MAAM,WAAW,MAAM,QAAQ,yBAAyB;CAExD,MAAM,qBACJ,cAGA,QAAQ,MACL;EACH,MAAM,eAC6C,CAAC;EAGpD,KAAK,IAAI,OAAO,cAAc;GAC5B,MAAM,SAASC,kCACb,OACA,IAAI,IACJ,IAAI,UACJ,IAAI,OACJ,IAAI,OACJ,QACA,IAAI,QACN;GAEA,OAAO,gBAAgB,IAAI;GAE3B,IAAI,IAAI,QAAQ,UAAU,QAAQ,UAAU;IAC1C,OAAO,UAAU,kBAAkB,IAAI,SAAS,QAAQ,CAAC;IACzD,MAAM;IAEN,IAAI,UAAU,GAAG,KAAK,CAAC,OAAO,QAAQ,QAAQ;KAC5C,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;KAC5B;IACF;IAEA,IAAI,UAAU,GAAG,KAAK,OAAO,QAAQ,QAAQ;KAC3C,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;KAC5B;IACF;GACF,OAAO;IACL,MAAM;IACN,IAAI,UAAU,GAAG,GAAG;KAClB,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;IAC9B;GACF;EACF;EAEA,OAAO;CACT;CAEA,OAAO;EACL,MAAM,kBAAkB,YAAY;EACpC,UAAU;EACV,UAAU;CACZ;AACF;AAEA,SAAS,uBAIP,cACA,WACA,OAC4B;CAC5B,MAAM,sBAAoD,CAAC;CAC3D,MAAM,sBAAsBD,4BAAqC;CACjE,MAAM,WAAW,MAAM,QAAQ,yBAAyB;CAGxD,MAAM,qBACJ,cACA,QAAQ,MACL;EAGH,MAAM,eAA6C,CAAC;EAGpD,KAAK,IAAI,OAAO,cAGd,IAFa,UAAU,GAEhB,GAAG;GACR,IAAI,IAAI,QAAQ,UAAU,QAAQ,UAAU;IAC1C,MAAM,SAASC,kCACb,OACA,IAAI,IACJ,IAAI,UACJ,IAAI,OACJ,IAAI,OACJ,QACA,IAAI,QACN;IACA,OAAO,UAAU,kBAAkB,IAAI,SAAS,QAAQ,CAAC;IACzD,MAAM;GACR;GAEA,aAAa,KAAK,GAAG;GACrB,oBAAoB,KAAK,GAAG;GAC5B,oBAAoB,IAAI,MAAM;EAChC;EAGF,OAAO;CACT;CAEA,OAAO;EACL,MAAM,kBAAkB,YAAY;EACpC,UAAU;EACV,UAAU;CACZ;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { makeObjectMap } from "../../utils.js";
|
|
1
2
|
import { constructRow } from "../../core/rows/constructRow.js";
|
|
2
3
|
|
|
3
4
|
//#region src/features/column-filtering/filterRowsUtils.ts
|
|
@@ -12,7 +13,7 @@ function filterRows(rows, filterRowImpl, table) {
|
|
|
12
13
|
}
|
|
13
14
|
function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
14
15
|
const newFilteredFlatRows = [];
|
|
15
|
-
const newFilteredRowsById =
|
|
16
|
+
const newFilteredRowsById = makeObjectMap();
|
|
16
17
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
|
|
17
18
|
const recurseFilterRows = (rowsToFilter, depth = 0) => {
|
|
18
19
|
const filteredRows = [];
|
|
@@ -53,7 +54,7 @@ function filterRowModelFromLeafs(rowsToFilter, filterRow, table) {
|
|
|
53
54
|
}
|
|
54
55
|
function filterRowModelFromRoot(rowsToFilter, filterRow, table) {
|
|
55
56
|
const newFilteredFlatRows = [];
|
|
56
|
-
const newFilteredRowsById =
|
|
57
|
+
const newFilteredRowsById = makeObjectMap();
|
|
57
58
|
const maxDepth = table.options.maxLeafRowFilterDepth ?? 100;
|
|
58
59
|
const recurseFilterRows = (rowsToFilter, depth = 0) => {
|
|
59
60
|
const filteredRows = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterRowsUtils.js","names":[],"sources":["../../../src/features/column-filtering/filterRowsUtils.ts"],"sourcesContent":["import { constructRow } from '../../core/rows/constructRow'\nimport type { Row_ColumnFiltering } from './columnFilteringFeature.types'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Filters a row model with the supplied row predicate.\n *\n * The helper supports both filtering from leaf rows upward and filtering parents before descendants, depending on table options.\n */\nexport function filterRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rows: Array<Row<TFeatures, TData>>,\n filterRowImpl: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n) {\n if (table.options.filterFromLeafRows) {\n return filterRowModelFromLeafs(rows, filterRowImpl, table)\n }\n\n return filterRowModelFromRoot(rows, filterRowImpl, table)\n}\n\nfunction filterRowModelFromLeafs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (\n row: Row<TFeatures, TData>,\n ) => Array<Row<TFeatures, TData>> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById
|
|
1
|
+
{"version":3,"file":"filterRowsUtils.js","names":[],"sources":["../../../src/features/column-filtering/filterRowsUtils.ts"],"sourcesContent":["import { constructRow } from '../../core/rows/constructRow'\nimport { makeObjectMap } from '../../utils'\nimport type { Row_ColumnFiltering } from './columnFilteringFeature.types'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Filters a row model with the supplied row predicate.\n *\n * The helper supports both filtering from leaf rows upward and filtering parents before descendants, depending on table options.\n */\nexport function filterRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rows: Array<Row<TFeatures, TData>>,\n filterRowImpl: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n) {\n if (table.options.filterFromLeafRows) {\n return filterRowModelFromLeafs(rows, filterRowImpl, table)\n }\n\n return filterRowModelFromRoot(rows, filterRowImpl, table)\n}\n\nfunction filterRowModelFromLeafs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (\n row: Row<TFeatures, TData>,\n ) => Array<Row<TFeatures, TData>> | undefined,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()\n const maxDepth = table.options.maxLeafRowFilterDepth ?? 100\n\n const recurseFilterRows = (\n rowsToFilter: Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >,\n depth = 0,\n ) => {\n const filteredRows: Array<Row<TFeatures, TData>> &\n Partial<Row_ColumnFiltering<TFeatures, TData>> = []\n\n // Filter from children up first\n for (let row of rowsToFilter) {\n const newRow = constructRow(\n table,\n row.id,\n row.original,\n row.index,\n row.depth,\n undefined,\n row.parentId,\n ) as Row<TFeatures, TData> &\n Partial<Row_ColumnFiltering<TFeatures, TData>>\n newRow.columnFilters = row.columnFilters\n\n if (row.subRows.length && depth < maxDepth) {\n newRow.subRows = recurseFilterRows(row.subRows, depth + 1)\n row = newRow\n\n if (filterRow(row) && !newRow.subRows.length) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n continue\n }\n\n if (filterRow(row) || newRow.subRows.length) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n continue\n }\n } else {\n row = newRow\n if (filterRow(row)) {\n filteredRows.push(row)\n newFilteredRowsById[row.id] = row\n newFilteredFlatRows.push(row)\n }\n }\n }\n\n return filteredRows\n }\n\n return {\n rows: recurseFilterRows(rowsToFilter),\n flatRows: newFilteredFlatRows,\n rowsById: newFilteredRowsById,\n }\n}\n\nfunction filterRowModelFromRoot<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n rowsToFilter: Array<Row<TFeatures, TData>>,\n filterRow: (row: Row<TFeatures, TData>) => any,\n table: Table_Internal<TFeatures, TData>,\n): RowModel<TFeatures, TData> {\n const newFilteredFlatRows: Array<Row<TFeatures, TData>> = []\n const newFilteredRowsById = makeObjectMap<Row<TFeatures, TData>>()\n const maxDepth = table.options.maxLeafRowFilterDepth ?? 100\n\n // Filters top level and nested rows\n const recurseFilterRows = (\n rowsToFilter: Array<Row<TFeatures, TData>>,\n depth = 0,\n ) => {\n // Filter from parents downward first\n\n const filteredRows: Array<Row<TFeatures, TData>> = []\n\n // Apply the filter to any subRows\n for (let row of rowsToFilter) {\n const pass = filterRow(row)\n\n if (pass) {\n if (row.subRows.length && depth < maxDepth) {\n const newRow = constructRow(\n table,\n row.id,\n row.original,\n row.index,\n row.depth,\n undefined,\n row.parentId,\n )\n newRow.subRows = recurseFilterRows(row.subRows, depth + 1)\n row = newRow\n }\n\n filteredRows.push(row)\n newFilteredFlatRows.push(row)\n newFilteredRowsById[row.id] = row\n }\n }\n\n return filteredRows\n }\n\n return {\n rows: recurseFilterRows(rowsToFilter),\n flatRows: newFilteredFlatRows,\n rowsById: newFilteredRowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAcA,SAAgB,WAId,MACA,eACA,OACA;CACA,IAAI,MAAM,QAAQ,oBAChB,OAAO,wBAAwB,MAAM,eAAe,KAAK;CAG3D,OAAO,uBAAuB,MAAM,eAAe,KAAK;AAC1D;AAEA,SAAS,wBAIP,cACA,WAGA,OAC4B;CAC5B,MAAM,sBAAoD,CAAC;CAC3D,MAAM,sBAAsB,cAAqC;CACjE,MAAM,WAAW,MAAM,QAAQ,yBAAyB;CAExD,MAAM,qBACJ,cAGA,QAAQ,MACL;EACH,MAAM,eAC6C,CAAC;EAGpD,KAAK,IAAI,OAAO,cAAc;GAC5B,MAAM,SAAS,aACb,OACA,IAAI,IACJ,IAAI,UACJ,IAAI,OACJ,IAAI,OACJ,QACA,IAAI,QACN;GAEA,OAAO,gBAAgB,IAAI;GAE3B,IAAI,IAAI,QAAQ,UAAU,QAAQ,UAAU;IAC1C,OAAO,UAAU,kBAAkB,IAAI,SAAS,QAAQ,CAAC;IACzD,MAAM;IAEN,IAAI,UAAU,GAAG,KAAK,CAAC,OAAO,QAAQ,QAAQ;KAC5C,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;KAC5B;IACF;IAEA,IAAI,UAAU,GAAG,KAAK,OAAO,QAAQ,QAAQ;KAC3C,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;KAC5B;IACF;GACF,OAAO;IACL,MAAM;IACN,IAAI,UAAU,GAAG,GAAG;KAClB,aAAa,KAAK,GAAG;KACrB,oBAAoB,IAAI,MAAM;KAC9B,oBAAoB,KAAK,GAAG;IAC9B;GACF;EACF;EAEA,OAAO;CACT;CAEA,OAAO;EACL,MAAM,kBAAkB,YAAY;EACpC,UAAU;EACV,UAAU;CACZ;AACF;AAEA,SAAS,uBAIP,cACA,WACA,OAC4B;CAC5B,MAAM,sBAAoD,CAAC;CAC3D,MAAM,sBAAsB,cAAqC;CACjE,MAAM,WAAW,MAAM,QAAQ,yBAAyB;CAGxD,MAAM,qBACJ,cACA,QAAQ,MACL;EAGH,MAAM,eAA6C,CAAC;EAGpD,KAAK,IAAI,OAAO,cAGd,IAFa,UAAU,GAEhB,GAAG;GACR,IAAI,IAAI,QAAQ,UAAU,QAAQ,UAAU;IAC1C,MAAM,SAAS,aACb,OACA,IAAI,IACJ,IAAI,UACJ,IAAI,OACJ,IAAI,OACJ,QACA,IAAI,QACN;IACA,OAAO,UAAU,kBAAkB,IAAI,SAAS,QAAQ,CAAC;IACzD,MAAM;GACR;GAEA,aAAa,KAAK,GAAG;GACrB,oBAAoB,KAAK,GAAG;GAC5B,oBAAoB,IAAI,MAAM;EAChC;EAGF,OAAO;CACT;CAEA,OAAO;EACL,MAAM,kBAAkB,YAAY;EACpC,UAAU;EACV,UAAU;CACZ;AACF"}
|
|
@@ -52,7 +52,7 @@ const columnGroupingFeature = {
|
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
initRowInstanceData: (row) => {
|
|
55
|
-
row._groupingValuesCache =
|
|
55
|
+
row._groupingValuesCache = require_utils.makeObjectMap();
|
|
56
56
|
},
|
|
57
57
|
constructTableAPIs: (table) => {
|
|
58
58
|
require_utils.assignTableAPIs("columnGroupingFeature", table, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnGroupingFeature.cjs","names":["getDefaultGroupingState","makeStateUpdater","cell_getIsGrouped","cell_getIsPlaceholder","cell_getIsAggregated","column_toggleGrouping","column_getCanGroup","column_getIsGrouped","column_getGroupedIndex","column_getToggleGroupingHandler","column_getAutoAggregationFn","column_getAggregationFn","row_getIsGrouped","row_getGroupingValue","table_setGrouping","table_resetGrouping"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n cell_getIsAggregated,\n cell_getIsGrouped,\n cell_getIsPlaceholder,\n column_getAggregationFn,\n column_getAutoAggregationFn,\n column_getCanGroup,\n column_getGroupedIndex,\n column_getIsGrouped,\n column_getToggleGroupingHandler,\n column_toggleGrouping,\n getDefaultGroupingState,\n row_getGroupingValue,\n row_getIsGrouped,\n table_resetGrouping,\n table_setGrouping,\n} from './columnGroupingFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds column grouping state, aggregation defaults, and grouped row APIs.\n */\nexport const columnGroupingFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n grouping: getDefaultGroupingState(),\n ...initialState,\n }\n },\n\n getDefaultColumnDef: () => {\n return {\n aggregatedCell: ({ getValue }: any) => getValue()?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n cell_getIsGrouped: {\n fn: (cell) => cell_getIsGrouped(cell),\n },\n cell_getIsPlaceholder: {\n fn: (cell) => cell_getIsPlaceholder(cell),\n },\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n column_toggleGrouping: {\n fn: (column) => column_toggleGrouping(column),\n },\n column_getCanGroup: {\n fn: (column) => column_getCanGroup(column),\n },\n column_getIsGrouped: {\n fn: (column) => column_getIsGrouped(column),\n },\n column_getGroupedIndex: {\n fn: (column) => column_getGroupedIndex(column),\n },\n column_getToggleGroupingHandler: {\n fn: (column) => column_getToggleGroupingHandler(column),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n },\n column_getAggregationFn: {\n fn: (column) => column_getAggregationFn(column),\n },\n })\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n row_getIsGrouped: {\n fn: (row) => row_getIsGrouped(row),\n },\n row_getGroupingValue: {\n fn: (row, columnId) => row_getGroupingValue(row, columnId),\n },\n })\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._groupingValuesCache =
|
|
1
|
+
{"version":3,"file":"columnGroupingFeature.cjs","names":["getDefaultGroupingState","makeStateUpdater","cell_getIsGrouped","cell_getIsPlaceholder","cell_getIsAggregated","column_toggleGrouping","column_getCanGroup","column_getIsGrouped","column_getGroupedIndex","column_getToggleGroupingHandler","column_getAutoAggregationFn","column_getAggregationFn","row_getIsGrouped","row_getGroupingValue","makeObjectMap","table_setGrouping","table_resetGrouping"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeObjectMap,\n makeStateUpdater,\n} from '../../utils'\nimport {\n cell_getIsAggregated,\n cell_getIsGrouped,\n cell_getIsPlaceholder,\n column_getAggregationFn,\n column_getAutoAggregationFn,\n column_getCanGroup,\n column_getGroupedIndex,\n column_getIsGrouped,\n column_getToggleGroupingHandler,\n column_toggleGrouping,\n getDefaultGroupingState,\n row_getGroupingValue,\n row_getIsGrouped,\n table_resetGrouping,\n table_setGrouping,\n} from './columnGroupingFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds column grouping state, aggregation defaults, and grouped row APIs.\n */\nexport const columnGroupingFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n grouping: getDefaultGroupingState(),\n ...initialState,\n }\n },\n\n getDefaultColumnDef: () => {\n return {\n aggregatedCell: ({ getValue }: any) => getValue()?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n cell_getIsGrouped: {\n fn: (cell) => cell_getIsGrouped(cell),\n },\n cell_getIsPlaceholder: {\n fn: (cell) => cell_getIsPlaceholder(cell),\n },\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n column_toggleGrouping: {\n fn: (column) => column_toggleGrouping(column),\n },\n column_getCanGroup: {\n fn: (column) => column_getCanGroup(column),\n },\n column_getIsGrouped: {\n fn: (column) => column_getIsGrouped(column),\n },\n column_getGroupedIndex: {\n fn: (column) => column_getGroupedIndex(column),\n },\n column_getToggleGroupingHandler: {\n fn: (column) => column_getToggleGroupingHandler(column),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n },\n column_getAggregationFn: {\n fn: (column) => column_getAggregationFn(column),\n },\n })\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n row_getIsGrouped: {\n fn: (row) => row_getIsGrouped(row),\n },\n row_getGroupingValue: {\n fn: (row, columnId) => row_getGroupingValue(row, columnId),\n },\n })\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._groupingValuesCache = makeObjectMap()\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnGroupingFeature', table, {\n table_setGrouping: {\n fn: (updater) => table_setGrouping(table, updater),\n },\n table_resetGrouping: {\n fn: (defaultState) => table_resetGrouping(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AA4BA,MAAa,wBAAsC;CACjD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,UAAUA,4DAAwB;GAClC,GAAG;EACL;CAC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jB,KAAK,YAAYC,sDAAkB,OAAO,OAAO,EACnD;GACA,qBAAqB,EACnB,KAAK,iBAAiBC,wDAAoB,OAAO,YAAY,EAC/D;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assignPrototypeAPIs, assignTableAPIs, makeStateUpdater } from "../../utils.js";
|
|
1
|
+
import { assignPrototypeAPIs, assignTableAPIs, makeObjectMap, makeStateUpdater } from "../../utils.js";
|
|
2
2
|
import { cell_getIsAggregated, cell_getIsGrouped, cell_getIsPlaceholder, column_getAggregationFn, column_getAutoAggregationFn, column_getCanGroup, column_getGroupedIndex, column_getIsGrouped, column_getToggleGroupingHandler, column_toggleGrouping, getDefaultGroupingState, row_getGroupingValue, row_getIsGrouped, table_resetGrouping, table_setGrouping } from "./columnGroupingFeature.utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/features/column-grouping/columnGroupingFeature.ts
|
|
@@ -52,7 +52,7 @@ const columnGroupingFeature = {
|
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
initRowInstanceData: (row) => {
|
|
55
|
-
row._groupingValuesCache =
|
|
55
|
+
row._groupingValuesCache = makeObjectMap();
|
|
56
56
|
},
|
|
57
57
|
constructTableAPIs: (table) => {
|
|
58
58
|
assignTableAPIs("columnGroupingFeature", table, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnGroupingFeature.js","names":[],"sources":["../../../src/features/column-grouping/columnGroupingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n cell_getIsAggregated,\n cell_getIsGrouped,\n cell_getIsPlaceholder,\n column_getAggregationFn,\n column_getAutoAggregationFn,\n column_getCanGroup,\n column_getGroupedIndex,\n column_getIsGrouped,\n column_getToggleGroupingHandler,\n column_toggleGrouping,\n getDefaultGroupingState,\n row_getGroupingValue,\n row_getIsGrouped,\n table_resetGrouping,\n table_setGrouping,\n} from './columnGroupingFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds column grouping state, aggregation defaults, and grouped row APIs.\n */\nexport const columnGroupingFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n grouping: getDefaultGroupingState(),\n ...initialState,\n }\n },\n\n getDefaultColumnDef: () => {\n return {\n aggregatedCell: ({ getValue }: any) => getValue()?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n cell_getIsGrouped: {\n fn: (cell) => cell_getIsGrouped(cell),\n },\n cell_getIsPlaceholder: {\n fn: (cell) => cell_getIsPlaceholder(cell),\n },\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n column_toggleGrouping: {\n fn: (column) => column_toggleGrouping(column),\n },\n column_getCanGroup: {\n fn: (column) => column_getCanGroup(column),\n },\n column_getIsGrouped: {\n fn: (column) => column_getIsGrouped(column),\n },\n column_getGroupedIndex: {\n fn: (column) => column_getGroupedIndex(column),\n },\n column_getToggleGroupingHandler: {\n fn: (column) => column_getToggleGroupingHandler(column),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n },\n column_getAggregationFn: {\n fn: (column) => column_getAggregationFn(column),\n },\n })\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n row_getIsGrouped: {\n fn: (row) => row_getIsGrouped(row),\n },\n row_getGroupingValue: {\n fn: (row, columnId) => row_getGroupingValue(row, columnId),\n },\n })\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._groupingValuesCache =
|
|
1
|
+
{"version":3,"file":"columnGroupingFeature.js","names":[],"sources":["../../../src/features/column-grouping/columnGroupingFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeObjectMap,\n makeStateUpdater,\n} from '../../utils'\nimport {\n cell_getIsAggregated,\n cell_getIsGrouped,\n cell_getIsPlaceholder,\n column_getAggregationFn,\n column_getAutoAggregationFn,\n column_getCanGroup,\n column_getGroupedIndex,\n column_getIsGrouped,\n column_getToggleGroupingHandler,\n column_toggleGrouping,\n getDefaultGroupingState,\n row_getGroupingValue,\n row_getIsGrouped,\n table_resetGrouping,\n table_setGrouping,\n} from './columnGroupingFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds column grouping state, aggregation defaults, and grouped row APIs.\n */\nexport const columnGroupingFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n grouping: getDefaultGroupingState(),\n ...initialState,\n }\n },\n\n getDefaultColumnDef: () => {\n return {\n aggregatedCell: ({ getValue }: any) => getValue()?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n cell_getIsGrouped: {\n fn: (cell) => cell_getIsGrouped(cell),\n },\n cell_getIsPlaceholder: {\n fn: (cell) => cell_getIsPlaceholder(cell),\n },\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n column_toggleGrouping: {\n fn: (column) => column_toggleGrouping(column),\n },\n column_getCanGroup: {\n fn: (column) => column_getCanGroup(column),\n },\n column_getIsGrouped: {\n fn: (column) => column_getIsGrouped(column),\n },\n column_getGroupedIndex: {\n fn: (column) => column_getGroupedIndex(column),\n },\n column_getToggleGroupingHandler: {\n fn: (column) => column_getToggleGroupingHandler(column),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n },\n column_getAggregationFn: {\n fn: (column) => column_getAggregationFn(column),\n },\n })\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('columnGroupingFeature', prototype, table, {\n row_getIsGrouped: {\n fn: (row) => row_getIsGrouped(row),\n },\n row_getGroupingValue: {\n fn: (row, columnId) => row_getGroupingValue(row, columnId),\n },\n })\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._groupingValuesCache = makeObjectMap()\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('columnGroupingFeature', table, {\n table_setGrouping: {\n fn: (updater) => table_setGrouping(table, updater),\n },\n table_resetGrouping: {\n fn: (defaultState) => table_resetGrouping(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AA4BA,MAAa,wBAAsC;CACjD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,UAAU,wBAAwB;GAClC,GAAG;EACL;CACF;CAEA,2BAA2B;EACzB,OAAO;GACL,iBAAiB,EAAE,eAAoB;;kCAAS,uEAAG,gGAAW,MAAK;GAAG;GACtE,eAAe;EACjB;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,kBAAkB,iBAAiB,YAAY,KAAK;GACpD,mBAAmB;EACrB;CACF;CAEA,sBAAsB,WAAW,UAAU;EACzC,oBAAoB,yBAAyB,WAAW,OAAO;GAC7D,mBAAmB,EACjB,KAAK,SAAS,kBAAkB,IAAI,EACtC;GACA,uBAAuB,EACrB,KAAK,SAAS,sBAAsB,IAAI,EAC1C;GACA,sBAAsB,EACpB,KAAK,SAAS,qBAAqB,IAAI,EACzC;EACF,CAAC;CACH;CAEA,wBAAwB,WAAW,UAAU;EAC3C,oBAAoB,yBAAyB,WAAW,OAAO;GAC7D,uBAAuB,EACrB,KAAK,WAAW,sBAAsB,MAAM,EAC9C;GACA,oBAAoB,EAClB,KAAK,WAAW,mBAAmB,MAAM,EAC3C;GACA,qBAAqB,EACnB,KAAK,WAAW,oBAAoB,MAAM,EAC5C;GACA,wBAAwB,EACtB,KAAK,WAAW,uBAAuB,MAAM,EAC/C;GACA,iCAAiC,EAC/B,KAAK,WAAW,gCAAgC,MAAM,EACxD;GACA,6BAA6B,EAC3B,KAAK,WAAW,4BAA4B,MAAM,EACpD;GACA,yBAAyB,EACvB,KAAK,WAAW,wBAAwB,MAAM,EAChD;EACF,CAAC;CACH;CAEA,qBAAqB,WAAW,UAAU;EACxC,oBAAoB,yBAAyB,WAAW,OAAO;GAC7D,kBAAkB,EAChB,KAAK,QAAQ,iBAAiB,GAAG,EACnC;GACA,sBAAsB,EACpB,KAAK,KAAK,aAAa,qBAAqB,KAAK,QAAQ,EAC3D;EACF,CAAC;CACH;CAEA,sBAAsB,QAAQ;EAC3B,AAAC,IAAY,uBAAuB,cAAc;CACrD;CAEA,qBAAqB,UAAU;EAC7B,gBAAgB,yBAAyB,OAAO;GAC9C,mBAAmB,EACjB,KAAK,YAAY,kBAAkB,OAAO,OAAO,EACnD;GACA,qBAAqB,EACnB,KAAK,iBAAiB,oBAAoB,OAAO,YAAY,EAC/D;EACF,CAAC;CACH;AACF"}
|
|
@@ -181,12 +181,12 @@ function row_getIsGrouped(row) {
|
|
|
181
181
|
* ```
|
|
182
182
|
*/
|
|
183
183
|
function row_getGroupingValue(row, columnId) {
|
|
184
|
-
var _row$_groupingValuesC
|
|
185
|
-
if (
|
|
184
|
+
var _row$_groupingValuesC;
|
|
185
|
+
if (row._groupingValuesCache && require_utils.hasOwn(row._groupingValuesCache, columnId)) return row._groupingValuesCache[columnId];
|
|
186
186
|
const column = row.table.getColumn(columnId);
|
|
187
187
|
if (!column.columnDef.getGroupingValue) return row.getValue(columnId);
|
|
188
188
|
if (row._groupingValuesCache) row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
189
|
-
return (_row$
|
|
189
|
+
return (_row$_groupingValuesC = row._groupingValuesCache) === null || _row$_groupingValuesC === void 0 ? void 0 : _row$_groupingValuesC[columnId];
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
192
|
* Checks whether this cell represents the grouped column for a grouped row.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnGroupingFeature.utils.cjs","names":["isFunction","cloneState"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\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.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache?.hasOwnProperty(columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAmD;CACnD,QACG,OAAO,UAAU,kBAAkB,UACnC,OAAO,MAAM,QAAQ,kBAAkB,UACvC,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,OAAO,UAAU;AAE/C;;;;;;;;;;;;AAaA,SAAgB,oBAId,QAA4D;;CAC5D,OAAO,CAAC,2BAAC,OAAO,MAAM,MAAM,yGAAU,IAAI,iFAAG,SAAS,OAAO,EAAE;AACjE;;;;;;;;;;;AAYA,SAAgB,uBAId,QAA2D;;CAC3D,kCAAO,OAAO,MAAM,MAAM,4GAAU,IAAI,mFAAG,QAAQ,OAAO,EAAE,MAAK;AACnE;;;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Y,OAAO,UAAU,iBACpD,IAAI,QACN;CAGF,iCAAO,IAAI,sGAAuB;AACpC;;;;;;;;;;;AAYA,SAAgB,kBAId,MAAsC;CACtC,MAAM,MAAM,KAAK;CACjB,OACE,oBAAoB,KAAK,MAAM,KAAK,KAAK,OAAO,OAAO,IAAI;AAE/D;;;;;;;;;;;;AAaA,SAAgB,sBAId,MAAsC;CACtC,OAAO,CAAC,kBAAkB,IAAI,KAAK,oBAAoB,KAAK,MAAM;AACpE;;;;;;;;;;;;AAaA,SAAgB,qBAId,MAAsC;CACtC,OACE,CAAC,kBAAkB,IAAI,KACvB,CAAC,sBAAsB,IAAI,KAC3B,CAAC,CAAC,KAAK,IAAI,QAAQ;AAEvB"}
|
|
1
|
+
{"version":3,"file":"columnGroupingFeature.utils.cjs","names":["isFunction","cloneState","hasOwn"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\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.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAmD;CACnD,QACG,OAAO,UAAU,kBAAkB,UACnC,OAAO,MAAM,Q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