@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
|
@@ -3,22 +3,24 @@ import { getDefaultColumnPinningState } from "../column-pinning/columnPinningFea
|
|
|
3
3
|
|
|
4
4
|
//#region src/features/column-visibility/columnVisibilityFeature.utils.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates the default column visibility state.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The feature default is an empty object, where missing column ids are treated
|
|
9
|
+
* as visible. Reset APIs use this value when `defaultState` is `true`.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```ts
|
|
12
|
-
* const
|
|
13
|
+
* const visibility = getDefaultColumnVisibilityState()
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
function getDefaultColumnVisibilityState() {
|
|
16
17
|
return {};
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
+
* Updates this column's visibility when hiding is allowed.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
+
* Passing `visible` stores that value. Omitting it flips the column's current
|
|
23
|
+
* visibility state. Columns that cannot hide are left unchanged.
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
24
26
|
* ```ts
|
|
@@ -32,13 +34,15 @@ function column_toggleVisibility(column, visible) {
|
|
|
32
34
|
}));
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
37
|
+
* Checks whether this column is visible.
|
|
36
38
|
*
|
|
37
|
-
*
|
|
39
|
+
* Leaf columns read `state.columnVisibility[column.id]`, where missing entries
|
|
40
|
+
* default to visible. Parent columns are visible when at least one child column
|
|
41
|
+
* is visible.
|
|
38
42
|
*
|
|
39
43
|
* @example
|
|
40
44
|
* ```ts
|
|
41
|
-
* const
|
|
45
|
+
* const visible = column_getIsVisible(column)
|
|
42
46
|
* ```
|
|
43
47
|
*/
|
|
44
48
|
function column_getIsVisible(column) {
|
|
@@ -47,26 +51,27 @@ function column_getIsVisible(column) {
|
|
|
47
51
|
return (childColumns.length ? childColumns.some((childColumn) => callMemoOrStaticFn(childColumn, "getIsVisible", column_getIsVisible)) : (_column$table$atoms$c = column.table.atoms.columnVisibility) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.get()) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c[column.id]) ?? true;
|
|
48
52
|
}
|
|
49
53
|
/**
|
|
50
|
-
*
|
|
54
|
+
* Checks whether this column is allowed to be hidden.
|
|
51
55
|
*
|
|
52
|
-
*
|
|
56
|
+
* Both `columnDef.enableHiding` and table `enableHiding` default to `true`.
|
|
53
57
|
*
|
|
54
58
|
* @example
|
|
55
59
|
* ```ts
|
|
56
|
-
* const
|
|
60
|
+
* const canHide = column_getCanHide(column)
|
|
57
61
|
* ```
|
|
58
62
|
*/
|
|
59
63
|
function column_getCanHide(column) {
|
|
60
64
|
return (column.columnDef.enableHiding ?? true) && (column.table.options.enableHiding ?? true);
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
|
-
*
|
|
67
|
+
* Creates a checkbox-style handler that writes this column's visibility.
|
|
64
68
|
*
|
|
65
|
-
* The handler
|
|
69
|
+
* The handler reads `event.target.checked`, so it is intended for visibility
|
|
70
|
+
* controls whose checked state means "visible".
|
|
66
71
|
*
|
|
67
72
|
* @example
|
|
68
73
|
* ```ts
|
|
69
|
-
* const
|
|
74
|
+
* const onChange = column_getToggleVisibilityHandler(column)
|
|
70
75
|
* ```
|
|
71
76
|
*/
|
|
72
77
|
function column_getToggleVisibilityHandler(column) {
|
|
@@ -75,38 +80,42 @@ function column_getToggleVisibilityHandler(column) {
|
|
|
75
80
|
};
|
|
76
81
|
}
|
|
77
82
|
/**
|
|
78
|
-
*
|
|
83
|
+
* Collects the cells from this row whose columns are visible.
|
|
79
84
|
*
|
|
80
|
-
*
|
|
85
|
+
* When column pinning is active, the result is ordered as left-pinned cells,
|
|
86
|
+
* center cells, then right-pinned cells.
|
|
81
87
|
*
|
|
82
88
|
* @example
|
|
83
89
|
* ```ts
|
|
84
|
-
* const
|
|
90
|
+
* const visibleCells = row_getVisibleCells(row)
|
|
85
91
|
* ```
|
|
86
92
|
*/
|
|
87
93
|
function row_getVisibleCells(row) {
|
|
88
94
|
var _row$table$atoms$colu;
|
|
89
|
-
const
|
|
95
|
+
const allCells = row.getAllCells();
|
|
96
|
+
const visibleCells = [];
|
|
97
|
+
for (let i = 0; i < allCells.length; i++) {
|
|
98
|
+
const cell = allCells[i];
|
|
99
|
+
if (callMemoOrStaticFn(cell.column, "getIsVisible", column_getIsVisible)) visibleCells.push(cell);
|
|
100
|
+
}
|
|
90
101
|
const { left, right } = ((_row$table$atoms$colu = row.table.atoms.columnPinning) === null || _row$table$atoms$colu === void 0 ? void 0 : _row$table$atoms$colu.get()) ?? getDefaultColumnPinningState();
|
|
91
|
-
if (!left.length && !right.length) return
|
|
92
|
-
const
|
|
93
|
-
for (const cell of cells) cellsByColumnId.set(cell.column.id, cell);
|
|
102
|
+
if (!left.length && !right.length) return visibleCells;
|
|
103
|
+
const visibleCellsByColumnId = callMemoOrStaticFn(row, "getVisibleCellsByColumnId", row_getVisibleCellsByColumnId);
|
|
94
104
|
const leftCells = [];
|
|
95
|
-
for (
|
|
96
|
-
const cell =
|
|
105
|
+
for (let i = 0; i < left.length; i++) {
|
|
106
|
+
const cell = visibleCellsByColumnId[left[i]];
|
|
97
107
|
if (cell) leftCells.push(cell);
|
|
98
108
|
}
|
|
99
109
|
const rightCells = [];
|
|
100
|
-
for (
|
|
101
|
-
const cell =
|
|
110
|
+
for (let i = 0; i < right.length; i++) {
|
|
111
|
+
const cell = visibleCellsByColumnId[right[i]];
|
|
102
112
|
if (cell) rightCells.push(cell);
|
|
103
113
|
}
|
|
104
|
-
const leftSet = new Set(left);
|
|
105
|
-
const rightSet = new Set(right);
|
|
106
114
|
const centerCells = [];
|
|
107
|
-
for (
|
|
115
|
+
for (let i = 0; i < visibleCells.length; i++) {
|
|
116
|
+
const cell = visibleCells[i];
|
|
108
117
|
const id = cell.column.id;
|
|
109
|
-
if (!
|
|
118
|
+
if (!left.includes(id) && !right.includes(id)) centerCells.push(cell);
|
|
110
119
|
}
|
|
111
120
|
return [
|
|
112
121
|
...leftCells,
|
|
@@ -115,39 +124,61 @@ function row_getVisibleCells(row) {
|
|
|
115
124
|
];
|
|
116
125
|
}
|
|
117
126
|
/**
|
|
118
|
-
*
|
|
127
|
+
* Builds a lookup map of this row's visible cells keyed by column id.
|
|
119
128
|
*
|
|
120
|
-
*
|
|
129
|
+
* Hidden columns are omitted from the map.
|
|
121
130
|
*
|
|
122
131
|
* @example
|
|
123
132
|
* ```ts
|
|
124
|
-
* const
|
|
133
|
+
* const visibleCellsById = row_getVisibleCellsByColumnId(row)
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
function row_getVisibleCellsByColumnId(row) {
|
|
137
|
+
const result = {};
|
|
138
|
+
const allCells = row.getAllCells();
|
|
139
|
+
for (let i = 0; i < allCells.length; i++) {
|
|
140
|
+
const cell = allCells[i];
|
|
141
|
+
if (callMemoOrStaticFn(cell.column, "getIsVisible", column_getIsVisible)) result[cell.column.id] = cell;
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Filters the flat column list down to visible columns.
|
|
147
|
+
*
|
|
148
|
+
* Parent/group columns are included when `column_getIsVisible` considers them
|
|
149
|
+
* visible.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const columns = table_getVisibleFlatColumns(table)
|
|
125
154
|
* ```
|
|
126
155
|
*/
|
|
127
156
|
function table_getVisibleFlatColumns(table) {
|
|
128
157
|
return table.getAllFlatColumns().filter((column) => callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible));
|
|
129
158
|
}
|
|
130
159
|
/**
|
|
131
|
-
*
|
|
160
|
+
* Filters leaf columns down to those currently visible.
|
|
132
161
|
*
|
|
133
|
-
* This
|
|
162
|
+
* This is the column list most row rendering code uses before pinning-specific
|
|
163
|
+
* partitioning.
|
|
134
164
|
*
|
|
135
165
|
* @example
|
|
136
166
|
* ```ts
|
|
137
|
-
* const
|
|
167
|
+
* const columns = table_getVisibleLeafColumns(table)
|
|
138
168
|
* ```
|
|
139
169
|
*/
|
|
140
170
|
function table_getVisibleLeafColumns(table) {
|
|
141
171
|
return table.getAllLeafColumns().filter((column) => callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible));
|
|
142
172
|
}
|
|
143
173
|
/**
|
|
144
|
-
*
|
|
174
|
+
* Routes a column visibility updater through the table's visibility change handler.
|
|
145
175
|
*
|
|
146
|
-
* The updater
|
|
176
|
+
* The updater may be a next visibility map or a function of the previous map,
|
|
177
|
+
* matching the instance `table.setColumnVisibility` behavior.
|
|
147
178
|
*
|
|
148
179
|
* @example
|
|
149
180
|
* ```ts
|
|
150
|
-
* table_setColumnVisibility(table, (old) => old)
|
|
181
|
+
* table_setColumnVisibility(table, (old) => ({ ...old, age: false }))
|
|
151
182
|
* ```
|
|
152
183
|
*/
|
|
153
184
|
function table_setColumnVisibility(table, updater) {
|
|
@@ -155,9 +186,10 @@ function table_setColumnVisibility(table, updater) {
|
|
|
155
186
|
(_table$options$onColu = (_table$options = table.options).onColumnVisibilityChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updater);
|
|
156
187
|
}
|
|
157
188
|
/**
|
|
158
|
-
* Resets the
|
|
189
|
+
* Resets `columnVisibility` to the configured initial state or feature default.
|
|
159
190
|
*
|
|
160
|
-
*
|
|
191
|
+
* With no argument, the reset clones `table.initialState.columnVisibility` when
|
|
192
|
+
* it exists. Passing `true` ignores initial state and resets to `{}`.
|
|
161
193
|
*
|
|
162
194
|
* @example
|
|
163
195
|
* ```ts
|
|
@@ -169,9 +201,9 @@ function table_resetColumnVisibility(table, defaultState) {
|
|
|
169
201
|
table_setColumnVisibility(table, defaultState ? {} : cloneState(table.initialState.columnVisibility ?? {}));
|
|
170
202
|
}
|
|
171
203
|
/**
|
|
172
|
-
*
|
|
204
|
+
* Shows or hides every hideable leaf column.
|
|
173
205
|
*
|
|
174
|
-
*
|
|
206
|
+
* Columns that cannot hide stay visible when toggling all columns off.
|
|
175
207
|
*
|
|
176
208
|
* @example
|
|
177
209
|
* ```ts
|
|
@@ -181,43 +213,49 @@ function table_resetColumnVisibility(table, defaultState) {
|
|
|
181
213
|
function table_toggleAllColumnsVisible(table, value) {
|
|
182
214
|
value = value ?? !table_getIsAllColumnsVisible(table);
|
|
183
215
|
const visibility = {};
|
|
184
|
-
|
|
216
|
+
const leafColumns = table.getAllLeafColumns();
|
|
217
|
+
for (let i = 0; i < leafColumns.length; i++) {
|
|
218
|
+
const column = leafColumns[i];
|
|
219
|
+
visibility[column.id] = !value ? !column_getCanHide(column) : value;
|
|
220
|
+
}
|
|
185
221
|
table_setColumnVisibility(table, visibility);
|
|
186
222
|
}
|
|
187
223
|
/**
|
|
188
|
-
*
|
|
224
|
+
* Checks whether every leaf column is currently visible.
|
|
189
225
|
*
|
|
190
|
-
*
|
|
226
|
+
* Non-hideable columns are naturally visible because missing visibility entries
|
|
227
|
+
* default to `true`.
|
|
191
228
|
*
|
|
192
229
|
* @example
|
|
193
230
|
* ```ts
|
|
194
|
-
* const
|
|
231
|
+
* const allVisible = table_getIsAllColumnsVisible(table)
|
|
195
232
|
* ```
|
|
196
233
|
*/
|
|
197
234
|
function table_getIsAllColumnsVisible(table) {
|
|
198
235
|
return !table.getAllLeafColumns().some((column) => !callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible));
|
|
199
236
|
}
|
|
200
237
|
/**
|
|
201
|
-
*
|
|
238
|
+
* Checks whether at least one leaf column is currently visible.
|
|
202
239
|
*
|
|
203
|
-
* This
|
|
240
|
+
* This is useful for tri-state "show all columns" controls.
|
|
204
241
|
*
|
|
205
242
|
* @example
|
|
206
243
|
* ```ts
|
|
207
|
-
* const
|
|
244
|
+
* const someVisible = table_getIsSomeColumnsVisible(table)
|
|
208
245
|
* ```
|
|
209
246
|
*/
|
|
210
247
|
function table_getIsSomeColumnsVisible(table) {
|
|
211
248
|
return table.getAllLeafColumns().some((column) => callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible));
|
|
212
249
|
}
|
|
213
250
|
/**
|
|
214
|
-
*
|
|
251
|
+
* Creates a checkbox-style handler that shows or hides all columns.
|
|
215
252
|
*
|
|
216
|
-
* The handler
|
|
253
|
+
* The handler reads `event.target.checked`, so it is intended for controls whose
|
|
254
|
+
* checked state means "all columns visible".
|
|
217
255
|
*
|
|
218
256
|
* @example
|
|
219
257
|
* ```ts
|
|
220
|
-
* const
|
|
258
|
+
* const onChange = table_getToggleAllColumnsVisibilityHandler(table)
|
|
221
259
|
* ```
|
|
222
260
|
*/
|
|
223
261
|
function table_getToggleAllColumnsVisibilityHandler(table) {
|
|
@@ -227,5 +265,5 @@ function table_getToggleAllColumnsVisibilityHandler(table) {
|
|
|
227
265
|
}
|
|
228
266
|
|
|
229
267
|
//#endregion
|
|
230
|
-
export { column_getCanHide, column_getIsVisible, column_getToggleVisibilityHandler, column_toggleVisibility, getDefaultColumnVisibilityState, row_getVisibleCells, table_getIsAllColumnsVisible, table_getIsSomeColumnsVisible, table_getToggleAllColumnsVisibilityHandler, table_getVisibleFlatColumns, table_getVisibleLeafColumns, table_resetColumnVisibility, table_setColumnVisibility, table_toggleAllColumnsVisible };
|
|
268
|
+
export { column_getCanHide, column_getIsVisible, column_getToggleVisibilityHandler, column_toggleVisibility, getDefaultColumnVisibilityState, row_getVisibleCells, row_getVisibleCellsByColumnId, table_getIsAllColumnsVisible, table_getIsSomeColumnsVisible, table_getToggleAllColumnsVisibilityHandler, table_getVisibleFlatColumns, table_getVisibleLeafColumns, table_resetColumnVisibility, table_setColumnVisibility, table_toggleAllColumnsVisible };
|
|
231
269
|
//# sourceMappingURL=columnVisibilityFeature.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnVisibilityFeature.utils.js","names":[],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn, cloneState } from '../../utils'\nimport { getDefaultColumnPinningState } from '../column-pinning/columnPinningFeature.utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Cell } from '../../types/Cell'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnVisibilityState } from './columnVisibilityFeature.types'\nimport type { Row } from '../../types/Row'\n\n/**\n * Returns the default column visibility 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 = getDefaultColumnVisibilityState()\n * ```\n */\nexport function getDefaultColumnVisibilityState(): ColumnVisibilityState {\n return {}\n}\n\n/**\n * Toggles visibility for a column.\n *\n * The update is applied through the owning table state slice and respects the feature options for that column.\n *\n * @example\n * ```ts\n * column_toggleVisibility(column)\n * ```\n */\nexport function column_toggleVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, visible?: boolean): void {\n if (column_getCanHide(column)) {\n table_setColumnVisibility(column.table, (old) => ({\n ...old,\n [column.id]:\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n }))\n }\n}\n\n/**\n * Returns is visible for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsVisible(column)\n * ```\n */\nexport function column_getIsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n const childColumns = column.columns\n return (\n (childColumns.length\n ? childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n : column.table.atoms.columnVisibility?.get()?.[column.id]) ?? true\n )\n}\n\n/**\n * Returns whether a column can use hide.\n *\n * This combines column options, table options, and any required accessor or feature state for the capability.\n *\n * @example\n * ```ts\n * const value = column_getCanHide(column)\n * ```\n */\nexport function column_getCanHide<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableHiding ?? true) &&\n (column.table.options.enableHiding ?? true)\n )\n}\n\n/**\n * Returns an event handler for toggling visibility handler.\n *\n * The handler is intended for direct use in column header controls such as buttons or checkboxes.\n *\n * @example\n * ```ts\n * const value = column_getToggleVisibilityHandler(column)\n * ```\n */\nexport function column_getToggleVisibilityHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (e: unknown) => {\n column_toggleVisibility(\n column,\n ((e as MouseEvent).target as HTMLInputElement).checked,\n )\n }\n}\n\n/**\n * Returns visible cells 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_getVisibleCells(row)\n * ```\n */\nexport function row_getVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const cells = row\n .getAllCells()\n .filter((cell) =>\n callMemoOrStaticFn(cell.column, 'getIsVisible', column_getIsVisible),\n )\n const { left, right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!left.length && !right.length) return cells // no pinning, return early\n\n const cellsByColumnId = new Map<string, Cell<TFeatures, TData, unknown>>()\n for (const cell of cells) cellsByColumnId.set(cell.column.id, cell)\n\n const leftCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (const columnId of left) {\n const cell = cellsByColumnId.get(columnId)\n if (cell) leftCells.push(cell)\n }\n\n const rightCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (const columnId of right) {\n const cell = cellsByColumnId.get(columnId)\n if (cell) rightCells.push(cell)\n }\n\n // Center cells: visible cells in natural column order, minus pinned ones.\n const leftSet = new Set(left)\n const rightSet = new Set(right)\n const centerCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (const cell of cells) {\n const id = cell.column.id\n if (!leftSet.has(id) && !rightSet.has(id)) centerCells.push(cell)\n }\n\n return [...leftCells, ...centerCells, ...rightCells]\n}\n\n/**\n * Returns visible flat columns 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_getVisibleFlatColumns(table)\n * ```\n */\nexport function table_getVisibleFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllFlatColumns()\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns visible leaf columns 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_getVisibleLeafColumns(table)\n * ```\n */\nexport function table_getVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllLeafColumns()\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Updates the table's column visibility 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_setColumnVisibility(table, (old) => old)\n * ```\n */\nexport function table_setColumnVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnVisibilityState>,\n) {\n table.options.onColumnVisibilityChange?.(updater)\n}\n\n/**\n * Resets the table's column visibility 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_resetColumnVisibility(table)\n * table_resetColumnVisibility(table, true)\n * ```\n */\nexport function table_resetColumnVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnVisibility(\n table,\n defaultState ? {} : cloneState(table.initialState.columnVisibility ?? {}),\n )\n}\n\n/**\n * Toggles all columns visible 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_toggleAllColumnsVisible(table)\n * ```\n */\nexport function table_toggleAllColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, value?: boolean) {\n value = value ?? !table_getIsAllColumnsVisible(table)\n\n const visibility: Record<string, boolean> = {}\n for (const column of table.getAllLeafColumns()) {\n visibility[column.id] = !value ? !column_getCanHide(column) : value\n }\n\n table_setColumnVisibility(table, visibility)\n}\n\n/**\n * Returns is all columns visible 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_getIsAllColumnsVisible(table)\n * ```\n */\nexport function table_getIsAllColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return !table\n .getAllLeafColumns()\n .some(\n (column) =>\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns is some columns visible 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_getIsSomeColumnsVisible(table)\n * ```\n */\nexport function table_getIsSomeColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllLeafColumns()\n .some((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns an event handler for all columns visibility 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_getToggleAllColumnsVisibilityHandler(table)\n * ```\n */\nexport function table_getToggleAllColumnsVisibilityHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n table_toggleAllColumnsVisible(\n table,\n ((e as MouseEvent).target as HTMLInputElement).checked,\n )\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"columnVisibilityFeature.utils.js","names":[],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn, cloneState } from '../../utils'\nimport { getDefaultColumnPinningState } from '../column-pinning/columnPinningFeature.utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Cell } from '../../types/Cell'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnVisibilityState } from './columnVisibilityFeature.types'\nimport type { Row } from '../../types/Row'\n\n/**\n * Creates the default column visibility state.\n *\n * The feature default is an empty object, where missing column ids are treated\n * as visible. Reset APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const visibility = getDefaultColumnVisibilityState()\n * ```\n */\nexport function getDefaultColumnVisibilityState(): ColumnVisibilityState {\n return {}\n}\n\n/**\n * Updates this column's visibility when hiding is allowed.\n *\n * Passing `visible` stores that value. Omitting it flips the column's current\n * visibility state. Columns that cannot hide are left unchanged.\n *\n * @example\n * ```ts\n * column_toggleVisibility(column)\n * ```\n */\nexport function column_toggleVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, visible?: boolean): void {\n if (column_getCanHide(column)) {\n table_setColumnVisibility(column.table, (old) => ({\n ...old,\n [column.id]:\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n }))\n }\n}\n\n/**\n * Checks whether this column is visible.\n *\n * Leaf columns read `state.columnVisibility[column.id]`, where missing entries\n * default to visible. Parent columns are visible when at least one child column\n * is visible.\n *\n * @example\n * ```ts\n * const visible = column_getIsVisible(column)\n * ```\n */\nexport function column_getIsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n const childColumns = column.columns\n return (\n (childColumns.length\n ? childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n : column.table.atoms.columnVisibility?.get()?.[column.id]) ?? true\n )\n}\n\n/**\n * Checks whether this column is allowed to be hidden.\n *\n * Both `columnDef.enableHiding` and table `enableHiding` default to `true`.\n *\n * @example\n * ```ts\n * const canHide = column_getCanHide(column)\n * ```\n */\nexport function column_getCanHide<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableHiding ?? true) &&\n (column.table.options.enableHiding ?? true)\n )\n}\n\n/**\n * Creates a checkbox-style handler that writes this column's visibility.\n *\n * The handler reads `event.target.checked`, so it is intended for visibility\n * controls whose checked state means \"visible\".\n *\n * @example\n * ```ts\n * const onChange = column_getToggleVisibilityHandler(column)\n * ```\n */\nexport function column_getToggleVisibilityHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (e: unknown) => {\n column_toggleVisibility(\n column,\n ((e as MouseEvent).target as HTMLInputElement).checked,\n )\n }\n}\n\n/**\n * Collects the cells from this row whose columns are visible.\n *\n * When column pinning is active, the result is ordered as left-pinned cells,\n * center cells, then right-pinned cells.\n *\n * @example\n * ```ts\n * const visibleCells = row_getVisibleCells(row)\n * ```\n */\nexport function row_getVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const allCells = row.getAllCells()\n const visibleCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < allCells.length; i++) {\n const cell = allCells[i]!\n if (callMemoOrStaticFn(cell.column, 'getIsVisible', column_getIsVisible)) {\n visibleCells.push(cell)\n }\n }\n\n const { left, right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!left.length && !right.length) return visibleCells // no pinning, return early\n\n const visibleCellsByColumnId = callMemoOrStaticFn(\n row,\n 'getVisibleCellsByColumnId',\n row_getVisibleCellsByColumnId,\n )\n\n const leftCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < left.length; i++) {\n const cell = visibleCellsByColumnId[left[i]!]\n if (cell) leftCells.push(cell)\n }\n\n const rightCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < right.length; i++) {\n const cell = visibleCellsByColumnId[right[i]!]\n if (cell) rightCells.push(cell)\n }\n\n // Center cells: visible cells in natural column order, minus pinned ones.\n const centerCells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < visibleCells.length; i++) {\n const cell = visibleCells[i]!\n const id = cell.column.id\n if (!left.includes(id) && !right.includes(id)) centerCells.push(cell)\n }\n\n return [...leftCells, ...centerCells, ...rightCells]\n}\n\n/**\n * Builds a lookup map of this row's visible cells keyed by column id.\n *\n * Hidden columns are omitted from the map.\n *\n * @example\n * ```ts\n * const visibleCellsById = row_getVisibleCellsByColumnId(row)\n * ```\n */\nexport function row_getVisibleCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Record<string, Cell<TFeatures, TData, unknown>> {\n const result: Record<string, Cell<TFeatures, TData, unknown>> = {}\n const allCells = row.getAllCells()\n for (let i = 0; i < allCells.length; i++) {\n const cell = allCells[i]!\n if (callMemoOrStaticFn(cell.column, 'getIsVisible', column_getIsVisible)) {\n result[cell.column.id] = cell\n }\n }\n return result\n}\n\n/**\n * Filters the flat column list down to visible columns.\n *\n * Parent/group columns are included when `column_getIsVisible` considers them\n * visible.\n *\n * @example\n * ```ts\n * const columns = table_getVisibleFlatColumns(table)\n * ```\n */\nexport function table_getVisibleFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllFlatColumns()\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Filters leaf columns down to those currently visible.\n *\n * This is the column list most row rendering code uses before pinning-specific\n * partitioning.\n *\n * @example\n * ```ts\n * const columns = table_getVisibleLeafColumns(table)\n * ```\n */\nexport function table_getVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllLeafColumns()\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Routes a column visibility updater through the table's visibility change handler.\n *\n * The updater may be a next visibility map or a function of the previous map,\n * matching the instance `table.setColumnVisibility` behavior.\n *\n * @example\n * ```ts\n * table_setColumnVisibility(table, (old) => ({ ...old, age: false }))\n * ```\n */\nexport function table_setColumnVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnVisibilityState>,\n) {\n table.options.onColumnVisibilityChange?.(updater)\n}\n\n/**\n * Resets `columnVisibility` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.columnVisibility` when\n * it exists. Passing `true` ignores initial state and resets to `{}`.\n *\n * @example\n * ```ts\n * table_resetColumnVisibility(table)\n * table_resetColumnVisibility(table, true)\n * ```\n */\nexport function table_resetColumnVisibility<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnVisibility(\n table,\n defaultState ? {} : cloneState(table.initialState.columnVisibility ?? {}),\n )\n}\n\n/**\n * Shows or hides every hideable leaf column.\n *\n * Columns that cannot hide stay visible when toggling all columns off.\n *\n * @example\n * ```ts\n * table_toggleAllColumnsVisible(table)\n * ```\n */\nexport function table_toggleAllColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, value?: boolean) {\n value = value ?? !table_getIsAllColumnsVisible(table)\n\n const visibility: Record<string, boolean> = {}\n const leafColumns = table.getAllLeafColumns()\n for (let i = 0; i < leafColumns.length; i++) {\n const column = leafColumns[i]!\n visibility[column.id] = !value ? !column_getCanHide(column) : value\n }\n\n table_setColumnVisibility(table, visibility)\n}\n\n/**\n * Checks whether every leaf column is currently visible.\n *\n * Non-hideable columns are naturally visible because missing visibility entries\n * default to `true`.\n *\n * @example\n * ```ts\n * const allVisible = table_getIsAllColumnsVisible(table)\n * ```\n */\nexport function table_getIsAllColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return !table\n .getAllLeafColumns()\n .some(\n (column) =>\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Checks whether at least one leaf column is currently visible.\n *\n * This is useful for tri-state \"show all columns\" controls.\n *\n * @example\n * ```ts\n * const someVisible = table_getIsSomeColumnsVisible(table)\n * ```\n */\nexport function table_getIsSomeColumnsVisible<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return table\n .getAllLeafColumns()\n .some((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Creates a checkbox-style handler that shows or hides all columns.\n *\n * The handler reads `event.target.checked`, so it is intended for controls whose\n * checked state means \"all columns visible\".\n *\n * @example\n * ```ts\n * const onChange = table_getToggleAllColumnsVisibilityHandler(table)\n * ```\n */\nexport function table_getToggleAllColumnsVisibilityHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return (e: unknown) => {\n table_toggleAllColumnsVisible(\n table,\n ((e as MouseEvent).target as HTMLInputElement).checked,\n )\n }\n}\n"],"mappings":"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"}
|
|
@@ -9,19 +9,22 @@ interface TableState_GlobalFiltering {
|
|
|
9
9
|
}
|
|
10
10
|
interface ColumnDef_GlobalFiltering {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Allows this column to be scanned by global filtering.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `true`; table-level global filtering and `enableFilters` must
|
|
15
|
+
* also allow filtering.
|
|
13
16
|
*/
|
|
14
17
|
enableGlobalFilter?: boolean;
|
|
15
18
|
}
|
|
16
19
|
interface Column_GlobalFiltering {
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* Checks whether this accessor column participates in global filtering.
|
|
19
22
|
*/
|
|
20
23
|
getCanGlobalFilter: () => boolean;
|
|
21
24
|
}
|
|
22
25
|
interface TableOptions_GlobalFiltering<TFeatures extends TableFeatures, TData extends RowData> {
|
|
23
26
|
/**
|
|
24
|
-
* Enables
|
|
27
|
+
* Enables global filtering across columns that allow it.
|
|
25
28
|
*/
|
|
26
29
|
enableGlobalFilter?: boolean;
|
|
27
30
|
/**
|
|
@@ -53,11 +56,13 @@ interface Table_GlobalFiltering<TFeatures extends TableFeatures, TData extends R
|
|
|
53
56
|
*/
|
|
54
57
|
getGlobalFilterFn: () => FilterFn<TFeatures, TData> | undefined;
|
|
55
58
|
/**
|
|
56
|
-
* Resets
|
|
59
|
+
* Resets `globalFilter` to `initialState.globalFilter`.
|
|
60
|
+
*
|
|
61
|
+
* Pass `true` to ignore initial state and reset to `undefined`.
|
|
57
62
|
*/
|
|
58
63
|
resetGlobalFilter: (defaultState?: boolean) => void;
|
|
59
64
|
/**
|
|
60
|
-
*
|
|
65
|
+
* Updates global filter state with a next value or updater function.
|
|
61
66
|
*/
|
|
62
67
|
setGlobalFilter: (updater: Updater<any>) => void;
|
|
63
68
|
}
|
|
@@ -9,19 +9,22 @@ interface TableState_GlobalFiltering {
|
|
|
9
9
|
}
|
|
10
10
|
interface ColumnDef_GlobalFiltering {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Allows this column to be scanned by global filtering.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `true`; table-level global filtering and `enableFilters` must
|
|
15
|
+
* also allow filtering.
|
|
13
16
|
*/
|
|
14
17
|
enableGlobalFilter?: boolean;
|
|
15
18
|
}
|
|
16
19
|
interface Column_GlobalFiltering {
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
21
|
+
* Checks whether this accessor column participates in global filtering.
|
|
19
22
|
*/
|
|
20
23
|
getCanGlobalFilter: () => boolean;
|
|
21
24
|
}
|
|
22
25
|
interface TableOptions_GlobalFiltering<TFeatures extends TableFeatures, TData extends RowData> {
|
|
23
26
|
/**
|
|
24
|
-
* Enables
|
|
27
|
+
* Enables global filtering across columns that allow it.
|
|
25
28
|
*/
|
|
26
29
|
enableGlobalFilter?: boolean;
|
|
27
30
|
/**
|
|
@@ -53,11 +56,13 @@ interface Table_GlobalFiltering<TFeatures extends TableFeatures, TData extends R
|
|
|
53
56
|
*/
|
|
54
57
|
getGlobalFilterFn: () => FilterFn<TFeatures, TData> | undefined;
|
|
55
58
|
/**
|
|
56
|
-
* Resets
|
|
59
|
+
* Resets `globalFilter` to `initialState.globalFilter`.
|
|
60
|
+
*
|
|
61
|
+
* Pass `true` to ignore initial state and reset to `undefined`.
|
|
57
62
|
*/
|
|
58
63
|
resetGlobalFilter: (defaultState?: boolean) => void;
|
|
59
64
|
/**
|
|
60
|
-
*
|
|
65
|
+
* Updates global filter state with a next value or updater function.
|
|
61
66
|
*/
|
|
62
67
|
setGlobalFilter: (updater: Updater<any>) => void;
|
|
63
68
|
}
|
|
@@ -3,13 +3,14 @@ const require_filterFns = require('../../fns/filterFns.cjs');
|
|
|
3
3
|
|
|
4
4
|
//#region src/features/global-filtering/globalFilteringFeature.utils.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Checks whether this accessor column participates in global filtering.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* The column must have an accessor and pass column-level, table-level, and
|
|
9
|
+
* optional `getColumnCanGlobalFilter` checks.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```ts
|
|
12
|
-
* const
|
|
13
|
+
* const canGlobalFilter = column_getCanGlobalFilter(column)
|
|
13
14
|
* ```
|
|
14
15
|
*/
|
|
15
16
|
function column_getCanGlobalFilter(column) {
|
|
@@ -17,26 +18,29 @@ function column_getCanGlobalFilter(column) {
|
|
|
17
18
|
return (column.columnDef.enableGlobalFilter ?? true) && (column.table.options.enableGlobalFilter ?? true) && (column.table.options.enableFilters ?? true) && (((_column$table$options = (_column$table$options2 = column.table.options).getColumnCanGlobalFilter) === null || _column$table$options === void 0 ? void 0 : _column$table$options.call(_column$table$options2, column)) ?? true) && !!column.accessorFn;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* Provides the built-in automatic global filter function.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
+
* Global filtering defaults to `includesString`, which gives search-box style
|
|
24
|
+
* matching across globally filterable columns.
|
|
23
25
|
*
|
|
24
26
|
* @example
|
|
25
27
|
* ```ts
|
|
26
|
-
* const
|
|
28
|
+
* const filterFn = table_getGlobalAutoFilterFn()
|
|
27
29
|
* ```
|
|
28
30
|
*/
|
|
29
31
|
function table_getGlobalAutoFilterFn() {
|
|
30
32
|
return require_filterFns.filterFn_includesString;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
35
|
+
* Resolves the filter function used for global filtering.
|
|
34
36
|
*
|
|
35
|
-
*
|
|
37
|
+
* Function-valued `options.globalFilterFn` is returned directly, `'auto'`
|
|
38
|
+
* delegates to `table_getGlobalAutoFilterFn`, and string values are looked up in
|
|
39
|
+
* the table's filter function registry.
|
|
36
40
|
*
|
|
37
41
|
* @example
|
|
38
42
|
* ```ts
|
|
39
|
-
* const
|
|
43
|
+
* const filterFn = table_getGlobalFilterFn(table)
|
|
40
44
|
* ```
|
|
41
45
|
*/
|
|
42
46
|
function table_getGlobalFilterFn(table) {
|
|
@@ -45,13 +49,14 @@ function table_getGlobalFilterFn(table) {
|
|
|
45
49
|
return require_utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table_getGlobalAutoFilterFn() : filterFns === null || filterFns === void 0 ? void 0 : filterFns[globalFilterFn];
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
|
-
*
|
|
52
|
+
* Routes a global filter updater through the table's global filter handler.
|
|
49
53
|
*
|
|
50
|
-
* The updater
|
|
54
|
+
* The updater may be a next value or a function of the previous value, matching
|
|
55
|
+
* the instance `table.setGlobalFilter` behavior.
|
|
51
56
|
*
|
|
52
57
|
* @example
|
|
53
58
|
* ```ts
|
|
54
|
-
* table_setGlobalFilter(table,
|
|
59
|
+
* table_setGlobalFilter(table, 'search text')
|
|
55
60
|
* ```
|
|
56
61
|
*/
|
|
57
62
|
function table_setGlobalFilter(table, updater) {
|
|
@@ -59,9 +64,10 @@ function table_setGlobalFilter(table, updater) {
|
|
|
59
64
|
(_table$options$onGlob = (_table$options = table.options).onGlobalFilterChange) === null || _table$options$onGlob === void 0 || _table$options$onGlob.call(_table$options, updater);
|
|
60
65
|
}
|
|
61
66
|
/**
|
|
62
|
-
* Resets the
|
|
67
|
+
* Resets `globalFilter` to the configured initial state or feature default.
|
|
63
68
|
*
|
|
64
|
-
*
|
|
69
|
+
* With no argument, the reset clones `table.initialState.globalFilter`. Passing
|
|
70
|
+
* `true` ignores initial state and resets to `undefined`.
|
|
65
71
|
*
|
|
66
72
|
* @example
|
|
67
73
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalFilteringFeature.utils.cjs","names":["filterFn_includesString","isFunction","cloneState"],"sources":["../../../src/features/global-filtering/globalFilteringFeature.utils.ts"],"sourcesContent":["import { filterFn_includesString } from '../../fns/filterFns'\nimport { cloneState, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { FilterFn } from '../column-filtering/columnFilteringFeature.types'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"globalFilteringFeature.utils.cjs","names":["filterFn_includesString","isFunction","cloneState"],"sources":["../../../src/features/global-filtering/globalFilteringFeature.utils.ts"],"sourcesContent":["import { filterFn_includesString } from '../../fns/filterFns'\nimport { cloneState, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { FilterFn } from '../column-filtering/columnFilteringFeature.types'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\n\n/**\n * Checks whether this accessor column participates in global filtering.\n *\n * The column must have an accessor and pass column-level, table-level, and\n * optional `getColumnCanGlobalFilter` checks.\n *\n * @example\n * ```ts\n * const canGlobalFilter = column_getCanGlobalFilter(column)\n * ```\n */\nexport function column_getCanGlobalFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return (\n (column.columnDef.enableGlobalFilter ?? true) &&\n (column.table.options.enableGlobalFilter ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n (column.table.options.getColumnCanGlobalFilter?.(column) ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Provides the built-in automatic global filter function.\n *\n * Global filtering defaults to `includesString`, which gives search-box style\n * matching across globally filterable columns.\n *\n * @example\n * ```ts\n * const filterFn = table_getGlobalAutoFilterFn()\n * ```\n */\nexport function table_getGlobalAutoFilterFn() {\n return filterFn_includesString\n}\n\n/**\n * Resolves the filter function used for global filtering.\n *\n * Function-valued `options.globalFilterFn` is returned directly, `'auto'`\n * delegates to `table_getGlobalAutoFilterFn`, and string values are looked up in\n * the table's filter function registry.\n *\n * @example\n * ```ts\n * const filterFn = table_getGlobalFilterFn(table)\n * ```\n */\nexport function table_getGlobalFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): FilterFn<TFeatures, TData> | FilterFn<TFeatures, TData> | undefined {\n const { globalFilterFn: globalFilterFn } = table.options\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n table._rowModelFns.filterFns\n\n return isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table_getGlobalAutoFilterFn()\n : filterFns?.[globalFilterFn as string]\n}\n\n/**\n * Routes a global filter updater through the table's global filter handler.\n *\n * The updater may be a next value or a function of the previous value, matching\n * the instance `table.setGlobalFilter` behavior.\n *\n * @example\n * ```ts\n * table_setGlobalFilter(table, 'search text')\n * ```\n */\nexport function table_setGlobalFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: any) {\n table.options.onGlobalFilterChange?.(updater)\n}\n\n/**\n * Resets `globalFilter` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.globalFilter`. Passing\n * `true` ignores initial state and resets to `undefined`.\n *\n * @example\n * ```ts\n * table_resetGlobalFilter(table)\n * table_resetGlobalFilter(table, true)\n * ```\n */\nexport function table_resetGlobalFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGlobalFilter(\n table,\n defaultState ? undefined : cloneState(table.initialState.globalFilter),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,0BAId,QAA4D;;CAC5D,QACG,OAAO,UAAU,sBAAsB,UACvC,OAAO,MAAM,QAAQ,sBAAsB,UAC3C,OAAO,MAAM,QAAQ,iBAAiB,8DACtC,OAAO,MAAM,SAAQ,qIAA2B,OAAO,KAAI,SAC5D,CAAC,CAAC,OAAO;;;;;;;;;;;;;AAeb,SAAgB,8BAA8B;CAC5C,OAAOA;;;;;;;;;;;;;;AAeT,SAAgB,wBAId,OACqE;CACrE,MAAM,EAAkB,mBAAmB,MAAM;CACjD,MAAM,YACJ,MAAM,aAAa;CAErB,OAAOC,yBAAW,eAAe,GAC7B,iBACA,mBAAmB,SACjB,6BAA6B,yDAC7B,UAAY;;;;;;;;;;;;;AAcpB,SAAgB,sBAGd,OAAyC,SAAc;;CACvD,iDAAM,SAAQ,iHAAuB,QAAQ;;;;;;;;;;;;;;AAe/C,SAAgB,wBAGd,OAAyC,cAAwB;CACjE,sBACE,OACA,eAAe,SAAYC,yBAAW,MAAM,aAAa,aAAa,CACvE"}
|