@tanstack/table-core 9.0.0-beta.36 → 9.0.0-beta.37

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 (36) hide show
  1. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  2. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  3. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +2 -2
  4. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +2 -2
  5. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +1 -1
  6. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +1 -1
  7. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  8. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  9. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +1 -1
  10. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +1 -1
  11. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +1 -1
  12. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
  13. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +1 -1
  14. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
  15. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
  16. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
  17. package/dist/utils.cjs +3 -15
  18. package/dist/utils.cjs.map +1 -1
  19. package/dist/utils.d.cts +2 -2
  20. package/dist/utils.d.ts +2 -2
  21. package/dist/utils.js +3 -15
  22. package/dist/utils.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/core/headers/coreHeadersFeature.utils.ts +0 -1
  25. package/src/core/row-models/coreRowModelsFeature.types.ts +0 -1
  26. package/src/core/table/coreTablesFeature.types.ts +1 -0
  27. package/src/features/column-faceting/columnFacetingFeature.types.ts +0 -1
  28. package/src/features/column-filtering/columnFilteringFeature.types.ts +3 -3
  29. package/src/features/column-grouping/columnGroupingFeature.types.ts +2 -2
  30. package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -0
  31. package/src/features/column-ordering/columnOrderingFeature.types.ts +2 -2
  32. package/src/features/row-expanding/rowExpandingFeature.types.ts +2 -3
  33. package/src/features/row-pagination/rowPaginationFeature.types.ts +2 -3
  34. package/src/features/row-sorting/rowSortingFeature.types.ts +2 -2
  35. package/src/types/ColumnDef.ts +1 -0
  36. package/src/utils.ts +3 -4
