@tanstack/table-core 8.5.1 → 8.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/table-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "8.5.1",
4
+ "version": "8.5.2",
5
5
  "description": "Headless UI for building powerful tables & datagrids for TS/JS.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/table#readme",
@@ -1,3 +1,8 @@
1
+ import {
2
+ CoreColumnDefDisplay,
3
+ CoreColumnDefDisplayWithStringHeader,
4
+ } from './core/column'
5
+ import { GroupingColumnDef } from './features/Grouping'
1
6
  import { AccessorFn, ColumnDef, RowData } from './types'
2
7
  import { DeepKeys, DeepValue, RequiredKeys } from './utils'
3
8
 
@@ -60,10 +65,14 @@ export type ColumnHelper<TData extends RowData> = {
60
65
  >
61
66
  ) => ColumnDef<TData, unknown>
62
67
  group: (
63
- column: RequiredKeys<
64
- Omit<ColumnDef<TData, unknown>, 'accessorKey' | 'accessorFn'>,
65
- 'id' | 'columns'
66
- >
68
+ column: Omit<
69
+ ColumnDef<TData, unknown>,
70
+ 'id' | 'header' | 'accessorKey' | 'accessorFn' | 'columns'
71
+ > &
72
+ (
73
+ | CoreColumnDefDisplayWithStringHeader<TData, unknown>
74
+ | CoreColumnDefDisplay<TData, unknown>
75
+ ) & { columns: ColumnDef<TData, any>[] }
67
76
  ) => ColumnDef<TData, unknown>
68
77
  }
69
78
 
package/src/core/table.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  } from '../types'
18
18
 
19
19
  //
20
- import { createColumn } from './column'
20
+ import { CoreColumnDefResolved, createColumn } from './column'
21
21
  import { Headers } from './headers'
22
22
  //
23
23
 
@@ -232,8 +232,21 @@ export function createTable<TData extends RowData>(
232
232
  >
233
233
 
234
234
  return {
235
- header: props => props.header.column.id,
236
- footer: props => props.header.column.id,
235
+ header: props => {
236
+ const resolvedColumnDef = props.header.column
237
+ .columnDef as CoreColumnDefResolved<TData>
238
+
239
+ if (resolvedColumnDef.accessorKey) {
240
+ return resolvedColumnDef.accessorKey
241
+ }
242
+
243
+ if (resolvedColumnDef.accessorFn) {
244
+ return resolvedColumnDef.id
245
+ }
246
+
247
+ return null
248
+ },
249
+ // footer: props => props.header.column.id,
237
250
  cell: props => props.renderValue<any>()?.toString?.() ?? null,
238
251
  ...table._features.reduce((obj, feature) => {
239
252
  return Object.assign(obj, feature.getDefaultColumnDef?.())