@tanstack/table-core 9.0.0-beta.7 → 9.0.0-beta.70
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 +5 -1
- package/dist/core/cells/constructCell.d.ts +4 -6
- package/dist/core/cells/constructCell.js +4 -6
- package/dist/core/cells/coreCellsFeature.d.ts +1 -3
- package/dist/core/cells/coreCellsFeature.js +1 -2
- package/dist/core/cells/coreCellsFeature.types.d.ts +7 -9
- package/dist/core/cells/coreCellsFeature.utils.d.ts +5 -5
- package/dist/core/cells/coreCellsFeature.utils.js +1 -2
- package/dist/core/columns/constructColumn.d.ts +4 -6
- package/dist/core/columns/constructColumn.js +8 -9
- package/dist/core/columns/coreColumnsFeature.d.ts +1 -3
- package/dist/core/columns/coreColumnsFeature.js +13 -20
- package/dist/core/columns/coreColumnsFeature.types.d.ts +13 -15
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +10 -12
- package/dist/core/columns/coreColumnsFeature.utils.js +19 -20
- package/dist/core/coreFeatures.d.ts +3 -3
- package/dist/core/coreFeatures.js +1 -2
- package/dist/core/headers/buildHeaderGroups.d.ts +3 -5
- package/dist/core/headers/buildHeaderGroups.js +99 -85
- package/dist/core/headers/constructHeader.d.ts +3 -5
- package/dist/core/headers/constructHeader.js +4 -6
- package/dist/core/headers/coreHeadersFeature.d.ts +1 -3
- package/dist/core/headers/coreHeadersFeature.js +9 -13
- package/dist/core/headers/coreHeadersFeature.types.d.ts +21 -11
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +8 -8
- package/dist/core/headers/coreHeadersFeature.utils.js +14 -17
- package/dist/core/reactivity/coreReactivityFeature.types.d.ts +8 -3
- package/dist/core/reactivity/coreReactivityFeature.utils.d.ts +1 -3
- package/dist/core/reactivity/coreReactivityFeature.utils.js +1 -2
- package/dist/core/reactivity/renderPhaseReactivity.d.ts +80 -0
- package/dist/core/reactivity/renderPhaseReactivity.js +95 -0
- package/dist/core/row-models/coreRowModelsFeature.d.ts +1 -3
- package/dist/core/row-models/coreRowModelsFeature.js +1 -2
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +7 -17
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +17 -19
- package/dist/core/row-models/coreRowModelsFeature.utils.js +9 -28
- package/dist/core/row-models/createCoreRowModel.d.ts +3 -5
- package/dist/core/row-models/createCoreRowModel.js +25 -24
- package/dist/core/rows/constructRow.d.ts +3 -5
- package/dist/core/rows/constructRow.js +9 -13
- package/dist/core/rows/coreRowsFeature.d.ts +1 -3
- package/dist/core/rows/coreRowsFeature.js +20 -5
- package/dist/core/rows/coreRowsFeature.types.d.ts +42 -10
- package/dist/core/rows/coreRowsFeature.utils.d.ts +26 -9
- package/dist/core/rows/coreRowsFeature.utils.js +65 -14
- package/dist/core/table/constructTable.d.ts +2 -4
- package/dist/core/table/constructTable.js +52 -23
- package/dist/core/table/coreTablesFeature.d.ts +1 -3
- package/dist/core/table/coreTablesFeature.js +1 -2
- package/dist/core/table/coreTablesFeature.types.d.ts +56 -25
- package/dist/core/table/coreTablesFeature.utils.d.ts +34 -12
- package/dist/core/table/coreTablesFeature.utils.js +69 -24
- package/dist/experimental-worker-plugin.d.ts +5 -0
- package/dist/experimental-worker-plugin.js +6 -0
- package/dist/features/cell-selection/cellSelectionFeature.d.ts +8 -0
- package/dist/features/cell-selection/cellSelectionFeature.js +128 -0
- package/dist/features/cell-selection/cellSelectionFeature.types.d.ts +296 -0
- package/dist/features/cell-selection/cellSelectionFeature.utils.d.ts +306 -0
- package/dist/features/cell-selection/cellSelectionFeature.utils.js +873 -0
- package/dist/features/cell-selection/cellSelectionGeometry.js +121 -0
- package/dist/features/cell-spanning/cellSpanningFeature.d.ts +13 -0
- package/dist/features/cell-spanning/cellSpanningFeature.js +47 -0
- package/dist/features/cell-spanning/cellSpanningFeature.types.d.ts +150 -0
- package/dist/features/cell-spanning/cellSpanningFeature.utils.d.ts +74 -0
- package/dist/features/cell-spanning/cellSpanningFeature.utils.js +262 -0
- package/dist/features/column-faceting/columnFacetingFeature.d.ts +1 -3
- package/dist/features/column-faceting/columnFacetingFeature.js +13 -20
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +15 -35
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +10 -12
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +25 -14
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.ts +2 -4
- package/dist/features/column-faceting/createFacetedMinMaxValues.js +9 -7
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +3 -5
- package/dist/features/column-faceting/createFacetedRowModel.js +12 -17
- package/dist/features/column-faceting/createFacetedUniqueValues.d.ts +2 -4
- package/dist/features/column-faceting/createFacetedUniqueValues.js +12 -9
- package/dist/features/column-filtering/columnFilteringFeature.d.ts +1 -3
- package/dist/features/column-filtering/columnFilteringFeature.js +4 -5
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +85 -33
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +19 -17
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +33 -21
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +11 -7
- package/dist/features/column-filtering/createFilteredRowModel.js +33 -29
- package/dist/features/column-filtering/filterFns.d.ts +208 -0
- package/dist/features/column-filtering/filterFns.js +374 -0
- package/dist/features/column-filtering/filterRowsUtils.js +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +2 -4
- package/dist/features/column-grouping/columnGroupingFeature.js +7 -20
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +14 -52
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +12 -51
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +8 -61
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +7 -7
- package/dist/features/column-grouping/createGroupedRowModel.js +69 -38
- package/dist/features/column-ordering/columnOrderingFeature.d.ts +1 -3
- package/dist/features/column-ordering/columnOrderingFeature.js +19 -24
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +28 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +26 -16
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +36 -18
- package/dist/features/column-pinning/columnPinningFeature.d.ts +7 -4
- package/dist/features/column-pinning/columnPinningFeature.js +126 -146
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +53 -44
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +100 -93
- package/dist/features/column-pinning/columnPinningFeature.utils.js +148 -150
- package/dist/features/column-resizing/columnResizingFeature.d.ts +1 -3
- package/dist/features/column-resizing/columnResizingFeature.js +1 -2
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +2 -7
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +7 -9
- package/dist/features/column-resizing/columnResizingFeature.utils.js +86 -48
- package/dist/features/column-sizing/columnSizingFeature.d.ts +1 -3
- package/dist/features/column-sizing/columnSizingFeature.js +35 -70
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +52 -11
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +43 -27
- package/dist/features/column-sizing/columnSizingFeature.utils.js +95 -54
- package/dist/features/column-visibility/columnVisibilityFeature.d.ts +1 -3
- package/dist/features/column-visibility/columnVisibilityFeature.js +26 -38
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +4 -6
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +20 -20
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +32 -32
- package/dist/features/global-filtering/globalFilteringFeature.d.ts +1 -3
- package/dist/features/global-filtering/globalFilteringFeature.js +3 -4
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +4 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +10 -13
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +7 -8
- package/dist/features/row-aggregation/aggregationFns.d.ts +66 -0
- package/dist/features/row-aggregation/aggregationFns.js +279 -0
- package/dist/features/row-aggregation/rowAggregationFeature.d.ts +8 -0
- package/dist/features/row-aggregation/rowAggregationFeature.js +35 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +193 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.js +11 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +46 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js +235 -0
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +3 -5
- package/dist/features/row-expanding/createExpandedRowModel.js +9 -13
- package/dist/features/row-expanding/rowExpandingFeature.d.ts +1 -3
- package/dist/features/row-expanding/rowExpandingFeature.js +1 -2
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +6 -17
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +11 -16
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +30 -33
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +3 -5
- package/dist/features/row-pagination/createPaginatedRowModel.js +7 -12
- package/dist/features/row-pagination/rowPaginationFeature.d.ts +1 -3
- package/dist/features/row-pagination/rowPaginationFeature.js +1 -2
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +5 -16
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +18 -20
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +10 -17
- package/dist/features/row-pinning/rowPinningFeature.d.ts +1 -3
- package/dist/features/row-pinning/rowPinningFeature.js +5 -18
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +3 -5
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +8 -10
- package/dist/features/row-pinning/rowPinningFeature.utils.js +10 -16
- package/dist/features/row-selection/rowSelectionFeature.d.ts +1 -3
- package/dist/features/row-selection/rowSelectionFeature.js +68 -25
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +51 -15
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +60 -35
- package/dist/features/row-selection/rowSelectionFeature.utils.js +142 -89
- package/dist/features/row-sorting/createSortedRowModel.d.ts +11 -7
- package/dist/features/row-sorting/createSortedRowModel.js +71 -53
- package/dist/features/row-sorting/rowSortingFeature.d.ts +1 -3
- package/dist/features/row-sorting/rowSortingFeature.js +1 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +54 -24
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +19 -22
- package/dist/features/row-sorting/rowSortingFeature.utils.js +36 -25
- package/dist/features/row-sorting/sortFns.d.ts +96 -0
- package/dist/features/row-sorting/sortFns.js +216 -0
- package/dist/features/stockFeatures.d.ts +7 -3
- package/dist/features/stockFeatures.js +7 -2
- package/dist/flex-render.d.ts +2 -4
- package/dist/flex-render.js +10 -3
- package/dist/helpers/columnHelper.d.ts +3 -5
- package/dist/helpers/columnHelper.js +1 -2
- package/dist/helpers/metaHelper.d.ts +25 -0
- package/dist/helpers/metaHelper.js +28 -0
- package/dist/helpers/tableFeatures.d.ts +35 -8
- package/dist/helpers/tableFeatures.js +33 -5
- package/dist/helpers/tableOptions.d.ts +1 -3
- package/dist/helpers/tableOptions.js +1 -2
- package/dist/index.d.ts +34 -27
- package/dist/index.js +10 -5
- package/dist/reactivity.d.ts +2 -1
- package/dist/reactivity.js +2 -1
- package/dist/static-functions.d.ts +11 -8
- package/dist/static-functions.js +11 -8
- package/dist/store-reactivity-bindings.d.ts +2 -4
- package/dist/store-reactivity-bindings.js +4 -5
- package/dist/types/Cell.d.ts +9 -5
- package/dist/types/Column.d.ts +13 -15
- package/dist/types/ColumnDef.d.ts +39 -21
- package/dist/types/Header.d.ts +3 -5
- package/dist/types/HeaderGroup.d.ts +3 -5
- package/dist/types/Row.d.ts +7 -7
- package/dist/types/RowModel.d.ts +11 -25
- package/dist/types/RowModelFns.d.ts +5 -7
- package/dist/types/Table.d.ts +29 -32
- package/dist/types/TableFeatures.d.ts +388 -24
- package/dist/types/TableOptions.d.ts +24 -14
- package/dist/types/TableState.d.ts +8 -8
- package/dist/types/type-utils.d.ts +10 -4
- package/dist/utils.d.ts +32 -26
- package/dist/utils.js +52 -32
- package/dist/worker/createTableWorker.d.ts +100 -0
- package/dist/worker/createTableWorker.js +185 -0
- package/dist/worker/createWorkerRowModel.d.ts +40 -0
- package/dist/worker/createWorkerRowModel.js +77 -0
- package/dist/worker/initTableWorker.d.ts +31 -0
- package/dist/worker/initTableWorker.js +99 -0
- package/dist/worker/rebuildRowModel.d.ts +11 -0
- package/dist/worker/rebuildRowModel.js +71 -0
- package/dist/worker/serializeRowModel.js +51 -0
- package/dist/worker/tableWorkerProtocol.d.ts +88 -0
- package/dist/worker/tableWorkerProtocol.js +26 -0
- package/package.json +12 -28
- package/skills/aggregation/SKILL.md +141 -0
- package/skills/api-not-found/SKILL.md +113 -0
- package/skills/cell-selection/SKILL.md +204 -0
- package/skills/cell-spanning/SKILL.md +162 -0
- package/skills/client-vs-server/SKILL.md +164 -0
- package/skills/column-faceting/SKILL.md +97 -0
- package/skills/column-filtering/SKILL.md +87 -0
- package/skills/column-ordering/SKILL.md +75 -0
- package/skills/column-pinning/SKILL.md +89 -0
- package/skills/column-resizing/SKILL.md +91 -0
- package/skills/column-sizing/SKILL.md +72 -0
- package/skills/column-visibility/SKILL.md +75 -0
- package/skills/core/SKILL.md +175 -0
- package/skills/custom-features/SKILL.md +235 -0
- package/skills/expanding/SKILL.md +80 -0
- package/skills/global-filtering/SKILL.md +84 -0
- package/skills/grouping/SKILL.md +51 -401
- package/skills/migrate-v8-to-v9/SKILL.md +275 -416
- package/skills/pagination/SKILL.md +37 -344
- package/skills/row-pinning/SKILL.md +47 -234
- package/skills/row-selection/SKILL.md +75 -302
- package/skills/sorting/SKILL.md +45 -303
- package/skills/table-features/SKILL.md +159 -0
- package/skills/typescript/SKILL.md +126 -0
- package/dist/core/cells/constructCell.cjs +0 -34
- package/dist/core/cells/constructCell.cjs.map +0 -1
- package/dist/core/cells/constructCell.d.cts +0 -17
- package/dist/core/cells/constructCell.js.map +0 -1
- package/dist/core/cells/coreCellsFeature.cjs +0 -21
- package/dist/core/cells/coreCellsFeature.cjs.map +0 -1
- package/dist/core/cells/coreCellsFeature.d.cts +0 -10
- package/dist/core/cells/coreCellsFeature.js.map +0 -1
- package/dist/core/cells/coreCellsFeature.types.d.cts +0 -57
- package/dist/core/cells/coreCellsFeature.utils.cjs +0 -57
- package/dist/core/cells/coreCellsFeature.utils.cjs.map +0 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +0 -53
- package/dist/core/cells/coreCellsFeature.utils.js.map +0 -1
- package/dist/core/columns/constructColumn.cjs +0 -61
- package/dist/core/columns/constructColumn.cjs.map +0 -1
- package/dist/core/columns/constructColumn.d.cts +0 -16
- package/dist/core/columns/constructColumn.js.map +0 -1
- package/dist/core/columns/coreColumnsFeature.cjs +0 -70
- package/dist/core/columns/coreColumnsFeature.cjs.map +0 -1
- package/dist/core/columns/coreColumnsFeature.d.cts +0 -10
- package/dist/core/columns/coreColumnsFeature.js.map +0 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +0 -94
- package/dist/core/columns/coreColumnsFeature.utils.cjs +0 -187
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +0 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +0 -119
- package/dist/core/columns/coreColumnsFeature.utils.js.map +0 -1
- package/dist/core/coreFeatures.cjs +0 -25
- package/dist/core/coreFeatures.cjs.map +0 -1
- package/dist/core/coreFeatures.d.cts +0 -26
- package/dist/core/coreFeatures.js.map +0 -1
- package/dist/core/headers/buildHeaderGroups.cjs +0 -103
- package/dist/core/headers/buildHeaderGroups.cjs.map +0 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +0 -16
- package/dist/core/headers/buildHeaderGroups.js.map +0 -1
- package/dist/core/headers/constructHeader.cjs +0 -41
- package/dist/core/headers/constructHeader.cjs.map +0 -1
- package/dist/core/headers/constructHeader.d.cts +0 -22
- package/dist/core/headers/constructHeader.js.map +0 -1
- package/dist/core/headers/coreHeadersFeature.cjs +0 -55
- package/dist/core/headers/coreHeadersFeature.cjs.map +0 -1
- package/dist/core/headers/coreHeadersFeature.d.cts +0 -10
- package/dist/core/headers/coreHeadersFeature.js.map +0 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +0 -106
- package/dist/core/headers/coreHeadersFeature.utils.cjs +0 -142
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +0 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +0 -85
- package/dist/core/headers/coreHeadersFeature.utils.js.map +0 -1
- package/dist/core/reactivity/coreReactivityFeature.types.d.cts +0 -48
- package/dist/core/reactivity/coreReactivityFeature.utils.cjs +0 -24
- package/dist/core/reactivity/coreReactivityFeature.utils.cjs.map +0 -1
- package/dist/core/reactivity/coreReactivityFeature.utils.d.cts +0 -24
- package/dist/core/reactivity/coreReactivityFeature.utils.js.map +0 -1
- package/dist/core/row-models/coreRowModelsFeature.cjs +0 -27
- package/dist/core/row-models/coreRowModelsFeature.cjs.map +0 -1
- package/dist/core/row-models/coreRowModelsFeature.d.cts +0 -10
- package/dist/core/row-models/coreRowModelsFeature.js.map +0 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +0 -41
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +0 -215
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +0 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +0 -153
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +0 -1
- package/dist/core/row-models/createCoreRowModel.cjs +0 -52
- package/dist/core/row-models/createCoreRowModel.cjs.map +0 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +0 -15
- package/dist/core/row-models/createCoreRowModel.js.map +0 -1
- package/dist/core/rows/constructRow.cjs +0 -44
- package/dist/core/rows/constructRow.cjs.map +0 -1
- package/dist/core/rows/constructRow.d.cts +0 -15
- package/dist/core/rows/constructRow.js.map +0 -1
- package/dist/core/rows/coreRowsFeature.cjs +0 -37
- package/dist/core/rows/coreRowsFeature.cjs.map +0 -1
- package/dist/core/rows/coreRowsFeature.d.cts +0 -10
- package/dist/core/rows/coreRowsFeature.js.map +0 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +0 -99
- package/dist/core/rows/coreRowsFeature.utils.cjs +0 -192
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +0 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +0 -127
- package/dist/core/rows/coreRowsFeature.utils.js.map +0 -1
- package/dist/core/table/constructTable.cjs +0 -118
- package/dist/core/table/constructTable.cjs.map +0 -1
- package/dist/core/table/constructTable.d.cts +0 -22
- package/dist/core/table/constructTable.js.map +0 -1
- package/dist/core/table/coreTablesFeature.cjs +0 -17
- package/dist/core/table/coreTablesFeature.cjs.map +0 -1
- package/dist/core/table/coreTablesFeature.d.cts +0 -10
- package/dist/core/table/coreTablesFeature.js.map +0 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +0 -186
- package/dist/core/table/coreTablesFeature.utils.cjs +0 -96
- package/dist/core/table/coreTablesFeature.utils.cjs.map +0 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +0 -57
- package/dist/core/table/coreTablesFeature.utils.js.map +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.cjs +0 -61
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.d.cts +0 -10
- package/dist/features/column-faceting/columnFacetingFeature.js.map +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +0 -85
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +0 -103
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +0 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +0 -84
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +0 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +0 -44
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +0 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.cts +0 -14
- package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +0 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +0 -50
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +0 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.cts +0 -15
- package/dist/features/column-faceting/createFacetedRowModel.js.map +0 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs +0 -41
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +0 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.cts +0 -14
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.cjs +0 -50
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.d.cts +0 -10
- package/dist/features/column-filtering/columnFilteringFeature.js.map +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +0 -160
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +0 -212
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +0 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +0 -143
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +0 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +0 -110
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +0 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +0 -16
- package/dist/features/column-filtering/createFilteredRowModel.js.map +0 -1
- package/dist/features/column-filtering/filterRowsUtils.cjs +0 -81
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +0 -1
- package/dist/features/column-filtering/filterRowsUtils.js.map +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +0 -67
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.cts +0 -10
- package/dist/features/column-grouping/columnGroupingFeature.js.map +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +0 -165
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +0 -250
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +0 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +0 -190
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +0 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +0 -119
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +0 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +0 -16
- package/dist/features/column-grouping/createGroupedRowModel.js.map +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +0 -58
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.d.cts +0 -10
- package/dist/features/column-ordering/columnOrderingFeature.js.map +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +0 -56
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +0 -172
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +0 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +0 -107
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +0 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +0 -221
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +0 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +0 -10
- package/dist/features/column-pinning/columnPinningFeature.js.map +0 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +0 -178
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +0 -585
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +0 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +0 -375
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +0 -1
- package/dist/features/column-resizing/columnResizingFeature.cjs +0 -41
- package/dist/features/column-resizing/columnResizingFeature.cjs.map +0 -1
- package/dist/features/column-resizing/columnResizingFeature.d.cts +0 -10
- package/dist/features/column-resizing/columnResizingFeature.js.map +0 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +0 -81
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +0 -246
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +0 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +0 -109
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +0 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +0 -124
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +0 -1
- package/dist/features/column-sizing/columnSizingFeature.d.cts +0 -10
- package/dist/features/column-sizing/columnSizingFeature.js.map +0 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +0 -96
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +0 -256
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +0 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +0 -182
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +0 -94
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.d.cts +0 -10
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +0 -97
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +0 -283
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +0 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +0 -189
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.cjs +0 -41
- package/dist/features/global-filtering/globalFilteringFeature.cjs.map +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.d.cts +0 -10
- package/dist/features/global-filtering/globalFilteringFeature.js.map +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +0 -71
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +0 -88
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +0 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +0 -74
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +0 -1
- package/dist/features/row-expanding/createExpandedRowModel.cjs +0 -59
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +0 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.cts +0 -21
- package/dist/features/row-expanding/createExpandedRowModel.js.map +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.cjs +0 -47
- package/dist/features/row-expanding/rowExpandingFeature.cjs.map +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.d.cts +0 -10
- package/dist/features/row-expanding/rowExpandingFeature.js.map +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +0 -127
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +0 -281
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +0 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +0 -191
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +0 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +0 -62
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +0 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.cts +0 -15
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.cjs +0 -45
- package/dist/features/row-pagination/rowPaginationFeature.cjs.map +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.d.cts +0 -10
- package/dist/features/row-pagination/rowPaginationFeature.js.map +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +0 -135
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +0 -312
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +0 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +0 -218
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +0 -1
- package/dist/features/row-pinning/rowPinningFeature.cjs +0 -67
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +0 -1
- package/dist/features/row-pinning/rowPinningFeature.d.cts +0 -10
- package/dist/features/row-pinning/rowPinningFeature.js.map +0 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +0 -83
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +0 -229
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +0 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +0 -143
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +0 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +0 -75
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +0 -1
- package/dist/features/row-selection/rowSelectionFeature.d.cts +0 -10
- package/dist/features/row-selection/rowSelectionFeature.js.map +0 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +0 -136
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +0 -514
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +0 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +0 -318
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +0 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +0 -95
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +0 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +0 -16
- package/dist/features/row-sorting/createSortedRowModel.js.map +0 -1
- package/dist/features/row-sorting/rowSortingFeature.cjs +0 -55
- package/dist/features/row-sorting/rowSortingFeature.cjs.map +0 -1
- package/dist/features/row-sorting/rowSortingFeature.d.cts +0 -10
- package/dist/features/row-sorting/rowSortingFeature.js.map +0 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +0 -188
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +0 -305
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +0 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +0 -193
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +0 -1
- package/dist/features/stockFeatures.cjs +0 -41
- package/dist/features/stockFeatures.cjs.map +0 -1
- package/dist/features/stockFeatures.d.cts +0 -41
- package/dist/features/stockFeatures.js.map +0 -1
- package/dist/flex-render.cjs +0 -29
- package/dist/flex-render.cjs.map +0 -1
- package/dist/flex-render.d.cts +0 -34
- package/dist/flex-render.js.map +0 -1
- package/dist/fns/aggregationFns.cjs +0 -161
- package/dist/fns/aggregationFns.cjs.map +0 -1
- package/dist/fns/aggregationFns.d.cts +0 -85
- package/dist/fns/aggregationFns.d.ts +0 -85
- package/dist/fns/aggregationFns.js +0 -151
- package/dist/fns/aggregationFns.js.map +0 -1
- package/dist/fns/filterFns.cjs +0 -201
- package/dist/fns/filterFns.cjs.map +0 -1
- package/dist/fns/filterFns.d.cts +0 -167
- package/dist/fns/filterFns.d.ts +0 -167
- package/dist/fns/filterFns.js +0 -185
- package/dist/fns/filterFns.js.map +0 -1
- package/dist/fns/sortFns.cjs +0 -130
- package/dist/fns/sortFns.cjs.map +0 -1
- package/dist/fns/sortFns.d.cts +0 -65
- package/dist/fns/sortFns.d.ts +0 -65
- package/dist/fns/sortFns.js +0 -122
- package/dist/fns/sortFns.js.map +0 -1
- package/dist/helpers/columnHelper.cjs +0 -41
- package/dist/helpers/columnHelper.cjs.map +0 -1
- package/dist/helpers/columnHelper.d.cts +0 -71
- package/dist/helpers/columnHelper.js.map +0 -1
- package/dist/helpers/tableFeatures.cjs +0 -20
- package/dist/helpers/tableFeatures.cjs.map +0 -1
- package/dist/helpers/tableFeatures.d.cts +0 -18
- package/dist/helpers/tableFeatures.js.map +0 -1
- package/dist/helpers/tableOptions.cjs +0 -15
- package/dist/helpers/tableOptions.cjs.map +0 -1
- package/dist/helpers/tableOptions.d.cts +0 -57
- package/dist/helpers/tableOptions.js.map +0 -1
- package/dist/index.cjs +0 -133
- package/dist/index.d.cts +0 -78
- package/dist/reactivity.cjs +0 -4
- package/dist/reactivity.d.cts +0 -3
- package/dist/static-functions.cjs +0 -263
- package/dist/static-functions.d.cts +0 -21
- package/dist/store-reactivity-bindings.cjs +0 -44
- package/dist/store-reactivity-bindings.cjs.map +0 -1
- package/dist/store-reactivity-bindings.d.cts +0 -22
- package/dist/store-reactivity-bindings.js.map +0 -1
- package/dist/types/Cell.d.cts +0 -14
- package/dist/types/Column.d.cts +0 -36
- package/dist/types/ColumnDef.d.cts +0 -109
- package/dist/types/Header.d.cts +0 -16
- package/dist/types/HeaderGroup.d.cts +0 -10
- package/dist/types/Row.d.cts +0 -26
- package/dist/types/RowModel.d.cts +0 -36
- package/dist/types/RowModelFns.d.cts +0 -18
- package/dist/types/Table.d.cts +0 -70
- package/dist/types/TableFeatures.d.cts +0 -53
- package/dist/types/TableOptions.d.cts +0 -69
- package/dist/types/TableState.d.cts +0 -48
- package/dist/types/type-utils.d.cts +0 -23
- package/dist/utils.cjs +0 -243
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -114
- package/dist/utils.js.map +0 -1
- package/skills/column-definitions/SKILL.md +0 -333
- package/skills/column-layout/SKILL.md +0 -328
- package/skills/column-layout/references/subsystems.md +0 -220
- package/skills/customizing-feature-behavior/SKILL.md +0 -416
- package/skills/filtering/SKILL.md +0 -357
- package/skills/filtering/references/faceting-and-fuzzy.md +0 -191
- package/skills/row-expanding/SKILL.md +0 -348
- package/skills/setup/SKILL.md +0 -400
- package/skills/state-management/SKILL.md +0 -388
- package/src/core/cells/constructCell.ts +0 -55
- package/src/core/cells/coreCellsFeature.ts +0 -27
- package/src/core/cells/coreCellsFeature.types.ts +0 -68
- package/src/core/cells/coreCellsFeature.utils.ts +0 -68
- package/src/core/columns/constructColumn.ts +0 -119
- package/src/core/columns/coreColumnsFeature.ts +0 -73
- package/src/core/columns/coreColumnsFeature.types.ts +0 -108
- package/src/core/columns/coreColumnsFeature.utils.ts +0 -275
- package/src/core/coreFeatures.ts +0 -31
- package/src/core/headers/buildHeaderGroups.ts +0 -182
- package/src/core/headers/constructHeader.ts +0 -67
- package/src/core/headers/coreHeadersFeature.ts +0 -56
- package/src/core/headers/coreHeadersFeature.types.ts +0 -125
- package/src/core/headers/coreHeadersFeature.utils.ts +0 -200
- package/src/core/reactivity/coreReactivityFeature.types.ts +0 -56
- package/src/core/reactivity/coreReactivityFeature.utils.ts +0 -44
- package/src/core/row-models/coreRowModelsFeature.ts +0 -62
- package/src/core/row-models/coreRowModelsFeature.types.ts +0 -64
- package/src/core/row-models/coreRowModelsFeature.utils.ts +0 -272
- package/src/core/row-models/createCoreRowModel.ts +0 -93
- package/src/core/rows/constructRow.ts +0 -66
- package/src/core/rows/coreRowsFeature.ts +0 -62
- package/src/core/rows/coreRowsFeature.types.ts +0 -117
- package/src/core/rows/coreRowsFeature.utils.ts +0 -264
- package/src/core/table/constructTable.ts +0 -172
- package/src/core/table/coreTablesFeature.ts +0 -19
- package/src/core/table/coreTablesFeature.types.ts +0 -216
- package/src/core/table/coreTablesFeature.utils.ts +0 -131
- package/src/features/column-faceting/columnFacetingFeature.ts +0 -89
- package/src/features/column-faceting/columnFacetingFeature.types.ts +0 -109
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +0 -145
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +0 -66
- package/src/features/column-faceting/createFacetedRowModel.ts +0 -85
- package/src/features/column-faceting/createFacetedUniqueValues.ts +0 -66
- package/src/features/column-filtering/columnFilteringFeature.ts +0 -86
- package/src/features/column-filtering/columnFilteringFeature.types.ts +0 -232
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +0 -331
- package/src/features/column-filtering/createFilteredRowModel.ts +0 -183
- package/src/features/column-filtering/filterRowsUtils.ts +0 -157
- package/src/features/column-grouping/columnGroupingFeature.ts +0 -115
- package/src/features/column-grouping/columnGroupingFeature.types.ts +0 -226
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +0 -354
- package/src/features/column-grouping/createGroupedRowModel.ts +0 -220
- package/src/features/column-ordering/columnOrderingFeature.ts +0 -73
- package/src/features/column-ordering/columnOrderingFeature.types.ts +0 -60
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +0 -241
- package/src/features/column-pinning/columnPinningFeature.ts +0 -316
- package/src/features/column-pinning/columnPinningFeature.types.ts +0 -192
- package/src/features/column-pinning/columnPinningFeature.utils.ts +0 -908
- package/src/features/column-resizing/columnResizingFeature.ts +0 -65
- package/src/features/column-resizing/columnResizingFeature.types.ts +0 -89
- package/src/features/column-resizing/columnResizingFeature.utils.ts +0 -364
- package/src/features/column-sizing/columnSizingFeature.ts +0 -145
- package/src/features/column-sizing/columnSizingFeature.types.ts +0 -102
- package/src/features/column-sizing/columnSizingFeature.utils.ts +0 -381
- package/src/features/column-visibility/columnVisibilityFeature.ts +0 -122
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +0 -112
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +0 -384
- package/src/features/global-filtering/globalFilteringFeature.ts +0 -65
- package/src/features/global-filtering/globalFilteringFeature.types.ts +0 -91
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +0 -118
- package/src/features/row-expanding/createExpandedRowModel.ts +0 -82
- package/src/features/row-expanding/rowExpandingFeature.ts +0 -94
- package/src/features/row-expanding/rowExpandingFeature.types.ts +0 -147
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +0 -374
- package/src/features/row-pagination/createPaginatedRowModel.ts +0 -83
- package/src/features/row-pagination/rowPaginationFeature.ts +0 -95
- package/src/features/row-pagination/rowPaginationFeature.types.ts +0 -152
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +0 -400
- package/src/features/row-pinning/rowPinningFeature.ts +0 -97
- package/src/features/row-pinning/rowPinningFeature.types.ts +0 -95
- package/src/features/row-pinning/rowPinningFeature.utils.ts +0 -323
- package/src/features/row-selection/rowSelectionFeature.ts +0 -140
- package/src/features/row-selection/rowSelectionFeature.types.ts +0 -151
- package/src/features/row-selection/rowSelectionFeature.utils.ts +0 -745
- package/src/features/row-sorting/createSortedRowModel.ts +0 -157
- package/src/features/row-sorting/rowSortingFeature.ts +0 -103
- package/src/features/row-sorting/rowSortingFeature.types.ts +0 -235
- package/src/features/row-sorting/rowSortingFeature.utils.ts +0 -489
- package/src/features/stockFeatures.ts +0 -53
- package/src/flex-render.ts +0 -70
- package/src/fns/aggregationFns.ts +0 -245
- package/src/fns/filterFns.ts +0 -382
- package/src/fns/sortFns.ts +0 -240
- package/src/helpers/columnHelper.ts +0 -122
- package/src/helpers/tableFeatures.ts +0 -24
- package/src/helpers/tableOptions.ts +0 -117
- package/src/index.ts +0 -138
- package/src/process-env.d.ts +0 -6
- package/src/reactivity.ts +0 -2
- package/src/static-functions.ts +0 -31
- package/src/store-reactivity-bindings.ts +0 -47
- package/src/types/Cell.ts +0 -21
- package/src/types/Column.ts +0 -51
- package/src/types/ColumnDef.ts +0 -228
- package/src/types/Header.ts +0 -23
- package/src/types/HeaderGroup.ts +0 -13
- package/src/types/Row.ts +0 -34
- package/src/types/RowModel.ts +0 -98
- package/src/types/RowModelFns.ts +0 -32
- package/src/types/Table.ts +0 -91
- package/src/types/TableFeatures.ts +0 -101
- package/src/types/TableOptions.ts +0 -101
- package/src/types/TableState.ts +0 -47
- package/src/types/type-utils.ts +0 -84
- package/src/utils.ts +0 -441
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
import { callMemoOrStaticFn, cloneState, makeObjectMap } from "../../utils.js";
|
|
2
|
+
import { table_getVisibleLeafColumns } from "../column-visibility/columnVisibilityFeature.utils.js";
|
|
3
|
+
import { applyCellSelectionBoundsOperations, expandCellSelectionBounds } from "./cellSelectionGeometry.js";
|
|
4
|
+
|
|
5
|
+
//#region src/features/cell-selection/cellSelectionFeature.utils.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates the default cell selection state.
|
|
8
|
+
*
|
|
9
|
+
* The feature default is an empty selection. Reset APIs use this value when
|
|
10
|
+
* `defaultState` is `true`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const selection = getDefaultCellSelectionState()
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function getDefaultCellSelectionState() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Routes a cell selection updater through the table's selection change handler.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* table_setCellSelection(table, (old) => old.slice(0, -1))
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function table_setCellSelection(table, updater) {
|
|
29
|
+
table.options.onCellSelectionChange?.(updater);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resets `cellSelection` to the configured initial state or feature default.
|
|
33
|
+
*
|
|
34
|
+
* With no argument, the reset clones `table.initialState.cellSelection` when it
|
|
35
|
+
* exists. Passing `true` ignores initial state and resets to an empty selection.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* table_resetCellSelection(table, true)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
function table_resetCellSelection(table, defaultState) {
|
|
43
|
+
table_setCellSelection(table, defaultState ? getDefaultCellSelectionState() : cloneState(table.initialState.cellSelection) ?? getDefaultCellSelectionState());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Schedules a cell selection reset after `data` changes.
|
|
47
|
+
*
|
|
48
|
+
* Ranges are stored as row and column ids, so without this a data swap would
|
|
49
|
+
* leave a selection pointing at rows that no longer exist, or silently
|
|
50
|
+
* re-select cells whenever new data reuses ids. The reset runs when
|
|
51
|
+
* `autoResetAll` or `autoResetCellSelection` allows it, defaulting to on.
|
|
52
|
+
*
|
|
53
|
+
* Resetting to `initialState.cellSelection` rather than to empty means the
|
|
54
|
+
* first row-model computation is a no-op, matching `table_autoResetExpanded`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* table_autoResetCellSelection(table)
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
function table_autoResetCellSelection(table) {
|
|
62
|
+
if (!table.atoms.cellSelection) return;
|
|
63
|
+
if (table.options.autoResetAll ?? table.options.autoResetCellSelection ?? true) table._reactivity.schedule(() => table_resetCellSelection(table));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the visible leaf columns in the order their cells actually render.
|
|
67
|
+
*
|
|
68
|
+
* This is deliberately not `getVisibleLeafColumns()`, which is
|
|
69
|
+
* visibility-filtered but *not* pinning-reordered, and not `column_getIndex()`,
|
|
70
|
+
* which indexes that same unpinned list. Cells render start-pinned first, then
|
|
71
|
+
* center, then end (see `row_getVisibleCells`), so indexing a selection in the
|
|
72
|
+
* unpinned order would make a dragged rectangle contiguous in index space but
|
|
73
|
+
* visually scattered the moment a column is pinned.
|
|
74
|
+
*
|
|
75
|
+
* The pinning read is inlined rather than delegated to the column pinning
|
|
76
|
+
* utils so this stays correct when that feature is absent, and so the ordering
|
|
77
|
+
* provably matches `row_getVisibleCells`.
|
|
78
|
+
*/
|
|
79
|
+
function getDisplayOrderedColumns(table) {
|
|
80
|
+
const columns = callMemoOrStaticFn(table, "getVisibleLeafColumns", table_getVisibleLeafColumns);
|
|
81
|
+
const pinning = table.atoms.columnPinning?.get();
|
|
82
|
+
if (!pinning || !pinning.start.length && !pinning.end.length) return columns;
|
|
83
|
+
const byId = makeObjectMap();
|
|
84
|
+
for (let i = 0; i < columns.length; i++) byId[columns[i].id] = columns[i];
|
|
85
|
+
const start = [];
|
|
86
|
+
for (let i = 0; i < pinning.start.length; i++) {
|
|
87
|
+
const column = byId[pinning.start[i]];
|
|
88
|
+
if (column) start.push(column);
|
|
89
|
+
}
|
|
90
|
+
const end = [];
|
|
91
|
+
for (let i = 0; i < pinning.end.length; i++) {
|
|
92
|
+
const column = byId[pinning.end[i]];
|
|
93
|
+
if (column) end.push(column);
|
|
94
|
+
}
|
|
95
|
+
const center = [];
|
|
96
|
+
for (let i = 0; i < columns.length; i++) {
|
|
97
|
+
const column = columns[i];
|
|
98
|
+
if (!pinning.start.includes(column.id) && !pinning.end.includes(column.id)) center.push(column);
|
|
99
|
+
}
|
|
100
|
+
return [
|
|
101
|
+
...start,
|
|
102
|
+
...center,
|
|
103
|
+
...end
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Builds a column id to render-order index map.
|
|
108
|
+
*
|
|
109
|
+
* Registered by this feature so the lookup stays memoized even when
|
|
110
|
+
* `columnOrderingFeature` is absent, since that feature's `getColumnIndexes`
|
|
111
|
+
* static rebuilds all four maps on every call, which would make per-cell reads
|
|
112
|
+
* O(columns).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const index = table_getCellSelectionColumnIndexes(table)[columnId]
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
function table_getCellSelectionColumnIndexes(table) {
|
|
120
|
+
const columns = getDisplayOrderedColumns(table);
|
|
121
|
+
const indexes = makeObjectMap();
|
|
122
|
+
for (let i = 0; i < columns.length; i++) indexes[columns[i].id] = i;
|
|
123
|
+
return indexes;
|
|
124
|
+
}
|
|
125
|
+
const EMPTY_MERGE_BOUNDS = [];
|
|
126
|
+
function probeCellSpanIndex(table) {
|
|
127
|
+
return table.getCellSpanIndex?.();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolves the merged-cell rectangles of the rendered rows into selection's
|
|
131
|
+
* own index space.
|
|
132
|
+
*
|
|
133
|
+
* The span index positions rows by their paginated render order while
|
|
134
|
+
* selection positions them by pre-paginated display order, so each merge is
|
|
135
|
+
* mapped through `row.getDisplayIndex()`. A merge whose rows do not map to a
|
|
136
|
+
* contiguous display range is skipped defensively; it then behaves like
|
|
137
|
+
* unmerged cells instead of corrupting the geometry.
|
|
138
|
+
*
|
|
139
|
+
* Returns an empty array when `cellSpanningFeature` is not registered, which
|
|
140
|
+
* keeps every selection code path identical to the span-unaware behavior.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const merges = table_getCellSelectionMergeBounds(table)
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
function table_getCellSelectionMergeBounds(table) {
|
|
148
|
+
const spanIndex = probeCellSpanIndex(table);
|
|
149
|
+
if (!spanIndex) return EMPTY_MERGE_BOUNDS;
|
|
150
|
+
const columnIndexes = callMemoOrStaticFn(table, "getCellSelectionColumnIndexes", table_getCellSelectionColumnIndexes);
|
|
151
|
+
const merges = [];
|
|
152
|
+
for (const columnId in spanIndex.rowSpans) {
|
|
153
|
+
const columnIndex = columnIndexes[columnId];
|
|
154
|
+
if (columnIndex === void 0) continue;
|
|
155
|
+
const spans = spanIndex.rowSpans[columnId];
|
|
156
|
+
const spanColumnIndex = spanIndex.columnIndexes[columnId];
|
|
157
|
+
for (let r = 0; r < spans.length; r++) {
|
|
158
|
+
const span = spans[r];
|
|
159
|
+
if (span <= 1) continue;
|
|
160
|
+
const startRow = spanIndex.rows[r].getDisplayIndex();
|
|
161
|
+
const endRow = spanIndex.rows[r + span - 1].getDisplayIndex();
|
|
162
|
+
if (startRow < 0 || endRow - startRow !== span - 1) continue;
|
|
163
|
+
const colSpan = spanColumnIndex === void 0 ? 1 : Math.max(spanIndex.colSpans[r]?.[spanColumnIndex] ?? 1, 1);
|
|
164
|
+
merges.push({
|
|
165
|
+
minRowIndex: startRow,
|
|
166
|
+
maxRowIndex: endRow,
|
|
167
|
+
minColumnIndex: columnIndex,
|
|
168
|
+
maxColumnIndex: columnIndex + colSpan - 1
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (spanIndex.colSpans.length) {
|
|
173
|
+
const columnIdBySpanIndex = [];
|
|
174
|
+
for (const columnId in spanIndex.columnIndexes) columnIdBySpanIndex[spanIndex.columnIndexes[columnId]] = columnId;
|
|
175
|
+
for (let r = 0; r < spanIndex.colSpans.length; r++) {
|
|
176
|
+
const rowColSpans = spanIndex.colSpans[r];
|
|
177
|
+
if (!rowColSpans) continue;
|
|
178
|
+
const displayRow = spanIndex.rows[r]?.getDisplayIndex() ?? -1;
|
|
179
|
+
if (displayRow < 0) continue;
|
|
180
|
+
for (let c = 0; c < rowColSpans.length; c++) {
|
|
181
|
+
const span = rowColSpans[c];
|
|
182
|
+
if (span <= 1) continue;
|
|
183
|
+
const columnId = columnIdBySpanIndex[c];
|
|
184
|
+
if (columnId === void 0) continue;
|
|
185
|
+
const vertical = spanIndex.rowSpans[columnId];
|
|
186
|
+
if (vertical && vertical[r] !== 1) continue;
|
|
187
|
+
const columnIndex = columnIndexes[columnId];
|
|
188
|
+
if (columnIndex === void 0) continue;
|
|
189
|
+
merges.push({
|
|
190
|
+
minRowIndex: displayRow,
|
|
191
|
+
maxRowIndex: displayRow,
|
|
192
|
+
minColumnIndex: columnIndex,
|
|
193
|
+
maxColumnIndex: columnIndex + span - 1
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return merges;
|
|
199
|
+
}
|
|
200
|
+
function findMergeBoundsAt(merges, rowIndex, columnIndex) {
|
|
201
|
+
for (let i = 0; i < merges.length; i++) {
|
|
202
|
+
const merge = merges[i];
|
|
203
|
+
if (rowIndex >= merge.minRowIndex && rowIndex <= merge.maxRowIndex && columnIndex >= merge.minColumnIndex && columnIndex <= merge.maxColumnIndex) return merge;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Resolves a row id to its display-order index, or `-1` when it no longer
|
|
208
|
+
* identifies a row in the current order.
|
|
209
|
+
*
|
|
210
|
+
* Callers must have already called `table.getRowsInDisplayOrder()`, which is
|
|
211
|
+
* what populates the display index cache each row reads.
|
|
212
|
+
*/
|
|
213
|
+
function resolveRowIndex(table, rows, rowId) {
|
|
214
|
+
const row = table.getPrePaginatedRowModel().rowsById[rowId] ?? table.getCoreRowModel().rowsById[rowId];
|
|
215
|
+
if (!row) return -1;
|
|
216
|
+
const index = row.getDisplayIndex();
|
|
217
|
+
if (index < 0 || index >= rows.length || rows[index]?.id !== rowId) return -1;
|
|
218
|
+
return index;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Resolves ordered range operations into disjoint, positive display-order
|
|
222
|
+
* index rectangles.
|
|
223
|
+
*
|
|
224
|
+
* This is the single cache every per-cell read goes through, so index lookups
|
|
225
|
+
* happen once per invalidation rather than once per cell. A range whose corners
|
|
226
|
+
* no longer resolve, for example because its anchor row was filtered out, is
|
|
227
|
+
* omitted rather than clamped, so it contributes nothing while remaining in
|
|
228
|
+
* state and returns intact when the filter clears.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* const bounds = table_getCellSelectionBounds(table)
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
function table_getCellSelectionBounds(table) {
|
|
236
|
+
const ranges = table.atoms.cellSelection?.get();
|
|
237
|
+
if (!ranges?.length) return [];
|
|
238
|
+
const rows = table.getRowsInDisplayOrder();
|
|
239
|
+
const columnIndexes = callMemoOrStaticFn(table, "getCellSelectionColumnIndexes", table_getCellSelectionColumnIndexes);
|
|
240
|
+
const operations = [];
|
|
241
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
242
|
+
const range = ranges[i];
|
|
243
|
+
const anchorRowIndex = resolveRowIndex(table, rows, range.anchorRowId);
|
|
244
|
+
const focusRowIndex = resolveRowIndex(table, rows, range.focusRowId);
|
|
245
|
+
const anchorColumnIndex = columnIndexes[range.anchorColumnId] ?? -1;
|
|
246
|
+
const focusColumnIndex = columnIndexes[range.focusColumnId] ?? -1;
|
|
247
|
+
if (anchorRowIndex < 0 || focusRowIndex < 0 || anchorColumnIndex < 0 || focusColumnIndex < 0) continue;
|
|
248
|
+
operations.push({
|
|
249
|
+
minRowIndex: Math.min(anchorRowIndex, focusRowIndex),
|
|
250
|
+
maxRowIndex: Math.max(anchorRowIndex, focusRowIndex),
|
|
251
|
+
minColumnIndex: Math.min(anchorColumnIndex, focusColumnIndex),
|
|
252
|
+
maxColumnIndex: Math.max(anchorColumnIndex, focusColumnIndex),
|
|
253
|
+
operation: range.operation ?? "include"
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
const merges = callMemoOrStaticFn(table, "getCellSelectionMergeBounds", table_getCellSelectionMergeBounds);
|
|
257
|
+
if (merges.length) for (let i = 0; i < operations.length; i++) {
|
|
258
|
+
const operation = operations[i];
|
|
259
|
+
const expanded = expandCellSelectionBounds(operation, merges);
|
|
260
|
+
operation.minRowIndex = expanded.minRowIndex;
|
|
261
|
+
operation.maxRowIndex = expanded.maxRowIndex;
|
|
262
|
+
operation.minColumnIndex = expanded.minColumnIndex;
|
|
263
|
+
operation.maxColumnIndex = expanded.maxColumnIndex;
|
|
264
|
+
}
|
|
265
|
+
return applyCellSelectionBoundsOperations(operations);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Tests whether an index pair falls inside any resolved rectangle.
|
|
269
|
+
*/
|
|
270
|
+
function isWithinBounds(bounds, rowIndex, columnIndex) {
|
|
271
|
+
for (let i = 0; i < bounds.length; i++) {
|
|
272
|
+
const bound = bounds[i];
|
|
273
|
+
if (rowIndex >= bound.minRowIndex && rowIndex <= bound.maxRowIndex && columnIndex >= bound.minColumnIndex && columnIndex <= bound.maxColumnIndex) return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Checks whether this cell can currently be selected.
|
|
279
|
+
*
|
|
280
|
+
* A column def opting out with `enableCellSelection: false` wins over the table
|
|
281
|
+
* option, matching how the other per-column enable flags resolve.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* const canSelect = cell_getCanSelect(cell)
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
function cell_getCanSelect(cell) {
|
|
289
|
+
if (cell.column.columnDef.enableCellSelection === false) return false;
|
|
290
|
+
const enabled = cell.table.options.enableCellSelection;
|
|
291
|
+
if (typeof enabled === "function") return enabled(cell);
|
|
292
|
+
return enabled ?? true;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Resolves a cell to the coordinates every selection read needs.
|
|
296
|
+
*
|
|
297
|
+
* Shared by `getIsSelected` and `getSelectionEdges` so a render pass resolves
|
|
298
|
+
* each cell once. Resolving in both meant every cell paid for the bounds memo,
|
|
299
|
+
* the display index, and the column index map twice over.
|
|
300
|
+
*
|
|
301
|
+
* Returns `null` when the cell cannot participate in a selection at all.
|
|
302
|
+
*/
|
|
303
|
+
function resolveCellPosition(cell) {
|
|
304
|
+
const table = cell.table;
|
|
305
|
+
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
306
|
+
if (!bounds.length) return null;
|
|
307
|
+
if (!callMemoOrStaticFn(cell, "getCanSelect", cell_getCanSelect)) return null;
|
|
308
|
+
const rowIndex = cell.row.getDisplayIndex();
|
|
309
|
+
if (rowIndex < 0) return null;
|
|
310
|
+
const columnIndex = callMemoOrStaticFn(table, "getCellSelectionColumnIndexes", table_getCellSelectionColumnIndexes)[cell.column.id] ?? -1;
|
|
311
|
+
if (columnIndex < 0) return null;
|
|
312
|
+
return {
|
|
313
|
+
bounds,
|
|
314
|
+
rowIndex,
|
|
315
|
+
columnIndex
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Checks whether this cell falls inside the final positive selection.
|
|
320
|
+
*
|
|
321
|
+
* Deliberately not memoized. Registering this through `assignPrototypeAPIs`
|
|
322
|
+
* with `memoDeps` would allocate a memo closure and dependency array per cell,
|
|
323
|
+
* which costs more than the handful of integer comparisons it would save.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* const isSelected = cell_getIsSelected(cell)
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
function cell_getIsSelected(cell) {
|
|
331
|
+
const position = resolveCellPosition(cell);
|
|
332
|
+
if (!position) return false;
|
|
333
|
+
return isWithinBounds(position.bounds, position.rowIndex, position.columnIndex);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Checks whether this cell is the active cell.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* const isFocused = cell_getIsFocused(cell)
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
function cell_getIsFocused(cell) {
|
|
344
|
+
const ranges = cell.table.atoms.cellSelection?.get();
|
|
345
|
+
const active = ranges?.[ranges.length - 1];
|
|
346
|
+
if (!active) return false;
|
|
347
|
+
return active.anchorRowId === cell.row.id && active.anchorColumnId === cell.column.id;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Returns `0` for the focused cell and `-1` otherwise, for roving tabindex.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* const tabIndex = cell_getTabIndex(cell)
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
function cell_getTabIndex(cell) {
|
|
358
|
+
return callMemoOrStaticFn(cell, "getIsFocused", cell_getIsFocused) ? 0 : -1;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Returns which sides of this cell sit on the outer boundary of the selection.
|
|
362
|
+
*
|
|
363
|
+
* A side is an edge when the neighbouring cell in that direction is not itself
|
|
364
|
+
* covered by a range, which is what lets a consumer draw a single outline
|
|
365
|
+
* around an arbitrary union of rectangles.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* const { top, right, bottom, left } = cell_getSelectionEdges(cell)
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
function cell_getSelectionEdges(cell) {
|
|
373
|
+
const none = {
|
|
374
|
+
top: false,
|
|
375
|
+
right: false,
|
|
376
|
+
bottom: false,
|
|
377
|
+
left: false
|
|
378
|
+
};
|
|
379
|
+
const position = resolveCellPosition(cell);
|
|
380
|
+
if (!position) return none;
|
|
381
|
+
const { bounds, rowIndex, columnIndex } = position;
|
|
382
|
+
if (!isWithinBounds(bounds, rowIndex, columnIndex)) return none;
|
|
383
|
+
const merges = callMemoOrStaticFn(cell.table, "getCellSelectionMergeBounds", table_getCellSelectionMergeBounds);
|
|
384
|
+
const merge = merges.length ? findMergeBoundsAt(merges, rowIndex, columnIndex) : void 0;
|
|
385
|
+
if (!merge) return {
|
|
386
|
+
top: !isWithinBounds(bounds, rowIndex - 1, columnIndex),
|
|
387
|
+
right: !isWithinBounds(bounds, rowIndex, columnIndex + 1),
|
|
388
|
+
bottom: !isWithinBounds(bounds, rowIndex + 1, columnIndex),
|
|
389
|
+
left: !isWithinBounds(bounds, rowIndex, columnIndex - 1)
|
|
390
|
+
};
|
|
391
|
+
return {
|
|
392
|
+
top: isStripOutside(bounds, merge.minRowIndex - 1, merge.minColumnIndex, merge.maxColumnIndex, true),
|
|
393
|
+
right: isStripOutside(bounds, merge.maxColumnIndex + 1, merge.minRowIndex, merge.maxRowIndex, false),
|
|
394
|
+
bottom: isStripOutside(bounds, merge.maxRowIndex + 1, merge.minColumnIndex, merge.maxColumnIndex, true),
|
|
395
|
+
left: isStripOutside(bounds, merge.minColumnIndex - 1, merge.minRowIndex, merge.maxRowIndex, false)
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function isStripOutside(bounds, fixedIndex, from, to, fixedIsRow) {
|
|
399
|
+
for (let i = from; i <= to; i++) if (!isWithinBounds(bounds, fixedIsRow ? fixedIndex : i, fixedIsRow ? i : fixedIndex)) return true;
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Returns the active cell, i.e. the anchor of the most recent operation.
|
|
404
|
+
*
|
|
405
|
+
* Focus is derived rather than stored: in spreadsheet semantics, dragging from
|
|
406
|
+
* A1 to C5 leaves the active cell at A1, so the active range's anchor already
|
|
407
|
+
* is the active cell.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* const cell = table_getFocusedCell(table)
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
function table_getFocusedCell(table) {
|
|
415
|
+
const ranges = table.atoms.cellSelection?.get();
|
|
416
|
+
const active = ranges?.[ranges.length - 1];
|
|
417
|
+
if (!active) return void 0;
|
|
418
|
+
return (table.getPrePaginatedRowModel().rowsById[active.anchorRowId] ?? table.getCoreRowModel().rowsById[active.anchorRowId])?.getAllCellsByColumnId()[active.anchorColumnId];
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Collapses the selection to a single cell at the given coordinates.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* table_setFocusedCell(table, '3', 'firstName')
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
function table_setFocusedCell(table, rowId, columnId) {
|
|
429
|
+
table_selectCellRange(table, {
|
|
430
|
+
anchorRowId: rowId,
|
|
431
|
+
anchorColumnId: columnId,
|
|
432
|
+
focusRowId: rowId,
|
|
433
|
+
focusColumnId: columnId
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Selects a rectangle using replace, include, or exclude semantics.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```ts
|
|
441
|
+
* table_selectCellRange(table, range, { mode: 'exclude' })
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
function table_selectCellRange(table, range, opts) {
|
|
445
|
+
const mode = opts?.mode ?? (opts?.additive ? "include" : "replace");
|
|
446
|
+
const { operation: _operation, ...coordinates } = range;
|
|
447
|
+
const nextRange = mode === "exclude" ? {
|
|
448
|
+
...coordinates,
|
|
449
|
+
operation: "exclude"
|
|
450
|
+
} : coordinates;
|
|
451
|
+
table_setCellSelection(table, (old) => mode === "replace" ? [nextRange] : [...old, nextRange]);
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Returns the visible leaf columns that permit selection, in display order.
|
|
455
|
+
*
|
|
456
|
+
* A column-level opt-out is enough to exclude a column here; a per-cell
|
|
457
|
+
* predicate is not consulted, since navigation and select-all work in column
|
|
458
|
+
* space rather than cell space.
|
|
459
|
+
*/
|
|
460
|
+
function getSelectableColumns(table) {
|
|
461
|
+
const columns = getDisplayOrderedColumns(table);
|
|
462
|
+
if (table.options.enableCellSelection === false) return [];
|
|
463
|
+
return columns.filter((column) => column.columnDef.enableCellSelection !== false);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Selects every selectable cell in the table as one range.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* table_selectAllCells(table)
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
function table_selectAllCells(table) {
|
|
474
|
+
const rows = table.getRowsInDisplayOrder();
|
|
475
|
+
const columns = getSelectableColumns(table);
|
|
476
|
+
if (!rows.length || !columns.length) return;
|
|
477
|
+
table_selectCellRange(table, {
|
|
478
|
+
anchorRowId: rows[0].id,
|
|
479
|
+
anchorColumnId: columns[0].id,
|
|
480
|
+
focusRowId: rows[rows.length - 1].id,
|
|
481
|
+
focusColumnId: columns[columns.length - 1].id
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Resolves a direction into row and column deltas.
|
|
486
|
+
*/
|
|
487
|
+
function getDirectionDelta(direction) {
|
|
488
|
+
switch (direction) {
|
|
489
|
+
case "up": return {
|
|
490
|
+
rowDelta: -1,
|
|
491
|
+
columnDelta: 0
|
|
492
|
+
};
|
|
493
|
+
case "down": return {
|
|
494
|
+
rowDelta: 1,
|
|
495
|
+
columnDelta: 0
|
|
496
|
+
};
|
|
497
|
+
case "left": return {
|
|
498
|
+
rowDelta: 0,
|
|
499
|
+
columnDelta: -1
|
|
500
|
+
};
|
|
501
|
+
default: return {
|
|
502
|
+
rowDelta: 0,
|
|
503
|
+
columnDelta: 1
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Steps one cell in a direction from a starting coordinate.
|
|
509
|
+
*
|
|
510
|
+
* Columns that cannot be selected are skipped over rather than landed on, so
|
|
511
|
+
* arrow navigation never parks on an opted-out column. Returns `null` when the
|
|
512
|
+
* step would leave the grid or find no selectable column.
|
|
513
|
+
*/
|
|
514
|
+
function stepCoordinate(table, rowId, columnId, direction) {
|
|
515
|
+
const rows = table.getRowsInDisplayOrder();
|
|
516
|
+
const columns = getDisplayOrderedColumns(table);
|
|
517
|
+
if (!rows.length || !columns.length) return null;
|
|
518
|
+
const { rowDelta, columnDelta } = getDirectionDelta(direction);
|
|
519
|
+
const rowIndex = resolveRowIndex(table, rows, rowId);
|
|
520
|
+
const columnIndex = columns.findIndex((column) => column.id === columnId);
|
|
521
|
+
if (rowIndex < 0 || columnIndex < 0) return null;
|
|
522
|
+
const merges = callMemoOrStaticFn(table, "getCellSelectionMergeBounds", table_getCellSelectionMergeBounds);
|
|
523
|
+
let fromRowIndex = rowIndex;
|
|
524
|
+
let fromColumnIndex = columnIndex;
|
|
525
|
+
if (merges.length) {
|
|
526
|
+
const startMerge = findMergeBoundsAt(merges, rowIndex, columnIndex);
|
|
527
|
+
if (startMerge) {
|
|
528
|
+
if (rowDelta > 0) fromRowIndex = startMerge.maxRowIndex;
|
|
529
|
+
if (rowDelta < 0) fromRowIndex = startMerge.minRowIndex;
|
|
530
|
+
if (columnDelta > 0) fromColumnIndex = startMerge.maxColumnIndex;
|
|
531
|
+
if (columnDelta < 0) fromColumnIndex = startMerge.minColumnIndex;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
const nextRowIndex = fromRowIndex + rowDelta;
|
|
535
|
+
if (nextRowIndex < 0 || nextRowIndex >= rows.length) return null;
|
|
536
|
+
const selectableColumnIds = new Set(getSelectableColumns(table).map((column) => column.id));
|
|
537
|
+
if (!selectableColumnIds.size) return null;
|
|
538
|
+
let nextColumnIndex = fromColumnIndex;
|
|
539
|
+
if (columnDelta) do
|
|
540
|
+
nextColumnIndex += columnDelta;
|
|
541
|
+
while (nextColumnIndex >= 0 && nextColumnIndex < columns.length && !selectableColumnIds.has(columns[nextColumnIndex].id));
|
|
542
|
+
else if (!selectableColumnIds.has(columnId)) for (let distance = 1; distance < columns.length; distance++) {
|
|
543
|
+
const before = columns[columnIndex - distance];
|
|
544
|
+
const after = columns[columnIndex + distance];
|
|
545
|
+
if (before && selectableColumnIds.has(before.id)) {
|
|
546
|
+
nextColumnIndex = columnIndex - distance;
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
if (after && selectableColumnIds.has(after.id)) {
|
|
550
|
+
nextColumnIndex = columnIndex + distance;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
if (nextColumnIndex < 0 || nextColumnIndex >= columns.length || !selectableColumnIds.has(columns[nextColumnIndex].id)) return null;
|
|
555
|
+
let landingRowIndex = nextRowIndex;
|
|
556
|
+
let landingColumnIndex = nextColumnIndex;
|
|
557
|
+
if (merges.length) {
|
|
558
|
+
const landingMerge = findMergeBoundsAt(merges, nextRowIndex, nextColumnIndex);
|
|
559
|
+
if (landingMerge) {
|
|
560
|
+
landingRowIndex = landingMerge.minRowIndex;
|
|
561
|
+
landingColumnIndex = landingMerge.minColumnIndex;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const landingRow = rows[landingRowIndex];
|
|
565
|
+
const landingColumn = columns[landingColumnIndex];
|
|
566
|
+
if (!landingRow || !landingColumn) return null;
|
|
567
|
+
return {
|
|
568
|
+
rowId: landingRow.id,
|
|
569
|
+
columnId: landingColumn.id
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Moves the selection one step in a direction, collapsing it to a single cell.
|
|
574
|
+
*
|
|
575
|
+
* With nothing selected, this selects the first selectable cell so keyboard
|
|
576
|
+
* navigation has somewhere to start.
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```ts
|
|
580
|
+
* table_moveCellSelection(table, 'down')
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
function table_moveCellSelection(table, direction) {
|
|
584
|
+
const ranges = table.atoms.cellSelection?.get();
|
|
585
|
+
const active = ranges?.[ranges.length - 1];
|
|
586
|
+
if (!active) {
|
|
587
|
+
const rows = table.getRowsInDisplayOrder();
|
|
588
|
+
const columns = getSelectableColumns(table);
|
|
589
|
+
if (!rows.length || !columns.length) return;
|
|
590
|
+
table_setFocusedCell(table, rows[0].id, columns[0].id);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const next = stepCoordinate(table, active.anchorRowId, active.anchorColumnId, direction);
|
|
594
|
+
if (!next) return;
|
|
595
|
+
table_setFocusedCell(table, next.rowId, next.columnId);
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Extends the active range one step in a direction, keeping its anchor fixed.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* table_extendCellSelection(table, 'right')
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
function table_extendCellSelection(table, direction) {
|
|
606
|
+
const ranges = table.atoms.cellSelection?.get();
|
|
607
|
+
const active = ranges?.[ranges.length - 1];
|
|
608
|
+
if (!active) {
|
|
609
|
+
table_moveCellSelection(table, direction);
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
const next = stepCoordinate(table, active.focusRowId, active.focusColumnId, direction);
|
|
613
|
+
if (!next) return;
|
|
614
|
+
table_setCellSelection(table, (old) => {
|
|
615
|
+
if (!old.length) return old;
|
|
616
|
+
const nextRanges = old.slice(0, -1);
|
|
617
|
+
nextRanges.push({
|
|
618
|
+
...old[old.length - 1],
|
|
619
|
+
focusRowId: next.rowId,
|
|
620
|
+
focusColumnId: next.columnId
|
|
621
|
+
});
|
|
622
|
+
return nextRanges;
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Walks each final positive region, invoking a visitor per selectable cell.
|
|
627
|
+
*
|
|
628
|
+
* Every expansion API shares this so the per-cell enable predicate is applied
|
|
629
|
+
* in exactly one place.
|
|
630
|
+
*/
|
|
631
|
+
function forEachSelectedCell(table, visit, skipCovered = false) {
|
|
632
|
+
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
633
|
+
if (!bounds.length) return;
|
|
634
|
+
const rows = table.getRowsInDisplayOrder();
|
|
635
|
+
const columns = getDisplayOrderedColumns(table);
|
|
636
|
+
for (let i = 0; i < bounds.length; i++) {
|
|
637
|
+
const bound = bounds[i];
|
|
638
|
+
for (let rowIndex = bound.minRowIndex; rowIndex <= bound.maxRowIndex; rowIndex++) {
|
|
639
|
+
const row = rows[rowIndex];
|
|
640
|
+
if (!row) continue;
|
|
641
|
+
const cellsByColumnId = row.getAllCellsByColumnId();
|
|
642
|
+
for (let columnIndex = bound.minColumnIndex; columnIndex <= bound.maxColumnIndex; columnIndex++) {
|
|
643
|
+
const column = columns[columnIndex];
|
|
644
|
+
if (!column) continue;
|
|
645
|
+
const cell = cellsByColumnId[column.id];
|
|
646
|
+
if (!cell) continue;
|
|
647
|
+
if (!callMemoOrStaticFn(cell, "getCanSelect", cell_getCanSelect)) continue;
|
|
648
|
+
if (skipCovered && cell.getIsCovered?.()) continue;
|
|
649
|
+
visit(cell, i, rowIndex - bound.minRowIndex, columnIndex - bound.minColumnIndex);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Returns the ids of all selected cells, in row-major order.
|
|
656
|
+
*
|
|
657
|
+
* Cells covered by overlapping ranges are returned once, at their first
|
|
658
|
+
* occurrence.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```ts
|
|
662
|
+
* const ids = table_getSelectedCellIds(table)
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
665
|
+
function table_getSelectedCellIds(table) {
|
|
666
|
+
const ids = [];
|
|
667
|
+
const seen = /* @__PURE__ */ new Set();
|
|
668
|
+
forEachSelectedCell(table, (cell) => {
|
|
669
|
+
if (seen.has(cell.id)) return;
|
|
670
|
+
seen.add(cell.id);
|
|
671
|
+
ids.push(cell.id);
|
|
672
|
+
}, true);
|
|
673
|
+
return ids;
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Returns each final positive region's values as a row-major grid.
|
|
677
|
+
*
|
|
678
|
+
* This is the raw material for clipboard export. Serializing it to text is left
|
|
679
|
+
* to userland, since the delimiter, the null representation, and whether values
|
|
680
|
+
* containing delimiters get quoted are all application decisions.
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```ts
|
|
684
|
+
* const [firstRange] = table_getSelectedCellRangesData(table)
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
687
|
+
function table_getSelectedCellRangesData(table) {
|
|
688
|
+
const grids = [];
|
|
689
|
+
forEachSelectedCell(table, (cell, rangeIndex, rowOffset) => {
|
|
690
|
+
const grid = grids[rangeIndex] ??= [];
|
|
691
|
+
(grid[rowOffset] ??= []).push(cell.getValue());
|
|
692
|
+
});
|
|
693
|
+
return grids;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Returns the number of selected cells.
|
|
697
|
+
*
|
|
698
|
+
* Uses rectangle arithmetic over the normalized, disjoint positive regions.
|
|
699
|
+
* A per-cell `enableCellSelection` predicate requires enumeration.
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```ts
|
|
703
|
+
* const count = table_getSelectedCellCount(table)
|
|
704
|
+
* ```
|
|
705
|
+
*/
|
|
706
|
+
function table_getSelectedCellCount(table) {
|
|
707
|
+
if (table.options.enableCellSelection === false) return 0;
|
|
708
|
+
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
709
|
+
if (!bounds.length) return 0;
|
|
710
|
+
const merges = callMemoOrStaticFn(table, "getCellSelectionMergeBounds", table_getCellSelectionMergeBounds);
|
|
711
|
+
if (typeof table.options.enableCellSelection === "function" || merges.length) {
|
|
712
|
+
const ids = /* @__PURE__ */ new Set();
|
|
713
|
+
forEachSelectedCell(table, (cell) => ids.add(cell.id), true);
|
|
714
|
+
return ids.size;
|
|
715
|
+
}
|
|
716
|
+
const columns = getDisplayOrderedColumns(table);
|
|
717
|
+
let count = 0;
|
|
718
|
+
for (const bound of bounds) {
|
|
719
|
+
let selectableColumns = 0;
|
|
720
|
+
for (let columnIndex = bound.minColumnIndex; columnIndex <= bound.maxColumnIndex; columnIndex++) {
|
|
721
|
+
const column = columns[columnIndex];
|
|
722
|
+
if (!column) continue;
|
|
723
|
+
if (column.columnDef.enableCellSelection !== false) selectableColumns++;
|
|
724
|
+
}
|
|
725
|
+
count += (bound.maxRowIndex - bound.minRowIndex + 1) * selectableColumns;
|
|
726
|
+
}
|
|
727
|
+
return count;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Returns the ids of all rows intersected by the selection.
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```ts
|
|
734
|
+
* const rowIds = table_getCellSelectionRowIds(table)
|
|
735
|
+
* ```
|
|
736
|
+
*/
|
|
737
|
+
function table_getCellSelectionRowIds(table) {
|
|
738
|
+
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
739
|
+
if (!bounds.length) return [];
|
|
740
|
+
const rows = table.getRowsInDisplayOrder();
|
|
741
|
+
const seen = /* @__PURE__ */ new Set();
|
|
742
|
+
const ids = [];
|
|
743
|
+
for (let i = 0; i < bounds.length; i++) {
|
|
744
|
+
const bound = bounds[i];
|
|
745
|
+
for (let index = bound.minRowIndex; index <= bound.maxRowIndex; index++) {
|
|
746
|
+
const row = rows[index];
|
|
747
|
+
if (!row || seen.has(row.id)) continue;
|
|
748
|
+
seen.add(row.id);
|
|
749
|
+
ids.push(row.id);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return ids;
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Returns the ids of all columns intersected by the selection.
|
|
756
|
+
*
|
|
757
|
+
* @example
|
|
758
|
+
* ```ts
|
|
759
|
+
* const columnIds = table_getCellSelectionColumnIds(table)
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
function table_getCellSelectionColumnIds(table) {
|
|
763
|
+
const bounds = callMemoOrStaticFn(table, "getCellSelectionBounds", table_getCellSelectionBounds);
|
|
764
|
+
if (!bounds.length) return [];
|
|
765
|
+
const columns = getDisplayOrderedColumns(table);
|
|
766
|
+
const seen = /* @__PURE__ */ new Set();
|
|
767
|
+
const ids = [];
|
|
768
|
+
for (let i = 0; i < bounds.length; i++) {
|
|
769
|
+
const bound = bounds[i];
|
|
770
|
+
for (let index = bound.minColumnIndex; index <= bound.maxColumnIndex; index++) {
|
|
771
|
+
const column = columns[index];
|
|
772
|
+
if (!column || seen.has(column.id)) continue;
|
|
773
|
+
if (column.columnDef.enableCellSelection === false) continue;
|
|
774
|
+
seen.add(column.id);
|
|
775
|
+
ids.push(column.id);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return ids;
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Creates a handler that begins a selection at this cell.
|
|
782
|
+
*
|
|
783
|
+
* Follows `header_getResizeHandler`: the enable check is resolved once outside
|
|
784
|
+
* the returned closure and guarded again inside it, the document is injectable
|
|
785
|
+
* for SSR and cross-document rendering, and the document-level `mouseup`
|
|
786
|
+
* listener is attached here so a drag released outside the table still ends.
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```tsx
|
|
790
|
+
* <td onMouseDown={cell.getSelectionStartHandler()} />
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
793
|
+
function cell_getSelectionStartHandler(cell, _contextDocument) {
|
|
794
|
+
const canSelect = cell_getCanSelect(cell);
|
|
795
|
+
return (e) => {
|
|
796
|
+
if (!canSelect) return;
|
|
797
|
+
const table = cell.table;
|
|
798
|
+
const options = table.options;
|
|
799
|
+
const contextDocument = _contextDocument ?? (typeof document !== "undefined" ? document : null);
|
|
800
|
+
const isRangeEvent = options.enableCellRangeSelection !== false && (options.isCellRangeSelectionEvent?.(e) ?? false);
|
|
801
|
+
const isMultiRangeEvent = options.enableMultiCellRangeSelection !== false && (options.isMultiCellRangeSelectionEvent?.(e) ?? false);
|
|
802
|
+
if (options.enableCellSelectionDrag !== false && options.enableCellRangeSelection !== false && contextDocument) {
|
|
803
|
+
table._isSelectingCells = true;
|
|
804
|
+
const upHandler = () => {
|
|
805
|
+
contextDocument.removeEventListener("mouseup", upHandler);
|
|
806
|
+
table._isSelectingCells = false;
|
|
807
|
+
};
|
|
808
|
+
contextDocument.addEventListener("mouseup", upHandler);
|
|
809
|
+
}
|
|
810
|
+
const rowId = cell.row.id;
|
|
811
|
+
const columnId = cell.column.id;
|
|
812
|
+
const shouldExclude = isMultiRangeEvent && callMemoOrStaticFn(cell, "getIsSelected", cell_getIsSelected);
|
|
813
|
+
table_setCellSelection(table, (old) => {
|
|
814
|
+
const active = old[old.length - 1];
|
|
815
|
+
if (isRangeEvent && active) {
|
|
816
|
+
const ranges = old.slice(0, -1);
|
|
817
|
+
ranges.push({
|
|
818
|
+
...active,
|
|
819
|
+
focusRowId: rowId,
|
|
820
|
+
focusColumnId: columnId
|
|
821
|
+
});
|
|
822
|
+
return ranges;
|
|
823
|
+
}
|
|
824
|
+
const range = {
|
|
825
|
+
anchorRowId: rowId,
|
|
826
|
+
anchorColumnId: columnId,
|
|
827
|
+
focusRowId: rowId,
|
|
828
|
+
focusColumnId: columnId,
|
|
829
|
+
...shouldExclude ? { operation: "exclude" } : {}
|
|
830
|
+
};
|
|
831
|
+
return isMultiRangeEvent ? [...old, range] : [range];
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Creates a handler that extends the active range to this cell during a drag.
|
|
837
|
+
*
|
|
838
|
+
* No rAF coalescing is needed here, unlike the resize handler: `mouseenter`
|
|
839
|
+
* fires once per cell boundary crossed rather than continuously, and deferring
|
|
840
|
+
* it by a frame would only delay the highlight.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```tsx
|
|
844
|
+
* <td onMouseEnter={cell.getSelectionExtendHandler()} />
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
function cell_getSelectionExtendHandler(cell) {
|
|
848
|
+
const canSelect = cell_getCanSelect(cell);
|
|
849
|
+
return (_e) => {
|
|
850
|
+
if (!canSelect) return;
|
|
851
|
+
const table = cell.table;
|
|
852
|
+
if (!table._isSelectingCells) return;
|
|
853
|
+
const ranges = table.atoms.cellSelection?.get();
|
|
854
|
+
const active = ranges?.[ranges.length - 1];
|
|
855
|
+
if (!active) return;
|
|
856
|
+
const rowId = cell.row.id;
|
|
857
|
+
const columnId = cell.column.id;
|
|
858
|
+
if (active.focusRowId === rowId && active.focusColumnId === columnId) return;
|
|
859
|
+
table_setCellSelection(table, (old) => {
|
|
860
|
+
if (!old.length) return old;
|
|
861
|
+
const next = old.slice(0, -1);
|
|
862
|
+
next.push({
|
|
863
|
+
...old[old.length - 1],
|
|
864
|
+
focusRowId: rowId,
|
|
865
|
+
focusColumnId: columnId
|
|
866
|
+
});
|
|
867
|
+
return next;
|
|
868
|
+
});
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
//#endregion
|
|
873
|
+
export { cell_getCanSelect, cell_getIsFocused, cell_getIsSelected, cell_getSelectionEdges, cell_getSelectionExtendHandler, cell_getSelectionStartHandler, cell_getTabIndex, getDefaultCellSelectionState, table_autoResetCellSelection, table_extendCellSelection, table_getCellSelectionBounds, table_getCellSelectionColumnIds, table_getCellSelectionColumnIndexes, table_getCellSelectionMergeBounds, table_getCellSelectionRowIds, table_getFocusedCell, table_getSelectedCellCount, table_getSelectedCellIds, table_getSelectedCellRangesData, table_moveCellSelection, table_resetCellSelection, table_selectAllCells, table_selectCellRange, table_setCellSelection, table_setFocusedCell };
|