@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.
Files changed (163) hide show
  1. package/dist/core/cells/constructCell.cjs +4 -3
  2. package/dist/core/cells/constructCell.cjs.map +1 -1
  3. package/dist/core/cells/constructCell.js +4 -3
  4. package/dist/core/cells/constructCell.js.map +1 -1
  5. package/dist/core/columns/constructColumn.cjs +6 -4
  6. package/dist/core/columns/constructColumn.cjs.map +1 -1
  7. package/dist/core/columns/constructColumn.js +6 -4
  8. package/dist/core/columns/constructColumn.js.map +1 -1
  9. package/dist/core/columns/coreColumnsFeature.utils.cjs +10 -2
  10. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  11. package/dist/core/columns/coreColumnsFeature.utils.js +10 -2
  12. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  13. package/dist/core/headers/buildHeaderGroups.cjs +27 -19
  14. package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
  15. package/dist/core/headers/buildHeaderGroups.js +27 -19
  16. package/dist/core/headers/buildHeaderGroups.js.map +1 -1
  17. package/dist/core/headers/constructHeader.cjs +4 -3
  18. package/dist/core/headers/constructHeader.cjs.map +1 -1
  19. package/dist/core/headers/constructHeader.js +4 -3
  20. package/dist/core/headers/constructHeader.js.map +1 -1
  21. package/dist/core/headers/coreHeadersFeature.cjs +1 -6
  22. package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
  23. package/dist/core/headers/coreHeadersFeature.js +2 -7
  24. package/dist/core/headers/coreHeadersFeature.js.map +1 -1
  25. package/dist/core/headers/coreHeadersFeature.utils.cjs +20 -18
  26. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  27. package/dist/core/headers/coreHeadersFeature.utils.d.cts +1 -1
  28. package/dist/core/headers/coreHeadersFeature.utils.d.ts +1 -1
  29. package/dist/core/headers/coreHeadersFeature.utils.js +21 -19
  30. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  31. package/dist/core/reactivity/coreReactivityFeature.types.d.cts +4 -0
  32. package/dist/core/reactivity/coreReactivityFeature.types.d.ts +4 -0
  33. package/dist/core/rows/constructRow.cjs +8 -6
  34. package/dist/core/rows/constructRow.cjs.map +1 -1
  35. package/dist/core/rows/constructRow.js +8 -6
  36. package/dist/core/rows/constructRow.js.map +1 -1
  37. package/dist/core/rows/coreRowsFeature.utils.cjs +9 -4
  38. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  39. package/dist/core/rows/coreRowsFeature.utils.js +9 -4
  40. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  41. package/dist/core/table/constructTable.cjs +9 -5
  42. package/dist/core/table/constructTable.cjs.map +1 -1
  43. package/dist/core/table/constructTable.js +9 -5
  44. package/dist/core/table/constructTable.js.map +1 -1
  45. package/dist/core/table/coreTablesFeature.utils.cjs +5 -1
  46. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  47. package/dist/core/table/coreTablesFeature.utils.js +5 -1
  48. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  49. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +8 -5
  50. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
  51. package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
  52. package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
  53. package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -3
  54. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  55. package/dist/features/column-faceting/createFacetedRowModel.js +8 -3
  56. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  57. package/dist/features/column-faceting/createFacetedUniqueValues.cjs +7 -4
  58. package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
  59. package/dist/features/column-faceting/createFacetedUniqueValues.js +7 -4
  60. package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
  61. package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -5
  62. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  63. package/dist/features/column-filtering/createFilteredRowModel.js +11 -5
  64. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  65. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +16 -6
  66. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  67. package/dist/features/column-ordering/columnOrderingFeature.utils.js +16 -6
  68. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  69. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +41 -24
  70. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  71. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +5 -4
  72. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +5 -4
  73. package/dist/features/column-pinning/columnPinningFeature.utils.js +42 -25
  74. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  75. package/dist/features/column-sizing/columnSizingFeature.cjs +28 -4
  76. package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
  77. package/dist/features/column-sizing/columnSizingFeature.js +28 -4
  78. package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
  79. package/dist/features/column-visibility/columnVisibilityFeature.cjs +23 -14
  80. package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
  81. package/dist/features/column-visibility/columnVisibilityFeature.js +24 -15
  82. package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
  83. package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +4 -0
  84. package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +4 -0
  85. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +40 -13
  86. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  87. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +12 -1
  88. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +12 -1
  89. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +40 -14
  90. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  91. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +2 -2
  92. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  93. package/dist/features/row-expanding/rowExpandingFeature.utils.js +2 -2
  94. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  95. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +13 -7
  96. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  97. package/dist/features/row-pinning/rowPinningFeature.utils.js +13 -7
  98. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  99. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +6 -3
  100. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  101. package/dist/features/row-selection/rowSelectionFeature.utils.js +6 -3
  102. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  103. package/dist/features/row-sorting/createSortedRowModel.cjs +13 -8
  104. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  105. package/dist/features/row-sorting/createSortedRowModel.js +13 -8
  106. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  107. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +2 -2
  108. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  109. package/dist/features/row-sorting/rowSortingFeature.utils.js +2 -2
  110. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  111. package/dist/fns/aggregationFns.cjs +14 -7
  112. package/dist/fns/aggregationFns.cjs.map +1 -1
  113. package/dist/fns/aggregationFns.js +14 -8
  114. package/dist/fns/aggregationFns.js.map +1 -1
  115. package/dist/index.cjs +0 -4
  116. package/dist/index.d.cts +2 -2
  117. package/dist/index.d.ts +2 -2
  118. package/dist/index.js +2 -2
  119. package/dist/static-functions.cjs +1 -0
  120. package/dist/static-functions.d.cts +2 -2
  121. package/dist/static-functions.d.ts +2 -2
  122. package/dist/static-functions.js +2 -2
  123. package/dist/store-reactivity-bindings.cjs +1 -0
  124. package/dist/store-reactivity-bindings.cjs.map +1 -1
  125. package/dist/store-reactivity-bindings.js +1 -0
  126. package/dist/store-reactivity-bindings.js.map +1 -1
  127. package/dist/utils.cjs +18 -39
  128. package/dist/utils.cjs.map +1 -1
  129. package/dist/utils.d.cts +1 -23
  130. package/dist/utils.d.ts +1 -23
  131. package/dist/utils.js +19 -36
  132. package/dist/utils.js.map +1 -1
  133. package/package.json +1 -1
  134. package/src/core/cells/constructCell.ts +3 -2
  135. package/src/core/columns/constructColumn.ts +5 -3
  136. package/src/core/columns/coreColumnsFeature.utils.ts +6 -2
  137. package/src/core/headers/buildHeaderGroups.ts +29 -30
  138. package/src/core/headers/constructHeader.ts +3 -2
  139. package/src/core/headers/coreHeadersFeature.ts +2 -27
  140. package/src/core/headers/coreHeadersFeature.utils.ts +29 -43
  141. package/src/core/reactivity/coreReactivityFeature.types.ts +4 -0
  142. package/src/core/rows/constructRow.ts +6 -4
  143. package/src/core/rows/coreRowsFeature.utils.ts +11 -4
  144. package/src/core/table/constructTable.ts +6 -4
  145. package/src/core/table/coreTablesFeature.utils.ts +3 -1
  146. package/src/features/column-faceting/createFacetedMinMaxValues.ts +8 -10
  147. package/src/features/column-faceting/createFacetedRowModel.ts +10 -6
  148. package/src/features/column-faceting/createFacetedUniqueValues.ts +4 -3
  149. package/src/features/column-filtering/createFilteredRowModel.ts +14 -8
  150. package/src/features/column-ordering/columnOrderingFeature.utils.ts +14 -6
  151. package/src/features/column-pinning/columnPinningFeature.utils.ts +53 -37
  152. package/src/features/column-sizing/columnSizingFeature.ts +16 -0
  153. package/src/features/column-visibility/columnVisibilityFeature.ts +8 -0
  154. package/src/features/column-visibility/columnVisibilityFeature.types.ts +7 -0
  155. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +50 -17
  156. package/src/features/row-expanding/rowExpandingFeature.utils.ts +2 -2
  157. package/src/features/row-pinning/rowPinningFeature.utils.ts +20 -18
  158. package/src/features/row-selection/rowSelectionFeature.utils.ts +20 -19
  159. package/src/features/row-sorting/createSortedRowModel.ts +16 -13
  160. package/src/features/row-sorting/rowSortingFeature.utils.ts +2 -2
  161. package/src/fns/aggregationFns.ts +20 -8
  162. package/src/store-reactivity-bindings.ts +1 -0
  163. package/src/utils.ts +19 -46
