@tanstack/vue-table
Version:
Headless UI for building powerful tables & datagrids for Vue.
34 lines • 1.56 kB
TypeScript
import { MaybeRef, VNode } from "vue";
import { RowData, Table, TableFeatures, TableOptions } from "@tanstack/table-core";
//#region src/useTable.d.ts
type TableOptionsWithReactiveData<TFeatures extends TableFeatures, TData extends RowData> = { [K in keyof TableOptions<TFeatures, TData>]: K extends 'data' ? MaybeRef<ReadonlyArray<TData>> : MaybeRef<TableOptions<TFeatures, TData>[K]>; };
type VueTable<TFeatures extends TableFeatures, TData extends RowData> = Table<TFeatures, TData> & {
/** Creates a reactive render boundary. The child function reads the table
* atoms it needs, so Vue only tracks those atom reads.
*/
Subscribe: (props: {
children: (atoms: Table<TFeatures, TData>['atoms']) => VNode | Array<VNode>;
}) => VNode | Array<VNode>;
};
/**
* Creates a Vue table instance backed by Vue-aware TanStack Store atoms.
*
* Table options may contain Vue refs or computed values. The adapter unwraps
* those reactive inputs, watches them with synchronous flushing, and keeps the
* table options in sync. Use `table.Subscribe` or native Vue computed values
* around `table.atoms.<slice>.get()` for selected reactive reads.
*
* @example
* ```ts
* const table = useTable(
* {
* features,
* columns,
* data,
* },
* )
* ```
*/
declare function useTable<TFeatures extends TableFeatures, TData extends RowData>(tableOptions: TableOptions<TFeatures, TData> | TableOptionsWithReactiveData<TFeatures, TData>): VueTable<TFeatures, TData>;
//#endregion
export { TableOptionsWithReactiveData, VueTable, useTable };