@tanstack/table-core 9.0.0-beta.31 → 9.0.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/cells/constructCell.cjs +1 -4
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.d.cts +1 -1
- package/dist/core/cells/constructCell.d.ts +1 -1
- package/dist/core/cells/constructCell.js +1 -4
- package/dist/core/cells/constructCell.js.map +1 -1
- package/dist/core/cells/coreCellsFeature.types.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.types.d.ts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.cts +1 -1
- package/dist/core/cells/coreCellsFeature.utils.d.ts +1 -1
- package/dist/core/columns/constructColumn.cjs +3 -9
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.js +3 -9
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.cjs +12 -18
- package/dist/core/columns/coreColumnsFeature.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.js +12 -18
- package/dist/core/columns/coreColumnsFeature.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.cjs +2 -6
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js +2 -6
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs +1 -2
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js +1 -2
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/constructHeader.cjs +1 -4
- package/dist/core/headers/constructHeader.cjs.map +1 -1
- package/dist/core/headers/constructHeader.js +1 -4
- package/dist/core/headers/constructHeader.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +8 -11
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +8 -11
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +2 -4
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +2 -4
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs +6 -24
- package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +1 -1
- package/dist/core/row-models/coreRowModelsFeature.utils.js +6 -24
- package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
- package/dist/core/row-models/createCoreRowModel.cjs +2 -3
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +1 -1
- package/dist/core/row-models/createCoreRowModel.d.ts +1 -1
- package/dist/core/row-models/createCoreRowModel.js +2 -3
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/constructRow.cjs +2 -8
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.js +2 -8
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.cjs +4 -1
- package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.js +4 -1
- package/dist/core/rows/coreRowsFeature.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.cjs +3 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.cts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.d.ts +1 -1
- package/dist/core/rows/coreRowsFeature.utils.js +3 -4
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +4 -10
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +4 -10
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/experimental-worker-plugin.cjs +14 -0
- package/dist/experimental-worker-plugin.d.cts +5 -0
- package/dist/experimental-worker-plugin.d.ts +5 -0
- package/dist/experimental-worker-plugin.js +6 -0
- package/dist/features/column-faceting/columnFacetingFeature.cjs +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.js +12 -18
- package/dist/features/column-faceting/columnFacetingFeature.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +7 -25
- package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.utils.js +7 -25
- package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -14
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.cts +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.d.ts +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js +8 -14
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +10 -13
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.js +10 -13
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +12 -18
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.cts +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.d.ts +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +12 -18
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.cjs +1 -4
- package/dist/features/column-grouping/columnGroupingFeature.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.js +1 -4
- package/dist/features/column-grouping/columnGroupingFeature.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +4 -4
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +8 -13
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.utils.js +8 -13
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.cjs +3 -7
- package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.cts +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.d.ts +1 -1
- package/dist/features/column-grouping/createGroupedRowModel.js +3 -7
- package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.cjs +13 -19
- package/dist/features/column-ordering/columnOrderingFeature.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.js +13 -19
- package/dist/features/column-ordering/columnOrderingFeature.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +6 -11
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +6 -11
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +78 -114
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.js +78 -114
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +15 -28
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.js +15 -28
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs +12 -16
- package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.utils.js +12 -16
- package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +24 -48
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +24 -48
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +11 -18
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.js +11 -18
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +25 -40
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +25 -40
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +3 -6
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +3 -6
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.cjs +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.js +1 -2
- package/dist/features/global-filtering/globalFilteringFeature.js.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +3 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js +3 -5
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.cjs +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.cjs.map +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.cts +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.d.ts +1 -1
- package/dist/features/row-expanding/createExpandedRowModel.js +6 -10
- package/dist/features/row-expanding/createExpandedRowModel.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +8 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +8 -15
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.cjs +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.cjs.map +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.cts +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.d.ts +1 -1
- package/dist/features/row-pagination/createPaginatedRowModel.js +6 -10
- package/dist/features/row-pagination/createPaginatedRowModel.js.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +8 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.utils.js +8 -14
- package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.cjs +4 -16
- package/dist/features/row-pinning/rowPinningFeature.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.js +4 -16
- package/dist/features/row-pinning/rowPinningFeature.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +7 -12
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.js +7 -12
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.cjs +30 -60
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +30 -60
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +11 -18
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.js +12 -19
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +20 -14
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.cts +1 -1
- package/dist/features/row-sorting/createSortedRowModel.d.ts +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +21 -15
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +10 -14
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +10 -14
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/flex-render.d.cts +1 -1
- package/dist/flex-render.d.ts +1 -1
- package/dist/fns/filterFns.cjs +8 -12
- package/dist/fns/filterFns.cjs.map +1 -1
- package/dist/fns/filterFns.js +8 -12
- package/dist/fns/filterFns.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +18 -18
- package/dist/index.d.ts +18 -18
- package/dist/index.js +2 -2
- package/dist/store-reactivity-bindings.cjs +2 -2
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.js +2 -2
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/types/Cell.d.cts +1 -1
- package/dist/types/Cell.d.ts +1 -1
- package/dist/types/Column.d.cts +7 -7
- package/dist/types/Column.d.ts +7 -7
- package/dist/types/ColumnDef.d.cts +6 -6
- package/dist/types/ColumnDef.d.ts +6 -6
- package/dist/types/Header.d.cts +1 -1
- package/dist/types/Header.d.ts +1 -1
- package/dist/types/Row.d.cts +2 -2
- package/dist/types/Row.d.ts +2 -2
- package/dist/types/RowModel.d.cts +4 -4
- package/dist/types/RowModel.d.ts +4 -4
- package/dist/types/RowModelFns.d.cts +2 -2
- package/dist/types/RowModelFns.d.ts +2 -2
- package/dist/types/Table.d.cts +9 -9
- package/dist/types/Table.d.ts +9 -9
- package/dist/types/TableFeatures.d.cts +4 -4
- package/dist/types/TableFeatures.d.ts +4 -4
- package/dist/types/TableOptions.d.cts +7 -7
- package/dist/types/TableOptions.d.ts +7 -7
- package/dist/types/TableState.d.cts +6 -6
- package/dist/types/TableState.d.ts +6 -6
- package/dist/utils.cjs +23 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.js +23 -13
- package/dist/utils.js.map +1 -1
- package/dist/worker/createTableWorker.cjs +189 -0
- package/dist/worker/createTableWorker.cjs.map +1 -0
- package/dist/worker/createTableWorker.d.cts +102 -0
- package/dist/worker/createTableWorker.d.ts +102 -0
- package/dist/worker/createTableWorker.js +186 -0
- package/dist/worker/createTableWorker.js.map +1 -0
- package/dist/worker/createWorkerRowModel.cjs +78 -0
- package/dist/worker/createWorkerRowModel.cjs.map +1 -0
- package/dist/worker/createWorkerRowModel.d.cts +42 -0
- package/dist/worker/createWorkerRowModel.d.ts +42 -0
- package/dist/worker/createWorkerRowModel.js +78 -0
- package/dist/worker/createWorkerRowModel.js.map +1 -0
- package/dist/worker/initTableWorker.cjs +100 -0
- package/dist/worker/initTableWorker.cjs.map +1 -0
- package/dist/worker/initTableWorker.d.cts +33 -0
- package/dist/worker/initTableWorker.d.ts +33 -0
- package/dist/worker/initTableWorker.js +100 -0
- package/dist/worker/initTableWorker.js.map +1 -0
- package/dist/worker/rebuildRowModel.cjs +72 -0
- package/dist/worker/rebuildRowModel.cjs.map +1 -0
- package/dist/worker/rebuildRowModel.d.cts +9 -0
- package/dist/worker/rebuildRowModel.d.ts +9 -0
- package/dist/worker/rebuildRowModel.js +72 -0
- package/dist/worker/rebuildRowModel.js.map +1 -0
- package/dist/worker/serializeRowModel.cjs +53 -0
- package/dist/worker/serializeRowModel.cjs.map +1 -0
- package/dist/worker/serializeRowModel.js +52 -0
- package/dist/worker/serializeRowModel.js.map +1 -0
- package/dist/worker/tableWorkerProtocol.cjs +29 -0
- package/dist/worker/tableWorkerProtocol.cjs.map +1 -0
- package/dist/worker/tableWorkerProtocol.d.cts +88 -0
- package/dist/worker/tableWorkerProtocol.d.ts +88 -0
- package/dist/worker/tableWorkerProtocol.js +27 -0
- package/dist/worker/tableWorkerProtocol.js.map +1 -0
- package/package.json +6 -2
- package/src/core/rows/coreRowsFeature.ts +1 -0
- package/src/experimental-worker-plugin.ts +22 -0
- package/src/features/row-selection/rowSelectionFeature.utils.ts +2 -1
- package/src/features/row-sorting/createSortedRowModel.ts +31 -10
- package/src/features/row-sorting/rowSortingFeature.utils.ts +2 -10
- package/src/utils.ts +21 -0
- package/src/worker/createTableWorker.ts +357 -0
- package/src/worker/createWorkerRowModel.ts +121 -0
- package/src/worker/initTableWorker.ts +164 -0
- package/src/worker/rebuildRowModel.ts +117 -0
- package/src/worker/serializeRowModel.ts +80 -0
- package/src/worker/tableWorkerProtocol.ts +105 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnVisibilityFeature.utils.cjs","names":["makeObjectMap","callMemoOrStaticFn","hasOwn","getDefaultColumnPinningState","cloneState"],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import {\n callMemoOrStaticFn,\n cloneState,\n hasOwn,\n makeObjectMap,\n} 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 makeObjectMap()\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 const next = Object.assign(makeObjectMap<boolean>(), old)\n next[column.id] =\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n return next\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 columnVisibility = column.table.atoms.columnVisibility?.get()\n if (!columnVisibility) return true\n\n const childColumns = column.columns\n if (childColumns.length) {\n return childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n }\n\n return (\n (hasOwn(columnVisibility, column.id)\n ? columnVisibility[column.id]\n : undefined) ?? 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 = makeObjectMap<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\n ? makeObjectMap()\n : Object.assign(\n makeObjectMap<boolean>(),\n cloneState(table.initialState.columnVisibility ?? {}),\n ),\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 = makeObjectMap<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":";;;;;;;;;;;;;;;AA0BA,SAAgB,kCAAyD;CACvE,OAAOA,4BAAc;AACvB;;;;;;;;;;;;AAaA,SAAgB,wBAId,QAAmD,SAAyB;CAC5E,IAAI,kBAAkB,MAAM,GAC1B,0BAA0B,OAAO,QAAQ,QAAQ;EAC/C,MAAM,OAAO,OAAO,OAAOA,4BAAuB,GAAG,GAAG;EACxD,KAAK,OAAO,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CACN;AACF;;;;;;;;;;;AAYA,SAAgB,8BAGd,OAAyC,OAAiB;CAC1D,QAAQ,SAAS,CAAC,6BAA6B,KAAK;CAEpD,MAAM,aAAaJ,4BAAuB;CAC1C,MAAM,cAAc,MAAM,kBAAkB;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,SAAS,YAAY;EAC3B,WAAW,OAAO,MAAM,CAAC,QAAQ,CAAC,kBAAkB,MAAM,IAAI;CAChE;CAEA,0BAA0B,OAAO,UAAU;AAC7C;;;;;;;;;;;;AAaA,SAAgB,6BAGd,OAAyC;CACzC,OAAO,CAAC,MACL,kBAAkB,CAAC,CACnB,MACE,WACC,CAACC,iCAAmB,QAAQ,gBAAgB,mBAAmB,CACnE;AACJ;;;;;;;;;;;AAYA,SAAgB,8BAGd,OAAyC;CACzC,OAAO,MACJ,kBAAkB,CAAC,CACnB,MAAM,WACLA,iCAAmB,QAAQ,gBAAgB,mBAAmB,CAChE;AACJ;;;;;;;;;;;;AAaA,SAAgB,2CAGd,OAAyC;CACzC,QAAQ,MAAe;EACrB,8BACE,OACE,EAAiB,OAA4B,OACjD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"columnVisibilityFeature.utils.cjs","names":["makeObjectMap","callMemoOrStaticFn","hasOwn","getDefaultColumnPinningState","cloneState"],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import {\n callMemoOrStaticFn,\n cloneState,\n hasOwn,\n makeObjectMap,\n} 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 makeObjectMap()\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 const next = Object.assign(makeObjectMap<boolean>(), old)\n next[column.id] =\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n return next\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 columnVisibility = column.table.atoms.columnVisibility?.get()\n if (!columnVisibility) return true\n\n const childColumns = column.columns\n if (childColumns.length) {\n return childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n }\n\n return (\n (hasOwn(columnVisibility, column.id)\n ? columnVisibility[column.id]\n : undefined) ?? 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 = makeObjectMap<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\n ? makeObjectMap()\n : Object.assign(\n makeObjectMap<boolean>(),\n cloneState(table.initialState.columnVisibility ?? {}),\n ),\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 = makeObjectMap<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":";;;;;;;;;;;;;;;AA0BA,SAAgB,kCAAyD;CACvE,OAAOA,4BAAc;AACvB;;;;;;;;;;;;AAaA,SAAgB,wBAId,QAAmD,SAAyB;CAC5E,IAAI,kBAAkB,MAAM,GAC1B,0BAA0B,OAAO,QAAQ,QAAQ;EAC/C,MAAM,OAAO,OAAO,OAAOA,4BAAuB,GAAG,GAAG;EACxD,KAAK,OAAO,MACV,WACA,CAACC,iCAAmB,QAAQ,gBAAgB,mBAAmB;EACjE,OAAO;CACT,CAAC;AAEL;;;;;;;;;;;;;AAcA,SAAgB,oBAId,QAA4D;CAC5D,MAAM,mBAAmB,OAAO,MAAM,MAAM,kBAAkB,IAAI;CAClE,IAAI,CAA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AI,YAAY,QAAQ,KAAK;EAC3C,MAAM,SAAS,YAAY;EAC3B,WAAW,OAAO,MAAM,CAAC,QAAQ,CAAC,kBAAkB,MAAM,IAAI;CAChE;CAEA,0BAA0B,OAAO,UAAU;AAC7C;;;;;;;;;;;;AAaA,SAAgB,6BAGd,OAAyC;CACzC,OAAO,CAAC,MACL,kBAAkB,CAAC,CACnB,MACE,WACC,CAACC,iCAAmB,QAAQ,gBAAgB,mBAAmB,CACnE;AACJ;;;;;;;;;;;AAYA,SAAgB,8BAGd,OAAyC;CACzC,OAAO,MACJ,kBAAkB,CAAC,CACnB,MAAM,WACLA,iCAAmB,QAAQ,gBAAgB,mBAAmB,CAChE;AACJ;;;;;;;;;;;;AAaA,SAAgB,2CAGd,OAAyC;CACzC,QAAQ,MAAe;EACrB,8BACE,OACE,EAAiB,OAA4B,OACjD;CACF;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellData, RowData, Updater } from "../../types/type-utils.cjs";
|
|
2
|
+
import { Cell } from "../../types/Cell.cjs";
|
|
2
3
|
import { ColumnVisibilityState } from "./columnVisibilityFeature.types.cjs";
|
|
3
4
|
import { Row } from "../../types/Row.cjs";
|
|
4
5
|
import { Table } from "../../types/Table.cjs";
|
|
5
6
|
import { Column } from "../../types/Column.cjs";
|
|
6
7
|
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
7
|
-
import { Cell } from "../../types/Cell.cjs";
|
|
8
8
|
//#region src/features/column-visibility/columnVisibilityFeature.utils.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Creates the default column visibility state.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CellData, RowData, Updater } from "../../types/type-utils.js";
|
|
2
|
+
import { Cell } from "../../types/Cell.js";
|
|
2
3
|
import { ColumnVisibilityState } from "./columnVisibilityFeature.types.js";
|
|
3
4
|
import { Row } from "../../types/Row.js";
|
|
4
5
|
import { Table } from "../../types/Table.js";
|
|
5
6
|
import { Column } from "../../types/Column.js";
|
|
6
7
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
7
|
-
import { Cell } from "../../types/Cell.js";
|
|
8
8
|
//#region src/features/column-visibility/columnVisibilityFeature.utils.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Creates the default column visibility state.
|
|
@@ -47,8 +47,7 @@ function column_toggleVisibility(column, visible) {
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
function column_getIsVisible(column) {
|
|
50
|
-
|
|
51
|
-
const columnVisibility = (_column$table$atoms$c = column.table.atoms.columnVisibility) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c.get();
|
|
50
|
+
const columnVisibility = column.table.atoms.columnVisibility?.get();
|
|
52
51
|
if (!columnVisibility) return true;
|
|
53
52
|
const childColumns = column.columns;
|
|
54
53
|
if (childColumns.length) return childColumns.some((childColumn) => callMemoOrStaticFn(childColumn, "getIsVisible", column_getIsVisible));
|
|
@@ -95,14 +94,13 @@ function column_getToggleVisibilityHandler(column) {
|
|
|
95
94
|
* ```
|
|
96
95
|
*/
|
|
97
96
|
function row_getVisibleCells(row) {
|
|
98
|
-
var _row$table$atoms$colu;
|
|
99
97
|
const allCells = row.getAllCells();
|
|
100
98
|
const visibleCells = [];
|
|
101
99
|
for (let i = 0; i < allCells.length; i++) {
|
|
102
100
|
const cell = allCells[i];
|
|
103
101
|
if (callMemoOrStaticFn(cell.column, "getIsVisible", column_getIsVisible)) visibleCells.push(cell);
|
|
104
102
|
}
|
|
105
|
-
const { left, right } =
|
|
103
|
+
const { left, right } = row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState();
|
|
106
104
|
if (!left.length && !right.length) return visibleCells;
|
|
107
105
|
const visibleCellsByColumnId = callMemoOrStaticFn(row, "getVisibleCellsByColumnId", row_getVisibleCellsByColumnId);
|
|
108
106
|
const leftCells = [];
|
|
@@ -186,8 +184,7 @@ function table_getVisibleLeafColumns(table) {
|
|
|
186
184
|
* ```
|
|
187
185
|
*/
|
|
188
186
|
function table_setColumnVisibility(table, updater) {
|
|
189
|
-
|
|
190
|
-
(_table$options$onColu = (_table$options = table.options).onColumnVisibilityChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updater);
|
|
187
|
+
table.options.onColumnVisibilityChange?.(updater);
|
|
191
188
|
}
|
|
192
189
|
/**
|
|
193
190
|
* Resets `columnVisibility` to the configured initial state or feature default.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnVisibilityFeature.utils.js","names":[],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import {\n callMemoOrStaticFn,\n cloneState,\n hasOwn,\n makeObjectMap,\n} 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 makeObjectMap()\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 const next = Object.assign(makeObjectMap<boolean>(), old)\n next[column.id] =\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n return next\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 columnVisibility = column.table.atoms.columnVisibility?.get()\n if (!columnVisibility) return true\n\n const childColumns = column.columns\n if (childColumns.length) {\n return childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n }\n\n return (\n (hasOwn(columnVisibility, column.id)\n ? columnVisibility[column.id]\n : undefined) ?? 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 = makeObjectMap<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\n ? makeObjectMap()\n : Object.assign(\n makeObjectMap<boolean>(),\n cloneState(table.initialState.columnVisibility ?? {}),\n ),\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 = makeObjectMap<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":";;;;;;;;;;;;;;;AA0BA,SAAgB,kCAAyD;CACvE,OAAO,cAAc;AACvB;;;;;;;;;;;;AAaA,SAAgB,wBAId,QAAmD,SAAyB;CAC5E,IAAI,kBAAkB,MAAM,GAC1B,0BAA0B,OAAO,QAAQ,QAAQ;EAC/C,MAAM,OAAO,OAAO,OAAO,cAAuB,GAAG,GAAG;EACxD,KAAK,OAAO,MACV,WACA,CAAC,mBAAmB,QAAQ,gBAAgB,mBAAmB;EACjE,OAAO;CACT,CAAC;AAEL;;;;;;;;;;;;;AAcA,SAAgB,oBAId,QAA4D;;CAC5D,MAAM,4CAAmB,OAAO,MAAM,MAAM,gGAAkB,IAAI;CAClE,IAAI,CAAC,kBAAkB,OAAO;CAE9B,MAAM,eAAe,OAAO;CAC5B,IAAI,aAAa,QACf,OAAO,aAAa,MAAM,gBACxB,mBAAmB,aAAa,gBAAgB,mBAAmB,CACrE;CAGF,QACG,OAAO,kBAAkB,OAAO,EAAE,IAC/B,iBAAiB,OAAO,MACxB,WAAc;AAEtB;;;;;;;;;;;AAYA,SAAgB,kBAId,QAAmD;CACnD,QACG,OAAO,UAAU,gBAAgB,UACjC,OAAO,MAAM,QAAQ,gBAAgB;AAE1C;;;;;;;;;;;;AAaA,SAAgB,kCAId,QAAmD;CACnD,QAAQ,MAAe;EACrB,wBACE,QACE,EAAiB,OAA4B,OACjD;CACF;AACF;;;;;;;;;;;;AAaA,SAAgB,oBAGd,KAAoE;;CACpE,MAAM,WAAW,IAAI,YAAY;CACjC,MAAM,eAAuD,CAA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AACF"}
|
|
1
|
+
{"version":3,"file":"columnVisibilityFeature.utils.js","names":[],"sources":["../../../src/features/column-visibility/columnVisibilityFeature.utils.ts"],"sourcesContent":["import {\n callMemoOrStaticFn,\n cloneState,\n hasOwn,\n makeObjectMap,\n} 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 makeObjectMap()\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 const next = Object.assign(makeObjectMap<boolean>(), old)\n next[column.id] =\n visible ??\n !callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n return next\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 columnVisibility = column.table.atoms.columnVisibility?.get()\n if (!columnVisibility) return true\n\n const childColumns = column.columns\n if (childColumns.length) {\n return childColumns.some((childColumn) =>\n callMemoOrStaticFn(childColumn, 'getIsVisible', column_getIsVisible),\n )\n }\n\n return (\n (hasOwn(columnVisibility, column.id)\n ? columnVisibility[column.id]\n : undefined) ?? 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 = makeObjectMap<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\n ? makeObjectMap()\n : Object.assign(\n makeObjectMap<boolean>(),\n cloneState(table.initialState.columnVisibility ?? {}),\n ),\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 = makeObjectMap<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}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;;;;;;;;;;;AAaA,SAAgB,0BAId,OACA,SACA;CACA,MAAM,QAAQ,2BAA2B,OAAO;AAClD;;;;;;;;;;;;;AAcA,SAAgB,4BAGd,OAAyC,cAAwB;CACjE,0BACE,OACA,eACI,cAAc,IACd,OAAO,OACL,cAAuB,GACvB,WAAW,MAAM,aAAa,oBAAoB,CAAC,CAAC,CACtD,CACN;AACF;;;;;;;;;;;AAYA,SAAgB,8BAGd,OAAyC,OAAiB;CAC1D,QAAQ,SAAS,CAAC,6BAA6B,KAAK;CAEpD,MAAM,aAAa,cAAuB;CAC1C,MAAM,cAAc,MAAM,kBAAkB;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,SAAS,YAAY;EAC3B,WAAW,OAAO,MAAM,CAAC,QAAQ,CAAC,kBAAkB,MAAM,IAAI;CAChE;CAEA,0BAA0B,OAAO,UAAU;AAC7C;;;;;;;;;;;;AAaA,SAAgB,6BAGd,OAAyC;CACzC,OAAO,CAAC,MACL,kBAAkB,CAAC,CACnB,MACE,WACC,CAAC,mBAAmB,QAAQ,gBAAgB,mBAAmB,CACnE;AACJ;;;;;;;;;;;AAYA,SAAgB,8BAGd,OAAyC;CACzC,OAAO,MACJ,kBAAkB,CAAC,CACnB,MAAM,WACL,mBAAmB,QAAQ,gBAAgB,mBAAmB,CAChE;AACJ;;;;;;;;;;;;AAaA,SAAgB,2CAGd,OAAyC;CACzC,QAAQ,MAAe;EACrB,8BACE,OACE,EAAiB,OAA4B,OACjD;CACF;AACF"}
|
|
@@ -17,8 +17,7 @@ const globalFilteringFeature = {
|
|
|
17
17
|
onGlobalFilterChange: require_utils.makeStateUpdater("globalFilter", table),
|
|
18
18
|
globalFilterFn: "auto",
|
|
19
19
|
getColumnCanGlobalFilter: (column) => {
|
|
20
|
-
|
|
21
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) === null || _table$getCoreRowMode === void 0 || (_table$getCoreRowMode = _table$getCoreRowMode.getAllCellsByColumnId()[column.id]) === null || _table$getCoreRowMode === void 0 ? void 0 : _table$getCoreRowMode.getValue();
|
|
20
|
+
const value = table.getCoreRowModel().flatRows[0]?.getAllCellsByColumnId()[column.id]?.getValue();
|
|
22
21
|
return typeof value === "string" || typeof value === "number";
|
|
23
22
|
}
|
|
24
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalFilteringFeature.cjs","names":["makeStateUpdater","column_getCanGlobalFilter","table_getGlobalAutoFilterFn","table_getGlobalFilterFn","table_setGlobalFilter","table_resetGlobalFilter"],"sources":["../../../src/features/global-filtering/globalFilteringFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalAutoFilterFn,\n table_getGlobalFilterFn,\n table_resetGlobalFilter,\n table_setGlobalFilter,\n} from './globalFilteringFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds global filtering state, defaults, and global filter APIs.\n */\nexport const globalFilteringFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n globalFilter: undefined,\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: (column) => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?.getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n }\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('globalFilteringFeature', prototype, table, {\n column_getCanGlobalFilter: {\n fn: (column) => column_getCanGlobalFilter(column),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('globalFilteringFeature', table, {\n table_getGlobalAutoFilterFn: {\n fn: () => table_getGlobalAutoFilterFn(),\n },\n table_getGlobalFilterFn: {\n fn: () => table_getGlobalFilterFn(table),\n },\n table_setGlobalFilter: {\n fn: (updater) => table_setGlobalFilter(table, updater),\n },\n table_resetGlobalFilter: {\n fn: (defaultState) => table_resetGlobalFilter(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,yBAAuC;CAClD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc;GACd,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsBA,+BAAiB,gBAAgB,KAAK;GAC5D,gBAAgB;GAChB,2BAA2B,WAAW
|
|
1
|
+
{"version":3,"file":"globalFilteringFeature.cjs","names":["makeStateUpdater","column_getCanGlobalFilter","table_getGlobalAutoFilterFn","table_getGlobalFilterFn","table_setGlobalFilter","table_resetGlobalFilter"],"sources":["../../../src/features/global-filtering/globalFilteringFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalAutoFilterFn,\n table_getGlobalFilterFn,\n table_resetGlobalFilter,\n table_setGlobalFilter,\n} from './globalFilteringFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds global filtering state, defaults, and global filter APIs.\n */\nexport const globalFilteringFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n globalFilter: undefined,\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: (column) => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?.getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n }\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('globalFilteringFeature', prototype, table, {\n column_getCanGlobalFilter: {\n fn: (column) => column_getCanGlobalFilter(column),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('globalFilteringFeature', table, {\n table_getGlobalAutoFilterFn: {\n fn: () => table_getGlobalAutoFilterFn(),\n },\n table_getGlobalFilterFn: {\n fn: () => table_getGlobalFilterFn(table),\n },\n table_setGlobalFilter: {\n fn: (updater) => table_setGlobalFilter(table, updater),\n },\n table_resetGlobalFilter: {\n fn: (defaultState) => table_resetGlobalFilter(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,yBAAuC;CAClD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc;GACd,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsBA,+BAAiB,gBAAgB,KAAK;GAC5D,gBAAgB;GAChB,2BAA2B,WAAW;IACpC,MAAM,QAAQ,MACX,gBAAgB,CAAC,CACjB,SAAS,EAAE,EAAE,sBAAsB,CAAC,CACpC,OAAO,GAAG,EAAE,SAAS;IAExB,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU;GACvD;EACF;CACF;CAEA,wBAAwB,WAAW,UAAU;EAC3C,kCAAoB,0BAA0B,WAAW,OAAO,EAC9D,2BAA2B,EACzB,KAAK,WAAWC,+DAA0B,MAAM,EAClD,EACF,CAAC;CACH;CAEA,qBAAqB,UAAU;EAC7B,8BAAgB,0BAA0B,OAAO;GAC/C,6BAA6B,EAC3B,UAAUC,iEAA4B,EACxC;GACA,yBAAyB,EACvB,UAAUC,6DAAwB,KAAK,EACzC;GACA,uBAAuB,EACrB,KAAK,YAAYC,2DAAsB,OAAO,OAAO,EACvD;GACA,yBAAyB,EACvB,KAAK,iBAAiBC,6DAAwB,OAAO,YAAY,EACnE;EACF,CAAC;CACH;AACF"}
|
|
@@ -17,8 +17,7 @@ const globalFilteringFeature = {
|
|
|
17
17
|
onGlobalFilterChange: makeStateUpdater("globalFilter", table),
|
|
18
18
|
globalFilterFn: "auto",
|
|
19
19
|
getColumnCanGlobalFilter: (column) => {
|
|
20
|
-
|
|
21
|
-
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) === null || _table$getCoreRowMode === void 0 || (_table$getCoreRowMode = _table$getCoreRowMode.getAllCellsByColumnId()[column.id]) === null || _table$getCoreRowMode === void 0 ? void 0 : _table$getCoreRowMode.getValue();
|
|
20
|
+
const value = table.getCoreRowModel().flatRows[0]?.getAllCellsByColumnId()[column.id]?.getValue();
|
|
22
21
|
return typeof value === "string" || typeof value === "number";
|
|
23
22
|
}
|
|
24
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalFilteringFeature.js","names":[],"sources":["../../../src/features/global-filtering/globalFilteringFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalAutoFilterFn,\n table_getGlobalFilterFn,\n table_resetGlobalFilter,\n table_setGlobalFilter,\n} from './globalFilteringFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds global filtering state, defaults, and global filter APIs.\n */\nexport const globalFilteringFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n globalFilter: undefined,\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: (column) => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?.getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n }\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('globalFilteringFeature', prototype, table, {\n column_getCanGlobalFilter: {\n fn: (column) => column_getCanGlobalFilter(column),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('globalFilteringFeature', table, {\n table_getGlobalAutoFilterFn: {\n fn: () => table_getGlobalAutoFilterFn(),\n },\n table_getGlobalFilterFn: {\n fn: () => table_getGlobalFilterFn(table),\n },\n table_setGlobalFilter: {\n fn: (updater) => table_setGlobalFilter(table, updater),\n },\n table_resetGlobalFilter: {\n fn: (defaultState) => table_resetGlobalFilter(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,yBAAuC;CAClD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc;GACd,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsB,iBAAiB,gBAAgB,KAAK;GAC5D,gBAAgB;GAChB,2BAA2B,WAAW
|
|
1
|
+
{"version":3,"file":"globalFilteringFeature.js","names":[],"sources":["../../../src/features/global-filtering/globalFilteringFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalAutoFilterFn,\n table_getGlobalFilterFn,\n table_resetGlobalFilter,\n table_setGlobalFilter,\n} from './globalFilteringFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds global filtering state, defaults, and global filter APIs.\n */\nexport const globalFilteringFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n globalFilter: undefined,\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onGlobalFilterChange: makeStateUpdater('globalFilter', table),\n globalFilterFn: 'auto',\n getColumnCanGlobalFilter: (column) => {\n const value = table\n .getCoreRowModel()\n .flatRows[0]?.getAllCellsByColumnId()\n [column.id]?.getValue()\n\n return typeof value === 'string' || typeof value === 'number'\n },\n }\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('globalFilteringFeature', prototype, table, {\n column_getCanGlobalFilter: {\n fn: (column) => column_getCanGlobalFilter(column),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('globalFilteringFeature', table, {\n table_getGlobalAutoFilterFn: {\n fn: () => table_getGlobalAutoFilterFn(),\n },\n table_getGlobalFilterFn: {\n fn: () => table_getGlobalFilterFn(table),\n },\n table_setGlobalFilter: {\n fn: (updater) => table_setGlobalFilter(table, updater),\n },\n table_resetGlobalFilter: {\n fn: (defaultState) => table_resetGlobalFilter(table, defaultState),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,yBAAuC;CAClD,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc;GACd,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsB,iBAAiB,gBAAgB,KAAK;GAC5D,gBAAgB;GAChB,2BAA2B,WAAW;IACpC,MAAM,QAAQ,MACX,gBAAgB,CAAC,CACjB,SAAS,EAAE,EAAE,sBAAsB,CAAC,CACpC,OAAO,GAAG,EAAE,SAAS;IAExB,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU;GACvD;EACF;CACF;CAEA,wBAAwB,WAAW,UAAU;EAC3C,oBAAoB,0BAA0B,WAAW,OAAO,EAC9D,2BAA2B,EACzB,KAAK,WAAW,0BAA0B,MAAM,EAClD,EACF,CAAC;CACH;CAEA,qBAAqB,UAAU;EAC7B,gBAAgB,0BAA0B,OAAO;GAC/C,6BAA6B,EAC3B,UAAU,4BAA4B,EACxC;GACA,yBAAyB,EACvB,UAAU,wBAAwB,KAAK,EACzC;GACA,uBAAuB,EACrB,KAAK,YAAY,sBAAsB,OAAO,OAAO,EACvD;GACA,yBAAyB,EACvB,KAAK,iBAAiB,wBAAwB,OAAO,YAAY,EACnE;EACF,CAAC;CACH;AACF"}
|
|
@@ -14,8 +14,7 @@ const require_filterFns = require('../../fns/filterFns.cjs');
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
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;
|
|
17
|
+
return (column.columnDef.enableGlobalFilter ?? true) && (column.table.options.enableGlobalFilter ?? true) && (column.table.options.enableFilters ?? true) && (column.table.options.getColumnCanGlobalFilter?.(column) ?? true) && !!column.accessorFn;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* Provides the built-in automatic global filter function.
|
|
@@ -46,7 +45,7 @@ function table_getGlobalAutoFilterFn() {
|
|
|
46
45
|
function table_getGlobalFilterFn(table) {
|
|
47
46
|
const { globalFilterFn } = table.options;
|
|
48
47
|
const filterFns = table._rowModelFns.filterFns;
|
|
49
|
-
return require_utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table_getGlobalAutoFilterFn() : filterFns
|
|
48
|
+
return require_utils.isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table_getGlobalAutoFilterFn() : filterFns?.[globalFilterFn];
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
51
|
* Routes a global filter updater through the table's global filter handler.
|
|
@@ -60,8 +59,7 @@ function table_getGlobalFilterFn(table) {
|
|
|
60
59
|
* ```
|
|
61
60
|
*/
|
|
62
61
|
function table_setGlobalFilter(table, updater) {
|
|
63
|
-
|
|
64
|
-
(_table$options$onGlob = (_table$options = table.options).onGlobalFilterChange) === null || _table$options$onGlob === void 0 || _table$options$onGlob.call(_table$options, updater);
|
|
62
|
+
table.options.onGlobalFilterChange?.(updater);
|
|
65
63
|
}
|
|
66
64
|
/**
|
|
67
65
|
* Resets `globalFilter` to the configured initial state or feature default.
|
|
@@ -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 * 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 as any) ?? 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> | undefined {\n const { globalFilterFn: globalFilterFn } = table.options\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n table._rowModelFns.filterFns\n\n const filterFn = isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table_getGlobalAutoFilterFn()\n : filterFns?.[globalFilterFn as string]\n\n return filterFn\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
|
|
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 as any) ?? 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> | undefined {\n const { globalFilterFn: globalFilterFn } = table.options\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n table._rowModelFns.filterFns\n\n const filterFn = isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table_getGlobalAutoFilterFn()\n : filterFns?.[globalFilterFn as string]\n\n return filterFn\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,UACtC,OAAO,MAAM,QAAQ,2BAA2B,MAAa,KAAK,SACnE,CAAC,CAAC,OAAO;AAEb;;;;;;;;;;;;AAaA,SAAgB,8BAA8B;CAC5C,OAAOA;AACT;;;;;;;;;;;;;AAcA,SAAgB,wBAId,OACwC;CACxC,MAAM,EAAkB,mBAAmB,MAAM;CACjD,MAAM,YACJ,MAAM,aAAa;CAQrB,OANiBC,yBAAW,cAAc,IACtC,iBACA,mBAAmB,SACjB,4BAA4B,IAC5B,YAAY;AAGpB;;;;;;;;;;;;AAaA,SAAgB,sBAGd,OAAyC,SAAc;CACvD,MAAM,QAAQ,uBAAuB,OAAO;AAC9C;;;;;;;;;;;;;AAcA,SAAgB,wBAGd,OAAyC,cAAwB;CACjE,sBACE,OACA,eAAe,SAAYC,yBAAW,MAAM,aAAa,YAAY,CACvE;AACF"}
|
|
@@ -14,8 +14,7 @@ import { filterFn_includesString } from "../../fns/filterFns.js";
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
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;
|
|
17
|
+
return (column.columnDef.enableGlobalFilter ?? true) && (column.table.options.enableGlobalFilter ?? true) && (column.table.options.enableFilters ?? true) && (column.table.options.getColumnCanGlobalFilter?.(column) ?? true) && !!column.accessorFn;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* Provides the built-in automatic global filter function.
|
|
@@ -46,7 +45,7 @@ function table_getGlobalAutoFilterFn() {
|
|
|
46
45
|
function table_getGlobalFilterFn(table) {
|
|
47
46
|
const { globalFilterFn } = table.options;
|
|
48
47
|
const filterFns = table._rowModelFns.filterFns;
|
|
49
|
-
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table_getGlobalAutoFilterFn() : filterFns
|
|
48
|
+
return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table_getGlobalAutoFilterFn() : filterFns?.[globalFilterFn];
|
|
50
49
|
}
|
|
51
50
|
/**
|
|
52
51
|
* Routes a global filter updater through the table's global filter handler.
|
|
@@ -60,8 +59,7 @@ function table_getGlobalFilterFn(table) {
|
|
|
60
59
|
* ```
|
|
61
60
|
*/
|
|
62
61
|
function table_setGlobalFilter(table, updater) {
|
|
63
|
-
|
|
64
|
-
(_table$options$onGlob = (_table$options = table.options).onGlobalFilterChange) === null || _table$options$onGlob === void 0 || _table$options$onGlob.call(_table$options, updater);
|
|
62
|
+
table.options.onGlobalFilterChange?.(updater);
|
|
65
63
|
}
|
|
66
64
|
/**
|
|
67
65
|
* Resets `globalFilter` to the configured initial state or feature default.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalFilteringFeature.utils.js","names":[],"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 as any) ?? 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> | undefined {\n const { globalFilterFn: globalFilterFn } = table.options\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n table._rowModelFns.filterFns\n\n const filterFn = isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table_getGlobalAutoFilterFn()\n : filterFns?.[globalFilterFn as string]\n\n return filterFn\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
|
|
1
|
+
{"version":3,"file":"globalFilteringFeature.utils.js","names":[],"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 as any) ?? 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> | undefined {\n const { globalFilterFn: globalFilterFn } = table.options\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n table._rowModelFns.filterFns\n\n const filterFn = isFunction(globalFilterFn)\n ? globalFilterFn\n : globalFilterFn === 'auto'\n ? table_getGlobalAutoFilterFn()\n : filterFns?.[globalFilterFn as string]\n\n return filterFn\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,UACtC,OAAO,MAAM,QAAQ,2BAA2B,MAAa,KAAK,SACnE,CAAC,CAAC,OAAO;AAEb;;;;;;;;;;;;AAaA,SAAgB,8BAA8B;CAC5C,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,wBAId,OACwC;CACxC,MAAM,EAAkB,mBAAmB,MAAM;CACjD,MAAM,YACJ,MAAM,aAAa;CAQrB,OANiB,WAAW,cAAc,IACtC,iBACA,mBAAmB,SACjB,4BAA4B,IAC5B,YAAY;AAGpB;;;;;;;;;;;;AAaA,SAAgB,sBAGd,OAAyC,SAAc;CACvD,MAAM,QAAQ,uBAAuB,OAAO;AAC9C;;;;;;;;;;;;;AAcA,SAAgB,wBAGd,OAAyC,cAAwB;CACjE,sBACE,OACA,eAAe,SAAY,WAAW,MAAM,aAAa,YAAY,CACvE;AACF"}
|
|
@@ -14,22 +14,18 @@ function createExpandedRowModel() {
|
|
|
14
14
|
feature: "rowExpandingFeature",
|
|
15
15
|
table,
|
|
16
16
|
fnName: "table.getExpandedRowModel",
|
|
17
|
-
memoDeps: () =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
table.options.paginateExpandedRows
|
|
23
|
-
];
|
|
24
|
-
},
|
|
17
|
+
memoDeps: () => [
|
|
18
|
+
table.atoms.expanded?.get(),
|
|
19
|
+
table.getPreExpandedRowModel(),
|
|
20
|
+
table.options.paginateExpandedRows
|
|
21
|
+
],
|
|
25
22
|
fn: () => _createExpandedRowModel(table)
|
|
26
23
|
});
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
function _createExpandedRowModel(table) {
|
|
30
|
-
var _table$atoms$expanded2;
|
|
31
27
|
const rowModel = table.getPreExpandedRowModel();
|
|
32
|
-
const expanded =
|
|
28
|
+
const expanded = table.atoms.expanded?.get();
|
|
33
29
|
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded ?? {}).length) return rowModel;
|
|
34
30
|
if (!table.options.paginateExpandedRows) return rowModel;
|
|
35
31
|
return expandRows(rowModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpandedRowModel.cjs","names":["tableMemo","row_getIsExpanded"],"sources":["../../../src/features/row-expanding/createExpandedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { row_getIsExpanded } from './rowExpandingFeature.utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized expanded row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'rowExpandingFeature',\n table,\n fnName: 'table.getExpandedRowModel',\n memoDeps: () => [\n table.atoms.expanded?.get(),\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n fn: () => _createExpandedRowModel(table),\n })\n }\n}\n\nfunction _createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreExpandedRowModel()\n const expanded = table.atoms.expanded?.get()\n\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!table.options.paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n return rowModel\n }\n\n return expandRows(rowModel)\n}\n\n/**\n * Expands a row model according to the current expanded row state.\n *\n * Expanded sub-rows are inserted into the flattened row order while preserving the original row hierarchy.\n */\nexport function expandRows<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(rowModel: RowModel<TFeatures, TData>): RowModel<TFeatures, TData> {\n const expandedRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n expandedRows.push(row)\n\n if (row.subRows.length && row_getIsExpanded(row)) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: rowModel.flatRows,\n rowsById: rowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB
|
|
1
|
+
{"version":3,"file":"createExpandedRowModel.cjs","names":["tableMemo","row_getIsExpanded"],"sources":["../../../src/features/row-expanding/createExpandedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { row_getIsExpanded } from './rowExpandingFeature.utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized expanded row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'rowExpandingFeature',\n table,\n fnName: 'table.getExpandedRowModel',\n memoDeps: () => [\n table.atoms.expanded?.get(),\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n fn: () => _createExpandedRowModel(table),\n })\n }\n}\n\nfunction _createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreExpandedRowModel()\n const expanded = table.atoms.expanded?.get()\n\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!table.options.paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n return rowModel\n }\n\n return expandRows(rowModel)\n}\n\n/**\n * Expands a row model according to the current expanded row state.\n *\n * Expanded sub-rows are inserted into the flattened row order while preserving the original row hierarchy.\n */\nexport function expandRows<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(rowModel: RowModel<TFeatures, TData>): RowModel<TFeatures, TData> {\n const expandedRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n expandedRows.push(row)\n\n if (row.subRows.length && row_getIsExpanded(row)) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: rowModel.flatRows,\n rowsById: rowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,MAAM,UAAU,IAAI;IAC1B,MAAM,uBAAuB;IAC7B,MAAM,QAAQ;GAChB;GACA,UAAU,wBAAwB,KAAK;EACzC,CAAC;CACH;AACF;AAEA,SAAS,wBAGP,OAAqE;CACrE,MAAM,WAAW,MAAM,uBAAuB;CAC9C,MAAM,WAAW,MAAM,MAAM,UAAU,IAAI;CAE3C,IACE,CAAC,SAAS,KAAK,UACd,aAAa,QAAQ,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,QAEnD,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,sBAEjB,OAAO;CAGT,OAAO,WAAW,QAAQ;AAC5B;;;;;;AAOA,SAAgB,WAGd,UAAkE;CAClE,MAAM,eAA6C,CAAC;CAEpD,MAAM,aAAa,QAA+B;EAChD,aAAa,KAAK,GAAG;EAErB,IAAI,IAAI,QAAQ,UAAUC,oDAAkB,GAAG,GAC7C,IAAI,QAAQ,QAAQ,SAAS;CAEjC;CAEA,SAAS,KAAK,QAAQ,SAAS;CAE/B,OAAO;EACL,MAAM;EACN,UAAU,SAAS;EACnB,UAAU,SAAS;CACrB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.cjs";
|
|
2
|
+
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.cjs";
|
|
2
3
|
import { Table } from "../../types/Table.cjs";
|
|
3
4
|
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
4
|
-
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-expanding/createExpandedRowModel.d.ts
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RowData } from "../../types/type-utils.js";
|
|
2
|
+
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
2
3
|
import { Table } from "../../types/Table.js";
|
|
3
4
|
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
|
-
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-expanding/createExpandedRowModel.d.ts
|
|
7
7
|
/**
|
|
@@ -14,22 +14,18 @@ function createExpandedRowModel() {
|
|
|
14
14
|
feature: "rowExpandingFeature",
|
|
15
15
|
table,
|
|
16
16
|
fnName: "table.getExpandedRowModel",
|
|
17
|
-
memoDeps: () =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
table.options.paginateExpandedRows
|
|
23
|
-
];
|
|
24
|
-
},
|
|
17
|
+
memoDeps: () => [
|
|
18
|
+
table.atoms.expanded?.get(),
|
|
19
|
+
table.getPreExpandedRowModel(),
|
|
20
|
+
table.options.paginateExpandedRows
|
|
21
|
+
],
|
|
25
22
|
fn: () => _createExpandedRowModel(table)
|
|
26
23
|
});
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
function _createExpandedRowModel(table) {
|
|
30
|
-
var _table$atoms$expanded2;
|
|
31
27
|
const rowModel = table.getPreExpandedRowModel();
|
|
32
|
-
const expanded =
|
|
28
|
+
const expanded = table.atoms.expanded?.get();
|
|
33
29
|
if (!rowModel.rows.length || expanded !== true && !Object.keys(expanded ?? {}).length) return rowModel;
|
|
34
30
|
if (!table.options.paginateExpandedRows) return rowModel;
|
|
35
31
|
return expandRows(rowModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpandedRowModel.js","names":[],"sources":["../../../src/features/row-expanding/createExpandedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { row_getIsExpanded } from './rowExpandingFeature.utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized expanded row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'rowExpandingFeature',\n table,\n fnName: 'table.getExpandedRowModel',\n memoDeps: () => [\n table.atoms.expanded?.get(),\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n fn: () => _createExpandedRowModel(table),\n })\n }\n}\n\nfunction _createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreExpandedRowModel()\n const expanded = table.atoms.expanded?.get()\n\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!table.options.paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n return rowModel\n }\n\n return expandRows(rowModel)\n}\n\n/**\n * Expands a row model according to the current expanded row state.\n *\n * Expanded sub-rows are inserted into the flattened row order while preserving the original row hierarchy.\n */\nexport function expandRows<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(rowModel: RowModel<TFeatures, TData>): RowModel<TFeatures, TData> {\n const expandedRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n expandedRows.push(row)\n\n if (row.subRows.length && row_getIsExpanded(row)) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: rowModel.flatRows,\n rowsById: rowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB
|
|
1
|
+
{"version":3,"file":"createExpandedRowModel.js","names":[],"sources":["../../../src/features/row-expanding/createExpandedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { row_getIsExpanded } from './rowExpandingFeature.utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized expanded row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table = _table as unknown as Table_Internal<TFeatures, TData>\n return tableMemo({\n feature: 'rowExpandingFeature',\n table,\n fnName: 'table.getExpandedRowModel',\n memoDeps: () => [\n table.atoms.expanded?.get(),\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n fn: () => _createExpandedRowModel(table),\n })\n }\n}\n\nfunction _createExpandedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreExpandedRowModel()\n const expanded = table.atoms.expanded?.get()\n\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!table.options.paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n return rowModel\n }\n\n return expandRows(rowModel)\n}\n\n/**\n * Expands a row model according to the current expanded row state.\n *\n * Expanded sub-rows are inserted into the flattened row order while preserving the original row hierarchy.\n */\nexport function expandRows<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(rowModel: RowModel<TFeatures, TData>): RowModel<TFeatures, TData> {\n const expandedRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n expandedRows.push(row)\n\n if (row.subRows.length && row_getIsExpanded(row)) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: rowModel.flatRows,\n rowsById: rowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;AAaA,SAAgB,yBAG0D;CACxE,QAAQ,WAAW;EACjB,MAAM,QAAQ;EACd,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,MAAM,UAAU,IAAI;IAC1B,MAAM,uBAAuB;IAC7B,MAAM,QAAQ;GAChB;GACA,UAAU,wBAAwB,KAAK;EACzC,CAAC;CACH;AACF;AAEA,SAAS,wBAGP,OAAqE;CACrE,MAAM,WAAW,MAAM,uBAAuB;CAC9C,MAAM,WAAW,MAAM,MAAM,UAAU,IAAI;CAE3C,IACE,CAAC,SAAS,KAAK,UACd,aAAa,QAAQ,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,QAEnD,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,sBAEjB,OAAO;CAGT,OAAO,WAAW,QAAQ;AAC5B;;;;;;AAOA,SAAgB,WAGd,UAAkE;CAClE,MAAM,eAA6C,CAAC;CAEpD,MAAM,aAAa,QAA+B;EAChD,aAAa,KAAK,GAAG;EAErB,IAAI,IAAI,QAAQ,UAAU,kBAAkB,GAAG,GAC7C,IAAI,QAAQ,QAAQ,SAAS;CAEjC;CAEA,SAAS,KAAK,QAAQ,SAAS;CAE/B,OAAO;EACL,MAAM;EACN,UAAU,SAAS;EACnB,UAAU,SAAS;CACrB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OnChangeFn, RowData, Updater } from "../../types/type-utils.cjs";
|
|
2
2
|
import { Row } from "../../types/Row.cjs";
|
|
3
|
-
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
4
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.cjs";
|
|
4
|
+
import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-expanding/rowExpandingFeature.types.d.ts
|
|
7
7
|
type ExpandedStateList = Record<string, boolean>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OnChangeFn, RowData, Updater } from "../../types/type-utils.js";
|
|
2
2
|
import { Row } from "../../types/Row.js";
|
|
3
|
-
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
4
3
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
4
|
+
import { TableFeatures } from "../../types/TableFeatures.js";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-expanding/rowExpandingFeature.types.d.ts
|
|
7
7
|
type ExpandedStateList = Record<string, boolean>;
|
|
@@ -42,8 +42,7 @@ function table_autoResetExpanded(table) {
|
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
function table_setExpanded(table, updater) {
|
|
45
|
-
|
|
46
|
-
(_table$options$onExpa = (_table$options = table.options).onExpandedChange) === null || _table$options$onExpa === void 0 || _table$options$onExpa.call(_table$options, updater);
|
|
45
|
+
table.options.onExpandedChange?.(updater);
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
48
|
* Expands or collapses every row.
|
|
@@ -104,8 +103,7 @@ function table_getCanSomeRowsExpand(table) {
|
|
|
104
103
|
*/
|
|
105
104
|
function table_getToggleAllRowsExpandedHandler(table) {
|
|
106
105
|
return (e) => {
|
|
107
|
-
|
|
108
|
-
(_persist = e.persist) === null || _persist === void 0 || _persist.call(e);
|
|
106
|
+
e.persist?.();
|
|
109
107
|
table_toggleAllRowsExpanded(table);
|
|
110
108
|
};
|
|
111
109
|
}
|
|
@@ -120,8 +118,7 @@ function table_getToggleAllRowsExpandedHandler(table) {
|
|
|
120
118
|
* ```
|
|
121
119
|
*/
|
|
122
120
|
function table_getIsSomeRowsExpanded(table) {
|
|
123
|
-
|
|
124
|
-
const expanded = ((_table$atoms$expanded = table.atoms.expanded) === null || _table$atoms$expanded === void 0 ? void 0 : _table$atoms$expanded.get()) ?? {};
|
|
121
|
+
const expanded = table.atoms.expanded?.get() ?? {};
|
|
125
122
|
return expanded === true || Object.values(expanded).some(Boolean);
|
|
126
123
|
}
|
|
127
124
|
/**
|
|
@@ -136,8 +133,7 @@ function table_getIsSomeRowsExpanded(table) {
|
|
|
136
133
|
* ```
|
|
137
134
|
*/
|
|
138
135
|
function table_getIsAllRowsExpanded(table) {
|
|
139
|
-
|
|
140
|
-
const expanded = ((_table$atoms$expanded2 = table.atoms.expanded) === null || _table$atoms$expanded2 === void 0 ? void 0 : _table$atoms$expanded2.get()) ?? {};
|
|
136
|
+
const expanded = table.atoms.expanded?.get() ?? {};
|
|
141
137
|
if (expanded === true) return true;
|
|
142
138
|
if (!Object.keys(expanded).length) return false;
|
|
143
139
|
if (table.getRowModel().flatRows.some((row) => !row_getIsExpanded(row))) return false;
|
|
@@ -155,9 +151,8 @@ function table_getIsAllRowsExpanded(table) {
|
|
|
155
151
|
* ```
|
|
156
152
|
*/
|
|
157
153
|
function table_getExpandedDepth(table) {
|
|
158
|
-
var _table$atoms$expanded3, _table$atoms$expanded4;
|
|
159
154
|
let maxDepth = 0;
|
|
160
|
-
(
|
|
155
|
+
(table.atoms.expanded?.get() === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.atoms.expanded?.get() ?? {})).forEach((id) => {
|
|
161
156
|
const splitId = id.split(".");
|
|
162
157
|
maxDepth = Math.max(maxDepth, splitId.length);
|
|
163
158
|
});
|
|
@@ -212,9 +207,8 @@ function row_toggleExpanded(row, expanded) {
|
|
|
212
207
|
* ```
|
|
213
208
|
*/
|
|
214
209
|
function row_getIsExpanded(row) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
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 || isExpandedRowId(expanded, row.id)));
|
|
210
|
+
const expanded = row.table.atoms.expanded?.get() ?? {};
|
|
211
|
+
return !!(row.table.options.getIsRowExpanded?.(row) ?? (expanded === true || isExpandedRowId(expanded, row.id)));
|
|
218
212
|
}
|
|
219
213
|
function isExpandedRowId(expanded, rowId) {
|
|
220
214
|
return !!(expanded && expanded !== true && require_utils.hasOwn(expanded, rowId) && expanded[rowId]);
|
|
@@ -231,8 +225,7 @@ function isExpandedRowId(expanded, rowId) {
|
|
|
231
225
|
* ```
|
|
232
226
|
*/
|
|
233
227
|
function row_getCanExpand(row) {
|
|
234
|
-
|
|
235
|
-
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);
|
|
228
|
+
return row.table.options.getRowCanExpand?.(row) ?? ((row.table.options.enableExpanding ?? true) && !!row.subRows.length);
|
|
236
229
|
}
|
|
237
230
|
/**
|
|
238
231
|
* Checks whether every ancestor of this row is expanded.
|