@@ -1 +1 @@
1
- {"version":3,"file":"coreHeadersFeature.utils.cjs","names":["getDefaultColumnPinningState","callMemoOrStaticFn","table_getVisibleLeafColumns","buildHeaderGroups","column_getIsVisible"],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\nimport type { Column } from '../../types/Column'\n\n/**\n * Walks a header tree and collects all descendant leaf headers.\n *\n * The header itself is included after its descendants, matching the recursive\n * shape used by nested header groups.\n *\n * @example\n * ```ts\n * const leafHeaders = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Builds the render context passed to a column's `header` or `footer` template.\n *\n * The context contains the header, its column, and the owning table instance.\n *\n * @example\n * ```ts\n * const context = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Builds visible header groups for the current column tree.\n *\n * Column visibility and pinning are applied before groups are built. When no\n * columns are pinned, the fast path skips pin partitioning.\n *\n * @example\n * ```ts\n * const headerGroups = table_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Builds footer groups by reversing the current header groups.\n *\n * Footer rendering uses the same header objects and grouping structure, but\n * renders them from leaf level back toward the root.\n *\n * @example\n * ```ts\n * const footerGroups = table_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Flattens every header from every header group into one array.\n *\n * The result includes parent headers and placeholder headers, in header-group\n * order from top to bottom.\n *\n * @example\n * ```ts\n * const flatHeaders = table_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j]!)\n }\n }\n return result\n}\n\n/**\n * Collects only the leaf headers from the current header tree.\n *\n * Parent/group headers are skipped, making the result suitable for rendering\n * one header per visible leaf column.\n *\n * @example\n * ```ts\n * const leafHeaders = table_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push(leafHeaders[j]!)\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyBA,SAAgB,sBAId,QAA0C;CAC1C,MAAM,cAAuD,CAAC;CAE9D,MAAM,iBAAiB,MAA+C;EACpE,IAAI,EAAE,WAAW,QACf,EAAE,WAAW,IAAI,aAAa;EAEhC,YAAY,KAAK,CAAqC;CACxD;CAEA,cAAc,MAAM;CAEpB,OAAO;AACT;;;;;;;;;;;AAYA,S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QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,EAAE,CAAE;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,EAAG;CAE3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,aAAa,MAAM,gBAAgB,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC;CAC3D,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,EAAE,CAAE,eAAe;EAClD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,EAAG;CAE/B;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"coreHeadersFeature.utils.cjs","names":["getDefaultColumnPinningState","callMemoOrStaticFn","table_getVisibleLeafColumns","buildHeaderGroups","column_getIsVisible"],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\n\n/**\n * Walks a header tree and collects all descendant leaf headers.\n *\n * The header itself is included after its descendants, matching the recursive\n * shape used by nested header groups.\n *\n * @example\n * ```ts\n * const leafHeaders = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Builds the render context passed to a column's `header` or `footer` template.\n *\n * The context contains the header, its column, and the owning table instance.\n *\n * @example\n * ```ts\n * const context = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Builds visible header groups for the current column tree.\n *\n * Column visibility and pinning are applied before groups are built. When no\n * columns are pinned, the fast path skips pin partitioning.\n *\n * @example\n * ```ts\n * const headerGroups = table_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Builds footer groups by reversing the current header groups.\n *\n * Footer rendering uses the same header objects and grouping structure, but\n * renders them from leaf level back toward the root.\n *\n * @example\n * ```ts\n * const footerGroups = table_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Flattens every header from every header group into one array.\n *\n * The result includes parent headers and placeholder headers, in header-group\n * order from top to bottom.\n *\n * @example\n * ```ts\n * const flatHeaders = table_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j]!)\n }\n }\n return result\n}\n\n/**\n * Collects only the leaf headers from the current header tree.\n *\n * Parent/group headers are skipped, making the result suitable for rendering\n * one header per visible leaf column.\n *\n * @example\n * ```ts\n * const leafHeaders = table_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push(leafHeaders[j]!)\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,SAAgB,sBAId,QAA0C;CAC1C,MAAM,cAAuD,CAAC;CAE9D,M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AAC,QAAQ;AACnC;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,EAAE,CAAE;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,EAAG;CAE3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,aAAa,MAAM,gBAAgB,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC;CAC3D,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,EAAE,CAAE,eAAe;EAClD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,EAAG;CAE/B;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"coreHeadersFeature.utils.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\nimport type { Column } from '../../types/Column'\n\n/**\n * Walks a header tree and collects all descendant leaf headers.\n *\n * The header itself is included after its descendants, matching the recursive\n * shape used by nested header groups.\n *\n * @example\n * ```ts\n * const leafHeaders = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Builds the render context passed to a column's `header` or `footer` template.\n *\n * The context contains the header, its column, and the owning table instance.\n *\n * @example\n * ```ts\n * const context = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Builds visible header groups for the current column tree.\n *\n * Column visibility and pinning are applied before groups are built. When no\n * columns are pinned, the fast path skips pin partitioning.\n *\n * @example\n * ```ts\n * const headerGroups = table_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Builds footer groups by reversing the current header groups.\n *\n * Footer rendering uses the same header objects and grouping structure, but\n * renders them from leaf level back toward the root.\n *\n * @example\n * ```ts\n * const footerGroups = table_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Flattens every header from every header group into one array.\n *\n * The result includes parent headers and placeholder headers, in header-group\n * order from top to bottom.\n *\n * @example\n * ```ts\n * const flatHeaders = table_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j]!)\n }\n }\n return result\n}\n\n/**\n * Collects only the leaf headers from the current header tree.\n *\n * Parent/group headers are skipped, making the result suitable for rendering\n * one header per visible leaf column.\n *\n * @example\n * ```ts\n * const leafHeaders = table_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push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;CAAY,GAClD,KACF;AACF;;;;;;;;;;;;AAaA,SAAgB,sBAGd,OAAyC;CAEzC,OAAO,CAAC,GADa,MAAM,gBACL,CAAC,CAAC,CAAC,QAAQ;AACnC;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,EAAE,CAAE;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,EAAG;CAE3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,aAAa,MAAM,gBAAgB,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC;CAC3D,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,EAAE,CAAE,eAAe;EAClD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,EAAG;CAE/B;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"coreHeadersFeature.utils.js","names":[],"sources":["../../../src/core/headers/coreHeadersFeature.utils.ts"],"sourcesContent":["import { getDefaultColumnPinningState } from '../../features/column-pinning/columnPinningFeature.utils'\nimport {\n column_getIsVisible,\n table_getVisibleLeafColumns,\n} from '../../features/column-visibility/columnVisibilityFeature.utils'\nimport { callMemoOrStaticFn } from '../../utils'\nimport { buildHeaderGroups } from './buildHeaderGroups'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Header } from '../../types/Header'\nimport type { RowData } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Header_Header } from './coreHeadersFeature.types'\n\n/**\n * Walks a header tree and collects all descendant leaf headers.\n *\n * The header itself is included after its descendants, matching the recursive\n * shape used by nested header groups.\n *\n * @example\n * ```ts\n * const leafHeaders = header_getLeafHeaders(header)\n * ```\n */\nexport function header_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n const leafHeaders: Array<Header<TFeatures, TData, TValue>> = []\n\n const recurseHeader = (h: Header_Header<TFeatures, TData, TValue>) => {\n if (h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TFeatures, TData, TValue>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n}\n\n/**\n * Builds the render context passed to a column's `header` or `footer` template.\n *\n * The context contains the header, its column, and the owning table instance.\n *\n * @example\n * ```ts\n * const context = header_getContext(header)\n * ```\n */\nexport function header_getContext<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue,\n>(header: Header<TFeatures, TData, TValue>) {\n return {\n column: header.column,\n header,\n table: header.column.table,\n }\n}\n\n/**\n * Builds visible header groups for the current column tree.\n *\n * Column visibility and pinning are applied before groups are built. When no\n * columns are pinned, the fast path skips pin partitioning.\n *\n * @example\n * ```ts\n * const headerGroups = table_getHeaderGroups(table)\n * ```\n */\nexport function table_getHeaderGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const { left, right } =\n table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()\n const allColumns = table.getAllColumns()\n const leafColumns = callMemoOrStaticFn(\n table,\n 'getVisibleLeafColumns',\n table_getVisibleLeafColumns,\n )\n\n // Fast path: no columns are pinned — skip per-side lookups, partition, and spread.\n if (!left.length && !right.length) {\n return buildHeaderGroups(allColumns, leafColumns, table)\n }\n\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const leftColumns: typeof leafColumns = []\n for (let i = 0; i < left.length; i++) {\n const column = leafColumnsById[left[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n leftColumns.push(column)\n }\n }\n\n const rightColumns: typeof leafColumns = []\n for (let i = 0; i < right.length; i++) {\n const column = leafColumnsById[right[i]!]\n if (\n column &&\n callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)\n ) {\n rightColumns.push(column)\n }\n }\n\n const centerColumns = leafColumns.filter(\n (column) => !left.includes(column.id) && !right.includes(column.id),\n )\n\n return buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table,\n )\n}\n\n/**\n * Builds footer groups by reversing the current header groups.\n *\n * Footer rendering uses the same header objects and grouping structure, but\n * renders them from leaf level back toward the root.\n *\n * @example\n * ```ts\n * const footerGroups = table_getFooterGroups(table)\n * ```\n */\nexport function table_getFooterGroups<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n return [...headerGroups].reverse()\n}\n\n/**\n * Flattens every header from every header group into one array.\n *\n * The result includes parent headers and placeholder headers, in header-group\n * order from top to bottom.\n *\n * @example\n * ```ts\n * const flatHeaders = table_getFlatHeaders(table)\n * ```\n */\nexport function table_getFlatHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const headerGroups = table.getHeaderGroups()\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < headerGroups.length; i++) {\n const headers = headerGroups[i]!.headers\n for (let j = 0; j < headers.length; j++) {\n result.push(headers[j]!)\n }\n }\n return result\n}\n\n/**\n * Collects only the leaf headers from the current header tree.\n *\n * Parent/group headers are skipped, making the result suitable for rendering\n * one header per visible leaf column.\n *\n * @example\n * ```ts\n * const leafHeaders = table_getLeafHeaders(table)\n * ```\n */\nexport function table_getLeafHeaders<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>) {\n const topHeaders = table.getHeaderGroups()[0]?.headers ?? []\n const result: Array<Header<TFeatures, TData, unknown>> = []\n for (let i = 0; i < topHeaders.length; i++) {\n const leafHeaders = topHeaders[i]!.getLeafHeaders()\n for (let j = 0; j < leafHeaders.length; j++) {\n result.push(leafHeaders[j]!)\n }\n }\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,SAAgB,sBAId,QAA0C;CAC1C,MAAM,cAAuD,CAAC;CAE9D,MAAM,iBAAiB,MAA+C;EACpE,IAAI,EAAE,WAAW,QACf,EAAE,WAAW,IAAI,aAAa;EAEhC,YAAY,KAAK,CAAqC;CACxD;CAEA,cAAc,MAAM;CAEpB,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,kBAId,QAA0C;CAC1C,OAAO;EACL,QAAQ,OAAO;EACf;EACA,OAAO,OAAO,OAAO;CACvB;AACF;;;;;;;;;;;;AAaA,SAAgB,sBAGd,OAAyC;CACzC,MAAM,EAAE,MAAM,UACZ,MAAM,MAAM,eAAe,IAAI,KAAK,6BAA6B;CACnE,MAAM,aAAa,MAAM,cAAc;CACvC,MAAM,cAAc,mBAClB,OACA,yBACA,2BACF;CAGA,IAAI,CAAC,KAAK,UAAU,CAAC,MAAM,QACzB,OAAO,kBAAkB,YAAY,aAAa,KAAK;CAGzD,MAAM,kBAAkB,MAAM,sBAAsB;CAEpD,MAAM,cAAkC,CAAC;CACzC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,SAAS,gBAAgB,KAAK;EACpC,IACE,UACA,mBAAmB,QAAQ,gBAAgB,mBAAmB,GAE9D,YAAY,KAAK,MAAM;CAE3B;CAEA,MAAM,eAAmC,CAAC;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,SAAS,gBAAgB,MAAM;EACrC,IACE,UACA,mBAAmB,QAAQ,gBAAgB,mBAAmB,GAE9D,aAAa,KAAK,MAAM;CAE5B;CAEA,MAAM,gBAAgB,YAAY,QAC/B,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE,KAAK,CAAC,MAAM,SAAS,OAAO,EAAE,CACpE;CAEA,OAAO,kBACL,YACA;EAAC,GAAG;EAAa,GAAG;EAAe,GAAG;CAAY,GAClD,KACF;AACF;;;;;;;;;;;;AAaA,SAAgB,sBAGd,OAAyC;CAEzC,OAAO,CAAC,GADa,MAAM,gBACL,CAAC,CAAC,CAAC,QAAQ;AACnC;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,UAAU,aAAa,EAAE,CAAE;EACjC,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAClC,OAAO,KAAK,QAAQ,EAAG;CAE3B;CACA,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,qBAGd,OAAyC;CACzC,MAAM,aAAa,MAAM,gBAAgB,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC;CAC3D,MAAM,SAAmD,CAAC;CAC1D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,cAAc,WAAW,EAAE,CAAE,eAAe;EAClD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KACtC,OAAO,KAAK,YAAY,EAAG;CAE/B;CACA,OAAO;AACT"}
@@ -103,7 +103,7 @@ interface Column_ColumnFiltering<in out TFeatures extends TableFeatures, in out
103
103
  */
104
104
  setFilterValue: (updater: Updater<any>) => void;
105
105
  }
106
- interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
106
+ interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out _TData extends RowData> {
107
107
  /**
108
108
  * The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
109
109
  */
@@ -113,7 +113,7 @@ interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out TDa
113
113
  */
114
114
  columnFiltersMeta: Record<string, ExtractFilterMeta<TFeatures>>;
115
115
  }
116
- interface TableOptions_ColumnFiltering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
116
+ interface TableOptions_ColumnFiltering<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
117
117
  /**
118
118
  * Enables column-specific filtering for all columns that also allow it.
119
119
  */
@@ -103,7 +103,7 @@ interface Column_ColumnFiltering<in out TFeatures extends TableFeatures, in out
103
103
  */
104
104
  setFilterValue: (updater: Updater<any>) => void;
105
105
  }
