@tanstack/table-core 9.0.0-beta.19 → 9.0.0-beta.20

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 (79) hide show
  1. package/dist/core/cells/constructCell.d.cts +1 -1
  2. package/dist/core/cells/constructCell.d.ts +1 -1
  3. package/dist/core/cells/coreCellsFeature.types.d.cts +1 -1
  4. package/dist/core/cells/coreCellsFeature.types.d.ts +1 -1
  5. package/dist/core/cells/coreCellsFeature.utils.d.cts +1 -1
  6. package/dist/core/cells/coreCellsFeature.utils.d.ts +1 -1
  7. package/dist/core/columns/constructColumn.cjs +5 -0
  8. package/dist/core/columns/constructColumn.cjs.map +1 -1
  9. package/dist/core/columns/constructColumn.d.cts +2 -2
  10. package/dist/core/columns/constructColumn.d.ts +2 -2
  11. package/dist/core/columns/constructColumn.js +5 -0
  12. package/dist/core/columns/constructColumn.js.map +1 -1
  13. package/dist/core/columns/coreColumnsFeature.types.d.cts +2 -2
  14. package/dist/core/columns/coreColumnsFeature.types.d.ts +2 -2
  15. package/dist/core/columns/coreColumnsFeature.utils.d.cts +2 -2
  16. package/dist/core/columns/coreColumnsFeature.utils.d.ts +2 -2
  17. package/dist/core/headers/buildHeaderGroups.d.cts +1 -1
  18. package/dist/core/headers/buildHeaderGroups.d.ts +1 -1
  19. package/dist/core/headers/constructHeader.d.cts +1 -1
  20. package/dist/core/headers/constructHeader.d.ts +1 -1
  21. package/dist/core/headers/coreHeadersFeature.types.d.cts +1 -1
  22. package/dist/core/headers/coreHeadersFeature.types.d.ts +1 -1
  23. package/dist/core/headers/coreHeadersFeature.utils.d.cts +1 -1
  24. package/dist/core/headers/coreHeadersFeature.utils.d.ts +1 -1
  25. package/dist/core/row-models/coreRowModelsFeature.types.d.cts +1 -1
  26. package/dist/core/row-models/coreRowModelsFeature.types.d.ts +1 -1
  27. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +1 -1
  28. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +1 -1
  29. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +1 -1
  30. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +1 -1
  31. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +1 -1
  32. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +1 -1
  33. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +1 -1
  34. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +1 -1
  35. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +1 -1
  36. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +1 -1
  37. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +1 -1
  38. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +1 -1
  39. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +1 -1
  40. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +1 -1
  41. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +1 -1
  42. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +1 -1
  43. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +1 -1
  44. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +1 -1
  45. package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +1 -1
  46. package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +1 -1
  47. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +1 -1
  48. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +1 -1
  49. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +2 -2
  50. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  51. package/dist/features/row-pinning/rowPinningFeature.utils.js +2 -2
  52. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  53. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
  54. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
  55. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +1 -1
  56. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +1 -1
  57. package/dist/index.d.cts +9 -9
  58. package/dist/index.d.ts +9 -9
  59. package/dist/types/Column.d.cts +4 -4
  60. package/dist/types/Column.d.ts +4 -4
  61. package/dist/types/ColumnDef.d.cts +3 -3
  62. package/dist/types/ColumnDef.d.ts +3 -3
  63. package/dist/types/Row.d.cts +1 -1
  64. package/dist/types/Row.d.ts +1 -1
  65. package/dist/types/RowModel.d.cts +1 -1
  66. package/dist/types/RowModel.d.ts +1 -1
  67. package/dist/types/RowModelFns.d.cts +1 -1
  68. package/dist/types/RowModelFns.d.ts +1 -1
  69. package/dist/types/Table.d.cts +5 -5
  70. package/dist/types/Table.d.ts +5 -5
  71. package/dist/types/TableFeatures.d.cts +154 -15
  72. package/dist/types/TableFeatures.d.ts +154 -15
  73. package/dist/types/TableOptions.d.cts +6 -6
  74. package/dist/types/TableOptions.d.ts +6 -6
  75. package/dist/types/TableState.d.cts +4 -4
  76. package/dist/types/TableState.d.ts +4 -4
  77. package/package.json +1 -1
  78. package/src/core/columns/constructColumn.ts +6 -0
  79. package/src/types/TableFeatures.ts +161 -15
