@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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellData, RowData, Updater } from "../../types/type-utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { GroupingState, Row_ColumnGrouping } from "./columnGroupingFeature.types.js";
|
|
3
|
+
import { Cell } from "../../types/Cell.js";
|
|
3
4
|
import { Row } from "../../types/Row.js";
|
|
5
|
+
import { Table } from "../../types/Table.js";
|
|
6
|
+
import { Column } from "../../types/Column.js";
|
|
4
7
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
|
-
import { Table_Internal } from "../../types/Table.js";
|
|
6
|
-
import { AggregationFn, GroupingState, Row_ColumnGrouping } from "./columnGroupingFeature.types.js";
|
|
7
|
-
import { Cell } from "../../types/Cell.js";
|
|
8
8
|
|
|
9
9
|
//#region src/features/column-grouping/columnGroupingFeature.utils.d.ts
|
|
10
10
|
/**
|
|
@@ -30,7 +30,7 @@ declare function getDefaultGroupingState(): GroupingState;
|
|
|
30
30
|
* column_toggleGrouping(column)
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
declare function column_toggleGrouping<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
33
|
+
declare function column_toggleGrouping<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): void;
|
|
34
34
|
/**
|
|
35
35
|
* Checks whether this column can be used for grouping.
|
|
36
36
|
*
|
|
@@ -42,7 +42,7 @@ declare function column_toggleGrouping<TFeatures extends TableFeatures, TData ex
|
|
|
42
42
|
* const canGroup = column_getCanGroup(column)
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
declare function column_getCanGroup<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
45
|
+
declare function column_getCanGroup<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): boolean;
|
|
46
46
|
/**
|
|
47
47
|
* Checks whether this column id is present in `state.grouping`.
|
|
48
48
|
*
|
|
@@ -54,7 +54,7 @@ declare function column_getCanGroup<TFeatures extends TableFeatures, TData exten
|
|
|
54
54
|
* const isGrouped = column_getIsGrouped(column)
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
declare function column_getIsGrouped<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
57
|
+
declare function column_getIsGrouped<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Finds this column's position in the ordered grouping state.
|
|
60
60
|
*
|
|
@@ -65,7 +65,7 @@ declare function column_getIsGrouped<TFeatures extends TableFeatures, TData exte
|
|
|
65
65
|
* const index = column_getGroupedIndex(column)
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
declare function column_getGroupedIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
68
|
+
declare function column_getGroupedIndex<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): number;
|
|
69
69
|
/**
|
|
70
70
|
* Creates a header/control handler that toggles grouping for this column.
|
|
71
71
|
*
|
|
@@ -76,32 +76,7 @@ declare function column_getGroupedIndex<TFeatures extends TableFeatures, TData e
|
|
|
76
76
|
* const onClick = column_getToggleGroupingHandler(column)
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
declare function column_getToggleGroupingHandler<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column:
|
|
80
|
-
/**
|
|
81
|
-
* Chooses a built-in aggregation function from the first core row value.
|
|
82
|
-
*
|
|
83
|
-
* Numeric columns default to `sum`, date-like values default to `extent`, and
|
|
84
|
-
* other value types leave aggregation unspecified.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```ts
|
|
88
|
-
* const aggregationFn = column_getAutoAggregationFn(column)
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare function column_getAutoAggregationFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): AggregationFn<TFeatures, TData> | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* Resolves the aggregation function configured for a column.
|
|
94
|
-
*
|
|
95
|
-
* Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`
|
|
96
|
-
* delegates to `column_getAutoAggregationFn`, and string values are looked up in
|
|
97
|
-
* the table's aggregation function registry.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```ts
|
|
101
|
-
* const aggregationFn = column_getAggregationFn(column)
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function column_getAggregationFn<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column_Internal<TFeatures, TData, TValue>): AggregationFn<TFeatures, TData> | undefined;
|
|
79
|
+
declare function column_getToggleGroupingHandler<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(column: Column<TFeatures, TData, TValue>): () => void;
|
|
105
80
|
/**
|
|
106
81
|
* Routes a grouping updater through the table's grouping change handler.
|
|
107
82
|
*
|
|
@@ -113,7 +88,7 @@ declare function column_getAggregationFn<TFeatures extends TableFeatures, TData
|
|
|
113
88
|
* table_setGrouping(table, (old) => [...old, 'status'])
|
|
114
89
|
* ```
|
|
115
90
|
*/
|
|
116
|
-
declare function table_setGrouping<TFeatures extends TableFeatures, TData extends RowData>(table:
|
|
91
|
+
declare function table_setGrouping<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, updater: Updater<GroupingState>): void;
|
|
117
92
|
/**
|
|
118
93
|
* Resets `grouping` to the configured initial state or feature default.
|
|
119
94
|
*
|
|
@@ -126,7 +101,7 @@ declare function table_setGrouping<TFeatures extends TableFeatures, TData extend
|
|
|
126
101
|
* table_resetGrouping(table, true)
|
|
127
102
|
* ```
|
|
128
103
|
*/
|
|
129
|
-
declare function table_resetGrouping<TFeatures extends TableFeatures, TData extends RowData>(table:
|
|
104
|
+
declare function table_resetGrouping<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, defaultState?: boolean): void;
|
|
130
105
|
/**
|
|
131
106
|
* Checks whether this row was created as a grouped row.
|
|
132
107
|
*
|
|
@@ -173,18 +148,6 @@ declare function cell_getIsGrouped<TFeatures extends TableFeatures, TData extend
|
|
|
173
148
|
* ```
|
|
174
149
|
*/
|
|
175
150
|
declare function cell_getIsPlaceholder<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(cell: Cell<TFeatures, TData, TValue>): boolean;
|
|
176
|
-
/**
|
|
177
|
-
* Checks whether this cell should render an aggregated value.
|
|
178
|
-
*
|
|
179
|
-
* Aggregated cells are non-placeholder, non-grouped cells on rows that have
|
|
180
|
-
* subRows.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* const isAggregated = cell_getIsAggregated(cell)
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
declare function cell_getIsAggregated<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData>(cell: Cell<TFeatures, TData, TValue>): boolean;
|
|
188
151
|
//#endregion
|
|
189
|
-
export {
|
|
152
|
+
export { cell_getIsGrouped, cell_getIsPlaceholder, column_getCanGroup, column_getGroupedIndex, column_getIsGrouped, column_getToggleGroupingHandler, column_toggleGrouping, getDefaultGroupingState, row_getGroupingValue, row_getIsGrouped, table_resetGrouping, table_setGrouping };
|
|
190
153
|
//# sourceMappingURL=columnGroupingFeature.utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneState,
|
|
1
|
+
import { cloneState, hasOwn } from "../../utils.js";
|
|
2
2
|
|
|
3
3
|
//#region src/features/column-grouping/columnGroupingFeature.utils.ts
|
|
4
4
|
/**
|
|
@@ -58,8 +58,7 @@ function column_getCanGroup(column) {
|
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
60
|
function column_getIsGrouped(column) {
|
|
61
|
-
|
|
62
|
-
return !!((_column$table$atoms$g = column.table.atoms.grouping) === null || _column$table$atoms$g === void 0 || (_column$table$atoms$g = _column$table$atoms$g.get()) === null || _column$table$atoms$g === void 0 ? void 0 : _column$table$atoms$g.includes(column.id));
|
|
61
|
+
return !!column.table.atoms.grouping?.get()?.includes(column.id);
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
64
|
* Finds this column's position in the ordered grouping state.
|
|
@@ -72,8 +71,7 @@ function column_getIsGrouped(column) {
|
|
|
72
71
|
* ```
|
|
73
72
|
*/
|
|
74
73
|
function column_getGroupedIndex(column) {
|
|
75
|
-
|
|
76
|
-
return ((_column$table$atoms$g2 = column.table.atoms.grouping) === null || _column$table$atoms$g2 === void 0 || (_column$table$atoms$g2 = _column$table$atoms$g2.get()) === null || _column$table$atoms$g2 === void 0 ? void 0 : _column$table$atoms$g2.indexOf(column.id)) ?? -1;
|
|
74
|
+
return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1;
|
|
77
75
|
}
|
|
78
76
|
/**
|
|
79
77
|
* Creates a header/control handler that toggles grouping for this column.
|
|
@@ -93,40 +91,6 @@ function column_getToggleGroupingHandler(column) {
|
|
|
93
91
|
};
|
|
94
92
|
}
|
|
95
93
|
/**
|
|
96
|
-
* Chooses a built-in aggregation function from the first core row value.
|
|
97
|
-
*
|
|
98
|
-
* Numeric columns default to `sum`, date-like values default to `extent`, and
|
|
99
|
-
* other value types leave aggregation unspecified.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* const aggregationFn = column_getAutoAggregationFn(column)
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
function column_getAutoAggregationFn(column) {
|
|
107
|
-
const aggregationFns = column.table._rowModelFns.aggregationFns;
|
|
108
|
-
const firstRow = column.table.getCoreRowModel().flatRows[0];
|
|
109
|
-
const value = firstRow === null || firstRow === void 0 ? void 0 : firstRow.getValue(column.id);
|
|
110
|
-
if (typeof value === "number") return aggregationFns === null || aggregationFns === void 0 ? void 0 : aggregationFns.sum;
|
|
111
|
-
if (Object.prototype.toString.call(value) === "[object Date]") return aggregationFns === null || aggregationFns === void 0 ? void 0 : aggregationFns.extent;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Resolves the aggregation function configured for a column.
|
|
115
|
-
*
|
|
116
|
-
* Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`
|
|
117
|
-
* delegates to `column_getAutoAggregationFn`, and string values are looked up in
|
|
118
|
-
* the table's aggregation function registry.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* const aggregationFn = column_getAggregationFn(column)
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
function column_getAggregationFn(column) {
|
|
126
|
-
const aggregationFns = column.table._rowModelFns.aggregationFns;
|
|
127
|
-
return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === "auto" ? column_getAutoAggregationFn(column) : aggregationFns === null || aggregationFns === void 0 ? void 0 : aggregationFns[column.columnDef.aggregationFn];
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
94
|
* Routes a grouping updater through the table's grouping change handler.
|
|
131
95
|
*
|
|
132
96
|
* The updater may be a next `GroupingState` array or a function of the previous
|
|
@@ -138,8 +102,7 @@ function column_getAggregationFn(column) {
|
|
|
138
102
|
* ```
|
|
139
103
|
*/
|
|
140
104
|
function table_setGrouping(table, updater) {
|
|
141
|
-
|
|
142
|
-
(_table$options$onGrou = (_table$options = table.options).onGroupingChange) === null || _table$options$onGrou === void 0 || _table$options$onGrou.call(_table$options, updater);
|
|
105
|
+
table.options.onGroupingChange?.(updater);
|
|
143
106
|
}
|
|
144
107
|
/**
|
|
145
108
|
* Resets `grouping` to the configured initial state or feature default.
|
|
@@ -181,12 +144,11 @@ function row_getIsGrouped(row) {
|
|
|
181
144
|
* ```
|
|
182
145
|
*/
|
|
183
146
|
function row_getGroupingValue(row, columnId) {
|
|
184
|
-
|
|
185
|
-
if ((_row$_groupingValuesC = row._groupingValuesCache) === null || _row$_groupingValuesC === void 0 ? void 0 : _row$_groupingValuesC.hasOwnProperty(columnId)) return row._groupingValuesCache[columnId];
|
|
147
|
+
if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) return row._groupingValuesCache[columnId];
|
|
186
148
|
const column = row.table.getColumn(columnId);
|
|
187
149
|
if (!column.columnDef.getGroupingValue) return row.getValue(columnId);
|
|
188
|
-
if (row._groupingValuesCache) row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
|
|
189
|
-
return
|
|
150
|
+
if (row._groupingValuesCache) row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original, row.index, row);
|
|
151
|
+
return row._groupingValuesCache?.[columnId];
|
|
190
152
|
}
|
|
191
153
|
/**
|
|
192
154
|
* Checks whether this cell represents the grouped column for a grouped row.
|
|
@@ -216,21 +178,7 @@ function cell_getIsGrouped(cell) {
|
|
|
216
178
|
function cell_getIsPlaceholder(cell) {
|
|
217
179
|
return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column);
|
|
218
180
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Checks whether this cell should render an aggregated value.
|
|
221
|
-
*
|
|
222
|
-
* Aggregated cells are non-placeholder, non-grouped cells on rows that have
|
|
223
|
-
* subRows.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* ```ts
|
|
227
|
-
* const isAggregated = cell_getIsAggregated(cell)
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
function cell_getIsAggregated(cell) {
|
|
231
|
-
return !cell_getIsGrouped(cell) && !cell_getIsPlaceholder(cell) && !!cell.row.subRows.length;
|
|
232
|
-
}
|
|
233
181
|
|
|
234
182
|
//#endregion
|
|
235
|
-
export {
|
|
183
|
+
export { cell_getIsGrouped, cell_getIsPlaceholder, column_getCanGroup, column_getGroupedIndex, column_getIsGrouped, column_getToggleGroupingHandler, column_toggleGrouping, getDefaultGroupingState, row_getGroupingValue, row_getIsGrouped, table_resetGrouping, table_setGrouping };
|
|
236
184
|
//# sourceMappingURL=columnGroupingFeature.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnGroupingFeature.utils.js","names":[],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache?.hasOwnProperty(columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"columnGroupingFeature.utils.js","names":[],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n row.index,\n row,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAmD;CACnD,QACG,OAAO,UAAU,kBAAkB,UACnC,OAAO,MAAM,QAAQ,kBAAkB,UACvC,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,OAAO,UAAU;AAE/C;;;;;;;;;;;;AAaA,SAAgB,oBAId,QAA4D;CAC5D,OAAO,CAAC,CAAC,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE;AACjE;;;;;;;;;;;AAYA,SAAgB,uBAId,QAA2D;CAC3D,OAAO,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,KAAK;AACnE;;;;;;;;;;;AAYA,SAAgB,gCAId,QAAmD;CACnD,MAAM,WAAW,mBAAmB,MAAM;CAE1C,aAAa;EACX,IAAI,CAAC,UAAU;EACf,sBAAsB,MAAM;CAC9B;AACF;;;;;;;;;;;;AAaA,SAAgB,kBAGd,OAAyC,SAAiC;CAC1E,MAAM,QAAQ,mBAAmB,OAAO;AAC1C;;;;;;;;;;;;;AAcA,SAAgB,oBAGd,OAAyC,cAAwB;CACjE,kBACE,OACA,eAAe,CAAC,IAAI,WAAW,MAAM,aAAa,YAAY,CAAC,CAAC,CAClE;AACF;;;;;;;;;;;AAYA,SAAgB,iBAGd,KAA0D;CAC1D,OAAO,CAAC,CAAC,IAAI;AACf;;;;;;;;;;;;AAaA,SAAgB,qBAGd,KAA0D,UAAkB;CAC5E,IAAI,IAAI,wBAAwB,OAAO,IAAI,sBAAsB,QAAQ,GACvE,OAAO,IAAI,qBAAqB;CAGlC,MAAM,SAAS,IAAI,MAAM,UAAU,QAAQ;CAK3C,IAAI,CAAC,OAAO,UAAU,kBACpB,OAAO,IAAI,SAAS,QAAQ;CAG9B,IAAI,IAAI,sBACN,IAAI,qBAAqB,YAAY,OAAO,UAAU,iBACpD,IAAI,UACJ,IAAI,OACJ,GACF;CAGF,OAAO,IAAI,uBAAuB;AACpC;;;;;;;;;;;AAYA,SAAgB,kBAId,MAAsC;CACtC,MAAM,MAAM,KAAK;CACjB,OACE,oBAAoB,KAAK,MAAM,KAAK,KAAK,OAAO,OAAO,IAAI;AAE/D;;;;;;;;;;;;AAaA,SAAgB,sBAId,MAAsC;CACtC,OAAO,CAAC,kBAAkB,IAAI,KAAK,oBAAoB,KAAK,MAAM;AACpE"}
|
|
@@ -2,6 +2,7 @@ const require_utils = require('../../utils.cjs');
|
|
|
2
2
|
const require_coreColumnsFeature_utils = require('../../core/columns/coreColumnsFeature.utils.cjs');
|
|
3
3
|
const require_constructRow = require('../../core/rows/constructRow.cjs');
|
|
4
4
|
const require_rowPaginationFeature_utils = require('../row-pagination/rowPaginationFeature.utils.cjs');
|
|
5
|
+
const require_rowAggregationFeature_utils = require('../row-aggregation/rowAggregationFeature.utils.cjs');
|
|
5
6
|
const require_columnGroupingFeature_utils = require('./columnGroupingFeature.utils.cjs');
|
|
6
7
|
const require_rowExpandingFeature_utils = require('../row-expanding/rowExpandingFeature.utils.cjs');
|
|
7
8
|
|
|
@@ -10,19 +11,22 @@ const require_rowExpandingFeature_utils = require('../row-expanding/rowExpanding
|
|
|
10
11
|
* Creates a memoized grouped row model factory.
|
|
11
12
|
*
|
|
12
13
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
14
|
+
*
|
|
15
|
+
* When rowAggregationFeature is also registered, grouped rows use its shared
|
|
16
|
+
* executor for non-group values. Grouping remains useful without aggregation.
|
|
13
17
|
*/
|
|
14
|
-
function createGroupedRowModel(
|
|
18
|
+
function createGroupedRowModel() {
|
|
15
19
|
return (_table) => {
|
|
16
20
|
const table = _table;
|
|
17
|
-
if (!table._rowModelFns.aggregationFns) table._rowModelFns.aggregationFns = aggregationFns;
|
|
18
21
|
return require_utils.tableMemo({
|
|
19
22
|
feature: "columnGroupingFeature",
|
|
20
23
|
table,
|
|
21
24
|
fnName: "table.getGroupedRowModel",
|
|
22
|
-
memoDeps: () =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
memoDeps: () => [
|
|
26
|
+
table.atoms.grouping?.get(),
|
|
27
|
+
table.getPreGroupedRowModel(),
|
|
28
|
+
table.options.columns
|
|
29
|
+
],
|
|
26
30
|
fn: () => _createGroupedRowModel(table),
|
|
27
31
|
onAfterUpdate: () => {
|
|
28
32
|
require_rowExpandingFeature_utils.table_autoResetExpanded(table);
|
|
@@ -32,10 +36,9 @@ function createGroupedRowModel(aggregationFns) {
|
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
function _createGroupedRowModel(table) {
|
|
35
|
-
var _table$atoms$grouping2;
|
|
36
39
|
const rowModel = table.getPreGroupedRowModel();
|
|
37
|
-
const grouping =
|
|
38
|
-
if (!rowModel.rows.length || !
|
|
40
|
+
const grouping = table.atoms.grouping?.get();
|
|
41
|
+
if (!rowModel.rows.length || !grouping?.length) {
|
|
39
42
|
rowModel.rows.forEach((row) => {
|
|
40
43
|
row.depth = 0;
|
|
41
44
|
row.parentId = void 0;
|
|
@@ -44,13 +47,18 @@ function _createGroupedRowModel(table) {
|
|
|
44
47
|
}
|
|
45
48
|
const existingGrouping = grouping.filter((columnId) => require_coreColumnsFeature_utils.table_getColumn(table, columnId));
|
|
46
49
|
const groupedFlatRows = [];
|
|
47
|
-
const groupedRowsById =
|
|
50
|
+
const groupedRowsById = require_utils.makeObjectMap();
|
|
48
51
|
const groupUpRecursively = (rows, depth = 0, parentId) => {
|
|
49
52
|
if (depth >= existingGrouping.length) return rows.map((row) => {
|
|
50
53
|
row.depth = depth;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
if (row.subRows.length) {
|
|
55
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
56
|
+
for (let i = 0; i < row.subRows.length; i++) {
|
|
57
|
+
const subRow = row.subRows[i];
|
|
58
|
+
groupedFlatRows.push(subRow);
|
|
59
|
+
groupedRowsById[subRow.id] = subRow;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
54
62
|
return row;
|
|
55
63
|
});
|
|
56
64
|
const columnId = existingGrouping[depth];
|
|
@@ -62,7 +70,7 @@ function _createGroupedRowModel(table) {
|
|
|
62
70
|
subRows.forEach((subRow) => {
|
|
63
71
|
subRow.parentId = id;
|
|
64
72
|
});
|
|
65
|
-
const leafRows =
|
|
73
|
+
const leafRows = require_rowAggregationFeature_utils.normalizeAggregationRows(groupedRows, Infinity);
|
|
66
74
|
const row = require_constructRow.constructRow(table, id, leafRows[0].original, index, depth, void 0, parentId);
|
|
67
75
|
Object.assign(row, {
|
|
68
76
|
groupingColumnId: columnId,
|
|
@@ -70,19 +78,24 @@ function _createGroupedRowModel(table) {
|
|
|
70
78
|
subRows,
|
|
71
79
|
leafRows,
|
|
72
80
|
getValue: (colId) => {
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
if (row._valuesCache
|
|
81
|
+
const groupingIndex = existingGrouping.indexOf(colId);
|
|
82
|
+
if (groupingIndex !== -1 && groupingIndex <= depth) {
|
|
83
|
+
if (require_utils.hasOwn(row._valuesCache, colId)) return row._valuesCache[colId];
|
|
76
84
|
if (groupedRows[0]) row._valuesCache[colId] = groupedRows[0].getValue(colId) ?? void 0;
|
|
77
85
|
return row._valuesCache[colId];
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const aggregationCache = row._aggregationValuesCache;
|
|
88
|
+
if (aggregationCache && require_utils.hasOwn(aggregationCache, colId)) return aggregationCache[colId];
|
|
89
|
+
const column = table.getColumn(colId);
|
|
90
|
+
if (typeof column.getAggregationFns !== "function") return void 0;
|
|
91
|
+
const cache = row._aggregationValuesCache ??= require_utils.makeObjectMap();
|
|
92
|
+
cache[colId] = require_rowAggregationFeature_utils.aggregateColumnValue({
|
|
93
|
+
subRows,
|
|
94
|
+
column,
|
|
95
|
+
groupingRow: row,
|
|
96
|
+
rows: groupedRows
|
|
97
|
+
});
|
|
98
|
+
return cache[colId];
|
|
86
99
|
}
|
|
87
100
|
});
|
|
88
101
|
subRows.forEach((subRow) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGroupedRowModel.cjs","names":["tableMemo","table_getColumn","flattenBy","constructRow","column_getAggregationFn","row_getGroupingValue"],"sources":["../../../src/features/column-grouping/createGroupedRowModel.ts"],"sourcesContent":["import { flattenBy, tableMemo } from '../../utils'\nimport { constructRow } from '../../core/rows/constructRow'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport { table_autoResetExpanded } from '../row-expanding/rowExpandingFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport {\n column_getAggregationFn,\n row_getGroupingValue,\n} from './columnGroupingFeature.utils'\nimport type { Column } from '../../types/Column'\nimport type {\n AggregationFn,\n AggregationFns,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized grouped row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createGroupedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n aggregationFns: Record<keyof AggregationFns, AggregationFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n if (!table._rowModelFns.aggregationFns)\n table._rowModelFns.aggregationFns = aggregationFns\n return tableMemo({\n feature: 'columnGroupingFeature',\n table,\n fnName: 'table.getGroupedRowModel',\n memoDeps: () => [\n table.atoms.grouping?.get(),\n table.getPreGroupedRowModel(),\n ],\n fn: () => _createGroupedRowModel(table),\n onAfterUpdate: () => {\n table_autoResetExpanded(table)\n table_autoResetPageIndex(table)\n },\n })\n }\n}\n\nfunction _createGroupedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreGroupedRowModel()\n const grouping = table.atoms.grouping?.get()\n\n if (!rowModel.rows.length || !grouping?.length) {\n rowModel.rows.forEach((row) => {\n row.depth = 0\n row.parentId = undefined\n })\n return rowModel\n }\n\n // Filter the grouping list down to columns that exist\n const existingGrouping = grouping.filter((columnId) =>\n table_getColumn(table, columnId),\n )\n\n const groupedFlatRows: Array<Row<TFeatures, TData>> &\n Partial<Row_ColumnGrouping> = []\n const groupedRowsById: Record<string, Row<TFeatures, TData>> = {}\n\n // Recursively group the data\n const groupUpRecursively = (\n rows: Array<Row<TFeatures, TData>>,\n depth = 0,\n parentId?: string,\n ) => {\n // Grouping depth has been been met\n // Stop grouping and simply rewrite thd depth and row relationships\n if (depth >= existingGrouping.length) {\n return rows.map((row) => {\n row.depth = depth\n\n groupedFlatRows.push(row)\n groupedRowsById[row.id] = row\n\n if (row.subRows.length) {\n row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id)\n }\n\n return row\n })\n }\n\n const columnId = existingGrouping[depth] as string\n\n // Group the rows together for this level\n const rowGroupsMap = groupBy(rows, columnId)\n\n // Perform aggregations for each group\n const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map(\n ([groupingValue, groupedRows], index) => {\n let id = `${columnId}:${groupingValue}`\n id = parentId ? `${parentId}>${id}` : id\n\n // First, Recurse to group sub rows before aggregation\n const subRows = groupUpRecursively(groupedRows, depth + 1, id)\n\n subRows.forEach((subRow) => {\n subRow.parentId = id\n })\n\n // Flatten the leaf rows of the rows in this group\n const leafRows = depth\n ? flattenBy(groupedRows, (row) => row.subRows)\n : groupedRows\n\n const row = constructRow(\n table,\n id,\n leafRows[0]!.original,\n index,\n depth,\n undefined,\n parentId,\n ) as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n\n Object.assign(row, {\n groupingColumnId: columnId,\n groupingValue,\n subRows,\n leafRows,\n getValue: (colId: string) => {\n // Don't aggregate columns that are in the grouping\n if (existingGrouping.includes(colId)) {\n if (row._valuesCache.hasOwnProperty(colId)) {\n return row._valuesCache[colId]\n }\n\n if (groupedRows[0]) {\n row._valuesCache[colId] =\n groupedRows[0].getValue(colId) ?? undefined\n }\n\n return row._valuesCache[colId]\n }\n\n if (row._groupingValuesCache?.hasOwnProperty(colId)) {\n return row._groupingValuesCache[colId]\n }\n\n // Aggregate the values\n const column = table.getColumn(colId)\n const aggregateFn = column_getAggregationFn(\n column as Column<TFeatures, TData, unknown>,\n )\n\n if (!row._groupingValuesCache) row._groupingValuesCache = {}\n\n if (aggregateFn) {\n row._groupingValuesCache[colId] = aggregateFn(\n colId,\n leafRows,\n groupedRows,\n )\n\n return row._groupingValuesCache[colId]\n }\n },\n })\n\n subRows.forEach((subRow) => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n })\n\n return row\n },\n )\n\n return aggregatedGroupedRows\n }\n\n const groupedRows = groupUpRecursively(rowModel.rows, 0)\n\n groupedRows.forEach((subRow) => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n })\n\n return {\n rows: groupedRows,\n flatRows: groupedFlatRows,\n rowsById: groupedRowsById,\n }\n}\n\nfunction groupBy<TFeatures extends TableFeatures, TData extends RowData = any>(\n rows: Array<Row<TFeatures, TData>>,\n columnId: string,\n) {\n const groupMap = new Map<any, Array<Row<TFeatures, TData>>>()\n\n return rows.reduce((map, row) => {\n const resKey = `${row_getGroupingValue(row, columnId)}`\n const previous = map.get(resKey)\n if (!previous) {\n map.set(resKey, [row])\n } else {\n previous.push(row)\n }\n return map\n }, groupMap)\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"createGroupedRowModel.cjs","names":["tableMemo","table_getColumn","makeObjectMap","normalizeAggregationRows","constructRow","hasOwn","aggregateColumnValue","row_getGroupingValue"],"sources":["../../../src/features/column-grouping/createGroupedRowModel.ts"],"sourcesContent":["import { hasOwn, makeObjectMap, tableMemo } from '../../utils'\nimport { constructRow } from '../../core/rows/constructRow'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport { table_autoResetExpanded } from '../row-expanding/rowExpandingFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport {\n aggregateColumnValue,\n normalizeAggregationRows,\n} from '../row-aggregation/rowAggregationFeature.utils'\nimport { row_getGroupingValue } from './columnGroupingFeature.utils'\nimport type { Row_ColumnGrouping } from './columnGroupingFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized grouped row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n *\n * When rowAggregationFeature is also registered, grouped rows use its shared\n * executor for non-group values. Grouping remains useful without aggregation.\n */\nexport function createGroupedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'columnGroupingFeature',\n table,\n fnName: 'table.getGroupedRowModel',\n memoDeps: () => [\n table.atoms.grouping?.get(),\n table.getPreGroupedRowModel(),\n table.options.columns,\n ],\n fn: () => _createGroupedRowModel(table),\n onAfterUpdate: () => {\n table_autoResetExpanded(table)\n table_autoResetPageIndex(table)\n },\n })\n }\n}\n\nfunction _createGroupedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreGroupedRowModel()\n const grouping = table.atoms.grouping?.get()\n\n if (!rowModel.rows.length || !grouping?.length) {\n rowModel.rows.forEach((row) => {\n row.depth = 0\n row.parentId = undefined\n })\n return rowModel\n }\n\n // Filter the grouping list down to columns that exist\n const existingGrouping = grouping.filter((columnId) =>\n table_getColumn(table, columnId),\n )\n\n const groupedFlatRows: Array<Row<TFeatures, TData>> &\n Partial<Row_ColumnGrouping> = []\n const groupedRowsById = makeObjectMap<Row<TFeatures, TData>>()\n\n // Recursively group the data\n const groupUpRecursively = (\n rows: Array<Row<TFeatures, TData>>,\n depth = 0,\n parentId?: string,\n ) => {\n // Grouping depth has been been met\n // Stop grouping and simply rewrite thd depth and row relationships\n if (depth >= existingGrouping.length) {\n return rows.map((row) => {\n row.depth = depth\n\n // Every row is pushed into flatRows/rowsById exactly once, by its\n // parent frame: rows returned here are pushed by the caller (the\n // parent group's loop or the root loop), so only descendants below\n // the terminal depth are pushed here.\n if (row.subRows.length) {\n row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id)\n for (let i = 0; i < row.subRows.length; i++) {\n const subRow = row.subRows[i]!\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n }\n }\n\n return row\n })\n }\n\n const columnId = existingGrouping[depth] as string\n\n // Group the rows together for this level\n const rowGroupsMap = groupBy(rows, columnId)\n\n // Perform aggregations for each group\n const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map(\n ([groupingValue, groupedRows], index) => {\n let id = `${columnId}:${groupingValue}`\n id = parentId ? `${parentId}>${id}` : id\n\n // First, Recurse to group sub rows before aggregation\n const subRows = groupUpRecursively(groupedRows, depth + 1, id)\n\n subRows.forEach((subRow) => {\n subRow.parentId = id\n })\n\n const leafRows = normalizeAggregationRows(groupedRows, Infinity)\n\n const row = constructRow(\n table,\n id,\n leafRows[0]!.original,\n index,\n depth,\n undefined,\n parentId,\n ) as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n\n Object.assign(row, {\n groupingColumnId: columnId,\n groupingValue,\n subRows,\n leafRows,\n getValue: (colId: string) => {\n const groupingIndex = existingGrouping.indexOf(colId)\n\n // The active grouping column and ancestor grouping columns expose\n // their inherited grouping values. Columns grouped at deeper\n // levels are still eligible for aggregation here.\n if (groupingIndex !== -1 && groupingIndex <= depth) {\n if (hasOwn(row._valuesCache, colId)) {\n return row._valuesCache[colId]\n }\n\n if (groupedRows[0]) {\n row._valuesCache[colId] =\n groupedRows[0].getValue(colId) ?? undefined\n }\n\n return row._valuesCache[colId]\n }\n\n const aggregationCache = (row as any)._aggregationValuesCache as\n | Record<string, unknown>\n | undefined\n if (aggregationCache && hasOwn(aggregationCache, colId)) {\n return aggregationCache[colId]\n }\n\n const column = table.getColumn(colId) as any\n if (typeof column.getAggregationFns !== 'function') return undefined\n\n const cache = ((row as any)._aggregationValuesCache ??=\n makeObjectMap())\n cache[colId] = aggregateColumnValue({\n subRows,\n column,\n groupingRow: row,\n rows: groupedRows,\n })\n return cache[colId]\n },\n })\n\n subRows.forEach((subRow) => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n })\n\n return row\n },\n )\n\n return aggregatedGroupedRows\n }\n\n const groupedRows = groupUpRecursively(rowModel.rows, 0)\n\n groupedRows.forEach((subRow) => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n })\n\n return {\n rows: groupedRows,\n flatRows: groupedFlatRows,\n rowsById: groupedRowsById,\n }\n}\n\nfunction groupBy<TFeatures extends TableFeatures, TData extends RowData = any>(\n rows: Array<Row<TFeatures, TData>>,\n columnId: string,\n) {\n const groupMap = new Map<any, Array<Row<TFeatures, TData>>>()\n\n return rows.reduce((map, row) => {\n const resKey = `${row_getGroupingValue(row, columnId)}`\n const previous = map.get(resKey)\n if (!previous) {\n map.set(resKey, [row])\n } else {\n previous.push(row)\n }\n return map\n }, groupMap)\n}\n"],"mappings":"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"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.cjs";
|
|
2
|
-
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
3
|
-
import { Table } from "../../types/Table.cjs";
|
|
4
2
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.cjs";
|
|
5
|
-
import {
|
|
3
|
+
import { Table } from "../../types/Table.cjs";
|
|
4
|
+
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
6
5
|
|
|
7
6
|
//#region src/features/column-grouping/createGroupedRowModel.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Creates a memoized grouped row model factory.
|
|
10
9
|
*
|
|
11
10
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
11
|
+
*
|
|
12
|
+
* When rowAggregationFeature is also registered, grouped rows use its shared
|
|
13
|
+
* executor for non-group values. Grouping remains useful without aggregation.
|
|
12
14
|
*/
|
|
13
|
-
declare function createGroupedRowModel<TFeatures extends TableFeatures, TData extends RowData = any>(
|
|
15
|
+
declare function createGroupedRowModel<TFeatures extends TableFeatures, TData extends RowData = any>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData>;
|
|
14
16
|
//#endregion
|
|
15
17
|
export { createGroupedRowModel };
|
|
16
18
|
//# sourceMappingURL=createGroupedRowModel.d.cts.map
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
|
-
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
3
|
-
import { Table } from "../../types/Table.js";
|
|
4
2
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
5
|
-
import {
|
|
3
|
+
import { Table } from "../../types/Table.js";
|
|
4
|
+
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
6
5
|
|
|
7
6
|
//#region src/features/column-grouping/createGroupedRowModel.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Creates a memoized grouped row model factory.
|
|
10
9
|
*
|
|
11
10
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
11
|
+
*
|
|
12
|
+
* When rowAggregationFeature is also registered, grouped rows use its shared
|
|
13
|
+
* executor for non-group values. Grouping remains useful without aggregation.
|
|
12
14
|
*/
|
|
13
|
-
declare function createGroupedRowModel<TFeatures extends TableFeatures, TData extends RowData = any>(
|
|
15
|
+
declare function createGroupedRowModel<TFeatures extends TableFeatures, TData extends RowData = any>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData>;
|
|
14
16
|
//#endregion
|
|
15
17
|
export { createGroupedRowModel };
|
|
16
18
|
//# sourceMappingURL=createGroupedRowModel.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasOwn, makeObjectMap, tableMemo } from "../../utils.js";
|
|
2
2
|
import { table_getColumn } from "../../core/columns/coreColumnsFeature.utils.js";
|
|
3
3
|
import { constructRow } from "../../core/rows/constructRow.js";
|
|
4
4
|
import { table_autoResetPageIndex } from "../row-pagination/rowPaginationFeature.utils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { aggregateColumnValue, normalizeAggregationRows } from "../row-aggregation/rowAggregationFeature.utils.js";
|
|
6
|
+
import { row_getGroupingValue } from "./columnGroupingFeature.utils.js";
|
|
6
7
|
import { table_autoResetExpanded } from "../row-expanding/rowExpandingFeature.utils.js";
|
|
7
8
|
|
|
8
9
|
//#region src/features/column-grouping/createGroupedRowModel.ts
|
|
@@ -10,19 +11,22 @@ import { table_autoResetExpanded } from "../row-expanding/rowExpandingFeature.ut
|
|
|
10
11
|
* Creates a memoized grouped row model factory.
|
|
11
12
|
*
|
|
12
13
|
* The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
|
|
14
|
+
*
|
|
15
|
+
* When rowAggregationFeature is also registered, grouped rows use its shared
|
|
16
|
+
* executor for non-group values. Grouping remains useful without aggregation.
|
|
13
17
|
*/
|
|
14
|
-
function createGroupedRowModel(
|
|
18
|
+
function createGroupedRowModel() {
|
|
15
19
|
return (_table) => {
|
|
16
20
|
const table = _table;
|
|
17
|
-
if (!table._rowModelFns.aggregationFns) table._rowModelFns.aggregationFns = aggregationFns;
|
|
18
21
|
return tableMemo({
|
|
19
22
|
feature: "columnGroupingFeature",
|
|
20
23
|
table,
|
|
21
24
|
fnName: "table.getGroupedRowModel",
|
|
22
|
-
memoDeps: () =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
memoDeps: () => [
|
|
26
|
+
table.atoms.grouping?.get(),
|
|
27
|
+
table.getPreGroupedRowModel(),
|
|
28
|
+
table.options.columns
|
|
29
|
+
],
|
|
26
30
|
fn: () => _createGroupedRowModel(table),
|
|
27
31
|
onAfterUpdate: () => {
|
|
28
32
|
table_autoResetExpanded(table);
|
|
@@ -32,10 +36,9 @@ function createGroupedRowModel(aggregationFns) {
|
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
38
|
function _createGroupedRowModel(table) {
|
|
35
|
-
var _table$atoms$grouping2;
|
|
36
39
|
const rowModel = table.getPreGroupedRowModel();
|
|
37
|
-
const grouping =
|
|
38
|
-
if (!rowModel.rows.length || !
|
|
40
|
+
const grouping = table.atoms.grouping?.get();
|
|
41
|
+
if (!rowModel.rows.length || !grouping?.length) {
|
|
39
42
|
rowModel.rows.forEach((row) => {
|
|
40
43
|
row.depth = 0;
|
|
41
44
|
row.parentId = void 0;
|
|
@@ -44,13 +47,18 @@ function _createGroupedRowModel(table) {
|
|
|
44
47
|
}
|
|
45
48
|
const existingGrouping = grouping.filter((columnId) => table_getColumn(table, columnId));
|
|
46
49
|
const groupedFlatRows = [];
|
|
47
|
-
const groupedRowsById =
|
|
50
|
+
const groupedRowsById = makeObjectMap();
|
|
48
51
|
const groupUpRecursively = (rows, depth = 0, parentId) => {
|
|
49
52
|
if (depth >= existingGrouping.length) return rows.map((row) => {
|
|
50
53
|
row.depth = depth;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
if (row.subRows.length) {
|
|
55
|
+
row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id);
|
|
56
|
+
for (let i = 0; i < row.subRows.length; i++) {
|
|
57
|
+
const subRow = row.subRows[i];
|
|
58
|
+
groupedFlatRows.push(subRow);
|
|
59
|
+
groupedRowsById[subRow.id] = subRow;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
54
62
|
return row;
|
|
55
63
|
});
|
|
56
64
|
const columnId = existingGrouping[depth];
|
|
@@ -62,7 +70,7 @@ function _createGroupedRowModel(table) {
|
|
|
62
70
|
subRows.forEach((subRow) => {
|
|
63
71
|
subRow.parentId = id;
|
|
64
72
|
});
|
|
65
|
-
const leafRows =
|
|
73
|
+
const leafRows = normalizeAggregationRows(groupedRows, Infinity);
|
|
66
74
|
const row = constructRow(table, id, leafRows[0].original, index, depth, void 0, parentId);
|
|
67
75
|
Object.assign(row, {
|
|
68
76
|
groupingColumnId: columnId,
|
|
@@ -70,19 +78,24 @@ function _createGroupedRowModel(table) {
|
|
|
70
78
|
subRows,
|
|
71
79
|
leafRows,
|
|
72
80
|
getValue: (colId) => {
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
if (row._valuesCache
|
|
81
|
+
const groupingIndex = existingGrouping.indexOf(colId);
|
|
82
|
+
if (groupingIndex !== -1 && groupingIndex <= depth) {
|
|
83
|
+
if (hasOwn(row._valuesCache, colId)) return row._valuesCache[colId];
|
|
76
84
|
if (groupedRows[0]) row._valuesCache[colId] = groupedRows[0].getValue(colId) ?? void 0;
|
|
77
85
|
return row._valuesCache[colId];
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const aggregationCache = row._aggregationValuesCache;
|
|
88
|
+
if (aggregationCache && hasOwn(aggregationCache, colId)) return aggregationCache[colId];
|
|
89
|
+
const column = table.getColumn(colId);
|
|
90
|
+
if (typeof column.getAggregationFns !== "function") return void 0;
|
|
91
|
+
const cache = row._aggregationValuesCache ??= makeObjectMap();
|
|
92
|
+
cache[colId] = aggregateColumnValue({
|
|
93
|
+
subRows,
|
|
94
|
+
column,
|
|
95
|
+
groupingRow: row,
|
|
96
|
+
rows: groupedRows
|
|
97
|
+
});
|
|
98
|
+
return cache[colId];
|
|
86
99
|
}
|
|
87
100
|
});
|
|
88
101
|
subRows.forEach((subRow) => {
|