106
- interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
106
+ interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out _TData extends RowData> {
107
107
  /**
108
108
  * The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
109
109
  */
@@ -113,7 +113,7 @@ interface Row_ColumnFiltering<in out TFeatures extends TableFeatures, in out TDa
113
113
  */
114
114
  columnFiltersMeta: Record<string, ExtractFilterMeta<TFeatures>>;
115
115
  }
116
- interface TableOptions_ColumnFiltering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
116
+ interface TableOptions_ColumnFiltering<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
117
117
  /**
118
118
  * Enables column-specific filtering for all columns that also allow it.
119
119
  */
@@ -142,7 +142,7 @@ interface TableOptions_ColumnGrouping {
142
142
  onGroupingChange?: OnChangeFn<GroupingState>;
143
143
  }
144
144
  type GroupingColumnMode = false | 'reorder' | 'remove';
145
- interface Table_ColumnGrouping<in out TFeatures extends TableFeatures, in out TData extends RowData> {
145
+ interface Table_ColumnGrouping<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
146
146
  /**
147
147
  * Resets `grouping` to `initialState.grouping`.
148
148
  *
@@ -142,7 +142,7 @@ interface TableOptions_ColumnGrouping {
142
142
  onGroupingChange?: OnChangeFn<GroupingState>;
143
143
  }
144
144
  type GroupingColumnMode = false | 'reorder' | 'remove';
145
- interface Table_ColumnGrouping<in out TFeatures extends TableFeatures, in out TData extends RowData> {
145
+ interface Table_ColumnGrouping<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
146
146
  /**
147
147
  * Resets `grouping` to `initialState.grouping`.
148
148
  *
@@ -1 +1 @@
1
- {"version":3,"file":"columnGroupingFeature.utils.cjs","names":["isFunction","cloneState","hasOwn"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n row.index,\n row,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAmD;CACnD,QACG,OAAO,UAAU,kBAAkB,UACnC,OAAO,MAAM,QAAQ,kBAAkB,UACvC,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,OAAO,UAAU;AAE/C;;;;;;;;;;;;AAaA,SAAgB,oBAId,QAA4D;CAC5D,OAAO,CAAC,CAAC,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE;AACjE;;;;;;;;;;;AAYA,SAAgB,uBAId,QAA2D;CAC3D,OAAO,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,OA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ACN,IAAI,qBAAqB,YAAY,OAAO,UAAU,iBACpD,IAAI,UACJ,IAAI,OACJ,GACF;CAGF,OAAO,IAAI,uBAAuB;AACpC;;;;;;;;;;;AAYA,SAAgB,kBAId,MAAsC;CACtC,MAAM,MAAM,KAAK;CACjB,OACE,oBAAoB,KAAK,MAAM,KAAK,KAAK,OAAO,OAAO,IAAI;AAE/D;;;;;;;;;;;;AAaA,SAAgB,sBAId,MAAsC;CACtC,OAAO,CAAC,kBAAkB,IAAI,KAAK,oBAAoB,KAAK,MAAM;AACpE;;;;;;;;;;;;AAaA,SAAgB,qBAId,MAAsC;CACtC,OACE,CAAC,kBAAkB,IAAI,KACvB,CAAC,sBAAsB,IAAI,KAC3B,CAAC,CAAC,KAAK,IAAI,QAAQ;AAEvB"}
1
+ {"version":3,"file":"columnGroupingFeature.utils.cjs","names":["isFunction","cloneState","hasOwn"],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n\n return undefined\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n row.index,\n row,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAm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Y,CAAC,CAAC,CAClE;AACF;;;;;;;;;;;AAYA,SAAgB,iBAGd,KAA0D;CAC1D,OAAO,CAAC,CAAC,IAAI;AACf;;;;;;;;;;;;AAaA,SAAgB,qBAGd,KAA0D,UAAkB;CAC5E,IAAI,IAAI,wBAAwBC,qBAAO,IAAI,sBAAsB,QAAQ,GACvE,OAAO,IAAI,qBAAqB;CAGlC,MAAM,SAAS,IAAI,MAAM,UAAU,QAAQ;CAK3C,IAAI,CAAC,OAAO,UAAU,kBACpB,OAAO,IAAI,SAAS,QAAQ;CAG9B,IAAI,IAAI,sBACN,IAAI,qBAAqB,YAAY,OAAO,UAAU,iBACpD,IAAI,UACJ,IAAI,OACJ,GACF;CAGF,OAAO,IAAI,uBAAuB;AACpC;;;;;;;;;;;AAYA,SAAgB,kBAId,MAAsC;CACtC,MAAM,MAAM,KAAK;CACjB,OACE,oBAAoB,KAAK,MAAM,KAAK,KAAK,OAAO,OAAO,IAAI;AAE/D;;;;;;;;;;;;AAaA,SAAgB,sBAId,MAAsC;CACtC,OAAO,CAAC,kBAAkB,IAAI,KAAK,oBAAoB,KAAK,MAAM;AACpE;;;;;;;;;;;;AAaA,SAAgB,qBAId,MAAsC;CACtC,OACE,CAAC,kBAAkB,IAAI,KACvB,CAAC,sBAAsB,IAAI,KAC3B,CAAC,CAAC,KAAK,IAAI,QAAQ;AAEvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"columnGroupingFeature.utils.js","names":[],"sources":["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n row.index,\n row,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.sub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["../../../src/features/column-grouping/columnGroupingFeature.utils.ts"],"sourcesContent":["import { cloneState, hasOwn, isFunction } from '../../utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { Cell } from '../../types/Cell'\nimport type {\n AggregationFn,\n GroupingState,\n Row_ColumnGrouping,\n} from './columnGroupingFeature.types'\n\n/**\n * Creates the default grouping state.\n *\n * The feature default is an empty array, meaning no columns are grouped. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const grouping = getDefaultGroupingState()\n * ```\n */\nexport function getDefaultGroupingState(): GroupingState {\n return []\n}\n\n/**\n * Adds or removes this column id from the grouping state.\n *\n * Existing grouped columns keep their order. A column already present in\n * `state.grouping` is removed; otherwise it is appended.\n *\n * @example\n * ```ts\n * column_toggleGrouping(column)\n * ```\n */\nexport function column_toggleGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n table_setGrouping(column.table, (old) => {\n // Find any existing grouping for this column\n if (old.includes(column.id)) {\n return old.filter((d) => d !== column.id)\n }\n\n return [...old, column.id]\n })\n}\n\n/**\n * Checks whether this column can be used for grouping.\n *\n * Grouping must be enabled at the column and table level, and the column must\n * either have an accessor or provide `getGroupingValue`.\n *\n * @example\n * ```ts\n * const canGroup = column_getCanGroup(column)\n * ```\n */\nexport function column_getCanGroup<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableGrouping ?? true) &&\n (column.table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\n )\n}\n\n/**\n * Checks whether this column id is present in `state.grouping`.\n *\n * The result only reflects grouping state, not whether the grouped row model has\n * been calculated yet.\n *\n * @example\n * ```ts\n * const isGrouped = column_getIsGrouped(column)\n * ```\n */\nexport function column_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return !!column.table.atoms.grouping?.get()?.includes(column.id)\n}\n\n/**\n * Finds this column's position in the ordered grouping state.\n *\n * The result is `-1` when the column is not grouped.\n *\n * @example\n * ```ts\n * const index = column_getGroupedIndex(column)\n * ```\n */\nexport function column_getGroupedIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return column.table.atoms.grouping?.get()?.indexOf(column.id) ?? -1\n}\n\n/**\n * Creates a header/control handler that toggles grouping for this column.\n *\n * The handler is a no-op when `column_getCanGroup(column)` is false.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleGroupingHandler(column)\n * ```\n */\nexport function column_getToggleGroupingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canGroup = column_getCanGroup(column)\n\n return () => {\n if (!canGroup) return\n column_toggleGrouping(column)\n }\n}\n\n/**\n * Chooses a built-in aggregation function from the first core row value.\n *\n * Numeric columns default to `sum`, date-like values default to `extent`, and\n * other value types leave aggregation unspecified.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAutoAggregationFn(column)\n * ```\n */\nexport function column_getAutoAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns?.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns?.extent\n }\n\n return undefined\n}\n\n/**\n * Resolves the aggregation function configured for a column.\n *\n * Function-valued `columnDef.aggregationFn` is returned directly, `'auto'`\n * delegates to `column_getAutoAggregationFn`, and string values are looked up in\n * the table's aggregation function registry.\n *\n * @example\n * ```ts\n * const aggregationFn = column_getAggregationFn(column)\n * ```\n */\nexport function column_getAggregationFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const aggregationFns:\n | Record<string, AggregationFn<TFeatures, TData>>\n | undefined = column.table._rowModelFns.aggregationFns\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column_getAutoAggregationFn(column)\n : aggregationFns?.[column.columnDef.aggregationFn as string]\n}\n\n/**\n * Routes a grouping updater through the table's grouping change handler.\n *\n * The updater may be a next `GroupingState` array or a function of the previous\n * grouping state, matching the instance `table.setGrouping` behavior.\n *\n * @example\n * ```ts\n * table_setGrouping(table, (old) => [...old, 'status'])\n * ```\n */\nexport function table_setGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<GroupingState>) {\n table.options.onGroupingChange?.(updater)\n}\n\n/**\n * Resets `grouping` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.grouping` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetGrouping(table)\n * table_resetGrouping(table, true)\n * ```\n */\nexport function table_resetGrouping<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setGrouping(\n table,\n defaultState ? [] : cloneState(table.initialState.grouping ?? []),\n )\n}\n\n/**\n * Checks whether this row was created as a grouped row.\n *\n * Grouped rows carry a `groupingColumnId`; ordinary leaf rows do not.\n *\n * @example\n * ```ts\n * const isGrouped = row_getIsGrouped(row)\n * ```\n */\nexport function row_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>) {\n return !!row.groupingColumnId\n}\n\n/**\n * Reads and caches this row's grouping value for a column.\n *\n * `columnDef.getGroupingValue` wins when provided; otherwise the normal row\n * accessor value is used.\n *\n * @example\n * ```ts\n * const groupValue = row_getGroupingValue(row, 'status')\n * ```\n */\nexport function row_getGroupingValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(row: Row<TFeatures, TData> & Partial<Row_ColumnGrouping>, columnId: string) {\n if (row._groupingValuesCache && hasOwn(row._groupingValuesCache, columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = row.table.getColumn(columnId) as Column_Internal<\n TFeatures,\n TData\n >\n\n if (!column.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n if (row._groupingValuesCache) {\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original,\n row.index,\n row,\n )\n }\n\n return row._groupingValuesCache?.[columnId]\n}\n\n/**\n * Checks whether this cell represents the grouped column for a grouped row.\n *\n * This is the cell that usually renders the grouped value and expansion control.\n *\n * @example\n * ```ts\n * const isGroupedCell = cell_getIsGrouped(cell)\n * ```\n */\nexport function cell_getIsGrouped<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n const row = cell.row as Row<TFeatures, TData> & Partial<Row_ColumnGrouping>\n return (\n column_getIsGrouped(cell.column) && cell.column.id === row.groupingColumnId\n )\n}\n\n/**\n * Checks whether this cell is a placeholder hidden by grouping.\n *\n * Placeholder cells belong to grouped columns other than the row's active\n * grouping column.\n *\n * @example\n * ```ts\n * const isPlaceholder = cell_getIsPlaceholder(cell)\n * ```\n */\nexport function cell_getIsPlaceholder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return !cell_getIsGrouped(cell) && column_getIsGrouped(cell.column)\n}\n\n/**\n * Checks whether this cell should render an aggregated value.\n *\n * Aggregated cells are non-placeholder, non-grouped cells on rows that have\n * subRows.\n *\n * @example\n * ```ts\n * const isAggregated = cell_getIsAggregated(cell)\n * ```\n */\nexport function cell_getIsAggregated<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(cell: Cell<TFeatures, TData, TValue>) {\n return (\n !cell_getIsGrouped(cell) &&\n !cell_getIsPlaceholder(cell) &&\n !!cell.row.subRows.length\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,0BAAyC;CACvD,OAAO,CAAC;AACV;;;;;;;;;;;;AAaA,SAAgB,sBAId,QAAmD;CACnD,kBAAkB,OAAO,QAAQ,QAAQ;EAEvC,IAAI,IAAI,SAAS,OAAO,EAAE,GACxB,OAAO,IAAI,QAAQ,MAAM,MAAM,OAAO,EAAE;EAG1C,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;CAC3B,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBAId,QAAmD;CACnD,QACG,OAAO,UAAU,kBAAkB,UACnC,OAAO,MAAM,QAAQ,kBAAkB,UACvC,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,OAAO,UAAU;AAE/C;;;;;;;;;;;;AAaA,SAAgB,oBAId,QAA4D;CAC5D,OAAO,CAAC,CAAC,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE;AACjE;;;;;;;;;;;AAYA,SAAgB,uBAId,QAA2D;CAC3D,OAAO,OAAO,MAAM,MAAM,UAAU,IAAI,CAAC,EAAE,QAAQ,OAAO,EAAE,KAAK;AACnE;;;;;;;;;;;AAYA,SAAgB,gCAId,QAAmD;CACnD,MAAM,WAAW,mBAAmB,MAAM;CAE1C,aAAa;EACX,IAAI,CAAC,UAAU;EACf,sBAAsB,MAAM;CAC9B;AACF;;;;;;;;;;;;AAaA,SAAgB,4B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M,KAAK,KAAK,OAAO,OAAO,IAAI;AAE/D;;;;;;;;;;;;AAaA,SAAgB,sBAId,MAAsC;CACtC,OAAO,CAAC,kBAAkB,IAAI,KAAK,oBAAoB,KAAK,MAAM;AACpE;;;;;;;;;;;;AAaA,SAAgB,qBAId,MAAsC;CACtC,OACE,CAAC,kBAAkB,IAAI,KACvB,CAAC,sBAAsB,IAAI,KAC3B,CAAC,CAAC,KAAK,IAAI,QAAQ;AAEvB"}
@@ -57,7 +57,7 @@ interface Column_ColumnOrdering {
57
57
  interface ColumnOrderDefaultOptions {
58
58
  onColumnOrderChange: OnChangeFn<ColumnOrderState>;
59
59
  }
60
- interface Table_ColumnOrdering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
60
+ interface Table_ColumnOrdering<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
61
61
  /**
62
62
  * Builds column-id to index records for each visible pinning region.
63
63
  *
@@ -57,7 +57,7 @@ interface Column_ColumnOrdering {
57
57
  interface ColumnOrderDefaultOptions {
58
58
  onColumnOrderChange: OnChangeFn<ColumnOrderState>;
59
59
  }
60
- interface Table_ColumnOrdering<in out TFeatures extends TableFeatures, in out TData extends RowData> {
60
+ interface Table_ColumnOrdering<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
61
61
  /**
62
62
  * Builds column-id to index records for each visible pinning region.
63
63
  *
@@ -63,7 +63,7 @@ interface TableOptions_RowExpanding<in out TFeatures extends TableFeatures, in o
63
63
  */
64
64
  paginateExpandedRows?: boolean;
65
65
  }
66
- interface Table_RowExpanding<in out TFeatures extends TableFeatures, in out TData extends RowData> {
66
+ interface Table_RowExpanding<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
67
67
  autoResetExpanded: () => void;
68
68
  /**
69
69
  * Checks whether at least one row can be expanded.
@@ -63,7 +63,7 @@ interface TableOptions_RowExpanding<in out TFeatures extends TableFeatures, in o
63
63
  */
64
64
  paginateExpandedRows?: boolean;
65
65
  }
66
- interface Table_RowExpanding<in out TFeatures extends TableFeatures, in out TData extends RowData> {
66
+ interface Table_RowExpanding<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
67
67
  autoResetExpanded: () => void;
68
68
  /**
69
69
  * Checks whether at least one row can be expanded.
@@ -37,7 +37,7 @@ interface TableOptions_RowPagination {
37
37
  interface PaginationDefaultOptions {
38
38
  onPaginationChange: OnChangeFn<PaginationState>;
39
39
  }
40
- interface Table_RowPagination<in out TFeatures extends TableFeatures, in out TData extends RowData> {
40
+ interface Table_RowPagination<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
41
41
  _autoResetPageIndex: () => void;
42
42
  /**
43
43
  * Checks whether the current page index can move forward.
@@ -37,7 +37,7 @@ interface TableOptions_RowPagination {
37
37
  interface PaginationDefaultOptions {
38
38
  onPaginationChange: OnChangeFn<PaginationState>;
39
39
  }
40
- interface Table_RowPagination<in out TFeatures extends TableFeatures, in out TData extends RowData> {
40
+ interface Table_RowPagination<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
41
41
  _autoResetPageIndex: () => void;
42
42
  /**
43
43
  * Checks whether the current page index can move forward.
@@ -161,7 +161,7 @@ interface TableOptions_RowSorting {
161
161
  */
162
162
  sortDescFirst?: boolean;
163
163
  }
164
- interface Table_RowSorting<in out TFeatures extends TableFeatures, in out TData extends RowData> {
164
+ interface Table_RowSorting<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
165
165
  /**
166
166
  * Resets `sorting` to `initialState.sorting`.
167
167
  *
@@ -161,7 +161,7 @@ interface TableOptions_RowSorting {
161
161
  */
162
162
  sortDescFirst?: boolean;
163
163
  }
164
- interface Table_RowSorting<in out TFeatures extends TableFeatures, in out TData extends RowData> {
164
+ interface Table_RowSorting<in out _TFeatures extends TableFeatures, in out _TData extends RowData> {
165
165
  /**
166
166
  * Resets `sorting` to `initialState.sorting`.
167
167
  *
package/dist/utils.cjs CHANGED
@@ -134,16 +134,12 @@ const pad = (str, num) => {
134
134
  * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.
135
135
  */
136
136
  function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOptions }) {
137
- let beforeCompareTime;
138
- let afterCompareTime;
139
137
  let startCalcTime;
140
138
  let endCalcTime;
141
139
  let runCount = 0;
142
140
  let debug;
143
- let debugCache;
144
141
  if (process.env.NODE_ENV === "development") {
145
- const { debugCache: _debugCache, debugAll } = table.options;
146
- debugCache = _debugCache;
142
+ const { debugAll } = table.options;
147
143
  const { parentName } = getFunctionNameInfo(fnName, ".");
148
144
  debug = debugAll || table.options[`debug${(parentName != "table" ? parentName + "s" : parentName).replace(parentName, parentName.charAt(0).toUpperCase() + parentName.slice(1))}`] || (feature ? table.options[`debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`] : false);
149
145
  }
@@ -166,16 +162,8 @@ function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOpt
166
162
  schedule(() => untrack(() => onAfterUpdate()));
167
163
  };
168
164
  const debugOptions = process.env.NODE_ENV === "development" ? {
169
- onBeforeCompare: () => {
170
- if (debugCache) beforeCompareTime = performance.now();
171
- },
172
- onAfterCompare: (depsChanged) => {
173
- if (debugCache) {
174
- afterCompareTime = performance.now();
175
- const compareTime = Math.round((afterCompareTime - beforeCompareTime) * 100) / 100;
176
- if (!depsChanged) logTime(compareTime, depsChanged);
177
- }
178
- },
165
+ onBeforeCompare: () => {},
166
+ onAfterCompare: (depsChanged) => {},
179
167
  onBeforeUpdate: () => {
180
168
  if (debug) startCalcTime = performance.now();
181
169
  },
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(\n key: K,\n // Minimal structural shape so any table view (public `Table`,\n // `Table_Internal`, or a custom plugin table) can be passed without forcing\n // the compiler to relate the full table types.\n instance: {\n readonly options: { readonly atoms?: object | undefined }\n readonly baseAtoms: object\n },\n) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\n/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,iBAAoB,SAAqB,OAAa;CACpE,OAAO,OAAO,YAAY,aACrB,QAAwB,KAAK,IAC9B;AACN;;;;;;AAOA,SAAgB,WAAc,OAAa;CACzC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,UAAU;CAG7B,IAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,KAAK;EAEzC,IAAI,UAAU,OAAO,aAAa,UA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GAAG;EACH,GAAG;CACL,CAAC;AACH;;;;AAeA,SAAgB,oBACd,cACA,UAAqB,KACrB;CACA,MAAM,CAAC,YAAY,SAAS,aAAa,MAAM,OAAO;CAEtD,OAAO;EAAE;EAAO,WADE,WAAW,GAAG;EACR;CAAW;AAKrC;;;;;AAMA,SAAgB,gBAMd,SACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAEzD,AAAC,MAA8B,SAAS,WACrC,UAAU;GACR;GACA;GACA;GACA;GACA;EACF,CAAC,IACD;CACN;AACF;;;;;;;;AAmBA,SAAgB,oBAMd,SACA,WACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAE1D,IAAI,UAAU;GAGZ,MAAM,UAAU,SAAS;GAEzB,UAAU,SAAS,SAAqB,GAAG,MAAkB;IAE3D,IAAI,CAAC,KAAK,UAAU;KAClB,MAAM,OAAO;KACb,KAAK,WAAW,UAAU;MACxB,WAAW,YAAY,SAAS,MAAM,OAAO;MAC7C,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;MACjC;MACA,UAAU,KAAK;MACf;MACA;KACF,CAAC;IACH;IACA,OAAO,KAAK,QAAQ,CAAC,GAAG,IAAI;GAC9B;EACF,OAEE,UAAU,SAAS,SAAqB,GAAG,MAAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;CACT,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(\n key: K,\n // Minimal structural shape so any table view (public `Table`,\n // `Table_Internal`, or a custom plugin table) can be passed without forcing\n // the compiler to relate the full table types.\n instance: {\n readonly options: { readonly atoms?: object | undefined }\n readonly baseAtoms: object\n },\n) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\n/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugAll } = table.options\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<_TDeps extends ReadonlyArray<any>, _TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<_TDeps extends ReadonlyArray<any>, _TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,iBAAoB,SAAqB,OAAa;CACpE,OAAO,OAAO,YAAY,aACrB,QAAwB,KAAK,IAC9B;AACN;;;;;;AAOA,SAAgB,WAAc,OAAa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;CACA,MAAM,CAAC,YAAY,SAAS,aAAa,MAAM,OAAO;CAEtD,OAAO;EAAE;EAAO,WADE,WAAW,GAAG;EACR;CAAW;AAKrC;;;;;AAMA,SAAgB,gBAMd,SACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAEzD,AAAC,MAA8B,SAAS,WACrC,UAAU;GACR;GACA;GACA;GACA;GACA;EACF,CAAC,IACD;CACN;AACF;;;;;;;;AAmBA,SAAgB,oBAMd,SACA,WACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAE1D,IAAI,UAAU;GAGZ,MAAM,UAAU,SAAS;GAEzB,UAAU,SAAS,SAAqB,GAAG,MAAkB;IAE3D,IAAI,CAAC,KAAK,UAAU;KAClB,MAAM,OAAO;KACb,KAAK,WAAW,UAAU;MACxB,WAAW,YAAY,SAAS,MAAM,OAAO;MAC7C,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;MACjC;MACA,UAAU,KAAK;MACf;MACA;KACF,CAAC;IACH;IACA,OAAO,KAAK,QAAQ,CAAC,GAAG,IAAI;GAC9B;EACF,OAEE,UAAU,SAAS,SAAqB,GAAG,MAAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;CACT,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
package/dist/utils.d.cts CHANGED
@@ -96,7 +96,7 @@ declare function tableMemo<TFeatures extends TableFeatures, TDeps extends Readon
96
96
  table,
97
97
  ...memoOptions
98
98
  }: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>): (depArgs?: TDepArgs | undefined) => TResult;
99
- interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {
99
+ interface API<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
100
100
  fn: (...args: any) => any;
101
101
  memoDeps?: (depArgs?: any) => [...any] | undefined;
102
102
  }
@@ -114,7 +114,7 @@ declare function getFunctionNameInfo(staticFnName: string, splitBy?: '_' | '.'):
114
114
  * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.
115
115
  */
116
116
  declare function assignTableAPIs<TFeatures extends TableFeatures, TData extends RowData, TDeps extends ReadonlyArray<any>, TDepArgs>(feature: keyof TFeatures & string, table: Table<TFeatures, TData>, apis: APIObject<TDeps, NoInfer<TDepArgs>>): void;
117
- interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {
117
+ interface PrototypeAPI<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
118
118
  fn: (self: any, ...args: any) => any;
119
119
  memoDeps?: (self: any, depArgs?: any) => [...any] | undefined;
120
120
  }
package/dist/utils.d.ts CHANGED
@@ -96,7 +96,7 @@ declare function tableMemo<TFeatures extends TableFeatures, TDeps extends Readon
96
96
  table,
97
97
  ...memoOptions
98
98
  }: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>): (depArgs?: TDepArgs | undefined) => TResult;
99
- interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {
99
+ interface API<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
100
100
  fn: (...args: any) => any;
101
101
  memoDeps?: (depArgs?: any) => [...any] | undefined;
102
102
  }
@@ -114,7 +114,7 @@ declare function getFunctionNameInfo(staticFnName: string, splitBy?: '_' | '.'):
114
114
  * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.
115
115
  */
116
116
  declare function assignTableAPIs<TFeatures extends TableFeatures, TData extends RowData, TDeps extends ReadonlyArray<any>, TDepArgs>(feature: keyof TFeatures & string, table: Table<TFeatures, TData>, apis: APIObject<TDeps, NoInfer<TDepArgs>>): void;
117
- interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {
117
+ interface PrototypeAPI<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
118
118
  fn: (self: any, ...args: any) => any;
119
119
  memoDeps?: (self: any, depArgs?: any) => [...any] | undefined;
120
120
  }
package/dist/utils.js CHANGED
@@ -133,16 +133,12 @@ const pad = (str, num) => {
133
133
  * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.
134
134
  */
135
135
  function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOptions }) {
136
- let beforeCompareTime;
137
- let afterCompareTime;
138
136
  let startCalcTime;
139
137
  let endCalcTime;
140
138
  let runCount = 0;
141
139
  let debug;
142
- let debugCache;
143
140
  if (process.env.NODE_ENV === "development") {
144
- const { debugCache: _debugCache, debugAll } = table.options;
145
- debugCache = _debugCache;
141
+ const { debugAll } = table.options;
146
142
  const { parentName } = getFunctionNameInfo(fnName, ".");
147
143
  debug = debugAll || table.options[`debug${(parentName != "table" ? parentName + "s" : parentName).replace(parentName, parentName.charAt(0).toUpperCase() + parentName.slice(1))}`] || (feature ? table.options[`debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`] : false);
148
144
  }
@@ -165,16 +161,8 @@ function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOpt
165
161
  schedule(() => untrack(() => onAfterUpdate()));
166
162
  };
