@tanstack/table-core 9.0.0-alpha.46 → 9.0.0-alpha.47
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 +4 -3
- package/dist/core/cells/constructCell.cjs.map +1 -1
- package/dist/core/cells/constructCell.js +4 -3
- package/dist/core/cells/constructCell.js.map +1 -1
- package/dist/core/columns/constructColumn.cjs +6 -4
- package/dist/core/columns/constructColumn.cjs.map +1 -1
- package/dist/core/columns/constructColumn.js +6 -4
- package/dist/core/columns/constructColumn.js.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.cjs +10 -2
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js +10 -2
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs +27 -19
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js +27 -19
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/constructHeader.cjs +4 -3
- package/dist/core/headers/constructHeader.cjs.map +1 -1
- package/dist/core/headers/constructHeader.js +4 -3
- package/dist/core/headers/constructHeader.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.cjs +1 -6
- package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.js +2 -7
- package/dist/core/headers/coreHeadersFeature.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +20 -18
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.cts +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.d.ts +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +21 -19
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/core/reactivity/coreReactivityFeature.types.d.cts +4 -0
- package/dist/core/reactivity/coreReactivityFeature.types.d.ts +4 -0
- package/dist/core/rows/constructRow.cjs +8 -6
- package/dist/core/rows/constructRow.cjs.map +1 -1
- package/dist/core/rows/constructRow.js +8 -6
- package/dist/core/rows/constructRow.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.cjs +9 -4
- package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
- package/dist/core/rows/coreRowsFeature.utils.js +9 -4
- package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
- package/dist/core/table/constructTable.cjs +9 -5
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js +9 -5
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.cjs +5 -1
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.js +5 -1
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +8 -5
- package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
- package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -3
- package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedRowModel.js +8 -3
- package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs +7 -4
- package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
- package/dist/features/column-faceting/createFacetedUniqueValues.js +7 -4
- package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -5
- package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
- package/dist/features/column-filtering/createFilteredRowModel.js +11 -5
- package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +16 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +16 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +41 -24
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +5 -4
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +5 -4
- package/dist/features/column-pinning/columnPinningFeature.utils.js +42 -25
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +28 -4
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +28 -4
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.cjs +23 -14
- package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.js +24 -15
- package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +4 -0
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +4 -0
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +40 -13
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +12 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +12 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +40 -14
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +2 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.utils.js +2 -2
- package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs +13 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
- package/dist/features/row-pinning/rowPinningFeature.utils.js +13 -7
- package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +6 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.js +6 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.cjs +13 -8
- package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
- package/dist/features/row-sorting/createSortedRowModel.js +13 -8
- package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
- package/dist/features/row-sorting/rowSortingFeature.utils.js +2 -2
- package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
- package/dist/fns/aggregationFns.cjs +14 -7
- package/dist/fns/aggregationFns.cjs.map +1 -1
- package/dist/fns/aggregationFns.js +14 -8
- package/dist/fns/aggregationFns.js.map +1 -1
- package/dist/index.cjs +0 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/static-functions.cjs +1 -0
- package/dist/static-functions.d.cts +2 -2
- package/dist/static-functions.d.ts +2 -2
- package/dist/static-functions.js +2 -2
- package/dist/store-reactivity-bindings.cjs +1 -0
- package/dist/store-reactivity-bindings.cjs.map +1 -1
- package/dist/store-reactivity-bindings.js +1 -0
- package/dist/store-reactivity-bindings.js.map +1 -1
- package/dist/utils.cjs +18 -39
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -23
- package/dist/utils.d.ts +1 -23
- package/dist/utils.js +19 -36
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/cells/constructCell.ts +3 -2
- package/src/core/columns/constructColumn.ts +5 -3
- package/src/core/columns/coreColumnsFeature.utils.ts +6 -2
- package/src/core/headers/buildHeaderGroups.ts +29 -30
- package/src/core/headers/constructHeader.ts +3 -2
- package/src/core/headers/coreHeadersFeature.ts +2 -27
- package/src/core/headers/coreHeadersFeature.utils.ts +29 -43
- package/src/core/reactivity/coreReactivityFeature.types.ts +4 -0
- package/src/core/rows/constructRow.ts +6 -4
- package/src/core/rows/coreRowsFeature.utils.ts +11 -4
- package/src/core/table/constructTable.ts +6 -4
- package/src/core/table/coreTablesFeature.utils.ts +3 -1
- package/src/features/column-faceting/createFacetedMinMaxValues.ts +8 -10
- package/src/features/column-faceting/createFacetedRowModel.ts +10 -6
- package/src/features/column-faceting/createFacetedUniqueValues.ts +4 -3
- package/src/features/column-filtering/createFilteredRowModel.ts +14 -8
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +14 -6
- package/src/features/column-pinning/columnPinningFeature.utils.ts +53 -37
- package/src/features/column-sizing/columnSizingFeature.ts +16 -0
- package/src/features/column-visibility/columnVisibilityFeature.ts +8 -0
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +7 -0
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +50 -17
- package/src/features/row-expanding/rowExpandingFeature.utils.ts +2 -2
- package/src/features/row-pinning/rowPinningFeature.utils.ts +20 -18
- package/src/features/row-selection/rowSelectionFeature.utils.ts +20 -19
- package/src/features/row-sorting/createSortedRowModel.ts +16 -13
- package/src/features/row-sorting/rowSortingFeature.utils.ts +2 -2
- package/src/fns/aggregationFns.ts +20 -8
- package/src/store-reactivity-bindings.ts +1 -0
- package/src/utils.ts +19 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFilteredRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","table_getColumn","column_getFilterFn","table_getGlobalFilterFn","column_getCanGlobalFilter","filterRows"],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-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 {\n FilterFn,\n FilterFns,\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered 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 createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n filterFns: Record<keyof FilterFns, FilterFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.filterFns) table._rowModelFns.filterFns = filterFns\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n
|
|
1
|
+
{"version":3,"file":"createFilteredRowModel.cjs","names":["tableMemo","table_autoResetPageIndex","table_getColumn","column_getFilterFn","table_getGlobalFilterFn","column_getCanGlobalFilter","filterRows"],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-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 {\n FilterFn,\n FilterFns,\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered 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 createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n filterFns: Record<keyof FilterFns, FilterFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.filterFns) table._rowModelFns.filterFns = filterFns\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = {}\n row.columnFiltersMeta = {}\n }\n return rowModel\n }\n\n const resolvedColumnFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n const resolvedGlobalFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n\n columnFilters?.forEach((columnFilter) => {\n const column = table_getColumn(table, columnFilter.id)\n\n if (!column) {\n return\n }\n\n const filterFn = column_getFilterFn(column)!\n\n resolvedColumnFilters.push({\n id: columnFilter.id,\n filterFn,\n resolvedValue:\n filterFn.resolveFilterValue?.(columnFilter.value) ?? columnFilter.value,\n })\n })\n\n const filterableIds = columnFilters?.map((d) => d.id) ?? []\n\n const globalFilterFn = table_getGlobalFilterFn(table)\n\n const globallyFilterableColumns = table\n .getAllLeafColumns()\n .filter((column) => column_getCanGlobalFilter(column))\n\n if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {\n filterableIds.push('__global__')\n\n globallyFilterableColumns.forEach((column) => {\n resolvedGlobalFilters.push({\n id: column.id,\n filterFn: globalFilterFn,\n resolvedValue:\n globalFilterFn.resolveFilterValue?.(globalFilter) ?? globalFilter,\n })\n })\n }\n\n // Flag the pre-filtered row model with each filter state\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = {}\n\n if (resolvedColumnFilters.length) {\n for (let j = 0; j < resolvedColumnFilters.length; j++) {\n const currentColumnFilter = resolvedColumnFilters[j]!\n const id = currentColumnFilter.id\n\n // Tag the row with the column filter state\n row.columnFilters[id] = currentColumnFilter.filterFn(\n row,\n id,\n currentColumnFilter.resolvedValue,\n (filterMeta) => {\n !row.columnFiltersMeta\n ? (row.columnFiltersMeta = {})\n : (row.columnFiltersMeta[id] = filterMeta)\n },\n )\n }\n }\n\n if (resolvedGlobalFilters.length) {\n for (let j = 0; j < resolvedGlobalFilters.length; j++) {\n const currentGlobalFilter = resolvedGlobalFilters[j]!\n const id = currentGlobalFilter.id\n // Tag the row with the first truthy global filter state\n if (\n currentGlobalFilter.filterFn(\n row,\n id,\n currentGlobalFilter.resolvedValue,\n (filterMeta) => {\n !row.columnFiltersMeta\n ? (row.columnFiltersMeta = {})\n : (row.columnFiltersMeta[id] = filterMeta)\n },\n )\n ) {\n row.columnFilters.__global__ = true\n break\n }\n }\n\n if (row.columnFilters.__global__ !== true) {\n row.columnFilters.__global__ = false\n }\n }\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Row_ColumnFiltering<TFeatures, TData>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n // Filter final rows using all of the active filters\n return filterRows(rowModel.rows, filterRowsImpl as any, table)\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,SAAgB,uBAId,WACsE;CACtE,QAAQ,WAAW;EACjB,MAAM,QAA0C;EAChD,IAAI,CAAC,MAAM,aAAa,WAAW,MAAM,aAAa,YAAY;EAClE,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAChC;;GACD,UAAU,wBAAwB,MAAM;GACxC,qBAAqBC,4DAAyB,MAAM;GACrD,CAAC;;;A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,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;GACrD,MAAM,sBAAsB,sBAAsB;GAClD,MAAM,KAAK,oBAAoB;GAG/B,IAAI,cAAc,MAAM,oBAAoB,SAC1C,KACA,IACA,oBAAoB,gBACnB,eAAe;IACd,CAAC,IAAI,oBACA,IAAI,oBAAoB,EAAE,GAC1B,IAAI,kBAAkB,MAAM;KAEpC;;EAIL,IAAI,sBAAsB,QAAQ;GAChC,KAAK,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;IACrD,MAAM,sBAAsB,sBAAsB;IAClD,MAAM,KAAK,oBAAoB;IAE/B,IACE,oBAAoB,SAClB,KACA,IACA,oBAAoB,gBACnB,eAAe;KACd,CAAC,IAAI,oBACA,IAAI,oBAAoB,EAAE,GAC1B,IAAI,kBAAkB,MAAM;MAEpC,EACD;KACA,IAAI,cAAc,aAAa;KAC/B;;;GAIJ,IAAI,IAAI,cAAc,eAAe,MACnC,IAAI,cAAc,aAAa;;;CAKrC,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,IAAI,cAAc,cAAc,QAAS,OAC3C,OAAO;EAGX,OAAO;;CAIT,OAAOC,mCAAW,SAAS,MAAM,gBAAuB,MAAM"}
|
|
@@ -38,7 +38,9 @@ function _createFilteredRowModel(table) {
|
|
|
38
38
|
const columnFilters = (_table$atoms$columnFi2 = table.atoms.columnFilters) === null || _table$atoms$columnFi2 === void 0 ? void 0 : _table$atoms$columnFi2.get();
|
|
39
39
|
const globalFilter = (_table$atoms$globalFi2 = table.atoms.globalFilter) === null || _table$atoms$globalFi2 === void 0 ? void 0 : _table$atoms$globalFi2.get();
|
|
40
40
|
if (!rowModel.rows.length || !(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.length) && !globalFilter) {
|
|
41
|
-
|
|
41
|
+
const flatRows = rowModel.flatRows;
|
|
42
|
+
for (let i = 0; i < flatRows.length; i++) {
|
|
43
|
+
const row = flatRows[i];
|
|
42
44
|
row.columnFilters = {};
|
|
43
45
|
row.columnFiltersMeta = {};
|
|
44
46
|
}
|
|
@@ -71,16 +73,20 @@ function _createFilteredRowModel(table) {
|
|
|
71
73
|
});
|
|
72
74
|
});
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
const flatRows = rowModel.flatRows;
|
|
77
|
+
for (let i = 0; i < flatRows.length; i++) {
|
|
78
|
+
const row = flatRows[i];
|
|
75
79
|
row.columnFilters = {};
|
|
76
|
-
if (resolvedColumnFilters.length) for (
|
|
80
|
+
if (resolvedColumnFilters.length) for (let j = 0; j < resolvedColumnFilters.length; j++) {
|
|
81
|
+
const currentColumnFilter = resolvedColumnFilters[j];
|
|
77
82
|
const id = currentColumnFilter.id;
|
|
78
83
|
row.columnFilters[id] = currentColumnFilter.filterFn(row, id, currentColumnFilter.resolvedValue, (filterMeta) => {
|
|
79
84
|
!row.columnFiltersMeta ? row.columnFiltersMeta = {} : row.columnFiltersMeta[id] = filterMeta;
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
87
|
if (resolvedGlobalFilters.length) {
|
|
83
|
-
for (
|
|
88
|
+
for (let j = 0; j < resolvedGlobalFilters.length; j++) {
|
|
89
|
+
const currentGlobalFilter = resolvedGlobalFilters[j];
|
|
84
90
|
const id = currentGlobalFilter.id;
|
|
85
91
|
if (currentGlobalFilter.filterFn(row, id, currentGlobalFilter.resolvedValue, (filterMeta) => {
|
|
86
92
|
!row.columnFiltersMeta ? row.columnFiltersMeta = {} : row.columnFiltersMeta[id] = filterMeta;
|
|
@@ -93,7 +99,7 @@ function _createFilteredRowModel(table) {
|
|
|
93
99
|
}
|
|
94
100
|
}
|
|
95
101
|
const filterRowsImpl = (row) => {
|
|
96
|
-
for (
|
|
102
|
+
for (let i = 0; i < filterableIds.length; i++) if (row.columnFilters[filterableIds[i]] === false) return false;
|
|
97
103
|
return true;
|
|
98
104
|
};
|
|
99
105
|
return filterRows(rowModel.rows, filterRowsImpl, table);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFilteredRowModel.js","names":[],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-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 {\n FilterFn,\n FilterFns,\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered 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 createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n filterFns: Record<keyof FilterFns, FilterFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.filterFns) table._rowModelFns.filterFns = filterFns\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n
|
|
1
|
+
{"version":3,"file":"createFilteredRowModel.js","names":[],"sources":["../../../src/features/column-filtering/createFilteredRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_getColumn } from '../../core/columns/coreColumnsFeature.utils'\nimport {\n column_getCanGlobalFilter,\n table_getGlobalFilterFn,\n} from '../global-filtering/globalFilteringFeature.utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { filterRows } from './filterRowsUtils'\nimport { column_getFilterFn } from './columnFilteringFeature.utils'\nimport type { RowData } from '../../types/type-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 {\n FilterFn,\n FilterFns,\n ResolvedColumnFilter,\n Row_ColumnFiltering,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates a memoized filtered 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 createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n filterFns: Record<keyof FilterFns, FilterFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.filterFns) table._rowModelFns.filterFns = filterFns\n return tableMemo({\n feature: 'columnFilteringFeature',\n table,\n fnName: 'table.getFilteredRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n ],\n fn: () => _createFilteredRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createFilteredRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const rowModel = table.getPreFilteredRowModel()\n const columnFilters = table.atoms.columnFilters?.get()\n const globalFilter = table.atoms.globalFilter?.get()\n\n if (!rowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = {}\n row.columnFiltersMeta = {}\n }\n return rowModel\n }\n\n const resolvedColumnFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n const resolvedGlobalFilters: Array<ResolvedColumnFilter<TFeatures, TData>> =\n []\n\n columnFilters?.forEach((columnFilter) => {\n const column = table_getColumn(table, columnFilter.id)\n\n if (!column) {\n return\n }\n\n const filterFn = column_getFilterFn(column)!\n\n resolvedColumnFilters.push({\n id: columnFilter.id,\n filterFn,\n resolvedValue:\n filterFn.resolveFilterValue?.(columnFilter.value) ?? columnFilter.value,\n })\n })\n\n const filterableIds = columnFilters?.map((d) => d.id) ?? []\n\n const globalFilterFn = table_getGlobalFilterFn(table)\n\n const globallyFilterableColumns = table\n .getAllLeafColumns()\n .filter((column) => column_getCanGlobalFilter(column))\n\n if (globalFilter && globalFilterFn && globallyFilterableColumns.length) {\n filterableIds.push('__global__')\n\n globallyFilterableColumns.forEach((column) => {\n resolvedGlobalFilters.push({\n id: column.id,\n filterFn: globalFilterFn,\n resolvedValue:\n globalFilterFn.resolveFilterValue?.(globalFilter) ?? globalFilter,\n })\n })\n }\n\n // Flag the pre-filtered row model with each filter state\n const flatRows = rowModel.flatRows as Array<\n Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>\n >\n for (let i = 0; i < flatRows.length; i++) {\n const row = flatRows[i]!\n row.columnFilters = {}\n\n if (resolvedColumnFilters.length) {\n for (let j = 0; j < resolvedColumnFilters.length; j++) {\n const currentColumnFilter = resolvedColumnFilters[j]!\n const id = currentColumnFilter.id\n\n // Tag the row with the column filter state\n row.columnFilters[id] = currentColumnFilter.filterFn(\n row,\n id,\n currentColumnFilter.resolvedValue,\n (filterMeta) => {\n !row.columnFiltersMeta\n ? (row.columnFiltersMeta = {})\n : (row.columnFiltersMeta[id] = filterMeta)\n },\n )\n }\n }\n\n if (resolvedGlobalFilters.length) {\n for (let j = 0; j < resolvedGlobalFilters.length; j++) {\n const currentGlobalFilter = resolvedGlobalFilters[j]!\n const id = currentGlobalFilter.id\n // Tag the row with the first truthy global filter state\n if (\n currentGlobalFilter.filterFn(\n row,\n id,\n currentGlobalFilter.resolvedValue,\n (filterMeta) => {\n !row.columnFiltersMeta\n ? (row.columnFiltersMeta = {})\n : (row.columnFiltersMeta[id] = filterMeta)\n },\n )\n ) {\n row.columnFilters.__global__ = true\n break\n }\n }\n\n if (row.columnFilters.__global__ !== true) {\n row.columnFilters.__global__ = false\n }\n }\n }\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Row_ColumnFiltering<TFeatures, TData>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n // Filter final rows using all of the active filters\n return filterRows(rowModel.rows, filterRowsImpl as any, table)\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,SAAgB,uBAId,WACsE;CACtE,QAAQ,WAAW;EACjB,MAAM,QAA0C;EAChD,IAAI,CAAC,MAAM,aAAa,WAAW,MAAM,aAAa,YAAY;EAClE,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAChC;;GACD,UAAU,wBAAwB,MAAM;GACxC,qBAAqB,yBAAyB,MAAM;GACrD,CAAC;;;AAIN,SAAS,wBAGP,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AI,sBAAsB,QAAQ,KAAK;GACrD,MAAM,sBAAsB,sBAAsB;GAClD,MAAM,KAAK,oBAAoB;GAG/B,IAAI,cAAc,MAAM,oBAAoB,SAC1C,KACA,IACA,oBAAoB,gBACnB,eAAe;IACd,CAAC,IAAI,oBACA,IAAI,oBAAoB,EAAE,GAC1B,IAAI,kBAAkB,MAAM;KAEpC;;EAIL,IAAI,sBAAsB,QAAQ;GAChC,KAAK,IAAI,IAAI,GAAG,IAAI,sBAAsB,QAAQ,KAAK;IACrD,MAAM,sBAAsB,sBAAsB;IAClD,MAAM,KAAK,oBAAoB;IAE/B,IACE,oBAAoB,SAClB,KACA,IACA,oBAAoB,gBACnB,eAAe;KACd,CAAC,IAAI,oBACA,IAAI,oBAAoB,EAAE,GAC1B,IAAI,kBAAkB,MAAM;MAEpC,EACD;KACA,IAAI,cAAc,aAAa;KAC/B;;;GAIJ,IAAI,IAAI,cAAc,eAAe,MACnC,IAAI,cAAc,aAAa;;;CAKrC,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,IAAI,IAAI,cAAc,cAAc,QAAS,OAC3C,OAAO;EAGX,OAAO;;CAIT,OAAO,WAAW,SAAS,MAAM,gBAAuB,MAAM"}
|
|
@@ -103,15 +103,22 @@ function table_getOrderColumnsFn(table) {
|
|
|
103
103
|
if (!(columnOrder === null || columnOrder === void 0 ? void 0 : columnOrder.length)) orderedColumns = columns;
|
|
104
104
|
else {
|
|
105
105
|
const remaining = /* @__PURE__ */ new Map();
|
|
106
|
-
for (
|
|
107
|
-
|
|
106
|
+
for (let i = 0; i < columns.length; i++) {
|
|
107
|
+
const column = columns[i];
|
|
108
|
+
remaining.set(column.id, column);
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < columnOrder.length; i++) {
|
|
111
|
+
const id = columnOrder[i];
|
|
108
112
|
const column = remaining.get(id);
|
|
109
113
|
if (column) {
|
|
110
114
|
orderedColumns.push(column);
|
|
111
115
|
remaining.delete(id);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
|
-
for (
|
|
118
|
+
for (let i = 0; i < columns.length; i++) {
|
|
119
|
+
const column = columns[i];
|
|
120
|
+
if (remaining.has(column.id)) orderedColumns.push(column);
|
|
121
|
+
}
|
|
115
122
|
}
|
|
116
123
|
return orderColumns(table, orderedColumns);
|
|
117
124
|
};
|
|
@@ -134,10 +141,13 @@ function orderColumns(table, leafColumns) {
|
|
|
134
141
|
const nonGroupingColumns = leafColumns.filter((col) => !grouping.includes(col.id));
|
|
135
142
|
if (groupedColumnMode === "remove") return nonGroupingColumns;
|
|
136
143
|
const leafColumnsById = /* @__PURE__ */ new Map();
|
|
137
|
-
for (
|
|
144
|
+
for (let i = 0; i < leafColumns.length; i++) {
|
|
145
|
+
const col = leafColumns[i];
|
|
146
|
+
leafColumnsById.set(col.id, col);
|
|
147
|
+
}
|
|
138
148
|
const groupingColumns = [];
|
|
139
|
-
for (
|
|
140
|
-
const col = leafColumnsById.get(
|
|
149
|
+
for (let i = 0; i < grouping.length; i++) {
|
|
150
|
+
const col = leafColumnsById.get(grouping[i]);
|
|
141
151
|
if (col) groupingColumns.push(col);
|
|
142
152
|
}
|
|
143
153
|
return [...groupingColumns, ...nonGroupingColumns];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnOrderingFeature.utils.cjs","names":["table_getPinnedVisibleLeafColumns","cloneState"],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Returns the default column order state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Returns index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIndex(column)\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Returns is first column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFirstColumn(column)\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Returns is last column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsLastColumn(column)\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Updates the table's column order state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, (old) => old)\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets the table's column order state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Returns order columns fn for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (const column
|
|
1
|
+
{"version":3,"file":"columnOrderingFeature.utils.cjs","names":["table_getPinnedVisibleLeafColumns","cloneState"],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Returns the default column order state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Returns index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIndex(column)\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Returns is first column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFirstColumn(column)\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Returns is last column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsLastColumn(column)\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Updates the table's column order state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, (old) => old)\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets the table's column order state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Returns order columns fn for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n remaining.set(column.id, column)\n }\n\n // Place columns in the requested order, removing each as it's used\n // (handles duplicates and unknown ids in columnOrder)\n for (let i = 0; i < columnOrder.length; i++) {\n const id = columnOrder[i]!\n const column = remaining.get(id)\n if (column) {\n orderedColumns.push(column)\n remaining.delete(id)\n }\n }\n\n // Append leftover columns in their original order\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (remaining.has(column.id)) orderedColumns.push(column)\n }\n }\n\n return orderColumns(table, orderedColumns)\n }\n}\n\n/**\n * Orders leaf columns with manual ordering, grouping, and pinning rules.\n *\n * This helper is used by the column ordering feature to produce the final visible column order.\n *\n * @example\n * ```ts\n * const orderedColumns = orderColumns(leafColumns, columnOrder, grouping, groupedColumnMode)\n * ```\n */\nexport function orderColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>,\n) {\n const grouping = table.atoms.grouping?.get() ?? ([] as GroupingState)\n const { groupedColumnMode } = table.options\n\n if (!grouping.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n (col) => !grouping.includes(col.id),\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const leafColumnsById = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < leafColumns.length; i++) {\n const col = leafColumns[i]!\n leafColumnsById.set(col.id, col)\n }\n\n const groupingColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < grouping.length; i++) {\n const col = leafColumnsById.get(grouping[i]!)\n if (col) groupingColumns.push(col)\n }\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,SAAgB,6BAA+C;CAC7D,OAAO,EAAE;;;;;;;;;;;;AAaX,SAAgB,gBAKd,QACA,UACA;CAEA,OADgBA,qEAAkC,OAAO,OAAO,SAClD,CAAC,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG;;;;;;;;;;;;AAarD,SAAgB,wBAKd,QACA,UACA;;CAEA,qBADgBA,qEAAkC,OAAO,OAAO,SAClD,CAAC,0DAAI,QAAO,OAAO;;;;;;;;;;;;AAanC,SAAgB,uBAKd,QACA,UACA;;C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CAAC,SAAS,SAAS,IAAI,GAAG,CACpC;CAED,IAAI,sBAAsB,UACxB,OAAO;CAGT,MAAM,kCAAkB,IAAI,KAGzB;CACH,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,MAAM,YAAY;EACxB,gBAAgB,IAAI,IAAI,IAAI,IAAI;;CAGlC,MAAM,kBAAqE,EAAE;CAC7E,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,MAAM,gBAAgB,IAAI,SAAS,GAAI;EAC7C,IAAI,KAAK,gBAAgB,KAAK,IAAI;;CAGpC,OAAO,CAAC,GAAG,iBAAiB,GAAG,mBAAmB"}
|
|
@@ -103,15 +103,22 @@ function table_getOrderColumnsFn(table) {
|
|
|
103
103
|
if (!(columnOrder === null || columnOrder === void 0 ? void 0 : columnOrder.length)) orderedColumns = columns;
|
|
104
104
|
else {
|
|
105
105
|
const remaining = /* @__PURE__ */ new Map();
|
|
106
|
-
for (
|
|
107
|
-
|
|
106
|
+
for (let i = 0; i < columns.length; i++) {
|
|
107
|
+
const column = columns[i];
|
|
108
|
+
remaining.set(column.id, column);
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < columnOrder.length; i++) {
|
|
111
|
+
const id = columnOrder[i];
|
|
108
112
|
const column = remaining.get(id);
|
|
109
113
|
if (column) {
|
|
110
114
|
orderedColumns.push(column);
|
|
111
115
|
remaining.delete(id);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
|
-
for (
|
|
118
|
+
for (let i = 0; i < columns.length; i++) {
|
|
119
|
+
const column = columns[i];
|
|
120
|
+
if (remaining.has(column.id)) orderedColumns.push(column);
|
|
121
|
+
}
|
|
115
122
|
}
|
|
116
123
|
return orderColumns(table, orderedColumns);
|
|
117
124
|
};
|
|
@@ -134,10 +141,13 @@ function orderColumns(table, leafColumns) {
|
|
|
134
141
|
const nonGroupingColumns = leafColumns.filter((col) => !grouping.includes(col.id));
|
|
135
142
|
if (groupedColumnMode === "remove") return nonGroupingColumns;
|
|
136
143
|
const leafColumnsById = /* @__PURE__ */ new Map();
|
|
137
|
-
for (
|
|
144
|
+
for (let i = 0; i < leafColumns.length; i++) {
|
|
145
|
+
const col = leafColumns[i];
|
|
146
|
+
leafColumnsById.set(col.id, col);
|
|
147
|
+
}
|
|
138
148
|
const groupingColumns = [];
|
|
139
|
-
for (
|
|
140
|
-
const col = leafColumnsById.get(
|
|
149
|
+
for (let i = 0; i < grouping.length; i++) {
|
|
150
|
+
const col = leafColumnsById.get(grouping[i]);
|
|
141
151
|
if (col) groupingColumns.push(col);
|
|
142
152
|
}
|
|
143
153
|
return [...groupingColumns, ...nonGroupingColumns];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnOrderingFeature.utils.js","names":[],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Returns the default column order state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Returns index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIndex(column)\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Returns is first column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFirstColumn(column)\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Returns is last column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsLastColumn(column)\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Updates the table's column order state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, (old) => old)\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets the table's column order state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Returns order columns fn for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (const column
|
|
1
|
+
{"version":3,"file":"columnOrderingFeature.utils.js","names":[],"sources":["../../../src/features/column-ordering/columnOrderingFeature.utils.ts"],"sourcesContent":["import { table_getPinnedVisibleLeafColumns } from '../column-pinning/columnPinningFeature.utils'\nimport { cloneState } from '../../utils'\nimport type { GroupingState } from '../column-grouping/columnGroupingFeature.types'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type { ColumnPinningPosition } from '../column-pinning/columnPinningFeature.types'\nimport type { ColumnOrderState } from './columnOrderingFeature.types'\n\n/**\n * Returns the default column order state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnOrderState()\n * ```\n */\nexport function getDefaultColumnOrderState(): ColumnOrderState {\n return []\n}\n\n/**\n * Returns index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIndex(column)\n * ```\n */\nexport function column_getIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns.findIndex((d) => d.id === column.id)\n}\n\n/**\n * Returns is first column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFirstColumn(column)\n * ```\n */\nexport function column_getIsFirstColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[0]?.id === column.id\n}\n\n/**\n * Returns is last column for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsLastColumn(column)\n * ```\n */\nexport function column_getIsLastColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position?: ColumnPinningPosition | 'center',\n) {\n const columns = table_getPinnedVisibleLeafColumns(column.table, position)\n return columns[columns.length - 1]?.id === column.id\n}\n\n/**\n * Updates the table's column order state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnOrder(table, (old) => old)\n * ```\n */\nexport function table_setColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<ColumnOrderState>) {\n table.options.onColumnOrderChange?.(updater)\n}\n\n/**\n * Resets the table's column order state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnOrder(table)\n * table_resetColumnOrder(table, true)\n * ```\n */\nexport function table_resetColumnOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnOrder(\n table,\n defaultState ? [] : cloneState(table.initialState.columnOrder ?? []),\n )\n}\n\n/**\n * Returns order columns fn for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getOrderColumnsFn(table)\n * ```\n */\nexport function table_getOrderColumnsFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const columnOrder = table.atoms.columnOrder?.get()\n\n return (columns: Array<Column_Internal<TFeatures, TData, unknown>>) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n // Index columns by id for O(1) lookup\n const remaining = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n remaining.set(column.id, column)\n }\n\n // Place columns in the requested order, removing each as it's used\n // (handles duplicates and unknown ids in columnOrder)\n for (let i = 0; i < columnOrder.length; i++) {\n const id = columnOrder[i]!\n const column = remaining.get(id)\n if (column) {\n orderedColumns.push(column)\n remaining.delete(id)\n }\n }\n\n // Append leftover columns in their original order\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (remaining.has(column.id)) orderedColumns.push(column)\n }\n }\n\n return orderColumns(table, orderedColumns)\n }\n}\n\n/**\n * Orders leaf columns with manual ordering, grouping, and pinning rules.\n *\n * This helper is used by the column ordering feature to produce the final visible column order.\n *\n * @example\n * ```ts\n * const orderedColumns = orderColumns(leafColumns, columnOrder, grouping, groupedColumnMode)\n * ```\n */\nexport function orderColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n leafColumns: Array<Column_Internal<TFeatures, TData, unknown>>,\n) {\n const grouping = table.atoms.grouping?.get() ?? ([] as GroupingState)\n const { groupedColumnMode } = table.options\n\n if (!grouping.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n (col) => !grouping.includes(col.id),\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const leafColumnsById = new Map<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >()\n for (let i = 0; i < leafColumns.length; i++) {\n const col = leafColumns[i]!\n leafColumnsById.set(col.id, col)\n }\n\n const groupingColumns: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < grouping.length; i++) {\n const col = leafColumnsById.get(grouping[i]!)\n if (col) groupingColumns.push(col)\n }\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,SAAgB,6BAA+C;CAC7D,OAAO,EAAE;;;;;;;;;;;;AAaX,SAAgB,gBAKd,QACA,UACA;CAEA,OADgB,kCAAkC,OAAO,OAAO,SAClD,CAAC,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG;;;;;;;;;;;;AAarD,SAAgB,wBAKd,QACA,UACA;;CAEA,qBADgB,kCAAkC,OAAO,OAAO,SAClD,CAAC,0DAAI,QAAO,OAAO;;;;;;;;;;;;AAanC,SAAgB,uBAKd,QACA,UACA;;CACA,MAAM,UAAU,kCAAkC,OAAO,OAAO,SAAS;CACzE,oBAAO,QAAQ,QAAQ,SAAS,wDAAI,QAAO,OAAO;;;;;;;;;;;;AAapD,SAAgB,qBAGd,OAAyC,SAAoC;;CAC7E,iDAAM,SAAQ,gHAAsB,QAAQ;;;;;;;;;;;;;AAc9C,SAAgB,uBAGd,OAAyC,cAAwB;CACjE,qBACE,OACA,eAAe,EAAE,GAAG,WAAW,MAAM,aAAa,eAAe,EAAE,CAAC,CACrE;;;;;;;;;;;;AAaH,SAAgB,wBAGd,OAAyC;;CACzC,MAAM,uCAAc,MAAM,MAAM,2FAAa,KAAK;CAElD,QAAQ,Y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,iBAAiB,GAAG,mBAAmB"}
|
|
@@ -30,7 +30,12 @@ function getDefaultColumnPinningState() {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
function column_pin(column, position) {
|
|
33
|
-
const
|
|
33
|
+
const leafColumns = column.getLeafColumns();
|
|
34
|
+
const columnIds = [];
|
|
35
|
+
for (let i = 0; i < leafColumns.length; i++) {
|
|
36
|
+
const id = leafColumns[i].id;
|
|
37
|
+
if (id) columnIds.push(id);
|
|
38
|
+
}
|
|
34
39
|
table_setColumnPinning(column.table, (old) => {
|
|
35
40
|
if (position === "right") return {
|
|
36
41
|
left: old.left.filter((d) => !columnIds.includes(d)),
|
|
@@ -123,10 +128,10 @@ function row_getLeftVisibleCells(row) {
|
|
|
123
128
|
var _row$table$atoms$colu2;
|
|
124
129
|
const { left } = ((_row$table$atoms$colu2 = row.table.atoms.columnPinning) === null || _row$table$atoms$colu2 === void 0 ? void 0 : _row$table$atoms$colu2.get()) ?? getDefaultColumnPinningState();
|
|
125
130
|
if (!left.length) return [];
|
|
126
|
-
const allVisibleCells = require_utils.callMemoOrStaticFn(row, "
|
|
131
|
+
const allVisibleCells = require_utils.callMemoOrStaticFn(row, "getVisibleCellsByColumnId", require_columnVisibilityFeature_utils.row_getVisibleCellsByColumnId);
|
|
127
132
|
const cells = [];
|
|
128
|
-
for (
|
|
129
|
-
const cell = allVisibleCells
|
|
133
|
+
for (let i = 0; i < left.length; i++) {
|
|
134
|
+
const cell = allVisibleCells[left[i]];
|
|
130
135
|
if (cell) {
|
|
131
136
|
cell.position = "left";
|
|
132
137
|
cells.push(cell);
|
|
@@ -148,10 +153,10 @@ function row_getRightVisibleCells(row) {
|
|
|
148
153
|
var _row$table$atoms$colu3;
|
|
149
154
|
const { right } = ((_row$table$atoms$colu3 = row.table.atoms.columnPinning) === null || _row$table$atoms$colu3 === void 0 ? void 0 : _row$table$atoms$colu3.get()) ?? getDefaultColumnPinningState();
|
|
150
155
|
if (!right.length) return [];
|
|
151
|
-
const allVisibleCells = require_utils.callMemoOrStaticFn(row, "
|
|
156
|
+
const allVisibleCells = require_utils.callMemoOrStaticFn(row, "getVisibleCellsByColumnId", require_columnVisibilityFeature_utils.row_getVisibleCellsByColumnId);
|
|
152
157
|
const cells = [];
|
|
153
|
-
for (
|
|
154
|
-
const cell = allVisibleCells
|
|
158
|
+
for (let i = 0; i < right.length; i++) {
|
|
159
|
+
const cell = allVisibleCells[right[i]];
|
|
155
160
|
if (cell) {
|
|
156
161
|
cell.position = "right";
|
|
157
162
|
cells.push(cell);
|
|
@@ -219,8 +224,8 @@ function table_getLeftHeaderGroups(table) {
|
|
|
219
224
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
220
225
|
const { left } = ((_table$atoms$columnPi2 = table.atoms.columnPinning) === null || _table$atoms$columnPi2 === void 0 ? void 0 : _table$atoms$columnPi2.get()) ?? getDefaultColumnPinningState();
|
|
221
226
|
const orderedLeafColumns = [];
|
|
222
|
-
for (
|
|
223
|
-
const column = leafColumnsById[
|
|
227
|
+
for (let i = 0; i < left.length; i++) {
|
|
228
|
+
const column = leafColumnsById[left[i]];
|
|
224
229
|
if (column && require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) orderedLeafColumns.push(column);
|
|
225
230
|
}
|
|
226
231
|
return require_buildHeaderGroups.buildHeaderGroups(allColumns, orderedLeafColumns, table, "left");
|
|
@@ -241,8 +246,8 @@ function table_getRightHeaderGroups(table) {
|
|
|
241
246
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
242
247
|
const { right } = ((_table$atoms$columnPi3 = table.atoms.columnPinning) === null || _table$atoms$columnPi3 === void 0 ? void 0 : _table$atoms$columnPi3.get()) ?? getDefaultColumnPinningState();
|
|
243
248
|
const orderedLeafColumns = [];
|
|
244
|
-
for (
|
|
245
|
-
const column = leafColumnsById[
|
|
249
|
+
for (let i = 0; i < right.length; i++) {
|
|
250
|
+
const column = leafColumnsById[right[i]];
|
|
246
251
|
if (column && require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) orderedLeafColumns.push(column);
|
|
247
252
|
}
|
|
248
253
|
return require_buildHeaderGroups.buildHeaderGroups(allColumns, orderedLeafColumns, table, "right");
|
|
@@ -316,9 +321,13 @@ function table_getCenterFooterGroups(table) {
|
|
|
316
321
|
* ```
|
|
317
322
|
*/
|
|
318
323
|
function table_getLeftFlatHeaders(table) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
324
|
+
const leftHeaderGroups = require_utils.callMemoOrStaticFn(table, "getLeftHeaderGroups", table_getLeftHeaderGroups);
|
|
325
|
+
const result = [];
|
|
326
|
+
for (let i = 0; i < leftHeaderGroups.length; i++) {
|
|
327
|
+
const headers = leftHeaderGroups[i].headers;
|
|
328
|
+
for (let j = 0; j < headers.length; j++) result.push(headers[j]);
|
|
329
|
+
}
|
|
330
|
+
return result;
|
|
322
331
|
}
|
|
323
332
|
/**
|
|
324
333
|
* Returns right flat headers for the table.
|
|
@@ -331,9 +340,13 @@ function table_getLeftFlatHeaders(table) {
|
|
|
331
340
|
* ```
|
|
332
341
|
*/
|
|
333
342
|
function table_getRightFlatHeaders(table) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
const rightHeaderGroups = require_utils.callMemoOrStaticFn(table, "getRightHeaderGroups", table_getRightHeaderGroups);
|
|
344
|
+
const result = [];
|
|
345
|
+
for (let i = 0; i < rightHeaderGroups.length; i++) {
|
|
346
|
+
const headers = rightHeaderGroups[i].headers;
|
|
347
|
+
for (let j = 0; j < headers.length; j++) result.push(headers[j]);
|
|
348
|
+
}
|
|
349
|
+
return result;
|
|
337
350
|
}
|
|
338
351
|
/**
|
|
339
352
|
* Returns center flat headers for the table.
|
|
@@ -346,9 +359,13 @@ function table_getRightFlatHeaders(table) {
|
|
|
346
359
|
* ```
|
|
347
360
|
*/
|
|
348
361
|
function table_getCenterFlatHeaders(table) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
362
|
+
const centerHeaderGroups = require_utils.callMemoOrStaticFn(table, "getCenterHeaderGroups", table_getCenterHeaderGroups);
|
|
363
|
+
const result = [];
|
|
364
|
+
for (let i = 0; i < centerHeaderGroups.length; i++) {
|
|
365
|
+
const headers = centerHeaderGroups[i].headers;
|
|
366
|
+
for (let j = 0; j < headers.length; j++) result.push(headers[j]);
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
352
369
|
}
|
|
353
370
|
/**
|
|
354
371
|
* Returns left leaf headers for the table.
|
|
@@ -404,8 +421,8 @@ function table_getLeftLeafColumns(table) {
|
|
|
404
421
|
const { left } = ((_table$atoms$columnPi5 = table.atoms.columnPinning) === null || _table$atoms$columnPi5 === void 0 ? void 0 : _table$atoms$columnPi5.get()) ?? getDefaultColumnPinningState();
|
|
405
422
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
406
423
|
const result = [];
|
|
407
|
-
for (
|
|
408
|
-
const column = leafColumnsById[
|
|
424
|
+
for (let i = 0; i < left.length; i++) {
|
|
425
|
+
const column = leafColumnsById[left[i]];
|
|
409
426
|
if (column) result.push(column);
|
|
410
427
|
}
|
|
411
428
|
return result;
|
|
@@ -425,8 +442,8 @@ function table_getRightLeafColumns(table) {
|
|
|
425
442
|
const { right } = ((_table$atoms$columnPi6 = table.atoms.columnPinning) === null || _table$atoms$columnPi6 === void 0 ? void 0 : _table$atoms$columnPi6.get()) ?? getDefaultColumnPinningState();
|
|
426
443
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
427
444
|
const result = [];
|
|
428
|
-
for (
|
|
429
|
-
const column = leafColumnsById[
|
|
445
|
+
for (let i = 0; i < right.length; i++) {
|
|
446
|
+
const column = leafColumnsById[right[i]];
|
|
430
447
|
if (column) result.push(column);
|
|
431
448
|
}
|
|
432
449
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnPinningFeature.utils.cjs","names":["callMemoOrStaticFn","row_getVisibleCells","cloneState","column_getIsVisible","buildHeaderGroups","table_getVisibleLeafColumns"],"sources":["../../../src/features/column-pinning/columnPinningFeature.utils.ts"],"sourcesContent":["import {\n column_getIsVisible,\n row_getVisibleCells,\n table_getVisibleLeafColumns,\n} from '../column-visibility/columnVisibilityFeature.utils'\nimport { buildHeaderGroups } from '../../core/headers/buildHeaderGroups'\nimport { callMemoOrStaticFn, cloneState } from '../../utils'\nimport type { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Cell } from '../../types/Cell'\nimport type { Row } from '../../types/Row'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnPinningPosition,\n ColumnPinningState,\n} from './columnPinningFeature.types'\n\n// State\n\n/**\n * Returns the default column pinning state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnPinningState()\n * ```\n */\nexport function getDefaultColumnPinningState(): ColumnPinningState {\n return {\n left: [],\n right: [],\n }\n}\n\n// Column APIs\n\n/**\n * Pin. for a column.\n *\n * This is the static implementation behind the matching column instance API.\n *\n * @example\n * ```ts\n * column_pin(column, 'left')\n * ```\n */\nexport function column_pin<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position: ColumnPinningPosition,\n) {\n const columnIds = column\n .getLeafColumns()\n .map((d) => d.id)\n .filter(Boolean)\n\n table_setColumnPinning(column.table, (old) => {\n if (position === 'right') {\n return {\n left: old.left.filter((d) => !columnIds.includes(d)),\n right: [\n ...old.right.filter((d) => !columnIds.includes(d)),\n ...columnIds,\n ],\n }\n }\n\n if (position === 'left') {\n return {\n left: [...old.left.filter((d) => !columnIds.includes(d)), ...columnIds],\n right: old.right.filter((d) => !columnIds.includes(d)),\n }\n }\n\n return {\n left: old.left.filter((d) => !columnIds.includes(d)),\n right: old.right.filter((d) => !columnIds.includes(d)),\n }\n })\n}\n\n/**\n * Returns whether a column can use pin.\n *\n * This combines column options, table options, and any required accessor or feature state for the capability.\n *\n * @example\n * ```ts\n * const value = column_getCanPin(column)\n * ```\n */\nexport function column_getCanPin<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const leafColumns = column.getLeafColumns() as Array<\n Column_Internal<TFeatures, TData, TValue>\n >\n\n return leafColumns.some(\n (leafColumn) =>\n (leafColumn.columnDef.enablePinning ?? true) &&\n (column.table.options.enableColumnPinning ?? true),\n )\n}\n\n/**\n * Returns is pinned for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsPinned(column)\n * ```\n */\nexport function column_getIsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): ColumnPinningPosition | false {\n const leafColumnIds = column.getLeafColumns().map((d) => d.id)\n\n const { left, right } =\n column.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const isLeft = leafColumnIds.some((d) => left.includes(d))\n const isRight = leafColumnIds.some((d) => right.includes(d))\n\n return isLeft ? 'left' : isRight ? 'right' : false\n}\n\n/**\n * Returns pinned index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getPinnedIndex(column)\n * ```\n */\nexport function column_getPinnedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const position = column_getIsPinned(column)\n\n return position\n ? (column.table.atoms.columnPinning?.get()?.[position].indexOf(column.id) ??\n -1)\n : 0\n}\n\n// Row APIs\n\n/**\n * Returns center visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getCenterVisibleCells(row)\n * ```\n */\nexport function row_getCenterVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const allCells = callMemoOrStaticFn(\n row,\n 'getVisibleCells',\n row_getVisibleCells,\n )\n const { left, right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n return allCells.filter((d) => !leftAndRight.includes(d.column.id))\n}\n\n/**\n * Returns left visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getLeftVisibleCells(row)\n * ```\n */\nexport function row_getLeftVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const { left } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!left.length) return []\n const allVisibleCells = callMemoOrStaticFn(\n row,\n 'getVisibleCells',\n row_getVisibleCells,\n )\n const cells: typeof allVisibleCells = []\n for (const columnId of left) {\n const cell = allVisibleCells.find((c) => c.column.id === columnId)\n if (cell) {\n // Assign position property directly to preserve prototype chain\n cell.position = 'left'\n cells.push(cell)\n }\n }\n return cells\n}\n\n/**\n * Returns right visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getRightVisibleCells(row)\n * ```\n */\nexport function row_getRightVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const { right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!right.length) return [] as Array<Cell<TFeatures, TData, unknown>>\n const allVisibleCells = callMemoOrStaticFn(\n row,\n 'getVisibleCells',\n row_getVisibleCells,\n )\n const cells: typeof allVisibleCells = []\n for (const columnId of right) {\n const cell = allVisibleCells.find((c) => c.column.id === columnId)\n if (cell) {\n // Assign position property directly to preserve prototype chain\n cell.position = 'right'\n cells.push(cell)\n }\n }\n return cells\n}\n\n// Table APIs\n\n/**\n * Updates the table's column pinning state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnPinning(table, (old) => old)\n * ```\n */\nexport function table_setColumnPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnPinningState>,\n) {\n table.options.onColumnPinningChange?.(updater)\n}\n\n/**\n * Resets the table's column pinning state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnPinning(table)\n * table_resetColumnPinning(table, true)\n * ```\n */\nexport function table_resetColumnPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnPinning(\n table,\n defaultState\n ? getDefaultColumnPinningState()\n : cloneState(\n table.initialState.columnPinning ?? getDefaultColumnPinningState(),\n ),\n )\n}\n\n/**\n * Returns is some columns pinned for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsSomeColumnsPinned(table)\n * ```\n */\nexport function table_getIsSomeColumnsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, position?: ColumnPinningPosition) {\n const pinningState = table.atoms.columnPinning?.get()\n\n if (!position) {\n return Boolean(pinningState?.left.length || pinningState?.right.length)\n }\n return Boolean(pinningState?.[position].length)\n}\n\n// header groups\n\n/**\n * Returns left header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftHeaderGroups(table)\n * ```\n */\nexport function table_getLeftHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const allColumns = table.getAllColumns()\n const leafColumnsById = table.getAllLeafColumnsById() as Record<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >\n const { left } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const orderedLeafColumns: Array<Column_Internal<TFeatures, TData, unknown>> =\n []\n for (const columnId of left) {\n const column = leafColumnsById[columnId]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n orderedLeafColumns.push(column)\n }\n }\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left')\n}\n\n/**\n * Returns right header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightHeaderGroups(table)\n * ```\n */\nexport function table_getRightHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const allColumns = table.getAllColumns()\n const leafColumnsById = table.getAllLeafColumnsById() as Record<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >\n const { right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const orderedLeafColumns: Array<Column_Internal<TFeatures, TData, unknown>> =\n []\n for (const columnId of right) {\n const column = leafColumnsById[columnId]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n orderedLeafColumns.push(column)\n }\n }\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right')\n}\n\n/**\n * Returns center header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterHeaderGroups(table)\n * ```\n */\nexport function table_getCenterHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<HeaderGroup<TFeatures, TData>> {\n const allColumns = table.getAllColumns()\n let leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n ) as unknown as Array<Column_Internal<TFeatures, TData, unknown>>\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n\n leafColumns = leafColumns.filter(\n (column) => !leftAndRight.includes(column.id),\n )\n return buildHeaderGroups(allColumns, leafColumns, table, 'center')\n}\n\n// footer groups\n\n/**\n * Returns left footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftFooterGroups(table)\n * ```\n */\nexport function table_getLeftFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getLeftHeaderGroups',\n table_getLeftHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns right footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightFooterGroups(table)\n * ```\n */\nexport function table_getRightFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getRightHeaderGroups',\n table_getRightHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns center footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterFooterGroups(table)\n * ```\n */\nexport function table_getCenterFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getCenterHeaderGroups',\n table_getCenterHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n// flat headers\n\n/**\n * Returns left flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftFlatHeaders(table)\n * ```\n */\nexport function table_getLeftFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const leftHeaderGroups = callMemoOrStaticFn(\n table,\n 'getLeftHeaderGroups',\n table_getLeftHeaderGroups,\n )\n return leftHeaderGroups\n .map((headerGroup) => {\n return headerGroup.headers\n })\n .flat()\n}\n\n/**\n * Returns right flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightFlatHeaders(table)\n * ```\n */\nexport function table_getRightFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rightHeaderGroups = callMemoOrStaticFn(\n table,\n 'getRightHeaderGroups',\n table_getRightHeaderGroups,\n )\n return rightHeaderGroups\n .map((headerGroup) => {\n return headerGroup.headers\n })\n .flat()\n}\n\n/**\n * Returns center flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterFlatHeaders(table)\n * ```\n */\nexport function table_getCenterFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const centerHeaderGroups = callMemoOrStaticFn(\n table,\n 'getCenterHeaderGroups',\n table_getCenterHeaderGroups,\n )\n return centerHeaderGroups\n .map((headerGroup) => {\n return headerGroup.headers\n })\n .flat()\n}\n\n// leaf headers\n\n/**\n * Returns left leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftLeafHeaders(table)\n * ```\n */\nexport function table_getLeftLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getLeftFlatHeaders',\n table_getLeftFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n/**\n * Returns right leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightLeafHeaders(table)\n * ```\n */\nexport function table_getRightLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getRightFlatHeaders',\n table_getRightFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n/**\n * Returns center leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterLeafHeaders(table)\n * ```\n */\nexport function table_getCenterLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getCenterFlatHeaders',\n table_getCenterFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n// leaf columns\n\n/**\n * Returns left leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftLeafColumns(table)\n * ```\n */\nexport function table_getLeftLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leafColumnsById = table.getAllLeafColumnsById()\n const result: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (const columnId of left) {\n const column = leafColumnsById[columnId]\n if (column) result.push(column)\n }\n return result\n}\n\n/**\n * Returns right leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightLeafColumns(table)\n * ```\n */\nexport function table_getRightLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leafColumnsById = table.getAllLeafColumnsById()\n const result: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (const columnId of right) {\n const column = leafColumnsById[columnId]\n if (column) result.push(column)\n }\n return result\n}\n\n/**\n * Returns center leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterLeafColumns(table)\n * ```\n */\nexport function table_getCenterLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n return table.getAllLeafColumns().filter((d) => !leftAndRight.includes(d.id))\n}\n\n/**\n * Returns pinned leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getPinnedLeafColumns(table)\n * ```\n */\nexport function table_getPinnedLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position: ColumnPinningPosition | 'center',\n) {\n return !position\n ? table.getAllLeafColumns()\n : position === 'left'\n ? callMemoOrStaticFn(\n table,\n 'getLeftLeafColumns',\n table_getLeftLeafColumns,\n )\n : position === 'right'\n ? callMemoOrStaticFn(\n table,\n 'getRightLeafColumns',\n table_getRightLeafColumns,\n )\n : callMemoOrStaticFn(\n table,\n 'getCenterLeafColumns',\n table_getCenterLeafColumns,\n )\n}\n\n// visible leaf columns\n\n/**\n * Returns left visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftVisibleLeafColumns(table)\n * ```\n */\nexport function table_getLeftVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getLeftLeafColumns',\n table_getLeftLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns right visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightVisibleLeafColumns(table)\n * ```\n */\nexport function table_getRightVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getRightLeafColumns',\n table_getRightLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns center visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterVisibleLeafColumns(table)\n * ```\n */\nexport function table_getCenterVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getCenterLeafColumns',\n table_getCenterLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns pinned visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getPinnedVisibleLeafColumns(table)\n * ```\n */\nexport function table_getPinnedVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position?: ColumnPinningPosition | 'center',\n) {\n return !position\n ? callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n : position === 'left'\n ? callMemoOrStaticFn(\n table,\n 'getLeftVisibleLeafColumns',\n table_getLeftVisibleLeafColumns,\n )\n : position === 'right'\n ? callMemoOrStaticFn(\n table,\n 'getRightVisibleLeafColumns',\n table_getRightVisibleLeafColumns,\n )\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aAAa,SACXA,iCACE,OACA,sBACA,yBACD,GACD,aAAa,UACXA,iCACE,OACA,uBACA,0BACD,GACDA,iCACE,OACA,wBACA,2BACD;;;;;;;;;;;;AAeX,SAAgB,gCAGd,OAAyC;CACzC,OAAOA,iCACL,OACA,sBACA,yBACD,CAAC,QAAQ,WACRA,iCAAmB,QAAQ,gBAAgBG,0DAAoB,CAChE;;;;;;;;;;;;AAaH,SAAgB,iCAGd,OAAyC;CACzC,OAAOH,iCACL,OACA,uBACA,0BACD,CAAC,QAAQ,WACRA,iCAAmB,QAAQ,gBAAgBG,0DAAoB,CAChE;;;;;;;;;;;;AAaH,SAAgB,kCAGd,OAAyC;CACzC,OAAOH,iCACL,OACA,wBACA,2BACD,CAAC,QAAQ,WACRA,iCAAmB,QAAQ,gBAAgBG,0DAAoB,CAChE;;;;;;;;;;;;AAaH,SAAgB,kCAId,OACA,UACA;CACA,OAAO,CAAC,WACJH,iCACE,OACA,yBACAK,kEACD,GACD,aAAa,SACXL,iCACE,OACA,6BACA,gCACD,GACD,aAAa,UACXA,iCACE,OACA,8BACA,iCACD,GACDA,iCACE,OACA,+BACA,kCACD"}
|
|
1
|
+
{"version":3,"file":"columnPinningFeature.utils.cjs","names":["callMemoOrStaticFn","row_getVisibleCells","row_getVisibleCellsByColumnId","cloneState","column_getIsVisible","buildHeaderGroups","table_getVisibleLeafColumns"],"sources":["../../../src/features/column-pinning/columnPinningFeature.utils.ts"],"sourcesContent":["import {\n column_getIsVisible,\n row_getVisibleCells,\n row_getVisibleCellsByColumnId,\n table_getVisibleLeafColumns,\n} from '../column-visibility/columnVisibilityFeature.utils'\nimport { buildHeaderGroups } from '../../core/headers/buildHeaderGroups'\nimport { callMemoOrStaticFn, cloneState } from '../../utils'\nimport type { Header } from '../../types/Header'\nimport type { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Cell } from '../../types/Cell'\nimport type { Row } from '../../types/Row'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnPinningPosition,\n ColumnPinningState,\n} from './columnPinningFeature.types'\n\n// State\n\n/**\n * Returns the default column pinning state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnPinningState()\n * ```\n */\nexport function getDefaultColumnPinningState(): ColumnPinningState {\n return {\n left: [],\n right: [],\n }\n}\n\n// Column APIs\n\n/**\n * Pin. for a column.\n *\n * This is the static implementation behind the matching column instance API.\n *\n * @example\n * ```ts\n * column_pin(column, 'left')\n * ```\n */\nexport function column_pin<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n position: ColumnPinningPosition,\n) {\n // Single pass: collect non-empty leaf-column ids.\n const leafColumns = column.getLeafColumns()\n const columnIds: Array<string> = []\n for (let i = 0; i < leafColumns.length; i++) {\n const id = leafColumns[i]!.id\n if (id) columnIds.push(id)\n }\n\n table_setColumnPinning(column.table, (old) => {\n if (position === 'right') {\n return {\n left: old.left.filter((d) => !columnIds.includes(d)),\n right: [\n ...old.right.filter((d) => !columnIds.includes(d)),\n ...columnIds,\n ],\n }\n }\n\n if (position === 'left') {\n return {\n left: [...old.left.filter((d) => !columnIds.includes(d)), ...columnIds],\n right: old.right.filter((d) => !columnIds.includes(d)),\n }\n }\n\n return {\n left: old.left.filter((d) => !columnIds.includes(d)),\n right: old.right.filter((d) => !columnIds.includes(d)),\n }\n })\n}\n\n/**\n * Returns whether a column can use pin.\n *\n * This combines column options, table options, and any required accessor or feature state for the capability.\n *\n * @example\n * ```ts\n * const value = column_getCanPin(column)\n * ```\n */\nexport function column_getCanPin<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const leafColumns = column.getLeafColumns() as Array<\n Column_Internal<TFeatures, TData, TValue>\n >\n\n return leafColumns.some(\n (leafColumn) =>\n (leafColumn.columnDef.enablePinning ?? true) &&\n (column.table.options.enableColumnPinning ?? true),\n )\n}\n\n/**\n * Returns is pinned for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsPinned(column)\n * ```\n */\nexport function column_getIsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): ColumnPinningPosition | false {\n const leafColumnIds = column.getLeafColumns().map((d) => d.id)\n\n const { left, right } =\n column.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const isLeft = leafColumnIds.some((d) => left.includes(d))\n const isRight = leafColumnIds.some((d) => right.includes(d))\n\n return isLeft ? 'left' : isRight ? 'right' : false\n}\n\n/**\n * Returns pinned index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getPinnedIndex(column)\n * ```\n */\nexport function column_getPinnedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const position = column_getIsPinned(column)\n\n return position\n ? (column.table.atoms.columnPinning?.get()?.[position].indexOf(column.id) ??\n -1)\n : 0\n}\n\n// Row APIs\n\n/**\n * Returns center visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getCenterVisibleCells(row)\n * ```\n */\nexport function row_getCenterVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const allCells = callMemoOrStaticFn(\n row,\n 'getVisibleCells',\n row_getVisibleCells,\n )\n const { left, right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n return allCells.filter((d) => !leftAndRight.includes(d.column.id))\n}\n\n/**\n * Returns left visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getLeftVisibleCells(row)\n * ```\n */\nexport function row_getLeftVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const { left } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!left.length) return []\n const allVisibleCells = callMemoOrStaticFn(\n row,\n 'getVisibleCellsByColumnId',\n row_getVisibleCellsByColumnId,\n )\n const cells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < left.length; i++) {\n const columnId = left[i]!\n const cell = allVisibleCells[columnId]\n if (cell) {\n // Assign position property directly to preserve prototype chain\n cell.position = 'left'\n cells.push(cell)\n }\n }\n return cells\n}\n\n/**\n * Returns right visible cells for a row.\n *\n * This is the static implementation behind the matching row instance API and may read row caches or table state atoms.\n *\n * @example\n * ```ts\n * const value = row_getRightVisibleCells(row)\n * ```\n */\nexport function row_getRightVisibleCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const { right } =\n row.table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n if (!right.length) return [] as Array<Cell<TFeatures, TData, unknown>>\n const allVisibleCells = callMemoOrStaticFn(\n row,\n 'getVisibleCellsByColumnId',\n row_getVisibleCellsByColumnId,\n )\n const cells: Array<Cell<TFeatures, TData, unknown>> = []\n for (let i = 0; i < right.length; i++) {\n const columnId = right[i]!\n const cell = allVisibleCells[columnId]\n if (cell) {\n // Assign position property directly to preserve prototype chain\n cell.position = 'right'\n cells.push(cell)\n }\n }\n return cells\n}\n\n// Table APIs\n\n/**\n * Updates the table's column pinning state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnPinning(table, (old) => old)\n * ```\n */\nexport function table_setColumnPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnPinningState>,\n) {\n table.options.onColumnPinningChange?.(updater)\n}\n\n/**\n * Resets the table's column pinning state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnPinning(table)\n * table_resetColumnPinning(table, true)\n * ```\n */\nexport function table_resetColumnPinning<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnPinning(\n table,\n defaultState\n ? getDefaultColumnPinningState()\n : cloneState(\n table.initialState.columnPinning ?? getDefaultColumnPinningState(),\n ),\n )\n}\n\n/**\n * Returns is some columns pinned for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getIsSomeColumnsPinned(table)\n * ```\n */\nexport function table_getIsSomeColumnsPinned<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, position?: ColumnPinningPosition) {\n const pinningState = table.atoms.columnPinning?.get()\n\n if (!position) {\n return Boolean(pinningState?.left.length || pinningState?.right.length)\n }\n return Boolean(pinningState?.[position].length)\n}\n\n// header groups\n\n/**\n * Returns left header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftHeaderGroups(table)\n * ```\n */\nexport function table_getLeftHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const allColumns = table.getAllColumns()\n const leafColumnsById = table.getAllLeafColumnsById() as Record<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >\n const { left } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const orderedLeafColumns: Array<Column_Internal<TFeatures, TData, unknown>> =\n []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n orderedLeafColumns.push(column)\n }\n }\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left')\n}\n\n/**\n * Returns right header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightHeaderGroups(table)\n * ```\n */\nexport function table_getRightHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const allColumns = table.getAllColumns()\n const leafColumnsById = table.getAllLeafColumnsById() as Record<\n string,\n Column_Internal<TFeatures, TData, unknown>\n >\n const { right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n\n const orderedLeafColumns: Array<Column_Internal<TFeatures, TData, unknown>> =\n []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n orderedLeafColumns.push(column)\n }\n }\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right')\n}\n\n/**\n * Returns center header groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterHeaderGroups(table)\n * ```\n */\nexport function table_getCenterHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<HeaderGroup<TFeatures, TData>> {\n const allColumns = table.getAllColumns()\n let leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n ) as unknown as Array<Column_Internal<TFeatures, TData, unknown>>\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n\n leafColumns = leafColumns.filter(\n (column) => !leftAndRight.includes(column.id),\n )\n return buildHeaderGroups(allColumns, leafColumns, table, 'center')\n}\n\n// footer groups\n\n/**\n * Returns left footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftFooterGroups(table)\n * ```\n */\nexport function table_getLeftFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getLeftHeaderGroups',\n table_getLeftHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns right footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightFooterGroups(table)\n * ```\n */\nexport function table_getRightFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getRightHeaderGroups',\n table_getRightHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns center footer groups for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterFooterGroups(table)\n * ```\n */\nexport function table_getCenterFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = callMemoOrStaticFn(\n table,\n 'getCenterHeaderGroups',\n table_getCenterHeaderGroups,\n )\n return [...headerGroups].reverse()\n}\n\n// flat headers\n\n/**\n * Returns left flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftFlatHeaders(table)\n * ```\n */\nexport function table_getLeftFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const leftHeaderGroups = callMemoOrStaticFn(\n table,\n 'getLeftHeaderGroups',\n table_getLeftHeaderGroups,\n )\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < leftHeaderGroups.length; i++) {\n const headers = leftHeaderGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j])\n }\n }\n return result\n}\n\n/**\n * Returns right flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightFlatHeaders(table)\n * ```\n */\nexport function table_getRightFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rightHeaderGroups = callMemoOrStaticFn(\n table,\n 'getRightHeaderGroups',\n table_getRightHeaderGroups,\n )\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < rightHeaderGroups.length; i++) {\n const headers = rightHeaderGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j])\n }\n }\n return result\n}\n\n/**\n * Returns center flat headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterFlatHeaders(table)\n * ```\n */\nexport function table_getCenterFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const centerHeaderGroups = callMemoOrStaticFn(\n table,\n 'getCenterHeaderGroups',\n table_getCenterHeaderGroups,\n )\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < centerHeaderGroups.length; i++) {\n const headers = centerHeaderGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j])\n }\n }\n return result\n}\n\n// leaf headers\n\n/**\n * Returns left leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftLeafHeaders(table)\n * ```\n */\nexport function table_getLeftLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getLeftFlatHeaders',\n table_getLeftFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n/**\n * Returns right leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightLeafHeaders(table)\n * ```\n */\nexport function table_getRightLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getRightFlatHeaders',\n table_getRightFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n/**\n * Returns center leaf headers for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterLeafHeaders(table)\n * ```\n */\nexport function table_getCenterLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getCenterFlatHeaders',\n table_getCenterFlatHeaders,\n ).filter((header) => !header.subHeaders.length)\n}\n\n// leaf columns\n\n/**\n * Returns left leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftLeafColumns(table)\n * ```\n */\nexport function table_getLeftLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leafColumnsById = table.getAllLeafColumnsById()\n const result: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (column) result.push(column)\n }\n return result\n}\n\n/**\n * Returns right leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightLeafColumns(table)\n * ```\n */\nexport function table_getRightLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leafColumnsById = table.getAllLeafColumnsById()\n const result: Array<Column_Internal<TFeatures, TData, unknown>> = []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (column) result.push(column)\n }\n return result\n}\n\n/**\n * Returns center leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterLeafColumns(table)\n * ```\n */\nexport function table_getCenterLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const leftAndRight: Array<string> = [...left, ...right]\n return table.getAllLeafColumns().filter((d) => !leftAndRight.includes(d.id))\n}\n\n/**\n * Returns pinned leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getPinnedLeafColumns(table)\n * ```\n */\nexport function table_getPinnedLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position: ColumnPinningPosition | 'center',\n) {\n return !position\n ? table.getAllLeafColumns()\n : position === 'left'\n ? callMemoOrStaticFn(\n table,\n 'getLeftLeafColumns',\n table_getLeftLeafColumns,\n )\n : position === 'right'\n ? callMemoOrStaticFn(\n table,\n 'getRightLeafColumns',\n table_getRightLeafColumns,\n )\n : callMemoOrStaticFn(\n table,\n 'getCenterLeafColumns',\n table_getCenterLeafColumns,\n )\n}\n\n// visible leaf columns\n\n/**\n * Returns left visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getLeftVisibleLeafColumns(table)\n * ```\n */\nexport function table_getLeftVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getLeftLeafColumns',\n table_getLeftLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns right visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getRightVisibleLeafColumns(table)\n * ```\n */\nexport function table_getRightVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getRightLeafColumns',\n table_getRightLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns center visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getCenterVisibleLeafColumns(table)\n * ```\n */\nexport function table_getCenterVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n return callMemoOrStaticFn(\n table,\n 'getCenterLeafColumns',\n table_getCenterLeafColumns,\n ).filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n}\n\n/**\n * Returns pinned visible leaf columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getPinnedVisibleLeafColumns(table)\n * ```\n */\nexport function table_getPinnedVisibleLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n position?: ColumnPinningPosition | 'center',\n) {\n return !position\n ? callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n : position === 'left'\n ? callMemoOrStaticFn(\n table,\n 'getLeftVisibleLeafColumns',\n table_getLeftVisibleLeafColumns,\n )\n : position === 'right'\n ? callMemoOrStaticFn(\n table,\n 'getRightVisibleLeafColumns',\n table_getRightVisibleLeafColumns,\n )\n : callMemoOrStaticFn(\n table,\n 'getCenterVisibleLeafColumns',\n table_getCenterVisibleLeafColumns,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,SAAgB,+BAAmD;CACjE,OAAO;EACL,MAAM,EAAE;EACR,OAAO,EAAE;EACV;;;;;;;;;;;;AAeH,SAAgB,WAKd,QACA,UACA;CAEA,MAAM,cAAc,OAAO,gBAAgB;CAC3C,MAAM,YAA2B,EAAE;CACnC,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,KAAK,YAAY,GAAI;EAC3B,IAAI,IAAI,UAAU,KAAK,GAAG;;CAG5B,uBAAuB,OAAO,QAAQ,QAAQ;EAC5C,IAAI,aAAa,SACf,OAAO;GACL,MAAM,IAAI,KAAK,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC;GACpD,OAAO,CACL,GAAG,IAAI,MAAM,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC,EAClD,GAAG,UACJ;GACF;EAGH,IAAI,aAAa,QACf,OAAO;GACL,MAAM,CAAC,GAAG,IAAI,KAAK,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC,EAAE,GAAG,UAAU;GACvE,OAAO,IAAI,MAAM,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC;GACvD;EAGH,OAAO;GACL,MAAM,IAAI,KAAK,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC;GACpD,OAAO,IAAI,MAAM,QAAQ,MAAM,CAAC,UAAU,SAAS,EAAE,CAAC;GACvD;GACD;;;;;;;;;;;;AAaJ,SAAgB,iBAId,QAAmD;CAKnD,OAJoB,OAAO,gBAIT,CAAC,MAChB,gBACE,WAAW,UAAU,iBAAiB,UACtC,OAAO,MAAM,QAAQ,uBAAuB,MAChD;;;;;;;;;;;;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