@tanstack/table-core 9.0.0-alpha.46 → 9.0.0-alpha.48
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 +10 -0
- package/dist/core/cells/constructCell.cjs +4 -3
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.js +4 -3
- package/dist/core/cells/constructCell.js.map +1 -1
- package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
- package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js +11 -8
- package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
- package/dist/core/columns/constructColumn.cjs +6 -4
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.js +6 -4
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
- package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
- package/dist/core/columns/coreColumnsFeature.utils.cjs +47 -29
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
- package/dist/core/columns/coreColumnsFeature.utils.js +47 -29
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs +27 -19
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js +27 -19
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/constructHeader.cjs +4 -3
- package/dist/core/headers/constructHeader.cjs.map +1 -1
- package/dist/core/headers/constructHeader.js +4 -3
- package/dist/core/headers/constructHeader.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +1 -6
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +2 -7
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
- package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
- package/dist/core/headers/coreHeadersFeature.utils.cjs +43 -36
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +24 -19
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +24 -19
- package/dist/core/headers/coreHeadersFeature.utils.js +44 -37
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/reactivity/coreReactivityFeature.types.d.cts +4 -0
- package/dist/core/reactivity/coreReactivityFeature.types.d.ts +4 -0
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +8 -6
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.js +8 -6
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
- package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs +43 -32
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
- package/dist/core/rows/coreRowsFeature.utils.js +43 -32
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +9 -5
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +9 -5
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
- package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
- package/dist/core/table/coreTablesFeature.utils.cjs +7 -3
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
- package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
- package/dist/core/table/coreTablesFeature.utils.js +7 -3
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +8 -5
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +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 +8 -3
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js +8 -3
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs +7 -4
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.js +7 -4
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -5
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +11 -5
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +46 -29
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +46 -29
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +152 -115
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +116 -95
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +116 -95
- package/dist/features/column-pinning/columnPinningFeature.utils.js +153 -116
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +28 -4
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +28 -4
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +23 -14
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +24 -15
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +19 -12
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +19 -12
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +91 -52
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +63 -40
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +63 -40
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +91 -53
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +58 -43
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +58 -43
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +52 -36
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
- package/dist/features/row-pinning/rowPinningFeature.utils.js +52 -36
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +95 -72
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
- package/dist/features/row-selection/rowSelectionFeature.utils.js +95 -72
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +13 -8
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +13 -8
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +63 -46
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
- package/dist/features/row-sorting/rowSortingFeature.utils.js +63 -46
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/fns/aggregationFns.cjs +47 -16
- package/dist/fns/aggregationFns.cjs.map +1 -1
- package/dist/fns/aggregationFns.d.cts +33 -9
- package/dist/fns/aggregationFns.d.ts +33 -9
- package/dist/fns/aggregationFns.js +47 -17
- package/dist/fns/aggregationFns.js.map +1 -1
- package/dist/fns/filterFns.cjs +48 -17
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.d.cts +42 -15
- package/dist/fns/filterFns.d.ts +42 -15
- package/dist/fns/filterFns.js +48 -17
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/helpers/columnHelper.cjs +9 -4
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +9 -4
- package/dist/helpers/columnHelper.d.ts +9 -4
- package/dist/helpers/columnHelper.js +9 -4
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/helpers/tableOptions.cjs.map +1 -1
- package/dist/helpers/tableOptions.d.cts +12 -9
- package/dist/helpers/tableOptions.d.ts +12 -9
- package/dist/helpers/tableOptions.js.map +1 -1
- package/dist/index.cjs +0 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/static-functions.cjs +1 -0
- package/dist/static-functions.d.cts +2 -2
- package/dist/static-functions.d.ts +2 -2
- package/dist/static-functions.js +2 -2
- package/dist/store-reactivity-bindings.cjs +1 -0
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.js +1 -0
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/types/ColumnDef.d.cts +38 -0
- package/dist/types/ColumnDef.d.ts +38 -0
- package/dist/types/TableOptions.d.cts +15 -0
- package/dist/types/TableOptions.d.ts +15 -0
- package/dist/types/TableState.d.cts +12 -0
- package/dist/types/TableState.d.ts +12 -0
- package/dist/utils.cjs +18 -39
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -23
- package/dist/utils.d.ts +1 -23
- package/dist/utils.js +19 -36
- package/dist/utils.js.map +1 -1
- package/package.json +5 -3
- package/skills/column-definitions/SKILL.md +333 -0
- package/skills/column-layout/SKILL.md +328 -0
- package/skills/column-layout/references/subsystems.md +220 -0
- package/skills/customizing-feature-behavior/SKILL.md +416 -0
- package/skills/filtering/SKILL.md +357 -0
- package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
- package/skills/grouping/SKILL.md +448 -0
- package/skills/migrate-v8-to-v9/SKILL.md +495 -0
- package/skills/pagination/SKILL.md +385 -0
- package/skills/row-expanding/SKILL.md +348 -0
- package/skills/row-pinning/SKILL.md +269 -0
- package/skills/row-selection/SKILL.md +391 -0
- package/skills/setup/SKILL.md +400 -0
- package/skills/sorting/SKILL.md +344 -0
- package/skills/state-management/SKILL.md +388 -0
- package/src/core/cells/constructCell.ts +3 -2
- package/src/core/cells/coreCellsFeature.utils.ts +11 -8
- package/src/core/columns/constructColumn.ts +5 -3
- package/src/core/columns/coreColumnsFeature.types.ts +7 -6
- package/src/core/columns/coreColumnsFeature.utils.ts +43 -29
- package/src/core/headers/buildHeaderGroups.ts +29 -30
- package/src/core/headers/constructHeader.ts +3 -2
- package/src/core/headers/coreHeadersFeature.ts +2 -27
- package/src/core/headers/coreHeadersFeature.types.ts +6 -4
- package/src/core/headers/coreHeadersFeature.utils.ts +52 -61
- package/src/core/reactivity/coreReactivityFeature.types.ts +4 -0
- package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
- package/src/core/rows/constructRow.ts +6 -4
- package/src/core/rows/coreRowsFeature.types.ts +4 -4
- package/src/core/rows/coreRowsFeature.utils.ts +45 -32
- package/src/core/table/constructTable.ts +6 -4
- package/src/core/table/coreTablesFeature.types.ts +6 -2
- package/src/core/table/coreTablesFeature.utils.ts +5 -3
- package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
- package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +8 -10
- package/src/features/column-faceting/createFacetedRowModel.ts +10 -6
- package/src/features/column-faceting/createFacetedUniqueValues.ts +4 -3
- package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
- package/src/features/column-filtering/createFilteredRowModel.ts +14 -8
- package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
- package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +44 -29
- package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
- package/src/features/column-pinning/columnPinningFeature.utils.ts +164 -128
- package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
- package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
- package/src/features/column-sizing/columnSizingFeature.ts +16 -0
- package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
- package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
- package/src/features/column-visibility/columnVisibilityFeature.ts +8 -0
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +22 -12
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +101 -56
- package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
- package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +58 -43
- package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
- package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
- package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
- package/src/features/row-pinning/rowPinningFeature.utils.ts +59 -47
- package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
- package/src/features/row-selection/rowSelectionFeature.utils.ts +109 -88
- package/src/features/row-sorting/createSortedRowModel.ts +16 -13
- package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
- package/src/features/row-sorting/rowSortingFeature.utils.ts +63 -46
- package/src/fns/aggregationFns.ts +53 -17
- package/src/fns/filterFns.ts +48 -17
- package/src/helpers/columnHelper.ts +9 -4
- package/src/helpers/tableOptions.ts +12 -9
- package/src/store-reactivity-bindings.ts +1 -0
- package/src/types/ColumnDef.ts +38 -0
- package/src/types/TableOptions.ts +15 -0
- package/src/types/TableState.ts +12 -0
- package/src/utils.ts +19 -46
|
@@ -6,20 +6,23 @@ import { Table_Internal } from "../../types/Table.js";
|
|
|
6
6
|
|
|
7
7
|
//#region src/features/row-expanding/rowExpandingFeature.utils.d.ts
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Creates the default expanded state.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* The feature default is an empty map, meaning no rows are expanded. Reset APIs
|
|
12
|
+
* use this value when `defaultState` is `true`.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
15
|
-
* const
|
|
16
|
+
* const expanded = getDefaultExpandedState()
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
19
|
declare function getDefaultExpandedState(): ExpandedState;
|
|
19
20
|
/**
|
|
20
|
-
* Schedules an
|
|
21
|
+
* Schedules an expanded-state reset after row-structure changes.
|
|
21
22
|
*
|
|
22
|
-
* The reset
|
|
23
|
+
* The reset runs when `autoResetAll`, `autoResetExpanded`, or the default
|
|
24
|
+
* client-side expanding behavior allows it. Manual expanding opts out unless
|
|
25
|
+
* the reset options explicitly opt back in.
|
|
23
26
|
*
|
|
24
27
|
* @example
|
|
25
28
|
* ```ts
|
|
@@ -28,20 +31,23 @@ declare function getDefaultExpandedState(): ExpandedState;
|
|
|
28
31
|
*/
|
|
29
32
|
declare function table_autoResetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): void;
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* Routes an expanded-state updater through the table's expanded change handler.
|
|
32
35
|
*
|
|
33
|
-
* The updater
|
|
36
|
+
* The updater may be `true`, a row-id map, or a function of the previous
|
|
37
|
+
* expanded state, matching the instance `table.setExpanded` behavior.
|
|
34
38
|
*
|
|
35
39
|
* @example
|
|
36
40
|
* ```ts
|
|
37
|
-
* table_setExpanded(table, (old) => old)
|
|
41
|
+
* table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
|
|
38
42
|
* ```
|
|
39
43
|
*/
|
|
40
44
|
declare function table_setExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>): void;
|
|
41
45
|
/**
|
|
42
|
-
*
|
|
46
|
+
* Expands or collapses every row.
|
|
43
47
|
*
|
|
44
|
-
*
|
|
48
|
+
* Passing `true` stores the special expanded-all state. Passing `false` stores
|
|
49
|
+
* an empty map. Omitting the value toggles based on whether all rows are
|
|
50
|
+
* currently expanded.
|
|
45
51
|
*
|
|
46
52
|
* @example
|
|
47
53
|
* ```ts
|
|
@@ -50,9 +56,10 @@ declare function table_setExpanded<TFeatures extends TableFeatures, TData extend
|
|
|
50
56
|
*/
|
|
51
57
|
declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, expanded?: boolean): void;
|
|
52
58
|
/**
|
|
53
|
-
* Resets the
|
|
59
|
+
* Resets `expanded` to the configured initial state or feature default.
|
|
54
60
|
*
|
|
55
|
-
*
|
|
61
|
+
* With no argument, the reset clones `table.initialState.expanded` when it
|
|
62
|
+
* exists. Passing `true` ignores initial state and resets to `{}`.
|
|
56
63
|
*
|
|
57
64
|
* @example
|
|
58
65
|
* ```ts
|
|
@@ -62,64 +69,70 @@ declare function table_toggleAllRowsExpanded<TFeatures extends TableFeatures, TD
|
|
|
62
69
|
*/
|
|
63
70
|
declare function table_resetExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean): void;
|
|
64
71
|
/**
|
|
65
|
-
*
|
|
72
|
+
* Checks whether at least one pre-paginated row can expand.
|
|
66
73
|
*
|
|
67
|
-
*
|
|
74
|
+
* Pagination is intentionally ignored so controls can reflect expandable rows
|
|
75
|
+
* that may not be on the current page.
|
|
68
76
|
*
|
|
69
77
|
* @example
|
|
70
78
|
* ```ts
|
|
71
|
-
* const
|
|
79
|
+
* const canExpand = table_getCanSomeRowsExpand(table)
|
|
72
80
|
* ```
|
|
73
81
|
*/
|
|
74
82
|
declare function table_getCanSomeRowsExpand<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
|
|
75
83
|
/**
|
|
76
|
-
*
|
|
84
|
+
* Creates an event handler that toggles all rows expanded.
|
|
77
85
|
*
|
|
78
|
-
*
|
|
86
|
+
* React-style synthetic events are persisted when present before the table state
|
|
87
|
+
* is toggled.
|
|
79
88
|
*
|
|
80
89
|
* @example
|
|
81
90
|
* ```ts
|
|
82
|
-
* const
|
|
91
|
+
* const onClick = table_getToggleAllRowsExpandedHandler(table)
|
|
83
92
|
* ```
|
|
84
93
|
*/
|
|
85
94
|
declare function table_getToggleAllRowsExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): (e: unknown) => void;
|
|
86
95
|
/**
|
|
87
|
-
*
|
|
96
|
+
* Checks whether any row is expanded.
|
|
88
97
|
*
|
|
89
|
-
*
|
|
98
|
+
* The special expanded-all value `true` counts as some rows expanded.
|
|
90
99
|
*
|
|
91
100
|
* @example
|
|
92
101
|
* ```ts
|
|
93
|
-
* const
|
|
102
|
+
* const someExpanded = table_getIsSomeRowsExpanded(table)
|
|
94
103
|
* ```
|
|
95
104
|
*/
|
|
96
105
|
declare function table_getIsSomeRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
|
|
97
106
|
/**
|
|
98
|
-
*
|
|
107
|
+
* Checks whether every row in the current row model is expanded.
|
|
99
108
|
*
|
|
100
|
-
*
|
|
109
|
+
* The special expanded-all value `true` returns true immediately. Empty
|
|
110
|
+
* expanded state returns false.
|
|
101
111
|
*
|
|
102
112
|
* @example
|
|
103
113
|
* ```ts
|
|
104
|
-
* const
|
|
114
|
+
* const allExpanded = table_getIsAllRowsExpanded(table)
|
|
105
115
|
* ```
|
|
106
116
|
*/
|
|
107
117
|
declare function table_getIsAllRowsExpanded<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): boolean;
|
|
108
118
|
/**
|
|
109
|
-
*
|
|
119
|
+
* Computes the deepest expanded row id depth.
|
|
110
120
|
*
|
|
111
|
-
*
|
|
121
|
+
* Row ids are split on `.`; expanded-all state scans the current row model,
|
|
122
|
+
* while explicit expanded state scans its expanded id keys.
|
|
112
123
|
*
|
|
113
124
|
* @example
|
|
114
125
|
* ```ts
|
|
115
|
-
* const
|
|
126
|
+
* const depth = table_getExpandedDepth(table)
|
|
116
127
|
* ```
|
|
117
128
|
*/
|
|
118
129
|
declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): number;
|
|
119
130
|
/**
|
|
120
|
-
*
|
|
131
|
+
* Expands or collapses this row.
|
|
121
132
|
*
|
|
122
|
-
*
|
|
133
|
+
* Omitting `expanded` toggles the row. If the current state is expanded-all,
|
|
134
|
+
* the function first materializes that state into a row-id map before applying
|
|
135
|
+
* the row-specific change.
|
|
123
136
|
*
|
|
124
137
|
* @example
|
|
125
138
|
* ```ts
|
|
@@ -128,46 +141,48 @@ declare function table_getExpandedDepth<TFeatures extends TableFeatures, TData e
|
|
|
128
141
|
*/
|
|
129
142
|
declare function row_toggleExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>, expanded?: boolean): void;
|
|
130
143
|
/**
|
|
131
|
-
*
|
|
144
|
+
* Checks whether this row is expanded.
|
|
132
145
|
*
|
|
133
|
-
*
|
|
146
|
+
* `options.getIsRowExpanded` can override state-derived behavior. Otherwise
|
|
147
|
+
* the row is expanded when expanded state is `true` or contains this row id.
|
|
134
148
|
*
|
|
135
149
|
* @example
|
|
136
150
|
* ```ts
|
|
137
|
-
* const
|
|
151
|
+
* const expanded = row_getIsExpanded(row)
|
|
138
152
|
* ```
|
|
139
153
|
*/
|
|
140
154
|
declare function row_getIsExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
|
|
141
155
|
/**
|
|
142
|
-
*
|
|
156
|
+
* Checks whether this row can be expanded.
|
|
143
157
|
*
|
|
144
|
-
*
|
|
158
|
+
* `options.getRowCanExpand` wins when provided. Otherwise rows can expand when
|
|
159
|
+
* expanding is enabled and the row has subRows.
|
|
145
160
|
*
|
|
146
161
|
* @example
|
|
147
162
|
* ```ts
|
|
148
|
-
* const
|
|
163
|
+
* const canExpand = row_getCanExpand(row)
|
|
149
164
|
* ```
|
|
150
165
|
*/
|
|
151
166
|
declare function row_getCanExpand<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
|
|
152
167
|
/**
|
|
153
|
-
*
|
|
168
|
+
* Checks whether every ancestor of this row is expanded.
|
|
154
169
|
*
|
|
155
|
-
*
|
|
170
|
+
* The current row is not considered; only its parent chain is walked.
|
|
156
171
|
*
|
|
157
172
|
* @example
|
|
158
173
|
* ```ts
|
|
159
|
-
* const
|
|
174
|
+
* const parentsExpanded = row_getIsAllParentsExpanded(row)
|
|
160
175
|
* ```
|
|
161
176
|
*/
|
|
162
177
|
declare function row_getIsAllParentsExpanded<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): boolean;
|
|
163
178
|
/**
|
|
164
|
-
*
|
|
179
|
+
* Creates a row control handler that toggles this row's expanded state.
|
|
165
180
|
*
|
|
166
|
-
* The handler is
|
|
181
|
+
* The handler is a no-op when the row cannot expand.
|
|
167
182
|
*
|
|
168
183
|
* @example
|
|
169
184
|
* ```ts
|
|
170
|
-
* const
|
|
185
|
+
* const onClick = row_getToggleExpandedHandler(row)
|
|
171
186
|
* ```
|
|
172
187
|
*/
|
|
173
188
|
declare function row_getToggleExpandedHandler<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): () => void;
|
|
@@ -2,22 +2,25 @@ import { cloneState } from "../../utils.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/features/row-expanding/rowExpandingFeature.utils.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates the default expanded state.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* The feature default is an empty map, meaning no rows are expanded. Reset APIs
|
|
8
|
+
* use this value when `defaultState` is `true`.
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
11
|
* ```ts
|
|
11
|
-
* const
|
|
12
|
+
* const expanded = getDefaultExpandedState()
|
|
12
13
|
* ```
|
|
13
14
|
*/
|
|
14
15
|
function getDefaultExpandedState() {
|
|
15
16
|
return {};
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
* Schedules an
|
|
19
|
+
* Schedules an expanded-state reset after row-structure changes.
|
|
19
20
|
*
|
|
20
|
-
* The reset
|
|
21
|
+
* The reset runs when `autoResetAll`, `autoResetExpanded`, or the default
|
|
22
|
+
* client-side expanding behavior allows it. Manual expanding opts out unless
|
|
23
|
+
* the reset options explicitly opt back in.
|
|
21
24
|
*
|
|
22
25
|
* @example
|
|
23
26
|
* ```ts
|
|
@@ -25,16 +28,17 @@ function getDefaultExpandedState() {
|
|
|
25
28
|
* ```
|
|
26
29
|
*/
|
|
27
30
|
function table_autoResetExpanded(table) {
|
|
28
|
-
if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding)
|
|
31
|
+
if (table.options.autoResetAll ?? table.options.autoResetExpanded ?? !table.options.manualExpanding) table._reactivity.schedule(() => table_resetExpanded(table));
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* Routes an expanded-state updater through the table's expanded change handler.
|
|
32
35
|
*
|
|
33
|
-
* The updater
|
|
36
|
+
* The updater may be `true`, a row-id map, or a function of the previous
|
|
37
|
+
* expanded state, matching the instance `table.setExpanded` behavior.
|
|
34
38
|
*
|
|
35
39
|
* @example
|
|
36
40
|
* ```ts
|
|
37
|
-
* table_setExpanded(table, (old) => old)
|
|
41
|
+
* table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))
|
|
38
42
|
* ```
|
|
39
43
|
*/
|
|
40
44
|
function table_setExpanded(table, updater) {
|
|
@@ -42,9 +46,11 @@ function table_setExpanded(table, updater) {
|
|
|
42
46
|
(_table$options$onExpa = (_table$options = table.options).onExpandedChange) === null || _table$options$onExpa === void 0 || _table$options$onExpa.call(_table$options, updater);
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Expands or collapses every row.
|
|
46
50
|
*
|
|
47
|
-
*
|
|
51
|
+
* Passing `true` stores the special expanded-all state. Passing `false` stores
|
|
52
|
+
* an empty map. Omitting the value toggles based on whether all rows are
|
|
53
|
+
* currently expanded.
|
|
48
54
|
*
|
|
49
55
|
* @example
|
|
50
56
|
* ```ts
|
|
@@ -56,9 +62,10 @@ function table_toggleAllRowsExpanded(table, expanded) {
|
|
|
56
62
|
else table_setExpanded(table, {});
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
|
-
* Resets the
|
|
65
|
+
* Resets `expanded` to the configured initial state or feature default.
|
|
60
66
|
*
|
|
61
|
-
*
|
|
67
|
+
* With no argument, the reset clones `table.initialState.expanded` when it
|
|
68
|
+
* exists. Passing `true` ignores initial state and resets to `{}`.
|
|
62
69
|
*
|
|
63
70
|
* @example
|
|
64
71
|
* ```ts
|
|
@@ -70,26 +77,28 @@ function table_resetExpanded(table, defaultState) {
|
|
|
70
77
|
table_setExpanded(table, defaultState ? {} : cloneState(table.initialState.expanded ?? {}));
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
73
|
-
*
|
|
80
|
+
* Checks whether at least one pre-paginated row can expand.
|
|
74
81
|
*
|
|
75
|
-
*
|
|
82
|
+
* Pagination is intentionally ignored so controls can reflect expandable rows
|
|
83
|
+
* that may not be on the current page.
|
|
76
84
|
*
|
|
77
85
|
* @example
|
|
78
86
|
* ```ts
|
|
79
|
-
* const
|
|
87
|
+
* const canExpand = table_getCanSomeRowsExpand(table)
|
|
80
88
|
* ```
|
|
81
89
|
*/
|
|
82
90
|
function table_getCanSomeRowsExpand(table) {
|
|
83
91
|
return table.getPrePaginatedRowModel().flatRows.some((row) => row_getCanExpand(row));
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
|
-
*
|
|
94
|
+
* Creates an event handler that toggles all rows expanded.
|
|
87
95
|
*
|
|
88
|
-
*
|
|
96
|
+
* React-style synthetic events are persisted when present before the table state
|
|
97
|
+
* is toggled.
|
|
89
98
|
*
|
|
90
99
|
* @example
|
|
91
100
|
* ```ts
|
|
92
|
-
* const
|
|
101
|
+
* const onClick = table_getToggleAllRowsExpandedHandler(table)
|
|
93
102
|
* ```
|
|
94
103
|
*/
|
|
95
104
|
function table_getToggleAllRowsExpandedHandler(table) {
|
|
@@ -100,13 +109,13 @@ function table_getToggleAllRowsExpandedHandler(table) {
|
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
111
|
/**
|
|
103
|
-
*
|
|
112
|
+
* Checks whether any row is expanded.
|
|
104
113
|
*
|
|
105
|
-
*
|
|
114
|
+
* The special expanded-all value `true` counts as some rows expanded.
|
|
106
115
|
*
|
|
107
116
|
* @example
|
|
108
117
|
* ```ts
|
|
109
|
-
* const
|
|
118
|
+
* const someExpanded = table_getIsSomeRowsExpanded(table)
|
|
110
119
|
* ```
|
|
111
120
|
*/
|
|
112
121
|
function table_getIsSomeRowsExpanded(table) {
|
|
@@ -115,13 +124,14 @@ function table_getIsSomeRowsExpanded(table) {
|
|
|
115
124
|
return expanded === true || Object.values(expanded).some(Boolean);
|
|
116
125
|
}
|
|
117
126
|
/**
|
|
118
|
-
*
|
|
127
|
+
* Checks whether every row in the current row model is expanded.
|
|
119
128
|
*
|
|
120
|
-
*
|
|
129
|
+
* The special expanded-all value `true` returns true immediately. Empty
|
|
130
|
+
* expanded state returns false.
|
|
121
131
|
*
|
|
122
132
|
* @example
|
|
123
133
|
* ```ts
|
|
124
|
-
* const
|
|
134
|
+
* const allExpanded = table_getIsAllRowsExpanded(table)
|
|
125
135
|
* ```
|
|
126
136
|
*/
|
|
127
137
|
function table_getIsAllRowsExpanded(table) {
|
|
@@ -133,13 +143,14 @@ function table_getIsAllRowsExpanded(table) {
|
|
|
133
143
|
return true;
|
|
134
144
|
}
|
|
135
145
|
/**
|
|
136
|
-
*
|
|
146
|
+
* Computes the deepest expanded row id depth.
|
|
137
147
|
*
|
|
138
|
-
*
|
|
148
|
+
* Row ids are split on `.`; expanded-all state scans the current row model,
|
|
149
|
+
* while explicit expanded state scans its expanded id keys.
|
|
139
150
|
*
|
|
140
151
|
* @example
|
|
141
152
|
* ```ts
|
|
142
|
-
* const
|
|
153
|
+
* const depth = table_getExpandedDepth(table)
|
|
143
154
|
* ```
|
|
144
155
|
*/
|
|
145
156
|
function table_getExpandedDepth(table) {
|
|
@@ -152,9 +163,11 @@ function table_getExpandedDepth(table) {
|
|
|
152
163
|
return maxDepth;
|
|
153
164
|
}
|
|
154
165
|
/**
|
|
155
|
-
*
|
|
166
|
+
* Expands or collapses this row.
|
|
156
167
|
*
|
|
157
|
-
*
|
|
168
|
+
* Omitting `expanded` toggles the row. If the current state is expanded-all,
|
|
169
|
+
* the function first materializes that state into a row-id map before applying
|
|
170
|
+
* the row-specific change.
|
|
158
171
|
*
|
|
159
172
|
* @example
|
|
160
173
|
* ```ts
|
|
@@ -182,13 +195,14 @@ function row_toggleExpanded(row, expanded) {
|
|
|
182
195
|
});
|
|
183
196
|
}
|
|
184
197
|
/**
|
|
185
|
-
*
|
|
198
|
+
* Checks whether this row is expanded.
|
|
186
199
|
*
|
|
187
|
-
*
|
|
200
|
+
* `options.getIsRowExpanded` can override state-derived behavior. Otherwise
|
|
201
|
+
* the row is expanded when expanded state is `true` or contains this row id.
|
|
188
202
|
*
|
|
189
203
|
* @example
|
|
190
204
|
* ```ts
|
|
191
|
-
* const
|
|
205
|
+
* const expanded = row_getIsExpanded(row)
|
|
192
206
|
* ```
|
|
193
207
|
*/
|
|
194
208
|
function row_getIsExpanded(row) {
|
|
@@ -197,13 +211,14 @@ function row_getIsExpanded(row) {
|
|
|
197
211
|
return !!(((_row$table$options$ge = (_row$table$options = row.table.options).getIsRowExpanded) === null || _row$table$options$ge === void 0 ? void 0 : _row$table$options$ge.call(_row$table$options, row)) ?? (expanded === true || expanded[row.id]));
|
|
198
212
|
}
|
|
199
213
|
/**
|
|
200
|
-
*
|
|
214
|
+
* Checks whether this row can be expanded.
|
|
201
215
|
*
|
|
202
|
-
*
|
|
216
|
+
* `options.getRowCanExpand` wins when provided. Otherwise rows can expand when
|
|
217
|
+
* expanding is enabled and the row has subRows.
|
|
203
218
|
*
|
|
204
219
|
* @example
|
|
205
220
|
* ```ts
|
|
206
|
-
* const
|
|
221
|
+
* const canExpand = row_getCanExpand(row)
|
|
207
222
|
* ```
|
|
208
223
|
*/
|
|
209
224
|
function row_getCanExpand(row) {
|
|
@@ -211,13 +226,13 @@ function row_getCanExpand(row) {
|
|
|
211
226
|
return ((_row$table$options$ge2 = (_row$table$options2 = row.table.options).getRowCanExpand) === null || _row$table$options$ge2 === void 0 ? void 0 : _row$table$options$ge2.call(_row$table$options2, row)) ?? ((row.table.options.enableExpanding ?? true) && !!row.subRows.length);
|
|
212
227
|
}
|
|
213
228
|
/**
|
|
214
|
-
*
|
|
229
|
+
* Checks whether every ancestor of this row is expanded.
|
|
215
230
|
*
|
|
216
|
-
*
|
|
231
|
+
* The current row is not considered; only its parent chain is walked.
|
|
217
232
|
*
|
|
218
233
|
* @example
|
|
219
234
|
* ```ts
|
|
220
|
-
* const
|
|
235
|
+
* const parentsExpanded = row_getIsAllParentsExpanded(row)
|
|
221
236
|
* ```
|
|
222
237
|
*/
|
|
223
238
|
function row_getIsAllParentsExpanded(row) {
|
|
@@ -225,18 +240,18 @@ function row_getIsAllParentsExpanded(row) {
|
|
|
225
240
|
let currentRow = row;
|
|
226
241
|
while (isFullyExpanded && currentRow.parentId) {
|
|
227
242
|
currentRow = row.table.getRow(currentRow.parentId, true);
|
|
228
|
-
isFullyExpanded = row_getIsExpanded(
|
|
243
|
+
isFullyExpanded = row_getIsExpanded(currentRow);
|
|
229
244
|
}
|
|
230
245
|
return isFullyExpanded;
|
|
231
246
|
}
|
|
232
247
|
/**
|
|
233
|
-
*
|
|
248
|
+
* Creates a row control handler that toggles this row's expanded state.
|
|
234
249
|
*
|
|
235
|
-
* The handler is
|
|
250
|
+
* The handler is a no-op when the row cannot expand.
|
|
236
251
|
*
|
|
237
252
|
* @example
|
|
238
253
|
* ```ts
|
|
239
|
-
* const
|
|
254
|
+
* const onClick = row_getToggleExpandedHandler(row)
|
|
240
255
|
* ```
|
|
241
256
|
*/
|
|
242
257
|
function row_getToggleExpandedHandler(row) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } 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 ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Returns the default expanded state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an automatic reset for expanded.\n *\n * The reset only runs when the related feature options allow automatic resets for the current table state change.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n queueMicrotask(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Updates the table's expanded state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => old)\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Toggles all rows expanded for the table.\n *\n * This is the table-level convenience API used by UI controls that affect many columns or rows at once.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets the table's expanded state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Returns can some rows expand for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Returns an event handler for all rows expanded handler.\n *\n * The handler calls the matching table toggle API and can be attached directly to checkbox or button UI.\n *\n * @example\n * ```ts\n * const value = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Returns is some rows expanded for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Returns is all rows expanded for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Returns expanded depth for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Toggles expanded for a row.\n *\n * The update is routed through the table state updater for the owning feature state slice.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Returns is expanded for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Returns whether a row can use expand.\n *\n * This evaluates row data, table options, and feature-specific enablement rules.\n *\n * @example\n * ```ts\n * const value = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Returns is all parents expanded for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(row)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Returns an event handler for toggling expanded handler.\n *\n * The handler is intended for direct use in row-level controls such as expansion or selection buttons.\n *\n * @example\n * ```ts\n * const value = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"rowExpandingFeature.utils.js","names":[],"sources":["../../../src/features/row-expanding/rowExpandingFeature.utils.ts"],"sourcesContent":["import { cloneState } 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 ExpandedState,\n ExpandedStateList,\n} from './rowExpandingFeature.types'\n\n/**\n * Creates the default expanded state.\n *\n * The feature default is an empty map, meaning no rows are expanded. Reset APIs\n * use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const expanded = getDefaultExpandedState()\n * ```\n */\nexport function getDefaultExpandedState(): ExpandedState {\n return {}\n}\n\n/**\n * Schedules an expanded-state reset after row-structure changes.\n *\n * The reset runs when `autoResetAll`, `autoResetExpanded`, or the default\n * client-side expanding behavior allows it. Manual expanding opts out unless\n * the reset options explicitly opt back in.\n *\n * @example\n * ```ts\n * table_autoResetExpanded(table)\n * ```\n */\nexport function table_autoResetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n if (\n table.options.autoResetAll ??\n table.options.autoResetExpanded ??\n !table.options.manualExpanding\n ) {\n table._reactivity.schedule(() => table_resetExpanded(table))\n }\n}\n\n/**\n * Routes an expanded-state updater through the table's expanded change handler.\n *\n * The updater may be `true`, a row-id map, or a function of the previous\n * expanded state, matching the instance `table.setExpanded` behavior.\n *\n * @example\n * ```ts\n * table_setExpanded(table, (old) => ({ ...old, [rowId]: true }))\n * ```\n */\nexport function table_setExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ExpandedState>) {\n table.options.onExpandedChange?.(updater)\n}\n\n/**\n * Expands or collapses every row.\n *\n * Passing `true` stores the special expanded-all state. Passing `false` stores\n * an empty map. Omitting the value toggles based on whether all rows are\n * currently expanded.\n *\n * @example\n * ```ts\n * table_toggleAllRowsExpanded(table)\n * ```\n */\nexport function table_toggleAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, expanded?: boolean) {\n if (expanded ?? !table_getIsAllRowsExpanded(table)) {\n table_setExpanded(table, true)\n } else {\n table_setExpanded(table, {})\n }\n}\n\n/**\n * Resets `expanded` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.expanded` when it\n * exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetExpanded(table)\n * table_resetExpanded(table, true)\n * ```\n */\nexport function table_resetExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setExpanded(\n table,\n defaultState ? {} : cloneState(table.initialState.expanded ?? {}),\n )\n}\n\n/**\n * Checks whether at least one pre-paginated row can expand.\n *\n * Pagination is intentionally ignored so controls can reflect expandable rows\n * that may not be on the current page.\n *\n * @example\n * ```ts\n * const canExpand = table_getCanSomeRowsExpand(table)\n * ```\n */\nexport function table_getCanSomeRowsExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getPrePaginatedRowModel()\n .flatRows.some((row) => row_getCanExpand(row))\n}\n\n/**\n * Creates an event handler that toggles all rows expanded.\n *\n * React-style synthetic events are persisted when present before the table state\n * is toggled.\n *\n * @example\n * ```ts\n * const onClick = table_getToggleAllRowsExpandedHandler(table)\n * ```\n */\nexport function table_getToggleAllRowsExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n ;(e as any).persist?.()\n table_toggleAllRowsExpanded(table)\n }\n}\n\n/**\n * Checks whether any row is expanded.\n *\n * The special expanded-all value `true` counts as some rows expanded.\n *\n * @example\n * ```ts\n * const someExpanded = table_getIsSomeRowsExpanded(table)\n * ```\n */\nexport function table_getIsSomeRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n return expanded === true || Object.values(expanded).some(Boolean)\n}\n\n/**\n * Checks whether every row in the current row model is expanded.\n *\n * The special expanded-all value `true` returns true immediately. Empty\n * expanded state returns false.\n *\n * @example\n * ```ts\n * const allExpanded = table_getIsAllRowsExpanded(table)\n * ```\n */\nexport function table_getIsAllRowsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const expanded = table.atoms.expanded?.get() ?? {}\n\n // If expanded is true, save some cycles and return true\n if (expanded === true) {\n return true\n }\n\n if (!Object.keys(expanded).length) {\n return false\n }\n\n // If any row is not expanded, return false\n if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) {\n return false\n }\n\n // They must all be expanded :shrug:\n return true\n}\n\n/**\n * Computes the deepest expanded row id depth.\n *\n * Row ids are split on `.`; expanded-all state scans the current row model,\n * while explicit expanded state scans its expanded id keys.\n *\n * @example\n * ```ts\n * const depth = table_getExpandedDepth(table)\n * ```\n */\nexport function table_getExpandedDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n let maxDepth = 0\n\n const rowIds =\n table.atoms.expanded?.get() === true\n ? Object.keys(table.getRowModel().rowsById)\n : Object.keys(table.atoms.expanded?.get() ?? {})\n\n rowIds.forEach((id) => {\n const splitId = id.split('.')\n maxDepth = Math.max(maxDepth, splitId.length)\n })\n\n return maxDepth\n}\n\n/**\n * Expands or collapses this row.\n *\n * Omitting `expanded` toggles the row. If the current state is expanded-all,\n * the function first materializes that state into a row-id map before applying\n * the row-specific change.\n *\n * @example\n * ```ts\n * row_toggleExpanded(row)\n * ```\n */\nexport function row_toggleExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, expanded?: boolean) {\n table_setExpanded(row.table, (old) => {\n const exists = old === true ? true : !!old[row.id]\n\n let oldExpanded: ExpandedStateList = {}\n\n if (old === true) {\n Object.keys(row.table.getRowModel().rowsById).forEach((rowId) => {\n oldExpanded[rowId] = true\n })\n } else {\n oldExpanded = old\n }\n\n expanded = expanded ?? !exists\n\n if (!exists && expanded) {\n return {\n ...oldExpanded,\n [row.id]: true,\n }\n }\n\n if (exists && !expanded) {\n const { [row.id]: _, ...rest } = oldExpanded\n return rest\n }\n\n return old\n })\n}\n\n/**\n * Checks whether this row is expanded.\n *\n * `options.getIsRowExpanded` can override state-derived behavior. Otherwise\n * the row is expanded when expanded state is `true` or contains this row id.\n *\n * @example\n * ```ts\n * const expanded = row_getIsExpanded(row)\n * ```\n */\nexport function row_getIsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const expanded: ExpandedState = row.table.atoms.expanded?.get() ?? {}\n\n return !!(\n row.table.options.getIsRowExpanded?.(row) ??\n (expanded === true || expanded[row.id])\n )\n}\n\n/**\n * Checks whether this row can be expanded.\n *\n * `options.getRowCanExpand` wins when provided. Otherwise rows can expand when\n * expanding is enabled and the row has subRows.\n *\n * @example\n * ```ts\n * const canExpand = row_getCanExpand(row)\n * ```\n */\nexport function row_getCanExpand<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return (\n row.table.options.getRowCanExpand?.(row) ??\n ((row.table.options.enableExpanding ?? true) && !!row.subRows.length)\n )\n}\n\n/**\n * Checks whether every ancestor of this row is expanded.\n *\n * The current row is not considered; only its parent chain is walked.\n *\n * @example\n * ```ts\n * const parentsExpanded = row_getIsAllParentsExpanded(row)\n * ```\n */\nexport function row_getIsAllParentsExpanded<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n let isFullyExpanded = true\n let currentRow = row\n\n while (isFullyExpanded && currentRow.parentId) {\n currentRow = row.table.getRow(currentRow.parentId, true)\n isFullyExpanded = row_getIsExpanded(currentRow)\n }\n\n return isFullyExpanded\n}\n\n/**\n * Creates a row control handler that toggles this row's expanded state.\n *\n * The handler is a no-op when the row cannot expand.\n *\n * @example\n * ```ts\n * const onClick = row_getToggleExpandedHandler(row)\n * ```\n */\nexport function row_getToggleExpandedHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const canExpand = row_getCanExpand(row)\n\n return () => {\n if (!canExpand) return\n row_toggleExpanded(row)\n }\n}\n"],"mappings":"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"}
|
|
@@ -41,23 +41,26 @@ interface PaginationDefaultOptions {
|
|
|
41
41
|
interface Table_RowPagination<TFeatures extends TableFeatures, TData extends RowData> {
|
|
42
42
|
_autoResetPageIndex: () => void;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Checks whether the current page index can move forward.
|
|
45
45
|
*/
|
|
46
46
|
getCanNextPage: () => boolean;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Checks whether the current page index can move backward.
|
|
49
49
|
*/
|
|
50
50
|
getCanPreviousPage: () => boolean;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Resolves the current page count from `options.pageCount` or row count and
|
|
53
|
+
* page size.
|
|
53
54
|
*/
|
|
54
55
|
getPageCount: () => number;
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
+
* Resolves the row count used for pagination math.
|
|
58
|
+
*
|
|
59
|
+
* `options.rowCount` wins; otherwise the pre-paginated row model is counted.
|
|
57
60
|
*/
|
|
58
61
|
getRowCount: () => number;
|
|
59
62
|
/**
|
|
60
|
-
*
|
|
63
|
+
* Builds zero-based page indexes for the current page count.
|
|
61
64
|
*/
|
|
62
65
|
getPageOptions: () => Array<number>;
|
|
63
66
|
/**
|
|
@@ -77,16 +80,20 @@ interface Table_RowPagination<TFeatures extends TableFeatures, TData extends Row
|
|
|
77
80
|
*/
|
|
78
81
|
lastPage: () => void;
|
|
79
82
|
/**
|
|
80
|
-
* Resets
|
|
83
|
+
* Resets `pagination.pageIndex` to initial state, or to `0` when
|
|
84
|
+
* `defaultState` is `true`.
|
|
81
85
|
*/
|
|
82
86
|
resetPageIndex: (defaultState?: boolean) => void;
|
|
83
87
|
/**
|
|
84
|
-
* Resets
|
|
88
|
+
* Resets `pagination.pageSize` to initial state, or to `10` when
|
|
89
|
+
* `defaultState` is `true`.
|
|
85
90
|
*/
|
|
86
91
|
resetPageSize: (defaultState?: boolean) => void;
|
|
87
92
|
/**
|
|
88
|
-
* Resets pagination
|
|
89
|
-
*
|
|
93
|
+
* Resets `pagination` to `initialState.pagination`.
|
|
94
|
+
*
|
|
95
|
+
* Pass `true` to ignore initial state and reset to
|
|
96
|
+
* `{ pageIndex: 0, pageSize: 10 }`.
|
|
90
97
|
*/
|
|
91
98
|
resetPagination: (defaultState?: boolean) => void;
|
|
92
99
|
/**
|
|
@@ -98,17 +105,17 @@ interface Table_RowPagination<TFeatures extends TableFeatures, TData extends Row
|
|
|
98
105
|
*/
|
|
99
106
|
setPageSize: (updater: Updater<number>) => void;
|
|
100
107
|
/**
|
|
101
|
-
*
|
|
108
|
+
* Updates pagination state with a next state or updater function.
|
|
102
109
|
*/
|
|
103
110
|
setPagination: (updater: Updater<PaginationState>) => void;
|
|
104
111
|
}
|
|
105
112
|
interface Table_RowModels_Paginated<TFeatures extends TableFeatures, TData extends RowData> {
|
|
106
113
|
/**
|
|
107
|
-
*
|
|
114
|
+
* Resolves the row model after pagination has sliced the current page.
|
|
108
115
|
*/
|
|
109
116
|
getPaginatedRowModel: () => RowModel<TFeatures, TData>;
|
|
110
117
|
/**
|
|
111
|
-
*
|
|
118
|
+
* Reads the row model immediately before pagination.
|
|
112
119
|
*/
|
|
113
120
|
getPrePaginatedRowModel: () => RowModel<TFeatures, TData>;
|
|
114
121
|
}
|