@@ -1,5 +1,6 @@
1
1
  import type { CoreFeatures } from '../core/coreFeatures'
2
2
  import type { CellData, RowData, UnionToIntersection } from './type-utils'
3
+ import type { Column } from './Column'
3
4
  import type { ColumnDefBase_All } from './ColumnDef'
4
5
  import type { Row } from './Row'
5
6
  import type { Table_Internal } from './Table'
@@ -11,11 +12,31 @@ import type { FilterFn } from '../features/column-filtering/columnFilteringFeatu
11
12
  import type { SortFn } from '../features/row-sorting/rowSortingFeature.types'
12
13
  import type { AggregationFn } from '../features/column-grouping/columnGroupingFeature.types'
13
14
 
15
+ /**
16
+ * Detects whether a type is `any`.
17
+ *
18
+ * Several feature-map helpers need a separate `any` path so broad generic
19
+ * usage still exposes all known feature APIs instead of narrowing to no keys.
20
+ */
14
21
  export type IsAny<T> = 0 extends 1 & T ? true : false
22
+
23
+ /**
24
+ * Converts a union to an intersection, returning `{}` for `never`.
25
+ *
26
+ * This keeps empty feature-map lookups usable as an intersection member.
27
+ */
15
28
  type UnionToIntersectionOrEmpty<T> = [T] extends [never]
16
29
  ? {}
17
30
  : UnionToIntersection<T> & {}
18
31
 
32
+ /**
33
+ * Extracts the API/types contributed by the features present in `TFeatures`.
34
+ *
35
+ * `TFeatureMap` maps feature keys to the types they contribute. When
36
+ * `TFeatures` is `any`, all feature-map entries are included to preserve the
37
+ * permissive behavior expected by broad table types. Otherwise, only entries
38
+ * whose keys are present in `TFeatures` are intersected together.
39
+ */
19
40
  export type ExtractFeatureMapTypes<
20
41
  TFeatures extends TableFeatures,
21
42
  TFeatureMap extends object,
@@ -27,7 +48,11 @@ export type ExtractFeatureMapTypes<
27
48
  >
28
49
 
29
50
  /**
30
- * This is an interface that you can delcaration-merge into to allow for custom plugins to be added to the table.
51
+ * Declaration-merge target for custom table features.
52
+ *
53
+ * Add custom feature keys here so `TableFeatures` can accept them in the
54
+ * `features` option and use the same feature-map extraction system as built-in
55
+ * features.
31
56
  */
32
57
  export interface Plugins {}
33
58
 
@@ -64,19 +89,61 @@ export type NonFeatureKeys =
64
89
  * interface to get the same validation from `tableFeatures()`.
65
90
  */
66
91
  export interface FeatureSlotPrereqs {
92
+ /**
93
+ * Named aggregation functions are only meaningful when grouping is enabled.
94
+ */
67
95
  aggregationFns: 'columnGroupingFeature'
68
- columnResizingFeature: 'columnSizingFeature' // columnSizingFeature is required for columnResizingFeature
96
+ /**
97
+ * Column resizing builds on the column sizing state and APIs.
98
+ */
99
+ columnResizingFeature: 'columnSizingFeature'
100
+ /**
101
+ * Expanded row-model factories require row expanding APIs and state.
102
+ */
69
103
  expandedRowModel: 'rowExpandingFeature'
104
+ /**
105
+ * Faceted min/max factories require column faceting APIs.
106
+ */
70
107
  facetedMinMaxValues: 'columnFacetingFeature'
108
+ /**
109
+ * Faceted row-model factories require column faceting APIs.
110
+ */
71
111
  facetedRowModel: 'columnFacetingFeature'
112
+ /**
113
+ * Faceted unique-value factories require column faceting APIs.
114
+ */
72
115
  facetedUniqueValues: 'columnFacetingFeature'
116
+ /**
117
+ * Filtered row-model factories require column filtering APIs and state.
118
+ */
73
119
  filteredRowModel: 'columnFilteringFeature'
120
+ /**
121
+ * Named filter functions are only meaningful when column filtering is enabled.
122
+ */
74
123
  filterFns: 'columnFilteringFeature'
124
+ /**
125
+ * Filter metadata types are only read and written by filtering features.
126
+ */
75
127
  filterMeta: 'columnFilteringFeature'
76
- globalFilteringFeature: 'columnFilteringFeature' // columnFilteringFeature is required for globalFilteringFeature
128
+ /**
129
+ * Global filtering builds on column filtering state and filter functions.
130
+ */
131
+ globalFilteringFeature: 'columnFilteringFeature'
132
+ /**
133
+ * Grouped row-model factories require column grouping APIs and state.
134
+ */
77
135
  groupedRowModel: 'columnGroupingFeature'
136
+ /**
137
+ * Paginated row-model factories require row pagination APIs and state.
138
+ */
78
139
  paginatedRowModel: 'rowPaginationFeature'
140
+ /**
141
+ * Sorted row-model factories require row sorting APIs and state.
142
+ */
79
143
  sortedRowModel: 'rowSortingFeature'
144
+ /**
145
+ * Named sorting functions are only meaningful when row sorting is enabled.
146
+ */
80
147
  sortFns: 'rowSortingFeature'
81
148
  }
