@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":"constructHeader.js","names":[],"sources":["../../../src/core/headers/constructHeader.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header } from '../../types/Header'\nimport type { Column } from '../../types/Column'\nimport type { Header_CoreProperties } from './coreHeadersFeature.types'\n\n/**\n * Creates or retrieves the header prototype for a table.\n * The prototype is cached on the table and shared by all header instances.\n */\nfunction getHeaderPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._headerPrototype) {\n table._headerPrototype = { table }\n
|
|
1
|
+
{"version":3,"file":"constructHeader.js","names":[],"sources":["../../../src/core/headers/constructHeader.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header } from '../../types/Header'\nimport type { Column } from '../../types/Column'\nimport type { Header_CoreProperties } from './coreHeadersFeature.types'\n\n/**\n * Creates or retrieves the header prototype for a table.\n * The prototype is cached on the table and shared by all header instances.\n */\nfunction getHeaderPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._headerPrototype) {\n table._headerPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignHeaderPrototype?.(table._headerPrototype, table)\n }\n }\n return table._headerPrototype\n}\n\n/**\n * Constructs a header instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport function constructHeader<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n table: Table_Internal<TFeatures, TData>,\n column: Column<TFeatures, TData, TValue>,\n options: {\n id?: string\n isPlaceholder?: boolean\n placeholderId?: string\n index: number\n depth: number\n },\n): Header<TFeatures, TData, TValue> {\n // Create header with shared prototype for memory efficiency\n const headerPrototype = getHeaderPrototype(table)\n const header = Object.create(headerPrototype) as Header_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n header.colSpan = 0\n header.column = column\n header.depth = options.depth\n header.headerGroup = null\n header.id = options.id ?? column.id\n header.index = options.index\n header.isPlaceholder = !!options.isPlaceholder\n header.placeholderId = options.placeholderId\n header.rowSpan = 0\n header.subHeaders = []\n\n return header as Header<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;AAWA,SAAS,mBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,kBAAkB;EAC3B,MAAM,mBAAmB,EAAE,OAAO;EAClC,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;GACxC,0CAAS,IAAI,wGAAwB,MAAM,kBAAkB,MAAM;;;CAGvE,OAAO,MAAM;;;;;;;AAQf,SAAgB,gBAKd,OACA,QACA,SAOkC;CAElC,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,SAAS,OAAO,OAAO,gBAAgB;CAO7C,OAAO,UAAU;CACjB,OAAO,SAAS;CAChB,OAAO,QAAQ,QAAQ;CACvB,OAAO,cAAc;CACrB,OAAO,KAAK,QAAQ,MAAM,OAAO;CACjC,OAAO,QAAQ,QAAQ;CACvB,OAAO,gBAAgB,CAAC,CAAC,QAAQ;CACjC,OAAO,gBAAgB,QAAQ;CAC/B,OAAO,UAAU;CACjB,OAAO,aAAa,EAAE;CAEtB,OAAO"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_utils = require('../../utils.cjs');
|
|
2
|
-
const require_columnPinningFeature_utils = require('../../features/column-pinning/columnPinningFeature.utils.cjs');
|
|
3
2
|
const require_coreHeadersFeature_utils = require('./coreHeadersFeature.utils.cjs');
|
|
4
3
|
|
|
5
4
|
//#region src/core/headers/coreHeadersFeature.ts
|
|
@@ -48,11 +47,7 @@ function constructCoreHeadersFeature() {
|
|
|
48
47
|
},
|
|
49
48
|
table_getLeafHeaders: {
|
|
50
49
|
fn: () => require_coreHeadersFeature_utils.table_getLeafHeaders(table),
|
|
51
|
-
memoDeps: () => [
|
|
52
|
-
require_utils.callMemoOrStaticFn(table, "getLeftHeaderGroups", require_columnPinningFeature_utils.table_getLeftHeaderGroups),
|
|
53
|
-
require_utils.callMemoOrStaticFn(table, "getCenterHeaderGroups", require_columnPinningFeature_utils.table_getCenterHeaderGroups),
|
|
54
|
-
require_utils.callMemoOrStaticFn(table, "getRightHeaderGroups", require_columnPinningFeature_utils.table_getRightHeaderGroups)
|
|
55
|
-
]
|
|
50
|
+
memoDeps: () => [table.getHeaderGroups()]
|
|
56
51
|
}
|
|
57
52
|
});
|
|
58
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreHeadersFeature.cjs","names":["header_getLeafHeaders","header_getContext","table_getHeaderGroups","table_getFooterGroups","table_getFlatHeaders","table_getLeafHeaders"
|
|
1
|
+
{"version":3,"file":"coreHeadersFeature.cjs","names":["header_getLeafHeaders","header_getContext","table_getHeaderGroups","table_getFooterGroups","table_getFlatHeaders","table_getLeafHeaders"],"sources":["../../../src/core/headers/coreHeadersFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n header_getContext,\n header_getLeafHeaders,\n table_getFlatHeaders,\n table_getFooterGroups,\n table_getHeaderGroups,\n table_getLeafHeaders,\n} from './coreHeadersFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\n// import type { Header_Header, Table_Headers } from './coreHeadersFeature.types'\n\nexport interface CoreHeadersFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // Header: Header_Header<TFeatures, TData>\n // Table: Table_Headers<TFeatures, TData>\n}\n\n/**\n * Creates the stock core headers feature.\n *\n * The returned feature registers its state defaults, option defaults, and instance APIs so it can be included in a `tableFeatures({ ... })` call.\n */\nexport function constructCoreHeadersFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<CoreHeadersFeatureConstructors<TFeatures, TData>> {\n return {\n assignHeaderPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreHeadersFeature', prototype, table, {\n header_getLeafHeaders: {\n fn: (header) => header_getLeafHeaders(header),\n memoDeps: (header) => [header.column.table.options.columns],\n },\n header_getContext: {\n fn: (header) => header_getContext(header),\n memoDeps: (header) => [header.column.table.options.columns],\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('coreHeadersFeature', table, {\n table_getHeaderGroups: {\n fn: () => table_getHeaderGroups(table),\n memoDeps: () => [\n table.options.columns,\n table.atoms.columnOrder?.get(),\n table.atoms.grouping?.get(),\n table.atoms.columnPinning?.get(),\n table.atoms.columnVisibility?.get(),\n table.options.groupedColumnMode,\n ],\n },\n table_getFooterGroups: {\n fn: () => table_getFooterGroups(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n table_getFlatHeaders: {\n fn: () => table_getFlatHeaders(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n table_getLeafHeaders: {\n fn: () => table_getLeafHeaders(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n })\n },\n }\n}\n\n/**\n * The Core Headers feature provides the core header functionality.\n */\nexport const coreHeadersFeature = constructCoreHeadersFeature()\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,8BAGoD;CAClE,OAAO;EACL,wBAAwB,WAAW,UAAU;GAC3C,kCAAoB,sBAAsB,WAAW,OAAO;IAC1D,uBAAuB;KACrB,KAAK,WAAWA,uDAAsB,OAAO;KAC7C,WAAW,WAAW,CAAC,OAAO,OAAO,MAAM,QAAQ,QAAQ;KAC5D;IACD,mBAAmB;KACjB,KAAK,WAAWC,mDAAkB,OAAO;KACzC,WAAW,WAAW,CAAC,OAAO,OAAO,MAAM,QAAQ,QAAQ;KAC5D;IACF,CAAC;;EAGJ,qBAAqB,UAAU;GAC7B,8BAAgB,sBAAsB,OAAO;IAC3C,uBAAuB;KACrB,UAAUC,uDAAsB,MAAM;KACtC,gBAAgB;;;OACd,MAAM,QAAQ;gCACd,MAAM,MAAM,2FAAa,KAAK;gCAC9B,MAAM,MAAM,wFAAU,KAAK;gCAC3B,MAAM,MAAM,6FAAe,KAAK;gCAChC,MAAM,MAAM,gGAAkB,KAAK;OACnC,MAAM,QAAQ;OACf;;KACF;IACD,uBAAuB;KACrB,UAAUC,uDAAsB,MAAM;KACtC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACD,sBAAsB;KACpB,UAAUC,sDAAqB,MAAM;KACrC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACD,sBAAsB;KACpB,UAAUC,sDAAqB,MAAM;KACrC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,qBAAqB,6BAA6B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { assignPrototypeAPIs, assignTableAPIs
|
|
2
|
-
import { table_getCenterHeaderGroups, table_getLeftHeaderGroups, table_getRightHeaderGroups } from "../../features/column-pinning/columnPinningFeature.utils.js";
|
|
1
|
+
import { assignPrototypeAPIs, assignTableAPIs } from "../../utils.js";
|
|
3
2
|
import { header_getContext, header_getLeafHeaders, table_getFlatHeaders, table_getFooterGroups, table_getHeaderGroups, table_getLeafHeaders } from "./coreHeadersFeature.utils.js";
|
|
4
3
|
|
|
5
4
|
//#region src/core/headers/coreHeadersFeature.ts
|
|
@@ -48,11 +47,7 @@ function constructCoreHeadersFeature() {
|
|
|
48
47
|
},
|
|
49
48
|
table_getLeafHeaders: {
|
|
50
49
|
fn: () => table_getLeafHeaders(table),
|
|
51
|
-
memoDeps: () => [
|
|
52
|
-
callMemoOrStaticFn(table, "getLeftHeaderGroups", table_getLeftHeaderGroups),
|
|
53
|
-
callMemoOrStaticFn(table, "getCenterHeaderGroups", table_getCenterHeaderGroups),
|
|
54
|
-
callMemoOrStaticFn(table, "getRightHeaderGroups", table_getRightHeaderGroups)
|
|
55
|
-
]
|
|
50
|
+
memoDeps: () => [table.getHeaderGroups()]
|
|
56
51
|
}
|
|
57
52
|
});
|
|
58
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreHeadersFeature.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"coreHeadersFeature.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n header_getContext,\n header_getLeafHeaders,\n table_getFlatHeaders,\n table_getFooterGroups,\n table_getHeaderGroups,\n table_getLeafHeaders,\n} from './coreHeadersFeature.utils'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeature, TableFeatures } from '../../types/TableFeatures'\n// import type { Header_Header, Table_Headers } from './coreHeadersFeature.types'\n\nexport interface CoreHeadersFeatureConstructors<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n // Header: Header_Header<TFeatures, TData>\n // Table: Table_Headers<TFeatures, TData>\n}\n\n/**\n * Creates the stock core headers feature.\n *\n * The returned feature registers its state defaults, option defaults, and instance APIs so it can be included in a `tableFeatures({ ... })` call.\n */\nexport function constructCoreHeadersFeature<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(): TableFeature<CoreHeadersFeatureConstructors<TFeatures, TData>> {\n return {\n assignHeaderPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreHeadersFeature', prototype, table, {\n header_getLeafHeaders: {\n fn: (header) => header_getLeafHeaders(header),\n memoDeps: (header) => [header.column.table.options.columns],\n },\n header_getContext: {\n fn: (header) => header_getContext(header),\n memoDeps: (header) => [header.column.table.options.columns],\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('coreHeadersFeature', table, {\n table_getHeaderGroups: {\n fn: () => table_getHeaderGroups(table),\n memoDeps: () => [\n table.options.columns,\n table.atoms.columnOrder?.get(),\n table.atoms.grouping?.get(),\n table.atoms.columnPinning?.get(),\n table.atoms.columnVisibility?.get(),\n table.options.groupedColumnMode,\n ],\n },\n table_getFooterGroups: {\n fn: () => table_getFooterGroups(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n table_getFlatHeaders: {\n fn: () => table_getFlatHeaders(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n table_getLeafHeaders: {\n fn: () => table_getLeafHeaders(table),\n memoDeps: () => [table.getHeaderGroups()],\n },\n })\n },\n }\n}\n\n/**\n * The Core Headers feature provides the core header functionality.\n */\nexport const coreHeadersFeature = constructCoreHeadersFeature()\n"],"mappings":";;;;;;;;;AA0BA,SAAgB,8BAGoD;CAClE,OAAO;EACL,wBAAwB,WAAW,UAAU;GAC3C,oBAAoB,sBAAsB,WAAW,OAAO;IAC1D,uBAAuB;KACrB,KAAK,WAAW,sBAAsB,OAAO;KAC7C,WAAW,WAAW,CAAC,OAAO,OAAO,MAAM,QAAQ,QAAQ;KAC5D;IACD,mBAAmB;KACjB,KAAK,WAAW,kBAAkB,OAAO;KACzC,WAAW,WAAW,CAAC,OAAO,OAAO,MAAM,QAAQ,QAAQ;KAC5D;IACF,CAAC;;EAGJ,qBAAqB,UAAU;GAC7B,gBAAgB,sBAAsB,OAAO;IAC3C,uBAAuB;KACrB,UAAU,sBAAsB,MAAM;KACtC,gBAAgB;;;OACd,MAAM,QAAQ;gCACd,MAAM,MAAM,2FAAa,KAAK;gCAC9B,MAAM,MAAM,wFAAU,KAAK;gCAC3B,MAAM,MAAM,6FAAe,KAAK;gCAChC,MAAM,MAAM,gGAAkB,KAAK;OACnC,MAAM,QAAQ;OACf;;KACF;IACD,uBAAuB;KACrB,UAAU,sBAAsB,MAAM;KACtC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACD,sBAAsB;KACpB,UAAU,qBAAqB,MAAM;KACrC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACD,sBAAsB;KACpB,UAAU,qBAAqB,MAAM;KACrC,gBAAgB,CAAC,MAAM,iBAAiB,CAAC;KAC1C;IACF,CAAC;;EAEL;;;;;AAMH,MAAa,qBAAqB,6BAA6B"}
|
|
@@ -55,15 +55,16 @@ function table_getHeaderGroups(table) {
|
|
|
55
55
|
const { left, right } = ((_table$atoms$columnPi = table.atoms.columnPinning) === null || _table$atoms$columnPi === void 0 ? void 0 : _table$atoms$columnPi.get()) ?? require_columnPinningFeature_utils.getDefaultColumnPinningState();
|
|
56
56
|
const allColumns = table.getAllColumns();
|
|
57
57
|
const leafColumns = require_utils.callMemoOrStaticFn(table, "getVisibleLeafColumns", require_columnVisibilityFeature_utils.table_getVisibleLeafColumns);
|
|
58
|
+
if (!left.length && !right.length) return require_buildHeaderGroups.buildHeaderGroups(allColumns, leafColumns, table);
|
|
58
59
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
59
60
|
const leftColumns = [];
|
|
60
|
-
for (
|
|
61
|
-
const column = leafColumnsById[
|
|
61
|
+
for (let i = 0; i < left.length; i++) {
|
|
62
|
+
const column = leafColumnsById[left[i]];
|
|
62
63
|
if (column && require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) leftColumns.push(column);
|
|
63
64
|
}
|
|
64
65
|
const rightColumns = [];
|
|
65
|
-
for (
|
|
66
|
-
const column = leafColumnsById[
|
|
66
|
+
for (let i = 0; i < right.length; i++) {
|
|
67
|
+
const column = leafColumnsById[right[i]];
|
|
67
68
|
if (column && require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) rightColumns.push(column);
|
|
68
69
|
}
|
|
69
70
|
const centerColumns = leafColumns.filter((column) => !left.includes(column.id) && !right.includes(column.id));
|
|
@@ -97,9 +98,13 @@ function table_getFooterGroups(table) {
|
|
|
97
98
|
* ```
|
|
98
99
|
*/
|
|
99
100
|
function table_getFlatHeaders(table) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const headerGroups = table.getHeaderGroups();
|
|
102
|
+
const result = [];
|
|
103
|
+
for (let i = 0; i < headerGroups.length; i++) {
|
|
104
|
+
const headers = headerGroups[i].headers;
|
|
105
|
+
for (let j = 0; j < headers.length; j++) result.push(headers[j]);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
103
108
|
}
|
|
104
109
|
/**
|
|
105
110
|
* Returns leaf headers for the table.
|
|
@@ -112,17 +117,14 @@ function table_getFlatHeaders(table) {
|
|
|
112
117
|
* ```
|
|
113
118
|
*/
|
|
114
119
|
function table_getLeafHeaders(table) {
|
|
115
|
-
var
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
].map((header) => {
|
|
124
|
-
return header.getLeafHeaders();
|
|
125
|
-
}).flat();
|
|
120
|
+
var _table$getHeaderGroup;
|
|
121
|
+
const topHeaders = ((_table$getHeaderGroup = table.getHeaderGroups()[0]) === null || _table$getHeaderGroup === void 0 ? void 0 : _table$getHeaderGroup.headers) ?? [];
|
|
122
|
+
const result = [];
|
|
123
|
+
for (let i = 0; i < topHeaders.length; i++) {
|
|
124
|
+
const leafHeaders = topHeaders[i].getLeafHeaders();
|
|
125
|
+
for (let j = 0; j < leafHeaders.length; j++) result.push(leafHeaders[j]);
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreHeadersFeature.utils.cjs","names":["getDefaultColumnPinningState","callMemoOrStaticFn","table_getVisibleLeafColumns","
|
|
1
|
+
{"version":3,"file":"coreHeadersFeature.utils.cjs","names":["getDefaultColumnPinningState","callMemoOrStaticFn","table_getVisibleLeafColumns","buildHeaderGroups","column_getIsVisible"],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns leaf headers for a header.\n *\n * This is the static implementation behind the matching header instance API and can account for nested header groups.\n *\n * @example\n * ```ts\n * const value = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Returns context for a header.\n *\n * This is the static implementation behind the matching header instance API and can account for nested header groups.\n *\n * @example\n * ```ts\n * const value = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Returns 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_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\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 allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n ) as Array<Column<TFeatures, TData, unknown>>\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\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 leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\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 rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Returns 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_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns 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_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[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 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_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push(leafHeaders[j]!)\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,SAAgB,sBAId,QAA0C;CAC1C,MAAM,cAAuD,EAAE;CAE/D,MAAM,iBAAiB,MAA+C;EACpE,IAAI,EAAE,WAAW,QACf,EAAE,WAAW,IAAI,cAAc;EAEjC,YAAY,KAAK,EAAsC;;CAGzD,cAAc,OAAO;CAErB,OAAO;;;;;;;;;;;;AAaT,SAAgB,kBAId,QAA0C;CAC1C,OAAO;EACL,QAAQ,OAAO;EACf;EACA,OAAO,OAAO,OAAO;EACtB;;;;;;;;;;;;AAaH,SAAgB,sBAGd,OAAyC;;CACzC,MAAM,EAAE,MAAM,oCACZ,MAAM,MAAM,6FAAe,KAAK,KAAIA,iEAA8B;CACpE,MAAM,aAAa,MAAM,eAAe;CACxC,MAAM,cAAcC,iCAClB,OACA,yBACAC,kEACD;CAGD,IAAI,CAAC,KAAK,UAAU,CAAC,MAAM,QACzB,OAAOC,4CAAkB,YAAY,aAAa,MAAM;CAG1D,MAAM,kBAAkB,MAAM,uBAAuB;CAErD,MAAM,cAAkC,EAAE;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,SAAS,gBAAgB,KAAK;EACpC,IACE,UACAF,iCAAmB,QAAQ,gBAAgBG,0DAAoB,EAE/D,YAAY,KAAK,OAAO;;CAI5B,MAAM,eAAmC,EAAE;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,SAAS,gBAAgB,MAAM;EACrC,IACE,UACAH,iCAAmB,QAAQ,gBAAgBG,0DAAoB,EAE/D,aAAa,KAAK,OAAO;;CAI7B,MAAM,gBAAgB,YAAY,QAC/B,WAAW,CAAC,KAAK,SAAS,OAAO,GAAG,IAAI,CAAC,MAAM,SAAS,OAAO,GAAG,CACpE;CAED,OAAOD,4CACL,YACA;EAAC,GAAG;EAAa,GAAG;EAAe,GAAG;EAAa,EACnD,MACD;;;;;;;;;;;;AAaH,SAAgB,sBAGd,OAAyC;CAEzC,OAAO,CAAC,GADa,MAAM,iBACJ,CAAC,CAAC,SAAS;;;;;;;;;;;;AAapC,SAAgB,qBAGd,OAAyC;CACzC,MAAM,eAAe,MAAM,iBAAiB;CAC5C,MAAM,SAAmD,EAAE;CAC3D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,GAAI;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,GAAI;;CAG5B,OAAO;;;;;;;;;;;;AAaT,SAAgB,qBAGd,OAAyC;;CACzC,MAAM,uCAAa,MAAM,iBAAiB,CAAC,kFAAI,YAAW,EAAE;CAC5D,MAAM,SAAmD,EAAE;CAC3D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,GAAI,gBAAgB;EACnD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,GAAI;;CAGhC,OAAO"}
|
|
@@ -74,7 +74,7 @@ declare function table_getFlatHeaders<TFeatures extends TableFeatures, TData ext
|
|
|
74
74
|
* const value = table_getLeafHeaders(table)
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
-
declare function table_getLeafHeaders<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>):
|
|
77
|
+
declare function table_getLeafHeaders<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): Header<TFeatures, TData, unknown>[];
|
|
78
78
|
//#endregion
|
|
79
79
|
export { header_getContext, header_getLeafHeaders, table_getFlatHeaders, table_getFooterGroups, table_getHeaderGroups, table_getLeafHeaders };
|
|
80
80
|
//# sourceMappingURL=coreHeadersFeature.utils.d.cts.map
|
|
@@ -74,7 +74,7 @@ declare function table_getFlatHeaders<TFeatures extends TableFeatures, TData ext
|
|
|
74
74
|
* const value = table_getLeafHeaders(table)
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
-
declare function table_getLeafHeaders<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>):
|
|
77
|
+
declare function table_getLeafHeaders<TFeatures extends TableFeatures, TData extends RowData>(table: Table_Internal<TFeatures, TData>): Header<TFeatures, TData, unknown>[];
|
|
78
78
|
//#endregion
|
|
79
79
|
export { header_getContext, header_getLeafHeaders, table_getFlatHeaders, table_getFooterGroups, table_getHeaderGroups, table_getLeafHeaders };
|
|
80
80
|
//# sourceMappingURL=coreHeadersFeature.utils.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callMemoOrStaticFn } from "../../utils.js";
|
|
2
2
|
import { column_getIsVisible, table_getVisibleLeafColumns } from "../../features/column-visibility/columnVisibilityFeature.utils.js";
|
|
3
3
|
import { buildHeaderGroups } from "./buildHeaderGroups.js";
|
|
4
|
-
import { getDefaultColumnPinningState
|
|
4
|
+
import { getDefaultColumnPinningState } from "../../features/column-pinning/columnPinningFeature.utils.js";
|
|
5
5
|
|
|
6
6
|
//#region src/core/headers/coreHeadersFeature.utils.ts
|
|
7
7
|
/**
|
|
@@ -55,15 +55,16 @@ function table_getHeaderGroups(table) {
|
|
|
55
55
|
const { left, right } = ((_table$atoms$columnPi = table.atoms.columnPinning) === null || _table$atoms$columnPi === void 0 ? void 0 : _table$atoms$columnPi.get()) ?? getDefaultColumnPinningState();
|
|
56
56
|
const allColumns = table.getAllColumns();
|
|
57
57
|
const leafColumns = callMemoOrStaticFn(table, "getVisibleLeafColumns", table_getVisibleLeafColumns);
|
|
58
|
+
if (!left.length && !right.length) return buildHeaderGroups(allColumns, leafColumns, table);
|
|
58
59
|
const leafColumnsById = table.getAllLeafColumnsById();
|
|
59
60
|
const leftColumns = [];
|
|
60
|
-
for (
|
|
61
|
-
const column = leafColumnsById[
|
|
61
|
+
for (let i = 0; i < left.length; i++) {
|
|
62
|
+
const column = leafColumnsById[left[i]];
|
|
62
63
|
if (column && callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible)) leftColumns.push(column);
|
|
63
64
|
}
|
|
64
65
|
const rightColumns = [];
|
|
65
|
-
for (
|
|
66
|
-
const column = leafColumnsById[
|
|
66
|
+
for (let i = 0; i < right.length; i++) {
|
|
67
|
+
const column = leafColumnsById[right[i]];
|
|
67
68
|
if (column && callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible)) rightColumns.push(column);
|
|
68
69
|
}
|
|
69
70
|
const centerColumns = leafColumns.filter((column) => !left.includes(column.id) && !right.includes(column.id));
|
|
@@ -97,9 +98,13 @@ function table_getFooterGroups(table) {
|
|
|
97
98
|
* ```
|
|
98
99
|
*/
|
|
99
100
|
function table_getFlatHeaders(table) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const headerGroups = table.getHeaderGroups();
|
|
102
|
+
const result = [];
|
|
103
|
+
for (let i = 0; i < headerGroups.length; i++) {
|
|
104
|
+
const headers = headerGroups[i].headers;
|
|
105
|
+
for (let j = 0; j < headers.length; j++) result.push(headers[j]);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
103
108
|
}
|
|
104
109
|
/**
|
|
105
110
|
* Returns leaf headers for the table.
|
|
@@ -112,17 +117,14 @@ function table_getFlatHeaders(table) {
|
|
|
112
117
|
* ```
|
|
113
118
|
*/
|
|
114
119
|
function table_getLeafHeaders(table) {
|
|
115
|
-
var
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
].map((header) => {
|
|
124
|
-
return header.getLeafHeaders();
|
|
125
|
-
}).flat();
|
|
120
|
+
var _table$getHeaderGroup;
|
|
121
|
+
const topHeaders = ((_table$getHeaderGroup = table.getHeaderGroups()[0]) === null || _table$getHeaderGroup === void 0 ? void 0 : _table$getHeaderGroup.headers) ?? [];
|
|
122
|
+
const result = [];
|
|
123
|
+
for (let i = 0; i < topHeaders.length; i++) {
|
|
124
|
+
const leafHeaders = topHeaders[i].getLeafHeaders();
|
|
125
|
+
for (let j = 0; j < leafHeaders.length; j++) result.push(leafHeaders[j]);
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreHeadersFeature.utils.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"coreHeadersFeature.utils.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns leaf headers for a header.\n *\n * This is the static implementation behind the matching header instance API and can account for nested header groups.\n *\n * @example\n * ```ts\n * const value = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Returns context for a header.\n *\n * This is the static implementation behind the matching header instance API and can account for nested header groups.\n *\n * @example\n * ```ts\n * const value = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Returns 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_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\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 allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n ) as Array<Column<TFeatures, TData, unknown>>\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\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 leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\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 rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Returns 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_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Returns 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_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[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 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_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push(leafHeaders[j]!)\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,SAAgB,sBAId,QAA0C;CAC1C,MAAM,cAAuD,EAAE;CAE/D,MAAM,iBAAiB,MAA+C;EACpE,IAAI,EAAE,WAAW,QACf,EAAE,WAAW,IAAI,cAAc;EAEjC,YAAY,KAAK,EAAsC;;CAGzD,cAAc,OAAO;CAErB,OAAO;;;;;;;;;;;;AAaT,SAAgB,kBAId,QAA0C;CAC1C,OAAO;EACL,QAAQ,OAAO;EACf;EACA,OAAO,OAAO,OAAO;EACtB;;;;;;;;;;;;AAaH,SAAgB,sBAGd,OAAyC;;CACzC,MAAM,EAAE,MAAM,oCACZ,MAAM,MAAM,6FAAe,KAAK,KAAI,8BAA8B;CACpE,MAAM,aAAa,MAAM,eAAe;CACxC,MAAM,cAAc,mBAClB,OACA,yBACA,4BACD;CAGD,IAAI,CAAC,KAAK,UAAU,CAAC,MAAM,QACzB,OAAO,kBAAkB,YAAY,aAAa,MAAM;CAG1D,MAAM,kBAAkB,MAAM,uBAAuB;CAErD,MAAM,cAAkC,EAAE;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,SAAS,gBAAgB,KAAK;EACpC,IACE,UACA,mBAAmB,QAAQ,gBAAgB,oBAAoB,EAE/D,YAAY,KAAK,OAAO;;CAI5B,MAAM,eAAmC,EAAE;CAC3C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,SAAS,gBAAgB,MAAM;EACrC,IACE,UACA,mBAAmB,QAAQ,gBAAgB,oBAAoB,EAE/D,aAAa,KAAK,OAAO;;CAI7B,MAAM,gBAAgB,YAAY,QAC/B,WAAW,CAAC,KAAK,SAAS,OAAO,GAAG,IAAI,CAAC,MAAM,SAAS,OAAO,GAAG,CACpE;CAED,OAAO,kBACL,YACA;EAAC,GAAG;EAAa,GAAG;EAAe,GAAG;EAAa,EACnD,MACD;;;;;;;;;;;;AAaH,SAAgB,sBAGd,OAAyC;CAEzC,OAAO,CAAC,GADa,MAAM,iBACJ,CAAC,CAAC,SAAS;;;;;;;;;;;;AAapC,SAAgB,qBAGd,OAAyC;CACzC,MAAM,eAAe,MAAM,iBAAiB;CAC5C,MAAM,SAAmD,EAAE;CAC3D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,GAAI;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,GAAI;;CAG5B,OAAO;;;;;;;;;;;;AAaT,SAAgB,qBAGd,OAAyC;;CACzC,MAAM,uCAAa,MAAM,iBAAiB,CAAC,kFAAI,YAAW,EAAE;CAC5D,MAAM,SAAmD,EAAE;CAC3D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,GAAI,gBAAgB;EACnD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,GAAI;;CAGhC,OAAO"}
|
|
@@ -32,6 +32,10 @@ interface TableReactivityBindings {
|
|
|
32
32
|
* Batches reactive updates to avoid intermediate recomputation.
|
|
33
33
|
*/
|
|
34
34
|
batch: (fn: () => void) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Schedules a function to run. This is used to defer updates after the current call stack (render, etc.) has finished
|
|
37
|
+
*/
|
|
38
|
+
schedule: (fn: () => void) => void;
|
|
35
39
|
}
|
|
36
40
|
//#endregion
|
|
37
41
|
export { TableAtomOptions, TableReactivityBindings };
|
|
@@ -32,6 +32,10 @@ interface TableReactivityBindings {
|
|
|
32
32
|
* Batches reactive updates to avoid intermediate recomputation.
|
|
33
33
|
*/
|
|
34
34
|
batch: (fn: () => void) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Schedules a function to run. This is used to defer updates after the current call stack (render, etc.) has finished
|
|
37
|
+
*/
|
|
38
|
+
schedule: (fn: () => void) => void;
|
|
35
39
|
}
|
|
36
40
|
//#endregion
|
|
37
41
|
export { TableAtomOptions, TableReactivityBindings };
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
function getRowPrototype(table) {
|
|
8
8
|
if (!table._rowPrototype) {
|
|
9
9
|
table._rowPrototype = { table };
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const features = Object.values(table._features);
|
|
11
|
+
for (let i = 0; i < features.length; i++) {
|
|
12
|
+
var _assignRowPrototype, _ref;
|
|
13
|
+
(_assignRowPrototype = (_ref = features[i]).assignRowPrototype) === null || _assignRowPrototype === void 0 || _assignRowPrototype.call(_ref, table._rowPrototype, table);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
return table._rowPrototype;
|
|
@@ -30,9 +31,10 @@ const constructRow = (table, id, original, rowIndex, depth, subRows, parentId) =
|
|
|
30
31
|
row.original = original;
|
|
31
32
|
row.parentId = parentId;
|
|
32
33
|
row.subRows = subRows ?? [];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const features = Object.values(table._features);
|
|
35
|
+
for (let i = 0; i < features.length; i++) {
|
|
36
|
+
var _initRowInstanceData, _ref2;
|
|
37
|
+
(_initRowInstanceData = (_ref2 = features[i]).initRowInstanceData) === null || _initRowInstanceData === void 0 || _initRowInstanceData.call(_ref2, row);
|
|
36
38
|
}
|
|
37
39
|
return row;
|
|
38
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructRow.cjs","names":[],"sources":["../../../src/core/rows/constructRow.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Row_CoreProperties } from './coreRowsFeature.types'\n\n/**\n * Creates or retrieves the row prototype for a table.\n * The prototype is cached on the table and shared by all row instances.\n */\nfunction getRowPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._rowPrototype) {\n table._rowPrototype = { table }\n
|
|
1
|
+
{"version":3,"file":"constructRow.cjs","names":[],"sources":["../../../src/core/rows/constructRow.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Row_CoreProperties } from './coreRowsFeature.types'\n\n/**\n * Creates or retrieves the row prototype for a table.\n * The prototype is cached on the table and shared by all row instances.\n */\nfunction getRowPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._rowPrototype) {\n table._rowPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignRowPrototype?.(table._rowPrototype, table)\n }\n }\n return table._rowPrototype\n}\n\n/**\n * Constructs a row instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport const constructRow = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Array<Row<TFeatures, TData>>,\n parentId?: string,\n): Row<TFeatures, TData> => {\n // Create row with shared prototype for memory efficiency\n const rowPrototype = getRowPrototype(table)\n const row = Object.create(rowPrototype) as Row_CoreProperties<\n TFeatures,\n TData\n >\n\n // Only assign instance-specific properties\n row._uniqueValuesCache = {}\n row._valuesCache = {}\n row.depth = depth\n row.id = id\n row.index = rowIndex\n row.original = original\n row.parentId = parentId\n row.subRows = subRows ?? []\n\n // Initialize instance-specific data (e.g., caches) for features that need it\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.initRowInstanceData?.(row)\n }\n\n return row as Row<TFeatures, TData>\n}\n"],"mappings":";;;;;;AAUA,SAAS,gBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,eAAe;EACxB,MAAM,gBAAgB,EAAE,OAAO;EAC/B,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;GACxC,wCAAS,IAAI,iGAAqB,MAAM,eAAe,MAAM;;;CAGjE,OAAO,MAAM;;;;;;;AAQf,MAAa,gBAIX,OACA,IACA,UACA,UACA,OACA,SACA,aAC0B;CAE1B,MAAM,eAAe,gBAAgB,MAAM;CAC3C,MAAM,MAAM,OAAO,OAAO,aAAa;CAMvC,IAAI,qBAAqB,EAAE;CAC3B,IAAI,eAAe,EAAE;CACrB,IAAI,QAAQ;CACZ,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,IAAI,WAAW;CACf,IAAI,WAAW;CACf,IAAI,UAAU,WAAW,EAAE;CAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;CAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;EACxC,0CAAS,IAAI,qGAAsB,IAAI;;CAGzC,OAAO"}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
function getRowPrototype(table) {
|
|
7
7
|
if (!table._rowPrototype) {
|
|
8
8
|
table._rowPrototype = { table };
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const features = Object.values(table._features);
|
|
10
|
+
for (let i = 0; i < features.length; i++) {
|
|
11
|
+
var _assignRowPrototype, _ref;
|
|
12
|
+
(_assignRowPrototype = (_ref = features[i]).assignRowPrototype) === null || _assignRowPrototype === void 0 || _assignRowPrototype.call(_ref, table._rowPrototype, table);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
return table._rowPrototype;
|
|
@@ -29,9 +30,10 @@ const constructRow = (table, id, original, rowIndex, depth, subRows, parentId) =
|
|
|
29
30
|
row.original = original;
|
|
30
31
|
row.parentId = parentId;
|
|
31
32
|
row.subRows = subRows ?? [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const features = Object.values(table._features);
|
|
34
|
+
for (let i = 0; i < features.length; i++) {
|
|
35
|
+
var _initRowInstanceData, _ref2;
|
|
36
|
+
(_initRowInstanceData = (_ref2 = features[i]).initRowInstanceData) === null || _initRowInstanceData === void 0 || _initRowInstanceData.call(_ref2, row);
|
|
35
37
|
}
|
|
36
38
|
return row;
|
|
37
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructRow.js","names":[],"sources":["../../../src/core/rows/constructRow.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Row_CoreProperties } from './coreRowsFeature.types'\n\n/**\n * Creates or retrieves the row prototype for a table.\n * The prototype is cached on the table and shared by all row instances.\n */\nfunction getRowPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._rowPrototype) {\n table._rowPrototype = { table }\n
|
|
1
|
+
{"version":3,"file":"constructRow.js","names":[],"sources":["../../../src/core/rows/constructRow.ts"],"sourcesContent":["import type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Row_CoreProperties } from './coreRowsFeature.types'\n\n/**\n * Creates or retrieves the row prototype for a table.\n * The prototype is cached on the table and shared by all row instances.\n */\nfunction getRowPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._rowPrototype) {\n table._rowPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignRowPrototype?.(table._rowPrototype, table)\n }\n }\n return table._rowPrototype\n}\n\n/**\n * Constructs a row instance from normalized table internals.\n *\n * This wires core properties, feature prototype APIs, and instance data used by table rendering and row-model operations.\n */\nexport const constructRow = <\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Array<Row<TFeatures, TData>>,\n parentId?: string,\n): Row<TFeatures, TData> => {\n // Create row with shared prototype for memory efficiency\n const rowPrototype = getRowPrototype(table)\n const row = Object.create(rowPrototype) as Row_CoreProperties<\n TFeatures,\n TData\n >\n\n // Only assign instance-specific properties\n row._uniqueValuesCache = {}\n row._valuesCache = {}\n row.depth = depth\n row.id = id\n row.index = rowIndex\n row.original = original\n row.parentId = parentId\n row.subRows = subRows ?? []\n\n // Initialize instance-specific data (e.g., caches) for features that need it\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.initRowInstanceData?.(row)\n }\n\n return row as Row<TFeatures, TData>\n}\n"],"mappings":";;;;;AAUA,SAAS,gBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,eAAe;EACxB,MAAM,gBAAgB,EAAE,OAAO;EAC/B,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;GACxC,wCAAS,IAAI,iGAAqB,MAAM,eAAe,MAAM;;;CAGjE,OAAO,MAAM;;;;;;;AAQf,MAAa,gBAIX,OACA,IACA,UACA,UACA,OACA,SACA,aAC0B;CAE1B,MAAM,eAAe,gBAAgB,MAAM;CAC3C,MAAM,MAAM,OAAO,OAAO,aAAa;CAMvC,IAAI,qBAAqB,EAAE;CAC3B,IAAI,eAAe,EAAE;CACrB,IAAI,QAAQ;CACZ,IAAI,KAAK;CACT,IAAI,QAAQ;CACZ,IAAI,WAAW;CACf,IAAI,WAAW;CACf,IAAI,UAAU,WAAW,EAAE;CAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;CAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;EACxC,0CAAS,IAAI,qGAAsB,IAAI;;CAGzC,OAAO"}
|
|
@@ -112,9 +112,10 @@ function row_getParentRows(row) {
|
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
114
114
|
function row_getAllCells(row) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const columns = row.table.getAllLeafColumns();
|
|
116
|
+
const cells = new Array(columns.length);
|
|
117
|
+
for (let i = 0; i < columns.length; i++) cells[i] = require_constructCell.constructCell(columns[i], row, row.table);
|
|
118
|
+
return cells;
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
120
121
|
* Returns all cells by column id for a row.
|
|
@@ -128,7 +129,11 @@ function row_getAllCells(row) {
|
|
|
128
129
|
*/
|
|
129
130
|
function row_getAllCellsByColumnId(row) {
|
|
130
131
|
const result = {};
|
|
131
|
-
|
|
132
|
+
const cells = row.getAllCells();
|
|
133
|
+
for (let i = 0; i < cells.length; i++) {
|
|
134
|
+
const cell = cells[i];
|
|
135
|
+
result[cell.column.id] = cell;
|
|
136
|
+
}
|
|
132
137
|
return result;
|
|
133
138
|
}
|
|
134
139
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreRowsFeature.utils.cjs","names":["flattenBy","constructCell"],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\n\n/**\n * Returns value 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_getValue(row)\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Returns unique values 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_getUniqueValues(row)\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row)\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Returns leaf rows 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_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Returns parent row 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_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Returns parent rows 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_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Returns all 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_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n
|
|
1
|
+
{"version":3,"file":"coreRowsFeature.utils.cjs","names":["flattenBy","constructCell"],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\n\n/**\n * Returns value 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_getValue(row)\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Returns unique values 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_getUniqueValues(row)\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row)\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Returns leaf rows 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_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Returns parent row 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_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Returns parent rows 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_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Returns all 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_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const columns = row.table.getAllLeafColumns()\n const cells: Array<Cell<TFeatures, TData, unknown>> = new Array(\n columns.length,\n )\n for (let i = 0; i < columns.length; i++) {\n cells[i] = constructCell(columns[i]!, row, row.table)\n }\n return cells\n}\n\n/**\n * Returns all cells by column id 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_getAllCellsByColumnId(row)\n * ```\n */\nexport function row_getAllCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const result: Record<string, Cell<TFeatures, TData, unknown>> = {}\n const cells = row.getAllCells()\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!\n result[cell.column.id] = cell\n }\n return result\n}\n\n/**\n * Returns row id 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_getRowId(table)\n * ```\n */\nexport function table_getRowId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n originalRow: TData,\n table: Table_Internal<TFeatures, TData>,\n index: number,\n parent?: Row<TFeatures, TData>,\n) {\n return (\n table.options.getRowId?.(originalRow, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`\n )\n}\n\n/**\n * Returns row 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_getRow(table)\n * ```\n */\nexport function table_getRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n rowId: string,\n searchAll?: boolean,\n): Row<TFeatures, TData> {\n // TODO - simplify this across different row models\n let row = (searchAll ? table.getPrePaginatedRowModel() : table.getRowModel())\n .rowsById[rowId]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[rowId]\n if (!row) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(`getRow could not find row with ID: ${rowId}`)\n }\n throw new Error()\n }\n }\n\n return row\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,aAGd,KAA4B,UAAkB;CAC9C,IAAI,IAAI,aAAa,eAAe,SAAS,EAC3C,OAAO,IAAI,aAAa;CAG1B,MAAM,SAAS,IAAI,MAAM,UAAU,SAAS;CAE5C,IAAI,kDAAC,OAAQ,aACX;CAGF,IAAI,aAAa,YAAY,OAAO,WAAW,IAAI,UAAU,IAAI,MAAM;CAEvE,OAAO,IAAI,aAAa;;;;;;;;;;;;AAa1B,SAAgB,oBAGd,KAA4B,UAAkB;CAC9C,IAAI,IAAI,mBAAmB,eAAe,SAAS,EACjD,OAAO,IAAI,mBAAmB;CAGhC,MAAM,SAAS,IAAI,MAAM,UAAU,SAAS;CAE5C,IAAI,kDAAC,OAAQ,aACX;CAGF,IAAI,CAAC,OAAO,UAAU,iBAAiB;EACrC,IAAI,mBAAmB,YAAY,CAAC,IAAI,SAAS,SAAS,CAAC;EAC3D,OAAO,IAAI,mBAAmB;;CAGhC,IAAI,mBAAmB,YAAY,OAAO,UAAU,gBAClD,IAAI,UACJ,IAAI,MACL;CAED,OAAO,IAAI,mBAAmB;;;;;;;;;;;;;AAchC,SAAgB,gBAGd,KAA4B,UAAkB;CAC9C,OAAO,IAAI,SAAS,SAAS,IAAI,IAAI,MAAM,QAAQ;;;;;;;;;;;;AAarD,SAAgB,gBAGd,KAA0D;CAC1D,OAAOA,wBAAU,IAAI,UAAU,MAAM,EAAE,QAAQ;;;;;;;;;;;;AAajD,SAAgB,iBAGd,KAA4B;CAC5B,OAAO,IAAI,WAAW,IAAI,MAAM,OAAO,IAAI,UAAU,KAAK,GAAG;;;;;;;;;;;;AAa/D,SAAgB,kBAGd,KAA4B;CAC5B,MAAM,aAA2C,EAAE;CACnD,IAAI,aAAa;CAEjB,OAAO,MAAM;EACX,MAAM,YAAY,WAAW,cAAc;EAC3C,IAAI,CAAC,WAAW;EAChB,WAAW,KAAK,UAAU;EAC1B,aAAa;;CAEf,OAAO,WAAW,SAAS;;;;;;;;;;;;AAa7B,SAAgB,gBAGd,KAAoE;CACpE,MAAM,UAAU,IAAI,MAAM,mBAAmB;CAC7C,MAAM,QAAgD,IAAI,MACxD,QAAQ,OACT;CACD,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,MAAM,KAAKC,oCAAc,QAAQ,IAAK,KAAK,IAAI,MAAM;CAEvD,OAAO;;;;;;;;;;;;AAaT,SAAgB,0BAGd,KAA4B;CAC5B,MAAM,SAA0D,EAAE;CAClE,MAAM,QAAQ,IAAI,aAAa;CAC/B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EACnB,OAAO,KAAK,OAAO,MAAM;;CAE3B,OAAO;;;;;;;;;;;;AAaT,SAAgB,eAId,aACA,OACA,OACA,QACA;;CACA,mDACE,MAAM,SAAQ,6GAAW,aAAa,OAAO,OAAO,KACpD,GAAG,SAAS,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,GAAG;;;;;;;;;;;;AAc/C,SAAgB,aAId,OACA,OACA,WACuB;CAEvB,IAAI,OAAO,YAAY,MAAM,yBAAyB,GAAG,MAAM,aAAa,EACzE,SAAS;CAEZ,IAAI,CAAC,KAAK;EACR,MAAM,MAAM,iBAAiB,CAAC,SAAS;EACvC,IAAI,CAAC,KAAK;GACR,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MAAM,sCAAsC,QAAQ;GAEhE,MAAM,IAAI,OAAO;;;CAIrB,OAAO"}
|
|
@@ -112,9 +112,10 @@ function row_getParentRows(row) {
|
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
114
114
|
function row_getAllCells(row) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const columns = row.table.getAllLeafColumns();
|
|
116
|
+
const cells = new Array(columns.length);
|
|
117
|
+
for (let i = 0; i < columns.length; i++) cells[i] = constructCell(columns[i], row, row.table);
|
|
118
|
+
return cells;
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
120
121
|
* Returns all cells by column id for a row.
|
|
@@ -128,7 +129,11 @@ function row_getAllCells(row) {
|
|
|
128
129
|
*/
|
|
129
130
|
function row_getAllCellsByColumnId(row) {
|
|
130
131
|
const result = {};
|
|
131
|
-
|
|
132
|
+
const cells = row.getAllCells();
|
|
133
|
+
for (let i = 0; i < cells.length; i++) {
|
|
134
|
+
const cell = cells[i];
|
|
135
|
+
result[cell.column.id] = cell;
|
|
136
|
+
}
|
|
132
137
|
return result;
|
|
133
138
|
}
|
|
134
139
|
/**
|