@tanstack/table-core 9.0.0-beta.10 → 9.0.0-beta.12

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 (133) hide show
  1. package/dist/core/cells/coreCellsFeature.types.d.cts +3 -3
  2. package/dist/core/cells/coreCellsFeature.types.d.ts +3 -3
  3. package/dist/core/columns/coreColumnsFeature.types.d.cts +4 -4
  4. package/dist/core/columns/coreColumnsFeature.types.d.ts +4 -4
  5. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  6. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  7. package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
  8. package/dist/core/headers/buildHeaderGroups.js.map +1 -1
  9. package/dist/core/headers/coreHeadersFeature.types.d.cts +5 -5
  10. package/dist/core/headers/coreHeadersFeature.types.d.ts +5 -5
  11. package/dist/core/row-models/coreRowModelsFeature.types.d.cts +3 -3
  12. package/dist/core/row-models/coreRowModelsFeature.types.d.ts +3 -3
  13. package/dist/core/row-models/createCoreRowModel.cjs +1 -2
  14. package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
  15. package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
  16. package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
  17. package/dist/core/row-models/createCoreRowModel.js +1 -2
  18. package/dist/core/row-models/createCoreRowModel.js.map +1 -1
  19. package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
  20. package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
  21. package/dist/core/table/constructTable.cjs.map +1 -1
  22. package/dist/core/table/constructTable.js.map +1 -1
  23. package/dist/core/table/coreTablesFeature.types.d.cts +4 -4
  24. package/dist/core/table/coreTablesFeature.types.d.ts +4 -4
  25. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  26. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  27. package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +4 -4
  28. package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +4 -4
  29. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +9 -9
  30. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +9 -9
  31. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  32. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  33. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +6 -6
  34. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -6
  35. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +1 -1
  36. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +1 -1
  37. package/dist/features/column-pinning/columnPinningFeature.types.d.cts +2 -2
  38. package/dist/features/column-pinning/columnPinningFeature.types.d.ts +2 -2
  39. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  40. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +3 -2
  41. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +3 -2
  42. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  43. package/dist/features/column-resizing/columnResizingFeature.types.d.cts +1 -4
  44. package/dist/features/column-resizing/columnResizingFeature.types.d.ts +1 -4
  45. package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +2 -2
  46. package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +2 -2
  47. package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +2 -2
  48. package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +2 -2
  49. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  50. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  51. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +4 -4
  52. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +4 -4
  53. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +3 -3
  54. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +3 -3
  55. package/dist/features/row-pinning/rowPinningFeature.types.d.cts +2 -2
  56. package/dist/features/row-pinning/rowPinningFeature.types.d.ts +2 -2
  57. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +2 -2
  58. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +2 -2
  59. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +7 -7
  60. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +7 -7
  61. package/dist/helpers/columnHelper.cjs.map +1 -1
  62. package/dist/helpers/columnHelper.d.cts +2 -2
  63. package/dist/helpers/columnHelper.d.ts +2 -2
  64. package/dist/helpers/columnHelper.js.map +1 -1
  65. package/dist/index.d.cts +2 -2
  66. package/dist/index.d.ts +2 -2
  67. package/dist/types/Cell.d.cts +1 -1
  68. package/dist/types/Cell.d.ts +1 -1
  69. package/dist/types/Column.d.cts +4 -4
  70. package/dist/types/Column.d.ts +4 -4
  71. package/dist/types/ColumnDef.d.cts +3 -3
  72. package/dist/types/ColumnDef.d.ts +3 -3
  73. package/dist/types/Header.d.cts +1 -1
  74. package/dist/types/Header.d.ts +1 -1
  75. package/dist/types/HeaderGroup.d.cts +2 -2
  76. package/dist/types/HeaderGroup.d.ts +2 -2
  77. package/dist/types/Row.d.cts +2 -2
  78. package/dist/types/Row.d.ts +2 -2
  79. package/dist/types/RowModel.d.cts +2 -2
  80. package/dist/types/RowModel.d.ts +2 -2
  81. package/dist/types/RowModelFns.d.cts +2 -2
  82. package/dist/types/RowModelFns.d.ts +2 -2
  83. package/dist/types/Table.d.cts +21 -12
  84. package/dist/types/Table.d.ts +21 -12
  85. package/dist/types/TableOptions.d.cts +11 -5
  86. package/dist/types/TableOptions.d.ts +11 -5
  87. package/dist/types/TableState.d.cts +1 -1
  88. package/dist/types/TableState.d.ts +1 -1
  89. package/dist/utils.cjs.map +1 -1
  90. package/dist/utils.d.cts +7 -2
  91. package/dist/utils.d.ts +7 -2
  92. package/dist/utils.js.map +1 -1
  93. package/package.json +1 -1
  94. package/src/core/cells/coreCellsFeature.types.ts +6 -6
  95. package/src/core/columns/coreColumnsFeature.types.ts +8 -8
  96. package/src/core/columns/coreColumnsFeature.utils.ts +1 -1
  97. package/src/core/headers/buildHeaderGroups.ts +3 -1
  98. package/src/core/headers/coreHeadersFeature.types.ts +10 -10
  99. package/src/core/row-models/coreRowModelsFeature.types.ts +6 -6
  100. package/src/core/row-models/createCoreRowModel.ts +5 -4
  101. package/src/core/rows/coreRowsFeature.types.ts +8 -8
  102. package/src/core/table/constructTable.ts +1 -1
  103. package/src/core/table/coreTablesFeature.types.ts +8 -8
  104. package/src/core/table/coreTablesFeature.utils.ts +8 -2
  105. package/src/features/column-faceting/columnFacetingFeature.types.ts +8 -8
  106. package/src/features/column-filtering/columnFilteringFeature.types.ts +18 -18
  107. package/src/features/column-filtering/columnFilteringFeature.utils.ts +1 -1
  108. package/src/features/column-grouping/columnGroupingFeature.types.ts +12 -12
  109. package/src/features/column-ordering/columnOrderingFeature.types.ts +2 -2
  110. package/src/features/column-pinning/columnPinningFeature.types.ts +4 -4
  111. package/src/features/column-pinning/columnPinningFeature.utils.ts +6 -14
  112. package/src/features/column-resizing/columnResizingFeature.types.ts +1 -4
  113. package/src/features/column-visibility/columnVisibilityFeature.types.ts +4 -4
  114. package/src/features/global-filtering/globalFilteringFeature.types.ts +4 -4
  115. package/src/features/global-filtering/globalFilteringFeature.utils.ts +1 -1
  116. package/src/features/row-expanding/rowExpandingFeature.types.ts +8 -8
  117. package/src/features/row-pagination/rowPaginationFeature.types.ts +6 -6
  118. package/src/features/row-pinning/rowPinningFeature.types.ts +4 -4
  119. package/src/features/row-selection/rowSelectionFeature.types.ts +4 -4
  120. package/src/features/row-sorting/rowSortingFeature.types.ts +14 -14
  121. package/src/helpers/columnHelper.ts +4 -4
  122. package/src/types/Cell.ts +2 -2
  123. package/src/types/Column.ts +8 -8
  124. package/src/types/ColumnDef.ts +6 -6
  125. package/src/types/Header.ts +2 -2
  126. package/src/types/HeaderGroup.ts +6 -6
  127. package/src/types/Row.ts +4 -4
  128. package/src/types/RowModel.ts +7 -7
  129. package/src/types/RowModelFns.ts +7 -7
  130. package/src/types/Table.ts +51 -25
  131. package/src/types/TableOptions.ts +54 -12
  132. package/src/types/TableState.ts +15 -1
  133. package/src/utils.ts +11 -2
