@tanstack/table-core 9.0.0-beta.64 → 9.0.0-beta.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/core/cells/constructCell.d.ts +0 -1
- package/dist/core/cells/coreCellsFeature.d.ts +0 -1
- package/dist/core/cells/coreCellsFeature.types.d.ts +0 -1
- package/dist/core/cells/coreCellsFeature.utils.d.ts +1 -0
- package/dist/core/columns/constructColumn.d.ts +0 -1
- package/dist/core/columns/coreColumnsFeature.d.ts +0 -1
- package/dist/core/columns/coreColumnsFeature.types.d.ts +5 -6
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +0 -1
- package/dist/core/coreFeatures.d.ts +1 -0
- package/dist/core/headers/buildHeaderGroups.d.ts +0 -1
- package/dist/core/headers/constructHeader.d.ts +0 -1
- package/dist/core/headers/coreHeadersFeature.d.ts +0 -1
- package/dist/core/headers/coreHeadersFeature.types.d.ts +0 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +1 -0
- package/dist/core/reactivity/coreReactivityFeature.types.d.ts +0 -1
- package/dist/core/reactivity/coreReactivityFeature.utils.d.ts +0 -1
- package/dist/core/reactivity/renderPhaseReactivity.d.ts +0 -1
- package/dist/core/row-models/coreRowModelsFeature.d.ts +0 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +0 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +0 -1
- package/dist/core/row-models/createCoreRowModel.d.ts +0 -1
- package/dist/core/rows/constructRow.d.ts +0 -1
- package/dist/core/rows/coreRowsFeature.d.ts +0 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +0 -1
- package/dist/core/rows/coreRowsFeature.utils.d.ts +0 -1
- package/dist/core/table/constructTable.d.ts +0 -1
- package/dist/core/table/coreTablesFeature.d.ts +0 -1
- package/dist/core/table/coreTablesFeature.types.d.ts +6 -7
- package/dist/core/table/coreTablesFeature.utils.d.ts +0 -1
- package/dist/features/cell-selection/cellSelectionFeature.d.ts +0 -1
- package/dist/features/cell-selection/cellSelectionFeature.types.d.ts +30 -16
- package/dist/features/cell-selection/cellSelectionFeature.utils.d.ts +9 -10
- package/dist/features/cell-selection/cellSelectionFeature.utils.js +37 -24
- package/dist/features/cell-selection/cellSelectionGeometry.js +90 -0
- package/dist/features/column-faceting/columnFacetingFeature.d.ts +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +0 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.ts +0 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +0 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.ts +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.d.ts +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +3 -4
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +0 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +0 -1
- package/dist/features/column-filtering/filterFns.d.ts +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +0 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.d.ts +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +0 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +0 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +0 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +0 -1
- package/dist/features/column-resizing/columnResizingFeature.d.ts +0 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +0 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +0 -1
- package/dist/features/column-sizing/columnSizingFeature.d.ts +0 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +0 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.d.ts +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +1 -0
- package/dist/features/global-filtering/globalFilteringFeature.d.ts +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.js +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +1 -0
- package/dist/features/row-aggregation/aggregationFns.d.ts +0 -1
- package/dist/features/row-aggregation/rowAggregationFeature.d.ts +0 -1
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +1 -2
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +0 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.d.ts +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +0 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.d.ts +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +0 -1
- package/dist/features/row-pinning/rowPinningFeature.d.ts +0 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +0 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +0 -1
- package/dist/features/row-selection/rowSelectionFeature.d.ts +0 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +2 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +3 -4
- package/dist/features/row-selection/rowSelectionFeature.utils.js +3 -3
- package/dist/features/row-sorting/createSortedRowModel.d.ts +0 -1
- package/dist/features/row-sorting/rowSortingFeature.d.ts +0 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +0 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +0 -1
- package/dist/features/row-sorting/sortFns.d.ts +0 -1
- package/dist/features/stockFeatures.d.ts +0 -1
- package/dist/flex-render.d.ts +0 -1
- package/dist/helpers/columnHelper.d.ts +0 -1
- package/dist/helpers/tableFeatures.d.ts +0 -1
- package/dist/helpers/tableOptions.d.ts +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/store-reactivity-bindings.d.ts +0 -1
- package/dist/types/Cell.d.ts +0 -1
- package/dist/types/Column.d.ts +0 -1
- package/dist/types/ColumnDef.d.ts +0 -1
- package/dist/types/Header.d.ts +0 -1
- package/dist/types/HeaderGroup.d.ts +0 -1
- package/dist/types/Row.d.ts +0 -1
- package/dist/types/RowModel.d.ts +0 -1
- package/dist/types/RowModelFns.d.ts +0 -1
- package/dist/types/Table.d.ts +0 -1
- package/dist/types/TableFeatures.d.ts +1 -2
- package/dist/types/TableOptions.d.ts +1 -2
- package/dist/types/TableState.d.ts +0 -1
- package/dist/types/type-utils.d.ts +1 -1
- package/dist/utils.d.ts +2 -17
- package/dist/utils.js +3 -1
- package/dist/worker/createTableWorker.d.ts +2 -3
- package/dist/worker/createWorkerRowModel.d.ts +0 -1
- package/dist/worker/initTableWorker.d.ts +0 -1
- package/dist/worker/rebuildRowModel.d.ts +3 -0
- package/dist/worker/tableWorkerProtocol.d.ts +5 -4
- package/package.json +1 -1
- package/skills/aggregation/SKILL.md +1 -1
- package/skills/api-not-found/SKILL.md +1 -1
- package/skills/cell-selection/SKILL.md +33 -9
- package/skills/client-vs-server/SKILL.md +1 -1
- package/skills/column-faceting/SKILL.md +1 -1
- package/skills/column-filtering/SKILL.md +1 -1
- package/skills/column-ordering/SKILL.md +1 -1
- package/skills/column-pinning/SKILL.md +1 -1
- package/skills/column-resizing/SKILL.md +1 -1
- package/skills/column-sizing/SKILL.md +1 -1
- package/skills/column-visibility/SKILL.md +1 -1
- package/skills/core/SKILL.md +1 -1
- package/skills/custom-features/SKILL.md +1 -1
- package/skills/expanding/SKILL.md +1 -1
- package/skills/global-filtering/SKILL.md +1 -1
- package/skills/grouping/SKILL.md +1 -1
- package/skills/migrate-v8-to-v9/SKILL.md +3 -2
- package/skills/pagination/SKILL.md +1 -1
- package/skills/row-pinning/SKILL.md +1 -1
- package/skills/row-selection/SKILL.md +1 -1
- package/skills/sorting/SKILL.md +1 -1
- package/skills/table-features/SKILL.md +1 -1
- package/skills/typescript/SKILL.md +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { callMemoOrStaticFn, cloneState, makeObjectMap } from "../../utils.js";
|
|
2
2
|
import { table_getVisibleLeafColumns } from "../column-visibility/columnVisibilityFeature.utils.js";
|
|
3
|
+
import { applyCellSelectionBoundsOperations } from "./cellSelectionGeometry.js";
|
|
3
4
|
|
|
4
5
|
//#region src/features/cell-selection/cellSelectionFeature.utils.ts
|
|
5
6
|
/**
|
|
@@ -136,7 +137,8 @@ function resolveRowIndex(table, rows, rowId) {
|
|
|
136
137
|
return index;
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
139
|
-
* Resolves
|
|
140
|
+
* Resolves ordered range operations into disjoint, positive display-order
|
|
141
|
+
* index rectangles.
|
|
140
142
|
*
|
|
141
143
|
* This is the single cache every per-cell read goes through, so index lookups
|
|
142
144
|
* happen once per invalidation rather than once per cell. A range whose corners
|
|
@@ -154,7 +156,7 @@ function table_getCellSelectionBounds(table) {
|
|
|
154
156
|
if (!ranges?.length) return [];
|
|
155
157
|
const rows = table.getRowsInDisplayOrder();
|
|
156
158
|
const columnIndexes = callMemoOrStaticFn(table, "getCellSelectionColumnIndexes", table_getCellSelectionColumnIndexes);
|
|
157
|
-
const
|
|
159
|
+
const operations = [];
|
|
158
160
|
for (let i = 0; i < ranges.length; i++) {
|
|
159
161
|
const range = ranges[i];
|
|
160
162
|
const anchorRowIndex = resolveRowIndex(table, rows, range.anchorRowId);
|
|
@@ -162,14 +164,15 @@ function table_getCellSelectionBounds(table) {
|
|
|
162
164
|
const anchorColumnIndex = columnIndexes[range.anchorColumnId] ?? -1;
|
|
163
165
|
const focusColumnIndex = columnIndexes[range.focusColumnId] ?? -1;
|
|
164
166
|
if (anchorRowIndex < 0 || focusRowIndex < 0 || anchorColumnIndex < 0 || focusColumnIndex < 0) continue;
|
|
165
|
-
|
|
167
|
+
operations.push({
|
|
166
168
|
minRowIndex: Math.min(anchorRowIndex, focusRowIndex),
|
|
167
169
|
maxRowIndex: Math.max(anchorRowIndex, focusRowIndex),
|
|
168
170
|
minColumnIndex: Math.min(anchorColumnIndex, focusColumnIndex),
|
|
169
|
-
maxColumnIndex: Math.max(anchorColumnIndex, focusColumnIndex)
|
|
171
|
+
maxColumnIndex: Math.max(anchorColumnIndex, focusColumnIndex),
|
|
172
|
+
operation: range.operation ?? "include"
|
|
170
173
|
});
|
|
171
174
|
}
|
|
172
|
-
return
|
|
175
|
+
return applyCellSelectionBoundsOperations(operations);
|
|
173
176
|
}
|
|
174
177
|
/**
|
|
175
178
|
* Tests whether an index pair falls inside any resolved rectangle.
|
|
@@ -223,7 +226,7 @@ function resolveCellPosition(cell) {
|
|
|
223
226
|
};
|
|
224
227
|
}
|
|
225
228
|
/**
|
|
226
|
-
* Checks whether this cell falls inside
|
|
229
|
+
* Checks whether this cell falls inside the final positive selection.
|
|
227
230
|
*
|
|
228
231
|
* Deliberately not memoized. Registering this through `assignPrototypeAPIs`
|
|
229
232
|
* with `memoDeps` would allocate a memo closure and dependency array per cell,
|
|
@@ -295,7 +298,7 @@ function cell_getSelectionEdges(cell) {
|
|
|
295
298
|
};
|
|
296
299
|
}
|
|
297
300
|
/**
|
|
298
|
-
* Returns the active cell, i.e. the anchor of the most recent
|
|
301
|
+
* Returns the active cell, i.e. the anchor of the most recent operation.
|
|
299
302
|
*
|
|
300
303
|
* Focus is derived rather than stored: in spreadsheet semantics, dragging from
|
|
301
304
|
* A1 to C5 leaves the active cell at A1, so the active range's anchor already
|
|
@@ -329,15 +332,21 @@ function table_setFocusedCell(table, rowId, columnId) {
|
|
|
329
332
|
});
|
|
330
333
|
}
|
|
331
334
|
/**
|
|
332
|
-
* Selects a rectangle
|
|
335
|
+
* Selects a rectangle using replace, include, or exclude semantics.
|
|
333
336
|
*
|
|
334
337
|
* @example
|
|
335
338
|
* ```ts
|
|
336
|
-
* table_selectCellRange(table, range, {
|
|
339
|
+
* table_selectCellRange(table, range, { mode: 'exclude' })
|
|
337
340
|
* ```
|
|
338
341
|
*/
|
|
339
342
|
function table_selectCellRange(table, range, opts) {
|
|
340
|
-
|
|
343
|
+
const mode = opts?.mode ?? (opts?.additive ? "include" : "replace");
|
|
344
|
+
const { operation: _operation, ...coordinates } = range;
|
|
345
|
+
const nextRange = mode === "exclude" ? {
|
|
346
|
+
...coordinates,
|
|
347
|
+
operation: "exclude"
|
|
348
|
+
} : coordinates;
|
|
349
|
+
table_setCellSelection(table, (old) => mode === "replace" ? [nextRange] : [...old, nextRange]);
|
|
341
350
|
}
|
|
342
351
|
/**
|
|
343
352
|
* Returns the visible leaf columns that permit selection, in display order.
|
|
@@ -488,7 +497,7 @@ function table_extendCellSelection(table, direction) {
|
|
|
488
497
|
});
|
|
489
498
|
}
|
|
490
499
|
/**
|
|
491
|
-
* Walks each
|
|
500
|
+
* Walks each final positive region, invoking a visitor per selectable cell.
|
|
492
501
|
*
|
|
493
502
|
* Every expansion API shares this so the per-cell enable predicate is applied
|
|
494
503
|
* in exactly one place.
|
|
@@ -537,7 +546,7 @@ function table_getSelectedCellIds(table) {
|
|
|
537
546
|
return ids;
|
|
538
547
|
}
|
|
539
548
|
/**
|
|
540
|
-
* Returns each
|
|
549
|
+
* Returns each final positive region's values as a row-major grid.
|
|
541
550
|
*
|
|
542
551
|
* This is the raw material for clipboard export. Serializing it to text is left
|
|
543
552
|
* to userland, since the delimiter, the null representation, and whether values
|
|
@@ -559,9 +568,8 @@ function table_getSelectedCellRangesData(table) {
|
|
|
559
568
|
/**
|
|
560
569
|
* Returns the number of selected cells.
|
|
561
570
|
*
|
|
562
|
-
* Uses rectangle arithmetic
|
|
563
|
-
*
|
|
564
|
-
* per-cell `enableCellSelection` predicate also requires enumeration.
|
|
571
|
+
* Uses rectangle arithmetic over the normalized, disjoint positive regions.
|
|
572
|
+
* A per-cell `enableCellSelection` predicate requires enumeration.
|
|
565
573
|
*
|
|
566
574
|
* @example
|
|
567
575
|
* ```ts
|
|
@@ -572,20 +580,23 @@ function table_getSelectedCellCount(table) {
|
|
|
572
580
|
if (table.options.enableCellSelection === false) return 0;
|
|
573
581
|
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
574
582
|
if (!bounds.length) return 0;
|
|
575
|
-
if (
|
|
583
|
+
if (typeof table.options.enableCellSelection === "function") {
|
|
576
584
|
const ids = /* @__PURE__ */ new Set();
|
|
577
585
|
forEachSelectedCell(table, (cell) => ids.add(cell.id));
|
|
578
586
|
return ids.size;
|
|
579
587
|
}
|
|
580
588
|
const columns = getDisplayOrderedColumns(table);
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
589
|
+
let count = 0;
|
|
590
|
+
for (const bound of bounds) {
|
|
591
|
+
let selectableColumns = 0;
|
|
592
|
+
for (let columnIndex = bound.minColumnIndex; columnIndex <= bound.maxColumnIndex; columnIndex++) {
|
|
593
|
+
const column = columns[columnIndex];
|
|
594
|
+
if (!column) continue;
|
|
595
|
+
if (column.columnDef.enableCellSelection !== false) selectableColumns++;
|
|
596
|
+
}
|
|
597
|
+
count += (bound.maxRowIndex - bound.minRowIndex + 1) * selectableColumns;
|
|
587
598
|
}
|
|
588
|
-
return
|
|
599
|
+
return count;
|
|
589
600
|
}
|
|
590
601
|
/**
|
|
591
602
|
* Returns the ids of all rows intersected by the selection.
|
|
@@ -670,6 +681,7 @@ function cell_getSelectionStartHandler(cell, _contextDocument) {
|
|
|
670
681
|
}
|
|
671
682
|
const rowId = cell.row.id;
|
|
672
683
|
const columnId = cell.column.id;
|
|
684
|
+
const shouldExclude = isMultiRangeEvent && callMemoOrStaticFn(cell, "getIsSelected", cell_getIsSelected);
|
|
673
685
|
table_setCellSelection(table, (old) => {
|
|
674
686
|
const active = old[old.length - 1];
|
|
675
687
|
if (isRangeEvent && active) {
|
|
@@ -685,7 +697,8 @@ function cell_getSelectionStartHandler(cell, _contextDocument) {
|
|
|
685
697
|
anchorRowId: rowId,
|
|
686
698
|
anchorColumnId: columnId,
|
|
687
699
|
focusRowId: rowId,
|
|
688
|
-
focusColumnId: columnId
|
|
700
|
+
focusColumnId: columnId,
|
|
701
|
+
...shouldExclude ? { operation: "exclude" } : {}
|
|
689
702
|
};
|
|
690
703
|
return isMultiRangeEvent ? [...old, range] : [range];
|
|
691
704
|
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//#region src/features/cell-selection/cellSelectionGeometry.ts
|
|
2
|
+
function compareBounds(a, b) {
|
|
3
|
+
return a.minRowIndex - b.minRowIndex || a.minColumnIndex - b.minColumnIndex || a.maxRowIndex - b.maxRowIndex || a.maxColumnIndex - b.maxColumnIndex;
|
|
4
|
+
}
|
|
5
|
+
function intersectCellSelectionBounds(a, b) {
|
|
6
|
+
const intersection = {
|
|
7
|
+
minRowIndex: Math.max(a.minRowIndex, b.minRowIndex),
|
|
8
|
+
maxRowIndex: Math.min(a.maxRowIndex, b.maxRowIndex),
|
|
9
|
+
minColumnIndex: Math.max(a.minColumnIndex, b.minColumnIndex),
|
|
10
|
+
maxColumnIndex: Math.min(a.maxColumnIndex, b.maxColumnIndex)
|
|
11
|
+
};
|
|
12
|
+
return intersection.minRowIndex <= intersection.maxRowIndex && intersection.minColumnIndex <= intersection.maxColumnIndex ? intersection : void 0;
|
|
13
|
+
}
|
|
14
|
+
function subtractCellSelectionBounds(source, excluded) {
|
|
15
|
+
const intersection = intersectCellSelectionBounds(source, excluded);
|
|
16
|
+
if (!intersection) return [source];
|
|
17
|
+
const result = [];
|
|
18
|
+
if (source.minRowIndex < intersection.minRowIndex) result.push({
|
|
19
|
+
...source,
|
|
20
|
+
maxRowIndex: intersection.minRowIndex - 1
|
|
21
|
+
});
|
|
22
|
+
if (intersection.maxRowIndex < source.maxRowIndex) result.push({
|
|
23
|
+
...source,
|
|
24
|
+
minRowIndex: intersection.maxRowIndex + 1
|
|
25
|
+
});
|
|
26
|
+
if (source.minColumnIndex < intersection.minColumnIndex) result.push({
|
|
27
|
+
minRowIndex: intersection.minRowIndex,
|
|
28
|
+
maxRowIndex: intersection.maxRowIndex,
|
|
29
|
+
minColumnIndex: source.minColumnIndex,
|
|
30
|
+
maxColumnIndex: intersection.minColumnIndex - 1
|
|
31
|
+
});
|
|
32
|
+
if (intersection.maxColumnIndex < source.maxColumnIndex) result.push({
|
|
33
|
+
minRowIndex: intersection.minRowIndex,
|
|
34
|
+
maxRowIndex: intersection.maxRowIndex,
|
|
35
|
+
minColumnIndex: intersection.maxColumnIndex + 1,
|
|
36
|
+
maxColumnIndex: source.maxColumnIndex
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function mergePair(a, b) {
|
|
41
|
+
if (a.minRowIndex === b.minRowIndex && a.maxRowIndex === b.maxRowIndex && (a.maxColumnIndex + 1 === b.minColumnIndex || b.maxColumnIndex + 1 === a.minColumnIndex)) return {
|
|
42
|
+
minRowIndex: a.minRowIndex,
|
|
43
|
+
maxRowIndex: a.maxRowIndex,
|
|
44
|
+
minColumnIndex: Math.min(a.minColumnIndex, b.minColumnIndex),
|
|
45
|
+
maxColumnIndex: Math.max(a.maxColumnIndex, b.maxColumnIndex)
|
|
46
|
+
};
|
|
47
|
+
if (a.minColumnIndex === b.minColumnIndex && a.maxColumnIndex === b.maxColumnIndex && (a.maxRowIndex + 1 === b.minRowIndex || b.maxRowIndex + 1 === a.minRowIndex)) return {
|
|
48
|
+
minRowIndex: Math.min(a.minRowIndex, b.minRowIndex),
|
|
49
|
+
maxRowIndex: Math.max(a.maxRowIndex, b.maxRowIndex),
|
|
50
|
+
minColumnIndex: a.minColumnIndex,
|
|
51
|
+
maxColumnIndex: a.maxColumnIndex
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function mergeAdjacentCellSelectionBounds(input) {
|
|
55
|
+
const result = input.slice();
|
|
56
|
+
for (let i = 0; i < result.length; i++) for (let j = i + 1; j < result.length; j++) {
|
|
57
|
+
const merged = mergePair(result[i], result[j]);
|
|
58
|
+
if (!merged) continue;
|
|
59
|
+
result.splice(j, 1);
|
|
60
|
+
result[i] = merged;
|
|
61
|
+
i = -1;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return result.sort(compareBounds);
|
|
65
|
+
}
|
|
66
|
+
function addCellSelectionBounds(selected, included) {
|
|
67
|
+
let fragments = [included];
|
|
68
|
+
for (const existing of selected) {
|
|
69
|
+
fragments = fragments.flatMap((fragment) => subtractCellSelectionBounds(fragment, existing));
|
|
70
|
+
if (!fragments.length) return selected.slice();
|
|
71
|
+
}
|
|
72
|
+
return mergeAdjacentCellSelectionBounds([...selected, ...fragments]);
|
|
73
|
+
}
|
|
74
|
+
function applyCellSelectionBoundsOperations(operations) {
|
|
75
|
+
let selected = [];
|
|
76
|
+
for (const operation of operations) {
|
|
77
|
+
const bounds = {
|
|
78
|
+
minRowIndex: operation.minRowIndex,
|
|
79
|
+
maxRowIndex: operation.maxRowIndex,
|
|
80
|
+
minColumnIndex: operation.minColumnIndex,
|
|
81
|
+
maxColumnIndex: operation.maxColumnIndex
|
|
82
|
+
};
|
|
83
|
+
if (operation.operation === "exclude") selected = mergeAdjacentCellSelectionBounds(selected.flatMap((bound) => subtractCellSelectionBounds(bound, bounds)));
|
|
84
|
+
else selected = addCellSelectionBounds(selected, bounds);
|
|
85
|
+
}
|
|
86
|
+
return selected.sort(compareBounds);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { addCellSelectionBounds, applyCellSelectionBoundsOperations, intersectCellSelectionBounds, mergeAdjacentCellSelectionBounds, subtractCellSelectionBounds };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
2
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/column-faceting/columnFacetingFeature.types.d.ts
|
|
6
5
|
interface Column_ColumnFaceting<in out TFeatures extends TableFeatures, in out TData extends RowData> {
|
|
7
6
|
/**
|
|
@@ -3,7 +3,6 @@ import { Table } from "../../types/Table.js";
|
|
|
3
3
|
import { Column } from "../../types/Column.js";
|
|
4
4
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
|
-
|
|
7
6
|
//#region src/features/column-faceting/columnFacetingFeature.utils.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Computes min and max numeric facet values for one column.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/column-faceting/createFacetedMinMaxValues.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Creates a memoized faceted min max values helper for faceted filtering.
|
|
@@ -2,7 +2,6 @@ import { RowData } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/column-faceting/createFacetedRowModel.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Creates a memoized faceted row model factory.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/column-faceting/createFacetedUniqueValues.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Creates a memoized faceted unique values helper for faceted filtering.
|
|
@@ -4,7 +4,6 @@ import { Column } from "../../types/Column.js";
|
|
|
4
4
|
import { Row } from "../../types/Row.js";
|
|
5
5
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
6
6
|
import { IsAny, TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
|
|
8
7
|
//#region src/features/column-filtering/columnFilteringFeature.types.d.ts
|
|
9
8
|
interface FilterMeta {}
|
|
10
9
|
/**
|
|
@@ -173,9 +172,9 @@ interface TableOptions_ColumnFiltering<in out _TFeatures extends TableFeatures,
|
|
|
173
172
|
*/
|
|
174
173
|
manualFiltering?: boolean;
|
|
175
174
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
* By default, filtering is done for all rows (max depth of 100), no matter if they are root level parent rows or the child leaf rows of a parent row. Setting this option to `0` will cause filtering to only be applied to the root level parent rows, with all sub-rows remaining unfiltered. Similarly, setting this option to `1` will cause filtering to only be applied to child leaf rows 1 level deep, and so on.
|
|
176
|
+
* This is useful for situations where you want a row's entire child hierarchy to be visible regardless of the applied filter.
|
|
177
|
+
*/
|
|
179
178
|
maxLeafRowFilterDepth?: number;
|
|
180
179
|
/**
|
|
181
180
|
* Called with an updater when column filter state changes. Pair this with
|
|
@@ -3,7 +3,6 @@ import { Table } from "../../types/Table.js";
|
|
|
3
3
|
import { Column } from "../../types/Column.js";
|
|
4
4
|
import { ColumnFiltersState, FilterFn } from "./columnFilteringFeature.types.js";
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
|
-
|
|
7
6
|
//#region src/features/column-filtering/columnFilteringFeature.utils.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Creates the default column filter state.
|
|
@@ -2,7 +2,6 @@ import { RowData } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/column-filtering/createFilteredRowModel.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Creates a memoized filtered row model factory.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
2
|
import { CreatedFilterFn, FilterFnDef } from "./columnFilteringFeature.types.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/column-filtering/filterFns.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Builds a `FilterFn` from a value-level comparator plus optional resolvers.
|
|
@@ -2,7 +2,6 @@ import { OnChangeFn, RowData, Updater } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Row } from "../../types/Row.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/column-grouping/columnGroupingFeature.types.d.ts
|
|
7
6
|
type GroupingState = Array<string>;
|
|
8
7
|
interface TableState_ColumnGrouping {
|
|
@@ -5,7 +5,6 @@ import { Row } from "../../types/Row.js";
|
|
|
5
5
|
import { GroupingState, Row_ColumnGrouping } from "./columnGroupingFeature.types.js";
|
|
6
6
|
import { Cell } from "../../types/Cell.js";
|
|
7
7
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
8
|
-
|
|
9
8
|
//#region src/features/column-grouping/columnGroupingFeature.utils.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Creates the default grouping state.
|
|
@@ -2,7 +2,6 @@ import { RowData } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/column-grouping/createGroupedRowModel.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Creates a memoized grouped row model factory.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { OnChangeFn, RowData, Updater } from "../../types/type-utils.js";
|
|
2
2
|
import { ColumnPinningPosition } from "../column-pinning/columnPinningFeature.types.js";
|
|
3
3
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/column-ordering/columnOrderingFeature.types.d.ts
|
|
6
5
|
type ColumnOrderState = Array<string>;
|
|
7
6
|
interface ColumnIndexes {
|
|
@@ -4,7 +4,6 @@ import { ColumnIndexes, ColumnOrderState } from "./columnOrderingFeature.types.j
|
|
|
4
4
|
import { Table } from "../../types/Table.js";
|
|
5
5
|
import { Column } from "../../types/Column.js";
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
|
|
8
7
|
//#region src/features/column-ordering/columnOrderingFeature.utils.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Creates the default column order state.
|
|
@@ -4,7 +4,6 @@ import { Header } from "../../types/Header.js";
|
|
|
4
4
|
import { Column } from "../../types/Column.js";
|
|
5
5
|
import { Cell } from "../../types/Cell.js";
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
|
|
8
7
|
//#region src/features/column-pinning/columnPinningFeature.types.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Logical column pinning region.
|
|
@@ -7,7 +7,6 @@ import { Column } from "../../types/Column.js";
|
|
|
7
7
|
import { Row } from "../../types/Row.js";
|
|
8
8
|
import { Cell } from "../../types/Cell.js";
|
|
9
9
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
10
|
-
|
|
11
10
|
//#region src/features/column-pinning/columnPinningFeature.utils.d.ts
|
|
12
11
|
/**
|
|
13
12
|
* Creates the default column pinning state.
|
|
@@ -4,7 +4,6 @@ import { Header } from "../../types/Header.js";
|
|
|
4
4
|
import { Table } from "../../types/Table.js";
|
|
5
5
|
import { Column } from "../../types/Column.js";
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
|
|
8
7
|
//#region src/features/column-resizing/columnResizingFeature.utils.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Creates the default transient column resizing state.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OnChangeFn, Updater } from "../../types/type-utils.js";
|
|
2
2
|
import { ColumnPinningPosition } from "../column-pinning/columnPinningFeature.types.js";
|
|
3
|
-
|
|
4
3
|
//#region src/features/column-sizing/columnSizingFeature.types.d.ts
|
|
5
4
|
interface TableState_ColumnSizing {
|
|
6
5
|
columnSizing: ColumnSizingState;
|
|
@@ -5,7 +5,6 @@ import { ColumnPinningPosition } from "../column-pinning/columnPinningFeature.ty
|
|
|
5
5
|
import { Table } from "../../types/Table.js";
|
|
6
6
|
import { Column } from "../../types/Column.js";
|
|
7
7
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
8
|
-
|
|
9
8
|
//#region src/features/column-sizing/columnSizingFeature.utils.d.ts
|
|
10
9
|
/**
|
|
11
10
|
* Creates the default committed column sizing state.
|
|
@@ -2,7 +2,6 @@ import { OnChangeFn, RowData, Updater } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Column } from "../../types/Column.js";
|
|
3
3
|
import { Cell } from "../../types/Cell.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/column-visibility/columnVisibilityFeature.types.d.ts
|
|
7
6
|
type ColumnVisibilityState = Record<string, boolean>;
|
|
8
7
|
interface TableState_ColumnVisibility {
|
|
@@ -5,6 +5,7 @@ import { ColumnVisibilityState } from "./columnVisibilityFeature.types.js";
|
|
|
5
5
|
import { Row } from "../../types/Row.js";
|
|
6
6
|
import { Cell } from "../../types/Cell.js";
|
|
7
7
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
8
|
+
import "../../index.js";
|
|
8
9
|
//#region src/features/column-visibility/columnVisibilityFeature.utils.d.ts
|
|
9
10
|
/**
|
|
10
11
|
* Creates the default column visibility state.
|
|
@@ -18,7 +18,7 @@ const globalFilteringFeature = {
|
|
|
18
18
|
globalFilterFn: "auto",
|
|
19
19
|
getColumnCanGlobalFilter: (column) => {
|
|
20
20
|
if ("enableGlobalFilter" in column.columnDef && column.columnDef.enableGlobalFilter === true) return true;
|
|
21
|
-
const value = table.getCoreRowModel().flatRows[
|
|
21
|
+
const value = table.getCoreRowModel().flatRows.find((row) => row.getAllCellsByColumnId()[column.id]?.getValue() != null)?.getAllCellsByColumnId()[column.id]?.getValue();
|
|
22
22
|
return typeof value === "string" || typeof value === "number";
|
|
23
23
|
}
|
|
24
24
|
};
|
|
@@ -2,7 +2,6 @@ import { CellData, OnChangeFn, RowData, Updater } from "../../types/type-utils.j
|
|
|
2
2
|
import { Column } from "../../types/Column.js";
|
|
3
3
|
import { FilterFn, FilterFnOption } from "../column-filtering/columnFilteringFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/global-filtering/globalFilteringFeature.types.d.ts
|
|
7
6
|
interface TableState_GlobalFiltering {
|
|
8
7
|
globalFilter: any;
|
|
@@ -3,6 +3,7 @@ import { Table } from "../../types/Table.js";
|
|
|
3
3
|
import { Column } from "../../types/Column.js";
|
|
4
4
|
import { CreatedFilterFn, FilterFn } from "../column-filtering/columnFilteringFeature.types.js";
|
|
5
5
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
|
+
import "../../index.js";
|
|
6
7
|
//#region src/features/global-filtering/globalFilteringFeature.utils.d.ts
|
|
7
8
|
/**
|
|
8
9
|
* Checks whether this accessor column participates in global filtering.
|
|
@@ -6,7 +6,6 @@ import { Column } from "../../types/Column.js";
|
|
|
6
6
|
import { Row } from "../../types/Row.js";
|
|
7
7
|
import { Cell } from "../../types/Cell.js";
|
|
8
8
|
import { IsAny, TableFeatures } from "../../types/TableFeatures.js";
|
|
9
|
-
|
|
10
9
|
//#region src/features/row-aggregation/rowAggregationFeature.types.d.ts
|
|
11
10
|
/** Declaration-merging fallback for named aggregation definitions. */
|
|
12
11
|
interface AggregationFns {}
|
|
@@ -100,7 +99,7 @@ type AggregationEntryDefinition<TEntry> = TEntry extends {
|
|
|
100
99
|
/** Infers the scalar or keyed result produced by an aggregation option. */
|
|
101
100
|
type AggregationResult<TOption, TFeatures extends TableFeatures = any> = TOption extends ReadonlyArray<infer TEntry> ? { [TKey in AggregationEntryId<TEntry>]: AggregationResultOfRef<AggregationEntryDefinition<Extract<TEntry, TKey | {
|
|
102
101
|
id: TKey;
|
|
103
|
-
}>>, TFeatures
|
|
102
|
+
}>>, TFeatures>; } : AggregationResultOfRef<TOption, TFeatures>;
|
|
104
103
|
type RegisteredAggregationResult<TFeatures extends TableFeatures> = TFeatures extends {
|
|
105
104
|
aggregationFns: infer TRegistry extends Record<string, unknown>;
|
|
106
105
|
} ? AggregationResultOf<TRegistry[keyof TRegistry]> : unknown;
|
|
@@ -4,7 +4,6 @@ import { Column } from "../../types/Column.js";
|
|
|
4
4
|
import { Row } from "../../types/Row.js";
|
|
5
5
|
import { Cell } from "../../types/Cell.js";
|
|
6
6
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
|
|
8
7
|
//#region src/features/row-aggregation/rowAggregationFeature.utils.d.ts
|
|
9
8
|
/**
|
|
10
9
|
* Selects unique rows at a maximum relative depth in encounter order.
|
|
@@ -2,7 +2,6 @@ import { RowData } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Table } from "../../types/Table.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/row-expanding/createExpandedRowModel.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Creates a memoized expanded row model factory.
|
|
@@ -2,7 +2,6 @@ import { OnChangeFn, RowData, Updater } from "../../types/type-utils.js";
|
|
|
2
2
|
import { Row } from "../../types/Row.js";
|
|
3
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/row-expanding/rowExpandingFeature.types.d.ts
|
|
7
6
|
type ExpandedStateList = Record<string, boolean>;
|
|
8
7
|
type ExpandedState = true | Record<string, boolean>;
|