@tanstack/react-table 9.0.0-alpha.12 → 9.0.0-alpha.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Subscribe.js","sources":["../../src/Subscribe.ts"],"sourcesContent":["'use client'\nimport { useStore } from '@tanstack/react-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a React node.\n */\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n props: SubscribeProps<TFeatures, TData, TSelected>,\n): ReturnType<FunctionComponent> {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"names":[],"mappings":";;AAyDO;AAOL;AAEA;AAGF;;;;"}
1
+ {"version":3,"file":"Subscribe.js","sources":["../../src/Subscribe.ts"],"sourcesContent":["'use client'\n\nimport { useStore } from '@tanstack/react-store'\nimport type {\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\n\nexport type SubscribeProps<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = {\n /**\n * The table instance to subscribe to. Required when using as a standalone component.\n * Not needed when using as `table.Subscribe`.\n */\n table: Table<TFeatures, TData>\n /**\n * A selector function that selects the part of the table state to subscribe to.\n * This allows for fine-grained reactivity by only re-rendering when the selected state changes.\n */\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n /**\n * The children to render. Can be a function that receives the selected state, or a React node.\n */\n children: ((state: TSelected) => ReactNode) | ReactNode\n}\n\n/**\n * A React component that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * ```tsx\n * // As a standalone component\n * <Subscribe table={table} selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </Subscribe>\n * ```\n *\n * @example\n * ```tsx\n * // As table.Subscribe (table instance method)\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => (\n * <div>Selected rows: {Object.keys(rowSelection).length}</div>\n * )}\n * </table.Subscribe>\n * ```\n */\nexport function Subscribe<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n props: SubscribeProps<TFeatures, TData, TSelected>,\n): ReturnType<FunctionComponent> {\n const selected = useStore(props.table.store, props.selector)\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n}\n"],"names":[],"mappings":";;AA0DO;AAOL;AAEA;AAGF;;;;"}
@@ -2,5 +2,4 @@ export * from '@tanstack/table-core';
2
2
  export * from './FlexRender.js';
3
3
  export * from './Subscribe.js';
4
4
  export * from './createTableHook.js';
5
- export * from './useLegacyTable.js';
6
5
  export * from './useTable.js';
package/dist/esm/index.js CHANGED
@@ -2,23 +2,12 @@ export * from "@tanstack/table-core";
2
2
  import { FlexRender, flexRender } from "./FlexRender.js";
3
3
  import { Subscribe } from "./Subscribe.js";
4
4
  import { createTableHook } from "./createTableHook.js";
5
- import { getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useLegacyTable } from "./useLegacyTable.js";
6
5
  import { useTable } from "./useTable.js";
7
6
  export {
8
7
  FlexRender,
9
8
  Subscribe,
10
9
  createTableHook,
11
10
  flexRender,
12
- getCoreRowModel,
13
- getExpandedRowModel,
14
- getFacetedMinMaxValues,
15
- getFacetedRowModel,
16
- getFacetedUniqueValues,
17
- getFilteredRowModel,
18
- getGroupedRowModel,
19
- getPaginationRowModel,
20
- getSortedRowModel,
21
- useLegacyTable,
22
11
  useTable
23
12
  };
24
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1 @@
1
+ export * from './useLegacyTable.js';
@@ -0,0 +1,15 @@
1
+ import { getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, legacyCreateColumnHelper, useLegacyTable } from "./useLegacyTable.js";
2
+ export {
3
+ getCoreRowModel,
4
+ getExpandedRowModel,
5
+ getFacetedMinMaxValues,
6
+ getFacetedRowModel,
7
+ getFacetedUniqueValues,
8
+ getFilteredRowModel,
9
+ getGroupedRowModel,
10
+ getPaginationRowModel,
11
+ getSortedRowModel,
12
+ legacyCreateColumnHelper,
13
+ useLegacyTable
14
+ };
15
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,4 +1,4 @@
1
- import { RowData, RowModel, StockFeatures, Table, TableOptions, TableState } from '@tanstack/table-core';
1
+ import { Cell, Column, ColumnDef, Header, HeaderGroup, Row, RowData, RowModel, StockFeatures, Table, TableOptions, TableState } from '@tanstack/table-core';
2
2
  import { ReactTable } from './useTable.js';