167
163
  const debugOptions = process.env.NODE_ENV === "development" ? {
168
- onBeforeCompare: () => {
169
- if (debugCache) beforeCompareTime = performance.now();
170
- },
171
- onAfterCompare: (depsChanged) => {
172
- if (debugCache) {
173
- afterCompareTime = performance.now();
174
- const compareTime = Math.round((afterCompareTime - beforeCompareTime) * 100) / 100;
175
- if (!depsChanged) logTime(compareTime, depsChanged);
176
- }
177
- },
164
+ onBeforeCompare: () => {},
165
+ onAfterCompare: (depsChanged) => {},
178
166
  onBeforeUpdate: () => {
179
167
  if (debug) startCalcTime = performance.now();
180
168
  },
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(\n key: K,\n // Minimal structural shape so any table view (public `Table`,\n // `Table_Internal`, or a custom plugin table) can be passed without forcing\n // the compiler to relate the full table types.\n instance: {\n readonly options: { readonly atoms?: object | undefined }\n readonly baseAtoms: object\n },\n) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\n/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;;;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E,UAAU,SAAS,SAAqB,GAAG,MAAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;CACT,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(\n key: K,\n // Minimal structural shape so any table view (public `Table`,\n // `Table_Internal`, or a custom plugin table) can be passed without forcing\n // the compiler to relate the full table types.\n instance: {\n readonly options: { readonly atoms?: object | undefined }\n readonly baseAtoms: object\n },\n) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<TNode>) => {\n subArr.forEach((item) => {\n flat.push(item)\n const children = getChildren(item)\n if (children.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n}\n\n/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugAll } = table.options\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<_TDeps extends ReadonlyArray<any>, _TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<_TDeps extends ReadonlyArray<any>, _TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;;;;;AAUA,SAAgB,iBAAoB,SAAqB,OAAa;CACpE,OAAO,OAAO,YAAY,aACrB,QAAwB,KAAK,IAC9B;AACN;;;;;;AAOA,SAAgB,WAAc,OAAa;CACzC,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,UAAU;CAG7B,IAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,KAAK;EAEzC,IAAI,UAAU,OAAO,aAAa,UAAU,MAC1C,OAAO;EAGT,MAAM,OAAgC,UAAU,OAAO,cAAc,IAAI,CAAC;EAC1E,MAAM,OAAO,OAAO,KAAK,KAAK;EAE9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,OAAO,eAAe,MAAM,KAAK;IAC/B,cAAc;IACd,YAAY;IACZ,OAAO,WAAY,MAAkC,IAAI;IACzD,UAAU;GACZ,CAAC;EACH;EAEA,OAAO;CACT;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,mCAGd,QAAiB,QAAoC;CACrD,MAAM,OAAO,OAAO,KAAK,MAAM;CAC/B,MAAM,eAAe;CAErB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,IAAI,WAAW,QAAQ,KAAK,QAAQ,eACvC,aAAa,OAAO,OAAO;CAE/B;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,gBAA0D;CACxE,OAAO,OAAO,OAAO,IAAI;AAC3B;;;;AAKA,SAAgB,OAAO,KAAa,KAA2B;CAC7D,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG;AACtD;;;;;;A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B;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;CACT,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
- "version": "9.0.0-beta.36",
3
+ "version": "9.0.0-beta.37",
4
4
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -10,7 +10,6 @@ import type { Header } from '../../types/Header'
10
10
  import type { RowData } from '../../types/type-utils'
11
11
  import type { TableFeatures } from '../../types/TableFeatures'
12
12
  import type { Header_Header } from './coreHeadersFeature.types'
13
- import type { Column } from '../../types/Column'
14
13
 
15
14
  /**
16
15
  * Walks a header tree and collects all descendant leaf headers.
@@ -1,4 +1,3 @@
1
- import type { Table } from '../../types/Table'
2
1
  import type { Table_RowModels_Faceted } from '../../features/column-faceting/columnFacetingFeature.types'
3
2
  import type { Table_RowModels_Filtered } from '../../features/column-filtering/columnFilteringFeature.types'
4
3
  import type { Table_RowModels_Grouped } from '../../features/column-grouping/columnGroupingFeature.types'
@@ -12,6 +12,7 @@ import type { CachedRowModels } from '../../types/RowModel'
12
12
  import type { TableOptions } from '../../types/TableOptions'
13
13
  import type { TableState, TableState_All } from '../../types/TableState'
14
14
 
15
+ // @ts-expect-error Phantom type params: unused in this empty base declaration, but required with these exact names so user `declare module` augmentations merge correctly.
15
16
  export interface TableMeta<
16
17
  in out TFeatures extends TableFeatures,
17
18
  in out TData extends RowData,
@@ -1,4 +1,3 @@
1
- import type { Table } from '../../types/Table'
2
1
  import type { RowData } from '../../types/type-utils'
3
2
  import type { TableFeatures } from '../../types/TableFeatures'
4
3
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
@@ -165,7 +165,7 @@ export interface Column_ColumnFiltering<
165
165
 
166
166
  export interface Row_ColumnFiltering<
167
167
  in out TFeatures extends TableFeatures,
168
- in out TData extends RowData,
168
+ in out _TData extends RowData,
169
169
  > {
170
170
  /**
171
171
  * The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
@@ -178,8 +178,8 @@ export interface Row_ColumnFiltering<
178
178
  }
179
179
 
180
180
  export interface TableOptions_ColumnFiltering<
181
- in out TFeatures extends TableFeatures,
182
- in out TData extends RowData,
181
+ in out _TFeatures extends TableFeatures,
182
+ in out _TData extends RowData,
183
183
  > {
184
184
  /**
185
185
  * Enables column-specific filtering for all columns that also allow it.
@@ -197,8 +197,8 @@ export interface TableOptions_ColumnGrouping {
197
197
  export type GroupingColumnMode = false | 'reorder' | 'remove'
198
198
 
199
199
  export interface Table_ColumnGrouping<
200
- in out TFeatures extends TableFeatures,
201
- in out TData extends RowData,
200
+ in out _TFeatures extends TableFeatures,
201
+ in out _TData extends RowData,
202
202
  > {
203
203
  /**
204
204
  * Resets `grouping` to `initialState.grouping`.
@@ -166,6 +166,8 @@ export function column_getAutoAggregationFn<
166
166
  if (Object.prototype.toString.call(value) === '[object Date]') {
167
167
  return aggregationFns?.extent
168
168
  }
169
+
170
+ return undefined
169
171
  }
170
172
 
171
173
  /**
@@ -63,8 +63,8 @@ export interface ColumnOrderDefaultOptions {
63
63
  }
64
64
 
65
65
  export interface Table_ColumnOrdering<
66
- in out TFeatures extends TableFeatures,
67
- in out TData extends RowData,
66
+ in out _TFeatures extends TableFeatures,
67
+ in out _TData extends RowData,
68
68
  > {
69
69
  /**
70
70
  * Builds column-id to index records for each visible pinning region.
@@ -1,4 +1,3 @@
1
- import type { Table } from '../../types/Table'
2
1
  import type { OnChangeFn, RowData, Updater } from '../../types/type-utils'
3
2
  import type { TableFeatures } from '../../types/TableFeatures'
4
3
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
@@ -71,8 +70,8 @@ export interface TableOptions_RowExpanding<
71
70
  }
72
71
 
73
72
  export interface Table_RowExpanding<
74
- in out TFeatures extends TableFeatures,
75
- in out TData extends RowData,
73
+ in out _TFeatures extends TableFeatures,
74
+ in out _TData extends RowData,
76
75
  > {
77
76
  autoResetExpanded: () => void
78
77
  /**
@@ -1,5 +1,4 @@
1
1
  import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
2
- import type { Table } from '../../types/Table'
3
2
  import type { OnChangeFn, RowData, Updater } from '../../types/type-utils'
4
3
  import type { TableFeatures } from '../../types/TableFeatures'
5
4
 
@@ -42,8 +41,8 @@ export interface PaginationDefaultOptions {
42
41
  }
43
42
 
44
43
  export interface Table_RowPagination<
45
- in out TFeatures extends TableFeatures,
46
- in out TData extends RowData,
44
+ in out _TFeatures extends TableFeatures,
45
+ in out _TData extends RowData,
47
46
  > {
48
47
  _autoResetPageIndex: () => void
49
48
  /**
@@ -199,8 +199,8 @@ export interface TableOptions_RowSorting {
199
199
  }
200
200
 
201
201
  export interface Table_RowSorting<
202
- in out TFeatures extends TableFeatures,
203
- in out TData extends RowData,
202
+ in out _TFeatures extends TableFeatures,
203
+ in out _TData extends RowData,
204
204
  > {
205
205
  /**
206
206
  * Resets `sorting` to `initialState.sorting`.
@@ -15,6 +15,7 @@ import type { ColumnDef_ColumnVisibility } from '../features/column-visibility/c
15
15
  import type { ColumnDef_GlobalFiltering } from '../features/global-filtering/globalFilteringFeature.types'
16
16
  import type { ColumnDef_RowSorting } from '../features/row-sorting/rowSortingFeature.types'
17
17
 
18
+ // @ts-expect-error Phantom type params: unused in this empty base declaration, but required with these exact names so user `declare module` augmentations merge correctly.
18
19
  export interface ColumnMeta<
19
20
  in out TFeatures extends TableFeatures,
20
21
  in out TData extends RowData,
package/src/utils.ts CHANGED
@@ -254,8 +254,7 @@ export function tableMemo<
254
254
  let debugCache: boolean | undefined
255
255
 
256
256
  if (process.env.NODE_ENV === 'development') {
257
- const { debugCache: _debugCache, debugAll } = table.options
258
- debugCache = _debugCache
257
+ const { debugAll } = table.options
259
258
  const { parentName } = getFunctionNameInfo(fnName, '.')
260
259
 
261
260
  const debugByParent =
@@ -360,7 +359,7 @@ export function tableMemo<
360
359
  })
361
360
  }
362
361
 
363
- export interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {
362
+ export interface API<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
364
363
  fn: (...args: any) => any
365
364
  memoDeps?: (depArgs?: any) => [...any] | undefined
366
365
  }
@@ -415,7 +414,7 @@ export function assignTableAPIs<
415
414
  }
416
415
  }
417
416
 
418
- export interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {
417
+ export interface PrototypeAPI<_TDeps extends ReadonlyArray<any>, _TDepArgs> {
419
418
  fn: (self: any, ...args: any) => any
420
419
  memoDeps?: (self: any, depArgs?: any) => [...any] | undefined
421
420
  }