82
149
 
@@ -102,6 +169,15 @@ export type ValidateFeatureSlots<TFeatures extends TableFeatures> =
102
169
  : never
103
170
  }
104
171
 
172
+ /**
173
+ * Complete feature registry for a table.
174
+ *
175
+ * This type combines core features, stock features, declaration-merged custom
176
+ * plugins, row-model factory slots, function registries, and type-only meta
177
+ * slots. The concrete `features` object passed to `tableFeatures()` determines
178
+ * which feature APIs are included throughout table, row, column, cell, header,
179
+ * options, and state types.
180
+ */
105
181
  export interface TableFeatures
106
182
  extends Partial<CoreFeatures>, Partial<StockFeatures>, Partial<Plugins> {
107
183
  /**
@@ -221,10 +297,22 @@ export interface TableFeatures
221
297
  tableMeta?: object
222
298
  }
223
299
 
300
+ /**
301
+ * Lifecycle hooks and defaults contributed by a table feature.
302
+ *
303
+ * Feature objects are registered in the table's `features` option. They can
304
+ * contribute default state/options, default column definitions, table APIs,
305
+ * shared prototype APIs for rows/columns/headers/cells, and per-instance row
306
+ * or column data.
307
+ */
224
308
  export interface TableFeature {
225
309
  /**
226
- * Assigns Cell APIs to the cell prototype for memory-efficient method sharing.
227
- * This is called once per table to build a shared prototype for all cells.
310
+ * Adds feature methods to the shared cell prototype for a table.
311
+ *
312
+ * This runs lazily the first time a cell is constructed for a table. Methods
313
+ * assigned here are shared by every cell instance created by that table, so
314
+ * this hook should be used for APIs and memoized methods rather than
315
+ * per-cell mutable data.
228
316
  */
229
317
  assignCellPrototype?: <
230
318
  TFeatures extends TableFeatures,
@@ -234,8 +322,12 @@ export interface TableFeature {
234
322
  table: Table_Internal<TFeatures, TData>,
235
323
  ) => void
236
324
  /**
237
- * Assigns Column APIs to the column prototype for memory-efficient method sharing.
238
- * This is called once per table to build a shared prototype for all columns.
325
+ * Adds feature methods to the shared column prototype for a table.
326
+ *
327
+ * This runs lazily the first time a column is constructed for a table.
328
+ * Methods assigned here are shared by every column instance created by that
329
+ * table, so this hook should be used for APIs and memoized methods rather
330
+ * than per-column mutable data.
239
331
  */
240
332
  assignColumnPrototype?: <
241
333
  TFeatures extends TableFeatures,
@@ -245,8 +337,12 @@ export interface TableFeature {
245
337
  table: Table_Internal<TFeatures, TData>,
246
338
  ) => void
247
339
  /**
248
- * Assigns Header APIs to the header prototype for memory-efficient method sharing.
249
- * This is called once per table to build a shared prototype for all headers.
340
+ * Adds feature methods to the shared header prototype for a table.
341
+ *
342
+ * This runs lazily the first time a header is constructed for a table.
343
+ * Methods assigned here are shared by every header instance created by that
344
+ * table, so this hook should be used for APIs and memoized methods rather
345
+ * than per-header mutable data.
250
346
  */
251
347
  assignHeaderPrototype?: <
252
348
  TFeatures extends TableFeatures,
@@ -256,35 +352,85 @@ export interface TableFeature {
256
352
  table: Table_Internal<TFeatures, TData>,
257
353
  ) => void
258
354
  /**
259
- * Assigns Row APIs to the row prototype for memory-efficient method sharing.
260
- * This is called once per table to build a shared prototype for all rows.
355
+ * Adds feature methods to the shared row prototype for a table.
356
+ *
357
+ * This runs lazily the first time a row is constructed for a table. Methods
358
+ * assigned here are shared by every row instance created by that table, so
359
+ * this hook should be used for APIs and memoized methods rather than per-row
360
+ * mutable data.
261
361
  */
262
362
  assignRowPrototype?: <TFeatures extends TableFeatures, TData extends RowData>(
263
363
  prototype: Record<string, any>,
264
364
  table: Table_Internal<TFeatures, TData>,
265
365
  ) => void
266
366
  /**
267
- * Assigns Table APIs to the table instance.
268
- * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.
367
+ * Adds feature APIs directly to the table instance.
368
+ *
369
+ * The table is a singleton, unlike rows, columns, headers, and cells, so
370
+ * table APIs are assigned directly instead of through a shared prototype.
371
+ * This runs while the table is being constructed, after options and initial
372
+ * state have been resolved.
269
373
  */
270
374
  constructTableAPIs?: <TFeatures extends TableFeatures, TData extends RowData>(
271
375
  table: Table_Internal<TFeatures, TData>,
272
376
  ) => void
377
+ /**
378
+ * Returns default column definition options contributed by this feature.
379
+ *
380
+ * These defaults are merged into the table's default column definition before
381
+ * `options.defaultColumn` and before each user-supplied column definition is
382
+ * resolved, so users can override values supplied here.
383
+ */
273
384
  getDefaultColumnDef?: <
274
385
  TFeatures extends TableFeatures,
275
386
  TData extends RowData,
276
387
  TValue extends CellData = CellData,
277
388
  >() => ColumnDefBase_All<TFeatures, TData, TValue>
389
+ /**
390
+ * Returns default table options contributed by this feature.
391
+ *
392
+ * This runs while table options are being resolved. Use it for option
393
+ * defaults such as feature enablement flags and default state-updater
394
+ * callbacks. User-supplied table options take precedence over values returned
395
+ * here.
396
+ */
278
397
  getDefaultTableOptions?: <
279
398
  TFeatures extends TableFeatures,
280
399
  TData extends RowData,
281
400
  >(
282
401
  table: Table_Internal<TFeatures, TData>,
283
402
  ) => Partial<TableOptions_All<TFeatures, TData>>
403
+ /**
404
+ * Returns this feature's initial table state.
405
+ *
406
+ * The incoming `initialState` contains state accumulated from earlier
407
+ * features and user-provided initial state. Return a complete state object
408
+ * for this feature, preserving `initialState` so user-provided values can
409
+ * override feature defaults.
410
+ */
284
411
  getInitialState?: (initialState: Partial<TableState_All>) => TableState_All
285
412
  /**
286
- * Initializes instance-specific data on each row (e.g., caches).
287
- * Methods should be assigned via assignRowPrototype instead.
413
+ * Initializes instance-specific data on each column.
414
+ *
415
+ * This runs for every constructed column after core column fields such as
416
+ * `id`, `depth`, `parent`, `columnDef`, and `columns` have been assigned.
417
+ * Use this for per-column mutable data, caches, or annotations. Shared
418
+ * methods should be assigned via `assignColumnPrototype` instead.
419
+ */
420
+ initColumnInstanceData?: <
421
+ TFeatures extends TableFeatures,
422
+ TData extends RowData,
423
+ TValue extends CellData = CellData,
424
+ >(
425
+ column: Column<TFeatures, TData, TValue>,
426
+ ) => void
427
+ /**
428
+ * Initializes instance-specific data on each row.
429
+ *
430
+ * This runs for every constructed row after core row fields such as `id`,
431
+ * `index`, `depth`, `original`, `parentId`, and `subRows` have been assigned.
432
+ * Use this for per-row mutable data, caches, or annotations. Shared methods
433
+ * should be assigned via `assignRowPrototype` instead.
288
434
  */
289
435
  initRowInstanceData?: <
290
436
  TFeatures extends TableFeatures,