@tanstack/table-core 9.0.0-alpha.10 → 9.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/core/cells/constructCell.d.ts +7 -0
- package/dist/esm/core/cells/constructCell.js +21 -0
- package/dist/esm/core/cells/constructCell.js.map +1 -0
- package/dist/esm/core/cells/coreCellsFeature.d.ts +10 -0
- package/dist/esm/core/cells/coreCellsFeature.js +26 -0
- package/dist/esm/core/cells/coreCellsFeature.js.map +1 -0
- package/dist/esm/core/cells/coreCellsFeature.types.d.ts +52 -0
- package/dist/esm/core/cells/coreCellsFeature.utils.d.ts +13 -0
- package/dist/esm/core/cells/coreCellsFeature.utils.js +23 -0
- package/dist/esm/core/cells/coreCellsFeature.utils.js.map +1 -0
- package/dist/esm/core/columns/constructColumn.d.ts +6 -0
- package/dist/esm/core/columns/constructColumn.js +60 -0
- package/dist/esm/core/columns/constructColumn.js.map +1 -0
- package/dist/esm/core/columns/coreColumnsFeature.d.ts +10 -0
- package/dist/esm/core/columns/coreColumnsFeature.js +61 -0
- package/dist/esm/core/columns/coreColumnsFeature.js.map +1 -0
- package/dist/esm/core/columns/coreColumnsFeature.types.d.ts +84 -0
- package/dist/esm/core/columns/coreColumnsFeature.utils.d.ts +13 -0
- package/dist/esm/core/columns/coreColumnsFeature.utils.js +91 -0
- package/dist/esm/core/columns/coreColumnsFeature.utils.js.map +1 -0
- package/dist/esm/core/coreFeatures.d.ts +15 -0
- package/dist/esm/core/coreFeatures.js +18 -0
- package/dist/esm/core/coreFeatures.js.map +1 -0
- package/dist/esm/core/headers/buildHeaderGroups.d.ts +6 -0
- package/dist/esm/core/headers/buildHeaderGroups.js +99 -0
- package/dist/esm/core/headers/buildHeaderGroups.js.map +1 -0
- package/dist/esm/core/headers/constructHeader.d.ts +12 -0
- package/dist/esm/core/headers/constructHeader.js +28 -0
- package/dist/esm/core/headers/constructHeader.js.map +1 -0
- package/dist/esm/core/headers/coreHeadersFeature.d.ts +10 -0
- package/dist/esm/core/headers/coreHeadersFeature.js +68 -0
- package/dist/esm/core/headers/coreHeadersFeature.js.map +1 -0
- package/dist/esm/core/headers/coreHeadersFeature.types.d.ts +99 -0
- package/dist/esm/core/headers/coreHeadersFeature.utils.d.ts +15 -0
- package/dist/esm/core/headers/coreHeadersFeature.utils.js +85 -0
- package/dist/esm/core/headers/coreHeadersFeature.utils.js.map +1 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.d.ts +10 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.js +52 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.js.map +1 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.types.d.ts +39 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.utils.d.ts +16 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.utils.js +85 -0
- package/dist/esm/core/row-models/coreRowModelsFeature.utils.js.map +1 -0
- package/dist/esm/core/row-models/createCoreRowModel.d.ts +5 -0
- package/dist/esm/core/row-models/createCoreRowModel.js +54 -0
- package/dist/esm/core/row-models/createCoreRowModel.js.map +1 -0
- package/dist/esm/core/rows/constructRow.d.ts +5 -0
- package/dist/esm/core/rows/constructRow.js +29 -0
- package/dist/esm/core/rows/constructRow.js.map +1 -0
- package/dist/esm/core/rows/coreRowsFeature.d.ts +10 -0
- package/dist/esm/core/rows/coreRowsFeature.js +52 -0
- package/dist/esm/core/rows/coreRowsFeature.js.map +1 -0
- package/dist/esm/core/rows/coreRowsFeature.types.d.ts +91 -0
- package/dist/esm/core/rows/coreRowsFeature.utils.d.ts +15 -0
- package/dist/esm/core/rows/coreRowsFeature.utils.js +94 -0
- package/dist/esm/core/rows/coreRowsFeature.utils.js.map +1 -0
- package/dist/esm/core/table/constructTable.d.ts +9 -0
- package/dist/esm/core/table/constructTable.js +65 -0
- package/dist/esm/core/table/constructTable.js.map +1 -0
- package/dist/esm/core/table/coreTablesFeature.d.ts +10 -0
- package/dist/esm/core/table/coreTablesFeature.js +22 -0
- package/dist/esm/core/table/coreTablesFeature.js.map +1 -0
- package/dist/esm/core/table/coreTablesFeature.types.d.ts +105 -0
- package/dist/esm/core/table/coreTablesFeature.utils.d.ts +7 -0
- package/dist/esm/core/table/coreTablesFeature.utils.js +23 -0
- package/dist/esm/core/table/coreTablesFeature.utils.js.map +1 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.d.ts +10 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.js +80 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.js.map +1 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.types.d.ts +68 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.utils.d.ts +11 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.utils.js +33 -0
- package/dist/esm/features/column-faceting/columnFacetingFeature.utils.js.map +1 -0
- package/dist/esm/features/column-faceting/createFacetedMinMaxValues.d.ts +4 -0
- package/dist/esm/features/column-faceting/createFacetedMinMaxValues.js +41 -0
- package/dist/esm/features/column-faceting/createFacetedMinMaxValues.js.map +1 -0
- package/dist/esm/features/column-faceting/createFacetedRowModel.d.ts +5 -0
- package/dist/esm/features/column-faceting/createFacetedRowModel.js +47 -0
- package/dist/esm/features/column-faceting/createFacetedRowModel.js.map +1 -0
- package/dist/esm/features/column-faceting/createFacetedUniqueValues.d.ts +4 -0
- package/dist/esm/features/column-faceting/createFacetedUniqueValues.js +46 -0
- package/dist/esm/features/column-faceting/createFacetedUniqueValues.js.map +1 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.d.ts +11 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.js +69 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.js.map +1 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.types.d.ts +145 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.utils.d.ts +16 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.utils.js +118 -0
- package/dist/esm/features/column-filtering/columnFilteringFeature.utils.js.map +1 -0
- package/dist/esm/features/column-filtering/createFilteredRowModel.d.ts +6 -0
- package/dist/esm/features/column-filtering/createFilteredRowModel.js +110 -0
- package/dist/esm/features/column-filtering/createFilteredRowModel.js.map +1 -0
- package/dist/esm/features/column-filtering/filterRowsUtils.d.ts +6 -0
- package/dist/esm/{utils → features/column-filtering}/filterRowsUtils.js +15 -19
- package/dist/esm/features/column-filtering/filterRowsUtils.js.map +1 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.d.ts +10 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.js +91 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.js.map +1 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.types.d.ts +153 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.utils.d.ts +22 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.utils.js +99 -0
- package/dist/esm/features/column-grouping/columnGroupingFeature.utils.js.map +1 -0
- package/dist/esm/features/column-grouping/createGroupedRowModel.d.ts +6 -0
- package/dist/esm/features/column-grouping/createGroupedRowModel.js +144 -0
- package/dist/esm/features/column-grouping/createGroupedRowModel.js.map +1 -0
- package/dist/esm/features/column-ordering/columnOrderingFeature.d.ts +10 -0
- package/dist/esm/features/column-ordering/columnOrderingFeature.js +60 -0
- package/dist/esm/features/column-ordering/columnOrderingFeature.js.map +1 -0
- package/dist/{cjs/features/ColumnOrdering.d.cts → esm/features/column-ordering/columnOrderingFeature.types.d.ts} +8 -22
- package/dist/esm/features/column-ordering/columnOrderingFeature.utils.d.ts +14 -0
- package/dist/esm/features/column-ordering/columnOrderingFeature.utils.js +72 -0
- package/dist/esm/features/column-ordering/columnOrderingFeature.utils.js.map +1 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.d.ts +10 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.js +260 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.js.map +1 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.types.d.ts +157 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.utils.d.ts +39 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.utils.js +325 -0
- package/dist/esm/features/column-pinning/columnPinningFeature.utils.js.map +1 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.d.ts +11 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.js +52 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.js.map +1 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.types.d.ts +68 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.utils.d.ts +14 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.utils.js +193 -0
- package/dist/esm/features/column-resizing/columnResizingFeature.utils.js.map +1 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.d.ts +11 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.js +95 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.js.map +1 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.types.d.ts +81 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.utils.d.ts +25 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.utils.js +128 -0
- package/dist/esm/features/column-sizing/columnSizingFeature.utils.js.map +1 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.d.ts +10 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.js +100 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.js.map +1 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.types.d.ts +84 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.utils.d.ts +22 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.utils.js +105 -0
- package/dist/esm/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.d.ts +11 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.js +51 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.js.map +1 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.types.d.ts +59 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.utils.d.ts +10 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.utils.js +30 -0
- package/dist/esm/features/global-filtering/globalFilteringFeature.utils.js.map +1 -0
- package/dist/esm/features/row-expanding/createExpandedRowModel.d.ts +6 -0
- package/dist/esm/features/row-expanding/createExpandedRowModel.js +49 -0
- package/dist/esm/features/row-expanding/createExpandedRowModel.js.map +1 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.d.ts +10 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.js +74 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.js.map +1 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.types.d.ts +116 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.utils.d.ts +20 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.utils.js +125 -0
- package/dist/esm/features/row-expanding/rowExpandingFeature.utils.js.map +1 -0
- package/dist/esm/features/row-pagination/createPaginatedRowModel.d.ts +5 -0
- package/dist/esm/features/row-pagination/createPaginatedRowModel.js +58 -0
- package/dist/esm/features/row-pagination/createPaginatedRowModel.js.map +1 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.d.ts +10 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.js +78 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.js.map +1 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.types.d.ts +119 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.utils.d.ts +21 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.utils.js +126 -0
- package/dist/esm/features/row-pagination/rowPaginationFeature.utils.js.map +1 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.d.ts +10 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.js +80 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.js.map +1 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.types.d.ts +72 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.utils.d.ts +16 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.utils.js +115 -0
- package/dist/esm/features/row-pinning/rowPinningFeature.utils.js.map +1 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.d.ts +10 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.js +112 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.js.map +1 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.types.d.ts +123 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.utils.d.ts +34 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.utils.js +290 -0
- package/dist/esm/features/row-selection/rowSelectionFeature.utils.js.map +1 -0
- package/dist/esm/features/row-sorting/createSortedRowModel.d.ts +6 -0
- package/dist/esm/features/row-sorting/createSortedRowModel.js +94 -0
- package/dist/esm/features/row-sorting/createSortedRowModel.js.map +1 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.d.ts +10 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.js +82 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.js.map +1 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.types.d.ts +178 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.utils.d.ts +20 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.utils.js +181 -0
- package/dist/esm/features/row-sorting/rowSortingFeature.utils.js.map +1 -0
- package/dist/esm/features/stockFeatures.d.ts +31 -0
- package/dist/esm/features/stockFeatures.js +34 -0
- package/dist/esm/features/stockFeatures.js.map +1 -0
- package/dist/esm/fns/aggregationFns.d.ts +49 -0
- package/dist/esm/fns/aggregationFns.js +110 -0
- package/dist/esm/fns/aggregationFns.js.map +1 -0
- package/dist/esm/fns/filterFns.d.ts +76 -0
- package/dist/esm/fns/filterFns.js +134 -0
- package/dist/esm/fns/filterFns.js.map +1 -0
- package/dist/esm/fns/sortFns.d.ts +17 -0
- package/dist/esm/{sortingFns.js → fns/sortFns.js} +21 -15
- package/dist/esm/fns/sortFns.js.map +1 -0
- package/dist/esm/helpers/columnHelper.d.ts +61 -0
- package/dist/esm/{columnHelper.js → helpers/columnHelper.js} +1 -0
- package/dist/esm/helpers/columnHelper.js.map +1 -0
- package/dist/esm/helpers/tableFeatures.d.ts +13 -0
- package/dist/esm/helpers/tableFeatures.js +7 -0
- package/dist/esm/helpers/tableFeatures.js.map +1 -0
- package/dist/esm/helpers/tableHelper.d.ts +25 -0
- package/dist/esm/helpers/tableHelper.js +13 -0
- package/dist/esm/helpers/tableHelper.js.map +1 -0
- package/dist/esm/helpers/tableOptions.d.ts +23 -0
- package/dist/esm/helpers/tableOptions.js +7 -0
- package/dist/esm/helpers/tableOptions.js.map +1 -0
- package/dist/esm/index.d.ts +109 -33
- package/dist/esm/index.js +397 -66
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/Cell.d.ts +13 -0
- package/dist/esm/types/Column.d.ts +26 -0
- package/dist/esm/types/ColumnDef.d.ts +64 -0
- package/dist/esm/types/Header.d.ts +14 -0
- package/dist/esm/types/HeaderGroup.d.ts +12 -0
- package/dist/esm/types/Row.d.ts +19 -0
- package/dist/esm/types/RowModel.d.ts +23 -0
- package/dist/esm/types/RowModelFns.d.ts +15 -0
- package/dist/esm/types/Table.d.ts +53 -0
- package/dist/esm/types/TableFeatures.d.ts +77 -0
- package/dist/esm/types/TableOptions.d.ts +39 -0
- package/dist/esm/types/TableState.d.ts +23 -0
- package/dist/esm/types/type-utils.d.ts +22 -0
- package/dist/esm/utils.d.ts +66 -33
- package/dist/esm/utils.js +183 -50
- package/dist/esm/utils.js.map +1 -1
- package/package.json +21 -12
- package/src/core/cells/constructCell.ts +49 -0
- package/src/core/cells/coreCellsFeature.ts +44 -0
- package/src/core/cells/coreCellsFeature.types.ts +68 -0
- package/src/core/cells/coreCellsFeature.utils.ts +35 -0
- package/src/core/columns/constructColumn.ts +111 -0
- package/src/core/columns/coreColumnsFeature.ts +90 -0
- package/src/core/columns/coreColumnsFeature.types.ts +103 -0
- package/src/core/columns/coreColumnsFeature.utils.ts +160 -0
- package/src/core/coreFeatures.ts +24 -0
- package/src/core/headers/buildHeaderGroups.ts +177 -0
- package/src/core/headers/constructHeader.ts +61 -0
- package/src/core/headers/coreHeadersFeature.ts +98 -0
- package/src/core/headers/coreHeadersFeature.types.ts +123 -0
- package/src/core/headers/coreHeadersFeature.utils.ts +131 -0
- package/src/core/row-models/coreRowModelsFeature.ts +78 -0
- package/src/core/row-models/coreRowModelsFeature.types.ts +67 -0
- package/src/core/row-models/coreRowModelsFeature.utils.ts +140 -0
- package/src/core/row-models/createCoreRowModel.ts +88 -0
- package/src/core/rows/constructRow.ts +59 -0
- package/src/core/rows/coreRowsFeature.ts +84 -0
- package/src/core/rows/coreRowsFeature.types.ts +111 -0
- package/src/core/rows/coreRowsFeature.utils.ts +152 -0
- package/src/core/table/constructTable.ts +95 -0
- package/src/core/table/coreTablesFeature.ts +36 -0
- package/src/core/table/coreTablesFeature.types.ts +123 -0
- package/src/core/table/coreTablesFeature.utils.ts +40 -0
- package/src/features/column-faceting/columnFacetingFeature.ts +112 -0
- package/src/features/column-faceting/columnFacetingFeature.types.ts +97 -0
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +77 -0
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +63 -0
- package/src/features/column-faceting/createFacetedRowModel.ts +76 -0
- package/src/features/column-faceting/createFacetedUniqueValues.ts +60 -0
- package/src/features/column-filtering/columnFilteringFeature.ts +121 -0
- package/src/features/column-filtering/columnFilteringFeature.types.ts +219 -0
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +213 -0
- package/src/features/column-filtering/createFilteredRowModel.ts +171 -0
- package/src/features/column-filtering/filterRowsUtils.ts +152 -0
- package/src/features/column-grouping/columnGroupingFeature.ts +151 -0
- package/src/features/column-grouping/columnGroupingFeature.types.ts +218 -0
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +192 -0
- package/src/features/column-grouping/createGroupedRowModel.ts +215 -0
- package/src/features/column-ordering/columnOrderingFeature.ts +96 -0
- package/src/features/column-ordering/columnOrderingFeature.types.ts +49 -0
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +133 -0
- package/src/features/column-pinning/columnPinningFeature.ts +324 -0
- package/src/features/column-pinning/columnPinningFeature.types.ts +176 -0
- package/src/features/column-pinning/columnPinningFeature.utils.ts +537 -0
- package/src/features/column-resizing/columnResizingFeature.ts +92 -0
- package/src/features/column-resizing/columnResizingFeature.types.ts +81 -0
- package/src/features/column-resizing/columnResizingFeature.utils.ts +265 -0
- package/src/features/column-sizing/columnSizingFeature.ts +146 -0
- package/src/features/column-sizing/columnSizingFeature.types.ts +92 -0
- package/src/features/column-sizing/columnSizingFeature.utils.ts +211 -0
- package/src/features/column-visibility/columnVisibilityFeature.ts +155 -0
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +101 -0
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +183 -0
- package/src/features/global-filtering/globalFilteringFeature.ts +92 -0
- package/src/features/global-filtering/globalFilteringFeature.types.ts +84 -0
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +60 -0
- package/src/features/row-expanding/createExpandedRowModel.ts +72 -0
- package/src/features/row-expanding/rowExpandingFeature.ts +122 -0
- package/src/features/row-expanding/rowExpandingFeature.types.ts +141 -0
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +207 -0
- package/src/features/row-pagination/createPaginatedRowModel.ts +78 -0
- package/src/features/row-pagination/rowPaginationFeature.ts +121 -0
- package/src/features/row-pagination/rowPaginationFeature.types.ts +141 -0
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +204 -0
- package/src/features/row-pinning/rowPinningFeature.ts +121 -0
- package/src/features/row-pinning/rowPinningFeature.types.ts +89 -0
- package/src/features/row-pinning/rowPinningFeature.utils.ts +197 -0
- package/src/features/row-selection/rowSelectionFeature.ts +164 -0
- package/src/features/row-selection/rowSelectionFeature.types.ts +143 -0
- package/src/features/row-selection/rowSelectionFeature.utils.ts +464 -0
- package/src/features/row-sorting/createSortedRowModel.ts +147 -0
- package/src/features/row-sorting/rowSortingFeature.ts +136 -0
- package/src/features/row-sorting/rowSortingFeature.types.ts +229 -0
- package/src/features/row-sorting/rowSortingFeature.utils.ts +320 -0
- package/src/features/stockFeatures.ts +48 -0
- package/src/fns/aggregationFns.ts +220 -0
- package/src/fns/filterFns.ts +379 -0
- package/src/{sortingFns.ts → fns/sortFns.ts} +66 -21
- package/src/helpers/columnHelper.ts +117 -0
- package/src/helpers/tableFeatures.ts +24 -0
- package/src/helpers/tableHelper.ts +61 -0
- package/src/helpers/tableOptions.ts +82 -0
- package/src/index.ts +156 -42
- package/src/types/Cell.ts +41 -0
- package/src/types/Column.ts +86 -0
- package/src/types/ColumnDef.ts +217 -0
- package/src/types/Header.ts +45 -0
- package/src/types/HeaderGroup.ts +24 -0
- package/src/types/Row.ts +55 -0
- package/src/types/RowModel.ts +137 -0
- package/src/types/RowModelFns.ts +51 -0
- package/src/types/Table.ts +125 -0
- package/src/types/TableFeatures.ts +150 -0
- package/src/types/TableOptions.ts +125 -0
- package/src/types/TableState.ts +88 -0
- package/src/types/type-utils.ts +84 -0
- package/src/utils.ts +344 -164
- package/dist/cjs/aggregationFns.cjs +0 -94
- package/dist/cjs/aggregationFns.cjs.map +0 -1
- package/dist/cjs/aggregationFns.d.cts +0 -14
- package/dist/cjs/columnHelper.cjs +0 -19
- package/dist/cjs/columnHelper.cjs.map +0 -1
- package/dist/cjs/columnHelper.d.cts +0 -9
- package/dist/cjs/core/cell.cjs +0 -38
- package/dist/cjs/core/cell.cjs.map +0 -1
- package/dist/cjs/core/cell.d.cts +0 -50
- package/dist/cjs/core/column.cjs +0 -81
- package/dist/cjs/core/column.cjs.map +0 -1
- package/dist/cjs/core/column.d.cts +0 -56
- package/dist/cjs/core/headers.cjs +0 -310
- package/dist/cjs/core/headers.cjs.map +0 -1
- package/dist/cjs/core/headers.d.cts +0 -195
- package/dist/cjs/core/row.cjs +0 -92
- package/dist/cjs/core/row.cjs.map +0 -1
- package/dist/cjs/core/row.d.cts +0 -92
- package/dist/cjs/core/table.cjs +0 -232
- package/dist/cjs/core/table.cjs.map +0 -1
- package/dist/cjs/core/table.d.cts +0 -229
- package/dist/cjs/features/ColumnFaceting.cjs +0 -29
- package/dist/cjs/features/ColumnFaceting.cjs.map +0 -1
- package/dist/cjs/features/ColumnFaceting.d.cts +0 -35
- package/dist/cjs/features/ColumnFiltering.cjs +0 -137
- package/dist/cjs/features/ColumnFiltering.cjs.map +0 -1
- package/dist/cjs/features/ColumnFiltering.d.cts +0 -195
- package/dist/cjs/features/ColumnGrouping.cjs +0 -133
- package/dist/cjs/features/ColumnGrouping.cjs.map +0 -1
- package/dist/cjs/features/ColumnGrouping.d.cts +0 -202
- package/dist/cjs/features/ColumnOrdering.cjs +0 -76
- package/dist/cjs/features/ColumnOrdering.cjs.map +0 -1
- package/dist/cjs/features/ColumnPinning.cjs +0 -145
- package/dist/cjs/features/ColumnPinning.cjs.map +0 -1
- package/dist/cjs/features/ColumnPinning.d.cts +0 -127
- package/dist/cjs/features/ColumnSizing.cjs +0 -307
- package/dist/cjs/features/ColumnSizing.cjs.map +0 -1
- package/dist/cjs/features/ColumnSizing.d.cts +0 -194
- package/dist/cjs/features/ColumnVisibility.cjs +0 -144
- package/dist/cjs/features/ColumnVisibility.cjs.map +0 -1
- package/dist/cjs/features/ColumnVisibility.d.cts +0 -130
- package/dist/cjs/features/GlobalFaceting.cjs +0 -29
- package/dist/cjs/features/GlobalFaceting.cjs.map +0 -1
- package/dist/cjs/features/GlobalFaceting.d.cts +0 -27
- package/dist/cjs/features/GlobalFiltering.cjs +0 -50
- package/dist/cjs/features/GlobalFiltering.cjs.map +0 -1
- package/dist/cjs/features/GlobalFiltering.d.cts +0 -80
- package/dist/cjs/features/RowExpanding.cjs +0 -152
- package/dist/cjs/features/RowExpanding.cjs.map +0 -1
- package/dist/cjs/features/RowExpanding.d.cts +0 -155
- package/dist/cjs/features/RowPagination.cjs +0 -161
- package/dist/cjs/features/RowPagination.cjs.map +0 -1
- package/dist/cjs/features/RowPagination.d.cts +0 -166
- package/dist/cjs/features/RowPinning.cjs +0 -132
- package/dist/cjs/features/RowPinning.cjs.map +0 -1
- package/dist/cjs/features/RowPinning.d.cts +0 -99
- package/dist/cjs/features/RowSelection.cjs +0 -296
- package/dist/cjs/features/RowSelection.cjs.map +0 -1
- package/dist/cjs/features/RowSelection.d.cts +0 -177
- package/dist/cjs/features/RowSorting.cjs +0 -200
- package/dist/cjs/features/RowSorting.cjs.map +0 -1
- package/dist/cjs/features/RowSorting.d.cts +0 -238
- package/dist/cjs/filterFns.cjs +0 -88
- package/dist/cjs/filterFns.cjs.map +0 -1
- package/dist/cjs/filterFns.d.cts +0 -14
- package/dist/cjs/index.cjs +0 -88
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -34
- package/dist/cjs/sortingFns.cjs +0 -91
- package/dist/cjs/sortingFns.cjs.map +0 -1
- package/dist/cjs/sortingFns.d.cts +0 -12
- package/dist/cjs/types.d.cts +0 -120
- package/dist/cjs/utils/filterRowsUtils.cjs +0 -99
- package/dist/cjs/utils/filterRowsUtils.cjs.map +0 -1
- package/dist/cjs/utils/filterRowsUtils.d.cts +0 -3
- package/dist/cjs/utils/getCoreRowModel.cjs +0 -54
- package/dist/cjs/utils/getCoreRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getCoreRowModel.d.cts +0 -3
- package/dist/cjs/utils/getExpandedRowModel.cjs +0 -41
- package/dist/cjs/utils/getExpandedRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getExpandedRowModel.d.cts +0 -8
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs +0 -35
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +0 -1
- package/dist/cjs/utils/getFacetedMinMaxValues.d.cts +0 -3
- package/dist/cjs/utils/getFacetedRowModel.cjs +0 -35
- package/dist/cjs/utils/getFacetedRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getFacetedRowModel.d.cts +0 -3
- package/dist/cjs/utils/getFacetedUniqueValues.cjs +0 -37
- package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +0 -1
- package/dist/cjs/utils/getFacetedUniqueValues.d.cts +0 -3
- package/dist/cjs/utils/getFilteredRowModel.cjs +0 -116
- package/dist/cjs/utils/getFilteredRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getFilteredRowModel.d.cts +0 -3
- package/dist/cjs/utils/getGroupedRowModel.cjs +0 -118
- package/dist/cjs/utils/getGroupedRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getGroupedRowModel.d.cts +0 -3
- package/dist/cjs/utils/getPaginationRowModel.cjs +0 -49
- package/dist/cjs/utils/getPaginationRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getPaginationRowModel.d.cts +0 -5
- package/dist/cjs/utils/getSortedRowModel.cjs +0 -88
- package/dist/cjs/utils/getSortedRowModel.cjs.map +0 -1
- package/dist/cjs/utils/getSortedRowModel.d.cts +0 -3
- package/dist/cjs/utils.cjs +0 -98
- package/dist/cjs/utils.cjs.map +0 -1
- package/dist/cjs/utils.d.cts +0 -39
- package/dist/esm/aggregationFns.d.ts +0 -14
- package/dist/esm/aggregationFns.js +0 -94
- package/dist/esm/aggregationFns.js.map +0 -1
- package/dist/esm/columnHelper.d.ts +0 -9
- package/dist/esm/columnHelper.js.map +0 -1
- package/dist/esm/core/cell.d.ts +0 -50
- package/dist/esm/core/cell.js +0 -38
- package/dist/esm/core/cell.js.map +0 -1
- package/dist/esm/core/column.d.ts +0 -56
- package/dist/esm/core/column.js +0 -81
- package/dist/esm/core/column.js.map +0 -1
- package/dist/esm/core/headers.d.ts +0 -195
- package/dist/esm/core/headers.js +0 -310
- package/dist/esm/core/headers.js.map +0 -1
- package/dist/esm/core/row.d.ts +0 -92
- package/dist/esm/core/row.js +0 -92
- package/dist/esm/core/row.js.map +0 -1
- package/dist/esm/core/table.d.ts +0 -229
- package/dist/esm/core/table.js +0 -232
- package/dist/esm/core/table.js.map +0 -1
- package/dist/esm/features/ColumnFaceting.d.ts +0 -35
- package/dist/esm/features/ColumnFaceting.js +0 -29
- package/dist/esm/features/ColumnFaceting.js.map +0 -1
- package/dist/esm/features/ColumnFiltering.d.ts +0 -195
- package/dist/esm/features/ColumnFiltering.js +0 -137
- package/dist/esm/features/ColumnFiltering.js.map +0 -1
- package/dist/esm/features/ColumnGrouping.d.ts +0 -202
- package/dist/esm/features/ColumnGrouping.js +0 -133
- package/dist/esm/features/ColumnGrouping.js.map +0 -1
- package/dist/esm/features/ColumnOrdering.d.ts +0 -54
- package/dist/esm/features/ColumnOrdering.js +0 -76
- package/dist/esm/features/ColumnOrdering.js.map +0 -1
- package/dist/esm/features/ColumnPinning.d.ts +0 -127
- package/dist/esm/features/ColumnPinning.js +0 -145
- package/dist/esm/features/ColumnPinning.js.map +0 -1
- package/dist/esm/features/ColumnSizing.d.ts +0 -194
- package/dist/esm/features/ColumnSizing.js +0 -307
- package/dist/esm/features/ColumnSizing.js.map +0 -1
- package/dist/esm/features/ColumnVisibility.d.ts +0 -130
- package/dist/esm/features/ColumnVisibility.js +0 -144
- package/dist/esm/features/ColumnVisibility.js.map +0 -1
- package/dist/esm/features/GlobalFaceting.d.ts +0 -27
- package/dist/esm/features/GlobalFaceting.js +0 -29
- package/dist/esm/features/GlobalFaceting.js.map +0 -1
- package/dist/esm/features/GlobalFiltering.d.ts +0 -80
- package/dist/esm/features/GlobalFiltering.js +0 -50
- package/dist/esm/features/GlobalFiltering.js.map +0 -1
- package/dist/esm/features/RowExpanding.d.ts +0 -155
- package/dist/esm/features/RowExpanding.js +0 -152
- package/dist/esm/features/RowExpanding.js.map +0 -1
- package/dist/esm/features/RowPagination.d.ts +0 -166
- package/dist/esm/features/RowPagination.js +0 -161
- package/dist/esm/features/RowPagination.js.map +0 -1
- package/dist/esm/features/RowPinning.d.ts +0 -99
- package/dist/esm/features/RowPinning.js +0 -132
- package/dist/esm/features/RowPinning.js.map +0 -1
- package/dist/esm/features/RowSelection.d.ts +0 -177
- package/dist/esm/features/RowSelection.js +0 -296
- package/dist/esm/features/RowSelection.js.map +0 -1
- package/dist/esm/features/RowSorting.d.ts +0 -238
- package/dist/esm/features/RowSorting.js +0 -200
- package/dist/esm/features/RowSorting.js.map +0 -1
- package/dist/esm/filterFns.d.ts +0 -14
- package/dist/esm/filterFns.js +0 -88
- package/dist/esm/filterFns.js.map +0 -1
- package/dist/esm/sortingFns.d.ts +0 -12
- package/dist/esm/sortingFns.js.map +0 -1
- package/dist/esm/types.d.ts +0 -120
- package/dist/esm/utils/filterRowsUtils.d.ts +0 -3
- package/dist/esm/utils/filterRowsUtils.js.map +0 -1
- package/dist/esm/utils/getCoreRowModel.d.ts +0 -3
- package/dist/esm/utils/getCoreRowModel.js +0 -54
- package/dist/esm/utils/getCoreRowModel.js.map +0 -1
- package/dist/esm/utils/getExpandedRowModel.d.ts +0 -8
- package/dist/esm/utils/getExpandedRowModel.js +0 -41
- package/dist/esm/utils/getExpandedRowModel.js.map +0 -1
- package/dist/esm/utils/getFacetedMinMaxValues.d.ts +0 -3
- package/dist/esm/utils/getFacetedMinMaxValues.js +0 -35
- package/dist/esm/utils/getFacetedMinMaxValues.js.map +0 -1
- package/dist/esm/utils/getFacetedRowModel.d.ts +0 -3
- package/dist/esm/utils/getFacetedRowModel.js +0 -35
- package/dist/esm/utils/getFacetedRowModel.js.map +0 -1
- package/dist/esm/utils/getFacetedUniqueValues.d.ts +0 -3
- package/dist/esm/utils/getFacetedUniqueValues.js +0 -37
- package/dist/esm/utils/getFacetedUniqueValues.js.map +0 -1
- package/dist/esm/utils/getFilteredRowModel.d.ts +0 -3
- package/dist/esm/utils/getFilteredRowModel.js +0 -116
- package/dist/esm/utils/getFilteredRowModel.js.map +0 -1
- package/dist/esm/utils/getGroupedRowModel.d.ts +0 -3
- package/dist/esm/utils/getGroupedRowModel.js +0 -118
- package/dist/esm/utils/getGroupedRowModel.js.map +0 -1
- package/dist/esm/utils/getPaginationRowModel.d.ts +0 -5
- package/dist/esm/utils/getPaginationRowModel.js +0 -49
- package/dist/esm/utils/getPaginationRowModel.js.map +0 -1
- package/dist/esm/utils/getSortedRowModel.d.ts +0 -3
- package/dist/esm/utils/getSortedRowModel.js +0 -88
- package/dist/esm/utils/getSortedRowModel.js.map +0 -1
- package/src/aggregationFns.ts +0 -123
- package/src/columnHelper.ts +0 -91
- package/src/core/cell.ts +0 -91
- package/src/core/column.ts +0 -165
- package/src/core/headers.ts +0 -639
- package/src/core/row.ts +0 -201
- package/src/core/table.ts +0 -563
- package/src/features/ColumnFaceting.ts +0 -84
- package/src/features/ColumnFiltering.ts +0 -429
- package/src/features/ColumnGrouping.ts +0 -422
- package/src/features/ColumnOrdering.ts +0 -161
- package/src/features/ColumnPinning.ts +0 -336
- package/src/features/ColumnSizing.ts +0 -579
- package/src/features/ColumnVisibility.ts +0 -317
- package/src/features/GlobalFaceting.ts +0 -66
- package/src/features/GlobalFiltering.ts +0 -162
- package/src/features/RowExpanding.ts +0 -355
- package/src/features/RowPagination.ts +0 -396
- package/src/features/RowPinning.ts +0 -277
- package/src/features/RowSelection.ts +0 -668
- package/src/features/RowSorting.ts +0 -542
- package/src/filterFns.ts +0 -150
- package/src/types.ts +0 -361
- package/src/utils/filterRowsUtils.ts +0 -130
- package/src/utils/getCoreRowModel.ts +0 -82
- package/src/utils/getExpandedRowModel.ts +0 -51
- package/src/utils/getFacetedMinMaxValues.ts +0 -42
- package/src/utils/getFacetedRowModel.ts +0 -44
- package/src/utils/getFacetedUniqueValues.ts +0 -42
- package/src/utils/getFilteredRowModel.ts +0 -151
- package/src/utils/getGroupedRowModel.ts +0 -181
- package/src/utils/getPaginationRowModel.ts +0 -60
- package/src/utils/getSortedRowModel.ts +0 -121
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { RowModel } from '../../core/row-models/coreRowModelsFeature.types';
|
|
2
|
+
import { Table } from '../../types/Table.js';
|
|
3
|
+
import { OnChangeFn, RowData, Updater } from '../../types/type-utils.js';
|
|
4
|
+
import { TableFeatures } from '../../types/TableFeatures.js';
|
|
5
|
+
export interface PaginationState {
|
|
6
|
+
pageIndex: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TableState_RowPagination {
|
|
10
|
+
pagination: PaginationState;
|
|
11
|
+
}
|
|
12
|
+
export interface TableOptions_RowPagination {
|
|
13
|
+
/**
|
|
14
|
+
* If set to `true`, pagination will be reset to the first page when page-altering state changes eg. `data` is updated, filters change, grouping changes, etc.
|
|
15
|
+
*/
|
|
16
|
+
autoResetPageIndex?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enables manual pagination. If this option is set to `true`, the table will not automatically paginate rows using `getPaginatedRowModel()` and instead will expect you to manually paginate the rows before passing them to the table. This is useful if you are doing server-side pagination and aggregation.
|
|
19
|
+
*/
|
|
20
|
+
manualPagination?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If this function is provided, it will be called when the pagination state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the `tableOptions.state.pagination` option.
|
|
23
|
+
*/
|
|
24
|
+
onPaginationChange?: OnChangeFn<PaginationState>;
|
|
25
|
+
/**
|
|
26
|
+
* When manually controlling pagination, you can supply a total `pageCount` value to the table if you know it (Or supply a `rowCount` and `pageCount` will be calculated). If you do not know how many pages there are, you can set this to `-1`.
|
|
27
|
+
*/
|
|
28
|
+
pageCount?: number;
|
|
29
|
+
/**
|
|
30
|
+
* When manually controlling pagination, you can supply a total `rowCount` value to the table if you know it. The `pageCount` can be calculated from this value and the `pageSize`.
|
|
31
|
+
*/
|
|
32
|
+
rowCount?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface PaginationDefaultOptions {
|
|
35
|
+
onPaginationChange: OnChangeFn<PaginationState>;
|
|
36
|
+
}
|
|
37
|
+
export interface Table_RowPagination<TFeatures extends TableFeatures, TData extends RowData> {
|
|
38
|
+
_autoResetPageIndex: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Returns whether the table can go to the next page.
|
|
41
|
+
*/
|
|
42
|
+
getCanNextPage: () => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Returns whether the table can go to the previous page.
|
|
45
|
+
*/
|
|
46
|
+
getCanPreviousPage: () => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the page count. If manually paginating or controlling the pagination state, this will come directly from the `options.pageCount` table option, otherwise it will be calculated from the table data using the total row count and current page size.
|
|
49
|
+
*/
|
|
50
|
+
getPageCount: () => number;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the row count. If manually paginating or controlling the pagination state, this will come directly from the `options.rowCount` table option, otherwise it will be calculated from the table data.
|
|
53
|
+
*/
|
|
54
|
+
getRowCount: () => number;
|
|
55
|
+
/**
|
|
56
|
+
* Returns an array of page options (zero-index-based) for the current page size.
|
|
57
|
+
*/
|
|
58
|
+
getPageOptions: () => Array<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Increments the page index by one, if possible.
|
|
61
|
+
*/
|
|
62
|
+
nextPage: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Decrements the page index by one, if possible.
|
|
65
|
+
*/
|
|
66
|
+
previousPage: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the page index to `0`.
|
|
69
|
+
*/
|
|
70
|
+
firstPage: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the page index to the last page.
|
|
73
|
+
*/
|
|
74
|
+
lastPage: () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Resets the page index to its initial state. If `defaultState` is `true`, the page index will be reset to `0` regardless of initial state.
|
|
77
|
+
*/
|
|
78
|
+
resetPageIndex: (defaultState?: boolean) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Resets the page size to its initial state. If `defaultState` is `true`, the page size will be reset to `10` regardless of initial state.
|
|
81
|
+
*/
|
|
82
|
+
resetPageSize: (defaultState?: boolean) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Resets the **pagination** state to `initialState.pagination`, or `true` can be passed to force a default blank state reset to `[]`.
|
|
85
|
+
*/
|
|
86
|
+
resetPagination: (defaultState?: boolean) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Updates the page index using the provided function or value in the `state.pagination.pageIndex` state.
|
|
89
|
+
*/
|
|
90
|
+
setPageIndex: (updater: Updater<number>) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Updates the page size using the provided function or value in the `state.pagination.pageSize` state.
|
|
93
|
+
*/
|
|
94
|
+
setPageSize: (updater: Updater<number>) => void;
|
|
95
|
+
/**
|
|
96
|
+
* Sets or updates the `state.pagination` state.
|
|
97
|
+
*/
|
|
98
|
+
setPagination: (updater: Updater<PaginationState>) => void;
|
|
99
|
+
}
|
|
100
|
+
export interface Table_RowModels_Paginated<TFeatures extends TableFeatures, TData extends RowData> {
|
|
101
|
+
/**
|
|
102
|
+
* Returns the row model for the table after pagination has been applied.
|
|
103
|
+
*/
|
|
104
|
+
getPaginatedRowModel: () => RowModel<TFeatures, TData>;
|
|
105
|
+
/**
|
|
106
|
+
* Returns the row model for the table before any pagination has been applied.
|
|
107
|
+
*/
|
|
108
|
+
getPrePaginatedRowModel: () => RowModel<TFeatures, TData>;
|
|
109
|
+
}
|
|
110
|
+
export interface CreateRowModel_Paginated<TFeatures extends TableFeatures, TData extends RowData> {
|
|
111
|
+
/**
|
|
112
|
+
* Returns the row model after pagination has taken place, but no further.
|
|
113
|
+
* Pagination columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.
|
|
114
|
+
*/
|
|
115
|
+
paginatedRowModel?: (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData>;
|
|
116
|
+
}
|
|
117
|
+
export interface CachedRowModel_Paginated<TFeatures extends TableFeatures, TData extends RowData> {
|
|
118
|
+
paginatedRowModel: () => RowModel<TFeatures, TData>;
|
|
119
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RowData, Updater } from '../../types/type-utils.js';
|
|
2
|
+
import { TableFeatures } from '../../types/TableFeatures.js';
|
|
3
|
+
import { Table_Internal } from '../../types/Table.js';
|
|
4
|
+
import { PaginationState } from './rowPaginationFeature.types';
|
|
5
|
+
export declare function getDefaultPaginationState(): PaginationState;
|
|
6
|
+
export declare function table_autoResetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
7
|
+
export declare function table_setPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<PaginationState>): void | undefined;
|
|
8
|
+
export declare function table_resetPagination<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
9
|
+
export declare function table_setPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>): void;
|
|
10
|
+
export declare function table_resetPageIndex<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
11
|
+
export declare function table_resetPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
12
|
+
export declare function table_setPageSize<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>): void;
|
|
13
|
+
export declare function table_getPageOptions<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number[];
|
|
14
|
+
export declare function table_getCanPreviousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
|
|
15
|
+
export declare function table_getCanNextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
|
|
16
|
+
export declare function table_previousPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
17
|
+
export declare function table_nextPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
18
|
+
export declare function table_firstPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
19
|
+
export declare function table_lastPage<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
20
|
+
export declare function table_getPageCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
|
|
21
|
+
export declare function table_getRowCount<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { functionalUpdate } from "../../utils.js";
|
|
2
|
+
const defaultPageIndex = 0;
|
|
3
|
+
const defaultPageSize = 10;
|
|
4
|
+
function getDefaultPaginationState() {
|
|
5
|
+
return structuredClone({
|
|
6
|
+
pageIndex: defaultPageIndex,
|
|
7
|
+
pageSize: defaultPageSize
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function table_autoResetPageIndex(table) {
|
|
11
|
+
if (table.options.autoResetAll ?? table.options.autoResetPageIndex ?? !table.options.manualPagination) {
|
|
12
|
+
table_resetPageIndex(table);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function table_setPagination(table, updater) {
|
|
16
|
+
const safeUpdater = (old) => {
|
|
17
|
+
const newState = functionalUpdate(updater, old);
|
|
18
|
+
return newState;
|
|
19
|
+
};
|
|
20
|
+
return table.options.onPaginationChange?.(safeUpdater);
|
|
21
|
+
}
|
|
22
|
+
function table_resetPagination(table, defaultState) {
|
|
23
|
+
table_setPagination(
|
|
24
|
+
table,
|
|
25
|
+
defaultState ? getDefaultPaginationState() : table.initialState.pagination ?? getDefaultPaginationState()
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function table_setPageIndex(table, updater) {
|
|
29
|
+
table_setPagination(table, (old) => {
|
|
30
|
+
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
31
|
+
const maxPageIndex = typeof table.options.pageCount === "undefined" || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
|
|
32
|
+
pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
|
|
33
|
+
return {
|
|
34
|
+
...old,
|
|
35
|
+
pageIndex
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function table_resetPageIndex(table, defaultState) {
|
|
40
|
+
table_setPageIndex(
|
|
41
|
+
table,
|
|
42
|
+
defaultState ? defaultPageIndex : table.initialState.pagination?.pageIndex ?? defaultPageIndex
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function table_resetPageSize(table, defaultState) {
|
|
46
|
+
table_setPageSize(
|
|
47
|
+
table,
|
|
48
|
+
defaultState ? defaultPageSize : table.initialState.pagination?.pageSize ?? defaultPageSize
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function table_setPageSize(table, updater) {
|
|
52
|
+
table_setPagination(table, (old) => {
|
|
53
|
+
const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
|
|
54
|
+
const topRowIndex = old.pageSize * old.pageIndex;
|
|
55
|
+
const pageIndex = Math.floor(topRowIndex / pageSize);
|
|
56
|
+
return {
|
|
57
|
+
...old,
|
|
58
|
+
pageIndex,
|
|
59
|
+
pageSize
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function table_getPageOptions(table) {
|
|
64
|
+
const pageCount = table_getPageCount(table);
|
|
65
|
+
let pageOptions = [];
|
|
66
|
+
if (pageCount && pageCount > 0) {
|
|
67
|
+
pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
|
|
68
|
+
}
|
|
69
|
+
return pageOptions;
|
|
70
|
+
}
|
|
71
|
+
function table_getCanPreviousPage(table) {
|
|
72
|
+
return (table.store.state.pagination?.pageIndex ?? 0) > 0;
|
|
73
|
+
}
|
|
74
|
+
function table_getCanNextPage(table) {
|
|
75
|
+
const pageIndex = table.store.state.pagination?.pageIndex ?? defaultPageIndex;
|
|
76
|
+
const pageCount = table_getPageCount(table);
|
|
77
|
+
if (pageCount === -1) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (pageCount === 0) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return pageIndex < pageCount - 1;
|
|
84
|
+
}
|
|
85
|
+
function table_previousPage(table) {
|
|
86
|
+
return table_setPageIndex(table, (old) => old - 1);
|
|
87
|
+
}
|
|
88
|
+
function table_nextPage(table) {
|
|
89
|
+
return table_setPageIndex(table, (old) => {
|
|
90
|
+
return old + 1;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function table_firstPage(table) {
|
|
94
|
+
return table_setPageIndex(table, 0);
|
|
95
|
+
}
|
|
96
|
+
function table_lastPage(table) {
|
|
97
|
+
return table_setPageIndex(table, table_getPageCount(table) - 1);
|
|
98
|
+
}
|
|
99
|
+
function table_getPageCount(table) {
|
|
100
|
+
return table.options.pageCount ?? Math.ceil(
|
|
101
|
+
table_getRowCount(table) / (table.store.state.pagination?.pageSize ?? defaultPageSize)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function table_getRowCount(table) {
|
|
105
|
+
return table.options.rowCount ?? table.getPrePaginatedRowModel().rows.length;
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
getDefaultPaginationState,
|
|
109
|
+
table_autoResetPageIndex,
|
|
110
|
+
table_firstPage,
|
|
111
|
+
table_getCanNextPage,
|
|
112
|
+
table_getCanPreviousPage,
|
|
113
|
+
table_getPageCount,
|
|
114
|
+
table_getPageOptions,
|
|
115
|
+
table_getRowCount,
|
|
116
|
+
table_lastPage,
|
|
117
|
+
table_nextPage,
|
|
118
|
+
table_previousPage,
|
|
119
|
+
table_resetPageIndex,
|
|
120
|
+
table_resetPageSize,
|
|
121
|
+
table_resetPagination,
|
|
122
|
+
table_setPageIndex,
|
|
123
|
+
table_setPageSize,
|
|
124
|
+
table_setPagination
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=rowPaginationFeature.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowPaginationFeature.utils.js","sources":["../../../../src/features/row-pagination/rowPaginationFeature.utils.ts"],"sourcesContent":["import { functionalUpdate } from '../../utils'\nimport type { RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { PaginationState } from './rowPaginationFeature.types'\n\nconst defaultPageIndex = 0\nconst defaultPageSize = 10\n\nexport function getDefaultPaginationState(): PaginationState {\n return structuredClone({\n pageIndex: defaultPageIndex,\n pageSize: defaultPageSize,\n })\n}\n\nexport function table_autoResetPageIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetPageIndex ??\n !table.options.manualPagination\n ) {\n table_resetPageIndex(table)\n }\n}\n\nexport function table_setPagination<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<PaginationState>) {\n const safeUpdater: Updater<PaginationState> = (old) => {\n const newState = functionalUpdate(updater, old)\n\n return newState\n }\n\n return table.options.onPaginationChange?.(safeUpdater)\n}\n\nexport function table_resetPagination<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setPagination(\n table,\n defaultState\n ? getDefaultPaginationState()\n : (table.initialState.pagination ?? getDefaultPaginationState()),\n )\n}\n\nexport function table_setPageIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>) {\n table_setPagination(table, (old) => {\n let pageIndex = functionalUpdate(updater, old.pageIndex)\n\n const maxPageIndex =\n typeof table.options.pageCount === 'undefined' ||\n table.options.pageCount === -1\n ? Number.MAX_SAFE_INTEGER\n : table.options.pageCount - 1\n\n pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex))\n\n return {\n ...old,\n pageIndex,\n }\n })\n}\n\nexport function table_resetPageIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setPageIndex(\n table,\n defaultState\n ? defaultPageIndex\n : (table.initialState.pagination?.pageIndex ?? defaultPageIndex),\n )\n}\n\nexport function table_resetPageSize<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setPageSize(\n table,\n defaultState\n ? defaultPageSize\n : (table.initialState.pagination?.pageSize ?? defaultPageSize),\n )\n}\n\nexport function table_setPageSize<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<number>) {\n table_setPagination(table, (old) => {\n const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize))\n const topRowIndex = old.pageSize * old.pageIndex\n const pageIndex = Math.floor(topRowIndex / pageSize)\n\n return {\n ...old,\n pageIndex,\n pageSize,\n }\n })\n}\n\nexport function table_getPageOptions<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const pageCount = table_getPageCount(table)\n let pageOptions: Array<number> = []\n if (pageCount && pageCount > 0) {\n pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i)\n }\n return pageOptions\n}\n\nexport function table_getCanPreviousPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (table.store.state.pagination?.pageIndex ?? 0) > 0\n}\n\nexport function table_getCanNextPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const pageIndex = table.store.state.pagination?.pageIndex ?? defaultPageIndex\n\n const pageCount = table_getPageCount(table)\n\n if (pageCount === -1) {\n return true\n }\n\n if (pageCount === 0) {\n return false\n }\n\n return pageIndex < pageCount - 1\n}\n\nexport function table_previousPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table_setPageIndex(table, (old) => old - 1)\n}\n\nexport function table_nextPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table_setPageIndex(table, (old) => {\n return old + 1\n })\n}\n\nexport function table_firstPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table_setPageIndex(table, 0)\n}\n\nexport function table_lastPage<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table_setPageIndex(table, table_getPageCount(table) - 1)\n}\n\nexport function table_getPageCount<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (\n table.options.pageCount ??\n Math.ceil(\n table_getRowCount(table) /\n (table.store.state.pagination?.pageSize ?? defaultPageSize),\n )\n )\n}\n\nexport function table_getRowCount<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table.options.rowCount ?? table.getPrePaginatedRowModel().rows.length\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RowData } from '../../types/type-utils.js';
|
|
2
|
+
import { TableFeature, TableFeatures } from '../../types/TableFeatures.js';
|
|
3
|
+
interface RowPinningFeatureConstructors<TFeatures extends TableFeatures, TData extends RowData> {
|
|
4
|
+
}
|
|
5
|
+
export declare function constructRowPinningFeature<TFeatures extends TableFeatures, TData extends RowData>(): TableFeature<RowPinningFeatureConstructors<TFeatures, TData>>;
|
|
6
|
+
/**
|
|
7
|
+
* The Row Pinning feature adds row pinning state and APIs to the table and row objects.
|
|
8
|
+
*/
|
|
9
|
+
export declare const rowPinningFeature: TableFeature<RowPinningFeatureConstructors<TableFeatures, RowData>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { assignTableAPIs, assignPrototypeAPIs, makeStateUpdater } from "../../utils.js";
|
|
2
|
+
import { table_getCenterRows, table_getBottomRows, table_getTopRows, table_getIsSomeRowsPinned, table_resetRowPinning, table_setRowPinning, row_pin, row_getPinnedIndex, row_getIsPinned, row_getCanPin, getDefaultRowPinningState } from "./rowPinningFeature.utils.js";
|
|
3
|
+
function constructRowPinningFeature() {
|
|
4
|
+
return {
|
|
5
|
+
getInitialState: (initialState) => {
|
|
6
|
+
return {
|
|
7
|
+
...initialState,
|
|
8
|
+
rowPinning: {
|
|
9
|
+
...getDefaultRowPinningState(),
|
|
10
|
+
...initialState.rowPinning
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
getDefaultTableOptions: (table) => {
|
|
15
|
+
return {
|
|
16
|
+
onRowPinningChange: makeStateUpdater("rowPinning", table)
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
assignRowPrototype: (prototype, table) => {
|
|
20
|
+
assignPrototypeAPIs("rowPinningFeature", prototype, table, {
|
|
21
|
+
row_getCanPin: {
|
|
22
|
+
fn: (row) => row_getCanPin(row)
|
|
23
|
+
},
|
|
24
|
+
row_getIsPinned: {
|
|
25
|
+
fn: (row) => row_getIsPinned(row)
|
|
26
|
+
},
|
|
27
|
+
row_getPinnedIndex: {
|
|
28
|
+
fn: (row) => row_getPinnedIndex(row),
|
|
29
|
+
memoDeps: (row) => [
|
|
30
|
+
row.table.getRowModel().rows,
|
|
31
|
+
row.table.store.state.rowPinning
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
row_pin: {
|
|
35
|
+
fn: (row, position, includeLeafRows, includeParentRows) => row_pin(row, position, includeLeafRows, includeParentRows)
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
constructTableAPIs: (table) => {
|
|
40
|
+
assignTableAPIs("rowPinningFeature", table, {
|
|
41
|
+
table_setRowPinning: {
|
|
42
|
+
fn: (updater) => table_setRowPinning(table, updater)
|
|
43
|
+
},
|
|
44
|
+
table_resetRowPinning: {
|
|
45
|
+
fn: (defaultState) => table_resetRowPinning(table, defaultState)
|
|
46
|
+
},
|
|
47
|
+
table_getIsSomeRowsPinned: {
|
|
48
|
+
fn: (position) => table_getIsSomeRowsPinned(table, position)
|
|
49
|
+
},
|
|
50
|
+
table_getTopRows: {
|
|
51
|
+
fn: () => table_getTopRows(table),
|
|
52
|
+
memoDeps: () => [
|
|
53
|
+
table.getRowModel().rows,
|
|
54
|
+
table.store.state.rowPinning?.top
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
table_getBottomRows: {
|
|
58
|
+
fn: () => table_getBottomRows(table),
|
|
59
|
+
memoDeps: () => [
|
|
60
|
+
table.getRowModel().rows,
|
|
61
|
+
table.store.state.rowPinning?.bottom
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
table_getCenterRows: {
|
|
65
|
+
fn: () => table_getCenterRows(table),
|
|
66
|
+
memoDeps: () => [
|
|
67
|
+
table.getRowModel().rows,
|
|
68
|
+
table.store.state.rowPinning
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const rowPinningFeature = constructRowPinningFeature();
|
|
76
|
+
export {
|
|
77
|
+
constructRowPinningFeature,
|
|
78
|
+
rowPinningFeature
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=rowPinningFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowPinningFeature.js","sources":["../../../../src/features/row-pinning/rowPinningFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowPinningState,\n row_getCanPin,\n row_getIsPinned,\n row_getPinnedIndex,\n row_pin,\n table_getBottomRows,\n table_getCenterRows,\n table_getIsSomeRowsPinned,\n table_getTopRows,\n table_resetRowPinning,\n table_setRowPinning,\n} from './rowPinningFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\n// import type {\n// Row_RowPinning,\n// TableOptions_RowPinning,\n// TableState_RowPinning,\n// Table_RowPinning,\n// } from './rowPinningFeature.types'\n\ninterface RowPinningFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // Row: Row_RowPinning\n // Table: Table_RowPinning<TFeatures, RowData>\n // TableOptions: TableOptions_RowPinning<TFeatures, RowData>\n // TableState: TableState_RowPinning\n}\n\nexport function constructRowPinningFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<RowPinningFeatureConstructors<TFeatures, TData>> {\n return {\n getInitialState: (initialState) => {\n return {\n ...initialState,\n rowPinning: {\n ...getDefaultRowPinningState(),\n ...initialState.rowPinning,\n },\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowPinningChange: makeStateUpdater('rowPinning', table),\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowPinningFeature', prototype, table, {\n row_getCanPin: {\n fn: (row) => row_getCanPin(row),\n },\n row_getIsPinned: {\n fn: (row) => row_getIsPinned(row),\n },\n row_getPinnedIndex: {\n fn: (row) => row_getPinnedIndex(row),\n memoDeps: (row) => [\n row.table.getRowModel().rows,\n row.table.store.state.rowPinning,\n ],\n },\n row_pin: {\n fn: (row, position, includeLeafRows, includeParentRows) =>\n row_pin(row, position, includeLeafRows, includeParentRows),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowPinningFeature', table, {\n table_setRowPinning: {\n fn: (updater) => table_setRowPinning(table, updater),\n },\n table_resetRowPinning: {\n fn: (defaultState) => table_resetRowPinning(table, defaultState),\n },\n table_getIsSomeRowsPinned: {\n fn: (position) => table_getIsSomeRowsPinned(table, position),\n },\n table_getTopRows: {\n fn: () => table_getTopRows(table),\n memoDeps: () => [\n table.getRowModel().rows,\n table.store.state.rowPinning?.top,\n ],\n },\n table_getBottomRows: {\n fn: () => table_getBottomRows(table),\n memoDeps: () => [\n table.getRowModel().rows,\n table.store.state.rowPinning?.bottom,\n ],\n },\n table_getCenterRows: {\n fn: () => table_getCenterRows(table),\n memoDeps: () => [\n table.getRowModel().rows,\n table.store.state.rowPinning,\n ],\n },\n })\n },\n }\n}\n\n/**\n * The Row Pinning feature adds row pinning state and APIs to the table and row objects.\n */\nexport const rowPinningFeature = constructRowPinningFeature()\n"],"names":[],"mappings":";;AAqCO,SAAS,6BAGmD;AACjE,SAAO;AAAA,IACL,iBAAiB,CAAC,iBAAiB;AACjC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,YAAY;AAAA,UACV,GAAG,0BAAA;AAAA,UACH,GAAG,aAAa;AAAA,QAAA;AAAA,MAClB;AAAA,IAEJ;AAAA,IAEA,wBAAwB,CAAC,UAAU;AACjC,aAAO;AAAA,QACL,oBAAoB,iBAAiB,cAAc,KAAK;AAAA,MAAA;AAAA,IAE5D;AAAA,IAEA,oBAAoB,CAAC,WAAW,UAAU;AACxC,0BAAoB,qBAAqB,WAAW,OAAO;AAAA,QACzD,eAAe;AAAA,UACb,IAAI,CAAC,QAAQ,cAAc,GAAG;AAAA,QAAA;AAAA,QAEhC,iBAAiB;AAAA,UACf,IAAI,CAAC,QAAQ,gBAAgB,GAAG;AAAA,QAAA;AAAA,QAElC,oBAAoB;AAAA,UAClB,IAAI,CAAC,QAAQ,mBAAmB,GAAG;AAAA,UACnC,UAAU,CAAC,QAAQ;AAAA,YACjB,IAAI,MAAM,YAAA,EAAc;AAAA,YACxB,IAAI,MAAM,MAAM,MAAM;AAAA,UAAA;AAAA,QACxB;AAAA,QAEF,SAAS;AAAA,UACP,IAAI,CAAC,KAAK,UAAU,iBAAiB,sBACnC,QAAQ,KAAK,UAAU,iBAAiB,iBAAiB;AAAA,QAAA;AAAA,MAC7D,CACD;AAAA,IACH;AAAA,IAEA,oBAAoB,CAAC,UAAU;AAC7B,sBAAgB,qBAAqB,OAAO;AAAA,QAC1C,qBAAqB;AAAA,UACnB,IAAI,CAAC,YAAY,oBAAoB,OAAO,OAAO;AAAA,QAAA;AAAA,QAErD,uBAAuB;AAAA,UACrB,IAAI,CAAC,iBAAiB,sBAAsB,OAAO,YAAY;AAAA,QAAA;AAAA,QAEjE,2BAA2B;AAAA,UACzB,IAAI,CAAC,aAAa,0BAA0B,OAAO,QAAQ;AAAA,QAAA;AAAA,QAE7D,kBAAkB;AAAA,UAChB,IAAI,MAAM,iBAAiB,KAAK;AAAA,UAChC,UAAU,MAAM;AAAA,YACd,MAAM,cAAc;AAAA,YACpB,MAAM,MAAM,MAAM,YAAY;AAAA,UAAA;AAAA,QAChC;AAAA,QAEF,qBAAqB;AAAA,UACnB,IAAI,MAAM,oBAAoB,KAAK;AAAA,UACnC,UAAU,MAAM;AAAA,YACd,MAAM,cAAc;AAAA,YACpB,MAAM,MAAM,MAAM,YAAY;AAAA,UAAA;AAAA,QAChC;AAAA,QAEF,qBAAqB;AAAA,UACnB,IAAI,MAAM,oBAAoB,KAAK;AAAA,UACnC,UAAU,MAAM;AAAA,YACd,MAAM,cAAc;AAAA,YACpB,MAAM,MAAM,MAAM;AAAA,UAAA;AAAA,QACpB;AAAA,MACF,CACD;AAAA,IACH;AAAA,EAAA;AAEJ;AAKO,MAAM,oBAAoB,2BAAA;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OnChangeFn, RowData, Updater } from '../../types/type-utils.js';
|
|
2
|
+
import { TableFeatures } from '../../types/TableFeatures.js';
|
|
3
|
+
import { Row } from '../../types/Row.js';
|
|
4
|
+
export type RowPinningPosition = false | 'top' | 'bottom';
|
|
5
|
+
export interface RowPinningState {
|
|
6
|
+
bottom: Array<string>;
|
|
7
|
+
top: Array<string>;
|
|
8
|
+
}
|
|
9
|
+
export interface TableState_RowPinning {
|
|
10
|
+
rowPinning: RowPinningState;
|
|
11
|
+
}
|
|
12
|
+
export interface TableOptions_RowPinning<TFeatures extends TableFeatures, TData extends RowData> {
|
|
13
|
+
/**
|
|
14
|
+
* Enables/disables row pinning for the table. Defaults to `true`.
|
|
15
|
+
*/
|
|
16
|
+
enableRowPinning?: boolean | ((row: Row<TFeatures, TData>) => boolean);
|
|
17
|
+
/**
|
|
18
|
+
* When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.
|
|
19
|
+
*/
|
|
20
|
+
keepPinnedRows?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.
|
|
23
|
+
*/
|
|
24
|
+
onRowPinningChange?: OnChangeFn<RowPinningState>;
|
|
25
|
+
}
|
|
26
|
+
export interface RowPinningDefaultOptions {
|
|
27
|
+
onRowPinningChange: OnChangeFn<RowPinningState>;
|
|
28
|
+
}
|
|
29
|
+
export interface Row_RowPinning {
|
|
30
|
+
/**
|
|
31
|
+
* Returns whether or not the row can be pinned.
|
|
32
|
+
*/
|
|
33
|
+
getCanPin: () => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)
|
|
36
|
+
*/
|
|
37
|
+
getIsPinned: () => RowPinningPosition;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the numeric pinned index of the row within a pinned row group.
|
|
40
|
+
*/
|
|
41
|
+
getPinnedIndex: () => number;
|
|
42
|
+
/**
|
|
43
|
+
* Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.
|
|
44
|
+
*/
|
|
45
|
+
pin: (position: RowPinningPosition, includeLeafRows?: boolean, includeParentRows?: boolean) => void;
|
|
46
|
+
}
|
|
47
|
+
export interface Table_RowPinning<TFeatures extends TableFeatures, TData extends RowData> {
|
|
48
|
+
/**
|
|
49
|
+
* Returns all bottom pinned rows.
|
|
50
|
+
*/
|
|
51
|
+
getBottomRows: () => Array<Row<TFeatures, TData>>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns all rows that are not pinned to the top or bottom.
|
|
54
|
+
*/
|
|
55
|
+
getCenterRows: () => Array<Row<TFeatures, TData>>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.
|
|
58
|
+
*/
|
|
59
|
+
getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Returns all top pinned rows.
|
|
62
|
+
*/
|
|
63
|
+
getTopRows: () => Array<Row<TFeatures, TData>>;
|
|
64
|
+
/**
|
|
65
|
+
* Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.
|
|
66
|
+
*/
|
|
67
|
+
resetRowPinning: (defaultState?: boolean) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets or updates the `state.rowPinning` state.
|
|
70
|
+
*/
|
|
71
|
+
setRowPinning: (updater: Updater<RowPinningState>) => void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RowData, Updater } from '../../types/type-utils.js';
|
|
2
|
+
import { TableFeatures } from '../../types/TableFeatures.js';
|
|
3
|
+
import { Table_Internal } from '../../types/Table.js';
|
|
4
|
+
import { Row } from '../../types/Row.js';
|
|
5
|
+
import { RowPinningPosition, RowPinningState } from './rowPinningFeature.types';
|
|
6
|
+
export declare function getDefaultRowPinningState(): RowPinningState;
|
|
7
|
+
export declare function table_setRowPinning<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<RowPinningState>): void;
|
|
8
|
+
export declare function table_resetRowPinning<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
9
|
+
export declare function table_getIsSomeRowsPinned<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, position?: RowPinningPosition): boolean;
|
|
10
|
+
export declare function table_getTopRows<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>>;
|
|
11
|
+
export declare function table_getBottomRows<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>>;
|
|
12
|
+
export declare function table_getCenterRows<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>>;
|
|
13
|
+
export declare function row_getCanPin<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
|
|
14
|
+
export declare function row_getIsPinned<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): RowPinningPosition;
|
|
15
|
+
export declare function row_getPinnedIndex<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): number;
|
|
16
|
+
export declare function row_pin<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>, position: RowPinningPosition, includeLeafRows?: boolean, includeParentRows?: boolean): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { row_getIsAllParentsExpanded } from "../row-expanding/rowExpandingFeature.utils.js";
|
|
2
|
+
import { callMemoOrStaticFn } from "../../utils.js";
|
|
3
|
+
function getDefaultRowPinningState() {
|
|
4
|
+
return structuredClone({
|
|
5
|
+
top: [],
|
|
6
|
+
bottom: []
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function table_setRowPinning(table, updater) {
|
|
10
|
+
table.options.onRowPinningChange?.(updater);
|
|
11
|
+
}
|
|
12
|
+
function table_resetRowPinning(table, defaultState) {
|
|
13
|
+
table_setRowPinning(
|
|
14
|
+
table,
|
|
15
|
+
defaultState ? getDefaultRowPinningState() : table.initialState.rowPinning ?? getDefaultRowPinningState()
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function table_getIsSomeRowsPinned(table, position) {
|
|
19
|
+
const rowPinning = table.store.state.rowPinning;
|
|
20
|
+
if (!position) {
|
|
21
|
+
return Boolean(rowPinning?.top.length || rowPinning?.bottom.length);
|
|
22
|
+
}
|
|
23
|
+
return Boolean(rowPinning?.[position].length);
|
|
24
|
+
}
|
|
25
|
+
function table_getPinnedRows(table, position) {
|
|
26
|
+
const visibleRows = table.getRowModel().rows;
|
|
27
|
+
const pinnedRowIds = table.store.state.rowPinning?.[position] ?? [];
|
|
28
|
+
const rows = table.options.keepPinnedRows ?? true ? (
|
|
29
|
+
// get all rows that are pinned even if they would not be otherwise visible
|
|
30
|
+
// account for expanded parent rows, but not pagination or filtering
|
|
31
|
+
pinnedRowIds.map((rowId) => {
|
|
32
|
+
const row = table.getRow(rowId, true);
|
|
33
|
+
return row_getIsAllParentsExpanded(row) ? row : null;
|
|
34
|
+
})
|
|
35
|
+
) : (
|
|
36
|
+
// else get only visible rows that are pinned
|
|
37
|
+
pinnedRowIds.map(
|
|
38
|
+
(rowId) => visibleRows.find((row) => row.id === rowId)
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
const filteredRows = rows.filter((r) => !!r);
|
|
42
|
+
filteredRows.forEach((row) => {
|
|
43
|
+
row.position = position;
|
|
44
|
+
});
|
|
45
|
+
return filteredRows;
|
|
46
|
+
}
|
|
47
|
+
function table_getTopRows(table) {
|
|
48
|
+
return table_getPinnedRows(table, "top");
|
|
49
|
+
}
|
|
50
|
+
function table_getBottomRows(table) {
|
|
51
|
+
return table_getPinnedRows(table, "bottom");
|
|
52
|
+
}
|
|
53
|
+
function table_getCenterRows(table) {
|
|
54
|
+
const { top, bottom } = table.store.state.rowPinning ?? getDefaultRowPinningState();
|
|
55
|
+
const allRows = table.getRowModel().rows;
|
|
56
|
+
const topAndBottom = /* @__PURE__ */ new Set([...top, ...bottom]);
|
|
57
|
+
return allRows.filter((d) => !topAndBottom.has(d.id));
|
|
58
|
+
}
|
|
59
|
+
function row_getCanPin(row) {
|
|
60
|
+
const { enableRowPinning } = row.table.options;
|
|
61
|
+
if (typeof enableRowPinning === "function") {
|
|
62
|
+
return enableRowPinning(row);
|
|
63
|
+
}
|
|
64
|
+
return enableRowPinning ?? true;
|
|
65
|
+
}
|
|
66
|
+
function row_getIsPinned(row) {
|
|
67
|
+
const { top, bottom } = row.table.store.state.rowPinning ?? getDefaultRowPinningState();
|
|
68
|
+
return top.includes(row.id) ? "top" : bottom.includes(row.id) ? "bottom" : false;
|
|
69
|
+
}
|
|
70
|
+
function row_getPinnedIndex(row) {
|
|
71
|
+
const position = row_getIsPinned(row);
|
|
72
|
+
if (!position) return -1;
|
|
73
|
+
const visiblePinnedRowIds = (position === "top" ? callMemoOrStaticFn(row.table, "getTopRows", table_getTopRows) : callMemoOrStaticFn(row.table, "getBottomRows", table_getBottomRows)).map(({ id }) => id);
|
|
74
|
+
return visiblePinnedRowIds.indexOf(row.id);
|
|
75
|
+
}
|
|
76
|
+
function row_pin(row, position, includeLeafRows, includeParentRows) {
|
|
77
|
+
const leafRowIds = includeLeafRows ? row.getLeafRows().map(({ id }) => id) : [];
|
|
78
|
+
const parentRowIds = includeParentRows ? row.getParentRows().map(({ id }) => id) : [];
|
|
79
|
+
const rowIds = /* @__PURE__ */ new Set([...parentRowIds, row.id, ...leafRowIds]);
|
|
80
|
+
table_setRowPinning(row.table, (old) => {
|
|
81
|
+
if (position === "bottom") {
|
|
82
|
+
return {
|
|
83
|
+
top: old.top.filter((d) => !rowIds.has(d)),
|
|
84
|
+
bottom: [
|
|
85
|
+
...old.bottom.filter((d) => !rowIds.has(d)),
|
|
86
|
+
...Array.from(rowIds)
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if (position === "top") {
|
|
91
|
+
return {
|
|
92
|
+
top: [...old.top.filter((d) => !rowIds.has(d)), ...Array.from(rowIds)],
|
|
93
|
+
bottom: old.bottom.filter((d) => !rowIds.has(d))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
top: old.top.filter((d) => !rowIds.has(d)),
|
|
98
|
+
bottom: old.bottom.filter((d) => !rowIds.has(d))
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
getDefaultRowPinningState,
|
|
104
|
+
row_getCanPin,
|
|
105
|
+
row_getIsPinned,
|
|
106
|
+
row_getPinnedIndex,
|
|
107
|
+
row_pin,
|
|
108
|
+
table_getBottomRows,
|
|
109
|
+
table_getCenterRows,
|
|
110
|
+
table_getIsSomeRowsPinned,
|
|
111
|
+
table_getTopRows,
|
|
112
|
+
table_resetRowPinning,
|
|
113
|
+
table_setRowPinning
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=rowPinningFeature.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rowPinningFeature.utils.js","sources":["../../../../src/features/row-pinning/rowPinningFeature.utils.ts"],"sourcesContent":["import { row_getIsAllParentsExpanded } from '../row-expanding/rowExpandingFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport type { 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 {\n RowPinningPosition,\n RowPinningState,\n} from './rowPinningFeature.types'\n\n// State Utils\n\nexport function getDefaultRowPinningState(): RowPinningState {\n return structuredClone({\n top: [],\n bottom: [],\n })\n}\n\nexport function table_setRowPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<RowPinningState>,\n): void {\n table.options.onRowPinningChange?.(updater)\n}\n\nexport function table_resetRowPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void {\n table_setRowPinning(\n table,\n defaultState\n ? getDefaultRowPinningState()\n : (table.initialState.rowPinning ?? getDefaultRowPinningState()),\n )\n}\n\n// Table Utils\n\nexport function table_getIsSomeRowsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position?: RowPinningPosition,\n): boolean {\n const rowPinning = table.store.state.rowPinning\n\n if (!position) {\n return Boolean(rowPinning?.top.length || rowPinning?.bottom.length)\n }\n return Boolean(rowPinning?.[position].length)\n}\n\nfunction table_getPinnedRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position: 'top' | 'bottom',\n): Array<Row<TFeatures, TData>> {\n const visibleRows = table.getRowModel().rows\n const pinnedRowIds = table.store.state.rowPinning?.[position] ?? []\n\n const rows =\n (table.options.keepPinnedRows ?? true)\n ? // get all rows that are pinned even if they would not be otherwise visible\n // account for expanded parent rows, but not pagination or filtering\n pinnedRowIds.map((rowId) => {\n const row = table.getRow(rowId, true)\n return row_getIsAllParentsExpanded(row) ? row : null\n })\n : // else get only visible rows that are pinned\n pinnedRowIds.map(\n (rowId) => visibleRows.find((row) => row.id === rowId)!,\n )\n\n const filteredRows = rows.filter((r) => !!r)\n // Assign position property directly to preserve prototype chain\n filteredRows.forEach((row) => {\n ;(row as any).position = position\n })\n return filteredRows\n}\n\nexport function table_getTopRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return table_getPinnedRows(table, 'top')\n}\n\nexport function table_getBottomRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return table_getPinnedRows(table, 'bottom')\n}\n\nexport function table_getCenterRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n const { top, bottom } =\n table.store.state.rowPinning ?? getDefaultRowPinningState()\n const allRows = table.getRowModel().rows\n\n const topAndBottom = new Set([...top, ...bottom])\n return allRows.filter((d) => !topAndBottom.has(d.id))\n}\n\n// Row Utils\n\nexport function row_getCanPin<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): boolean {\n const { enableRowPinning } = row.table.options\n if (typeof enableRowPinning === 'function') {\n return enableRowPinning(row)\n }\n return enableRowPinning ?? true\n}\n\nexport function row_getIsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): RowPinningPosition {\n const { top, bottom } =\n row.table.store.state.rowPinning ?? getDefaultRowPinningState()\n\n return top.includes(row.id)\n ? 'top'\n : bottom.includes(row.id)\n ? 'bottom'\n : false\n}\n\nexport function row_getPinnedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): number {\n const position = row_getIsPinned(row)\n if (!position) return -1\n\n const visiblePinnedRowIds = (\n position === 'top'\n ? callMemoOrStaticFn(row.table, 'getTopRows', table_getTopRows)\n : callMemoOrStaticFn(row.table, 'getBottomRows', table_getBottomRows)\n ).map(({ id }) => id)\n\n return visiblePinnedRowIds.indexOf(row.id)\n}\n\nexport function row_pin<TFeatures extends TableFeatures, TData extends RowData>(\n row: Row<TFeatures, TData>,\n position: RowPinningPosition,\n includeLeafRows?: boolean,\n includeParentRows?: boolean,\n): void {\n const leafRowIds = includeLeafRows\n ? row.getLeafRows().map(({ id }) => id)\n : []\n const parentRowIds = includeParentRows\n ? row.getParentRows().map(({ id }) => id)\n : []\n const rowIds: Set<string> = new Set([...parentRowIds, row.id, ...leafRowIds])\n\n table_setRowPinning(row.table, (old) => {\n if (position === 'bottom') {\n return {\n top: old.top.filter((d) => !rowIds.has(d)),\n bottom: [\n ...old.bottom.filter((d) => !rowIds.has(d)),\n ...Array.from(rowIds),\n ],\n }\n }\n\n if (position === 'top') {\n return {\n top: [...old.top.filter((d) => !rowIds.has(d)), ...Array.from(rowIds)],\n bottom: old.bottom.filter((d) => !rowIds.has(d)),\n }\n }\n\n return {\n top: old.top.filter((d) => !rowIds.has(d)),\n bottom: old.bottom.filter((d) => !rowIds.has(d)),\n }\n })\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RowData } from '../../types/type-utils.js';
|
|
2
|
+
import { TableFeature, TableFeatures } from '../../types/TableFeatures.js';
|
|
3
|
+
interface RowSelectionFeatureConstructors<TFeatures extends TableFeatures, TData extends RowData> {
|
|
4
|
+
}
|
|
5
|
+
export declare function constructRowSelectionFeature<TFeatures extends TableFeatures, TData extends RowData>(): TableFeature<RowSelectionFeatureConstructors<TFeatures, TData>>;
|
|
6
|
+
/**
|
|
7
|
+
* The Row Selection feature adds row selection state and APIs to the table and row objects.
|
|
8
|
+
*/
|
|
9
|
+
export declare const rowSelectionFeature: TableFeature<RowSelectionFeatureConstructors<TableFeatures, RowData>>;
|
|
10
|
+
export {};
|