@@ -16,36 +16,40 @@ import type { Table_RowSorting } from '../features/row-sorting/rowSortingFeature
16
16
  import type { Table_RowModels } from '../core/row-models/coreRowModelsFeature.types'
17
17
  import type { CachedRowModel_All } from './RowModel'
18
18
  import type { RowModelFns_All } from './RowModelFns'
19
- import type { TableState_All } from './TableState'
19
+ import type { TableState, TableState_All } from './TableState'
20
20
  import type { RowData } from './type-utils'
21
21
  import type { ExtractFeatureMapTypes, TableFeatures } from './TableFeatures'
22
22
  import type { Table_Columns } from '../core/columns/coreColumnsFeature.types'
23
23
  import type { Table_Headers } from '../core/headers/coreHeadersFeature.types'
24
24
  import type { Table_Rows } from '../core/rows/coreRowsFeature.types'
25
25
  import type {
26
+ Atoms,
26
27
  Atoms_All,
28
+ BaseAtoms,
27
29
  BaseAtoms_All,
28
30
  ExternalAtoms_All,
29
31
  Table_Table,
30
32
  } from '../core/table/coreTablesFeature.types'
31
- import type { TableOptions_All } from './TableOptions'
33
+ import type { DebugOptions, TableOptions_All } from './TableOptions'
32
34
 
33
35
  /**
34
36
  * The core table object that only includes the core table functionality such as column, header, row, and table APIS.
35
37
  * No features are included.
36
38
  */
37
- export type Table_Core<
38
- TFeatures extends TableFeatures,
39
- TData extends RowData,
40
- > = Table_Table<TFeatures, TData> &
41
- Table_Columns<TFeatures, TData> &
42
- Table_Rows<TFeatures, TData> &
43
- Table_RowModels<TFeatures, TData> &
44
- Table_Headers<TFeatures, TData>
39
+ export interface Table_Core<
40
+ in out TFeatures extends TableFeatures,
41
+ in out TData extends RowData,
42
+ >
43
+ extends
44
+ Table_Table<TFeatures, TData>,
45
+ Table_Columns<TFeatures, TData>,
46
+ Table_Rows<TFeatures, TData>,
47
+ Table_RowModels<TFeatures, TData>,
48
+ Table_Headers<TFeatures, TData> {}
45
49
 
