@tanstack/table-core
Version:
Headless UI for building powerful tables & datagrids for TS/JS.
45 lines • 2.06 kB
TypeScript
import { TableFeatures, ValidateFeatureSlots } from "../types/TableFeatures.js";
//#region src/helpers/tableFeatures.d.ts
/**
* A helper function to help define the features that are to be imported and applied to a table instance.
* Use this utility to make it easier to have the correct type inference for the features that are being imported.
* **Note:** It is recommended to use this utility statically outside of a component.
*
* Alongside feature modules, this object carries everything else that is
* statically stitched into the table:
*
* - Row model factories (`sortedRowModel`, `filteredRowModel`, etc.)
* - Row model function registries (`sortFns`, `filterFns`, `aggregationFns`),
* whose keys become the valid string values for `sortFn`, `filterFn`,
* `globalFilterFn`, and `aggregationFn` with full inference
* - Type-only `tableMeta`/`columnMeta` slots for declaring per-table meta types
* instead of using global declaration merging. The values are phantom
* (ignored and stripped at runtime); only their types are used.
* @example
* ```
* import {
* columnFilteringFeature,
* createFilteredRowModel,
* createSortedRowModel,
* filterFn_includesString,
* rowSortingFeature,
* sortFn_alphanumeric,
* sortFn_text,
* tableFeatures,
* } from '@tanstack/react-table'
* const features = tableFeatures({
* columnFilteringFeature,
* rowSortingFeature,
* filteredRowModel: createFilteredRowModel(),
* sortedRowModel: createSortedRowModel(),
* filterFns: { includesString: filterFn_includesString, myCustomFilterFn },
* sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text },
* tableMeta: {} as { updateData: (rowIndex: number, columnId: string, value: unknown) => void },
* columnMeta: {} as { align?: 'left' | 'right' },
* });
* const table = useTable({ features, columns, data });
* ```
*/
declare function tableFeatures<TFeatures extends TableFeatures>(features: TFeatures & ValidateFeatureSlots<TFeatures>): TFeatures;
//#endregion
export { tableFeatures };