@@ -7,9 +7,10 @@
7
7
  function getCellPrototype(table) {
8
8
  if (!table._cellPrototype) {
9
9
  table._cellPrototype = { table };
10
- for (const feature of Object.values(table._features)) {
11
- var _feature$assignCellPr;
12
- (_feature$assignCellPr = feature.assignCellPrototype) === null || _feature$assignCellPr === void 0 || _feature$assignCellPr.call(feature, table._cellPrototype, table);
10
+ const features = Object.values(table._features);
11
+ for (let i = 0; i < features.length; i++) {
12
+ var _assignCellPrototype, _ref;
13
+ (_assignCellPrototype = (_ref = features[i]).assignCellPrototype) === null || _assignCellPrototype === void 0 || _assignCellPrototype.call(_ref, table._cellPrototype, table);
13
14
  }
14
15
  }
15
16
  return table._cellPrototype;
@@ -1 +1 @@
1
- {"version":3,"file":"constructCell.cjs","names":[],"sources":["../../../src/core/cells/constructCell.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 { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { Cell_CoreProperties } from './coreCellsFeature.types'\n\n/**\n * Creates or retrieves the cell prototype for a table.\n * The prototype is cached on the table and shared by all cell instances.\n */\nfunction getCellPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._cellPrototype) {\n table._cellPrototype = { table }\n for (const feature of Object.values(table._features)) {\n feature.assignCellPrototype?.(table._cellPrototype, table)\n }\n }\n return table._cellPrototype\n}\n\n/**\n * Constructs a cell 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 constructCell<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n row: Row<TFeatures, TData>,\n table: Table_Internal<TFeatures, TData>,\n): Cell<TFeatures, TData, TValue> {\n // Create cell with shared prototype for memory efficiency\n const cellPrototype = getCellPrototype(table)\n const cell = Object.create(cellPrototype) as Cell_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n cell.column = column\n cell.id = `${row.id}_${column.id}`\n cell.row = row\n\n return cell as Cell<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;;AAYA,SAAS,iBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,gBAAgB;EACzB,MAAM,iBAAiB,EAAE,OAAO;EAChC,KAAK,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,EAAE;;GACpD,iCAAQ,yGAAsB,MAAM,gBAAgB,MAAM;;;CAG9D,OAAO,MAAM;;;;;;;AAQf,SAAgB,cAKd,QACA,KACA,OACgC;CAEhC,MAAM,gBAAgB,iBAAiB,MAAM;CAC7C,MAAM,OAAO,OAAO,OAAO,cAAc;CAOzC,KAAK,SAAS;CACd,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,OAAO;CAC9B,KAAK,MAAM;CAEX,OAAO"}
1
+ {"version":3,"file":"constructCell.cjs","names":[],"sources":["../../../src/core/cells/constructCell.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 { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { Cell_CoreProperties } from './coreCellsFeature.types'\n\n/**\n * Creates or retrieves the cell prototype for a table.\n * The prototype is cached on the table and shared by all cell instances.\n */\nfunction getCellPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._cellPrototype) {\n table._cellPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignCellPrototype?.(table._cellPrototype, table)\n }\n }\n return table._cellPrototype\n}\n\n/**\n * Constructs a cell 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 constructCell<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n row: Row<TFeatures, TData>,\n table: Table_Internal<TFeatures, TData>,\n): Cell<TFeatures, TData, TValue> {\n // Create cell with shared prototype for memory efficiency\n const cellPrototype = getCellPrototype(table)\n const cell = Object.create(cellPrototype) as Cell_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n cell.column = column\n cell.id = `${row.id}_${column.id}`\n cell.row = row\n\n return cell as Cell<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;;AAYA,SAAS,iBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,gBAAgB;EACzB,MAAM,iBAAiB,EAAE,OAAO;EAChC,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;GACxC,yCAAS,IAAI,oGAAsB,MAAM,gBAAgB,MAAM;;;CAGnE,OAAO,MAAM;;;;;;;AAQf,SAAgB,cAKd,QACA,KACA,OACgC;CAEhC,MAAM,gBAAgB,iBAAiB,MAAM;CAC7C,MAAM,OAAO,OAAO,OAAO,cAAc;CAOzC,KAAK,SAAS;CACd,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,OAAO;CAC9B,KAAK,MAAM;CAEX,OAAO"}
@@ -6,9 +6,10 @@
6
6
  function getCellPrototype(table) {
7
7
  if (!table._cellPrototype) {
8
8
  table._cellPrototype = { table };
9
- for (const feature of Object.values(table._features)) {
10
- var _feature$assignCellPr;
11
- (_feature$assignCellPr = feature.assignCellPrototype) === null || _feature$assignCellPr === void 0 || _feature$assignCellPr.call(feature, table._cellPrototype, table);
9
+ const features = Object.values(table._features);
10
+ for (let i = 0; i < features.length; i++) {
11
+ var _assignCellPrototype, _ref;
12
+ (_assignCellPrototype = (_ref = features[i]).assignCellPrototype) === null || _assignCellPrototype === void 0 || _assignCellPrototype.call(_ref, table._cellPrototype, table);
12
13
  }
13
14
  }
14
15
  return table._cellPrototype;
@@ -1 +1 @@
1
- {"version":3,"file":"constructCell.js","names":[],"sources":["../../../src/core/cells/constructCell.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 { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { Cell_CoreProperties } from './coreCellsFeature.types'\n\n/**\n * Creates or retrieves the cell prototype for a table.\n * The prototype is cached on the table and shared by all cell instances.\n */\nfunction getCellPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._cellPrototype) {\n table._cellPrototype = { table }\n for (const feature of Object.values(table._features)) {\n feature.assignCellPrototype?.(table._cellPrototype, table)\n }\n }\n return table._cellPrototype\n}\n\n/**\n * Constructs a cell 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 constructCell<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n row: Row<TFeatures, TData>,\n table: Table_Internal<TFeatures, TData>,\n): Cell<TFeatures, TData, TValue> {\n // Create cell with shared prototype for memory efficiency\n const cellPrototype = getCellPrototype(table)\n const cell = Object.create(cellPrototype) as Cell_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n cell.column = column\n cell.id = `${row.id}_${column.id}`\n cell.row = row\n\n return cell as Cell<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;AAYA,SAAS,iBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,gBAAgB;EACzB,MAAM,iBAAiB,EAAE,OAAO;EAChC,KAAK,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,EAAE;;GACpD,iCAAQ,yGAAsB,MAAM,gBAAgB,MAAM;;;CAG9D,OAAO,MAAM;;;;;;;AAQf,SAAgB,cAKd,QACA,KACA,OACgC;CAEhC,MAAM,gBAAgB,iBAAiB,MAAM;CAC7C,MAAM,OAAO,OAAO,OAAO,cAAc;CAOzC,KAAK,SAAS;CACd,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,OAAO;CAC9B,KAAK,MAAM;CAEX,OAAO"}
1
+ {"version":3,"file":"constructCell.js","names":[],"sources":["../../../src/core/cells/constructCell.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 { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { Cell_CoreProperties } from './coreCellsFeature.types'\n\n/**\n * Creates or retrieves the cell prototype for a table.\n * The prototype is cached on the table and shared by all cell instances.\n */\nfunction getCellPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._cellPrototype) {\n table._cellPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignCellPrototype?.(table._cellPrototype, table)\n }\n }\n return table._cellPrototype\n}\n\n/**\n * Constructs a cell 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 constructCell<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n row: Row<TFeatures, TData>,\n table: Table_Internal<TFeatures, TData>,\n): Cell<TFeatures, TData, TValue> {\n // Create cell with shared prototype for memory efficiency\n const cellPrototype = getCellPrototype(table)\n const cell = Object.create(cellPrototype) as Cell_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n cell.column = column\n cell.id = `${row.id}_${column.id}`\n cell.row = row\n\n return cell as Cell<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;AAYA,SAAS,iBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,gBAAgB;EACzB,MAAM,iBAAiB,EAAE,OAAO;EAChC,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;;GACxC,yCAAS,IAAI,oGAAsB,MAAM,gBAAgB,MAAM;;;CAGnE,OAAO,MAAM;;;;;;;AAQf,SAAgB,cAKd,QACA,KACA,OACgC;CAEhC,MAAM,gBAAgB,iBAAiB,MAAM;CAC7C,MAAM,OAAO,OAAO,OAAO,cAAc;CAOzC,KAAK,SAAS;CACd,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,OAAO;CAC9B,KAAK,MAAM;CAEX,OAAO"}
@@ -7,9 +7,10 @@
7
7
  function getColumnPrototype(table) {
8
8
  if (!table._columnPrototype) {
9
9
  table._columnPrototype = { table };
10
- for (const feature of Object.values(table._features)) {
11
- var _feature$assignColumn;
12
- (_feature$assignColumn = feature.assignColumnPrototype) === null || _feature$assignColumn === void 0 || _feature$assignColumn.call(feature, table._columnPrototype, table);
10
+ const features = Object.values(table._features);
11
+ for (let i = 0; i < features.length; i++) {
12
+ var _assignColumnPrototyp, _ref;
13
+ (_assignColumnPrototyp = (_ref = features[i]).assignColumnPrototype) === null || _assignColumnPrototyp === void 0 || _assignColumnPrototyp.call(_ref, table._columnPrototype, table);
13
14
  }
14
15
  }
15
16
  return table._columnPrototype;
@@ -32,7 +33,8 @@ function constructColumn(table, columnDef, depth, parent) {
32
33
  const keys = accessorKey.split(".");
33
34
  accessorFn = (originalRow) => {
34
35
  let result = originalRow;
35
- for (const key of keys) {
36
+ for (let i = 0; i < keys.length; i++) {
37
+ const key = keys[i];
36
38
  result = result === null || result === void 0 ? void 0 : result[key];
37
39
  if (process.env.NODE_ENV === "development" && result === void 0) console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
38
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"constructColumn.cjs","names":[],"sources":["../../../src/core/columns/constructColumn.ts"],"sourcesContent":["import {} from '../../utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n AccessorFn,\n ColumnDef,\n ColumnDefResolved,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\nimport type { Column_CoreProperties } from './coreColumnsFeature.types'\n\n/**\n * Creates or retrieves the column prototype for a table.\n * The prototype is cached on the table and shared by all column instances.\n */\nfunction getColumnPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._columnPrototype) {\n table._columnPrototype = { table }\n for (const feature of Object.values(table._features)) {\n feature.assignColumnPrototype?.(table._columnPrototype, table)\n }\n }\n return table._columnPrototype\n}\n\n/**\n * Constructs a column 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 constructColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnDef: ColumnDef<TFeatures, TData, TValue>,\n depth: number,\n parent?: Column<TFeatures, TData, TValue>,\n): Column<TFeatures, TData, TValue> {\n const defaultColumn = table.getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<{}, TData, TValue>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n const id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.replaceAll('.', '_') : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData, TValue> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n const keys = accessorKey.split('.')\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any> | undefined\n\n for (const key of keys) {\n result = result?.[key]\n if (process.env.NODE_ENV === 'development' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`,\n )\n }\n }\n\n return result as TValue\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `coreColumnsFeature require an id when using an accessorFn`\n : `coreColumnsFeature require an id when using a non-string header`,\n )\n }\n throw new Error()\n }\n\n // Create column with shared prototype for memory efficiency\n const columnPrototype = getColumnPrototype(table)\n const column = Object.create(columnPrototype) as Column_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n column.accessorFn = accessorFn\n column.columnDef = resolvedColumnDef as ColumnDef<TFeatures, TData, TValue>\n column.columns = []\n column.depth = depth\n column.id = `${String(id)}`\n column.parent = parent\n\n return column as Column<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;;AAgBA,SAAS,mBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,kBAAkB;EAC3B,MAAM,mBAAmB,EAAE,OAAO;EAClC,KAAK,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,EAAE;;GACpD,iCAAQ,2GAAwB,MAAM,kBAAkB,MAAM;;;CAGlE,OAAO,MAAM;;;;;;;AAQf,SAAgB,gBAKd,OACA,WACA,OACA,QACkC;CAGlC,MAAM,oBAAoB;EACxB,GAHoB,MAAM,qBAGV;EAChB,GAAG;EACJ;CAED,MAAM,cAAc,kBAAkB;CAEtC,MAAM,KACJ,kBAAkB,OACjB,cAAc,YAAY,WAAW,KAAK,IAAI,GAAG,YACjD,OAAO,kBAAkB,WAAW,WACjC,kBAAkB,SAClB;CAEN,IAAI;CAEJ,IAAI,kBAAkB,YACpB,aAAa,kBAAkB;MAC1B,IAAI,aAET,IAAI,YAAY,SAAS,IAAI,EAAE;EAC7B,MAAM,OAAO,YAAY,MAAM,IAAI;EACnC,cAAc,gBAAuB;GACnC,IAAI,SAAS;GAEb,KAAK,MAAM,OAAO,MAAM;IACtB,yDAAS,OAAS;IAClB,IAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,QACvD,QAAQ,KACN,IAAI,IAAI,0BAA0B,YAAY,uBAC/C;;GAIL,OAAO;;QAGT,cAAc,gBACX,YAAoB,kBAAkB;CAI7C,IAAI,CAAC,IAAI;EACP,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MACR,kBAAkB,aACd,8DACA,kEACL;EAEH,MAAM,IAAI,OAAO;;CAInB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,SAAS,OAAO,OAAO,gBAAgB;CAO7C,OAAO,aAAa;CACpB,OAAO,YAAY;CACnB,OAAO,UAAU,EAAE;CACnB,OAAO,QAAQ;CACf,OAAO,KAAK,GAAG,OAAO,GAAG;CACzB,OAAO,SAAS;CAEhB,OAAO"}
1
+ {"version":3,"file":"constructColumn.cjs","names":[],"sources":["../../../src/core/columns/constructColumn.ts"],"sourcesContent":["import {} from '../../utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n AccessorFn,\n ColumnDef,\n ColumnDefResolved,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\nimport type { Column_CoreProperties } from './coreColumnsFeature.types'\n\n/**\n * Creates or retrieves the column prototype for a table.\n * The prototype is cached on the table and shared by all column instances.\n */\nfunction getColumnPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._columnPrototype) {\n table._columnPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignColumnPrototype?.(table._columnPrototype, table)\n }\n }\n return table._columnPrototype\n}\n\n/**\n * Constructs a column 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 constructColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnDef: ColumnDef<TFeatures, TData, TValue>,\n depth: number,\n parent?: Column<TFeatures, TData, TValue>,\n): Column<TFeatures, TData, TValue> {\n const defaultColumn = table.getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<{}, TData, TValue>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n const id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.replaceAll('.', '_') : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData, TValue> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n const keys = accessorKey.split('.')\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any> | undefined\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n result = result?.[key]\n if (process.env.NODE_ENV === 'development' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`,\n )\n }\n }\n\n return result as TValue\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `coreColumnsFeature require an id when using an accessorFn`\n : `coreColumnsFeature require an id when using a non-string header`,\n )\n }\n throw new Error()\n }\n\n // Create column with shared prototype for memory efficiency\n const columnPrototype = getColumnPrototype(table)\n const column = Object.create(columnPrototype) as Column_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n column.accessorFn = accessorFn\n column.columnDef = resolvedColumnDef as ColumnDef<TFeatures, TData, TValue>\n column.columns = []\n column.depth = depth\n column.id = `${String(id)}`\n column.parent = parent\n\n return column as Column<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;;AAgBA,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,WACA,OACA,QACkC;CAGlC,MAAM,oBAAoB;EACxB,GAHoB,MAAM,qBAGV;EAChB,GAAG;EACJ;CAED,MAAM,cAAc,kBAAkB;CAEtC,MAAM,KACJ,kBAAkB,OACjB,cAAc,YAAY,WAAW,KAAK,IAAI,GAAG,YACjD,OAAO,kBAAkB,WAAW,WACjC,kBAAkB,SAClB;CAEN,IAAI;CAEJ,IAAI,kBAAkB,YACpB,aAAa,kBAAkB;MAC1B,IAAI,aAET,IAAI,YAAY,SAAS,IAAI,EAAE;EAC7B,MAAM,OAAO,YAAY,MAAM,IAAI;EACnC,cAAc,gBAAuB;GACnC,IAAI,SAAS;GAEb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,MAAM,KAAK;IACjB,yDAAS,OAAS;IAClB,IAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,QACvD,QAAQ,KACN,IAAI,IAAI,0BAA0B,YAAY,uBAC/C;;GAIL,OAAO;;QAGT,cAAc,gBACX,YAAoB,kBAAkB;CAI7C,IAAI,CAAC,IAAI;EACP,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MACR,kBAAkB,aACd,8DACA,kEACL;EAEH,MAAM,IAAI,OAAO;;CAInB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,SAAS,OAAO,OAAO,gBAAgB;CAO7C,OAAO,aAAa;CACpB,OAAO,YAAY;CACnB,OAAO,UAAU,EAAE;CACnB,OAAO,QAAQ;CACf,OAAO,KAAK,GAAG,OAAO,GAAG;CACzB,OAAO,SAAS;CAEhB,OAAO"}
@@ -6,9 +6,10 @@
6
6
  function getColumnPrototype(table) {
7
7
  if (!table._columnPrototype) {
8
8
  table._columnPrototype = { table };
9
- for (const feature of Object.values(table._features)) {
10
- var _feature$assignColumn;
11
- (_feature$assignColumn = feature.assignColumnPrototype) === null || _feature$assignColumn === void 0 || _feature$assignColumn.call(feature, table._columnPrototype, table);
9
+ const features = Object.values(table._features);
10
+ for (let i = 0; i < features.length; i++) {
11
+ var _assignColumnPrototyp, _ref;
12
+ (_assignColumnPrototyp = (_ref = features[i]).assignColumnPrototype) === null || _assignColumnPrototyp === void 0 || _assignColumnPrototyp.call(_ref, table._columnPrototype, table);
12
13
  }
13
14
  }
14
15
  return table._columnPrototype;
@@ -31,7 +32,8 @@ function constructColumn(table, columnDef, depth, parent) {
31
32
  const keys = accessorKey.split(".");
32
33
  accessorFn = (originalRow) => {
33
34
  let result = originalRow;
34
- for (const key of keys) {
35
+ for (let i = 0; i < keys.length; i++) {
36
+ const key = keys[i];
35
37
  result = result === null || result === void 0 ? void 0 : result[key];
36
38
  if (process.env.NODE_ENV === "development" && result === void 0) console.warn(`"${key}" in deeply nested key "${accessorKey}" returned undefined.`);
37
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"constructColumn.js","names":[],"sources":["../../../src/core/columns/constructColumn.ts"],"sourcesContent":["import {} from '../../utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n AccessorFn,\n ColumnDef,\n ColumnDefResolved,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\nimport type { Column_CoreProperties } from './coreColumnsFeature.types'\n\n/**\n * Creates or retrieves the column prototype for a table.\n * The prototype is cached on the table and shared by all column instances.\n */\nfunction getColumnPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._columnPrototype) {\n table._columnPrototype = { table }\n for (const feature of Object.values(table._features)) {\n feature.assignColumnPrototype?.(table._columnPrototype, table)\n }\n }\n return table._columnPrototype\n}\n\n/**\n * Constructs a column 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 constructColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnDef: ColumnDef<TFeatures, TData, TValue>,\n depth: number,\n parent?: Column<TFeatures, TData, TValue>,\n): Column<TFeatures, TData, TValue> {\n const defaultColumn = table.getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<{}, TData, TValue>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n const id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.replaceAll('.', '_') : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData, TValue> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n const keys = accessorKey.split('.')\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any> | undefined\n\n for (const key of keys) {\n result = result?.[key]\n if (process.env.NODE_ENV === 'development' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`,\n )\n }\n }\n\n return result as TValue\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `coreColumnsFeature require an id when using an accessorFn`\n : `coreColumnsFeature require an id when using a non-string header`,\n )\n }\n throw new Error()\n }\n\n // Create column with shared prototype for memory efficiency\n const columnPrototype = getColumnPrototype(table)\n const column = Object.create(columnPrototype) as Column_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n column.accessorFn = accessorFn\n column.columnDef = resolvedColumnDef as ColumnDef<TFeatures, TData, TValue>\n column.columns = []\n column.depth = depth\n column.id = `${String(id)}`\n column.parent = parent\n\n return column as Column<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;AAgBA,SAAS,mBAGP,OAAiD;CACjD,IAAI,CAAC,MAAM,kBAAkB;EAC3B,MAAM,mBAAmB,EAAE,OAAO;EAClC,KAAK,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,EAAE;;GACpD,iCAAQ,2GAAwB,MAAM,kBAAkB,MAAM;;;CAGlE,OAAO,MAAM;;;;;;;AAQf,SAAgB,gBAKd,OACA,WACA,OACA,QACkC;CAGlC,MAAM,oBAAoB;EACxB,GAHoB,MAAM,qBAGV;EAChB,GAAG;EACJ;CAED,MAAM,cAAc,kBAAkB;CAEtC,MAAM,KACJ,kBAAkB,OACjB,cAAc,YAAY,WAAW,KAAK,IAAI,GAAG,YACjD,OAAO,kBAAkB,WAAW,WACjC,kBAAkB,SAClB;CAEN,IAAI;CAEJ,IAAI,kBAAkB,YACpB,aAAa,kBAAkB;MAC1B,IAAI,aAET,IAAI,YAAY,SAAS,IAAI,EAAE;EAC7B,MAAM,OAAO,YAAY,MAAM,IAAI;EACnC,cAAc,gBAAuB;GACnC,IAAI,SAAS;GAEb,KAAK,MAAM,OAAO,MAAM;IACtB,yDAAS,OAAS;IAClB,IAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,QACvD,QAAQ,KACN,IAAI,IAAI,0BAA0B,YAAY,uBAC/C;;GAIL,OAAO;;QAGT,cAAc,gBACX,YAAoB,kBAAkB;CAI7C,IAAI,CAAC,IAAI;EACP,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MACR,kBAAkB,aACd,8DACA,kEACL;EAEH,MAAM,IAAI,OAAO;;CAInB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,SAAS,OAAO,OAAO,gBAAgB;CAO7C,OAAO,aAAa;CACpB,OAAO,YAAY;CACnB,OAAO,UAAU,EAAE;CACnB,OAAO,QAAQ;CACf,OAAO,KAAK,GAAG,OAAO,GAAG;CACzB,OAAO,SAAS;CAEhB,OAAO"}
1
+ {"version":3,"file":"constructColumn.js","names":[],"sources":["../../../src/core/columns/constructColumn.ts"],"sourcesContent":["import {} from '../../utils'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n AccessorFn,\n ColumnDef,\n ColumnDefResolved,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\nimport type { Column_CoreProperties } from './coreColumnsFeature.types'\n\n/**\n * Creates or retrieves the column prototype for a table.\n * The prototype is cached on the table and shared by all column instances.\n */\nfunction getColumnPrototype<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): object {\n if (!table._columnPrototype) {\n table._columnPrototype = { table }\n const features = Object.values(table._features)\n for (let i = 0; i < features.length; i++) {\n features[i]!.assignColumnPrototype?.(table._columnPrototype, table)\n }\n }\n return table._columnPrototype\n}\n\n/**\n * Constructs a column 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 constructColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnDef: ColumnDef<TFeatures, TData, TValue>,\n depth: number,\n parent?: Column<TFeatures, TData, TValue>,\n): Column<TFeatures, TData, TValue> {\n const defaultColumn = table.getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<{}, TData, TValue>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n const id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.replaceAll('.', '_') : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData, TValue> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n const keys = accessorKey.split('.')\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any> | undefined\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n result = result?.[key]\n if (process.env.NODE_ENV === 'development' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`,\n )\n }\n }\n\n return result as TValue\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `coreColumnsFeature require an id when using an accessorFn`\n : `coreColumnsFeature require an id when using a non-string header`,\n )\n }\n throw new Error()\n }\n\n // Create column with shared prototype for memory efficiency\n const columnPrototype = getColumnPrototype(table)\n const column = Object.create(columnPrototype) as Column_CoreProperties<\n TFeatures,\n TData,\n TValue\n >\n\n // Only assign instance-specific properties\n column.accessorFn = accessorFn\n column.columnDef = resolvedColumnDef as ColumnDef<TFeatures, TData, TValue>\n column.columns = []\n column.depth = depth\n column.id = `${String(id)}`\n column.parent = parent\n\n return column as Column<TFeatures, TData, TValue>\n}\n"],"mappings":";;;;;AAgBA,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,WACA,OACA,QACkC;CAGlC,MAAM,oBAAoB;EACxB,GAHoB,MAAM,qBAGV;EAChB,GAAG;EACJ;CAED,MAAM,cAAc,kBAAkB;CAEtC,MAAM,KACJ,kBAAkB,OACjB,cAAc,YAAY,WAAW,KAAK,IAAI,GAAG,YACjD,OAAO,kBAAkB,WAAW,WACjC,kBAAkB,SAClB;CAEN,IAAI;CAEJ,IAAI,kBAAkB,YACpB,aAAa,kBAAkB;MAC1B,IAAI,aAET,IAAI,YAAY,SAAS,IAAI,EAAE;EAC7B,MAAM,OAAO,YAAY,MAAM,IAAI;EACnC,cAAc,gBAAuB;GACnC,IAAI,SAAS;GAEb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,MAAM,KAAK;IACjB,yDAAS,OAAS;IAClB,IAAI,QAAQ,IAAI,aAAa,iBAAiB,WAAW,QACvD,QAAQ,KACN,IAAI,IAAI,0BAA0B,YAAY,uBAC/C;;GAIL,OAAO;;QAGT,cAAc,gBACX,YAAoB,kBAAkB;CAI7C,IAAI,CAAC,IAAI;EACP,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MACR,kBAAkB,aACd,8DACA,kEACL;EAEH,MAAM,IAAI,OAAO;;CAInB,MAAM,kBAAkB,mBAAmB,MAAM;CACjD,MAAM,SAAS,OAAO,OAAO,gBAAgB;CAO7C,OAAO,aAAa;CACpB,OAAO,YAAY;CACnB,OAAO,UAAU,EAAE;CACnB,OAAO,QAAQ;CACf,OAAO,KAAK,GAAG,OAAO,GAAG;CACzB,OAAO,SAAS;CAEhB,OAAO"}
@@ -108,7 +108,11 @@ function table_getAllFlatColumns(table) {
108
108
  */
109
109
  function table_getAllFlatColumnsById(table) {
110
110
  const result = {};
111
- for (const column of table.getAllFlatColumns()) result[column.id] = column;
111
+ const flatColumns = table.getAllFlatColumns();
112
+ for (let i = 0; i < flatColumns.length; i++) {
113
+ const column = flatColumns[i];
114
+ result[column.id] = column;
115
+ }
112
116
  return result;
113
117
  }
114
118
  /**
@@ -137,7 +141,11 @@ function table_getAllLeafColumns(table) {
137
141
  */
138
142
  function table_getAllLeafColumnsById(table) {
139
143
  const result = {};
140
- for (const column of table.getAllLeafColumns()) result[column.id] = column;
144
+ const leafColumns = table.getAllLeafColumns();
145
+ for (let i = 0; i < leafColumns.length; i++) {
146
+ const column = leafColumns[i];
147
+ result[column.id] = column;
148
+ }
141
149
  return result;
142
150
  }
143
151
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"coreColumnsFeature.utils.cjs","names":["callMemoOrStaticFn","table_getOrderColumnsFn","constructColumn"],"sources":["../../../src/core/columns/coreColumnsFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { table_getOrderColumnsFn } from '../../features/column-ordering/columnOrderingFeature.utils'\nimport { constructColumn } from './constructColumn'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n ColumnDef,\n ColumnDefResolved,\n GroupColumnDef,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns flat columns 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_getFlatColumns(column)\n * ```\n */\nexport function column_getFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n return [column, ...column.columns.flatMap((col) => col.getFlatColumns())]\n}\n\n/**\n * Returns leaf columns 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_getLeafColumns(column)\n * ```\n */\nexport function column_getLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n if (column.columns.length) {\n const leafColumns = column.columns.flatMap(\n (col) => col.getLeafColumns(), // recursive\n )\n\n return callMemoOrStaticFn(\n column.table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns as any) as any\n }\n\n return [column]\n}\n\n/**\n * Returns default column def 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_getDefaultColumnDef(table)\n * ```\n */\nexport function table_getDefaultColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Partial<ColumnDef<TFeatures, TData, unknown>> {\n return {\n header: (props) => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<{}, TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n cell: (props) => props.renderValue<any>()?.toString?.() ?? null,\n ...Object.values(table._features).reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultColumnDef?.())\n }, {}),\n ...table.options.defaultColumn,\n } as Partial<ColumnDef<TFeatures, TData, unknown>>\n}\n\n/**\n * Returns all 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_getAllColumns(table)\n * ```\n */\nexport function table_getAllColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const recurseColumns = (\n colDefs: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>,\n parent?: Column<TFeatures, TData, unknown>,\n depth = 0,\n ): Array<Column<TFeatures, TData, unknown>> => {\n return colDefs.map((columnDef) => {\n const column = constructColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TFeatures,\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(table.options.columns)\n}\n\n/**\n * Returns all flat columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getAllFlatColumns(table)\n * ```\n */\nexport function table_getAllFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n return table.getAllColumns().flatMap((column) => column.getFlatColumns())\n}\n\n/**\n * Returns all flat columns by 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_getAllFlatColumnsById(table)\n * ```\n */\nexport function table_getAllFlatColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n for (const column of table.getAllFlatColumns()) {\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns all 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_getAllLeafColumns(table)\n * ```\n */\nexport function table_getAllLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const leafColumns = table.getAllColumns().flatMap(\n (c) => c.getLeafColumns(), // recursive\n )\n return callMemoOrStaticFn(\n table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns)\n}\n\n/**\n * Returns all leaf columns by 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_getAllLeafColumnsById(table)\n * ```\n */\nexport function table_getAllLeafColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n for (const column of table.getAllLeafColumns()) {\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns column 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_getColumn(table)\n * ```\n */\nexport function table_getColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n): Column<TFeatures, TData, unknown> | undefined {\n const column = table.getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV === 'development' && !column) {\n console.warn(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,SAAgB,sBAKd,QACyC;CACzC,OAAO,CAAC,QAAQ,GAAG,OAAO,QAAQ,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC;;;;;;;;;;;;AAa3E,SAAgB,sBAKd,QACyC;CACzC,IAAI,OAAO,QAAQ,QAAQ;EACzB,MAAM,cAAc,OAAO,QAAQ,SAChC,QAAQ,IAAI,gBAAgB,CAC9B;EAED,OAAOA,iCACL,OAAO,OACP,mB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B,SAAgB,4BAId,OACmD;CACnD,MAAM,SAA4D,EAAE;CACpE,KAAK,MAAM,UAAU,MAAM,mBAAmB,EAC5C,OAAO,OAAO,MAAM;CAEtB,OAAO;;;;;;;;;;;;AAaT,SAAgB,gBAId,OACA,UAC+C;CAC/C,MAAM,SAAS,MAAM,uBAAuB,CAAC;CAE7C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAC7C,QAAQ,KAAK,2BAA2B,SAAS,mBAAmB;CAGtE,OAAO"}
1
+ {"version":3,"file":"coreColumnsFeature.utils.cjs","names":["callMemoOrStaticFn","table_getOrderColumnsFn","constructColumn"],"sources":["../../../src/core/columns/coreColumnsFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { table_getOrderColumnsFn } from '../../features/column-ordering/columnOrderingFeature.utils'\nimport { constructColumn } from './constructColumn'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n ColumnDef,\n ColumnDefResolved,\n GroupColumnDef,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns flat columns 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_getFlatColumns(column)\n * ```\n */\nexport function column_getFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n return [column, ...column.columns.flatMap((col) => col.getFlatColumns())]\n}\n\n/**\n * Returns leaf columns 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_getLeafColumns(column)\n * ```\n */\nexport function column_getLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n if (column.columns.length) {\n const leafColumns = column.columns.flatMap(\n (col) => col.getLeafColumns(), // recursive\n )\n\n return callMemoOrStaticFn(\n column.table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns as any) as any\n }\n\n return [column]\n}\n\n/**\n * Returns default column def 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_getDefaultColumnDef(table)\n * ```\n */\nexport function table_getDefaultColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Partial<ColumnDef<TFeatures, TData, unknown>> {\n return {\n header: (props) => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<{}, TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n cell: (props) => props.renderValue<any>()?.toString?.() ?? null,\n ...Object.values(table._features).reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultColumnDef?.())\n }, {}),\n ...table.options.defaultColumn,\n } as Partial<ColumnDef<TFeatures, TData, unknown>>\n}\n\n/**\n * Returns all 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_getAllColumns(table)\n * ```\n */\nexport function table_getAllColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const recurseColumns = (\n colDefs: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>,\n parent?: Column<TFeatures, TData, unknown>,\n depth = 0,\n ): Array<Column<TFeatures, TData, unknown>> => {\n return colDefs.map((columnDef) => {\n const column = constructColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TFeatures,\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(table.options.columns)\n}\n\n/**\n * Returns all flat columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getAllFlatColumns(table)\n * ```\n */\nexport function table_getAllFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n return table.getAllColumns().flatMap((column) => column.getFlatColumns())\n}\n\n/**\n * Returns all flat columns by 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_getAllFlatColumnsById(table)\n * ```\n */\nexport function table_getAllFlatColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n const flatColumns = table.getAllFlatColumns()\n for (let i = 0; i < flatColumns.length; i++) {\n const column = flatColumns[i]!\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns all 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_getAllLeafColumns(table)\n * ```\n */\nexport function table_getAllLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const leafColumns = table.getAllColumns().flatMap(\n (c) => c.getLeafColumns(), // recursive\n )\n return callMemoOrStaticFn(\n table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns)\n}\n\n/**\n * Returns all leaf columns by 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_getAllLeafColumnsById(table)\n * ```\n */\nexport function table_getAllLeafColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n const leafColumns = table.getAllLeafColumns()\n for (let i = 0; i < leafColumns.length; i++) {\n const column = leafColumns[i]!\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns column 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_getColumn(table)\n * ```\n */\nexport function table_getColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n): Column<TFeatures, TData, unknown> | undefined {\n const column = table.getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV === 'development' && !column) {\n console.warn(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,SAAgB,sBAKd,QACyC;CACzC,OAAO,CAAC,QAAQ,GAAG,OAAO,QAAQ,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC;;;;;;;;;;;;AAa3E,SAAgB,sBAKd,QACyC;CACzC,IAAI,OAAO,QAAQ,QAAQ;EACzB,MAAM,cAAc,OAAO,QAAQ,SAChC,QAAQ,IAAI,gBAAgB,CAC9B;EAED,OAAOA,iCACL,OAAO,OACP,mBACAC,4DACD,CAAC,YAAmB;;CAGvB,OAAO,CAAC,OAAO;;;;;;;;;;;;AAajB,SAAgB,0BAId,OAC+C;CAC/C,OAAO;EACL,SAAS,UAAU;GACjB,MAAM,oBAAoB,MAAM,OAAO,OACpC;GAEH,IAAI,kBAAkB,aACpB,OAAO,kBAAkB;GAG3B,IAAI,kBAAkB,YACpB,OAAO,kBAAkB;GAG3B,OAAO;;EAET,OAAO,UAAU;;uCAAM,aAAkB,2FAAE,gHAAY,KAAI;;EAC3D,GAAG,OAAO,OAAO,MAAM,UAAU,CAAC,QAAQ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AC;CAE7C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAC7C,QAAQ,KAAK,2BAA2B,SAAS,mBAAmB;CAGtE,OAAO"}
@@ -108,7 +108,11 @@ function table_getAllFlatColumns(table) {
108
108
  */
109
109
  function table_getAllFlatColumnsById(table) {
110
110
  const result = {};
111
- for (const column of table.getAllFlatColumns()) result[column.id] = column;
111
+ const flatColumns = table.getAllFlatColumns();
112
+ for (let i = 0; i < flatColumns.length; i++) {
113
+ const column = flatColumns[i];
114
+ result[column.id] = column;
115
+ }
112
116
  return result;
113
117
  }
114
118
  /**
@@ -137,7 +141,11 @@ function table_getAllLeafColumns(table) {
137
141
  */
138
142
  function table_getAllLeafColumnsById(table) {
139
143
  const result = {};
140
- for (const column of table.getAllLeafColumns()) result[column.id] = column;
144
+ const leafColumns = table.getAllLeafColumns();
145
+ for (let i = 0; i < leafColumns.length; i++) {
146
+ const column = leafColumns[i];
147
+ result[column.id] = column;
148
+ }
141
149
  return result;
142
150
  }
143
151
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"coreColumnsFeature.utils.js","names":[],"sources":["../../../src/core/columns/coreColumnsFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { table_getOrderColumnsFn } from '../../features/column-ordering/columnOrderingFeature.utils'\nimport { constructColumn } from './constructColumn'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n ColumnDef,\n ColumnDefResolved,\n GroupColumnDef,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns flat columns 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_getFlatColumns(column)\n * ```\n */\nexport function column_getFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n return [column, ...column.columns.flatMap((col) => col.getFlatColumns())]\n}\n\n/**\n * Returns leaf columns 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_getLeafColumns(column)\n * ```\n */\nexport function column_getLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n if (column.columns.length) {\n const leafColumns = column.columns.flatMap(\n (col) => col.getLeafColumns(), // recursive\n )\n\n return callMemoOrStaticFn(\n column.table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns as any) as any\n }\n\n return [column]\n}\n\n/**\n * Returns default column def 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_getDefaultColumnDef(table)\n * ```\n */\nexport function table_getDefaultColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Partial<ColumnDef<TFeatures, TData, unknown>> {\n return {\n header: (props) => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<{}, TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n cell: (props) => props.renderValue<any>()?.toString?.() ?? null,\n ...Object.values(table._features).reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultColumnDef?.())\n }, {}),\n ...table.options.defaultColumn,\n } as Partial<ColumnDef<TFeatures, TData, unknown>>\n}\n\n/**\n * Returns all 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_getAllColumns(table)\n * ```\n */\nexport function table_getAllColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const recurseColumns = (\n colDefs: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>,\n parent?: Column<TFeatures, TData, unknown>,\n depth = 0,\n ): Array<Column<TFeatures, TData, unknown>> => {\n return colDefs.map((columnDef) => {\n const column = constructColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TFeatures,\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(table.options.columns)\n}\n\n/**\n * Returns all flat columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getAllFlatColumns(table)\n * ```\n */\nexport function table_getAllFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n return table.getAllColumns().flatMap((column) => column.getFlatColumns())\n}\n\n/**\n * Returns all flat columns by 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_getAllFlatColumnsById(table)\n * ```\n */\nexport function table_getAllFlatColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n for (const column of table.getAllFlatColumns()) {\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns all 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_getAllLeafColumns(table)\n * ```\n */\nexport function table_getAllLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const leafColumns = table.getAllColumns().flatMap(\n (c) => c.getLeafColumns(), // recursive\n )\n return callMemoOrStaticFn(\n table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns)\n}\n\n/**\n * Returns all leaf columns by 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_getAllLeafColumnsById(table)\n * ```\n */\nexport function table_getAllLeafColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n for (const column of table.getAllLeafColumns()) {\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns column 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_getColumn(table)\n * ```\n */\nexport function table_getColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n): Column<TFeatures, TData, unknown> | undefined {\n const column = table.getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV === 'development' && !column) {\n console.warn(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,SAAgB,sBAKd,QACyC;CACzC,OAAO,CAAC,QAAQ,GAAG,OAAO,QAAQ,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC;;;;;;;;;;;;AAa3E,SAAgB,sBAKd,QACyC;CACzC,IAAI,OAAO,QAAQ,QAAQ;EACzB,MAAM,cAAc,OAAO,QAAQ,SAChC,QAAQ,IAAI,gBAAgB,CAC9B;EAED,OAAO,mBACL,OAAO,OACP,mBACA,wBACD,CAAC,YAAmB;;CAGvB,OAAO,CAAC,OAAO;;;;;;;;;;;;AAajB,SAAgB,0BAId,OAC+C;CAC/C,OAAO;EACL,SAAS,UAAU;GACjB,MAAM,oBAAoB,MAAM,OAAO,OACpC;GA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C+C;CAC/C,MAAM,SAAS,MAAM,uBAAuB,CAAC;CAE7C,IAAI,QAAQ,IAAI,aAAa,iBAAiB,CAAC,QAC7C,QAAQ,KAAK,2BAA2B,SAAS,mBAAmB;CAGtE,OAAO"}
1
+ {"version":3,"file":"coreColumnsFeature.utils.js","names":[],"sources":["../../../src/core/columns/coreColumnsFeature.utils.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { table_getOrderColumnsFn } from '../../features/column-ordering/columnOrderingFeature.utils'\nimport { constructColumn } from './constructColumn'\nimport type { Table_Internal } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type {\n ColumnDef,\n ColumnDefResolved,\n GroupColumnDef,\n} from '../../types/ColumnDef'\nimport type { Column } from '../../types/Column'\n\n/**\n * Returns flat columns 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_getFlatColumns(column)\n * ```\n */\nexport function column_getFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n return [column, ...column.columns.flatMap((col) => col.getFlatColumns())]\n}\n\n/**\n * Returns leaf columns 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_getLeafColumns(column)\n * ```\n */\nexport function column_getLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column<TFeatures, TData, TValue>,\n): Array<Column<TFeatures, TData, TValue>> {\n if (column.columns.length) {\n const leafColumns = column.columns.flatMap(\n (col) => col.getLeafColumns(), // recursive\n )\n\n return callMemoOrStaticFn(\n column.table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns as any) as any\n }\n\n return [column]\n}\n\n/**\n * Returns default column def 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_getDefaultColumnDef(table)\n * ```\n */\nexport function table_getDefaultColumnDef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Partial<ColumnDef<TFeatures, TData, unknown>> {\n return {\n header: (props) => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<{}, TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n cell: (props) => props.renderValue<any>()?.toString?.() ?? null,\n ...Object.values(table._features).reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultColumnDef?.())\n }, {}),\n ...table.options.defaultColumn,\n } as Partial<ColumnDef<TFeatures, TData, unknown>>\n}\n\n/**\n * Returns all 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_getAllColumns(table)\n * ```\n */\nexport function table_getAllColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const recurseColumns = (\n colDefs: ReadonlyArray<ColumnDef<TFeatures, TData, unknown>>,\n parent?: Column<TFeatures, TData, unknown>,\n depth = 0,\n ): Array<Column<TFeatures, TData, unknown>> => {\n return colDefs.map((columnDef) => {\n const column = constructColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TFeatures,\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(table.options.columns)\n}\n\n/**\n * Returns all flat columns for the table.\n *\n * This reads the relevant table atoms, options, and row-model cache to derive the current table-level value.\n *\n * @example\n * ```ts\n * const value = table_getAllFlatColumns(table)\n * ```\n */\nexport function table_getAllFlatColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n return table.getAllColumns().flatMap((column) => column.getFlatColumns())\n}\n\n/**\n * Returns all flat columns by 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_getAllFlatColumnsById(table)\n * ```\n */\nexport function table_getAllFlatColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n const flatColumns = table.getAllFlatColumns()\n for (let i = 0; i < flatColumns.length; i++) {\n const column = flatColumns[i]!\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns all 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_getAllLeafColumns(table)\n * ```\n */\nexport function table_getAllLeafColumns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Array<Column<TFeatures, TData, unknown>> {\n const leafColumns = table.getAllColumns().flatMap(\n (c) => c.getLeafColumns(), // recursive\n )\n return callMemoOrStaticFn(\n table,\n 'getOrderColumns',\n table_getOrderColumnsFn,\n )(leafColumns)\n}\n\n/**\n * Returns all leaf columns by 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_getAllLeafColumnsById(table)\n * ```\n */\nexport function table_getAllLeafColumnsById<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n): Record<string, Column<TFeatures, TData, unknown>> {\n const result: Record<string, Column<TFeatures, TData, unknown>> = {}\n const leafColumns = table.getAllLeafColumns()\n for (let i = 0; i < leafColumns.length; i++) {\n const column = leafColumns[i]!\n result[column.id] = column\n }\n return result\n}\n\n/**\n * Returns column 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_getColumn(table)\n * ```\n */\nexport function table_getColumn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n): Column<TFeatures, TData, unknown> | undefined {\n const column = table.getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV === 'development' && !column) {\n console.warn(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,SAAgB,sBAKd,QACyC;CACzC,OAAO,CAAC,QAAQ,GAAG,OAAO,QAAQ,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC;;;;;;;;;;;;AAa3E,SAAgB,sBAKd,QACyC;CACzC,IAAI,OAAO,QAAQ,QAAQ;EACzB,MAAM,cAAc,OAAO,QAAQ,SAChC,QAAQ,IAAI,gBAAgB,CAC9B;EAED,OAAO,mBACL,OAAO,OACP,mBACA,wBACD,CAAC,YAAmB;;CAGvB,OAAO,CAAC,OAAO;;;;;;;;;;;;AAajB,SAAgB,0BAId,OAC+C;CAC/C,OAAO;EACL,SAAS,UAAU;GACjB,MAAM,oBAAoB,MAAM,OAAO,OACpC;GAEH,IAAI,kBAAkB,aACpB,OAAO,kBAAkB;GAG3B,IAAI,kBAAkB,YACpB,OAAO,kBAAkB;GAG3B,OAAO;;EAET,OAAO,UAAU;;uCAAM,aAAkB,2FAAE,gHAAY,KAAI;;EAC3D,GAAG,OAAO,OAAO,MAAM,UAAU,CAAC,QAAQ,KAAK,YAAY;;GACzD,OAAO,OAAO,OAAO,8BAAK,QAAQ,gHAAuB,CAAC;KACzD,EAAE,CAAC;EACN,GAAG,MAAM,QAAQ;EAClB;;;;;;;;;;;;AAaH,SAAgB,oBAId,OAC0C;CAC1C,MAAM,kBACJ,SACA,QACA,QAAQ,MACqC;EAC7C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ns, depth = 1) => {
15
15
  maxDepth = Math.max(maxDepth, depth);
16
- columns.filter((column) => require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)).forEach((column) => {
17
- if (column.columns.length) findMaxDepth(column.columns, depth + 1);
18
- }, 0);
16
+ for (let i = 0; i < columns.length; i++) {
17
+ const column = columns[i];
18
+ if (require_utils.callMemoOrStaticFn(column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) {
19
+ if (column.columns.length) findMaxDepth(column.columns, depth + 1);
20
+ }
21
+ }
19
22
  };
20
23
  findMaxDepth(allColumns);
21
24
  const headerGroups = [];
@@ -65,26 +68,31 @@ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
65
68
  })), maxDepth - 1);
66
69
  headerGroups.reverse();
67
70
  const recurseHeadersForSpans = (headers) => {
68
- return headers.filter((header) => require_utils.callMemoOrStaticFn(header.column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)).map((header) => {
71
+ const results = [];
72
+ for (let i = 0; i < headers.length; i++) {
73
+ const header = headers[i];
74
+ if (!require_utils.callMemoOrStaticFn(header.column, "getIsVisible", require_columnVisibilityFeature_utils.column_getIsVisible)) continue;
69
75
  let colSpan = 0;
70
- let rowSpan = 0;
71
- let childRowSpans = [0];
76
+ let minChildRowSpan = Infinity;
72
77
  if (header.subHeaders.length) {
73
- childRowSpans = [];
74
- recurseHeadersForSpans(header.subHeaders).forEach(({ colSpan: childColSpan, rowSpan: childRowSpan }) => {
75
- colSpan += childColSpan;
76
- childRowSpans.push(childRowSpan);
77
- });
78
- } else colSpan = 1;
79
- const minChildRowSpan = Math.min(...childRowSpans);
80
- rowSpan = rowSpan + minChildRowSpan;
78
+ const childSpans = recurseHeadersForSpans(header.subHeaders);
79
+ for (let j = 0; j < childSpans.length; j++) {
80
+ const child = childSpans[j];
81
+ colSpan += child.colSpan;
82
+ if (child.rowSpan < minChildRowSpan) minChildRowSpan = child.rowSpan;
83
+ }
84
+ } else {
85
+ colSpan = 1;
86
+ minChildRowSpan = 0;
87
+ }
81
88
  header.colSpan = colSpan;
82
- header.rowSpan = rowSpan;
83
- return {
89
+ header.rowSpan = minChildRowSpan;
90
+ results.push({
84
91
  colSpan,
85
- rowSpan
86
- };
87
- });
92
+ rowSpan: header.rowSpan
93
+ });
94
+ }
95
+ return results;
88
96
  };
89
97
  recurseHeadersForSpans(((_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 ? void 0 : _headerGroups$.headers) ?? []);
90
98
  return headerGroups;
@@ -1 +1 @@
1
- {"version":3,"file":"buildHeaderGroups.cjs","names":["callMemoOrStaticFn","column_getIsVisible","constructHeader"],"sources":["../../../src/core/headers/buildHeaderGroups.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { column_getIsVisible } from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { constructHeader } from './constructHeader'\nimport 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 { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Column } from '../../types/Column'\n\n/**\n * Builds the nested header group structure for a table.\n *\n * The result accounts for visible leaf columns, pinned column groups, and placeholder headers needed to render multi-level headers.\n */\nexport function buildHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n allColumns: Array<Column<TFeatures, TData, TValue>>,\n columnsToGroup: Array<Column<TFeatures, TData, TValue>>,\n table: Table_Internal<TFeatures, TData>,\n headerFamily?: 'center' | 'left' | 'right',\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (\n columns: Array<Column<TFeatures, TData, TValue>>,\n depth = 1,\n ) => {\n maxDepth = Math.max(maxDepth, depth)\n\n columns\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n .forEach((column) => {\n if (column.columns.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }, 0)\n }\n\n findMaxDepth(allColumns)\n\n const headerGroups: Array<HeaderGroup<TFeatures, TData>> = []\n\n const constructHeaderGroup = (\n headersToGroup: Array<Header<TFeatures, TData, TValue>>,\n depth: number,\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TFeatures, TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n } as any\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n // Scan each column for parents\n headersToGroup.forEach((headerToGroup) => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader =\n pendingParentHeaders[pendingParentHeaders.length - 1]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TFeatures, TData, TValue>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = constructHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter((d) => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n constructHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n constructHeader(table, column, {\n depth: maxDepth,\n index,\n }),\n )\n\n constructHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n // headerGroups = headerGroups.filter(headerGroup => {\n // return !headerGroup.headers.every(header => header.isPlaceholder)\n // })\n\n const recurseHeadersForSpans = (\n headers: Array<Header<TFeatures, TData, TValue>>,\n ): Array<{ colSpan: number; rowSpan: number }> => {\n const filteredHeaders = headers.filter((header) =>\n callMemoOrStaticFn(header.column, 'getIsVisible', column_getIsVisible),\n )\n\n return filteredHeaders.map((header) => {\n let colSpan = 0\n let rowSpan = 0\n let childRowSpans = [0]\n\n if (header.subHeaders.length) {\n childRowSpans = []\n\n recurseHeadersForSpans(header.subHeaders).forEach(\n ({ colSpan: childColSpan, rowSpan: childRowSpan }) => {\n colSpan += childColSpan\n childRowSpans.push(childRowSpan)\n },\n )\n } else {\n colSpan = 1\n }\n\n const minChildRowSpan = Math.min(...childRowSpans)\n rowSpan = rowSpan + minChildRowSpan\n\n header.colSpan = colSpan\n header.rowSpan = rowSpan\n\n return { colSpan, rowSpan }\n })\n }\n\n recurseHeadersForSpans(\n (headerGroups[0]?.headers ?? []) as Array<Header<TFeatures, TData, TValue>>,\n )\n\n return headerGroups\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAgB,kBAKd,YACA,gBACA,OACA,cACA;;CAOA,IAAI,WAAW;CAEf,MAAM,gBACJ,SACA,QAAQ,MACL;EACH,WAAW,KAAK,IAAI,UAAU,MAAM;EAEpC,QACG,QAAQ,WACPA,iCAAmB,QAAQ,gBAAgBC,0DAAoB,CAChE,CACA,SAAS,WAAW;GACnB,IAAI,OAAO,QAAQ,QACjB,aAAa,OAAO,SAAS,QAAQ,EAAE;KAExC,EAAE;;CAGT,aAAa,WAAW;CAExB,MAAM,eAAqD,EAAE;CAE7D,MAAM,wBACJ,gBACA,UACG;EAEH,MAAM,cAA6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EvB,IAAI,OAAO,WAAW,QAAQ;IAC5B,gBAAgB,EAAE;IAElB,uBAAuB,OAAO,WAAW,CAAC,SACvC,EAAE,SAAS,cAAc,SAAS,mBAAmB;KACpD,WAAW;KACX,cAAc,KAAK,aAAa;MAEnC;UAED,UAAU;GAGZ,MAAM,kBAAkB,KAAK,IAAI,GAAG,cAAc;GAClD,UAAU,UAAU;GAEpB,OAAO,UAAU;GACjB,OAAO,UAAU;GAEjB,OAAO;IAAE;IAAS;IAAS;IAC3B;;CAGJ,0CACG,aAAa,oEAAI,YAAW,EAAE,CAChC;CAED,OAAO"}
1
+ {"version":3,"file":"buildHeaderGroups.cjs","names":["callMemoOrStaticFn","column_getIsVisible","constructHeader"],"sources":["../../../src/core/headers/buildHeaderGroups.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { column_getIsVisible } from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { constructHeader } from './constructHeader'\nimport 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 { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Column } from '../../types/Column'\n\n/**\n * Builds the nested header group structure for a table.\n *\n * The result accounts for visible leaf columns, pinned column groups, and placeholder headers needed to render multi-level headers.\n */\nexport function buildHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n allColumns: Array<Column<TFeatures, TData, TValue>>,\n columnsToGroup: Array<Column<TFeatures, TData, TValue>>,\n table: Table_Internal<TFeatures, TData>,\n headerFamily?: 'center' | 'left' | 'right',\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (\n columns: Array<Column<TFeatures, TData, TValue>>,\n depth = 1,\n ) => {\n maxDepth = Math.max(maxDepth, depth)\n\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)) {\n if (column.columns.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }\n }\n }\n\n findMaxDepth(allColumns)\n\n const headerGroups: Array<HeaderGroup<TFeatures, TData>> = []\n\n const constructHeaderGroup = (\n headersToGroup: Array<Header<TFeatures, TData, TValue>>,\n depth: number,\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TFeatures, TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n } as any\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n // Scan each column for parents\n headersToGroup.forEach((headerToGroup) => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader =\n pendingParentHeaders[pendingParentHeaders.length - 1]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TFeatures, TData, TValue>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = constructHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter((d) => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n constructHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n constructHeader(table, column, {\n depth: maxDepth,\n index,\n }),\n )\n\n constructHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n const recurseHeadersForSpans = (\n headers: Array<Header<TFeatures, TData, TValue>>,\n ): Array<{ colSpan: number; rowSpan: number }> => {\n const results: Array<{ colSpan: number; rowSpan: number }> = []\n\n for (let i = 0; i < headers.length; i++) {\n const header = headers[i]!\n if (\n !callMemoOrStaticFn(header.column, 'getIsVisible', column_getIsVisible)\n ) {\n continue\n }\n\n let colSpan = 0\n let minChildRowSpan = Infinity\n\n if (header.subHeaders.length) {\n const childSpans = recurseHeadersForSpans(header.subHeaders)\n for (let j = 0; j < childSpans.length; j++) {\n const child = childSpans[j]!\n colSpan += child.colSpan\n if (child.rowSpan < minChildRowSpan) {\n minChildRowSpan = child.rowSpan\n }\n }\n } else {\n colSpan = 1\n minChildRowSpan = 0\n }\n\n header.colSpan = colSpan\n header.rowSpan = minChildRowSpan\n\n results.push({ colSpan, rowSpan: header.rowSpan })\n }\n\n return results\n }\n\n recurseHeadersForSpans(\n (headerGroups[0]?.headers ?? []) as Array<Header<TFeatures, TData, TValue>>,\n )\n\n return headerGroups\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAgB,kBAKd,YACA,gBACA,OACA,cACA;;CAOA,IAAI,WAAW;CAEf,MAAM,gBACJ,SACA,QAAQ,MACL;EACH,WAAW,KAAK,IAAI,UAAU,MAAM;EAEpC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,SAAS,QAAQ;GACvB,IAAIA,iCAAmB,QAAQ,gBAAgBC,0DAAoB,EACjE;QAAI,OAAO,QAAQ,QACjB,aAAa,OAAO,SAAS,QAAQ,EAAE;;;;CAM/C,aAAa,WAAW;CAExB,MAAM,eAAqD,EAAE;CAE7D,MAAM,w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AO,QAAQ,gBAAgBC,0DAAoB,EAEvE;GAGF,IAAI,UAAU;GACd,IAAI,kBAAkB;GAEtB,IAAI,OAAO,WAAW,QAAQ;IAC5B,MAAM,aAAa,uBAAuB,OAAO,WAAW;IAC5D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;KAC1C,MAAM,QAAQ,WAAW;KACzB,WAAW,MAAM;KACjB,IAAI,MAAM,UAAU,iBAClB,kBAAkB,MAAM;;UAGvB;IACL,UAAU;IACV,kBAAkB;;GAGpB,OAAO,UAAU;GACjB,OAAO,UAAU;GAEjB,QAAQ,KAAK;IAAE;IAAS,SAAS,OAAO;IAAS,CAAC;;EAGpD,OAAO;;CAGT,0CACG,aAAa,oEAAI,YAAW,EAAE,CAChC;CAED,OAAO"}
@@ -13,9 +13,12 @@ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
13
13
  let maxDepth = 0;
14
14
  const findMaxDepth = (columns, depth = 1) => {
15
15
  maxDepth = Math.max(maxDepth, depth);
16
- columns.filter((column) => callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible)).forEach((column) => {
17
- if (column.columns.length) findMaxDepth(column.columns, depth + 1);
18
- }, 0);
16
+ for (let i = 0; i < columns.length; i++) {
17
+ const column = columns[i];
18
+ if (callMemoOrStaticFn(column, "getIsVisible", column_getIsVisible)) {
19
+ if (column.columns.length) findMaxDepth(column.columns, depth + 1);
20
+ }
21
+ }
19
22
  };
20
23
  findMaxDepth(allColumns);
21
24
  const headerGroups = [];
@@ -65,26 +68,31 @@ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
65
68
  })), maxDepth - 1);
66
69
  headerGroups.reverse();
67
70
  const recurseHeadersForSpans = (headers) => {
68
- return headers.filter((header) => callMemoOrStaticFn(header.column, "getIsVisible", column_getIsVisible)).map((header) => {
71
+ const results = [];
72
+ for (let i = 0; i < headers.length; i++) {
73
+ const header = headers[i];
74
+ if (!callMemoOrStaticFn(header.column, "getIsVisible", column_getIsVisible)) continue;
69
75
  let colSpan = 0;
70
- let rowSpan = 0;
71
- let childRowSpans = [0];
76
+ let minChildRowSpan = Infinity;
72
77
  if (header.subHeaders.length) {
73
- childRowSpans = [];
74
- recurseHeadersForSpans(header.subHeaders).forEach(({ colSpan: childColSpan, rowSpan: childRowSpan }) => {
75
- colSpan += childColSpan;
76
- childRowSpans.push(childRowSpan);
77
- });
78
- } else colSpan = 1;
79
- const minChildRowSpan = Math.min(...childRowSpans);
80
- rowSpan = rowSpan + minChildRowSpan;
78
+ const childSpans = recurseHeadersForSpans(header.subHeaders);
79
+ for (let j = 0; j < childSpans.length; j++) {
80
+ const child = childSpans[j];
81
+ colSpan += child.colSpan;
82
+ if (child.rowSpan < minChildRowSpan) minChildRowSpan = child.rowSpan;
83
+ }
84
+ } else {
85
+ colSpan = 1;
86
+ minChildRowSpan = 0;
87
+ }
81
88
  header.colSpan = colSpan;
82
- header.rowSpan = rowSpan;
83
- return {
89
+ header.rowSpan = minChildRowSpan;
90
+ results.push({
84
91
  colSpan,
85
- rowSpan
86
- };
87
- });
92
+ rowSpan: header.rowSpan
93
+ });
94
+ }
95
+ return results;
88
96
  };
89
97
  recurseHeadersForSpans(((_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 ? void 0 : _headerGroups$.headers) ?? []);
90
98
  return headerGroups;
@@ -1 +1 @@
1
- {"version":3,"file":"buildHeaderGroups.js","names":[],"sources":["../../../src/core/headers/buildHeaderGroups.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { column_getIsVisible } from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { constructHeader } from './constructHeader'\nimport 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 { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Column } from '../../types/Column'\n\n/**\n * Builds the nested header group structure for a table.\n *\n * The result accounts for visible leaf columns, pinned column groups, and placeholder headers needed to render multi-level headers.\n */\nexport function buildHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n allColumns: Array<Column<TFeatures, TData, TValue>>,\n columnsToGroup: Array<Column<TFeatures, TData, TValue>>,\n table: Table_Internal<TFeatures, TData>,\n headerFamily?: 'center' | 'left' | 'right',\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (\n columns: Array<Column<TFeatures, TData, TValue>>,\n depth = 1,\n ) => {\n maxDepth = Math.max(maxDepth, depth)\n\n columns\n .filter((column) =>\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible),\n )\n .forEach((column) => {\n if (column.columns.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }, 0)\n }\n\n findMaxDepth(allColumns)\n\n const headerGroups: Array<HeaderGroup<TFeatures, TData>> = []\n\n const constructHeaderGroup = (\n headersToGroup: Array<Header<TFeatures, TData, TValue>>,\n depth: number,\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TFeatures, TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n } as any\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n // Scan each column for parents\n headersToGroup.forEach((headerToGroup) => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader =\n pendingParentHeaders[pendingParentHeaders.length - 1]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TFeatures, TData, TValue>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = constructHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter((d) => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n constructHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n constructHeader(table, column, {\n depth: maxDepth,\n index,\n }),\n )\n\n constructHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n // headerGroups = headerGroups.filter(headerGroup => {\n // return !headerGroup.headers.every(header => header.isPlaceholder)\n // })\n\n const recurseHeadersForSpans = (\n headers: Array<Header<TFeatures, TData, TValue>>,\n ): Array<{ colSpan: number; rowSpan: number }> => {\n const filteredHeaders = headers.filter((header) =>\n callMemoOrStaticFn(header.column, 'getIsVisible', column_getIsVisible),\n )\n\n return filteredHeaders.map((header) => {\n let colSpan = 0\n let rowSpan = 0\n let childRowSpans = [0]\n\n if (header.subHeaders.length) {\n childRowSpans = []\n\n recurseHeadersForSpans(header.subHeaders).forEach(\n ({ colSpan: childColSpan, rowSpan: childRowSpan }) => {\n colSpan += childColSpan\n childRowSpans.push(childRowSpan)\n },\n )\n } else {\n colSpan = 1\n }\n\n const minChildRowSpan = Math.min(...childRowSpans)\n rowSpan = rowSpan + minChildRowSpan\n\n header.colSpan = colSpan\n header.rowSpan = rowSpan\n\n return { colSpan, rowSpan }\n })\n }\n\n recurseHeadersForSpans(\n (headerGroups[0]?.headers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,KAAK,cAAc;GACvC,cAAc,cAAc;IAC5B;EAEF,aAAa,KAAK,YAAY;EAE9B,IAAI,QAAQ,GACV,qBAAqB,sBAAsB,QAAQ,EAAE;;CAWzD,qBAPsB,eAAe,KAAK,QAAQ,UAChD,gBAAgB,OAAO,QAAQ;EAC7B,OAAO;EACP;EACD,CAAC,CAG8B,EAAE,WAAW,EAAE;CAEjD,aAAa,SAAS;CAMtB,MAAM,0BACJ,YACgD;EAKhD,OAJwB,QAAQ,QAAQ,WACtC,mBAAmB,OAAO,QAAQ,gBAAgB,oBAAoB,CAGlD,CAAC,KAAK,WAAW;GACrC,IAAI,UAAU;GACd,IAAI,UAAU;GACd,IAAI,gBAAgB,CAAC,EAAE;GAEvB,IAAI,OAAO,WAAW,QAAQ;IAC5B,gBAAgB,EAAE;IAElB,uBAAuB,OAAO,WAAW,CAAC,SACvC,EAAE,SAAS,cAAc,SAAS,mBAAmB;KACpD,WAAW;KACX,cAAc,KAAK,aAAa;MAEnC;UAED,UAAU;GAGZ,MAAM,kBAAkB,KAAK,IAAI,GAAG,cAAc;GAClD,UAAU,UAAU;GAEpB,OAAO,UAAU;GACjB,OAAO,UAAU;GAEjB,OAAO;IAAE;IAAS;IAAS;IAC3B;;CAGJ,0CACG,aAAa,oEAAI,YAAW,EAAE,CAChC;CAED,OAAO"}
1
+ {"version":3,"file":"buildHeaderGroups.js","names":[],"sources":["../../../src/core/headers/buildHeaderGroups.ts"],"sourcesContent":["import { callMemoOrStaticFn } from '../../utils'\nimport { column_getIsVisible } from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { constructHeader } from './constructHeader'\nimport 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 { HeaderGroup } from '../../types/HeaderGroup'\nimport type { Column } from '../../types/Column'\n\n/**\n * Builds the nested header group structure for a table.\n *\n * The result accounts for visible leaf columns, pinned column groups, and placeholder headers needed to render multi-level headers.\n */\nexport function buildHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n allColumns: Array<Column<TFeatures, TData, TValue>>,\n columnsToGroup: Array<Column<TFeatures, TData, TValue>>,\n table: Table_Internal<TFeatures, TData>,\n headerFamily?: 'center' | 'left' | 'right',\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (\n columns: Array<Column<TFeatures, TData, TValue>>,\n depth = 1,\n ) => {\n maxDepth = Math.max(maxDepth, depth)\n\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n if (callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)) {\n if (column.columns.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }\n }\n }\n\n findMaxDepth(allColumns)\n\n const headerGroups: Array<HeaderGroup<TFeatures, TData>> = []\n\n const constructHeaderGroup = (\n headersToGroup: Array<Header<TFeatures, TData, TValue>>,\n depth: number,\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TFeatures, TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n } as any\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n // Scan each column for parents\n headersToGroup.forEach((headerToGroup) => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader =\n pendingParentHeaders[pendingParentHeaders.length - 1]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TFeatures, TData, TValue>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = constructHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter((d) => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n constructHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n constructHeader(table, column, {\n depth: maxDepth,\n index,\n }),\n )\n\n constructHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n const recurseHeadersForSpans = (\n headers: Array<Header<TFeatures, TData, TValue>>,\n ): Array<{ colSpan: number; rowSpan: number }> => {\n const results: Array<{ colSpan: number; rowSpan: number }> = []\n\n for (let i = 0; i < headers.length; i++) {\n const header = headers[i]!\n if (\n !callMemoOrStaticFn(header.column, 'getIsVisible', column_getIsVisible)\n ) {\n continue\n }\n\n let colSpan = 0\n let minChildRowSpan = Infinity\n\n if (header.subHeaders.length) {\n const childSpans = recurseHeadersForSpans(header.subHeaders)\n for (let j = 0; j < childSpans.length; j++) {\n const child = childSpans[j]!\n colSpan += child.colSpan\n if (child.rowSpan < minChildRowSpan) {\n minChildRowSpan = child.rowSpan\n }\n }\n } else {\n colSpan = 1\n minChildRowSpan = 0\n }\n\n header.colSpan = colSpan\n header.rowSpan = minChildRowSpan\n\n results.push({ colSpan, rowSpan: header.rowSpan })\n }\n\n return results\n }\n\n recurseHeadersForSpans(\n (headerGroups[0]?.headers ?? []) as Array<Header<TFeatures, TData, TValue>>,\n )\n\n return headerGro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cAAc;GACvC,cAAc,cAAc;IAC5B;EAEF,aAAa,KAAK,YAAY;EAE9B,IAAI,QAAQ,GACV,qBAAqB,sBAAsB,QAAQ,EAAE;;CAWzD,qBAPsB,eAAe,KAAK,QAAQ,UAChD,gBAAgB,OAAO,QAAQ;EAC7B,OAAO;EACP;EACD,CAAC,CAG8B,EAAE,WAAW,EAAE;CAEjD,aAAa,SAAS;CAEtB,MAAM,0BACJ,YACgD;EAChD,MAAM,UAAuD,EAAE;EAE/D,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,SAAS,QAAQ;GACvB,IACE,CAAC,mBAAmB,OAAO,QAAQ,gBAAgB,oBAAoB,EAEvE;GAGF,IAAI,UAAU;GACd,IAAI,kBAAkB;GAEtB,IAAI,OAAO,WAAW,QAAQ;IAC5B,MAAM,aAAa,uBAAuB,OAAO,WAAW;IAC5D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;KAC1C,MAAM,QAAQ,WAAW;KACzB,WAAW,MAAM;KACjB,IAAI,MAAM,UAAU,iBAClB,kBAAkB,MAAM;;UAGvB;IACL,UAAU;IACV,kBAAkB;;GAGpB,OAAO,UAAU;GACjB,OAAO,UAAU;GAEjB,QAAQ,KAAK;IAAE;IAAS,SAAS,OAAO;IAAS,CAAC;;EAGpD,OAAO;;CAGT,0CACG,aAAa,oEAAI,YAAW,EAAE,CAChC;CAED,OAAO"}
@@ -7,9 +7,10 @@
7
7
  function getHeaderPrototype(table) {
8
8
  if (!table._headerPrototype) {
9
9
  table._headerPrototype = { table };
10
- for (const feature of Object.values(table._features)) {
11
- var _feature$assignHeader;
12
- (_feature$assignHeader = feature.assignHeaderPrototype) === null || _feature$assignHeader === void 0 || _feature$assignHeader.call(feature, table._headerPrototype, table);
10
+ const features = Object.values(table._features);
11
+ for (let i = 0; i < features.length; i++) {
12
+ var _assignHeaderPrototyp, _ref;
13
+ (_assignHeaderPrototyp = (_ref = features[i]).assignHeaderPrototype) === null || _assignHeaderPrototyp === void 0 || _assignHeaderPrototyp.call(_ref, table._headerPrototype, table);
13
14
  }
14
15
  }
15
16
  return table._headerPrototype;
@@ -1 +1 @@
1
- {"version":3,"file":"constructHeader.cjs","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 for (const feature of Object.values(table._features)) {\n feature.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,KAAK,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,EAAE;;GACpD,iCAAQ,2GAAwB,MAAM,kBAAkB,MAAM;;;CAGlE,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
+ {"version":3,"file":"constructHeader.cjs","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"}
@@ -6,9 +6,10 @@
6
6
  function getHeaderPrototype(table) {
7
7
  if (!table._headerPrototype) {
8
8
  table._headerPrototype = { table };
9
- for (const feature of Object.values(table._features)) {
10
- var _feature$assignHeader;
11
- (_feature$assignHeader = feature.assignHeaderPrototype) === null || _feature$assignHeader === void 0 || _feature$assignHeader.call(feature, table._headerPrototype, table);
9
+ const features = Object.values(table._features);
10
+ for (let i = 0; i < features.length; i++) {
11
+ var _assignHeaderPrototyp, _ref;
12
+ (_assignHeaderPrototyp = (_ref = features[i]).assignHeaderPrototype) === null || _assignHeaderPrototyp === void 0 || _assignHeaderPrototyp.call(_ref, table._headerPrototype, table);
12
13
  }
13
14
  }
14
15
  return table._headerPrototype;