3
3
  /**
4
4
  * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.
@@ -150,6 +150,27 @@ export type LegacyReactTable<TData extends RowData> = ReactTable<StockFeatures,
150
150
  */
151
151
  getState: () => TableState<StockFeatures>;
152
152
  };
153
+ /** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */
154
+ export type LegacyColumn<TData extends RowData, TValue = unknown> = Column<StockFeatures, TData, TValue>;
155
+ /** @deprecated Use Row<TFeatures, TData> with useTable instead. */
156
+ export type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>;
157
+ /** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */
158
+ export type LegacyCell<TData extends RowData, TValue = unknown> = Cell<StockFeatures, TData, TValue>;
159
+ /** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */
160
+ export type LegacyHeader<TData extends RowData, TValue = unknown> = Header<StockFeatures, TData, TValue>;
161
+ /** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */
162
+ export type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<StockFeatures, TData>;
163
+ /** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */
164
+ export type LegacyColumnDef<TData extends RowData, TValue = unknown> = ColumnDef<StockFeatures, TData, TValue>;
165
+ /** @deprecated Use Table<TFeatures, TData> with useTable instead. */
166
+ export type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>;
167
+ /**
168
+ * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.
169
+ *
170
+ * A column helper with StockFeatures pre-bound for use with useLegacyTable.
171
+ * Only requires TData—no need to specify TFeatures.
172
+ */
173
+ export declare function legacyCreateColumnHelper<TData extends RowData>(): import('@tanstack/table-core').ColumnHelper<StockFeatures, TData>;
153
174
  /**
154
175
  * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
155
176
  *
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { createFilteredRowModel, filterFns, createSortedRowModel, sortFns, createPaginatedRowModel, createExpandedRowModel, createGroupedRowModel, aggregationFns, createFacetedRowModel, createFacetedMinMaxValues, createFacetedUniqueValues, stockFeatures } from "@tanstack/table-core";
2
+ import { createColumnHelper, createFilteredRowModel, filterFns, createSortedRowModel, sortFns, createPaginatedRowModel, createExpandedRowModel, createGroupedRowModel, aggregationFns, createFacetedRowModel, createFacetedMinMaxValues, createFacetedUniqueValues, stockFeatures } from "@tanstack/table-core";
3
3
  import { useMemo } from "react";
4
4
  import { useStore } from "@tanstack/react-store";
5
5
  import { useTable } from "./useTable.js";
@@ -37,6 +37,9 @@ function getCoreRowModel() {
37
37
  return (() => () => {
38
38
  });
39
39
  }
40
+ function legacyCreateColumnHelper() {
41
+ return createColumnHelper();
42
+ }
40
43
  function useLegacyTable(options) {
41
44
  const {
42
45
  // Extract legacy row model options
@@ -101,6 +104,7 @@ export {
101
104
  getGroupedRowModel,
102
105
  getPaginationRowModel,
103
106
  getSortedRowModel,
107
+ legacyCreateColumnHelper,
104
108
  useLegacyTable
105
109
  };
106
110
  //# sourceMappingURL=useLegacyTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLegacyTable.js","sources":["../../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useMemo } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { useTable } from './useTable'\nimport type {\n CreateRowModels_All,\n RowData,\n RowModel,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return (() => () => undefined) as unknown as FacetedMinMaxValuesFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return (() => () => new Map()) as unknown as FacetedUniqueValuesFactory<TData>\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\ntype RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\ntype FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\ntype FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\ntype FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.store.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n}\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n // Build the _rowModels object based on which legacy options were provided\n const _rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Map v8 row model factories to v9 _rowModels\n // Note: getCoreRowModel is handled automatically in v9, so we ignore it\n\n if (getFilteredRowModel) {\n _rowModels.filteredRowModel = createFilteredRowModel(filterFns)\n }\n\n if (getSortedRowModel) {\n _rowModels.sortedRowModel = createSortedRowModel(sortFns)\n }\n\n if (getPaginationRowModel) {\n _rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n _rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n _rowModels.groupedRowModel = createGroupedRowModel(aggregationFns)\n }\n\n if (getFacetedRowModel) {\n _rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n _rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n _rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>({\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n } as TableOptions<StockFeatures, TData>)\n\n const state = useStore(table.store, (state) => state)\n\n return useMemo(\n () =>\n ({\n ...table,\n getState: () => state,\n }) as LegacyReactTable<TData>,\n [table, state],\n )\n}\n"],"names":["getFilteredRowModel","getSortedRowModel","getPaginationRowModel","getExpandedRowModel","getGroupedRowModel","getFacetedRowModel","getFacetedMinMaxValues","getFacetedUniqueValues"],"mappings":";;;;;AA2CO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AACF;AAQO;AAGL;AACF;AAQO;AAGL;AAAoB;AACtB;AAyJO;AAGL;AAAM;AAAA;AAEa;AACjBA;AACAC;AACAC;AACAC;AACAC;AACAC;AACAC;AACAC;AAAAA;AAEG;AAIL;AAKA;AACE;AAA8D;AAGhE;AACE;AAAwD;AAG1D;AACE;AAA+B;AAGjC;AACE;AAA8B;AAGhC;AACE;AAAiE;AAGnE;AACE;AAA6B;AAG/B;AACE;AAAiC;AAGnC;AACE;AAAiC;AAInC;AAAwE;AACnE;AACQ;AACX;AAGF;AAEA;AAAO;AAEF;AACI;AACa;AAAA;AAEP;AAEjB;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"useLegacyTable.js","sources":["../../src/useLegacyTable.ts"],"sourcesContent":["'use client'\n\nimport {\n aggregationFns,\n createColumnHelper,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n filterFns,\n sortFns,\n stockFeatures,\n} from '@tanstack/table-core'\nimport { useMemo } from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport { useTable } from './useTable'\nimport type {\n Cell,\n Column,\n ColumnDef,\n CreateRowModels_All,\n Header,\n HeaderGroup,\n Row,\n RowData,\n RowModel,\n StockFeatures,\n Table,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { ReactTable } from './useTable'\n\n// =============================================================================\n// V8-style row model factory functions\n// These are stub functions that act as markers for useLegacyTable to know\n// which row models to enable. They don't actually do anything - the real\n// implementation is handled by useLegacyTable internally.\n// =============================================================================\n\n/**\n * @deprecated Use `createFilteredRowModel(filterFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the filtered row model.\n */\nexport function getFilteredRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createSortedRowModel(sortFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the sorted row model.\n */\nexport function getSortedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createPaginatedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the paginated row model.\n */\nexport function getPaginationRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createExpandedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the expanded row model.\n */\nexport function getExpandedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createGroupedRowModel(aggregationFns)` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the grouped row model.\n */\nexport function getGroupedRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedRowModel()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted row model.\n */\nexport function getFacetedRowModel<\n TData extends RowData,\n>(): FacetedRowModelFactory<TData> {\n return (() => () => {}) as unknown as FacetedRowModelFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedMinMaxValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted min/max values.\n */\nexport function getFacetedMinMaxValues<\n TData extends RowData,\n>(): FacetedMinMaxValuesFactory<TData> {\n return (() => () => undefined) as unknown as FacetedMinMaxValuesFactory<TData>\n}\n\n/**\n * @deprecated Use `createFacetedUniqueValues()` with the new `useTable` hook instead.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It acts as a marker to enable the faceted unique values.\n */\nexport function getFacetedUniqueValues<\n TData extends RowData,\n>(): FacetedUniqueValuesFactory<TData> {\n return (() => () => new Map()) as unknown as FacetedUniqueValuesFactory<TData>\n}\n\n/**\n * @deprecated The core row model is always created automatically in v9.\n *\n * This is a stub function for v8 API compatibility with `useLegacyTable`.\n * It does nothing - the core row model is always available.\n */\nexport function getCoreRowModel<\n TData extends RowData,\n>(): RowModelFactory<TData> {\n return (() => () => {}) as unknown as RowModelFactory<TData>\n}\n\n// =============================================================================\n// Type definitions\n// =============================================================================\n\n/**\n * Row model factory function type from v8 API\n */\ntype RowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted row model factory function type from v8 API\n */\ntype FacetedRowModelFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => RowModel<StockFeatures, TData>\n\n/**\n * Faceted min/max values factory function type from v8 API\n */\ntype FacetedMinMaxValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number]\n\n/**\n * Faceted unique values factory function type from v8 API\n */\ntype FacetedUniqueValuesFactory<TData extends RowData> = (\n table: Table<StockFeatures, TData>,\n columnId: string,\n) => () => Map<any, number>\n\n/**\n * Legacy v8-style row model options\n */\nexport interface LegacyRowModelOptions<TData extends RowData> {\n /**\n * Returns the core row model for the table.\n * @deprecated This option is no longer needed in v9. The core row model is always created automatically.\n */\n getCoreRowModel?: RowModelFactory<TData>\n /**\n * Returns the filtered row model for the table.\n * @deprecated Use `_rowModels.filteredRowModel` with `createFilteredRowModel(filterFns)` instead.\n */\n getFilteredRowModel?: RowModelFactory<TData>\n /**\n * Returns the sorted row model for the table.\n * @deprecated Use `_rowModels.sortedRowModel` with `createSortedRowModel(sortFns)` instead.\n */\n getSortedRowModel?: RowModelFactory<TData>\n /**\n * Returns the paginated row model for the table.\n * @deprecated Use `_rowModels.paginatedRowModel` with `createPaginatedRowModel()` instead.\n */\n getPaginationRowModel?: RowModelFactory<TData>\n /**\n * Returns the expanded row model for the table.\n * @deprecated Use `_rowModels.expandedRowModel` with `createExpandedRowModel()` instead.\n */\n getExpandedRowModel?: RowModelFactory<TData>\n /**\n * Returns the grouped row model for the table.\n * @deprecated Use `_rowModels.groupedRowModel` with `createGroupedRowModel(aggregationFns)` instead.\n */\n getGroupedRowModel?: RowModelFactory<TData>\n /**\n * Returns the faceted row model for a column.\n * @deprecated Use `_rowModels.facetedRowModel` with `createFacetedRowModel()` instead.\n */\n getFacetedRowModel?: FacetedRowModelFactory<TData>\n /**\n * Returns the faceted min/max values for a column.\n * @deprecated Use `_rowModels.facetedMinMaxValues` with `createFacetedMinMaxValues()` instead.\n */\n getFacetedMinMaxValues?: FacetedMinMaxValuesFactory<TData>\n /**\n * Returns the faceted unique values for a column.\n * @deprecated Use `_rowModels.facetedUniqueValues` with `createFacetedUniqueValues()` instead.\n */\n getFacetedUniqueValues?: FacetedUniqueValuesFactory<TData>\n}\n\n/**\n * Legacy v8-style table options that work with useLegacyTable.\n *\n * This type omits `_features` and `_rowModels` and instead accepts the v8-style\n * `get*RowModel` function options.\n *\n * @deprecated This is a compatibility layer for migrating from v8. Use `useTable` with explicit `_features` and `_rowModels` instead.\n */\nexport type LegacyTableOptions<TData extends RowData> = Omit<\n TableOptions<StockFeatures, TData>,\n '_features' | '_rowModels'\n> &\n LegacyRowModelOptions<TData>\n\n/**\n * Legacy table instance type that includes the v8-style `getState()` method.\n *\n * @deprecated Use `useTable` with explicit state selection instead.\n */\nexport type LegacyReactTable<TData extends RowData> = ReactTable<\n StockFeatures,\n TData,\n TableState<StockFeatures>\n> & {\n /**\n * Returns the current table state.\n * @deprecated In v9, access state directly via `table.state` or use `table.store.state` for the full state.\n */\n getState: () => TableState<StockFeatures>\n}\n\n// =============================================================================\n// Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable\n// =============================================================================\n\n/** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumn<TData extends RowData, TValue = unknown> = Column<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Row<TFeatures, TData> with useTable instead. */\nexport type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>\n\n/** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyCell<TData extends RowData, TValue = unknown> = Cell<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyHeader<TData extends RowData, TValue = unknown> = Header<\n StockFeatures,\n TData,\n TValue\n>\n\n/** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */\nexport type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<\n StockFeatures,\n TData\n>\n\n/** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */\nexport type LegacyColumnDef<\n TData extends RowData,\n TValue = unknown,\n> = ColumnDef<StockFeatures, TData, TValue>\n\n/** @deprecated Use Table<TFeatures, TData> with useTable instead. */\nexport type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>\n\n// =============================================================================\n// Legacy column helper - StockFeatures hardcoded\n// =============================================================================\n\n/**\n * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.\n *\n * A column helper with StockFeatures pre-bound for use with useLegacyTable.\n * Only requires TData—no need to specify TFeatures.\n */\nexport function legacyCreateColumnHelper<TData extends RowData>() {\n return createColumnHelper<StockFeatures, TData>()\n}\n\n// =============================================================================\n// useLegacyTable hook\n// =============================================================================\n\n/**\n * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.\n *\n * Use the new `useTable` hook instead with explicit `_features` and `_rowModels`:\n *\n * ```tsx\n * // New v9 API\n * const _features = tableFeatures({\n * columnFilteringFeature,\n * rowSortingFeature,\n * rowPaginationFeature,\n * })\n *\n * const table = useTable({\n * _features,\n * _rowModels: {\n * filteredRowModel: createFilteredRowModel(filterFns),\n * sortedRowModel: createSortedRowModel(sortFns),\n * paginatedRowModel: createPaginatedRowModel(),\n * },\n * columns,\n * data,\n * })\n * ```\n *\n * Key differences from v8:\n * - Features are tree-shakeable - only import what you use\n * - Row models are explicitly passed via `_rowModels`\n * - Use `table.Subscribe` for fine-grained re-renders\n * - State is accessed via `table.state` after selecting with the 2nd argument\n *\n * @param options - Legacy v8-style table options\n * @returns A table instance with the full state subscribed and a `getState()` method\n */\nexport function useLegacyTable<TData extends RowData>(\n options: LegacyTableOptions<TData>,\n): LegacyReactTable<TData> {\n const {\n // Extract legacy row model options\n getCoreRowModel: _getCoreRowModel,\n getFilteredRowModel,\n getSortedRowModel,\n getPaginationRowModel,\n getExpandedRowModel,\n getGroupedRowModel,\n getFacetedRowModel,\n getFacetedMinMaxValues,\n getFacetedUniqueValues,\n // Rest of the options\n ...restOptions\n } = options\n\n // Build the _rowModels object based on which legacy options were provided\n const _rowModels: CreateRowModels_All<StockFeatures, TData> = {}\n\n // Map v8 row model factories to v9 _rowModels\n // Note: getCoreRowModel is handled automatically in v9, so we ignore it\n\n if (getFilteredRowModel) {\n _rowModels.filteredRowModel = createFilteredRowModel(filterFns)\n }\n\n if (getSortedRowModel) {\n _rowModels.sortedRowModel = createSortedRowModel(sortFns)\n }\n\n if (getPaginationRowModel) {\n _rowModels.paginatedRowModel = createPaginatedRowModel()\n }\n\n if (getExpandedRowModel) {\n _rowModels.expandedRowModel = createExpandedRowModel()\n }\n\n if (getGroupedRowModel) {\n _rowModels.groupedRowModel = createGroupedRowModel(aggregationFns)\n }\n\n if (getFacetedRowModel) {\n _rowModels.facetedRowModel = createFacetedRowModel()\n }\n\n if (getFacetedMinMaxValues) {\n _rowModels.facetedMinMaxValues = createFacetedMinMaxValues()\n }\n\n if (getFacetedUniqueValues) {\n _rowModels.facetedUniqueValues = createFacetedUniqueValues()\n }\n\n // Call useTable with the v9 API, subscribing to all state changes\n const table = useTable<StockFeatures, TData, TableState<StockFeatures>>({\n ...restOptions,\n _features: stockFeatures,\n _rowModels,\n } as TableOptions<StockFeatures, TData>)\n\n const state = useStore(table.store, (state) => state)\n\n return useMemo(\n () =>\n ({\n ...table,\n getState: () => state,\n }) as LegacyReactTable<TData>,\n [table, state],\n )\n}\n"],"names":["getFilteredRowModel","getSortedRowModel","getPaginationRowModel","getExpandedRowModel","getGroupedRowModel","getFacetedRowModel","getFacetedMinMaxValues","getFacetedUniqueValues"],"mappings":";;;;;AAkDO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AAAoB;AACtB;AAQO;AAGL;AACF;AAQO;AAGL;AACF;AAQO;AAGL;AAAoB;AACtB;AA4KO;AACL;AACF;AAwCO;AAGL;AAAM;AAAA;AAEa;AACjBA;AACAC;AACAC;AACAC;AACAC;AACAC;AACAC;AACAC;AAAAA;AAEG;AAIL;AAKA;AACE;AAA8D;AAGhE;AACE;AAAwD;AAG1D;AACE;AAA+B;AAGjC;AACE;AAA8B;AAGhC;AACE;AAAiE;AAGnE;AACE;AAA6B;AAG/B;AACE;AAAiC;AAGnC;AACE;AAAiC;AAInC;AAAwE;AACnE;AACQ;AACX;AAGF;AAEA;AAAO;AAEF;AACI;AACa;AAAA;AAEP;AAEjB;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../src/useTable.ts"],"sourcesContent":["'use client'\nimport { useEffect, useLayoutEffect, useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { useStore } from '@tanstack/react-store'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type {\n CellData,\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribeProps } from './Subscribe'\n\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A React HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => ( // important to include `{() => {()}}` syntax\n * <tr key={row.id}>\n // render the row\n * </tr>\n * ))}\n * </table.Subscribe>\n */\n Subscribe: <TSelected>(props: {\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n }) => ReturnType<FunctionComponent>\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of `table.store.state` because it is selected by the `selector` function that you pass as the 2nd argument to `useTable`.\n *\n * @example\n * const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state\n *\n * console.log(table.state.globalFilter)\n */\n readonly state: Readonly<TSelected>\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): ReactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable(tableOptions) as ReactTable<\n TFeatures,\n TData,\n TSelected\n >\n\n tableInstance.Subscribe = function SubscribeBound<TSelected>(\n props: Omit<SubscribeProps<TFeatures, TData, TSelected>, 'table'>,\n ) {\n return Subscribe({ ...props, table: tableInstance })\n }\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync table options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n useIsomorphicLayoutEffect(() => {\n // prevent race condition between table.setOptions and table.baseStore.setState\n queueMicrotask(() => {\n table.baseStore.setState((prev) => ({\n ...prev,\n }))\n })\n }, [\n table.options.columns, // re-render when columns change\n table.options.data, // re-render when data changes\n table.options.state, // sync react state to the table store\n ])\n\n const state = useStore(table.store, selector)\n\n return useMemo(\n () => ({\n ...table,\n state,\n }),\n [state, table],\n )\n}\n"],"names":[],"mappings":";;;;;;AAmBA;AA0DO;AASL;AACE;AAMA;AAGE;AAAmD;AAGrD;AAEA;AAAO;AAIT;AAA4B;AACvB;AACA;AAGL;AAEE;AACE;AAAoC;AAC/B;AACH;AACH;AACA;AACa;AAAA;AACA;AAAA;AACA;AAAA;AAGhB;AAEA;AAAO;AACE;AACF;AACH;AAAA;AAEW;AAEjB;;;;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../src/useTable.ts"],"sourcesContent":["'use client'\n\nimport { useEffect, useLayoutEffect, useMemo, useState } from 'react'\nimport { constructTable } from '@tanstack/table-core'\nimport { useStore } from '@tanstack/react-store'\nimport { FlexRender } from './FlexRender'\nimport { Subscribe } from './Subscribe'\nimport type {\n CellData,\n NoInfer,\n RowData,\n Table,\n TableFeatures,\n TableOptions,\n TableState,\n} from '@tanstack/table-core'\nimport type { FunctionComponent, ReactNode } from 'react'\nimport type { FlexRenderProps } from './FlexRender'\nimport type { SubscribeProps } from './Subscribe'\n\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport type ReactTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n> = Table<TFeatures, TData> & {\n /**\n * A React HOC (Higher Order Component) that allows you to subscribe to the table state.\n *\n * This is useful for opting into state re-renders for specific parts of the table state.\n *\n * @example\n * <table.Subscribe selector={(state) => ({ rowSelection: state.rowSelection })}>\n * {({ rowSelection }) => ( // important to include `{() => {()}}` syntax\n * <tr key={row.id}>\n // render the row\n * </tr>\n * ))}\n * </table.Subscribe>\n */\n Subscribe: <TSelected>(props: {\n selector: (state: NoInfer<TableState<TFeatures>>) => TSelected\n children: ((state: TSelected) => ReactNode) | ReactNode\n }) => ReturnType<FunctionComponent>\n /**\n * A React component that renders headers, cells, or footers with custom markup.\n * Use this utility component instead of manually calling flexRender.\n *\n * @example\n * ```tsx\n * <table.FlexRender cell={cell} />\n * <table.FlexRender header={header} />\n * <table.FlexRender footer={footer} />\n * ```\n *\n * This replaces calling `flexRender` directly like this:\n * ```tsx\n * flexRender(cell.column.columnDef.cell, cell.getContext())\n * flexRender(header.column.columnDef.header, header.getContext())\n * flexRender(footer.column.columnDef.footer, footer.getContext())\n * ```\n */\n FlexRender: <TValue extends CellData = CellData>(\n props: FlexRenderProps<TFeatures, TData, TValue>,\n ) => ReactNode\n /**\n * The selected state of the table. This state may not match the structure of `table.store.state` because it is selected by the `selector` function that you pass as the 2nd argument to `useTable`.\n *\n * @example\n * const table = useTable(options, (state) => ({ globalFilter: state.globalFilter })) // only globalFilter is part of the selected state\n *\n * console.log(table.state.globalFilter)\n */\n readonly state: Readonly<TSelected>\n}\n\nexport function useTable<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TSelected = {},\n>(\n tableOptions: TableOptions<TFeatures, TData>,\n selector: (state: TableState<TFeatures>) => TSelected = () =>\n ({}) as TSelected,\n): ReactTable<TFeatures, TData, TSelected> {\n const [table] = useState(() => {\n const tableInstance = constructTable(tableOptions) as ReactTable<\n TFeatures,\n TData,\n TSelected\n >\n\n tableInstance.Subscribe = function SubscribeBound<TSelected>(\n props: Omit<SubscribeProps<TFeatures, TData, TSelected>, 'table'>,\n ) {\n return Subscribe({ ...props, table: tableInstance })\n }\n\n tableInstance.FlexRender = FlexRender\n\n return tableInstance\n })\n\n // sync table options on every render\n table.setOptions((prev) => ({\n ...prev,\n ...tableOptions,\n }))\n\n useIsomorphicLayoutEffect(() => {\n // prevent race condition between table.setOptions and table.baseStore.setState\n queueMicrotask(() => {\n table.baseStore.setState((prev) => ({\n ...prev,\n }))\n })\n }, [\n table.options.columns, // re-render when columns change\n table.options.data, // re-render when data changes\n table.options.state, // sync react state to the table store\n ])\n\n const state = useStore(table.store, selector)\n\n return useMemo(\n () => ({\n ...table,\n state,\n }),\n [state, table],\n )\n}\n"],"names":[],"mappings":";;;;;;AAoBA;AA0DO;AASL;AACE;AAMA;AAGE;AAAmD;AAGrD;AAEA;AAAO;AAIT;AAA4B;AACvB;AACA;AAGL;AAEE;AACE;AAAoC;AAC/B;AACH;AACH;AACA;AACa;AAAA;AACA;AAAA;AACA;AAAA;AAGhB;AAEA;AAAO;AACE;AACF;AACH;AAAA;AAEW;AAEjB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-table",
3
- "version": "9.0.0-alpha.12",
3
+ "version": "9.0.0-alpha.15",
4
4
  "description": "Headless UI for building powerful tables & datagrids for React.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -31,7 +31,13 @@
31
31
  "default": "./dist/esm/index.js"
32
32
  }
