@tanstack/table-core 9.0.0-beta.5 → 9.0.0-beta.51
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 +2 -0
- package/dist/core/cells/constructCell.cjs +1 -4
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.d.cts +4 -4
- package/dist/core/cells/constructCell.d.ts +4 -4
- package/dist/core/cells/constructCell.js +1 -4
- package/dist/core/cells/constructCell.js.map +1 -1
- package/dist/core/cells/coreCellsFeature.types.d.cts +7 -7
- package/dist/core/cells/coreCellsFeature.types.d.ts +7 -7
- package/dist/core/cells/coreCellsFeature.utils.d.cts +4 -4
- package/dist/core/cells/coreCellsFeature.utils.d.ts +4 -4
- package/dist/core/columns/constructColumn.cjs +4 -5
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.d.cts +3 -3
- package/dist/core/columns/constructColumn.d.ts +3 -3
- package/dist/core/columns/constructColumn.js +4 -5
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.cjs +12 -18
- package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.js +12 -18
- package/dist/core/columns/coreColumnsFeature.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -7
- package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -7
- package/dist/core/columns/coreColumnsFeature.utils.cjs +4 -8
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +9 -9
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +9 -9
- package/dist/core/columns/coreColumnsFeature.utils.js +5 -9
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/coreFeatures.cjs.map +1 -1
- package/dist/core/coreFeatures.d.cts +1 -1
- package/dist/core/coreFeatures.d.ts +1 -1
- package/dist/core/coreFeatures.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs +1 -2
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +2 -2
- package/dist/core/headers/buildHeaderGroups.d.ts +2 -2
- package/dist/core/headers/buildHeaderGroups.js +1 -2
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/constructHeader.cjs +1 -4
- package/dist/core/headers/constructHeader.cjs.map +1 -1
- package/dist/core/headers/constructHeader.d.cts +2 -2
- package/dist/core/headers/constructHeader.d.ts +2 -2
- package/dist/core/headers/constructHeader.js +1 -4
- package/dist/core/headers/constructHeader.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +8 -11
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +8 -11
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -6
- package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.cjs +8 -10
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +6 -6
- package/dist/core/headers/coreHeadersFeature.utils.js +8 -10
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +7 -15
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +7 -15
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +8 -26
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +16 -16
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +16 -16
- package/dist/core/row-models/coreRowModelsFeature.utils.js +8 -26
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs +4 -6
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
- package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
- package/dist/core/row-models/createCoreRowModel.js +5 -7
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +6 -10
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.d.cts +2 -2
- package/dist/core/rows/constructRow.d.ts +2 -2
- package/dist/core/rows/constructRow.js +7 -10
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.cjs +18 -2
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.js +19 -3
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +41 -7
- package/dist/core/rows/coreRowsFeature.types.d.ts +41 -7
- package/dist/core/rows/coreRowsFeature.utils.cjs +62 -8
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +24 -5
- package/dist/core/rows/coreRowsFeature.utils.d.ts +24 -5
- package/dist/core/rows/coreRowsFeature.utils.js +61 -10
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +24 -14
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.d.cts +1 -1
- package/dist/core/table/constructTable.d.ts +1 -1
- package/dist/core/table/constructTable.js +24 -14
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +32 -19
- package/dist/core/table/coreTablesFeature.types.d.ts +32 -19
- package/dist/core/table/coreTablesFeature.utils.cjs +38 -14
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +10 -7
- package/dist/core/table/coreTablesFeature.utils.d.ts +10 -7
- package/dist/core/table/coreTablesFeature.utils.js +38 -14
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/experimental-worker-plugin.cjs +14 -0
- package/dist/experimental-worker-plugin.d.cts +5 -0
- package/dist/experimental-worker-plugin.d.ts +5 -0
- package/dist/experimental-worker-plugin.js +6 -0
- package/dist/features/column-faceting/columnFacetingFeature.cjs +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.js +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +15 -33
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +15 -33
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +23 -12
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +9 -9
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +9 -9
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +24 -12
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +7 -4
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
- package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +10 -15
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.cts +2 -2
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +2 -2
- package/dist/features/column-faceting/createFacetedRowModel.js +10 -15
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs +10 -6
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.js +11 -7
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.cjs +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.js +3 -3
- package/dist/features/column-filtering/columnFilteringFeature.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +83 -29
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +83 -29
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +23 -17
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +18 -14
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +18 -14
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +23 -17
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +29 -25
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +10 -4
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +10 -4
- package/dist/features/column-filtering/createFilteredRowModel.js +30 -26
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-filtering/filterFns.cjs +399 -0
- package/dist/features/column-filtering/filterFns.cjs.map +1 -0
- package/dist/features/column-filtering/filterFns.d.cts +210 -0
- package/dist/features/column-filtering/filterFns.d.ts +210 -0
- package/dist/features/column-filtering/filterFns.js +375 -0
- package/dist/features/column-filtering/filterFns.js.map +1 -0
- package/dist/features/column-filtering/filterRowsUtils.cjs +3 -2
- package/dist/features/column-filtering/filterRowsUtils.cjs.map +1 -1
- package/dist/features/column-filtering/filterRowsUtils.js +3 -2
- package/dist/features/column-filtering/filterRowsUtils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +4 -16
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.cts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.d.ts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +6 -18
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +14 -50
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +14 -50
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +6 -61
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +12 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +12 -49
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +8 -60
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +37 -24
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +6 -4
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +6 -4
- package/dist/features/column-grouping/createGroupedRowModel.js +39 -26
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +17 -21
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js +18 -22
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +28 -3
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +28 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +35 -15
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +26 -14
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +26 -14
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +36 -17
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +124 -143
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.js +125 -144
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +52 -41
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +52 -41
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +161 -162
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +101 -92
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +101 -92
- package/dist/features/column-pinning/columnPinningFeature.utils.js +148 -149
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +1 -4
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +1 -4
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +84 -44
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +6 -6
- package/dist/features/column-resizing/columnResizingFeature.utils.js +85 -45
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +33 -67
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +34 -68
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +52 -9
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +52 -9
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +88 -45
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +43 -25
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +43 -25
- package/dist/features/column-sizing/columnSizingFeature.utils.js +88 -46
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +25 -36
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +25 -36
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +30 -29
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +18 -18
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +18 -18
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +31 -30
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.cjs +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.js +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +6 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +8 -11
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +8 -11
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +6 -6
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-aggregation/aggregationFns.cjs +246 -0
- package/dist/features/row-aggregation/aggregationFns.cjs.map +1 -0
- package/dist/features/row-aggregation/aggregationFns.d.cts +68 -0
- package/dist/features/row-aggregation/aggregationFns.d.ts +68 -0
- package/dist/features/row-aggregation/aggregationFns.js +235 -0
- package/dist/features/row-aggregation/aggregationFns.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.cjs +39 -0
- package/dist/features/row-aggregation/rowAggregationFeature.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.d.cts +10 -0
- package/dist/features/row-aggregation/rowAggregationFeature.d.ts +10 -0
- package/dist/features/row-aggregation/rowAggregationFeature.js +39 -0
- package/dist/features/row-aggregation/rowAggregationFeature.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.cjs +13 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.cts +195 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.d.ts +195 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.js +12 -0
- package/dist/features/row-aggregation/rowAggregationFeature.types.js.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.cjs +212 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.cjs.map +1 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.cts +34 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.d.ts +34 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js +206 -0
- package/dist/features/row-aggregation/rowAggregationFeature.utils.js.map +1 -0
- package/dist/features/row-expanding/createExpandedRowModel.cjs +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.cts +2 -2
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +2 -2
- package/dist/features/row-expanding/createExpandedRowModel.js +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +6 -15
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +6 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +28 -26
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +10 -10
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +29 -27
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.cts +2 -2
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +2 -2
- package/dist/features/row-pagination/createPaginatedRowModel.js +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +5 -14
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +5 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +9 -15
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +17 -17
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +17 -17
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +9 -15
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.cjs +4 -16
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.js +4 -16
- package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +9 -14
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +7 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +7 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.js +9 -14
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +66 -22
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +67 -23
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +49 -11
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +49 -11
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +128 -72
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +57 -30
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +57 -30
- package/dist/features/row-selection/rowSelectionFeature.utils.js +129 -74
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +69 -50
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +10 -4
- package/dist/features/row-sorting/createSortedRowModel.d.ts +10 -4
- package/dist/features/row-sorting/createSortedRowModel.js +70 -51
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +54 -22
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +54 -22
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +31 -17
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +16 -16
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +16 -16
- package/dist/features/row-sorting/rowSortingFeature.utils.js +31 -17
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/sortFns.cjs +226 -0
- package/dist/features/row-sorting/sortFns.cjs.map +1 -0
- package/dist/features/row-sorting/sortFns.d.cts +98 -0
- package/dist/features/row-sorting/sortFns.d.ts +98 -0
- package/dist/features/row-sorting/sortFns.js +217 -0
- package/dist/features/row-sorting/sortFns.js.map +1 -0
- package/dist/features/stockFeatures.cjs +2 -0
- package/dist/features/stockFeatures.cjs.map +1 -1
- package/dist/features/stockFeatures.d.cts +2 -0
- package/dist/features/stockFeatures.d.ts +2 -0
- package/dist/features/stockFeatures.js +2 -0
- package/dist/features/stockFeatures.js.map +1 -1
- package/dist/flex-render.d.cts +1 -1
- package/dist/flex-render.d.ts +1 -1
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +2 -2
- package/dist/helpers/columnHelper.d.ts +2 -2
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/helpers/metaHelper.cjs +30 -0
- package/dist/helpers/metaHelper.cjs.map +1 -0
- package/dist/helpers/metaHelper.d.cts +26 -0
- package/dist/helpers/metaHelper.d.ts +26 -0
- package/dist/helpers/metaHelper.js +29 -0
- package/dist/helpers/metaHelper.js.map +1 -0
- package/dist/helpers/tableFeatures.cjs +32 -3
- package/dist/helpers/tableFeatures.cjs.map +1 -1
- package/dist/helpers/tableFeatures.d.cts +34 -5
- package/dist/helpers/tableFeatures.d.ts +34 -5
- package/dist/helpers/tableFeatures.js +32 -3
- package/dist/helpers/tableFeatures.js.map +1 -1
- package/dist/index.cjs +23 -3
- package/dist/index.d.cts +31 -28
- package/dist/index.d.ts +31 -28
- package/dist/index.js +8 -5
- package/dist/static-functions.cjs +30 -19
- package/dist/static-functions.d.cts +8 -7
- package/dist/static-functions.d.ts +8 -7
- package/dist/static-functions.js +8 -7
- package/dist/store-reactivity-bindings.cjs +3 -3
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.d.cts +1 -1
- package/dist/store-reactivity-bindings.d.ts +1 -1
- package/dist/store-reactivity-bindings.js +3 -3
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/types/Cell.d.cts +4 -2
- package/dist/types/Cell.d.ts +4 -2
- package/dist/types/Column.d.cts +15 -15
- package/dist/types/Column.d.ts +15 -15
- package/dist/types/ColumnDef.d.cts +30 -14
- package/dist/types/ColumnDef.d.ts +30 -14
- package/dist/types/Header.d.cts +2 -2
- package/dist/types/Header.d.ts +2 -2
- package/dist/types/HeaderGroup.d.cts +2 -2
- package/dist/types/HeaderGroup.d.ts +2 -2
- package/dist/types/Row.d.cts +6 -4
- package/dist/types/Row.d.ts +6 -4
- package/dist/types/RowModel.d.cts +11 -23
- package/dist/types/RowModel.d.ts +11 -23
- package/dist/types/RowModelFns.d.cts +4 -4
- package/dist/types/RowModelFns.d.ts +4 -4
- package/dist/types/Table.d.cts +26 -31
- package/dist/types/Table.d.ts +26 -31
- package/dist/types/TableFeatures.d.cts +350 -22
- package/dist/types/TableFeatures.d.ts +350 -22
- package/dist/types/TableOptions.d.cts +22 -14
- package/dist/types/TableOptions.d.ts +22 -14
- package/dist/types/TableState.d.cts +6 -6
- package/dist/types/TableState.d.ts +6 -6
- package/dist/types/type-utils.d.cts +8 -1
- package/dist/types/type-utils.d.ts +8 -1
- package/dist/utils.cjs +51 -29
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +30 -8
- package/dist/utils.d.ts +30 -8
- package/dist/utils.js +49 -30
- package/dist/utils.js.map +1 -1
- package/dist/worker/createTableWorker.cjs +189 -0
- package/dist/worker/createTableWorker.cjs.map +1 -0
- package/dist/worker/createTableWorker.d.cts +102 -0
- package/dist/worker/createTableWorker.d.ts +102 -0
- package/dist/worker/createTableWorker.js +186 -0
- package/dist/worker/createTableWorker.js.map +1 -0
- package/dist/worker/createWorkerRowModel.cjs +78 -0
- package/dist/worker/createWorkerRowModel.cjs.map +1 -0
- package/dist/worker/createWorkerRowModel.d.cts +42 -0
- package/dist/worker/createWorkerRowModel.d.ts +42 -0
- package/dist/worker/createWorkerRowModel.js +78 -0
- package/dist/worker/createWorkerRowModel.js.map +1 -0
- package/dist/worker/initTableWorker.cjs +100 -0
- package/dist/worker/initTableWorker.cjs.map +1 -0
- package/dist/worker/initTableWorker.d.cts +33 -0
- package/dist/worker/initTableWorker.d.ts +33 -0
- package/dist/worker/initTableWorker.js +100 -0
- package/dist/worker/initTableWorker.js.map +1 -0
- package/dist/worker/rebuildRowModel.cjs +72 -0
- package/dist/worker/rebuildRowModel.cjs.map +1 -0
- package/dist/worker/rebuildRowModel.d.cts +9 -0
- package/dist/worker/rebuildRowModel.d.ts +9 -0
- package/dist/worker/rebuildRowModel.js +72 -0
- package/dist/worker/rebuildRowModel.js.map +1 -0
- package/dist/worker/serializeRowModel.cjs +53 -0
- package/dist/worker/serializeRowModel.cjs.map +1 -0
- package/dist/worker/serializeRowModel.js +52 -0
- package/dist/worker/serializeRowModel.js.map +1 -0
- package/dist/worker/tableWorkerProtocol.cjs +29 -0
- package/dist/worker/tableWorkerProtocol.cjs.map +1 -0
- package/dist/worker/tableWorkerProtocol.d.cts +88 -0
- package/dist/worker/tableWorkerProtocol.d.ts +88 -0
- package/dist/worker/tableWorkerProtocol.js +27 -0
- package/dist/worker/tableWorkerProtocol.js.map +1 -0
- package/package.json +8 -3
- package/skills/aggregation/SKILL.md +141 -0
- package/skills/api-not-found/SKILL.md +113 -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 +274 -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/src/core/cells/coreCellsFeature.types.ts +6 -6
- package/src/core/columns/constructColumn.ts +6 -0
- package/src/core/columns/coreColumnsFeature.types.ts +8 -8
- package/src/core/columns/coreColumnsFeature.utils.ts +4 -4
- package/src/core/coreFeatures.ts +1 -1
- package/src/core/headers/buildHeaderGroups.ts +4 -2
- package/src/core/headers/coreHeadersFeature.types.ts +12 -12
- package/src/core/headers/coreHeadersFeature.utils.ts +7 -8
- package/src/core/row-models/coreRowModelsFeature.types.ts +6 -20
- package/src/core/row-models/coreRowModelsFeature.utils.ts +8 -8
- package/src/core/row-models/createCoreRowModel.ts +7 -6
- package/src/core/rows/constructRow.ts +4 -2
- package/src/core/rows/coreRowsFeature.ts +21 -0
- package/src/core/rows/coreRowsFeature.types.ts +45 -8
- package/src/core/rows/coreRowsFeature.utils.ts +93 -5
- package/src/core/table/constructTable.ts +44 -6
- package/src/core/table/coreTablesFeature.types.ts +45 -20
- package/src/core/table/coreTablesFeature.utils.ts +59 -19
- package/src/experimental-worker-plugin.ts +22 -0
- package/src/features/column-faceting/columnFacetingFeature.types.ts +17 -48
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +53 -18
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +33 -7
- package/src/features/column-faceting/createFacetedRowModel.ts +8 -1
- package/src/features/column-faceting/createFacetedUniqueValues.ts +41 -10
- package/src/features/column-filtering/columnFilteringFeature.ts +3 -2
- package/src/features/column-filtering/columnFilteringFeature.types.ts +117 -41
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +37 -23
- package/src/features/column-filtering/createFilteredRowModel.ts +28 -17
- package/src/features/column-filtering/filterFns.ts +533 -0
- package/src/features/column-filtering/filterRowsUtils.ts +3 -2
- package/src/features/column-grouping/columnGroupingFeature.ts +3 -21
- package/src/features/column-grouping/columnGroupingFeature.types.ts +21 -95
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +4 -87
- package/src/features/column-grouping/createGroupedRowModel.ts +46 -45
- package/src/features/column-ordering/columnOrderingFeature.ts +12 -7
- package/src/features/column-ordering/columnOrderingFeature.types.ts +29 -3
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +59 -8
- package/src/features/column-pinning/columnPinningFeature.ts +76 -59
- package/src/features/column-pinning/columnPinningFeature.types.ts +53 -42
- package/src/features/column-pinning/columnPinningFeature.utils.ts +184 -170
- package/src/features/column-resizing/columnResizingFeature.types.ts +1 -4
- package/src/features/column-resizing/columnResizingFeature.utils.ts +120 -52
- package/src/features/column-sizing/columnSizingFeature.ts +24 -24
- package/src/features/column-sizing/columnSizingFeature.types.ts +53 -8
- package/src/features/column-sizing/columnSizingFeature.utils.ts +143 -62
- package/src/features/column-visibility/columnVisibilityFeature.ts +4 -0
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +4 -4
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +48 -30
- package/src/features/global-filtering/globalFilteringFeature.types.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +13 -5
- package/src/features/row-aggregation/aggregationFns.ts +345 -0
- package/src/features/row-aggregation/rowAggregationFeature.ts +60 -0
- package/src/features/row-aggregation/rowAggregationFeature.types.ts +339 -0
- package/src/features/row-aggregation/rowAggregationFeature.utils.ts +430 -0
- package/src/features/row-expanding/rowExpandingFeature.types.ts +8 -23
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +38 -13
- package/src/features/row-pagination/createPaginatedRowModel.ts +1 -1
- package/src/features/row-pagination/rowPaginationFeature.types.ts +6 -21
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +1 -1
- package/src/features/row-pinning/rowPinningFeature.types.ts +4 -4
- package/src/features/row-selection/rowSelectionFeature.ts +53 -3
- package/src/features/row-selection/rowSelectionFeature.types.ts +54 -10
- package/src/features/row-selection/rowSelectionFeature.utils.ts +273 -91
- package/src/features/row-sorting/createSortedRowModel.ts +107 -75
- package/src/features/row-sorting/rowSortingFeature.types.ts +87 -34
- package/src/features/row-sorting/rowSortingFeature.utils.ts +49 -23
- package/src/features/row-sorting/sortFns.ts +366 -0
- package/src/features/stockFeatures.ts +3 -0
- package/src/helpers/columnHelper.ts +4 -4
- package/src/helpers/metaHelper.ts +24 -0
- package/src/helpers/tableFeatures.ts +37 -5
- package/src/index.ts +8 -8
- package/src/static-functions.ts +1 -0
- package/src/store-reactivity-bindings.ts +1 -1
- package/src/types/Cell.ts +4 -2
- package/src/types/Column.ts +13 -9
- package/src/types/ColumnDef.ts +40 -10
- package/src/types/Header.ts +2 -2
- package/src/types/HeaderGroup.ts +6 -6
- package/src/types/Row.ts +6 -4
- package/src/types/RowModel.ts +19 -74
- package/src/types/RowModelFns.ts +10 -10
- package/src/types/Table.ts +52 -27
- package/src/types/TableFeatures.ts +392 -14
- package/src/types/TableOptions.ts +67 -14
- package/src/types/TableState.ts +15 -1
- package/src/types/type-utils.ts +8 -0
- package/src/utils.ts +60 -8
- package/src/worker/createTableWorker.ts +357 -0
- package/src/worker/createWorkerRowModel.ts +121 -0
- package/src/worker/initTableWorker.ts +164 -0
- package/src/worker/rebuildRowModel.ts +120 -0
- package/src/worker/serializeRowModel.ts +80 -0
- package/src/worker/tableWorkerProtocol.ts +105 -0
- 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 -118
- 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 -110
- package/dist/fns/sortFns.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/fns/aggregationFns.ts +0 -245
- package/src/fns/filterFns.ts +0 -382
- package/src/fns/sortFns.ts +0 -217
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { constructTable } from '../core/table/constructTable'
|
|
2
|
+
import { storeReactivityBindings } from '../store-reactivity-bindings'
|
|
3
|
+
import { makeObjectMap } from '../utils'
|
|
4
|
+
import { serializeRowModel } from './serializeRowModel'
|
|
5
|
+
import type { RowData } from '../types/type-utils'
|
|
6
|
+
import type { TableFeatures } from '../types/TableFeatures'
|
|
7
|
+
import type { TableOptions } from '../types/TableOptions'
|
|
8
|
+
import type { Table_Internal } from '../types/Table'
|
|
9
|
+
import type {
|
|
10
|
+
TableWorkerRequest,
|
|
11
|
+
TableWorkerResult,
|
|
12
|
+
TableWorkerStage,
|
|
13
|
+
TableWorkerStagePayload,
|
|
14
|
+
} from './tableWorkerProtocol'
|
|
15
|
+
|
|
16
|
+
export type TableWorkerConfig<
|
|
17
|
+
TFeatures extends TableFeatures,
|
|
18
|
+
TData extends RowData,
|
|
19
|
+
> = Omit<TableOptions<TFeatures, TData>, 'data'>
|
|
20
|
+
|
|
21
|
+
function capitalize(stage: string) {
|
|
22
|
+
return stage.charAt(0).toUpperCase() + stage.slice(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Flatten column-group defs to leaf defs (mirrors core's id resolution). */
|
|
26
|
+
function flattenColumnDefs(defs: Array<any>): Array<any> {
|
|
27
|
+
return defs.flatMap((def) =>
|
|
28
|
+
def.columns ? flattenColumnDefs(def.columns) : [def],
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Runs a headless "shadow table" inside a dedicated Web Worker.
|
|
34
|
+
*
|
|
35
|
+
* Call this from a user-authored worker entry file, passing the same columns
|
|
36
|
+
* and processing features used on the main thread. The shadow table runs the
|
|
37
|
+
* real table-core row model pipeline (real fns, real Row objects) off the
|
|
38
|
+
* main thread and posts back one payload per stage the main thread requested:
|
|
39
|
+
* a transferable index permutation for flat results, a serialized row tree
|
|
40
|
+
* (with eagerly computed aggregates) when grouping produces synthetic rows.
|
|
41
|
+
*
|
|
42
|
+
* Everything passed here must be thread-portable: `accessorKey` columns or
|
|
43
|
+
* accessors defined in a shared module, and fns from registries or shared
|
|
44
|
+
* modules (no closures over app state).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* // table.worker.ts
|
|
49
|
+
* import { initTableWorker } from '@tanstack/table-core/experimental-worker-plugin'
|
|
50
|
+
* import { columns, sharedFeatures } from './tableConfig'
|
|
51
|
+
*
|
|
52
|
+
* initTableWorker({ features: sharedFeatures, columns })
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function initTableWorker<
|
|
56
|
+
TFeatures extends TableFeatures,
|
|
57
|
+
TData extends RowData,
|
|
58
|
+
>(config: TableWorkerConfig<TFeatures, TData>): void {
|
|
59
|
+
let table: Table_Internal<TFeatures, TData> | undefined
|
|
60
|
+
let dataVersion = 0
|
|
61
|
+
let coreIndexById: Record<string, number> = makeObjectMap()
|
|
62
|
+
let aggregateColumnIds: Array<string> = []
|
|
63
|
+
// Last-sent model identity per stage: the memoized getters return stable
|
|
64
|
+
// objects when their inputs did not change, so identity equality is exactly
|
|
65
|
+
// "this stage's result is unchanged".
|
|
66
|
+
let lastSentModels: { [K in TableWorkerStage]?: unknown } = {}
|
|
67
|
+
|
|
68
|
+
self.onmessage = (event: MessageEvent<TableWorkerRequest<TData>>) => {
|
|
69
|
+
const message = event.data
|
|
70
|
+
|
|
71
|
+
if (message.type === 'data') {
|
|
72
|
+
dataVersion = message.dataVersion
|
|
73
|
+
lastSentModels = {}
|
|
74
|
+
if (!table) {
|
|
75
|
+
table = constructTable<TFeatures, TData>({
|
|
76
|
+
...(config as TableOptions<TFeatures, TData>),
|
|
77
|
+
features: {
|
|
78
|
+
coreReactivityFeature: storeReactivityBindings(),
|
|
79
|
+
...config.features,
|
|
80
|
+
},
|
|
81
|
+
data: message.data,
|
|
82
|
+
})
|
|
83
|
+
// Only columns with an explicit aggregation get eagerly aggregated
|
|
84
|
+
// per group. Sync tables aggregate lazily (visible cells only), so
|
|
85
|
+
// auto-aggregating every column would explode on high-cardinality
|
|
86
|
+
// grouping for values nothing renders. Read the RAW column defs:
|
|
87
|
+
// rowAggregationFeature injects default aggregatedCell/aggregationFn
|
|
88
|
+
// into every resolved columnDef, so the resolved defs can't tell
|
|
89
|
+
// explicit from default.
|
|
90
|
+
aggregateColumnIds = flattenColumnDefs(config.columns as Array<any>)
|
|
91
|
+
.filter(
|
|
92
|
+
(def) => def.aggregationFn != null || def.aggregatedCell != null,
|
|
93
|
+
)
|
|
94
|
+
.map(
|
|
95
|
+
(def) =>
|
|
96
|
+
def.id ??
|
|
97
|
+
(typeof def.accessorKey === 'string'
|
|
98
|
+
? def.accessorKey.replaceAll('.', '_')
|
|
99
|
+
: undefined),
|
|
100
|
+
)
|
|
101
|
+
.filter((id): id is string => id != null)
|
|
102
|
+
} else {
|
|
103
|
+
table.setOptions((prev) => ({ ...prev, data: message.data }))
|
|
104
|
+
}
|
|
105
|
+
// Map row ids to data positions once per dataset; serialization uses it
|
|
106
|
+
// to express every stage result in terms of core row positions.
|
|
107
|
+
const coreFlatRows = table.getCoreRowModel().flatRows
|
|
108
|
+
coreIndexById = makeObjectMap()
|
|
109
|
+
for (let i = 0; i < coreFlatRows.length; i++) {
|
|
110
|
+
coreIndexById[coreFlatRows[i]!.id] = i
|
|
111
|
+
}
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!table) return
|
|
116
|
+
|
|
117
|
+
const start = performance.now()
|
|
118
|
+
|
|
119
|
+
// Apply the serializable state slices to the shadow table's base atoms.
|
|
120
|
+
table._reactivity.batch(() => {
|
|
121
|
+
for (const [key, value] of Object.entries(message.state)) {
|
|
122
|
+
const baseAtom = (table!.baseAtoms as Record<string, any>)[key]
|
|
123
|
+
if (baseAtom && value !== undefined) {
|
|
124
|
+
baseAtom.set(value)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// Compute exactly the stages the main thread requested, skipping any this
|
|
130
|
+
// shadow table has no row model factory for (the main thread warns).
|
|
131
|
+
const stages: { [K in TableWorkerStage]?: TableWorkerStagePayload } = {}
|
|
132
|
+
const transfer: Array<Transferable> = []
|
|
133
|
+
|
|
134
|
+
for (const stage of message.stages) {
|
|
135
|
+
if (!(config.features as Record<string, unknown>)[`${stage}RowModel`]) {
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
const model = (table as any)[`get${capitalize(stage)}RowModel`]()
|
|
139
|
+
// Memoized getters return the same object when inputs are unchanged;
|
|
140
|
+
// skip re-serializing (and the main thread skips rebuilding). Safe under
|
|
141
|
+
// single-flight: results are never dropped within a dataVersion.
|
|
142
|
+
if (lastSentModels[stage] === model) {
|
|
143
|
+
stages[stage] = { kind: 'unchanged' }
|
|
144
|
+
continue
|
|
145
|
+
}
|
|
146
|
+
lastSentModels[stage] = model
|
|
147
|
+
stages[stage] = serializeRowModel(
|
|
148
|
+
model,
|
|
149
|
+
coreIndexById,
|
|
150
|
+
aggregateColumnIds,
|
|
151
|
+
transfer,
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const response: TableWorkerResult = {
|
|
156
|
+
type: 'result',
|
|
157
|
+
requestId: message.requestId,
|
|
158
|
+
dataVersion,
|
|
159
|
+
stages,
|
|
160
|
+
computeMs: performance.now() - start,
|
|
161
|
+
}
|
|
162
|
+
postMessage(response, { transfer })
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { constructRow } from '../core/rows/constructRow'
|
|
2
|
+
import { hasOwn } from '../utils'
|
|
3
|
+
import type { RowModel } from '../core/row-models/coreRowModelsFeature.types'
|
|
4
|
+
import type { Table_Internal } from '../types/Table'
|
|
5
|
+
import type { TableFeatures } from '../types/TableFeatures'
|
|
6
|
+
import type { RowData } from '../types/type-utils'
|
|
7
|
+
import type {
|
|
8
|
+
TableWorkerRowNode,
|
|
9
|
+
TableWorkerStagePayload,
|
|
10
|
+
} from './tableWorkerProtocol'
|
|
11
|
+
|
|
12
|
+
/** Payloads that carry data; `unchanged` never reaches the rebuilder. */
|
|
13
|
+
export type TableWorkerDataPayload = Exclude<
|
|
14
|
+
TableWorkerStagePayload,
|
|
15
|
+
{ kind: 'unchanged' }
|
|
16
|
+
>
|
|
17
|
+
|
|
18
|
+
// Main-thread side: payload + this table's core rows -> RowModel. Mirrors how
|
|
19
|
+
// the sync row models treat rows: data rows are reused (with depth/parentId
|
|
20
|
+
// rewritten, exactly like createGroupedRowModel does), synthetic group rows
|
|
21
|
+
// are reconstructed via constructRow with their worker-computed aggregates
|
|
22
|
+
// pre-seeded so no aggregation ever runs on the main thread.
|
|
23
|
+
|
|
24
|
+
function collectLeafRows(subRows: Array<any>, out: Array<any>) {
|
|
25
|
+
for (let i = 0; i < subRows.length; i++) {
|
|
26
|
+
const row = subRows[i]
|
|
27
|
+
if (row.groupingColumnId == null) {
|
|
28
|
+
out.push(row)
|
|
29
|
+
} else {
|
|
30
|
+
collectLeafRows(row.subRows, out)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function rebuildRowModel<
|
|
36
|
+
TFeatures extends TableFeatures,
|
|
37
|
+
TData extends RowData,
|
|
38
|
+
>(
|
|
39
|
+
table: Table_Internal<TFeatures, TData>,
|
|
40
|
+
payload: TableWorkerDataPayload,
|
|
41
|
+
/**
|
|
42
|
+
* Whether a flat payload should rewrite row depth/parentId. Mirrors core:
|
|
43
|
+
* the grouped model's passthrough resets them, the filtered model never
|
|
44
|
+
* touches them. Without this distinction a filtered rebuild could zero the
|
|
45
|
+
* depths a grouped/sorted tree rebuild just assigned to shared row objects.
|
|
46
|
+
*/
|
|
47
|
+
resetDepths: boolean,
|
|
48
|
+
): RowModel<TFeatures, TData> {
|
|
49
|
+
const core = table.getCoreRowModel()
|
|
50
|
+
|
|
51
|
+
if (payload.kind === 'flat') {
|
|
52
|
+
const { indices } = payload
|
|
53
|
+
const rows = new Array(indices.length)
|
|
54
|
+
for (let i = 0; i < indices.length; i++) {
|
|
55
|
+
const row: any = core.flatRows[indices[i]!]!
|
|
56
|
+
if (resetDepths) {
|
|
57
|
+
row.depth = 0
|
|
58
|
+
row.parentId = undefined
|
|
59
|
+
}
|
|
60
|
+
rows[i] = row
|
|
61
|
+
}
|
|
62
|
+
return { rows, flatRows: rows, rowsById: core.rowsById }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const flatRows: Array<any> = []
|
|
66
|
+
// Data rows resolve through the prototype chain to the core map; only
|
|
67
|
+
// synthetic group rows are added on top.
|
|
68
|
+
const rowsById: Record<string, any> = Object.create(core.rowsById)
|
|
69
|
+
|
|
70
|
+
const rebuildRows = (
|
|
71
|
+
nodes: Array<TableWorkerRowNode>,
|
|
72
|
+
depth: number,
|
|
73
|
+
parentId: string | undefined,
|
|
74
|
+
): Array<any> => {
|
|
75
|
+
const rows = new Array(nodes.length)
|
|
76
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
77
|
+
const node = nodes[i]!
|
|
78
|
+
if (typeof node === 'number') {
|
|
79
|
+
const row: any = core.flatRows[node]!
|
|
80
|
+
row.depth = depth
|
|
81
|
+
row.parentId = parentId
|
|
82
|
+
flatRows.push(row)
|
|
83
|
+
rows[i] = row
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const subRows = rebuildRows(node.children, depth + 1, node.id)
|
|
88
|
+
const leafRows: Array<any> = []
|
|
89
|
+
collectLeafRows(subRows, leafRows)
|
|
90
|
+
|
|
91
|
+
const row: any = constructRow(
|
|
92
|
+
table,
|
|
93
|
+
node.id,
|
|
94
|
+
leafRows[0]?.original,
|
|
95
|
+
node.index,
|
|
96
|
+
depth,
|
|
97
|
+
undefined,
|
|
98
|
+
parentId,
|
|
99
|
+
)
|
|
100
|
+
const aggregates = node.aggregates
|
|
101
|
+
Object.assign(row, {
|
|
102
|
+
groupingColumnId: node.groupingColumnId,
|
|
103
|
+
groupingValue: node.groupingValue,
|
|
104
|
+
subRows,
|
|
105
|
+
leafRows,
|
|
106
|
+
getValue: (columnId: string) =>
|
|
107
|
+
hasOwn(aggregates, columnId) ? aggregates[columnId] : undefined,
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
flatRows.push(row)
|
|
111
|
+
rowsById[node.id] = row
|
|
112
|
+
rows[i] = row
|
|
113
|
+
}
|
|
114
|
+
return rows
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const rows = rebuildRows(payload.children, 0, undefined)
|
|
118
|
+
|
|
119
|
+
return { rows, flatRows, rowsById }
|
|
120
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { RowModel } from '../core/row-models/coreRowModelsFeature.types'
|
|
2
|
+
import type {
|
|
3
|
+
TableWorkerRowNode,
|
|
4
|
+
TableWorkerStagePayload,
|
|
5
|
+
} from './tableWorkerProtocol'
|
|
6
|
+
|
|
7
|
+
// Worker-side: RowModel -> transferable payload. Stage-agnostic; the payload
|
|
8
|
+
// kind is chosen from the model's shape (synthetic rows present or not).
|
|
9
|
+
|
|
10
|
+
function isCloneSafe(value: unknown): boolean {
|
|
11
|
+
return typeof value !== 'function' && typeof value !== 'symbol'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function serializeRows(
|
|
15
|
+
rows: Array<any>,
|
|
16
|
+
coreIndexById: Record<string, number>,
|
|
17
|
+
aggregateColumnIds: Array<string>,
|
|
18
|
+
): Array<TableWorkerRowNode> {
|
|
19
|
+
const nodes = new Array<TableWorkerRowNode>(rows.length)
|
|
20
|
+
for (let i = 0; i < rows.length; i++) {
|
|
21
|
+
const row = rows[i]
|
|
22
|
+
if (row.groupingColumnId == null) {
|
|
23
|
+
// Data row: its position in `options.data` is all the main thread needs.
|
|
24
|
+
nodes[i] = coreIndexById[row.id]!
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
// Synthetic group row: compute aggregates eagerly (the expensive per-group
|
|
28
|
+
// work we want off the main thread), but only for columns with an explicit
|
|
29
|
+
// aggregation; sync tables aggregate lazily, so eagerly auto-aggregating
|
|
30
|
+
// every column would explode on high-cardinality grouping.
|
|
31
|
+
const aggregates: Record<string, unknown> = {}
|
|
32
|
+
for (let c = 0; c < aggregateColumnIds.length; c++) {
|
|
33
|
+
const columnId = aggregateColumnIds[c]!
|
|
34
|
+
const value = row.getValue(columnId)
|
|
35
|
+
if (value !== undefined && isCloneSafe(value)) {
|
|
36
|
+
aggregates[columnId] = value
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// The group's own column always serializes its display value (the first
|
|
40
|
+
// leaf's value) so grouped cells render.
|
|
41
|
+
if (!(row.groupingColumnId in aggregates)) {
|
|
42
|
+
const value = row.getValue(row.groupingColumnId)
|
|
43
|
+
if (value !== undefined && isCloneSafe(value)) {
|
|
44
|
+
aggregates[row.groupingColumnId] = value
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
nodes[i] = {
|
|
48
|
+
id: row.id,
|
|
49
|
+
groupingColumnId: row.groupingColumnId,
|
|
50
|
+
groupingValue: row.groupingValue,
|
|
51
|
+
index: row.index,
|
|
52
|
+
aggregates,
|
|
53
|
+
children: serializeRows(row.subRows, coreIndexById, aggregateColumnIds),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return nodes
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function serializeRowModel(
|
|
60
|
+
model: RowModel<any, any>,
|
|
61
|
+
coreIndexById: Record<string, number>,
|
|
62
|
+
aggregateColumnIds: Array<string>,
|
|
63
|
+
transfer: Array<Transferable>,
|
|
64
|
+
): TableWorkerStagePayload {
|
|
65
|
+
// Flat fast path: no synthetic rows anywhere (flatRows === rows for flat
|
|
66
|
+
// data). A Uint32Array permutation transfers at zero-copy cost.
|
|
67
|
+
if (model.flatRows.length === model.rows.length) {
|
|
68
|
+
const indices = new Uint32Array(model.rows.length)
|
|
69
|
+
for (let i = 0; i < indices.length; i++) {
|
|
70
|
+
indices[i] = coreIndexById[model.rows[i]!.id]!
|
|
71
|
+
}
|
|
72
|
+
transfer.push(indices.buffer)
|
|
73
|
+
return { kind: 'flat', indices }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
kind: 'tree',
|
|
78
|
+
children: serializeRows(model.rows, coreIndexById, aggregateColumnIds),
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { RowData } from '../types/type-utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Row model stages that can be offloaded to the worker, in pipeline order.
|
|
5
|
+
* Everything else in this module is derived from this list; adding a stage
|
|
6
|
+
* means adding an entry here and to `tableWorkerStageStateDeps`.
|
|
7
|
+
*/
|
|
8
|
+
export const tableWorkerPipeline = [
|
|
9
|
+
'filtered',
|
|
10
|
+
'grouped',
|
|
11
|
+
'sorted',
|
|
12
|
+
'expanded',
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export type TableWorkerStage = (typeof tableWorkerPipeline)[number]
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The state slices each stage's computation depends on. The main thread sends
|
|
19
|
+
* the union of deps for its registered stages; a change to any of them
|
|
20
|
+
* triggers one worker round trip.
|
|
21
|
+
*/
|
|
22
|
+
export const tableWorkerStageStateDeps: Record<
|
|
23
|
+
TableWorkerStage,
|
|
24
|
+
Array<string>
|
|
25
|
+
> = {
|
|
26
|
+
filtered: ['columnFilters', 'globalFilter'],
|
|
27
|
+
grouped: ['grouping'],
|
|
28
|
+
sorted: ['sorting'],
|
|
29
|
+
expanded: ['expanded'],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A serialized synthetic (group) row. Leaf rows serialize as their position in
|
|
34
|
+
* `options.data`; group rows carry what `constructRow` + the grouped row model
|
|
35
|
+
* need to rebuild them, plus eagerly computed aggregate values so no
|
|
36
|
+
* aggregation runs on the main thread.
|
|
37
|
+
*/
|
|
38
|
+
export interface TableWorkerGroupNode {
|
|
39
|
+
id: string
|
|
40
|
+
groupingColumnId: string
|
|
41
|
+
groupingValue: unknown
|
|
42
|
+
index: number
|
|
43
|
+
aggregates: Record<string, unknown>
|
|
44
|
+
children: Array<TableWorkerRowNode>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type TableWorkerRowNode = number | TableWorkerGroupNode
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A stage result. Flat models (every row is a data row) travel as a
|
|
51
|
+
* transferable index permutation; models containing synthetic rows (grouping)
|
|
52
|
+
* travel as a tree. The kind is chosen from the model's actual shape at
|
|
53
|
+
* runtime, not from the stage name: a sorted model is flat without grouping
|
|
54
|
+
* and a tree with it.
|
|
55
|
+
*
|
|
56
|
+
* `unchanged` means the stage's model is identical to the last one sent for
|
|
57
|
+
* this dataset (its memoized inputs did not change); the main thread keeps
|
|
58
|
+
* its previous result and skips the rebuild entirely.
|
|
59
|
+
*/
|
|
60
|
+
export type TableWorkerStagePayload =
|
|
61
|
+
| { kind: 'flat'; indices: Uint32Array }
|
|
62
|
+
| { kind: 'tree'; children: Array<TableWorkerRowNode> }
|
|
63
|
+
| { kind: 'unchanged' }
|
|
64
|
+
|
|
65
|
+
export type TableWorkerRequest<TData extends RowData = any> =
|
|
66
|
+
| {
|
|
67
|
+
type: 'data'
|
|
68
|
+
dataVersion: number
|
|
69
|
+
data: Array<TData>
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
type: 'process'
|
|
73
|
+
requestId: number
|
|
74
|
+
dataVersion: number
|
|
75
|
+
/** The stages the main thread has worker-backed row models for. */
|
|
76
|
+
stages: Array<TableWorkerStage>
|
|
77
|
+
/** Serializable state slices (union of the stages' deps). */
|
|
78
|
+
state: Record<string, unknown>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface TableWorkerResult {
|
|
82
|
+
type: 'result'
|
|
83
|
+
requestId: number
|
|
84
|
+
dataVersion: number
|
|
85
|
+
stages: { [K in TableWorkerStage]?: TableWorkerStagePayload }
|
|
86
|
+
computeMs: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type TableWorkerResponse = TableWorkerResult
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The state slice added by `workerRowModelsFeature`. `version` bumps when a
|
|
93
|
+
* worker result lands (driving re-renders through the normal state path);
|
|
94
|
+
* `isPending` is true while a request is in flight. The timing fields expose
|
|
95
|
+
* the last result's worker compute time and full round trip for devtools and
|
|
96
|
+
* debugging.
|
|
97
|
+
*/
|
|
98
|
+
export interface TableState_WorkerRowModels {
|
|
99
|
+
workerRowModels: {
|
|
100
|
+
version: number
|
|
101
|
+
isPending: boolean
|
|
102
|
+
lastComputeMs?: number
|
|
103
|
+
lastRoundTripMs?: number
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/fns/aggregationFns.ts
|
|
3
|
-
/**
|
|
4
|
-
* Sums numeric child-row values for a grouped column.
|
|
5
|
-
*
|
|
6
|
-
* Non-number values contribute `0`. Child rows are used so nested group totals
|
|
7
|
-
* can reuse already aggregated values.
|
|
8
|
-
*/
|
|
9
|
-
function aggregationFn_sum(columnId, _leafRows, childRows) {
|
|
10
|
-
return childRows.reduce((sumValue, next) => {
|
|
11
|
-
const nextValue = next.getValue(columnId);
|
|
12
|
-
return sumValue + (typeof nextValue === "number" ? nextValue : 0);
|
|
13
|
-
}, 0);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Finds the minimum numeric child-row value for a grouped column.
|
|
17
|
-
*
|
|
18
|
-
* Nullish and non-number values are ignored. Returns `undefined` when no
|
|
19
|
-
* numeric value is found.
|
|
20
|
-
*/
|
|
21
|
-
function aggregationFn_min(columnId, _leafRows, childRows) {
|
|
22
|
-
let minValue;
|
|
23
|
-
childRows.forEach((row) => {
|
|
24
|
-
const value = row.getValue(columnId);
|
|
25
|
-
if (value != null && typeof value === "number" && (minValue === void 0 || value < minValue)) minValue = value;
|
|
26
|
-
});
|
|
27
|
-
return minValue;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Finds the maximum numeric child-row value for a grouped column.
|
|
31
|
-
*
|
|
32
|
-
* Nullish and non-number values are ignored. Returns `undefined` when no
|
|
33
|
-
* numeric value is found.
|
|
34
|
-
*/
|
|
35
|
-
function aggregationFn_max(columnId, _leafRows, childRows) {
|
|
36
|
-
let maxValue;
|
|
37
|
-
childRows.forEach((row) => {
|
|
38
|
-
const value = row.getValue(columnId);
|
|
39
|
-
if (value != null && typeof value === "number" && (maxValue === void 0 || value > maxValue)) maxValue = value;
|
|
40
|
-
});
|
|
41
|
-
return maxValue;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Finds the numeric extent for a grouped column.
|
|
45
|
-
*
|
|
46
|
-
* Returns `[min, max]`, where each entry is `undefined` when no numeric value is
|
|
47
|
-
* present.
|
|
48
|
-
*/
|
|
49
|
-
function aggregationFn_extent(columnId, _leafRows, childRows) {
|
|
50
|
-
let minValue;
|
|
51
|
-
let maxValue;
|
|
52
|
-
childRows.forEach((row) => {
|
|
53
|
-
const value = row.getValue(columnId);
|
|
54
|
-
if (value != null && typeof value === "number") if (minValue === void 0) minValue = maxValue = value;
|
|
55
|
-
else {
|
|
56
|
-
if (minValue > value) minValue = value;
|
|
57
|
-
if (maxValue < value) maxValue = value;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return [minValue, maxValue];
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Averages numeric leaf-row values for a grouped column.
|
|
64
|
-
*
|
|
65
|
-
* Number-like values are coerced with unary `+`; nullish and non-numeric values
|
|
66
|
-
* are ignored.
|
|
67
|
-
*/
|
|
68
|
-
function aggregationFn_mean(columnId, leafRows) {
|
|
69
|
-
let count = 0;
|
|
70
|
-
let sumValue = 0;
|
|
71
|
-
leafRows.forEach((row) => {
|
|
72
|
-
const value = row.getValue(columnId);
|
|
73
|
-
if (value != null && typeof value === "number") {
|
|
74
|
-
++count;
|
|
75
|
-
sumValue += value;
|
|
76
|
-
} else if (value != null) {
|
|
77
|
-
const numValue = +value;
|
|
78
|
-
if (!Number.isNaN(numValue)) {
|
|
79
|
-
++count;
|
|
80
|
-
sumValue += numValue;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
if (count) return sumValue / count;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Computes the median of numeric leaf-row values for a grouped column.
|
|
88
|
-
*
|
|
89
|
-
* All values must be numbers. If any value is non-numeric, or no leaf rows are
|
|
90
|
-
* present, the result is `undefined`.
|
|
91
|
-
*/
|
|
92
|
-
function aggregationFn_median(columnId, leafRows) {
|
|
93
|
-
if (!leafRows.length) return;
|
|
94
|
-
const values = new Array(leafRows.length);
|
|
95
|
-
for (let i = 0; i < leafRows.length; i++) {
|
|
96
|
-
const v = leafRows[i].getValue(columnId);
|
|
97
|
-
if (typeof v !== "number") return;
|
|
98
|
-
values[i] = v;
|
|
99
|
-
}
|
|
100
|
-
if (values.length === 1) return values[0];
|
|
101
|
-
const mid = Math.floor(values.length / 2);
|
|
102
|
-
values.sort((a, b) => a - b);
|
|
103
|
-
return values.length % 2 !== 0 ? values[mid] : (values[mid - 1] + values[mid]) / 2;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Collects unique leaf-row values for a grouped column.
|
|
107
|
-
*
|
|
108
|
-
* Values are compared with JavaScript `Set` semantics.
|
|
109
|
-
*/
|
|
110
|
-
function aggregationFn_unique(columnId, leafRows) {
|
|
111
|
-
const set = /* @__PURE__ */ new Set();
|
|
112
|
-
for (let i = 0; i < leafRows.length; i++) set.add(leafRows[i].getValue(columnId));
|
|
113
|
-
return Array.from(set.values());
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Counts unique leaf-row values for a grouped column.
|
|
117
|
-
*
|
|
118
|
-
* Values are compared with JavaScript `Set` semantics.
|
|
119
|
-
*/
|
|
120
|
-
function aggregationFn_uniqueCount(columnId, leafRows) {
|
|
121
|
-
const set = /* @__PURE__ */ new Set();
|
|
122
|
-
for (let i = 0; i < leafRows.length; i++) set.add(leafRows[i].getValue(columnId));
|
|
123
|
-
return set.size;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Counts the number of leaf rows in the group.
|
|
127
|
-
*
|
|
128
|
-
* The column id is ignored because the result is based only on group size.
|
|
129
|
-
*/
|
|
130
|
-
function aggregationFn_count(_columnId, leafRows) {
|
|
131
|
-
return leafRows.length;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* The built-in aggregation function registry.
|
|
135
|
-
*
|
|
136
|
-
* Pass this object to grouped row model creation or extend it with custom aggregation functions for grouped columns.
|
|
137
|
-
*/
|
|
138
|
-
const aggregationFns = {
|
|
139
|
-
sum: aggregationFn_sum,
|
|
140
|
-
min: aggregationFn_min,
|
|
141
|
-
max: aggregationFn_max,
|
|
142
|
-
extent: aggregationFn_extent,
|
|
143
|
-
mean: aggregationFn_mean,
|
|
144
|
-
median: aggregationFn_median,
|
|
145
|
-
unique: aggregationFn_unique,
|
|
146
|
-
uniqueCount: aggregationFn_uniqueCount,
|
|
147
|
-
count: aggregationFn_count
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
exports.aggregationFn_count = aggregationFn_count;
|
|
152
|
-
exports.aggregationFn_extent = aggregationFn_extent;
|
|
153
|
-
exports.aggregationFn_max = aggregationFn_max;
|
|
154
|
-
exports.aggregationFn_mean = aggregationFn_mean;
|
|
155
|
-
exports.aggregationFn_median = aggregationFn_median;
|
|
156
|
-
exports.aggregationFn_min = aggregationFn_min;
|
|
157
|
-
exports.aggregationFn_sum = aggregationFn_sum;
|
|
158
|
-
exports.aggregationFn_unique = aggregationFn_unique;
|
|
159
|
-
exports.aggregationFn_uniqueCount = aggregationFn_uniqueCount;
|
|
160
|
-
exports.aggregationFns = aggregationFns;
|
|
161
|
-
//# sourceMappingURL=aggregationFns.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aggregationFns.cjs","names":[],"sources":["../../src/fns/aggregationFns.ts"],"sourcesContent":["import type { RowData } from '../types/type-utils'\nimport type { TableFeatures } from '../types/TableFeatures'\nimport type { Row } from '../types/Row'\n\n/**\n * Sums numeric child-row values for a grouped column.\n *\n * Non-number values contribute `0`. Child rows are used so nested group totals\n * can reuse already aggregated values.\n */\nexport function aggregationFn_sum<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n columnId: string,\n _leafRows: Array<Row<TFeatures, TData>>,\n childRows: Array<Row<TFeatures, TData>>,\n) {\n // It's faster to just add the aggregations together instead of\n // process leaf nodes individually\n return childRows.reduce((sumValue, next) => {\n const nextValue = next.getValue(columnId)\n return sumValue + (typeof nextValue === 'number' ? nextValue : 0)\n }, 0)\n}\n\n/**\n * Finds the minimum numeric child-row value for a grouped column.\n *\n * Nullish and non-number values are ignored. Returns `undefined` when no\n * numeric value is found.\n */\nexport function aggregationFn_min<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n columnId: string,\n _leafRows: Array<Row<TFeatures, TData>>,\n childRows: Array<Row<TFeatures, TData>>,\n) {\n let minValue: number | undefined\n\n childRows.forEach((row) => {\n const value = row.getValue(columnId)\n\n if (\n value != null &&\n typeof value === 'number' &&\n (minValue === undefined || value < minValue)\n ) {\n minValue = value\n }\n })\n\n return minValue\n}\n\n/**\n * Finds the maximum numeric child-row value for a grouped column.\n *\n * Nullish and non-number values are ignored. Returns `undefined` when no\n * numeric value is found.\n */\nexport function aggregationFn_max<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n columnId: string,\n _leafRows: Array<Row<TFeatures, TData>>,\n childRows: Array<Row<TFeatures, TData>>,\n) {\n let maxValue: number | undefined\n\n childRows.forEach((row) => {\n const value = row.getValue(columnId)\n if (\n value != null &&\n typeof value === 'number' &&\n (maxValue === undefined || value > maxValue)\n ) {\n maxValue = value\n }\n })\n\n return maxValue\n}\n\n/**\n * Finds the numeric extent for a grouped column.\n *\n * Returns `[min, max]`, where each entry is `undefined` when no numeric value is\n * present.\n */\nexport function aggregationFn_extent<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n columnId: string,\n _leafRows: Array<Row<TFeatures, TData>>,\n childRows: Array<Row<TFeatures, TData>>,\n) {\n let minValue: number | undefined\n let maxValue: number | undefined\n\n childRows.forEach((row) => {\n const value = row.getValue(columnId)\n if (value != null && typeof value === 'number') {\n if (minValue === undefined) {\n minValue = maxValue = value\n } else {\n if (minValue > value) minValue = value\n if (maxValue! < value) maxValue = value\n }\n }\n })\n\n return [minValue, maxValue]\n}\n\n/**\n * Averages numeric leaf-row values for a grouped column.\n *\n * Number-like values are coerced with unary `+`; nullish and non-numeric values\n * are ignored.\n */\nexport function aggregationFn_mean<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(columnId: string, leafRows: Array<Row<TFeatures, TData>>) {\n let count = 0\n let sumValue = 0\n\n leafRows.forEach((row) => {\n const value = row.getValue(columnId)\n if (value != null && typeof value === 'number') {\n ++count\n sumValue += value\n } else if (value != null) {\n const numValue = +value\n if (!Number.isNaN(numValue)) {\n ++count\n sumValue += numValue\n }\n }\n })\n\n if (count) return sumValue / count\n\n return\n}\n\n/**\n * Computes the median of numeric leaf-row values for a grouped column.\n *\n * All values must be numbers. If any value is non-numeric, or no leaf rows are\n * present, the result is `undefined`.\n */\nexport function aggregationFn_median<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(columnId: string, leafRows: Array<Row<TFeatures, TData>>) {\n if (!leafRows.length) {\n return\n }\n\n const values: Array<number> = new Array(leafRows.length)\n for (let i = 0; i < leafRows.length; i++) {\n const v = leafRows[i]!.getValue(columnId)\n if (typeof v !== 'number') return\n values[i] = v\n }\n\n if (values.length === 1) {\n return values[0]\n }\n\n const mid = Math.floor(values.length / 2)\n values.sort((a, b) => a - b)\n return values.length % 2 !== 0\n ? values[mid]\n : (values[mid - 1]! + values[mid]!) / 2\n}\n\n/**\n * Collects unique leaf-row values for a grouped column.\n *\n * Values are compared with JavaScript `Set` semantics.\n */\nexport function aggregationFn_unique<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(columnId: string, leafRows: Array<Row<TFeatures, TData>>) {\n const set = new Set<unknown>()\n for (let i = 0; i < leafRows.length; i++) {\n set.add(leafRows[i]!.getValue(columnId))\n }\n return Array.from(set.values())\n}\n\n/**\n * Counts unique leaf-row values for a grouped column.\n *\n * Values are compared with JavaScript `Set` semantics.\n */\nexport function aggregationFn_uniqueCount<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(columnId: string, leafRows: Array<Row<TFeatures, TData>>) {\n const set = new Set<unknown>()\n for (let i = 0; i < leafRows.length; i++) {\n set.add(leafRows[i]!.getValue(columnId))\n }\n return set.size\n}\n\n/**\n * Counts the number of leaf rows in the group.\n *\n * The column id is ignored because the result is based only on group size.\n */\nexport function aggregationFn_count<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(_columnId: string, leafRows: Array<Row<TFeatures, TData>>) {\n return leafRows.length\n}\n\n/**\n * The built-in aggregation function registry.\n *\n * Pass this object to grouped row model creation or extend it with custom aggregation functions for grouped columns.\n */\nexport const aggregationFns = {\n sum: aggregationFn_sum,\n min: aggregationFn_min,\n max: aggregationFn_max,\n extent: aggregationFn_extent,\n mean: aggregationFn_mean,\n median: aggregationFn_median,\n unique: aggregationFn_unique,\n uniqueCount: aggregationFn_uniqueCount,\n count: aggregationFn_count,\n}\n\nexport type BuiltInAggregationFn = keyof typeof aggregationFns\n"],"mappings":";;;;;;;;AAUA,SAAgB,kBAId,UACA,WACA,WACA;CAGA,OAAO,UAAU,QAAQ,UAAU,SAAS;EAC1C,MAAM,YAAY,KAAK,SAAS,QAAQ;EACxC,OAAO,YAAY,OAAO,cAAc,WAAW,YAAY;CACjE,GAAG,CAAC;AACN;;;;;;;AAQA,SAAgB,kBAId,UACA,WACA,WACA;CACA,IAAI;CAEJ,UAAU,SAAS,QAAQ;EACzB,MAAM,QAAQ,IAAI,SAAS,QAAQ;EAEnC,IACE,SAAS,QACT,OAAO,UAAU,aAChB,aAAa,UAAa,QAAQ,WAEnC,WAAW;CAEf,CAAC;CAED,OAAO;AACT;;;;;;;AAQA,SAAgB,kBAId,UACA,WACA,WACA;CACA,IAAI;CAEJ,UAAU,SAAS,QAAQ;EACzB,MAAM,QAAQ,IAAI,SAAS,QAAQ;EACnC,IACE,SAAS,QACT,OAAO,UAAU,aAChB,aAAa,UAAa,QAAQ,WAEnC,WAAW;CAEf,CAAC;CAED,OAAO;AACT;;;;;;;AAQA,SAAgB,qBAId,UACA,WACA,WACA;CACA,IAAI;CACJ,IAAI;CAEJ,UAAU,SAAS,QAAQ;EACzB,MAAM,QAAQ,IAAI,SAAS,QAAQ;EACnC,IAAI,SAAS,QAAQ,OAAO,UAAU,UACpC,IAAI,aAAa,QACf,WAAW,WAAW;OACjB;GACL,IAAI,WAAW,OAAO,WAAW;GACjC,IAAI,WAAY,OAAO,WAAW;EACpC;CAEJ,CAAC;CAED,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;AAQA,SAAgB,mBAGd,UAAkB,UAAwC;CAC1D,IAAI,QAAQ;CACZ,IAAI,WAAW;CAEf,SAAS,SAAS,QAAQ;EACxB,MAAM,QAAQ,IAAI,SAAS,QAAQ;EACnC,IAAI,SAAS,QAAQ,OAAO,UAAU,UAAU;GAC9C,EAAE;GACF,YAAY;EACd,OAAO,IAAI,SAAS,MAAM;GACxB,MAAM,WAAW,CAAC;GAClB,IAAI,CAAC,OAAO,MAAM,QAAQ,GAAG;IAC3B,EAAE;IACF,YAAY;GACd;EACF;CACF,CAAC;CAED,IAAI,OAAO,OAAO,WAAW;AAG/B;;;;;;;AAQA,SAAgB,qBAGd,UAAkB,UAAwC;CAC1D,IAAI,CAAC,SAAS,QACZ;CAGF,MAAM,SAAwB,IAAI,MAAM,SAAS,MAAM;CACvD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,IAAI,SAAS,EAAE,CAAE,SAAS,QAAQ;EACxC,IAAI,OAAO,MAAM,UAAU;EAC3B,OAAO,KAAK;CACd;CAEA,IAAI,OAAO,WAAW,GACpB,OAAO,OAAO;CAGhB,MAAM,MAAM,KAAK,MAAM,OAAO,SAAS,CAAC;CACxC,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO,OAAO,SAAS,MAAM,IACzB,OAAO,QACN,OAAO,MAAM,KAAM,OAAO,QAAS;AAC1C;;;;;;AAOA,SAAgB,qBAGd,UAAkB,UAAwC;CAC1D,MAAM,sBAAM,IAAI,IAAa;CAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACnC,IAAI,IAAI,SAAS,EAAE,CAAE,SAAS,QAAQ,CAAC;CAEzC,OAAO,MAAM,KAAK,IAAI,OAAO,CAAC;AAChC;;;;;;AAOA,SAAgB,0BAGd,UAAkB,UAAwC;CAC1D,MAAM,sBAAM,IAAI,IAAa;CAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACnC,IAAI,IAAI,SAAS,EAAE,CAAE,SAAS,QAAQ,CAAC;CAEzC,OAAO,IAAI;AACb;;;;;;AAOA,SAAgB,oBAGd,WAAmB,UAAwC;CAC3D,OAAO,SAAS;AAClB;;;;;;AAOA,MAAa,iBAAiB;CAC5B,KAAK;CACL,KAAK;CACL,KAAK;CACL,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,OAAO;AACT"}
|