@tanstack/react-table 9.0.0-alpha.9 → 9.0.0-beta.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/README.md +127 -0
- package/dist/FlexRender.cjs +61 -0
- package/dist/FlexRender.cjs.map +1 -0
- package/dist/FlexRender.d.cts +51 -0
- package/dist/FlexRender.d.ts +51 -0
- package/dist/FlexRender.js +58 -0
- package/dist/FlexRender.js.map +1 -0
- package/dist/Subscribe.cjs +13 -0
- package/dist/Subscribe.cjs.map +1 -0
- package/dist/Subscribe.d.cts +101 -0
- package/dist/Subscribe.d.ts +101 -0
- package/dist/Subscribe.js +13 -0
- package/dist/Subscribe.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/createTableHook.cjs +313 -0
- package/dist/createTableHook.cjs.map +1 -0
- package/dist/createTableHook.d.cts +358 -0
- package/dist/createTableHook.d.ts +358 -0
- package/dist/createTableHook.js +311 -0
- package/dist/createTableHook.js.map +1 -0
- package/dist/flex-render.cjs +5 -0
- package/dist/flex-render.d.cts +2 -0
- package/dist/flex-render.d.ts +2 -0
- package/dist/flex-render.js +3 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/legacy.cjs +14 -0
- package/dist/legacy.d.cts +2 -0
- package/dist/legacy.d.ts +2 -0
- package/dist/legacy.js +3 -0
- package/dist/reactivity.cjs +34 -0
- package/dist/reactivity.cjs.map +1 -0
- package/dist/reactivity.js +34 -0
- package/dist/reactivity.js.map +1 -0
- package/dist/static-functions.cjs +9 -0
- package/dist/static-functions.d.cts +1 -0
- package/dist/static-functions.d.ts +1 -0
- package/dist/static-functions.js +3 -0
- package/dist/useLegacyTable.cjs +191 -0
- package/dist/useLegacyTable.cjs.map +1 -0
- package/dist/useLegacyTable.d.cts +233 -0
- package/dist/useLegacyTable.d.ts +233 -0
- package/dist/useLegacyTable.js +181 -0
- package/dist/useLegacyTable.js.map +1 -0
- package/dist/useTable.cjs +72 -0
- package/dist/useTable.cjs.map +1 -0
- package/dist/useTable.d.cts +122 -0
- package/dist/useTable.d.ts +122 -0
- package/dist/useTable.js +72 -0
- package/dist/useTable.js.map +1 -0
- package/package.json +41 -22
- package/skills/react/client-to-server/SKILL.md +377 -0
- package/skills/react/compose-with-tanstack-form/SKILL.md +363 -0
- package/skills/react/compose-with-tanstack-pacer/SKILL.md +287 -0
- package/skills/react/compose-with-tanstack-query/SKILL.md +467 -0
- package/skills/react/compose-with-tanstack-store/SKILL.md +347 -0
- package/skills/react/compose-with-tanstack-virtual/SKILL.md +388 -0
- package/skills/react/compose-with-tanstack-virtual/references/column-virtualization-and-infinite-scroll.md +136 -0
- package/skills/react/getting-started/SKILL.md +388 -0
- package/skills/react/migrate-v8-to-v9/SKILL.md +488 -0
- package/skills/react/production-readiness/SKILL.md +341 -0
- package/skills/react/react-subscribe-compiler-compat/SKILL.md +269 -0
- package/skills/react/table-state/SKILL.md +432 -0
- package/src/FlexRender.tsx +136 -0
- package/src/Subscribe.ts +153 -0
- package/src/createTableHook.tsx +1121 -0
- package/src/flex-render.ts +1 -0
- package/src/index.ts +6 -0
- package/src/legacy.ts +3 -0
- package/src/reactivity.ts +41 -0
- package/src/static-functions.ts +1 -0
- package/src/useLegacyTable.ts +487 -0
- package/src/useTable.ts +191 -0
- package/dist/cjs/index.cjs +0 -77
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -9
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.js +0 -55
- package/dist/esm/index.js.map +0 -1
- package/src/index.tsx +0 -92
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ReactTable } from "./useTable.cjs";
|
|
2
|
+
import { AggregationFns, Cell, Column, ColumnDef, FilterFns, Header, HeaderGroup, Row, RowData, RowModel, SortFns, StockFeatures, Table, TableOptions, TableState } from "@tanstack/table-core";
|
|
3
|
+
|
|
4
|
+
//#region src/useLegacyTable.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.
|
|
7
|
+
*
|
|
8
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
9
|
+
* It acts as a marker to enable the filtered row model.
|
|
10
|
+
*/
|
|
11
|
+
declare function getFilteredRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.
|
|
14
|
+
*
|
|
15
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
16
|
+
* It acts as a marker to enable the sorted row model.
|
|
17
|
+
*/
|
|
18
|
+
declare function getSortedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.
|
|
21
|
+
*
|
|
22
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
23
|
+
* It acts as a marker to enable the paginated row model.
|
|
24
|
+
*/
|
|
25
|
+
declare function getPaginationRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.
|
|
28
|
+
*
|
|
29
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
30
|
+
* It acts as a marker to enable the expanded row model.
|
|
31
|
+
*/
|
|
32
|
+
declare function getExpandedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.
|
|
35
|
+
*
|
|
36
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
37
|
+
* It acts as a marker to enable the grouped row model.
|
|
38
|
+
*/
|
|
39
|
+
declare function getGroupedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.
|
|
42
|
+
*
|
|
43
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
44
|
+
* It acts as a marker to enable the faceted row model.
|
|
45
|
+
*/
|
|
46
|
+
declare function getFacetedRowModel<TData extends RowData>(): FacetedRowModelFactory<TData>;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.
|
|
49
|
+
*
|
|
50
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
51
|
+
* It acts as a marker to enable the faceted min/max values.
|
|
52
|
+
*/
|
|
53
|
+
declare function getFacetedMinMaxValues<TData extends RowData>(): FacetedMinMaxValuesFactory<TData>;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.
|
|
56
|
+
*
|
|
57
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
58
|
+
* It acts as a marker to enable the faceted unique values.
|
|
59
|
+
*/
|
|
60
|
+
declare function getFacetedUniqueValues<TData extends RowData>(): FacetedUniqueValuesFactory<TData>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated The core row model is always created automatically in v9.
|
|
63
|
+
*
|
|
64
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
65
|
+
* It does nothing - the core row model is always available.
|
|
66
|
+
*/
|
|
67
|
+
declare function getCoreRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
68
|
+
/**
|
|
69
|
+
* Row model factory function type from v8 API
|
|
70
|
+
*/
|
|
71
|
+
type RowModelFactory<TData extends RowData> = (table: Table<StockFeatures, TData>) => () => RowModel<StockFeatures, TData>;
|
|
72
|
+
/**
|
|
73
|
+
* Faceted row model factory function type from v8 API
|
|
74
|
+
*/
|
|
75
|
+
type FacetedRowModelFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => RowModel<StockFeatures, TData>;
|
|
76
|
+
/**
|
|
77
|
+
* Faceted min/max values factory function type from v8 API
|
|
78
|
+
*/
|
|
79
|
+
type FacetedMinMaxValuesFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => undefined | [number, number];
|
|
80
|
+
/**
|
|
81
|
+
* Faceted unique values factory function type from v8 API
|
|
82
|
+
*/
|
|
83
|
+
type FacetedUniqueValuesFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => Map<any, number>;
|
|
84
|
+
/**
|
|
85
|
+
* Legacy v8-style row model options
|
|
86
|
+
*/
|
|
87
|
+
interface LegacyRowModelOptions<TData extends RowData> {
|
|
88
|
+
/**
|
|
89
|
+
* Returns the core row model for the table.
|
|
90
|
+
* @deprecated This option is no longer needed in v9. The core row model is always created automatically.
|
|
91
|
+
*/
|
|
92
|
+
getCoreRowModel?: RowModelFactory<TData>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the filtered row model for the table.
|
|
95
|
+
* @deprecated Use `rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.
|
|
96
|
+
*/
|
|
97
|
+
getFilteredRowModel?: RowModelFactory<TData>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the sorted row model for the table.
|
|
100
|
+
* @deprecated Use `rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.
|
|
101
|
+
*/
|
|
102
|
+
getSortedRowModel?: RowModelFactory<TData>;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the paginated row model for the table.
|
|
105
|
+
* @deprecated Use `rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.
|
|
106
|
+
*/
|
|
107
|
+
getPaginationRowModel?: RowModelFactory<TData>;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the expanded row model for the table.
|
|
110
|
+
* @deprecated Use `rowModels.expandedRowModel` with `createExpandedRowModel()` instead.
|
|
111
|
+
*/
|
|
112
|
+
getExpandedRowModel?: RowModelFactory<TData>;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the grouped row model for the table.
|
|
115
|
+
* @deprecated Use `rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.
|
|
116
|
+
*/
|
|
117
|
+
getGroupedRowModel?: RowModelFactory<TData>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the faceted row model for a column.
|
|
120
|
+
* @deprecated Use `rowModels.facetedRowModel` with `createFacetedRowModel()` instead.
|
|
121
|
+
*/
|
|
122
|
+
getFacetedRowModel?: FacetedRowModelFactory<TData>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the faceted min/max values for a column.
|
|
125
|
+
* @deprecated Use `rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.
|
|
126
|
+
*/
|
|
127
|
+
getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the faceted unique values for a column.
|
|
130
|
+
* @deprecated Use `rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.
|
|
131
|
+
*/
|
|
132
|
+
getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>;
|
|
133
|
+
/**
|
|
134
|
+
* Additional filter functions to apply to the table.
|
|
135
|
+
* @deprecated Use `rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.
|
|
136
|
+
*/
|
|
137
|
+
filterFns?: FilterFns;
|
|
138
|
+
/**
|
|
139
|
+
* Additional sort functions to apply to the table.
|
|
140
|
+
* @deprecated Use `rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.
|
|
141
|
+
*/
|
|
142
|
+
sortFns?: SortFns;
|
|
143
|
+
/**
|
|
144
|
+
* Additional aggregation functions to apply to the table.
|
|
145
|
+
* @deprecated Use `rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.
|
|
146
|
+
*/
|
|
147
|
+
aggregationFns?: AggregationFns;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Legacy v8-style table options that work with useLegacyTable.
|
|
151
|
+
*
|
|
152
|
+
* This type omits `features` and `rowModels` and instead accepts the v8-style
|
|
153
|
+
* `get*RowModel` function options.
|
|
154
|
+
*
|
|
155
|
+
* @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `features` and `rowModels` instead.
|
|
156
|
+
*/
|
|
157
|
+
type LegacyTableOptions<TData extends RowData> = Omit<TableOptions<StockFeatures, TData>, 'features' | 'rowModels'> & LegacyRowModelOptions<TData>;
|
|
158
|
+
/**
|
|
159
|
+
* Legacy table instance type that includes the v8-style `getState()` method.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated Use `useTable` with explicit state selection instead.
|
|
162
|
+
*/
|
|
163
|
+
type LegacyReactTable<TData extends RowData> = ReactTable<StockFeatures, TData, TableState<StockFeatures>> & {
|
|
164
|
+
/**
|
|
165
|
+
* Returns the current table state.
|
|
166
|
+
* @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.
|
|
167
|
+
*/
|
|
168
|
+
getState: () => TableState<StockFeatures>;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the current table state.
|
|
171
|
+
* @deprecated In v9, access state directly via `table.baseAtoms`
|
|
172
|
+
*/
|
|
173
|
+
setState: (state: TableState<StockFeatures>) => void;
|
|
174
|
+
};
|
|
175
|
+
/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */
|
|
176
|
+
type LegacyColumn<TData extends RowData, TValue = unknown> = Column<StockFeatures, TData, TValue>;
|
|
177
|
+
/** @deprecated Use Row<TFeatures, TData> with useTable instead. */
|
|
178
|
+
type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>;
|
|
179
|
+
/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */
|
|
180
|
+
type LegacyCell<TData extends RowData, TValue = unknown> = Cell<StockFeatures, TData, TValue>;
|
|
181
|
+
/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */
|
|
182
|
+
type LegacyHeader<TData extends RowData, TValue = unknown> = Header<StockFeatures, TData, TValue>;
|
|
183
|
+
/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */
|
|
184
|
+
type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<StockFeatures, TData>;
|
|
185
|
+
/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */
|
|
186
|
+
type LegacyColumnDef<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
|
|
187
|
+
/** @deprecated Use Table<TFeatures, TData> with useTable instead. */
|
|
188
|
+
type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>;
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.
|
|
191
|
+
*
|
|
192
|
+
* A column helper with StockFeatures pre-bound for use with useLegacyTable.
|
|
193
|
+
* Only requires TData—no need to specify TFeatures.
|
|
194
|
+
*/
|
|
195
|
+
declare function legacyCreateColumnHelper<TData extends RowData>(): import("@tanstack/table-core").ColumnHelper<StockFeatures, TData>;
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
|
|
198
|
+
*
|
|
199
|
+
* Use the new `useTable` hook instead with explicit `features` and `rowModels`:
|
|
200
|
+
*
|
|
201
|
+
* ```tsx
|
|
202
|
+
* // New v9 API
|
|
203
|
+
* const features = tableFeatures({
|
|
204
|
+
* columnFilteringFeature,
|
|
205
|
+
* rowSortingFeature,
|
|
206
|
+
* rowPaginationFeature,
|
|
207
|
+
* })
|
|
208
|
+
*
|
|
209
|
+
* const table = useTable({
|
|
210
|
+
* features,
|
|
211
|
+
* rowModels: {
|
|
212
|
+
* filteredRowModel: createFilteredRowModel(filterFns),
|
|
213
|
+
* sortedRowModel: createSortedRowModel(sortFns),
|
|
214
|
+
* paginatedRowModel: createPaginatedRowModel(),
|
|
215
|
+
* },
|
|
216
|
+
* columns,
|
|
217
|
+
* data,
|
|
218
|
+
* })
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* Key differences from v8:
|
|
222
|
+
* - Features are tree-shakeable - only import what you use
|
|
223
|
+
* - Row models are explicitly passed via `rowModels`
|
|
224
|
+
* - Use `table.Subscribe` for fine-grained re-renders
|
|
225
|
+
* - State is accessed via `table.state` after selecting with the 2nd argument
|
|
226
|
+
*
|
|
227
|
+
* @param options - Legacy v8-style table options
|
|
228
|
+
* @returns A table instance with the full state subscribed and a `getState()` method
|
|
229
|
+
*/
|
|
230
|
+
declare function useLegacyTable<TData extends RowData>(options: LegacyTableOptions<TData>): LegacyReactTable<TData>;
|
|
231
|
+
//#endregion
|
|
232
|
+
export { FacetedMinMaxValuesFactory, FacetedRowModelFactory, FacetedUniqueValuesFactory, LegacyCell, LegacyColumn, LegacyColumnDef, LegacyHeader, LegacyHeaderGroup, LegacyReactTable, LegacyRow, LegacyRowModelOptions, LegacyTable, LegacyTableOptions, RowModelFactory, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, legacyCreateColumnHelper, useLegacyTable };
|
|
233
|
+
//# sourceMappingURL=useLegacyTable.d.cts.map
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ReactTable } from "./useTable.js";
|
|
2
|
+
import { AggregationFns, Cell, Column, ColumnDef, FilterFns, Header, HeaderGroup, Row, RowData, RowModel, SortFns, StockFeatures, Table, TableOptions, TableState } from "@tanstack/table-core";
|
|
3
|
+
|
|
4
|
+
//#region src/useLegacyTable.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.
|
|
7
|
+
*
|
|
8
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
9
|
+
* It acts as a marker to enable the filtered row model.
|
|
10
|
+
*/
|
|
11
|
+
declare function getFilteredRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.
|
|
14
|
+
*
|
|
15
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
16
|
+
* It acts as a marker to enable the sorted row model.
|
|
17
|
+
*/
|
|
18
|
+
declare function getSortedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.
|
|
21
|
+
*
|
|
22
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
23
|
+
* It acts as a marker to enable the paginated row model.
|
|
24
|
+
*/
|
|
25
|
+
declare function getPaginationRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.
|
|
28
|
+
*
|
|
29
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
30
|
+
* It acts as a marker to enable the expanded row model.
|
|
31
|
+
*/
|
|
32
|
+
declare function getExpandedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.
|
|
35
|
+
*
|
|
36
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
37
|
+
* It acts as a marker to enable the grouped row model.
|
|
38
|
+
*/
|
|
39
|
+
declare function getGroupedRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.
|
|
42
|
+
*
|
|
43
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
44
|
+
* It acts as a marker to enable the faceted row model.
|
|
45
|
+
*/
|
|
46
|
+
declare function getFacetedRowModel<TData extends RowData>(): FacetedRowModelFactory<TData>;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.
|
|
49
|
+
*
|
|
50
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
51
|
+
* It acts as a marker to enable the faceted min/max values.
|
|
52
|
+
*/
|
|
53
|
+
declare function getFacetedMinMaxValues<TData extends RowData>(): FacetedMinMaxValuesFactory<TData>;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.
|
|
56
|
+
*
|
|
57
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
58
|
+
* It acts as a marker to enable the faceted unique values.
|
|
59
|
+
*/
|
|
60
|
+
declare function getFacetedUniqueValues<TData extends RowData>(): FacetedUniqueValuesFactory<TData>;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated The core row model is always created automatically in v9.
|
|
63
|
+
*
|
|
64
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
65
|
+
* It does nothing - the core row model is always available.
|
|
66
|
+
*/
|
|
67
|
+
declare function getCoreRowModel<TData extends RowData>(): RowModelFactory<TData>;
|
|
68
|
+
/**
|
|
69
|
+
* Row model factory function type from v8 API
|
|
70
|
+
*/
|
|
71
|
+
type RowModelFactory<TData extends RowData> = (table: Table<StockFeatures, TData>) => () => RowModel<StockFeatures, TData>;
|
|
72
|
+
/**
|
|
73
|
+
* Faceted row model factory function type from v8 API
|
|
74
|
+
*/
|
|
75
|
+
type FacetedRowModelFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => RowModel<StockFeatures, TData>;
|
|
76
|
+
/**
|
|
77
|
+
* Faceted min/max values factory function type from v8 API
|
|
78
|
+
*/
|
|
79
|
+
type FacetedMinMaxValuesFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => undefined | [number, number];
|
|
80
|
+
/**
|
|
81
|
+
* Faceted unique values factory function type from v8 API
|
|
82
|
+
*/
|
|
83
|
+
type FacetedUniqueValuesFactory<TData extends RowData> = (table: Table<StockFeatures, TData>, columnId: string) => () => Map<any, number>;
|
|
84
|
+
/**
|
|
85
|
+
* Legacy v8-style row model options
|
|
86
|
+
*/
|
|
87
|
+
interface LegacyRowModelOptions<TData extends RowData> {
|
|
88
|
+
/**
|
|
89
|
+
* Returns the core row model for the table.
|
|
90
|
+
* @deprecated This option is no longer needed in v9. The core row model is always created automatically.
|
|
91
|
+
*/
|
|
92
|
+
getCoreRowModel?: RowModelFactory<TData>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the filtered row model for the table.
|
|
95
|
+
* @deprecated Use `rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.
|
|
96
|
+
*/
|
|
97
|
+
getFilteredRowModel?: RowModelFactory<TData>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the sorted row model for the table.
|
|
100
|
+
* @deprecated Use `rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.
|
|
101
|
+
*/
|
|
102
|
+
getSortedRowModel?: RowModelFactory<TData>;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the paginated row model for the table.
|
|
105
|
+
* @deprecated Use `rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.
|
|
106
|
+
*/
|
|
107
|
+
getPaginationRowModel?: RowModelFactory<TData>;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the expanded row model for the table.
|
|
110
|
+
* @deprecated Use `rowModels.expandedRowModel` with `createExpandedRowModel()` instead.
|
|
111
|
+
*/
|
|
112
|
+
getExpandedRowModel?: RowModelFactory<TData>;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the grouped row model for the table.
|
|
115
|
+
* @deprecated Use `rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.
|
|
116
|
+
*/
|
|
117
|
+
getGroupedRowModel?: RowModelFactory<TData>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns the faceted row model for a column.
|
|
120
|
+
* @deprecated Use `rowModels.facetedRowModel` with `createFacetedRowModel()` instead.
|
|
121
|
+
*/
|
|
122
|
+
getFacetedRowModel?: FacetedRowModelFactory<TData>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the faceted min/max values for a column.
|
|
125
|
+
* @deprecated Use `rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.
|
|
126
|
+
*/
|
|
127
|
+
getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the faceted unique values for a column.
|
|
130
|
+
* @deprecated Use `rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.
|
|
131
|
+
*/
|
|
132
|
+
getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>;
|
|
133
|
+
/**
|
|
134
|
+
* Additional filter functions to apply to the table.
|
|
135
|
+
* @deprecated Use `rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.
|
|
136
|
+
*/
|
|
137
|
+
filterFns?: FilterFns;
|
|
138
|
+
/**
|
|
139
|
+
* Additional sort functions to apply to the table.
|
|
140
|
+
* @deprecated Use `rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.
|
|
141
|
+
*/
|
|
142
|
+
sortFns?: SortFns;
|
|
143
|
+
/**
|
|
144
|
+
* Additional aggregation functions to apply to the table.
|
|
145
|
+
* @deprecated Use `rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.
|
|
146
|
+
*/
|
|
147
|
+
aggregationFns?: AggregationFns;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Legacy v8-style table options that work with useLegacyTable.
|
|
151
|
+
*
|
|
152
|
+
* This type omits `features` and `rowModels` and instead accepts the v8-style
|
|
153
|
+
* `get*RowModel` function options.
|
|
154
|
+
*
|
|
155
|
+
* @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `features` and `rowModels` instead.
|
|
156
|
+
*/
|
|
157
|
+
type LegacyTableOptions<TData extends RowData> = Omit<TableOptions<StockFeatures, TData>, 'features' | 'rowModels'> & LegacyRowModelOptions<TData>;
|
|
158
|
+
/**
|
|
159
|
+
* Legacy table instance type that includes the v8-style `getState()` method.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated Use `useTable` with explicit state selection instead.
|
|
162
|
+
*/
|
|
163
|
+
type LegacyReactTable<TData extends RowData> = ReactTable<StockFeatures, TData, TableState<StockFeatures>> & {
|
|
164
|
+
/**
|
|
165
|
+
* Returns the current table state.
|
|
166
|
+
* @deprecated In v9, access state directly via `table.state` or use `table.state` for the full state.
|
|
167
|
+
*/
|
|
168
|
+
getState: () => TableState<StockFeatures>;
|
|
169
|
+
/**
|
|
170
|
+
* Sets the current table state.
|
|
171
|
+
* @deprecated In v9, access state directly via `table.baseAtoms`
|
|
172
|
+
*/
|
|
173
|
+
setState: (state: TableState<StockFeatures>) => void;
|
|
174
|
+
};
|
|
175
|
+
/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */
|
|
176
|
+
type LegacyColumn<TData extends RowData, TValue = unknown> = Column<StockFeatures, TData, TValue>;
|
|
177
|
+
/** @deprecated Use Row<TFeatures, TData> with useTable instead. */
|
|
178
|
+
type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>;
|
|
179
|
+
/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */
|
|
180
|
+
type LegacyCell<TData extends RowData, TValue = unknown> = Cell<StockFeatures, TData, TValue>;
|
|
181
|
+
/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */
|
|
182
|
+
type LegacyHeader<TData extends RowData, TValue = unknown> = Header<StockFeatures, TData, TValue>;
|
|
183
|
+
/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */
|
|
184
|
+
type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<StockFeatures, TData>;
|
|
185
|
+
/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */
|
|
186
|
+
type LegacyColumnDef<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
|
|
187
|
+
/** @deprecated Use Table<TFeatures, TData> with useTable instead. */
|
|
188
|
+
type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>;
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.
|
|
191
|
+
*
|
|
192
|
+
* A column helper with StockFeatures pre-bound for use with useLegacyTable.
|
|
193
|
+
* Only requires TData—no need to specify TFeatures.
|
|
194
|
+
*/
|
|
195
|
+
declare function legacyCreateColumnHelper<TData extends RowData>(): import("@tanstack/table-core").ColumnHelper<StockFeatures, TData>;
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
|
|
198
|
+
*
|
|
199
|
+
* Use the new `useTable` hook instead with explicit `features` and `rowModels`:
|
|
200
|
+
*
|
|
201
|
+
* ```tsx
|
|
202
|
+
* // New v9 API
|
|
203
|
+
* const features = tableFeatures({
|
|
204
|
+
* columnFilteringFeature,
|
|
205
|
+
* rowSortingFeature,
|
|
206
|
+
* rowPaginationFeature,
|
|
207
|
+
* })
|
|
208
|
+
*
|
|
209
|
+
* const table = useTable({
|
|
210
|
+
* features,
|
|
211
|
+
* rowModels: {
|
|
212
|
+
* filteredRowModel: createFilteredRowModel(filterFns),
|
|
213
|
+
* sortedRowModel: createSortedRowModel(sortFns),
|
|
214
|
+
* paginatedRowModel: createPaginatedRowModel(),
|
|
215
|
+
* },
|
|
216
|
+
* columns,
|
|
217
|
+
* data,
|
|
218
|
+
* })
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* Key differences from v8:
|
|
222
|
+
* - Features are tree-shakeable - only import what you use
|
|
223
|
+
* - Row models are explicitly passed via `rowModels`
|
|
224
|
+
* - Use `table.Subscribe` for fine-grained re-renders
|
|
225
|
+
* - State is accessed via `table.state` after selecting with the 2nd argument
|
|
226
|
+
*
|
|
227
|
+
* @param options - Legacy v8-style table options
|
|
228
|
+
* @returns A table instance with the full state subscribed and a `getState()` method
|
|
229
|
+
*/
|
|
230
|
+
declare function useLegacyTable<TData extends RowData>(options: LegacyTableOptions<TData>): LegacyReactTable<TData>;
|
|
231
|
+
//#endregion
|
|
232
|
+
export { FacetedMinMaxValuesFactory, FacetedRowModelFactory, FacetedUniqueValuesFactory, LegacyCell, LegacyColumn, LegacyColumnDef, LegacyHeader, LegacyHeaderGroup, LegacyReactTable, LegacyRow, LegacyRowModelOptions, LegacyTable, LegacyTableOptions, RowModelFactory, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, legacyCreateColumnHelper, useLegacyTable };
|
|
233
|
+
//# sourceMappingURL=useLegacyTable.d.ts.map
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useTable } from "./useTable.js";
|
|
4
|
+
import { aggregationFns, createColumnHelper, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, filterFns, sortFns, stockFeatures } from "@tanstack/table-core";
|
|
5
|
+
import { useCallback, useMemo, useState } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/useLegacyTable.ts
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.
|
|
10
|
+
*
|
|
11
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
12
|
+
* It acts as a marker to enable the filtered row model.
|
|
13
|
+
*/
|
|
14
|
+
function getFilteredRowModel() {
|
|
15
|
+
return (() => () => {});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.
|
|
19
|
+
*
|
|
20
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
21
|
+
* It acts as a marker to enable the sorted row model.
|
|
22
|
+
*/
|
|
23
|
+
function getSortedRowModel() {
|
|
24
|
+
return (() => () => {});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.
|
|
28
|
+
*
|
|
29
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
30
|
+
* It acts as a marker to enable the paginated row model.
|
|
31
|
+
*/
|
|
32
|
+
function getPaginationRowModel() {
|
|
33
|
+
return (() => () => {});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.
|
|
37
|
+
*
|
|
38
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
39
|
+
* It acts as a marker to enable the expanded row model.
|
|
40
|
+
*/
|
|
41
|
+
function getExpandedRowModel() {
|
|
42
|
+
return (() => () => {});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.
|
|
46
|
+
*
|
|
47
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
48
|
+
* It acts as a marker to enable the grouped row model.
|
|
49
|
+
*/
|
|
50
|
+
function getGroupedRowModel() {
|
|
51
|
+
return (() => () => {});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.
|
|
55
|
+
*
|
|
56
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
57
|
+
* It acts as a marker to enable the faceted row model.
|
|
58
|
+
*/
|
|
59
|
+
function getFacetedRowModel() {
|
|
60
|
+
return (() => () => {});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.
|
|
64
|
+
*
|
|
65
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
66
|
+
* It acts as a marker to enable the faceted min/max values.
|
|
67
|
+
*/
|
|
68
|
+
function getFacetedMinMaxValues() {
|
|
69
|
+
return () => () => void 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.
|
|
73
|
+
*
|
|
74
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
75
|
+
* It acts as a marker to enable the faceted unique values.
|
|
76
|
+
*/
|
|
77
|
+
function getFacetedUniqueValues() {
|
|
78
|
+
return () => () => /* @__PURE__ */ new Map();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated The core row model is always created automatically in v9.
|
|
82
|
+
*
|
|
83
|
+
* This is a stub function for v8 API compatibility with `useLegacyTable`.
|
|
84
|
+
* It does nothing - the core row model is always available.
|
|
85
|
+
*/
|
|
86
|
+
function getCoreRowModel() {
|
|
87
|
+
return (() => () => {});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.
|
|
91
|
+
*
|
|
92
|
+
* A column helper with StockFeatures pre-bound for use with useLegacyTable.
|
|
93
|
+
* Only requires TData—no need to specify TFeatures.
|
|
94
|
+
*/
|
|
95
|
+
function legacyCreateColumnHelper() {
|
|
96
|
+
return createColumnHelper();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
|
|
100
|
+
*
|
|
101
|
+
* Use the new `useTable` hook instead with explicit `features` and `rowModels`:
|
|
102
|
+
*
|
|
103
|
+
* ```tsx
|
|
104
|
+
* // New v9 API
|
|
105
|
+
* const features = tableFeatures({
|
|
106
|
+
* columnFilteringFeature,
|
|
107
|
+
* rowSortingFeature,
|
|
108
|
+
* rowPaginationFeature,
|
|
109
|
+
* })
|
|
110
|
+
*
|
|
111
|
+
* const table = useTable({
|
|
112
|
+
* features,
|
|
113
|
+
* rowModels: {
|
|
114
|
+
* filteredRowModel: createFilteredRowModel(filterFns),
|
|
115
|
+
* sortedRowModel: createSortedRowModel(sortFns),
|
|
116
|
+
* paginatedRowModel: createPaginatedRowModel(),
|
|
117
|
+
* },
|
|
118
|
+
* columns,
|
|
119
|
+
* data,
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* Key differences from v8:
|
|
124
|
+
* - Features are tree-shakeable - only import what you use
|
|
125
|
+
* - Row models are explicitly passed via `rowModels`
|
|
126
|
+
* - Use `table.Subscribe` for fine-grained re-renders
|
|
127
|
+
* - State is accessed via `table.state` after selecting with the 2nd argument
|
|
128
|
+
*
|
|
129
|
+
* @param options - Legacy v8-style table options
|
|
130
|
+
* @returns A table instance with the full state subscribed and a `getState()` method
|
|
131
|
+
*/
|
|
132
|
+
function useLegacyTable(options) {
|
|
133
|
+
const { getCoreRowModel: _getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, getExpandedRowModel, getGroupedRowModel, getFacetedRowModel, getFacetedMinMaxValues, getFacetedUniqueValues, ...restOptions } = options;
|
|
134
|
+
const [rowModels] = useState(() => {
|
|
135
|
+
const rowModels = {};
|
|
136
|
+
if (getFilteredRowModel) rowModels.filteredRowModel = createFilteredRowModel({
|
|
137
|
+
...filterFns,
|
|
138
|
+
...options.filterFns
|
|
139
|
+
});
|
|
140
|
+
if (getSortedRowModel) rowModels.sortedRowModel = createSortedRowModel({
|
|
141
|
+
...sortFns,
|
|
142
|
+
...options.sortFns
|
|
143
|
+
});
|
|
144
|
+
if (getPaginationRowModel) rowModels.paginatedRowModel = createPaginatedRowModel();
|
|
145
|
+
if (getExpandedRowModel) rowModels.expandedRowModel = createExpandedRowModel();
|
|
146
|
+
if (getGroupedRowModel) rowModels.groupedRowModel = createGroupedRowModel({
|
|
147
|
+
...aggregationFns,
|
|
148
|
+
...options.aggregationFns
|
|
149
|
+
});
|
|
150
|
+
if (getFacetedRowModel) rowModels.facetedRowModel = createFacetedRowModel();
|
|
151
|
+
if (getFacetedMinMaxValues) rowModels.facetedMinMaxValues = createFacetedMinMaxValues();
|
|
152
|
+
if (getFacetedUniqueValues) rowModels.facetedUniqueValues = createFacetedUniqueValues();
|
|
153
|
+
return rowModels;
|
|
154
|
+
});
|
|
155
|
+
const table = useTable({
|
|
156
|
+
...restOptions,
|
|
157
|
+
features: stockFeatures,
|
|
158
|
+
rowModels
|
|
159
|
+
}, (state) => state);
|
|
160
|
+
const getState = useCallback(() => {
|
|
161
|
+
return table.state;
|
|
162
|
+
}, [table]);
|
|
163
|
+
const setState = useCallback((state) => {
|
|
164
|
+
Object.entries(state).forEach(([key, value]) => {
|
|
165
|
+
table.baseAtoms[key].set(value);
|
|
166
|
+
});
|
|
167
|
+
}, [table]);
|
|
168
|
+
return useMemo(() => ({
|
|
169
|
+
...table,
|
|
170
|
+
getState,
|
|
171
|
+
setState
|
|
172
|
+
}), [
|
|
173
|
+
table,
|
|
174
|
+
getState,
|
|
175
|
+
setState
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
export { getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, legacyCreateColumnHelper, useLegacyTable };
|
|
181
|
+
//# sourceMappingURL=useLegacyTable.js.map
|