33
33
  },
34
- "./package.json": "./package.json"
34
+ "./package.json": "./package.json",
35
+ "./legacy": {
36
+ "import": {
37
+ "types": "./dist/esm/legacy.d.ts",
38
+ "default": "./dist/esm/legacy.js"
39
+ }
40
+ }
35
41
  },
36
42
  "sideEffects": false,
37
43
  "engines": {
@@ -43,7 +49,7 @@
43
49
  ],
44
50
  "dependencies": {
45
51
  "@tanstack/react-store": "^0.9.1",
46
- "@tanstack/table-core": "9.0.0-alpha.12"
52
+ "@tanstack/table-core": "9.0.0-alpha.13"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@eslint-react/eslint-plugin": "^2.13.0",
package/src/Subscribe.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client'
2
+
2
3
  import { useStore } from '@tanstack/react-store'
3
4
  import type {
4
5
  NoInfer,
package/src/index.ts CHANGED
@@ -3,5 +3,4 @@ export * from '@tanstack/table-core'
3
3
  export * from './FlexRender'
4
4
  export * from './Subscribe'
5
5
  export * from './createTableHook'
6
- export * from './useLegacyTable'
7
6
  export * from './useTable'
package/src/legacy.ts ADDED
@@ -0,0 +1,3 @@
1
+ // Legacy entry - v8-style API for incremental migration
2
+ // Import flexRender, types (ColumnFiltersState, etc.) from '@tanstack/react-table'
3
+ export * from './useLegacyTable'
@@ -2,6 +2,7 @@
2
2
 
3
3
  import {
4
4
  aggregationFns,
5
+ createColumnHelper,
5
6
  createExpandedRowModel,
6
7
  createFacetedMinMaxValues,
7
8
  createFacetedRowModel,
@@ -18,7 +19,13 @@ import { useMemo } from 'react'
18
19
  import { useStore } from '@tanstack/react-store'
19
20
  import { useTable } from './useTable'
20
21
  import type {
22
+ Cell,
23
+ Column,
24
+ ColumnDef,
21
25
  CreateRowModels_All,
26
+ Header,
27
+ HeaderGroup,
28
+ Row,
22
29
  RowData,
23
30
  RowModel,
24
31
  StockFeatures,
@@ -260,6 +267,67 @@ export type LegacyReactTable<TData extends RowData> = ReactTable<
260
267
  getState: () => TableState<StockFeatures>
261
268
  }
262
269
 
270
+ // =============================================================================
271
+ // Legacy type aliases - StockFeatures hardcoded for simpler prop typing with useLegacyTable
272
+ // =============================================================================
273
+
274
+ /** @deprecated Use Column<TFeatures, TData, TValue> with useTable instead. */
275
+ export type LegacyColumn<TData extends RowData, TValue = unknown> = Column<
276
+ StockFeatures,
277
+ TData,
278
+ TValue
279
+ >
280
+
281
+ /** @deprecated Use Row<TFeatures, TData> with useTable instead. */
282
+ export type LegacyRow<TData extends RowData> = Row<StockFeatures, TData>
283
+
284
+ /** @deprecated Use Cell<TFeatures, TData, TValue> with useTable instead. */
285
+ export type LegacyCell<TData extends RowData, TValue = unknown> = Cell<
286
+ StockFeatures,
287
+ TData,
288
+ TValue
289
+ >
290
+
291
+ /** @deprecated Use Header<TFeatures, TData, TValue> with useTable instead. */
292
+ export type LegacyHeader<TData extends RowData, TValue = unknown> = Header<
293
+ StockFeatures,
294
+ TData,
295
+ TValue
296
+ >
297
+
298
+ /** @deprecated Use HeaderGroup<TFeatures, TData> with useTable instead. */
299
+ export type LegacyHeaderGroup<TData extends RowData> = HeaderGroup<
300
+ StockFeatures,
301
+ TData
302
+ >
303
+
304
+ /** @deprecated Use ColumnDef<TFeatures, TData, TValue> with useTable instead. */
305
+ export type LegacyColumnDef<
306
+ TData extends RowData,
307
+ TValue = unknown,
308
+ > = ColumnDef<StockFeatures, TData, TValue>
309
+
310
+ /** @deprecated Use Table<TFeatures, TData> with useTable instead. */
311
+ export type LegacyTable<TData extends RowData> = Table<StockFeatures, TData>
312
+
313
+ // =============================================================================
314
+ // Legacy column helper - StockFeatures hardcoded
315
+ // =============================================================================
316
+
317
+ /**
318
+ * @deprecated Use `createColumnHelper<TFeatures, TData>()` with useTable instead.
319
+ *
320
+ * A column helper with StockFeatures pre-bound for use with useLegacyTable.
321
+ * Only requires TData—no need to specify TFeatures.
322
+ */
323
+ export function legacyCreateColumnHelper<TData extends RowData>() {
324
+ return createColumnHelper<StockFeatures, TData>()
325
+ }
326
+
327
+ // =============================================================================
328
+ // useLegacyTable hook
329
+ // =============================================================================
330
+
263
331
  /**
264
332
  * @deprecated This hook is provided as a compatibility layer for migrating from TanStack Table v8.
265
333
  *
package/src/useTable.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client'
2
+
2
3
  import { useEffect, useLayoutEffect, useMemo, useState } from 'react'
3
4
  import { constructTable } from '@tanstack/table-core'
4
5
  import { useStore } from '@tanstack/react-store'