@tanstack/table-core 9.0.0-beta.49 → 9.0.0-beta.50

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 (73) hide show
  1. package/dist/core/rows/coreRowsFeature.cjs +5 -1
  2. package/dist/core/rows/coreRowsFeature.cjs.map +1 -1
  3. package/dist/core/rows/coreRowsFeature.js +6 -2
  4. package/dist/core/rows/coreRowsFeature.js.map +1 -1
  5. package/dist/core/rows/coreRowsFeature.types.d.cts +8 -0
  6. package/dist/core/rows/coreRowsFeature.types.d.ts +8 -0
  7. package/dist/core/rows/coreRowsFeature.utils.cjs +11 -0
  8. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  9. package/dist/core/rows/coreRowsFeature.utils.d.cts +6 -1
  10. package/dist/core/rows/coreRowsFeature.utils.d.ts +6 -1
  11. package/dist/core/rows/coreRowsFeature.utils.js +11 -1
  12. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  13. package/dist/features/aggregation/aggregationFeature.cjs +3 -2
  14. package/dist/features/aggregation/aggregationFeature.cjs.map +1 -1
  15. package/dist/features/aggregation/aggregationFeature.js +3 -2
  16. package/dist/features/aggregation/aggregationFeature.js.map +1 -1
  17. package/dist/features/aggregation/aggregationFeature.types.cjs.map +1 -1
  18. package/dist/features/aggregation/aggregationFeature.types.d.cts +36 -13
  19. package/dist/features/aggregation/aggregationFeature.types.d.ts +36 -13
  20. package/dist/features/aggregation/aggregationFeature.types.js.map +1 -1
  21. package/dist/features/aggregation/aggregationFeature.utils.cjs +36 -22
  22. package/dist/features/aggregation/aggregationFeature.utils.cjs.map +1 -1
  23. package/dist/features/aggregation/aggregationFeature.utils.d.cts +9 -8
  24. package/dist/features/aggregation/aggregationFeature.utils.d.ts +9 -8
  25. package/dist/features/aggregation/aggregationFeature.utils.js +36 -22
  26. package/dist/features/aggregation/aggregationFeature.utils.js.map +1 -1
  27. package/dist/features/aggregation/aggregationFns.cjs +35 -29
  28. package/dist/features/aggregation/aggregationFns.cjs.map +1 -1
  29. package/dist/features/aggregation/aggregationFns.d.cts +8 -7
  30. package/dist/features/aggregation/aggregationFns.d.ts +8 -7
  31. package/dist/features/aggregation/aggregationFns.js +35 -29
  32. package/dist/features/aggregation/aggregationFns.js.map +1 -1
  33. package/dist/features/column-grouping/createGroupedRowModel.cjs +3 -3
  34. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  35. package/dist/features/column-grouping/createGroupedRowModel.js +3 -3
  36. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  37. package/dist/index.d.cts +2 -2
  38. package/dist/index.d.ts +2 -2
  39. package/dist/static-functions.cjs +1 -0
  40. package/dist/static-functions.d.cts +2 -2
  41. package/dist/static-functions.d.ts +2 -2
  42. package/dist/static-functions.js +2 -2
  43. package/package.json +1 -1
  44. package/skills/aggregation/SKILL.md +25 -15
  45. package/skills/api-not-found/SKILL.md +1 -1
  46. package/skills/client-vs-server/SKILL.md +1 -1
  47. package/skills/column-faceting/SKILL.md +1 -1
  48. package/skills/column-filtering/SKILL.md +1 -1
  49. package/skills/column-ordering/SKILL.md +1 -1
  50. package/skills/column-pinning/SKILL.md +1 -1
  51. package/skills/column-resizing/SKILL.md +1 -1
  52. package/skills/column-sizing/SKILL.md +1 -1
  53. package/skills/column-visibility/SKILL.md +1 -1
  54. package/skills/core/SKILL.md +1 -1
  55. package/skills/custom-features/SKILL.md +1 -1
  56. package/skills/expanding/SKILL.md +1 -1
  57. package/skills/global-filtering/SKILL.md +1 -1
  58. package/skills/grouping/SKILL.md +1 -1
  59. package/skills/migrate-v8-to-v9/SKILL.md +11 -3
  60. package/skills/pagination/SKILL.md +1 -1
  61. package/skills/row-pinning/SKILL.md +1 -1
  62. package/skills/row-selection/SKILL.md +1 -1
  63. package/skills/sorting/SKILL.md +1 -1
  64. package/skills/table-features/SKILL.md +1 -1
  65. package/skills/typescript/SKILL.md +1 -1
  66. package/src/core/rows/coreRowsFeature.ts +5 -0
  67. package/src/core/rows/coreRowsFeature.types.ts +8 -0
  68. package/src/core/rows/coreRowsFeature.utils.ts +18 -0
  69. package/src/features/aggregation/aggregationFeature.ts +2 -1
  70. package/src/features/aggregation/aggregationFeature.types.ts +39 -12
  71. package/src/features/aggregation/aggregationFeature.utils.ts +56 -27
  72. package/src/features/aggregation/aggregationFns.ts +42 -33
  73. package/src/features/column-grouping/createGroupedRowModel.ts +3 -3
@@ -39,7 +39,11 @@ const coreRowsFeature = {
39
39
  ]
40
40
  },
41
41
  table_getRowId: { fn: (originalRow, index, parent) => require_coreRowsFeature_utils.table_getRowId(originalRow, table, index, parent) },
42
- table_getRow: { fn: (id, searchAll) => require_coreRowsFeature_utils.table_getRow(table, id, searchAll) }
42
+ table_getRow: { fn: (id, searchAll) => require_coreRowsFeature_utils.table_getRow(table, id, searchAll) },
43
+ table_getMaxSubRowDepth: {
44
+ fn: () => require_coreRowsFeature_utils.table_getMaxSubRowDepth(table),
45
+ memoDeps: () => [table.getCoreRowModel()]
46
+ }
43
47
  });
44
48
  }
