@tanstack/table-core 8.0.0-beta.2 → 8.0.0-beta.3

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.0.0-beta.2",
4
+ "version": "8.0.0-beta.3",
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",
@@ -254,7 +254,7 @@ export function createTableInstance<TGenerics extends TableGenerics>(
254
254
  return {
255
255
  header: props => props.header.column.id,
256
256
  footer: props => props.header.column.id,
257
- cell: props => props.getValue().toString?.() ?? null,
257
+ cell: props => props.getValue()?.toString?.() ?? null,
258
258
  ...instance._features.reduce((obj, feature) => {
259
259
  return Object.assign(obj, feature.getDefaultColumnDef?.())
260
260
  }, {}),
@@ -75,7 +75,6 @@ export type FiltersColumnDef<TGenerics extends TableGenerics> = {
75
75
  }
76
76
 
77
77
  export type FiltersColumn<TGenerics extends TableGenerics> = {
78
- filterFn: FilterFnOption<Overwrite<TGenerics, { Value: any }>>
79
78
  getAutoFilterFn: () => FilterFn<TGenerics> | undefined
80
79
  getFilterFn: () => FilterFn<TGenerics> | undefined
81
80
  setFilterValue: (updater: Updater<any>) => void
@@ -197,7 +196,6 @@ export const Filters: TableFeature = {
197
196
  instance: TableInstance<TGenerics>
198
197
  ): FiltersColumn<TGenerics> => {
199
198
  return {
200
- filterFn: column.filterFn,
201
199
  getAutoFilterFn: () => {
202
200
  const firstRow = instance.getCoreRowModel().flatRows[0]
203
201
 
@@ -228,15 +226,15 @@ export const Filters: TableFeature = {
228
226
  getFilterFn: () => {
229
227
  const userFilterFns = instance.options.filterFns
230
228
 
231
- return isFunction(column.filterFn)
232
- ? column.filterFn
233
- : column.filterFn === 'auto'
229
+ return isFunction(column.columnDef.filterFn)
230
+ ? column.columnDef.filterFn
231
+ : column.columnDef.filterFn === 'auto'
234
232
  ? column.getAutoFilterFn()
235
233
  : (userFilterFns as Record<string, any>)?.[
236
- column.filterFn as string
234
+ column.columnDef.filterFn as string
237
235
  ] ??
238
236
  (filterFns[
239
- column.filterFn as BuiltInFilterFn
237
+ column.columnDef.filterFn as BuiltInFilterFn
240
238
  ] as FilterFn<TGenerics>)
241
239
  },
242
240
  getCanFilter: () => {
@@ -52,7 +52,6 @@ export type GroupingColumnDef<TGenerics extends TableGenerics> = {
52
52
  }
53
53
 
54
54
  export type GroupingColumn<TGenerics extends TableGenerics> = {
55
- aggregationFn?: AggregationFnOption<Overwrite<TGenerics, { Value: any }>>
56
55
  getCanGroup: () => boolean
57
56
  getIsGrouped: () => boolean
58
57
  getGroupedIndex: () => number
@@ -108,6 +107,7 @@ export const Grouping: TableFeature = {
108
107
  TGenerics extends TableGenerics
109
108
  >(): GroupingColumnDef<TGenerics> => {
110
109
  return {
110
+ aggregatedCell: props => props.getValue()?.toString?.() ?? null,
111
111
  aggregationFn: 'auto',
112
112
  }
113
113
  },
@@ -180,8 +180,6 @@ export const Grouping: TableFeature = {
180
180
  if (Object.prototype.toString.call(value) === '[object Date]') {
181
181
  return aggregationFns.extent
182
182
  }
183
-
184
- return aggregationFns.count
185
183
  },
186
184
  getAggregationFn: () => {
187
185
  const userAggregationFns = instance.options.aggregationFns
@@ -190,15 +188,15 @@ export const Grouping: TableFeature = {
190
188
  throw new Error()
191
189
  }
192
190
 
193
- return isFunction(column.aggregationFn)
194
- ? column.aggregationFn
195
- : column.aggregationFn === 'auto'
191
+ return isFunction(column.columnDef.aggregationFn)
192
+ ? column.columnDef.aggregationFn
193
+ : column.columnDef.aggregationFn === 'auto'
196
194
  ? column.getAutoAggregationFn()
197
195
  : (userAggregationFns as Record<string, any>)?.[
198
- column.aggregationFn as string
196
+ column.columnDef.aggregationFn as string
199
197
  ] ??
200
198
  (aggregationFns[
201
- column.aggregationFn as BuiltInAggregationFn
199
+ column.columnDef.aggregationFn as BuiltInAggregationFn
202
200
  ] as AggregationFn<TGenerics>)
203
201
  },
204
202
  }
@@ -93,13 +93,6 @@ export function getGroupedRowModel<TGenerics extends TableGenerics>(): (
93
93
  )
94
94
 
95
95
  return row._groupingValuesCache[columnId]
96
- } else if (column.aggregationFn) {
97
- console.info({ column })
98
- throw new Error(
99
- process.env.NODE_ENV !== 'production'
100
- ? `Table: Invalid column.aggregateType option for column listed above`
101
- : ''
102
- )
103
96
  }
104
97
  },
105
98
  })