@tanstack/table-core 9.0.0-beta.35 → 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 (52) 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/core/table/coreTablesFeature.types.d.cts +2 -2
  4. package/dist/core/table/coreTablesFeature.types.d.ts +2 -2
  5. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +2 -2
  6. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +2 -2
  7. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +1 -1
  8. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +1 -1
  9. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  10. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  11. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +1 -1
  12. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +1 -1
  13. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +11 -2
  14. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  15. package/dist/features/column-resizing/columnResizingFeature.utils.js +11 -2
  16. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  17. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +1 -1
  18. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
  19. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +1 -1
  20. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
  21. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
  22. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
  23. package/dist/types/RowModel.d.cts +2 -4
  24. package/dist/types/RowModel.d.ts +2 -4
  25. package/dist/utils.cjs +3 -15
  26. package/dist/utils.cjs.map +1 -1
  27. package/dist/utils.d.cts +2 -2
  28. package/dist/utils.d.ts +2 -2
  29. package/dist/utils.js +3 -15
  30. package/dist/utils.js.map +1 -1
  31. package/dist/worker/initTableWorker.cjs.map +1 -1
  32. package/dist/worker/initTableWorker.js.map +1 -1
  33. package/dist/worker/rebuildRowModel.cjs.map +1 -1
  34. package/dist/worker/rebuildRowModel.js.map +1 -1
  35. package/package.json +2 -1
  36. package/src/core/headers/coreHeadersFeature.utils.ts +0 -1
  37. package/src/core/row-models/coreRowModelsFeature.types.ts +0 -1
  38. package/src/core/table/coreTablesFeature.types.ts +3 -2
  39. package/src/features/column-faceting/columnFacetingFeature.types.ts +0 -1
  40. package/src/features/column-filtering/columnFilteringFeature.types.ts +3 -3
  41. package/src/features/column-grouping/columnGroupingFeature.types.ts +2 -2
  42. package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -0
  43. package/src/features/column-ordering/columnOrderingFeature.types.ts +2 -2
  44. package/src/features/column-resizing/columnResizingFeature.utils.ts +22 -5
  45. package/src/features/row-expanding/rowExpandingFeature.types.ts +2 -3
  46. package/src/features/row-pagination/rowPaginationFeature.types.ts +2 -3
  47. package/src/features/row-sorting/rowSortingFeature.types.ts +2 -2
  48. package/src/types/ColumnDef.ts +1 -0
  49. package/src/types/RowModel.ts +6 -10
  50. package/src/utils.ts +3 -4
  51. package/src/worker/initTableWorker.ts +1 -1
  52. package/src/worker/rebuildRowModel.ts +8 -5
@@ -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.
@@ -263,17 +263,29 @@ export function header_getResizeHandler<
263
263
  return false
264
264
  },
265
265
  upHandler: (e: TouchEvent) => {
266
- contextDocument?.removeEventListener(
267
- 'touchmove',
268
- touchEvents.moveHandler,
269
- )
270
- contextDocument?.removeEventListener('touchend', touchEvents.upHandler)
266
+ removeTouchEvents()
271
267
  if (e.cancelable) {
272
268
  e.preventDefault()
273
269
  e.stopPropagation()
274
270
  }
275
271
  onEnd(e.touches[0]?.clientX)
276
272
  },
273
+ // the browser fires touchcancel instead of touchend when it takes over
274
+ // the gesture (system gesture, scroll takeover, tab switch); without
275
+ // this the non-passive touchmove listener stays on the document forever
276
+ cancelHandler: () => {
277
+ removeTouchEvents()
278
+ onEnd()
279
+ },
280
+ }
281
+
282
+ const removeTouchEvents = () => {
283
+ contextDocument?.removeEventListener('touchmove', touchEvents.moveHandler)
284
+ contextDocument?.removeEventListener('touchend', touchEvents.upHandler)
285
+ contextDocument?.removeEventListener(
286
+ 'touchcancel',
287
+ touchEvents.cancelHandler,
288
+ )
277
289
  }
278
290
 
279
291
  const passiveIfSupported = passiveEventSupported()
@@ -291,6 +303,11 @@ export function header_getResizeHandler<
291
303
  touchEvents.upHandler,
292
304
  passiveIfSupported,
293
305
  )