46
50
  export interface Table_FeatureMap<
47
- TFeatures extends TableFeatures,
48
- TData extends RowData,
51
+ in out TFeatures extends TableFeatures,
52
+ in out TData extends RowData,
49
53
  > {
50
54
  columnFilteringFeature: Table_ColumnFiltering
51
55
  columnGroupingFeature: Table_ColumnGrouping<TFeatures, TData>
@@ -72,19 +76,41 @@ export type Table<
72
76
  > = Table_Core<TFeatures, TData> &
73
77
  ExtractFeatureMapTypes<TFeatures, Table_FeatureMap<TFeatures, TData>>
74
78
 
75
- export type Table_Internal<
76
- TFeatures extends TableFeatures,
77
- TData extends RowData = any,
78
- > = Table<TFeatures, TData> & {
79
+ /**
80
+ * `Table_Table` members that `Table_Internal` re-declares with broadened
81
+ * (all-features) types so internal code can read any feature's slots and
82
+ * construction code can assign them.
83
+ */
84
+ type Table_InternalBroadenedKeys =
85
+ | '_rowModels'
86
+ | '_rowModelFns'
87
+ | 'options'
88
+ | 'initialState'
89
+ | 'store'
90
+
91
+ /**
92
+ * Internal broad table shape used by feature implementations.
93
+ */
94
+ export interface Table_Internal<
95
+ in out TFeatures extends TableFeatures,
96
+ in out TData extends RowData = any,
97
+ >
98
+ extends
99
+ Omit<Table_Table<TFeatures, TData>, Table_InternalBroadenedKeys>,
100
+ Table_Columns<TFeatures, TData>,
101
+ Table_Rows<TFeatures, TData>,
102
+ Table_RowModels<TFeatures, TData>,
103
+ Table_Headers<TFeatures, TData> {
79
104
  _rowModels: CachedRowModel_All<TFeatures, TData>
80
105
  _rowModelFns: RowModelFns_All<TFeatures, TData>
81
- options: TableOptions_All<TFeatures, TData> & {
82
- state?: TableState_All
83
- initialState?: TableState_All
84
- atoms?: ExternalAtoms_All
85
- }
86
- initialState: TableState_All
87
- baseAtoms: BaseAtoms_All
88
- atoms: Atoms_All
89
- store: ReadonlyStore<TableState_All>
106
+ options: DebugOptions<TableFeatures> &
107
+ TableOptions_All<TFeatures, TData> & {
108
+ state?: TableState_All
109
+ initialState?: TableState_All
110
+ atoms?: ExternalAtoms_All
111
+ }
112
+ initialState: TableState<TFeatures> & TableState_All
113
+ baseAtoms: BaseAtoms<TFeatures> & BaseAtoms_All
114
+ atoms: Atoms<TFeatures> & Atoms_All
115
+ store: ReadonlyStore<TableState<TFeatures>> & ReadonlyStore<TableState_All>
90
116
  }
@@ -28,8 +28,8 @@ import type {
28
28
  * options are mixed in.
29
29
  */
30
30
  export interface TableOptions_Core<
31
- TFeatures extends TableFeatures,
32
- TData extends RowData,
31
+ in out TFeatures extends TableFeatures,
32
+ in out TData extends RowData,
33
33
  >
34
34
  extends
35
35
  TableOptions_Table<TFeatures, TData>,
@@ -55,8 +55,8 @@ export type DebugOptions<TFeatures extends TableFeatures> = {
55
55
  } & DebugKeysFor<CoreFeatures & TFeatures>
56
56
 
57
57
  export interface TableOptions_FeatureMap<
58
- TFeatures extends TableFeatures,
59
- TData extends RowData,
58
+ in out TFeatures extends TableFeatures,
59
+ in out TData extends RowData,
60
60
  > {
61
61
  columnFilteringFeature: TableOptions_ColumnFiltering<TFeatures, TData>
62
62
  columnGroupingFeature: TableOptions_ColumnGrouping
@@ -73,15 +73,42 @@ export interface TableOptions_FeatureMap<
73
73
  rowSortingFeature: TableOptions_RowSorting
74
74
  }
75
75
 
76
- export type TableOptions_FeatureMap_All<
76
+ type TableOptions_StockFeatureKeys =
77
+ | 'columnFilteringFeature'
78
+ | 'columnGroupingFeature'
79
+ | 'columnOrderingFeature'
80
+ | 'columnPinningFeature'
81
+ | 'columnResizingFeature'
82
+ | 'columnSizingFeature'
83
+ | 'columnVisibilityFeature'
84
+ | 'globalFilteringFeature'
85
+ | 'rowExpandingFeature'
86
+ | 'rowPaginationFeature'
87
+ | 'rowPinningFeature'
88
+ | 'rowSelectionFeature'
89
+ | 'rowSortingFeature'
90
+
91
+ /**
92
+ * Plugin entries declaration-merged into `TableOptions_FeatureMap`, i.e. keys
93
+ * beyond the stock set. Resolves to `unknown` (an intersection no-op) when no
94
+ * plugins are merged so the common case skips the union-to-intersection work.
95
+ */
96
+ type TableOptions_PluginFeatureMapTypes<
77
97
  TFeatures extends TableFeatures,
78
98
  TData extends RowData,
79
- > = UnionToIntersection<
80
- TableOptions_FeatureMap<TFeatures, TData>[keyof TableOptions_FeatureMap<
81
- TFeatures,
82
- TData
83
- >]
84
- >
99
+ > = [
100
+ Exclude<
101
+ keyof TableOptions_FeatureMap<TFeatures, TData>,
102
+ TableOptions_StockFeatureKeys
103
+ >,
104
+ ] extends [never]
105
+ ? unknown
106
+ : UnionToIntersection<
107
+ TableOptions_FeatureMap<TFeatures, TData>[Exclude<
108
+ keyof TableOptions_FeatureMap<TFeatures, TData>,
109
+ TableOptions_StockFeatureKeys
110
+ >]
111
+ >
85
112
 
86
113
  /**
87
114
  * Complete table options for a specific feature set.
@@ -105,4 +132,19 @@ export type TableOptions_All<
105
132
  TFeatures extends TableFeatures,
106
133
  TData extends RowData,
107
134
  > = TableOptions_Core<TFeatures, TData> &
108
- Partial<TableOptions_FeatureMap_All<TFeatures, TData>>
135
+ Partial<
136
+ TableOptions_ColumnFiltering<TFeatures, TData> &
137
+ TableOptions_ColumnGrouping &
138
+ TableOptions_ColumnOrdering &
139
+ TableOptions_ColumnPinning &
140
+ TableOptions_ColumnResizing &
141
+ TableOptions_ColumnSizing &
142
+ TableOptions_ColumnVisibility &
143
+ TableOptions_GlobalFiltering<TFeatures, TData> &
144
+ TableOptions_RowExpanding<TFeatures, TData> &
145
+ TableOptions_RowPagination &
146
+ TableOptions_RowPinning<TFeatures, TData> &
147
+ TableOptions_RowSelection<TFeatures, TData> &
148
+ TableOptions_RowSorting &
149
+ TableOptions_PluginFeatureMapTypes<TFeatures, TData>
150
+ >
@@ -44,4 +44,18 @@ export type TableState<TFeatures extends TableFeatures> =
44
44
  * Feature internals use this when they may need to inspect optional slices owned
45
45
  * by other features.
46
46
  */
47
- export type TableState_All = Partial<TableState<TableFeatures>>
47
+ export interface TableState_All extends Partial<
48
+ TableState_ColumnFiltering &
49
+ TableState_ColumnGrouping &
50
+ TableState_ColumnOrdering &
51
+ TableState_ColumnPinning &
52
+ TableState_ColumnResizing &
53
+ TableState_ColumnSizing &
54
+ TableState_ColumnVisibility &
55
+ TableState_GlobalFiltering &
56
+ TableState_RowExpanding &
57
+ TableState_RowPagination &
58
+ TableState_RowPinning &
59
+ TableState_RowSelection &
60
+ TableState_RowSorting
61
+ > {}
package/src/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Table, Table_Internal } from './types/Table'
1
+ import type { Table_Internal } from './types/Table'
2
2
  import type { NoInfer, RowData, Updater } from './types/type-utils'
3
3
  import type { TableFeatures } from './types/TableFeatures'
4
4
  import type { TableState, TableState_All } from './types/TableState'
@@ -53,7 +53,16 @@ export function cloneState<T>(value: T): T {
53
53
  export function makeStateUpdater<
54
54
  TFeatures extends TableFeatures,
55
55
  K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,
56
- >(key: K, instance: Table<TFeatures, any>) {
56
+ >(
57
+ key: K,
58
+ // Minimal structural shape so any table view (public `Table`,
59
+ // `Table_Internal`, or a custom plugin table) can be passed without forcing
60
+ // the compiler to relate the full table types.
61
+ instance: {
62
+ readonly options: { readonly atoms?: object | undefined }
63
+ readonly baseAtoms: object
64
+ },
65
+ ) {
57
66
  return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {
58
67
  const externalAtom = (instance.options as any).atoms?.[key]
59
68
  const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]