45
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"coreRowsFeature.cjs","names":["row_getDisplayIndex","row_getAllCellsByColumnId","row_getAllCells","row_getLeafRows","row_getParentRow","row_getParentRows","row_getUniqueValues","row_getValue","row_renderValue","table_getRowsInDisplayOrder","table_getRowId","table_getRow"],"sources":["../../../src/core/rows/coreRowsFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n row_getAllCells,\n row_getAllCellsByColumnId,\n row_getDisplayIndex,\n row_getLeafRows,\n row_getParentRow,\n row_getParentRows,\n row_getUniqueValues,\n row_getValue,\n row_renderValue,\n table_getRow,\n table_getRowId,\n table_getRowsInDisplayOrder,\n} from './coreRowsFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Core feature that creates row APIs for values, cells, and tree traversal.\n */\nexport const coreRowsFeature: TableFeature = {\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreRowsFeature', prototype, table, {\n row_getDisplayIndex: {\n fn: (row) => row_getDisplayIndex(row),\n },\n row_getAllCellsByColumnId: {\n fn: (row) => row_getAllCellsByColumnId(row),\n memoDeps: (row) => [row.getAllCells()],\n },\n row_getAllCells: {\n fn: (row) => row_getAllCells(row),\n memoDeps: (row) => [row.table.getAllLeafColumns()],\n },\n row_getLeafRows: {\n fn: (row) => row_getLeafRows(row),\n memoDeps: (row) => [row.subRows],\n },\n row_getParentRow: {\n fn: (row) => row_getParentRow(row),\n },\n row_getParentRows: {\n fn: (row) => row_getParentRows(row),\n },\n row_getUniqueValues: {\n fn: (row, columnId) => row_getUniqueValues(row, columnId),\n },\n row_getValue: {\n fn: (row, columnId) => row_getValue(row, columnId),\n },\n row_renderValue: {\n fn: (row, columnId) => row_renderValue(row, columnId),\n },\n })\n },\n constructTableAPIs: (table) => {\n assignTableAPIs('coreRowsFeature', table, {\n table_getRowsInDisplayOrder: {\n fn: () => table_getRowsInDisplayOrder(table),\n memoDeps: () => [\n table.getPrePaginatedRowModel().rows,\n table.options.paginateExpandedRows,\n table.options.paginateExpandedRows === false\n ? table.atoms.expanded?.get()\n : undefined,\n ],\n },\n table_getRowId: {\n fn: (originalRow, index, parent) =>\n table_getRowId(originalRow, table, index, parent),\n },\n table_getRow: {\n fn: (id: string, searchAll?: boolean) =>\n table_getRow(table, id, searchAll),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoBA,MAAa,kBAAgC;CAC3C,qBAAqB,WAAW,UAAU;EACxC,kCAAoB,mBAAmB,WAAW,OAAO;GACvD,qBAAqB,EACnB,KAAK,QAAQA,kDAAoB,GAAG,EACtC;GACA,2BAA2B;IACzB,KAAK,QAAQC,wDAA0B,GAAG;IAC1C,WAAW,QAAQ,CAAC,IAAI,YAAY,CAAC;GACvC;GACA,iBAAiB;IACf,KAAK,QAAQC,8CAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,MAAM,kBAAkB,CAAC;GACnD;GACA,iBAAiB;IACf,KAAK,QAAQC,8CAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,OAAO;GACjC;GACA,kBAAkB,EAChB,KAAK,QAAQC,+CAAiB,GAAG,EACnC;GACA,mBAAmB,EACjB,KAAK,QAAQC,gDAAkB,GAAG,EACpC;GACA,qBAAqB,EACnB,KAAK,KAAK,aAAaC,kDAAoB,KAAK,QAAQ,EAC1D;GACA,cAAc,EACZ,KAAK,KAAK,aAAaC,2CAAa,KAAK,QAAQ,EACnD;GACA,iBAAiB,EACf,KAAK,KAAK,aAAaC,8CAAgB,KAAK,QAAQ,EACtD;EACF,CAAC;CACH;CACA,qBAAqB,UAAU;EAC7B,8BAAgB,mBAAmB,OAAO;GACxC,6BAA6B;IAC3B,UAAUC,0DAA4B,KAAK;IAC3C,gBAAgB;KACd,MAAM,wBAAwB,CAAC,CAAC;KAChC,MAAM,QAAQ;KACd,MAAM,QAAQ,yBAAyB,QACnC,MAAM,MAAM,UAAU,IAAI,IAC1B;IACN;GACF;GACA,gBAAgB,EACd,KAAK,aAAa,OAAO,WACvBC,6CAAe,aAAa,OAAO,OAAO,MAAM,EACpD;GACA,cAAc,EACZ,KAAK,IAAY,cACfC,2CAAa,OAAO,IAAI,SAAS,EACrC;EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"coreRowsFeature.cjs","names":["row_getDisplayIndex","row_getAllCellsByColumnId","row_getAllCells","row_getLeafRows","row_getParentRow","row_getParentRows","row_getUniqueValues","row_getValue","row_renderValue","table_getRowsInDisplayOrder","table_getRowId","table_getRow","table_getMaxSubRowDepth"],"sources":["../../../src/core/rows/coreRowsFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n row_getAllCells,\n row_getAllCellsByColumnId,\n row_getDisplayIndex,\n row_getLeafRows,\n row_getParentRow,\n row_getParentRows,\n row_getUniqueValues,\n row_getValue,\n row_renderValue,\n table_getMaxSubRowDepth,\n table_getRow,\n table_getRowId,\n table_getRowsInDisplayOrder,\n} from './coreRowsFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Core feature that creates row APIs for values, cells, and tree traversal.\n */\nexport const coreRowsFeature: TableFeature = {\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreRowsFeature', prototype, table, {\n row_getDisplayIndex: {\n fn: (row) => row_getDisplayIndex(row),\n },\n row_getAllCellsByColumnId: {\n fn: (row) => row_getAllCellsByColumnId(row),\n memoDeps: (row) => [row.getAllCells()],\n },\n row_getAllCells: {\n fn: (row) => row_getAllCells(row),\n memoDeps: (row) => [row.table.getAllLeafColumns()],\n },\n row_getLeafRows: {\n fn: (row) => row_getLeafRows(row),\n memoDeps: (row) => [row.subRows],\n },\n row_getParentRow: {\n fn: (row) => row_getParentRow(row),\n },\n row_getParentRows: {\n fn: (row) => row_getParentRows(row),\n },\n row_getUniqueValues: {\n fn: (row, columnId) => row_getUniqueValues(row, columnId),\n },\n row_getValue: {\n fn: (row, columnId) => row_getValue(row, columnId),\n },\n row_renderValue: {\n fn: (row, columnId) => row_renderValue(row, columnId),\n },\n })\n },\n constructTableAPIs: (table) => {\n assignTableAPIs('coreRowsFeature', table, {\n table_getRowsInDisplayOrder: {\n fn: () => table_getRowsInDisplayOrder(table),\n memoDeps: () => [\n table.getPrePaginatedRowModel().rows,\n table.options.paginateExpandedRows,\n table.options.paginateExpandedRows === false\n ? table.atoms.expanded?.get()\n : undefined,\n ],\n },\n table_getRowId: {\n fn: (originalRow, index, parent) =>\n table_getRowId(originalRow, table, index, parent),\n },\n table_getRow: {\n fn: (id: string, searchAll?: boolean) =>\n table_getRow(table, id, searchAll),\n },\n table_getMaxSubRowDepth: {\n fn: () => table_getMaxSubRowDepth(table),\n memoDeps: () => [table.getCoreRowModel()],\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAqBA,MAAa,kBAAgC;CAC3C,qBAAqB,WAAW,UAAU;EACxC,kCAAoB,mBAAmB,WAA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_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getRow, table_getRowId, table_getRowsInDisplayOrder } from "./coreRowsFeature.utils.js";
2
+ import { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getMaxSubRowDepth, table_getRow, table_getRowId, table_getRowsInDisplayOrder } from "./coreRowsFeature.utils.js";
3
3
 
4
4
  //#region src/core/rows/coreRowsFeature.ts
5
5
  /**
@@ -39,7 +39,11 @@ const coreRowsFeature = {
39
39
  ]
40
40
  },
41
41
  table_getRowId: { fn: (originalRow, index, parent) => table_getRowId(originalRow, table, index, parent) },
42
- table_getRow: { fn: (id, searchAll) => table_getRow(table, id, searchAll) }
42
+ table_getRow: { fn: (id, searchAll) => table_getRow(table, id, searchAll) },
43
+ table_getMaxSubRowDepth: {
44
+ fn: () => table_getMaxSubRowDepth(table),
45
+ memoDeps: () => [table.getCoreRowModel()]
46
+ }
43
47
  });
44
48
  }
45
49
  };
@@ -1 +1 @@
1
- {"version":3,"file":"coreRowsFeature.js","names":[],"sources":["../../../src/core/rows/coreRowsFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n row_getAllCells,\n row_getAllCellsByColumnId,\n row_getDisplayIndex,\n row_getLeafRows,\n row_getParentRow,\n row_getParentRows,\n row_getUniqueValues,\n row_getValue,\n row_renderValue,\n table_getRow,\n table_getRowId,\n table_getRowsInDisplayOrder,\n} from './coreRowsFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Core feature that creates row APIs for values, cells, and tree traversal.\n */\nexport const coreRowsFeature: TableFeature = {\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreRowsFeature', prototype, table, {\n row_getDisplayIndex: {\n fn: (row) => row_getDisplayIndex(row),\n },\n row_getAllCellsByColumnId: {\n fn: (row) => row_getAllCellsByColumnId(row),\n memoDeps: (row) => [row.getAllCells()],\n },\n row_getAllCells: {\n fn: (row) => row_getAllCells(row),\n memoDeps: (row) => [row.table.getAllLeafColumns()],\n },\n row_getLeafRows: {\n fn: (row) => row_getLeafRows(row),\n memoDeps: (row) => [row.subRows],\n },\n row_getParentRow: {\n fn: (row) => row_getParentRow(row),\n },\n row_getParentRows: {\n fn: (row) => row_getParentRows(row),\n },\n row_getUniqueValues: {\n fn: (row, columnId) => row_getUniqueValues(row, columnId),\n },\n row_getValue: {\n fn: (row, columnId) => row_getValue(row, columnId),\n },\n row_renderValue: {\n fn: (row, columnId) => row_renderValue(row, columnId),\n },\n })\n },\n constructTableAPIs: (table) => {\n assignTableAPIs('coreRowsFeature', table, {\n table_getRowsInDisplayOrder: {\n fn: () => table_getRowsInDisplayOrder(table),\n memoDeps: () => [\n table.getPrePaginatedRowModel().rows,\n table.options.paginateExpandedRows,\n table.options.paginateExpandedRows === false\n ? table.atoms.expanded?.get()\n : undefined,\n ],\n },\n table_getRowId: {\n fn: (originalRow, index, parent) =>\n table_getRowId(originalRow, table, index, parent),\n },\n table_getRow: {\n fn: (id: string, searchAll?: boolean) =>\n table_getRow(table, id, searchAll),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoBA,MAAa,kBAAgC;CAC3C,qBAAqB,WAAW,UAAU;EACxC,oBAAoB,mBAAmB,WAAW,OAAO;GACvD,qBAAqB,EACnB,KAAK,QAAQ,oBAAoB,GAAG,EACtC;GACA,2BAA2B;IACzB,KAAK,QAAQ,0BAA0B,GAAG;IAC1C,WAAW,QAAQ,CAAC,IAAI,YAAY,CAAC;GACvC;GACA,iBAAiB;IACf,KAAK,QAAQ,gBAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,MAAM,kBAAkB,CAAC;GACnD;GACA,iBAAiB;IACf,KAAK,QAAQ,gBAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,OAAO;GACjC;GACA,kBAAkB,EAChB,KAAK,QAAQ,iBAAiB,GAAG,EACnC;GACA,mBAAmB,EACjB,KAAK,QAAQ,kBAAkB,GAAG,EACpC;GACA,qBAAqB,EACnB,KAAK,KAAK,aAAa,oBAAoB,KAAK,QAAQ,EAC1D;GACA,cAAc,EACZ,KAAK,KAAK,aAAa,aAAa,KAAK,QAAQ,EACnD;GACA,iBAAiB,EACf,KAAK,KAAK,aAAa,gBAAgB,KAAK,QAAQ,EACtD;EACF,CAAC;CACH;CACA,qBAAqB,UAAU;EAC7B,gBAAgB,mBAAmB,OAAO;GACxC,6BAA6B;IAC3B,UAAU,4BAA4B,KAAK;IAC3C,gBAAgB;KACd,MAAM,wBAAwB,CAAC,CAAC;KAChC,MAAM,QAAQ;KACd,MAAM,QAAQ,yBAAyB,QACnC,MAAM,MAAM,UAAU,IAAI,IAC1B;IACN;GACF;GACA,gBAAgB,EACd,KAAK,aAAa,OAAO,WACvB,eAAe,aAAa,OAAO,OAAO,MAAM,EACpD;GACA,cAAc,EACZ,KAAK,IAAY,cACf,aAAa,OAAO,IAAI,SAAS,EACrC;EACF,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"coreRowsFeature.js","names":[],"sources":["../../../src/core/rows/coreRowsFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, assignTableAPIs } from '../../utils'\nimport {\n row_getAllCells,\n row_getAllCellsByColumnId,\n row_getDisplayIndex,\n row_getLeafRows,\n row_getParentRow,\n row_getParentRows,\n row_getUniqueValues,\n row_getValue,\n row_renderValue,\n table_getMaxSubRowDepth,\n table_getRow,\n table_getRowId,\n table_getRowsInDisplayOrder,\n} from './coreRowsFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Core feature that creates row APIs for values, cells, and tree traversal.\n */\nexport const coreRowsFeature: TableFeature = {\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('coreRowsFeature', prototype, table, {\n row_getDisplayIndex: {\n fn: (row) => row_getDisplayIndex(row),\n },\n row_getAllCellsByColumnId: {\n fn: (row) => row_getAllCellsByColumnId(row),\n memoDeps: (row) => [row.getAllCells()],\n },\n row_getAllCells: {\n fn: (row) => row_getAllCells(row),\n memoDeps: (row) => [row.table.getAllLeafColumns()],\n },\n row_getLeafRows: {\n fn: (row) => row_getLeafRows(row),\n memoDeps: (row) => [row.subRows],\n },\n row_getParentRow: {\n fn: (row) => row_getParentRow(row),\n },\n row_getParentRows: {\n fn: (row) => row_getParentRows(row),\n },\n row_getUniqueValues: {\n fn: (row, columnId) => row_getUniqueValues(row, columnId),\n },\n row_getValue: {\n fn: (row, columnId) => row_getValue(row, columnId),\n },\n row_renderValue: {\n fn: (row, columnId) => row_renderValue(row, columnId),\n },\n })\n },\n constructTableAPIs: (table) => {\n assignTableAPIs('coreRowsFeature', table, {\n table_getRowsInDisplayOrder: {\n fn: () => table_getRowsInDisplayOrder(table),\n memoDeps: () => [\n table.getPrePaginatedRowModel().rows,\n table.options.paginateExpandedRows,\n table.options.paginateExpandedRows === false\n ? table.atoms.expanded?.get()\n : undefined,\n ],\n },\n table_getRowId: {\n fn: (originalRow, index, parent) =>\n table_getRowId(originalRow, table, index, parent),\n },\n table_getRow: {\n fn: (id: string, searchAll?: boolean) =>\n table_getRow(table, id, searchAll),\n },\n table_getMaxSubRowDepth: {\n fn: () => table_getMaxSubRowDepth(table),\n memoDeps: () => [table.getCoreRowModel()],\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAqBA,MAAa,kBAAgC;CAC3C,qBAAqB,WAAW,UAAU;EACxC,oBAAoB,mBAAmB,WAAW,OAAO;GACvD,qBAAqB,EACnB,KAAK,QAAQ,oBAAoB,GAAG,EACtC;GACA,2BAA2B;IACzB,KAAK,QAAQ,0BAA0B,GAAG;IAC1C,WAAW,QAAQ,CAAC,IAAI,YAAY,CAAC;GACvC;GACA,iBAAiB;IACf,KAAK,QAAQ,gBAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,MAAM,kBAAkB,CAAC;GACnD;GACA,iBAAiB;IACf,KAAK,QAAQ,gBAAgB,GAAG;IAChC,WAAW,QAAQ,CAAC,IAAI,OAAO;GACjC;GACA,kBAAkB,EAChB,KAAK,QAAQ,iBAAiB,GAAG,EACnC;GACA,mBAAmB,EACjB,KAAK,QAAQ,kBAAkB,GAAG,EACpC;GACA,qBAAqB,EACnB,KAAK,KAAK,aAAa,oBAAoB,KAAK,QAAQ,EAC1D;GACA,cAAc,EACZ,KAAK,KAAK,aAAa,aAAa,KAAK,QAAQ,EACnD;GACA,iBAAiB,EACf,KAAK,KAAK,aAAa,gBAAgB,KAAK,QAAQ,EACtD;EACF,CAAC;CACH;CACA,qBAAqB,UAAU;EAC7B,gBAAgB,mBAAmB,OAAO;GACxC,6BAA6B;IAC3B,UAAU,4BAA4B,KAAK;IAC3C,gBAAgB;KACd,MAAM,wBAAwB,CAAC,CAAC;KAChC,MAAM,QAAQ;KACd,MAAM,QAAQ,yBAAyB,QACnC,MAAM,MAAM,UAAU,IAAI,IAC1B;IACN;GACF;GACA,gBAAgB,EACd,KAAK,aAAa,OAAO,WACvB,eAAe,aAAa,OAAO,OAAO,MAAM,EACpD;GACA,cAAc,EACZ,KAAK,IAAY,cACf,aAAa,OAAO,IAAI,SAAS,EACrC;GACA,yBAAyB;IACvB,UAAU,wBAAwB,KAAK;IACvC,gBAAgB,CAAC,MAAM,gBAAgB,CAAC;GAC1C;EACF,CAAC;CACH;AACF"}
@@ -107,6 +107,11 @@ interface TableOptions_Rows<in out TFeatures extends TableFeatures, in out TData
107
107
  getSubRows?: (originalRow: TData, index: number) => undefined | ReadonlyArray<TData>;
108
108
  }
109
109
  interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
110
+ /**
111
+ * Returns the deepest structural row depth in the core row model.
112
+ * Root rows are depth `0`, direct sub-rows are depth `1`, and so on.
113
+ */
114
+ getMaxSubRowDepth: () => number;
110
115
  /**
111
116
  * Returns the rows in the current display order and assigns their display
112
117
  * indexes. When expanded rows bypass pagination, expanded descendants are
@@ -114,6 +119,9 @@ interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extend
114
119
  * `row.getDisplayIndex()`.
115
120
  */
116
121
  getRowsInDisplayOrder: () => Array<Row<TFeatures, TData>>;
122
+ /**
123
+ * Returns the row id for a given row.
124
+ */
117
125
  getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string;
118
126
  /**
119
127
  * Returns the row with the given ID.
@@ -107,6 +107,11 @@ interface TableOptions_Rows<in out TFeatures extends TableFeatures, in out TData
107
107
  getSubRows?: (originalRow: TData, index: number) => undefined | ReadonlyArray<TData>;
108
108
  }
109
109
  interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extends RowData> {
110
+ /**
111
+ * Returns the deepest structural row depth in the core row model.
112
+ * Root rows are depth `0`, direct sub-rows are depth `1`, and so on.
113
+ */
114
+ getMaxSubRowDepth: () => number;
110
115
  /**
111
116
  * Returns the rows in the current display order and assigns their display
112
117
  * indexes. When expanded rows bypass pagination, expanded descendants are
@@ -114,6 +119,9 @@ interface Table_Rows<in out TFeatures extends TableFeatures, in out TData extend
114
119
  * `row.getDisplayIndex()`.
115
120
  */
116
121
  getRowsInDisplayOrder: () => Array<Row<TFeatures, TData>>;
122
+ /**
123
+ * Returns the row id for a given row.
124
+ */
117
125
  getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string;
118
126
  /**
119
127
  * Returns the row with the given ID.
@@ -102,6 +102,16 @@ function row_getLeafRows(row) {
102
102
  return require_utils.flattenBy(row.subRows, (d) => d.subRows);
103
103
  }
104
104
  /**
105
+ * Returns the deepest structural row depth in the core row model.
106
+ * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.
107
+ */
108
+ function table_getMaxSubRowDepth(table) {
109
+ const rows = table.getCoreRowModel().flatRows;
110
+ let maxDepth = 0;
111
+ for (let i = 0; i < rows.length; i++) maxDepth = Math.max(maxDepth, rows[i].depth);
112
+ return maxDepth;
113
+ }
114
+ /**
105
115
  * Looks up this row's direct parent, if it has one.
106
116
  *
107
117
  * Parent lookup searches the pre-pagination row model so parent relationships
@@ -229,6 +239,7 @@ exports.row_getParentRows = row_getParentRows;
229
239
  exports.row_getUniqueValues = row_getUniqueValues;
230
240
  exports.row_getValue = row_getValue;
231
241
  exports.row_renderValue = row_renderValue;
242
+ exports.table_getMaxSubRowDepth = table_getMaxSubRowDepth;
232
243
  exports.table_getRow = table_getRow;
233
244
  exports.table_getRowId = table_getRowId;
234
245
  exports.table_getRowsInDisplayOrder = table_getRowsInDisplayOrder;
@@ -1 +1 @@
1
- {"version":3,"file":"coreRowsFeature.utils.cjs","names":["hasOwn","flattenBy","constructCell","makeObjectMap"],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy, hasOwn, makeObjectMap } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Row_RowExpanding } from '../../features/row-expanding/rowExpandingFeature.types'\n\n/**\n * Returns this row's zero-based position in the current pre-pagination row\n * model. Rows outside that model return `-1`.\n */\nexport function row_getDisplayIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const rows = row.table.getRowsInDisplayOrder()\n const displayIndex = row._displayIndexCache\n\n return rows[displayIndex] === row ? displayIndex : -1\n}\n\n/**\n * Returns the rows in the current display order after assigning their\n * zero-based display indexes.\n *\n * When expanded rows bypass pagination, expanded descendants are inserted into\n * the returned order even though they are absent from the pre-pagination row\n * model.\n */\nexport function table_getRowsInDisplayOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rows = table.getPrePaginatedRowModel().rows\n\n if (table.options.paginateExpandedRows === false) {\n const displayRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n row._displayIndexCache = displayRows.length\n displayRows.push(row)\n\n if (\n row.subRows.length &&\n (\n row as Row<TFeatures, TData> & Partial<Row_RowExpanding>\n ).getIsExpanded?.()\n ) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rows.forEach(handleRow)\n\n return displayRows\n }\n\n for (let i = 0; i < rows.length; i++) {\n rows[i]!._displayIndexCache = i\n }\n\n return rows\n}\n\n/**\n * Reads and caches this row's value for a column.\n *\n * The value is produced by the column accessor. Missing columns or display\n * columns without an accessor return `undefined`.\n *\n * @example\n * ```ts\n * const firstName = row_getValue(row, 'firstName')\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._valuesCache, columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Reads and caches the values used by faceting/grouping for a column.\n *\n * If the column defines `getUniqueValues`, that result is used. Otherwise the\n * row's accessor value is wrapped in a single-item array.\n *\n * @example\n * ```ts\n * const values = row_getUniqueValues(row, 'tags')\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._uniqueValuesCache, columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row, 'firstName')\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Flattens this row's descendant tree into leaf rows.\n *\n * The row itself is not included; only nested `subRows` are walked.\n *\n * @example\n * ```ts\n * const descendants = row_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Looks up this row's direct parent, if it has one.\n *\n * Parent lookup searches the pre-pagination row model so parent relationships\n * are available even when the parent is not on the current page.\n *\n * @example\n * ```ts\n * const parent = row_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Collects this row's ancestor chain from root to direct parent.\n *\n * The current row is not included. Rows without a parent return an empty array.\n *\n * @example\n * ```ts\n * const ancestors = row_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Constructs one cell for each leaf column in this row.\n *\n * The result follows `table.getAllLeafColumns()` order and includes hidden\n * columns; visibility-specific APIs filter this list later.\n *\n * @example\n * ```ts\n * const cells = row_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const columns = row.table.getAllLeafColumns()\n // WeakMap so cells keyed by replaced column instances can be collected;\n // rows are memoized on data only and outlive column generations\n let cache = row._cellsCache\n if (!cache) {\n cache = row._cellsCache = new WeakMap()\n }\n const cells: Array<Cell<TFeatures, TData, unknown>> = new Array(\n columns.length,\n )\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n let cell = cache.get(column)\n if (!cell) {\n cell = constructCell(column, row, row.table)\n cache.set(column, cell)\n }\n cells[i] = cell\n }\n return cells\n}\n\n/**\n * Builds a lookup map of this row's cells keyed by column id.\n *\n * This is the static implementation behind `row.getAllCellsByColumnId()`.\n *\n * @example\n * ```ts\n * const cellsById = row_getAllCellsByColumnId(row)\n * ```\n */\nexport function row_getAllCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const result = makeObjectMap<Cell<TFeatures, TData, unknown>>()\n const cells = row.getAllCells()\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!\n result[cell.column.id] = cell\n }\n return result\n}\n\n/**\n * Resolves the stable id for a row.\n *\n * `options.getRowId` wins when provided. Otherwise root rows use their index\n * and child rows append their index to the parent id, such as `0.2`.\n *\n * @example\n * ```ts\n * const id = table_getRowId(originalRow, table, index, parentRow)\n * ```\n */\nexport function table_getRowId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n originalRow: TData,\n table: Table_Internal<TFeatures, TData>,\n index: number,\n parent?: Row<TFeatures, TData>,\n) {\n return (\n table.options.getRowId?.(originalRow, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`\n )\n}\n\n/**\n * Looks up a row by id from the current or full row model.\n *\n * By default this searches `table.getRowModel()`. Passing `searchAll` searches\n * the pre-pagination model first, then falls back to the core model.\n *\n * @example\n * ```ts\n * const row = table_getRow(table, rowId, true)\n * ```\n */\nexport function table_getRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n rowId: string,\n searchAll?: boolean,\n): Row<TFeatures, TData> {\n // TODO - simplify this across different row models\n let row = (searchAll ? table.getPrePaginatedRowModel() : table.getRowModel())\n .rowsById[rowId]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[rowId]\n if (!row) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(`getRow could not find row with ID: ${rowId}`)\n }\n throw new Error()\n }\n }\n\n return row\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,oBAGd,KAA4B;CAC5B,MAAM,OAAO,IAAI,MAAM,sBAAsB;CAC7C,MAAM,eAAe,IAAI;CAEzB,OAAO,KAAK,kBAAkB,MAAM,eAAe;AACrD;;;;;;;;;AAUA,SAAgB,4BAGd,OAAyC;CACzC,MAAM,OAAO,MAAM,wBAAwB,CAAC,CAAC;CAE7C,IAAI,MAAM,QAAQ,yBAAyB,OAAO;EAChD,MAAM,cAA4C,CAAC;EAEnD,MAAM,aAAa,QAA+B;GAChD,IAAI,qBAAqB,YAAY;GACrC,YAAY,KAAK,GAAG;GAEpB,IACE,IAAI,QAAQ,UAEV,IACA,gBAAgB,GAElB,IAAI,QAAQ,QAAQ,SAAS;EAEjC;EAEA,KAAK,QAAQ,SAAS;EAEtB,OAAO;CACT;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAC/B,KAAK,EAAE,CAAE,qBAAqB;CAGhC,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,aAGd,KAA4B,UAAkB;CAC9C,IAAIA,qBAAO,IAAI,cAAc,QAAQ,GACnC,OAAO,IAAI,aAAa;CAG1B,MAAM,SAAS,IAAI,MAAM,UAAU,QAAQ;CAE3C,IAAI,CAAC,QAAQ,YACX;CAGF,IAAI,aAAa,YAAY,OAAO,WAAW,IAAI,UAAU,IAAI,KAAK;CAEtE,OAAO,IAAI,aAAa;AAC1B;;;;;;;;;;;;AAaA,SAAgB,oBAGd,KAA4B,UAAkB;CAC9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AAM,IAAI,MAAM;EAC3B,IAAI,CAAC,MAAM;GACT,OAAOC,oCAAc,QAAQ,KAAK,IAAI,KAAK;GAC3C,MAAM,IAAI,QAAQ,IAAI;EACxB;EACA,MAAM,KAAK;CACb;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,0BAGd,KAA4B;CAC5B,MAAM,SAASC,4BAA+C;CAC9D,MAAM,QAAQ,IAAI,YAAY;CAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EACnB,OAAO,KAAK,OAAO,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,eAId,aACA,OACA,OACA,QACA;CACA,OACE,MAAM,QAAQ,WAAW,aAAa,OAAO,MAAM,KACnD,GAAG,SAAS,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI;AAE/C;;;;;;;;;;;;AAaA,SAAgB,aAId,OACA,OACA,WACuB;CAEvB,IAAI,OAAO,YAAY,MAAM,wBAAwB,IAAI,MAAM,YAAY,EAAC,CACzE,SAAS;CAEZ,IAAI,CAAC,KAAK;EACR,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS;EACvC,IAAI,CAAC,KAAK;GACR,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MAAM,sCAAsC,OAAO;GAE/D,MAAM,IAAI,MAAM;EAClB;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"coreRowsFeature.utils.cjs","names":["hasOwn","flattenBy","constructCell","makeObjectMap"],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy, hasOwn, makeObjectMap } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Row_RowExpanding } from '../../features/row-expanding/rowExpandingFeature.types'\n\n/**\n * Returns this row's zero-based position in the current pre-pagination row\n * model. Rows outside that model return `-1`.\n */\nexport function row_getDisplayIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const rows = row.table.getRowsInDisplayOrder()\n const displayIndex = row._displayIndexCache\n\n return rows[displayIndex] === row ? displayIndex : -1\n}\n\n/**\n * Returns the rows in the current display order after assigning their\n * zero-based display indexes.\n *\n * When expanded rows bypass pagination, expanded descendants are inserted into\n * the returned order even though they are absent from the pre-pagination row\n * model.\n */\nexport function table_getRowsInDisplayOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rows = table.getPrePaginatedRowModel().rows\n\n if (table.options.paginateExpandedRows === false) {\n const displayRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n row._displayIndexCache = displayRows.length\n displayRows.push(row)\n\n if (\n row.subRows.length &&\n (\n row as Row<TFeatures, TData> & Partial<Row_RowExpanding>\n ).getIsExpanded?.()\n ) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rows.forEach(handleRow)\n\n return displayRows\n }\n\n for (let i = 0; i < rows.length; i++) {\n rows[i]!._displayIndexCache = i\n }\n\n return rows\n}\n\n/**\n * Reads and caches this row's value for a column.\n *\n * The value is produced by the column accessor. Missing columns or display\n * columns without an accessor return `undefined`.\n *\n * @example\n * ```ts\n * const firstName = row_getValue(row, 'firstName')\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._valuesCache, columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Reads and caches the values used by faceting/grouping for a column.\n *\n * If the column defines `getUniqueValues`, that result is used. Otherwise the\n * row's accessor value is wrapped in a single-item array.\n *\n * @example\n * ```ts\n * const values = row_getUniqueValues(row, 'tags')\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._uniqueValuesCache, columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row, 'firstName')\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Flattens this row's descendant tree into leaf rows.\n *\n * The row itself is not included; only nested `subRows` are walked.\n *\n * @example\n * ```ts\n * const descendants = row_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Returns the deepest structural row depth in the core row model.\n * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.\n */\nexport function table_getMaxSubRowDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): number {\n const rows = table.getCoreRowModel().flatRows\n let maxDepth = 0\n\n for (let i = 0; i < rows.length; i++) {\n maxDepth = Math.max(maxDepth, rows[i]!.depth)\n }\n\n return maxDepth\n}\n\n/**\n * Looks up this row's direct parent, if it has one.\n *\n * Parent lookup searches the pre-pagination row model so parent relationships\n * are available even when the parent is not on the current page.\n *\n * @example\n * ```ts\n * const parent = row_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Collects this row's ancestor chain from root to direct parent.\n *\n * The current row is not included. Rows without a parent return an empty array.\n *\n * @example\n * ```ts\n * const ancestors = row_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Constructs one cell for each leaf column in this row.\n *\n * The result follows `table.getAllLeafColumns()` order and includes hidden\n * columns; visibility-specific APIs filter this list later.\n *\n * @example\n * ```ts\n * const cells = row_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const columns = row.table.getAllLeafColumns()\n // WeakMap so cells keyed by replaced column instances can be collected;\n // rows are memoized on data only and outlive column generations\n let cache = row._cellsCache\n if (!cache) {\n cache = row._cellsCache = new WeakMap()\n }\n const cells: Array<Cell<TFeatures, TData, unknown>> = new Array(\n columns.length,\n )\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n let cell = cache.get(column)\n if (!cell) {\n cell = constructCell(column, row, row.table)\n cache.set(column, cell)\n }\n cells[i] = cell\n }\n return cells\n}\n\n/**\n * Builds a lookup map of this row's cells keyed by column id.\n *\n * This is the static implementation behind `row.getAllCellsByColumnId()`.\n *\n * @example\n * ```ts\n * const cellsById = row_getAllCellsByColumnId(row)\n * ```\n */\nexport function row_getAllCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const result = makeObjectMap<Cell<TFeatures, TData, unknown>>()\n const cells = row.getAllCells()\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!\n result[cell.column.id] = cell\n }\n return result\n}\n\n/**\n * Resolves the stable id for a row.\n *\n * `options.getRowId` wins when provided. Otherwise root rows use their index\n * and child rows append their index to the parent id, such as `0.2`.\n *\n * @example\n * ```ts\n * const id = table_getRowId(originalRow, table, index, parentRow)\n * ```\n */\nexport function table_getRowId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n originalRow: TData,\n table: Table_Internal<TFeatures, TData>,\n index: number,\n parent?: Row<TFeatures, TData>,\n) {\n return (\n table.options.getRowId?.(originalRow, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`\n )\n}\n\n/**\n * Looks up a row by id from the current or full row model.\n *\n * By default this searches `table.getRowModel()`. Passing `searchAll` searches\n * the pre-pagination model first, then falls back to the core model.\n *\n * @example\n * ```ts\n * const row = table_getRow(table, rowId, true)\n * ```\n */\nexport function table_getRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n rowId: string,\n searchAll?: boolean,\n): Row<TFeatures, TData> {\n // TODO - simplify this across different row models\n let row = (searchAll ? table.getPrePaginatedRowModel() : table.getRowModel())\n .rowsById[rowId]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[rowId]\n if (!row) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(`getRow could not find row with ID: ${rowId}`)\n }\n throw new Error()\n }\n }\n\n return row\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,oBAGd,KAA4B;CAC5B,MAAM,OAAO,IAAI,MAAM,sBAAsB;CAC7C,MAAM,eAAe,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AYA,SAAgB,0BAGd,KAA4B;CAC5B,MAAM,SAASC,4BAA+C;CAC9D,MAAM,QAAQ,IAAI,YAAY;CAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EACnB,OAAO,KAAK,OAAO,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,eAId,aACA,OACA,OACA,QACA;CACA,OACE,MAAM,QAAQ,WAAW,aAAa,OAAO,MAAM,KACnD,GAAG,SAAS,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI;AAE/C;;;;;;;;;;;;AAaA,SAAgB,aAId,OACA,OACA,WACuB;CAEvB,IAAI,OAAO,YAAY,MAAM,wBAAwB,IAAI,MAAM,YAAY,EAAC,CACzE,SAAS;CAEZ,IAAI,CAAC,KAAK;EACR,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS;EACvC,IAAI,CAAC,KAAK;GACR,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MAAM,sCAAsC,OAAO;GAE/D,MAAM,IAAI,MAAM;EAClB;CACF;CAEA,OAAO;AACT"}
@@ -66,6 +66,11 @@ declare function row_renderValue<TFeatures extends TableFeatures, TData extends
66
66
  * ```
67
67
  */
68
68
  declare function row_getLeafRows<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>>;
69
+ /**
70
+ * Returns the deepest structural row depth in the core row model.
71
+ * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.
72
+ */
73
+ declare function table_getMaxSubRowDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
69
74
  /**
70
75
  * Looks up this row's direct parent, if it has one.
71
76
  *
@@ -137,5 +142,5 @@ declare function table_getRowId<TFeatures extends TableFeatures, TData extends R
137
142
  */
138
143
  declare function table_getRow<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, rowId: string, searchAll?: boolean): Row<TFeatures, TData>;
139
144
  //#endregion
140
- export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
145
+ export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getMaxSubRowDepth, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
141
146
  //# sourceMappingURL=coreRowsFeature.utils.d.cts.map
@@ -66,6 +66,11 @@ declare function row_renderValue<TFeatures extends TableFeatures, TData extends
66
66
  * ```
67
67
  */
68
68
  declare function row_getLeafRows<TFeatures extends TableFeatures, TData extends RowData>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>>;
69
+ /**
70
+ * Returns the deepest structural row depth in the core row model.
71
+ * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.
72
+ */
73
+ declare function table_getMaxSubRowDepth<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>): number;
69
74
  /**
70
75
  * Looks up this row's direct parent, if it has one.
71
76
  *
@@ -137,5 +142,5 @@ declare function table_getRowId<TFeatures extends TableFeatures, TData extends R
137
142
  */
138
143
  declare function table_getRow<TFeatures extends TableFeatures, TData extends RowData>(table: Table<TFeatures, TData>, rowId: string, searchAll?: boolean): Row<TFeatures, TData>;
139
144
  //#endregion
140
- export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
145
+ export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getMaxSubRowDepth, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
141
146
  //# sourceMappingURL=coreRowsFeature.utils.d.ts.map
@@ -102,6 +102,16 @@ function row_getLeafRows(row) {
102
102
  return flattenBy(row.subRows, (d) => d.subRows);
103
103
  }
104
104
  /**
105
+ * Returns the deepest structural row depth in the core row model.
106
+ * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.
107
+ */
108
+ function table_getMaxSubRowDepth(table) {
109
+ const rows = table.getCoreRowModel().flatRows;
110
+ let maxDepth = 0;
111
+ for (let i = 0; i < rows.length; i++) maxDepth = Math.max(maxDepth, rows[i].depth);
112
+ return maxDepth;
113
+ }
114
+ /**
105
115
  * Looks up this row's direct parent, if it has one.
106
116
  *
107
117
  * Parent lookup searches the pre-pagination row model so parent relationships
@@ -220,5 +230,5 @@ function table_getRow(table, rowId, searchAll) {
220
230
  }
221
231
 
222
232
  //#endregion
223
- export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
233
+ export { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getMaxSubRowDepth, table_getRow, table_getRowId, table_getRowsInDisplayOrder };
224
234
  //# sourceMappingURL=coreRowsFeature.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coreRowsFeature.utils.js","names":[],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy, hasOwn, makeObjectMap } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Row_RowExpanding } from '../../features/row-expanding/rowExpandingFeature.types'\n\n/**\n * Returns this row's zero-based position in the current pre-pagination row\n * model. Rows outside that model return `-1`.\n */\nexport function row_getDisplayIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const rows = row.table.getRowsInDisplayOrder()\n const displayIndex = row._displayIndexCache\n\n return rows[displayIndex] === row ? displayIndex : -1\n}\n\n/**\n * Returns the rows in the current display order after assigning their\n * zero-based display indexes.\n *\n * When expanded rows bypass pagination, expanded descendants are inserted into\n * the returned order even though they are absent from the pre-pagination row\n * model.\n */\nexport function table_getRowsInDisplayOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rows = table.getPrePaginatedRowModel().rows\n\n if (table.options.paginateExpandedRows === false) {\n const displayRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n row._displayIndexCache = displayRows.length\n displayRows.push(row)\n\n if (\n row.subRows.length &&\n (\n row as Row<TFeatures, TData> & Partial<Row_RowExpanding>\n ).getIsExpanded?.()\n ) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rows.forEach(handleRow)\n\n return displayRows\n }\n\n for (let i = 0; i < rows.length; i++) {\n rows[i]!._displayIndexCache = i\n }\n\n return rows\n}\n\n/**\n * Reads and caches this row's value for a column.\n *\n * The value is produced by the column accessor. Missing columns or display\n * columns without an accessor return `undefined`.\n *\n * @example\n * ```ts\n * const firstName = row_getValue(row, 'firstName')\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._valuesCache, columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Reads and caches the values used by faceting/grouping for a column.\n *\n * If the column defines `getUniqueValues`, that result is used. Otherwise the\n * row's accessor value is wrapped in a single-item array.\n *\n * @example\n * ```ts\n * const values = row_getUniqueValues(row, 'tags')\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._uniqueValuesCache, columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row, 'firstName')\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Flattens this row's descendant tree into leaf rows.\n *\n * The row itself is not included; only nested `subRows` are walked.\n *\n * @example\n * ```ts\n * const descendants = row_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Looks up this row's direct parent, if it has one.\n *\n * Parent lookup searches the pre-pagination row model so parent relationships\n * are available even when the parent is not on the current page.\n *\n * @example\n * ```ts\n * const parent = row_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Collects this row's ancestor chain from root to direct parent.\n *\n * The current row is not included. Rows without a parent return an empty array.\n *\n * @example\n * ```ts\n * const ancestors = row_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Constructs one cell for each leaf column in this row.\n *\n * The result follows `table.getAllLeafColumns()` order and includes hidden\n * columns; visibility-specific APIs filter this list later.\n *\n * @example\n * ```ts\n * const cells = row_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const columns = row.table.getAllLeafColumns()\n // WeakMap so cells keyed by replaced column instances can be collected;\n // rows are memoized on data only and outlive column generations\n let cache = row._cellsCache\n if (!cache) {\n cache = row._cellsCache = new WeakMap()\n }\n const cells: Array<Cell<TFeatures, TData, unknown>> = new Array(\n columns.length,\n )\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n let cell = cache.get(column)\n if (!cell) {\n cell = constructCell(column, row, row.table)\n cache.set(column, cell)\n }\n cells[i] = cell\n }\n return cells\n}\n\n/**\n * Builds a lookup map of this row's cells keyed by column id.\n *\n * This is the static implementation behind `row.getAllCellsByColumnId()`.\n *\n * @example\n * ```ts\n * const cellsById = row_getAllCellsByColumnId(row)\n * ```\n */\nexport function row_getAllCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const result = makeObjectMap<Cell<TFeatures, TData, unknown>>()\n const cells = row.getAllCells()\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!\n result[cell.column.id] = cell\n }\n return result\n}\n\n/**\n * Resolves the stable id for a row.\n *\n * `options.getRowId` wins when provided. Otherwise root rows use their index\n * and child rows append their index to the parent id, such as `0.2`.\n *\n * @example\n * ```ts\n * const id = table_getRowId(originalRow, table, index, parentRow)\n * ```\n */\nexport function table_getRowId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n originalRow: TData,\n table: Table_Internal<TFeatures, TData>,\n index: number,\n parent?: Row<TFeatures, TData>,\n) {\n return (\n table.options.getRowId?.(originalRow, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`\n )\n}\n\n/**\n * Looks up a row by id from the current or full row model.\n *\n * By default this searches `table.getRowModel()`. Passing `searchAll` searches\n * the pre-pagination model first, then falls back to the core model.\n *\n * @example\n * ```ts\n * const row = table_getRow(table, rowId, true)\n * ```\n */\nexport function table_getRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n rowId: string,\n searchAll?: boolean,\n): Row<TFeatures, TData> {\n // TODO - simplify this across different row models\n let row = (searchAll ? table.getPrePaginatedRowModel() : table.getRowModel())\n .rowsById[rowId]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[rowId]\n if (!row) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(`getRow could not find row with ID: ${rowId}`)\n }\n throw new Error()\n }\n }\n\n return row\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,oBAGd,KAA4B;CAC5B,MAAM,OAAO,IAAI,MAAM,sBAAsB;CAC7C,MAAM,eAAe,IAAI;CAEzB,OAAO,KAAK,kBAAkB,MAAM,eAAe;AACrD;;;;;;;;;AAUA,SAAgB,4BAGd,OAAyC;CACzC,MAAM,OAAO,MAAM,wBAAwB,CAAC,CAAC;CAE7C,IAAI,MAAM,QAAQ,yBAAyB,OAAO;EAChD,MAAM,cAA4C,CAAC;EAEnD,MAAM,aAAa,QAA+B;GAChD,IAAI,qBAAqB,YAAY;GACrC,YAAY,KAAK,GAAG;GAEpB,IACE,IAAI,QAAQ,UAEV,IACA,gBAAgB,GAElB,IAAI,QAAQ,QAAQ,SAAS;EAEjC;E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vC,IAAI,CAAC,KAAK;GACR,IAAI,QAAQ,IAAI,aAAa,eAC3B,MAAM,IAAI,MAAM,sCAAsC,OAAO;GAE/D,MAAM,IAAI,MAAM;EAClB;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"coreRowsFeature.utils.js","names":[],"sources":["../../../src/core/rows/coreRowsFeature.utils.ts"],"sourcesContent":["import { flattenBy, hasOwn, makeObjectMap } from '../../utils'\nimport { constructCell } from '../cells/constructCell'\nimport type { Table_Internal } from '../../types/Table'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type { Row_RowExpanding } from '../../features/row-expanding/rowExpandingFeature.types'\n\n/**\n * Returns this row's zero-based position in the current pre-pagination row\n * model. Rows outside that model return `-1`.\n */\nexport function row_getDisplayIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const rows = row.table.getRowsInDisplayOrder()\n const displayIndex = row._displayIndexCache\n\n return rows[displayIndex] === row ? displayIndex : -1\n}\n\n/**\n * Returns the rows in the current display order after assigning their\n * zero-based display indexes.\n *\n * When expanded rows bypass pagination, expanded descendants are inserted into\n * the returned order even though they are absent from the pre-pagination row\n * model.\n */\nexport function table_getRowsInDisplayOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const rows = table.getPrePaginatedRowModel().rows\n\n if (table.options.paginateExpandedRows === false) {\n const displayRows: Array<Row<TFeatures, TData>> = []\n\n const handleRow = (row: Row<TFeatures, TData>) => {\n row._displayIndexCache = displayRows.length\n displayRows.push(row)\n\n if (\n row.subRows.length &&\n (\n row as Row<TFeatures, TData> & Partial<Row_RowExpanding>\n ).getIsExpanded?.()\n ) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rows.forEach(handleRow)\n\n return displayRows\n }\n\n for (let i = 0; i < rows.length; i++) {\n rows[i]!._displayIndexCache = i\n }\n\n return rows\n}\n\n/**\n * Reads and caches this row's value for a column.\n *\n * The value is produced by the column accessor. Missing columns or display\n * columns without an accessor return `undefined`.\n *\n * @example\n * ```ts\n * const firstName = row_getValue(row, 'firstName')\n * ```\n */\nexport function row_getValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._valuesCache, columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(row.original, row.index)\n\n return row._valuesCache[columnId]\n}\n\n/**\n * Reads and caches the values used by faceting/grouping for a column.\n *\n * If the column defines `getUniqueValues`, that result is used. Otherwise the\n * row's accessor value is wrapped in a single-item array.\n *\n * @example\n * ```ts\n * const values = row_getUniqueValues(row, 'tags')\n * ```\n */\nexport function row_getUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n if (hasOwn(row._uniqueValuesCache, columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original,\n row.index,\n )\n\n return row._uniqueValuesCache[columnId]\n}\n\n/**\n * Returns a renderable row value for a column.\n *\n * If the accessor value is nullish, the table's `renderFallbackValue` is used\n * instead.\n *\n * @example\n * ```ts\n * const value = row_renderValue(row, 'firstName')\n * ```\n */\nexport function row_renderValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>, columnId: string) {\n return row.getValue(columnId) ?? row.table.options.renderFallbackValue\n}\n\n/**\n * Flattens this row's descendant tree into leaf rows.\n *\n * The row itself is not included; only nested `subRows` are walked.\n *\n * @example\n * ```ts\n * const descendants = row_getLeafRows(row)\n * ```\n */\nexport function row_getLeafRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Row<TFeatures, TData>> {\n return flattenBy(row.subRows, (d) => d.subRows)\n}\n\n/**\n * Returns the deepest structural row depth in the core row model.\n * Root rows are depth `0`, their direct sub-rows are depth `1`, and so on.\n */\nexport function table_getMaxSubRowDepth<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>): number {\n const rows = table.getCoreRowModel().flatRows\n let maxDepth = 0\n\n for (let i = 0; i < rows.length; i++) {\n maxDepth = Math.max(maxDepth, rows[i]!.depth)\n }\n\n return maxDepth\n}\n\n/**\n * Looks up this row's direct parent, if it has one.\n *\n * Parent lookup searches the pre-pagination row model so parent relationships\n * are available even when the parent is not on the current page.\n *\n * @example\n * ```ts\n * const parent = row_getParentRow(row)\n * ```\n */\nexport function row_getParentRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n return row.parentId ? row.table.getRow(row.parentId, true) : undefined\n}\n\n/**\n * Collects this row's ancestor chain from root to direct parent.\n *\n * The current row is not included. Rows without a parent return an empty array.\n *\n * @example\n * ```ts\n * const ancestors = row_getParentRows(row)\n * ```\n */\nexport function row_getParentRows<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const parentRows: Array<Row<TFeatures, TData>> = []\n let currentRow = row\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n}\n\n/**\n * Constructs one cell for each leaf column in this row.\n *\n * The result follows `table.getAllLeafColumns()` order and includes hidden\n * columns; visibility-specific APIs filter this list later.\n *\n * @example\n * ```ts\n * const cells = row_getAllCells(row)\n * ```\n */\nexport function row_getAllCells<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>): Array<Cell<TFeatures, TData, unknown>> {\n const columns = row.table.getAllLeafColumns()\n // WeakMap so cells keyed by replaced column instances can be collected;\n // rows are memoized on data only and outlive column generations\n let cache = row._cellsCache\n if (!cache) {\n cache = row._cellsCache = new WeakMap()\n }\n const cells: Array<Cell<TFeatures, TData, unknown>> = new Array(\n columns.length,\n )\n for (let i = 0; i < columns.length; i++) {\n const column = columns[i]!\n let cell = cache.get(column)\n if (!cell) {\n cell = constructCell(column, row, row.table)\n cache.set(column, cell)\n }\n cells[i] = cell\n }\n return cells\n}\n\n/**\n * Builds a lookup map of this row's cells keyed by column id.\n *\n * This is the static implementation behind `row.getAllCellsByColumnId()`.\n *\n * @example\n * ```ts\n * const cellsById = row_getAllCellsByColumnId(row)\n * ```\n */\nexport function row_getAllCellsByColumnId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData>) {\n const result = makeObjectMap<Cell<TFeatures, TData, unknown>>()\n const cells = row.getAllCells()\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!\n result[cell.column.id] = cell\n }\n return result\n}\n\n/**\n * Resolves the stable id for a row.\n *\n * `options.getRowId` wins when provided. Otherwise root rows use their index\n * and child rows append their index to the parent id, such as `0.2`.\n *\n * @example\n * ```ts\n * const id = table_getRowId(originalRow, table, index, parentRow)\n * ```\n */\nexport function table_getRowId<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n originalRow: TData,\n table: Table_Internal<TFeatures, TData>,\n index: number,\n parent?: Row<TFeatures, TData>,\n) {\n return (\n table.options.getRowId?.(originalRow, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`\n )\n}\n\n/**\n * Looks up a row by id from the current or full row model.\n *\n * By default this searches `table.getRowModel()`. Passing `searchAll` searches\n * the pre-pagination model first, then falls back to the core model.\n *\n * @example\n * ```ts\n * const row = table_getRow(table, rowId, true)\n * ```\n */\nexport function table_getRow<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n rowId: string,\n searchAll?: boolean,\n): Row<TFeatures, TData> {\n // TODO - simplify this across different row models\n let row = (searchAll ? table.getPrePaginatedRowModel() : table.getRowModel())\n .rowsById[rowId]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[rowId]\n if (!row) {\n if (process.env.NODE_ENV === 'development') {\n throw new Error(`getRow could not find row with ID: ${rowId}`)\n }\n throw new Error()\n }\n }\n\n return row\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,oBAGd,KAA4B;CAC5B,MAAM,OAAO,IAAI,MAAM,sBAAsB;CAC7C,MAAM,eAAe,IAAI;CAEzB,OAAO,KAAK,kBAAkB,MAAM,eAAe;AACrD;;;;;;;;;AAUA,SAAgB,4BAGd,OAAyC;CACzC,MAAM,OAAO,MAAM,wBAAwB,CAAC,CAAC;CAE7C,IAAI,MAAM,QAAQ,yBAAyB,OAAO;EAChD,MAAM,cAA4C,CAAC;EAEnD,MAAM,aAAa,QAA+B;GAChD,IAAI,qBAAqB,YAAY;GACrC,YAAY,KAAK,GAAG;GAEpB,IACE,IAAI,QAAQ,UAEV,IACA,gBAAgB,GAElB,IAAI,QAAQ,QAAQ,SAAS;EAEjC;EAEA,KAAK,QAAQ,SAAS;EAEtB,OAAO;CACT;CAEA,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAC/B,KAAK,EAAE,CAAE,qBAAqB;CAGhC,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,aAGd,KAA4B,UAAkB;CAC9C,IAAI,OAAO,IAAI,cAAc,QAAQ,GACnC,OAAO,IAAI,aAAa;CAG1B,MAAM,SAAS,IAAI,MAAM,UAAU,QAAQ;CAE3C,IAAI,CAAC,QAAQ,YACX;CAGF,IAAI,aAAa,YAAY,OAAO,WAAW,IAAI,UAAU,IAAI,KAAK;CAEtE,OAAO,IAAI,aAAa;AAC1B;;;;;;;;;;;;AA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ature = {
9
9
  getDefaultColumnDef: () => ({
10
10
  aggregatedCell: ({ column, getValue }) => require_aggregationFeature_utils.formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),
11
- aggregationFn: "auto"
11
+ aggregationFn: "auto",
12
+ maxAggregationDepth: 0
12
13
  }),
13
14
  getDefaultTableOptions: () => ({ manualAggregation: false }),
14
15
  assignCellPrototype: (prototype, table) => {
@@ -17,7 +18,7 @@ const aggregationFeature = {
17
18
  assignColumnPrototype: (prototype, table) => {
18
19
  require_utils.assignPrototypeAPIs("aggregationFeature", prototype, table, {
19
20
  column_getAggregationFns: { fn: (column) => require_aggregationFeature_utils.column_getAggregationFns(column) },
20
- column_getAggregationValue: { fn: (column, rows) => require_aggregationFeature_utils.column_getAggregationValue(column, rows) },
21
+ column_getAggregationValue: { fn: (column, options) => require_aggregationFeature_utils.column_getAggregationValue(column, options) },
21
22
  column_getAutoAggregationFn: {
22
23
  fn: (column) => require_aggregationFeature_utils.column_getAutoAggregationFn(column),
23
24
  memoDeps: (column) => [column.table.getCoreRowModel(), column.table._rowModelFns.aggregationFns]
@@ -1 +1 @@
1
- {"version":3,"file":"aggregationFeature.cjs","names":["formatAggregatedCellValue","cell_getIsAggregated","column_getAggregationFns","column_getAggregationValue","column_getAutoAggregationFn","makeObjectMap"],"sources":["../../../src/features/aggregation/aggregationFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, makeObjectMap } from '../../utils'\nimport {\n cell_getIsAggregated,\n column_getAggregationFns,\n column_getAggregationValue,\n column_getAutoAggregationFn,\n formatAggregatedCellValue,\n} from './aggregationFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Independent aggregation feature for grouped values and root/custom-row totals.\n */\nexport const aggregationFeature: TableFeature = {\n getDefaultColumnDef: () => ({\n aggregatedCell: ({ column, getValue }: any) =>\n formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),\n aggregationFn: 'auto',\n }),\n\n getDefaultTableOptions: () => ({\n manualAggregation: false,\n }),\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n column_getAggregationFns: {\n fn: (column) => column_getAggregationFns(column),\n },\n column_getAggregationValue: {\n fn: (column, rows) => column_getAggregationValue(column, rows),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n memoDeps: (column) => [\n column.table.getCoreRowModel(),\n column.table._rowModelFns.aggregationFns,\n ],\n },\n })\n },\n\n initColumnInstanceData: (column) => {\n ;(column as any)._aggregationValueCache = undefined\n ;(column as any)._resolvedAggregationFnsCache = undefined\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._aggregationValuesCache = makeObjectMap()\n },\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBAAmC;CAC9C,4BAA4B;EAC1B,iBAAiB,EAAE,QAAQ,eACzBA,2DAA0B,SAAS,GAAG,OAAO,UAAU,aAAa;EACtE,eAAe;CACjB;CAEA,+BAA+B,EAC7B,mBAAmB,MACrB;CAEA,sBAAsB,WAAW,UAAU;EACzC,kCAAoB,sBAAsB,WAAW,OAAO,EAC1D,sBAAsB,EACpB,KAAK,SAASC,sDAAqB,IAAI,EACzC,EACF,CAAC;CACH;CAEA,wBAAwB,WAAW,UAAU;EAC3C,kCAAoB,sBAAsB,WAAW,OAAO;GAC1D,0BAA0B,EACxB,KAAK,WAAWC,0DAAyB,MAAM,EACjD;GACA,4BAA4B,EAC1B,KAAK,QAAQ,SAASC,4DAA2B,QAAQ,IAAI,EAC/D;GACA,6BAA6B;IAC3B,KAAK,WAAWC,6DAA4B,MAAM;IAClD,WAAW,WAAW,CACpB,OAAO,MAAM,gBAAgB,GAC7B,OAAO,MAAM,aAAa,cAC5B;GACF;EACF,CAAC;CACH;CAEA,yBAAyB,WAAW;EACjC,AAAC,OAAe,yBAAyB;EACzC,AAAC,OAAe,+BAA+B;CAClD;CAEA,sBAAsB,QAAQ;EAC3B,AAAC,IAAY,0BAA0BC,4BAAc;CACxD;AACF"}
1
+ {"version":3,"file":"aggregationFeature.cjs","names":["formatAggregatedCellValue","cell_getIsAggregated","column_getAggregationFns","column_getAggregationValue","column_getAutoAggregationFn","makeObjectMap"],"sources":["../../../src/features/aggregation/aggregationFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, makeObjectMap } from '../../utils'\nimport {\n cell_getIsAggregated,\n column_getAggregationFns,\n column_getAggregationValue,\n column_getAutoAggregationFn,\n formatAggregatedCellValue,\n} from './aggregationFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Independent aggregation feature for grouped values and root/custom-row totals.\n */\nexport const aggregationFeature: TableFeature = {\n getDefaultColumnDef: () => ({\n aggregatedCell: ({ column, getValue }: any) =>\n formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),\n aggregationFn: 'auto',\n maxAggregationDepth: 0,\n }),\n\n getDefaultTableOptions: () => ({\n manualAggregation: false,\n }),\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n column_getAggregationFns: {\n fn: (column) => column_getAggregationFns(column),\n },\n column_getAggregationValue: {\n fn: (column, options) => column_getAggregationValue(column, options),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n memoDeps: (column) => [\n column.table.getCoreRowModel(),\n column.table._rowModelFns.aggregationFns,\n ],\n },\n })\n },\n\n initColumnInstanceData: (column) => {\n ;(column as any)._aggregationValueCache = undefined\n ;(column as any)._resolvedAggregationFnsCache = undefined\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._aggregationValuesCache = makeObjectMap()\n },\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBAAmC;CAC9C,4BAA4B;EAC1B,iBAAiB,EAAE,QAAQ,eACzBA,2DAA0B,SAAS,GAAG,OAAO,UAAU,aAAa;EACtE,eAAe;EACf,qBAAqB;CACvB;CAEA,+BAA+B,EAC7B,mBAAmB,MACrB;CAEA,sBAAsB,WAAW,UAAU;EACzC,kCAAoB,sBAAsB,WAAW,OAAO,EAC1D,sBAAsB,EACpB,KAAK,SAASC,sDAAqB,IAAI,EACzC,EACF,CAAC;CACH;CAEA,wBAAwB,WAAW,UAAU;EAC3C,kCAAoB,sBAAsB,WAAW,OAAO;GAC1D,0BAA0B,EACxB,KAAK,WAAWC,0DAAyB,MAAM,EACjD;GACA,4BAA4B,EAC1B,KAAK,QAAQ,YAAYC,4DAA2B,QAAQ,OAAO,EACrE;GACA,6BAA6B;IAC3B,KAAK,WAAWC,6DAA4B,MAAM;IAClD,WAAW,WAAW,CACpB,OAAO,MAAM,gBAAgB,GAC7B,OAAO,MAAM,aAAa,cAC5B;GACF;EACF,CAAC;CACH;CAEA,yBAAyB,WAAW;EACjC,AAAC,OAAe,yBAAyB;EACzC,AAAC,OAAe,+BAA+B;CAClD;CAEA,sBAAsB,QAAQ;EAC3B,AAAC,IAAY,0BAA0BC,4BAAc;CACxD;AACF"}
@@ -8,7 +8,8 @@ import { cell_getIsAggregated, column_getAggregationFns, column_getAggregationVa
8
8
  const aggregationFeature = {
9
9
  getDefaultColumnDef: () => ({
10
10
  aggregatedCell: ({ column, getValue }) => formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),
11
- aggregationFn: "auto"
11
+ aggregationFn: "auto",
12
+ maxAggregationDepth: 0
12
13
  }),
13
14
  getDefaultTableOptions: () => ({ manualAggregation: false }),
14
15
  assignCellPrototype: (prototype, table) => {
@@ -17,7 +18,7 @@ const aggregationFeature = {
17
18
  assignColumnPrototype: (prototype, table) => {
18
19
  assignPrototypeAPIs("aggregationFeature", prototype, table, {
19
20
  column_getAggregationFns: { fn: (column) => column_getAggregationFns(column) },
20
- column_getAggregationValue: { fn: (column, rows) => column_getAggregationValue(column, rows) },
21
+ column_getAggregationValue: { fn: (column, options) => column_getAggregationValue(column, options) },
21
22
  column_getAutoAggregationFn: {
22
23
  fn: (column) => column_getAutoAggregationFn(column),
23
24
  memoDeps: (column) => [column.table.getCoreRowModel(), column.table._rowModelFns.aggregationFns]
@@ -1 +1 @@
1
- {"version":3,"file":"aggregationFeature.js","names":[],"sources":["../../../src/features/aggregation/aggregationFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, makeObjectMap } from '../../utils'\nimport {\n cell_getIsAggregated,\n column_getAggregationFns,\n column_getAggregationValue,\n column_getAutoAggregationFn,\n formatAggregatedCellValue,\n} from './aggregationFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Independent aggregation feature for grouped values and root/custom-row totals.\n */\nexport const aggregationFeature: TableFeature = {\n getDefaultColumnDef: () => ({\n aggregatedCell: ({ column, getValue }: any) =>\n formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),\n aggregationFn: 'auto',\n }),\n\n getDefaultTableOptions: () => ({\n manualAggregation: false,\n }),\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n column_getAggregationFns: {\n fn: (column) => column_getAggregationFns(column),\n },\n column_getAggregationValue: {\n fn: (column, rows) => column_getAggregationValue(column, rows),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n memoDeps: (column) => [\n column.table.getCoreRowModel(),\n column.table._rowModelFns.aggregationFns,\n ],\n },\n })\n },\n\n initColumnInstanceData: (column) => {\n ;(column as any)._aggregationValueCache = undefined\n ;(column as any)._resolvedAggregationFnsCache = undefined\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._aggregationValuesCache = makeObjectMap()\n },\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBAAmC;CAC9C,4BAA4B;EAC1B,iBAAiB,EAAE,QAAQ,eACzB,0BAA0B,SAAS,GAAG,OAAO,UAAU,aAAa;EACtE,eAAe;CACjB;CAEA,+BAA+B,EAC7B,mBAAmB,MACrB;CAEA,sBAAsB,WAAW,UAAU;EACzC,oBAAoB,sBAAsB,WAAW,OAAO,EAC1D,sBAAsB,EACpB,KAAK,SAAS,qBAAqB,IAAI,EACzC,EACF,CAAC;CACH;CAEA,wBAAwB,WAAW,UAAU;EAC3C,oBAAoB,sBAAsB,WAAW,OAAO;GAC1D,0BAA0B,EACxB,KAAK,WAAW,yBAAyB,MAAM,EACjD;GACA,4BAA4B,EAC1B,KAAK,QAAQ,SAAS,2BAA2B,QAAQ,IAAI,EAC/D;GACA,6BAA6B;IAC3B,KAAK,WAAW,4BAA4B,MAAM;IAClD,WAAW,WAAW,CACpB,OAAO,MAAM,gBAAgB,GAC7B,OAAO,MAAM,aAAa,cAC5B;GACF;EACF,CAAC;CACH;CAEA,yBAAyB,WAAW;EACjC,AAAC,OAAe,yBAAyB;EACzC,AAAC,OAAe,+BAA+B;CAClD;CAEA,sBAAsB,QAAQ;EAC3B,AAAC,IAAY,0BAA0B,cAAc;CACxD;AACF"}
1
+ {"version":3,"file":"aggregationFeature.js","names":[],"sources":["../../../src/features/aggregation/aggregationFeature.ts"],"sourcesContent":["import { assignPrototypeAPIs, makeObjectMap } from '../../utils'\nimport {\n cell_getIsAggregated,\n column_getAggregationFns,\n column_getAggregationValue,\n column_getAutoAggregationFn,\n formatAggregatedCellValue,\n} from './aggregationFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Independent aggregation feature for grouped values and root/custom-row totals.\n */\nexport const aggregationFeature: TableFeature = {\n getDefaultColumnDef: () => ({\n aggregatedCell: ({ column, getValue }: any) =>\n formatAggregatedCellValue(getValue(), column.columnDef.aggregationFn),\n aggregationFn: 'auto',\n maxAggregationDepth: 0,\n }),\n\n getDefaultTableOptions: () => ({\n manualAggregation: false,\n }),\n\n assignCellPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n cell_getIsAggregated: {\n fn: (cell) => cell_getIsAggregated(cell),\n },\n })\n },\n\n assignColumnPrototype: (prototype, table) => {\n assignPrototypeAPIs('aggregationFeature', prototype, table, {\n column_getAggregationFns: {\n fn: (column) => column_getAggregationFns(column),\n },\n column_getAggregationValue: {\n fn: (column, options) => column_getAggregationValue(column, options),\n },\n column_getAutoAggregationFn: {\n fn: (column) => column_getAutoAggregationFn(column),\n memoDeps: (column) => [\n column.table.getCoreRowModel(),\n column.table._rowModelFns.aggregationFns,\n ],\n },\n })\n },\n\n initColumnInstanceData: (column) => {\n ;(column as any)._aggregationValueCache = undefined\n ;(column as any)._resolvedAggregationFnsCache = undefined\n },\n\n initRowInstanceData: (row) => {\n ;(row as any)._aggregationValuesCache = makeObjectMap()\n },\n}\n"],"mappings":";;;;;;;AAaA,MAAa,qBAAmC;CAC9C,4BAA4B;EAC1B,iBAAiB,EAAE,QAAQ,eACzB,0BAA0B,SAAS,GAAG,OAAO,UAAU,aAAa;EACtE,eAAe;EACf,qBAAqB;CACvB;CAEA,+BAA+B,EAC7B,mBAAmB,MACrB;CAEA,sBAAsB,WAAW,UAAU;EACzC,oBAAoB,sBAAsB,WAAW,OAAO,EAC1D,sBAAsB,EACpB,KAAK,SAAS,qBAAqB,IAAI,EACzC,EACF,CAAC;CACH;CAEA,wBAAwB,WAAW,UAAU;EAC3C,oBAAoB,sBAAsB,WAAW,OAAO;GAC1D,0BAA0B,EACxB,KAAK,WAAW,yBAAyB,MAAM,EACjD;GACA,4BAA4B,EAC1B,KAAK,QAAQ,YAAY,2BAA2B,QAAQ,OAAO,EACrE;GACA,6BAA6B;IAC3B,KAAK,WAAW,4BAA4B,MAAM;IAClD,WAAW,WAAW,CACpB,OAAO,MAAM,gBAAgB,GAC7B,OAAO,MAAM,aAAa,cAC5B;GACF;EACF,CAAC;CACH;CAEA,yBAAyB,WAAW;EACjC,AAAC,OAAe,yBAAyB;EACzC,AAAC,OAAe,+BAA+B;CAClD;CAEA,sBAAsB,QAAQ;EAC3B,AAAC,IAAY,0BAA0B,cAAc;CACxD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"aggregationFeature.types.cjs","names":[],"sources":["../../../src/features/aggregation/aggregationFeature.types.ts"],"sourcesContent":["import type { BuiltInAggregationFn } from './aggregationFns'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { ColumnDefTemplate } from '../../types/ColumnDef'\nimport type { IsAny, TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Table } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\n\n/** Declaration-merging fallback for named aggregation definitions. */\nexport interface AggregationFns {}\n\n/** Values and table objects available while one aggregation is evaluated. */\nexport interface AggregationContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> {\n /** The column whose values are being aggregated. */\n column: Column<TFeatures, TData, TValue>\n /** Convenience alias for `column.id`. */\n columnId: string\n /** Reads this column's value from one of `rows`. */\n getValue: (row: Row<TFeatures, TData>) => TValue\n /**\n * The synthetic grouped row receiving this result. This property is omitted\n * for root or caller-supplied-row aggregation. Its `depth` identifies the\n * grouping level when grouped aggregation needs that distinction.\n */\n groupingRow?: Row<TFeatures, TData>\n /**\n * Terminal leaf rows included in this aggregation. The executor normalizes\n * hierarchical and duplicate row inputs before invoking the definition.\n */\n rows: ReadonlyArray<Row<TFeatures, TData>>\n /** The table that owns the column and rows. */\n table: Table<TFeatures, TData>\n}\n\n/** Additional values available when merging nested grouped results. */\nexport interface AggregationMergeContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n TResult,\n> extends AggregationContext<TFeatures, TData, TValue> {\n /** Results produced for each immediate child group, in child-row order. */\n childResults: ReadonlyArray<TResult>\n /** Immediate child group rows corresponding to `childResults`. */\n childRows: ReadonlyArray<Row<TFeatures, TData>>\n}\n\n/** A context-based aggregation definition and optional grouped-result merge. */\nexport interface AggregationFnDef<\n TFeatures extends TableFeatures = any,\n TData extends RowData = any,\n TValue = unknown,\n TResult = unknown,\n> {\n /** Computes a result directly from normalized terminal rows. */\n aggregate: (context: AggregationContext<TFeatures, TData, TValue>) => TResult\n /**\n * Combines already-computed immediate child-group results. When omitted,\n * nested grouping falls back to `aggregate` over the group's terminal rows.\n */\n merge?: (\n context: AggregationMergeContext<TFeatures, TData, TValue, TResult>,\n ) => TResult\n}\n\n/**\n * Creates a typed context-based aggregation definition for a column or\n * aggregation-function registry.\n */\nexport function constructAggregationFn<\n TFeatures extends TableFeatures = any,\n TData extends RowData = any,\n TValue = unknown,\n TResult = unknown,\n>(\n definition: AggregationFnDef<TFeatures, TData, TValue, TResult>,\n): AggregationFnDef<TFeatures, TData, TValue, TResult> {\n return definition\n}\n\n/** Aggregation-definition registry carried by a table feature set. */\nexport interface RowModelFns_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n> {\n aggregationFns: Record<string, AggregationFnDef<TFeatures, TData, any, any>>\n}\n\n/** Named context-based aggregation definitions registered on a feature set. */\nexport type CustomAggregationFns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Record<string, AggregationFnDef<TFeatures, TData, any, any>>\n\n/** String names available from a feature set's aggregation registry. */\nexport type ExtractAggregationFnKeys<TFeatures extends TableFeatures> =\n IsAny<TFeatures> extends true\n ? keyof AggregationFns | BuiltInAggregationFn\n : TFeatures extends { aggregationFns: infer TAggregationFns extends object }\n ? Extract<keyof TAggregationFns, string>\n : keyof AggregationFns\n\n/** A registered name, automatic inference, or inline aggregation definition. */\nexport type AggregationFnRef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n TResult = unknown,\n> =\n | 'auto'\n | ExtractAggregationFnKeys<TFeatures>\n | AggregationFnDef<TFeatures, TData, TValue, TResult>\n\n/** Gives an aggregation reference a stable key in a multiple result. */\nexport interface AggregationFnDescriptor<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n TResult = unknown,\n> {\n /** The named, automatic, or inline definition to execute. */\n aggregationFn: AggregationFnRef<TFeatures, TData, TValue, TResult>\n /** Stable key used in the object returned by a multiple aggregation. */\n id: string\n}\n\n/** One named or explicitly keyed entry in a multiple aggregation option. */\nexport type AggregationFnListItem<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> =\n | 'auto'\n | ExtractAggregationFnKeys<TFeatures>\n | AggregationFnDescriptor<TFeatures, TData, TValue, any>\n\n/** A scalar aggregation reference or a list that produces a keyed object. */\nexport type AggregationFnOption<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> =\n | AggregationFnRef<TFeatures, TData, TValue, any>\n | ReadonlyArray<AggregationFnListItem<TFeatures, TData, TValue>>\n\n/** Extracts the result type produced by an aggregation definition. */\nexport type AggregationResultOf<TDefinition> =\n TDefinition extends AggregationFnDef<any, any, any, infer TResult>\n ? TResult\n : unknown\n\ntype RegisteredAggregationDefinition<\n TFeatures extends TableFeatures,\n TKey extends PropertyKey,\n> = TFeatures extends {\n aggregationFns: infer TRegistry extends Record<PropertyKey, unknown>\n}\n ? TKey extends keyof TRegistry\n ? TRegistry[TKey]\n : never\n : never\n\ntype AggregationResultOfRef<TRef, TFeatures extends TableFeatures> =\n TRef extends AggregationFnDef<any, any, any, any>\n ? AggregationResultOf<TRef>\n : TRef extends 'auto'\n ? RegisteredAggregationResult<TFeatures>\n : TRef extends PropertyKey\n ? AggregationResultOf<RegisteredAggregationDefinition<TFeatures, TRef>>\n : unknown\n\ntype AggregationEntryId<TEntry> = TEntry extends string\n ? TEntry\n : TEntry extends { id: infer TId extends string }\n ? TId\n : never\n\ntype AggregationEntryDefinition<TEntry> = TEntry extends {\n aggregationFn: infer TDefinition\n}\n ? TDefinition\n : TEntry\n\n/** Infers the scalar or keyed result produced by an aggregation option. */\nexport type AggregationResult<TOption, TFeatures extends TableFeatures = any> =\n TOption extends ReadonlyArray<infer TEntry>\n ? {\n [TKey in AggregationEntryId<TEntry>]: AggregationResultOfRef<\n AggregationEntryDefinition<Extract<TEntry, TKey | { id: TKey }>>,\n TFeatures\n >\n }\n : AggregationResultOfRef<TOption, TFeatures>\n\ntype RegisteredAggregationResult<TFeatures extends TableFeatures> =\n TFeatures extends {\n aggregationFns: infer TRegistry extends Record<string, unknown>\n }\n ? AggregationResultOf<TRegistry[keyof TRegistry]>\n : unknown\n\n/** Default public result union when a column's precise option is not known. */\nexport type ColumnAggregationValue<TFeatures extends TableFeatures> =\n | RegisteredAggregationResult<TFeatures>\n | Record<string, RegisteredAggregationResult<TFeatures> | undefined>\n | undefined\n\n/** A validated aggregation entry returned by `column.getAggregationFns()`. */\nexport interface ResolvedAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n /** Resolved definition, or `undefined` when configuration is invalid. */\n aggregationFn: AggregationFnDef<TFeatures, TData, any, any> | undefined\n /** Key used for a multiple result; scalar inline definitions have no id. */\n id: string | undefined\n}\n\n/** Column-definition options installed by `aggregationFeature`. */\nexport interface ColumnDef_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n TValue extends CellData = CellData,\n> {\n /** Renderer used for a grouped row's aggregated cell. */\n aggregatedCell?: ColumnDefTemplate<\n ReturnType<Cell<TFeatures, TData, TValue>['getContext']>\n >\n /**\n * One aggregation reference for a scalar result, or an array for a keyed\n * result object. Inline definitions in an array require an explicit `id`.\n */\n aggregationFn?: AggregationFnOption<TFeatures, TData, TValue>\n /**\n * Optionally supplies a precomputed aggregation value for this column.\n * Return `{ value }` to handle the request, including `{ value: undefined }`;\n * return `undefined` to use the local aggregation fallback.\n */\n getAggregationValue?: (\n context: AggregationValueContext<TFeatures, TData, TValue>,\n ) => AggregationValueResult | undefined\n}\n\n/** Column instance APIs installed by `aggregationFeature`. */\nexport interface Column_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n> {\n /** Resolves the configured scalar or multiple aggregation definitions. */\n getAggregationFns: () => ReadonlyArray<\n ResolvedAggregationFn<TFeatures, TData>\n >\n /**\n * Aggregates this column over the default pre-grouped row model, or over a\n * caller-provided array of rows. Explicit rows are normalized to unique\n * terminal leaves and are intentionally not cached.\n */\n getAggregationValue: <TResult = ColumnAggregationValue<TFeatures>>(\n rows?: ReadonlyArray<Row<TFeatures, TData>>,\n ) => TResult\n /** Infers `sum` for a numeric first row and `extent` for a Date first row. */\n getAutoAggregationFn: () =>\n | AggregationFnDef<TFeatures, TData, any, any>\n | undefined\n}\n\n/** Cell instance APIs installed by `aggregationFeature`. */\nexport interface Cell_Aggregation {\n /** Whether this cell displays an aggregate on a synthetic grouped row. */\n getIsAggregated: () => boolean\n}\n\n/** Internal per-row cache used while grouped aggregates are evaluated. */\nexport interface Row_Aggregation {\n /** Cached aggregate results keyed by column id. */\n _aggregationValuesCache: Record<string, unknown>\n}\n\n/** Values passed to a column-level aggregation-value provider. */\nexport interface AggregationValueContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> {\n /** The column whose value was requested. */\n column: Column<TFeatures, TData, TValue>\n /** Caller-provided rows, or `undefined` for the default row model. */\n rows?: ReadonlyArray<Row<TFeatures, TData>>\n /** The table that owns the column. */\n table: Table<TFeatures, TData>\n}\n\n/** Marks an aggregation-value override as handled. */\nexport interface AggregationValueResult<TResult = unknown> {\n /** The supplied value. `undefined` is still a handled result. */\n value: TResult\n}\n\n/** Table options installed by `aggregationFeature`. */\nexport interface TableOptions_Aggregation {\n /**\n * Disables local `column.getAggregationValue()` calculation when a column\n * override does not handle the request. Group values supplied by manually\n * grouped rows remain the responsibility of the data owner.\n */\n manualAggregation?: boolean\n}\n"],"mappings":";;;;;;AA0EA,SAAgB,uBAMd,YACqD;CACrD,OAAO;AACT"}
1
+ {"version":3,"file":"aggregationFeature.types.cjs","names":[],"sources":["../../../src/features/aggregation/aggregationFeature.types.ts"],"sourcesContent":["import type { BuiltInAggregationFn } from './aggregationFns'\nimport type { Cell } from '../../types/Cell'\nimport type { Column } from '../../types/Column'\nimport type { ColumnDefTemplate } from '../../types/ColumnDef'\nimport type { IsAny, TableFeatures } from '../../types/TableFeatures'\nimport type { Row } from '../../types/Row'\nimport type { Table } from '../../types/Table'\nimport type { CellData, RowData } from '../../types/type-utils'\n\n/** Declaration-merging fallback for named aggregation definitions. */\nexport interface AggregationFns {}\n\n/** Values and table objects available while one aggregation is evaluated. */\nexport interface AggregationContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> {\n /** The column whose values are being aggregated. */\n column: Column<TFeatures, TData, TValue>\n /** Convenience alias for `column.id`. */\n columnId: string\n /** Maximum relative sub-row depth used to select `rows`. */\n maxDepth: number\n /**\n * Immediate sub-rows for grouped aggregation. This property is omitted\n * for root or caller-supplied-row aggregation. At a terminal grouping level\n * these are the direct data rows; at a nested level they are sub-row groups.\n */\n subRows?: ReadonlyArray<Row<TFeatures, TData>>\n /** Reads this column's value from one of `rows`. */\n getValue: (row: Row<TFeatures, TData>) => TValue\n /**\n * The synthetic grouped row receiving this result. This property is omitted\n * for root or caller-supplied-row aggregation. Its `depth` identifies the\n * grouping level when grouped aggregation needs that distinction.\n */\n groupingRow?: Row<TFeatures, TData>\n /**\n * Unique rows selected at `maxDepth`. Branches that end before `maxDepth`\n * contribute their deepest available row.\n */\n rows: ReadonlyArray<Row<TFeatures, TData>>\n /** The table that owns the column and rows. */\n table: Table<TFeatures, TData>\n}\n\n/** Additional values available when merging nested grouped results. */\nexport interface AggregationMergeContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n TResult,\n> extends AggregationContext<TFeatures, TData, TValue> {\n /** Results produced for each immediate sub-row group, in sub-row order. */\n subRowResults: ReadonlyArray<TResult>\n /** Immediate sub-row groups corresponding to `subRowResults`. */\n subRows: ReadonlyArray<Row<TFeatures, TData>>\n}\n\n/** A context-based aggregation definition and optional grouped-result merge. */\nexport interface AggregationFnDef<\n TFeatures extends TableFeatures = any,\n TData extends RowData = any,\n TValue = unknown,\n TResult = unknown,\n> {\n /** Computes a result directly from the selected `rows`. */\n aggregate: (context: AggregationContext<TFeatures, TData, TValue>) => TResult\n /**\n * Combines already-computed immediate sub-row results. When omitted,\n * nested grouping falls back to `aggregate` over the group's selected rows.\n */\n merge?: (\n context: AggregationMergeContext<TFeatures, TData, TValue, TResult>,\n ) => TResult\n}\n\n/**\n * Creates a typed context-based aggregation definition for a column or\n * aggregation-function registry.\n */\nexport function constructAggregationFn<\n TFeatures extends TableFeatures = any,\n TData extends RowData = any,\n TValue = unknown,\n TResult = unknown,\n>(\n definition: AggregationFnDef<TFeatures, TData, TValue, TResult>,\n): AggregationFnDef<TFeatures, TData, TValue, TResult> {\n return definition\n}\n\n/** Aggregation-definition registry carried by a table feature set. */\nexport interface RowModelFns_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n> {\n aggregationFns: Record<string, AggregationFnDef<TFeatures, TData, any, any>>\n}\n\n/** Named context-based aggregation definitions registered on a feature set. */\nexport type CustomAggregationFns<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> = Record<string, AggregationFnDef<TFeatures, TData, any, any>>\n\n/** String names available from a feature set's aggregation registry. */\nexport type ExtractAggregationFnKeys<TFeatures extends TableFeatures> =\n IsAny<TFeatures> extends true\n ? keyof AggregationFns | BuiltInAggregationFn\n : TFeatures extends { aggregationFns: infer TAggregationFns extends object }\n ? Extract<keyof TAggregationFns, string>\n : keyof AggregationFns\n\n/** A registered name, automatic inference, or inline aggregation definition. */\nexport type AggregationFnRef<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n TResult = unknown,\n> =\n | 'auto'\n | ExtractAggregationFnKeys<TFeatures>\n | AggregationFnDef<TFeatures, TData, TValue, TResult>\n\n/** Gives an aggregation reference a stable key in a multiple result. */\nexport interface AggregationFnDescriptor<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n TResult = unknown,\n> {\n /** The named, automatic, or inline definition to execute. */\n aggregationFn: AggregationFnRef<TFeatures, TData, TValue, TResult>\n /** Stable key used in the object returned by a multiple aggregation. */\n id: string\n}\n\n/** One named or explicitly keyed entry in a multiple aggregation option. */\nexport type AggregationFnListItem<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> =\n | 'auto'\n | ExtractAggregationFnKeys<TFeatures>\n | AggregationFnDescriptor<TFeatures, TData, TValue, any>\n\n/** A scalar aggregation reference or a list that produces a keyed object. */\nexport type AggregationFnOption<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue = unknown,\n> =\n | AggregationFnRef<TFeatures, TData, TValue, any>\n | ReadonlyArray<AggregationFnListItem<TFeatures, TData, TValue>>\n\n/** Extracts the result type produced by an aggregation definition. */\nexport type AggregationResultOf<TDefinition> =\n TDefinition extends AggregationFnDef<any, any, any, infer TResult>\n ? TResult\n : unknown\n\ntype RegisteredAggregationDefinition<\n TFeatures extends TableFeatures,\n TKey extends PropertyKey,\n> = TFeatures extends {\n aggregationFns: infer TRegistry extends Record<PropertyKey, unknown>\n}\n ? TKey extends keyof TRegistry\n ? TRegistry[TKey]\n : never\n : never\n\ntype AggregationResultOfRef<TRef, TFeatures extends TableFeatures> =\n TRef extends AggregationFnDef<any, any, any, any>\n ? AggregationResultOf<TRef>\n : TRef extends 'auto'\n ? RegisteredAggregationResult<TFeatures>\n : TRef extends PropertyKey\n ? AggregationResultOf<RegisteredAggregationDefinition<TFeatures, TRef>>\n : unknown\n\ntype AggregationEntryId<TEntry> = TEntry extends string\n ? TEntry\n : TEntry extends { id: infer TId extends string }\n ? TId\n : never\n\ntype AggregationEntryDefinition<TEntry> = TEntry extends {\n aggregationFn: infer TDefinition\n}\n ? TDefinition\n : TEntry\n\n/** Infers the scalar or keyed result produced by an aggregation option. */\nexport type AggregationResult<TOption, TFeatures extends TableFeatures = any> =\n TOption extends ReadonlyArray<infer TEntry>\n ? {\n [TKey in AggregationEntryId<TEntry>]: AggregationResultOfRef<\n AggregationEntryDefinition<Extract<TEntry, TKey | { id: TKey }>>,\n TFeatures\n >\n }\n : AggregationResultOfRef<TOption, TFeatures>\n\ntype RegisteredAggregationResult<TFeatures extends TableFeatures> =\n TFeatures extends {\n aggregationFns: infer TRegistry extends Record<string, unknown>\n }\n ? AggregationResultOf<TRegistry[keyof TRegistry]>\n : unknown\n\n/** Default public result union when a column's precise option is not known. */\nexport type ColumnAggregationValue<TFeatures extends TableFeatures> =\n | RegisteredAggregationResult<TFeatures>\n | Record<string, RegisteredAggregationResult<TFeatures> | undefined>\n | undefined\n\n/** A validated aggregation entry returned by `column.getAggregationFns()`. */\nexport interface ResolvedAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n> {\n /** Resolved definition, or `undefined` when configuration is invalid. */\n aggregationFn: AggregationFnDef<TFeatures, TData, any, any> | undefined\n /** Key used for a multiple result; scalar inline definitions have no id. */\n id: string | undefined\n}\n\n/** Column-definition options installed by `aggregationFeature`. */\nexport interface ColumnDef_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n TValue extends CellData = CellData,\n> {\n /** Renderer used for a grouped row's aggregated cell. */\n aggregatedCell?: ColumnDefTemplate<\n ReturnType<Cell<TFeatures, TData, TValue>['getContext']>\n >\n /**\n * One aggregation reference for a scalar result, or an array for a keyed\n * result object. Inline definitions in an array require an explicit `id`.\n */\n aggregationFn?: AggregationFnOption<TFeatures, TData, TValue>\n /**\n * Maximum relative sub-row depth used for grouped aggregation and cached\n * default totals. `0` selects the supplied root rows, `1` their direct\n * sub-rows, and so on. Defaults to `0`.\n */\n maxAggregationDepth?: number\n /**\n * Optionally supplies a precomputed aggregation value for this column.\n * Return `{ value }` to handle the request, including `{ value: undefined }`;\n * return `undefined` to use the local aggregation fallback.\n */\n getAggregationValue?: (\n context: AggregationValueContext<TFeatures, TData, TValue>,\n ) => AggregationValueResult | undefined\n}\n\n/** Column instance APIs installed by `aggregationFeature`. */\nexport interface Column_Aggregation<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n> {\n /** Resolves the configured scalar or multiple aggregation definitions. */\n getAggregationFns: () => ReadonlyArray<\n ResolvedAggregationFn<TFeatures, TData>\n >\n /**\n * Aggregates this column over the default pre-grouped row model, or over a\n * caller-provided array of rows. `options.maxDepth` overrides the column's\n * `maxAggregationDepth`. Explicit-row calls are intentionally not cached.\n */\n getAggregationValue: <TResult = ColumnAggregationValue<TFeatures>>(\n options?: AggregationValueOptions<TFeatures, TData>,\n ) => TResult\n /** Infers `sum` for a numeric first row and `extent` for a Date first row. */\n getAutoAggregationFn: () =>\n | AggregationFnDef<TFeatures, TData, any, any>\n | undefined\n}\n\n/** Options for a caller-requested column aggregation value. */\nexport interface AggregationValueOptions<\n in out TFeatures extends TableFeatures,\n in out TData extends RowData,\n> {\n /** Overrides the column's `maxAggregationDepth` for this request. */\n maxDepth?: number\n /** Rows to aggregate instead of the default pre-grouped row model. */\n rows?: ReadonlyArray<Row<TFeatures, TData>>\n}\n\n/** Cell instance APIs installed by `aggregationFeature`. */\nexport interface Cell_Aggregation {\n /** Whether this cell displays an aggregate on a synthetic grouped row. */\n getIsAggregated: () => boolean\n}\n\n/** Internal per-row cache used while grouped aggregates are evaluated. */\nexport interface Row_Aggregation {\n /** Cached aggregate results keyed by column id. */\n _aggregationValuesCache: Record<string, unknown>\n}\n\n/** Values passed to a column-level aggregation-value provider. */\nexport interface AggregationValueContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n> {\n /** The column whose value was requested. */\n column: Column<TFeatures, TData, TValue>\n /** Maximum relative sub-row depth used for the request. */\n maxDepth: number\n /** Caller-provided rows, or `undefined` for the default row model. */\n rows?: ReadonlyArray<Row<TFeatures, TData>>\n /** The table that owns the column. */\n table: Table<TFeatures, TData>\n}\n\n/** Marks an aggregation-value override as handled. */\nexport interface AggregationValueResult<TResult = unknown> {\n /** The supplied value. `undefined` is still a handled result. */\n value: TResult\n}\n\n/** Table options installed by `aggregationFeature`. */\nexport interface TableOptions_Aggregation {\n /**\n * Disables local `column.getAggregationValue()` calculation when a column\n * override does not handle the request. Group values supplied by manually\n * grouped rows remain the responsibility of the data owner.\n */\n manualAggregation?: boolean\n}\n"],"mappings":";;;;;;AAkFA,SAAgB,uBAMd,YACqD;CACrD,OAAO;AACT"}
@@ -16,6 +16,14 @@ interface AggregationContext<TFeatures extends TableFeatures, TData extends RowD
16
16
  column: Column<TFeatures, TData, TValue>;
17
17
  /** Convenience alias for `column.id`. */
18
18
  columnId: string;
19
+ /** Maximum relative sub-row depth used to select `rows`. */
20
+ maxDepth: number;
21
+ /**
22
+ * Immediate sub-rows for grouped aggregation. This property is omitted
23
+ * for root or caller-supplied-row aggregation. At a terminal grouping level
24
+ * these are the direct data rows; at a nested level they are sub-row groups.
25
+ */
26
+ subRows?: ReadonlyArray<Row<TFeatures, TData>>;
19
27
  /** Reads this column's value from one of `rows`. */
20
28
  getValue: (row: Row<TFeatures, TData>) => TValue;
21
29
  /**
@@ -25,8 +33,8 @@ interface AggregationContext<TFeatures extends TableFeatures, TData extends RowD
25
33
  */
26
34
  groupingRow?: Row<TFeatures, TData>;
27
35
  /**
28
- * Terminal leaf rows included in this aggregation. The executor normalizes
29
- * hierarchical and duplicate row inputs before invoking the definition.
36
+ * Unique rows selected at `maxDepth`. Branches that end before `maxDepth`
37
+ * contribute their deepest available row.
30
38
  */
31
39
  rows: ReadonlyArray<Row<TFeatures, TData>>;
32
40
  /** The table that owns the column and rows. */
@@ -34,18 +42,18 @@ interface AggregationContext<TFeatures extends TableFeatures, TData extends RowD
34
42
  }
35
43
  /** Additional values available when merging nested grouped results. */
36
44
  interface AggregationMergeContext<TFeatures extends TableFeatures, TData extends RowData, TValue, TResult> extends AggregationContext<TFeatures, TData, TValue> {
37
- /** Results produced for each immediate child group, in child-row order. */
38
- childResults: ReadonlyArray<TResult>;
39
- /** Immediate child group rows corresponding to `childResults`. */
40
- childRows: ReadonlyArray<Row<TFeatures, TData>>;
45
+ /** Results produced for each immediate sub-row group, in sub-row order. */
46
+ subRowResults: ReadonlyArray<TResult>;
47
+ /** Immediate sub-row groups corresponding to `subRowResults`. */
48
+ subRows: ReadonlyArray<Row<TFeatures, TData>>;
41
49
  }
42
50
  /** A context-based aggregation definition and optional grouped-result merge. */
43
51
  interface AggregationFnDef<TFeatures extends TableFeatures = any, TData extends RowData = any, TValue = unknown, TResult = unknown> {
44
- /** Computes a result directly from normalized terminal rows. */
52
+ /** Computes a result directly from the selected `rows`. */
45
53
  aggregate: (context: AggregationContext<TFeatures, TData, TValue>) => TResult;
46
54
  /**
47
- * Combines already-computed immediate child-group results. When omitted,
48
- * nested grouping falls back to `aggregate` over the group's terminal rows.
55
+ * Combines already-computed immediate sub-row results. When omitted,
56
+ * nested grouping falls back to `aggregate` over the group's selected rows.
49
57
  */
50
58
  merge?: (context: AggregationMergeContext<TFeatures, TData, TValue, TResult>) => TResult;
51
59
  }
@@ -114,6 +122,12 @@ interface ColumnDef_Aggregation<in out TFeatures extends TableFeatures, in out T
114
122
  * result object. Inline definitions in an array require an explicit `id`.
115
123
  */
116
124
  aggregationFn?: AggregationFnOption<TFeatures, TData, TValue>;
125
+ /**
126
+ * Maximum relative sub-row depth used for grouped aggregation and cached
127
+ * default totals. `0` selects the supplied root rows, `1` their direct
128
+ * sub-rows, and so on. Defaults to `0`.
129
+ */
130
+ maxAggregationDepth?: number;
117
131
  /**
118
132
  * Optionally supplies a precomputed aggregation value for this column.
119
133
  * Return `{ value }` to handle the request, including `{ value: undefined }`;
@@ -127,13 +141,20 @@ interface Column_Aggregation<in out TFeatures extends TableFeatures, in out TDat
127
141
  getAggregationFns: () => ReadonlyArray<ResolvedAggregationFn<TFeatures, TData>>;
128
142
  /**
129
143
  * Aggregates this column over the default pre-grouped row model, or over a
130
- * caller-provided array of rows. Explicit rows are normalized to unique
131
- * terminal leaves and are intentionally not cached.
144
+ * caller-provided array of rows. `options.maxDepth` overrides the column's
145
+ * `maxAggregationDepth`. Explicit-row calls are intentionally not cached.
132
146
  */
133
- getAggregationValue: <TResult = ColumnAggregationValue<TFeatures>>(rows?: ReadonlyArray<Row<TFeatures, TData>>) => TResult;
147
+ getAggregationValue: <TResult = ColumnAggregationValue<TFeatures>>(options?: AggregationValueOptions<TFeatures, TData>) => TResult;
134
148
  /** Infers `sum` for a numeric first row and `extent` for a Date first row. */
135
149
  getAutoAggregationFn: () => AggregationFnDef<TFeatures, TData, any, any> | undefined;
136
150
  }
151
+ /** Options for a caller-requested column aggregation value. */
152
+ interface AggregationValueOptions<in out TFeatures extends TableFeatures, in out TData extends RowData> {
153
+ /** Overrides the column's `maxAggregationDepth` for this request. */
154
+ maxDepth?: number;
155
+ /** Rows to aggregate instead of the default pre-grouped row model. */
156
+ rows?: ReadonlyArray<Row<TFeatures, TData>>;
157
+ }
137
158
  /** Cell instance APIs installed by `aggregationFeature`. */
138
159
  interface Cell_Aggregation {
139
160
  /** Whether this cell displays an aggregate on a synthetic grouped row. */
@@ -148,6 +169,8 @@ interface Row_Aggregation {
148
169
  interface AggregationValueContext<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
149
170
  /** The column whose value was requested. */
150
171
  column: Column<TFeatures, TData, TValue>;
172
+ /** Maximum relative sub-row depth used for the request. */
173
+ maxDepth: number;
151
174
  /** Caller-provided rows, or `undefined` for the default row model. */
152
175
  rows?: ReadonlyArray<Row<TFeatures, TData>>;
153
176
  /** The table that owns the column. */
@@ -168,5 +191,5 @@ interface TableOptions_Aggregation {
168
191
  manualAggregation?: boolean;
169
192
  }
170
193
  //#endregion
171
- export { AggregationContext, AggregationFnDef, AggregationFnDescriptor, AggregationFnListItem, AggregationFnOption, AggregationFnRef, AggregationFns, AggregationMergeContext, AggregationResult, AggregationResultOf, AggregationValueContext, AggregationValueResult, Cell_Aggregation, ColumnAggregationValue, ColumnDef_Aggregation, Column_Aggregation, CustomAggregationFns, ExtractAggregationFnKeys, ResolvedAggregationFn, RowModelFns_Aggregation, Row_Aggregation, TableOptions_Aggregation, constructAggregationFn };
194
+ export { AggregationContext, AggregationFnDef, AggregationFnDescriptor, AggregationFnListItem, AggregationFnOption, AggregationFnRef, AggregationFns, AggregationMergeContext, AggregationResult, AggregationResultOf, AggregationValueContext, AggregationValueOptions, AggregationValueResult, Cell_Aggregation, ColumnAggregationValue, ColumnDef_Aggregation, Column_Aggregation, CustomAggregationFns, ExtractAggregationFnKeys, ResolvedAggregationFn, RowModelFns_Aggregation, Row_Aggregation, TableOptions_Aggregation, constructAggregationFn };
172
195
  //# sourceMappingURL=aggregationFeature.types.d.cts.map