306
+ contextDocument?.addEventListener(
307
+ 'touchcancel',
308
+ touchEvents.cancelHandler,
309
+ passiveIfSupported,
310
+ )
294
311
  } else {
295
312
  contextDocument?.addEventListener(
296
313
  'mousemove',
@@ -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,
@@ -1,10 +1,7 @@
1
1
  import type { CachedRowModel_Faceted } from '../features/column-faceting/columnFacetingFeature.types'
2
2
  import type { CachedRowModel_Grouped } from '../features/column-grouping/columnGroupingFeature.types'
3
3
  import type { CachedRowModel_Filtered } from '../features/column-filtering/columnFilteringFeature.types'
4
- import type {
5
- CachedRowModel_Core,
6
- RowModel,
7
- } from '../core/row-models/coreRowModelsFeature.types'
4
+ import type { CachedRowModel_Core } from '../core/row-models/coreRowModelsFeature.types'
8
5
  import type { CachedRowModel_Expanded } from '../features/row-expanding/rowExpandingFeature.types'
9
6
  import type { CachedRowModel_Paginated } from '../features/row-pagination/rowPaginationFeature.types'
10
7
  import type { CachedRowModel_Sorted } from '../features/row-sorting/rowSortingFeature.types'
@@ -26,12 +23,11 @@ export interface CachedRowModels_FeatureMap<
26
23
  export type CachedRowModels<
27
24
  TFeatures extends TableFeatures,
28
25
  TData extends RowData,
29
- > = {
30
- CachedRowModel_Core: () => RowModel<TFeatures, TData>
31
- } & ExtractFeatureMapTypes<
32
- TFeatures,
33
- CachedRowModels_FeatureMap<TFeatures, TData>
34
- >
26
+ > = Partial<CachedRowModel_Core<TFeatures, TData>> &
27
+ ExtractFeatureMapTypes<
28
+ TFeatures,
29
+ CachedRowModels_FeatureMap<TFeatures, TData>
30
+ >
35
31
 
36
32
  export interface CachedRowModel_All<
37
33
  in out TFeatures extends TableFeatures,
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
  }
@@ -79,7 +79,7 @@ export function initTableWorker<
79
79
  ...config.features,
80
80
  },
81
81
  data: message.data,
82
- }) as unknown as Table_Internal<TFeatures, TData>
82
+ })
83
83
  // Only columns with an explicit aggregation get eagerly aggregated
84
84
  // per group. Sync tables aggregate lazily (visible cells only), so
85
85
  // auto-aggregating every column would explode on high-cardinality
@@ -2,6 +2,8 @@ import { constructRow } from '../core/rows/constructRow'
2
2
  import { hasOwn } from '../utils'
3
3
  import type { RowModel } from '../core/row-models/coreRowModelsFeature.types'
4
4
  import type { Table_Internal } from '../types/Table'
5
+ import type { TableFeatures } from '../types/TableFeatures'
6
+ import type { RowData } from '../types/type-utils'
5
7
  import type {
6
8
  TableWorkerRowNode,
7
9
  TableWorkerStagePayload,
@@ -13,8 +15,6 @@ export type TableWorkerDataPayload = Exclude<
13
15
  { kind: 'unchanged' }
14
16
  >
15
17
 
16
- type AnyTable = Table_Internal<any, any>
17
-
18
18
  // Main-thread side: payload + this table's core rows -> RowModel. Mirrors how
19
19
  // the sync row models treat rows: data rows are reused (with depth/parentId
20
20
  // rewritten, exactly like createGroupedRowModel does), synthetic group rows
@@ -32,8 +32,11 @@ function collectLeafRows(subRows: Array<any>, out: Array<any>) {
32
32
  }
33
33
  }
34
34
 
35
- export function rebuildRowModel(
36
- table: AnyTable,
35
+ export function rebuildRowModel<
36
+ TFeatures extends TableFeatures,
37
+ TData extends RowData,
38
+ >(
39
+ table: Table_Internal<TFeatures, TData>,
37
40
  payload: TableWorkerDataPayload,
38
41
  /**
39
42
  * Whether a flat payload should rewrite row depth/parentId. Mirrors core:
@@ -42,7 +45,7 @@ export function rebuildRowModel(
42
45
  * depths a grouped/sorted tree rebuild just assigned to shared row objects.
43
46
  */
44
47
  resetDepths: boolean,
45
- ): RowModel<any, any> {
48
+ ): RowModel<TFeatures, TData> {
46
49
  const core = table.getCoreRowModel()
47
50
 
48
51
  if (payload.kind === 'flat') {