diff --git a/docs/guide/sorting.md b/docs/guide/sorting.md index a0e66d198e..102bea4dd6 100644 --- a/docs/guide/sorting.md +++ b/docs/guide/sorting.md @@ -130,7 +130,7 @@ const table = useTable({ }) ``` -### Sorting ProcessingFns +### Sorting RowModelFns The default sorting function for all columns is inferred from the data type of the column. However, it can be useful to define the exact sorting function that you want to use for a specific column, especially if any of your data is nullable or not a standard data type. diff --git a/examples/react/basic-table-helper/src/main.tsx b/examples/react/basic-table-helper/src/main.tsx index ce03a1a6ac..2867da774a 100644 --- a/examples/react/basic-table-helper/src/main.tsx +++ b/examples/react/basic-table-helper/src/main.tsx @@ -55,7 +55,7 @@ const defaultData: Array = [ const tableHelper = createTableHelper({ _features: {}, _rowModels: {}, // client-side row models. `Core` row model is now included by default, but you can still override it here - _processingFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example + _rowModelFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example debugTable: true, // TData: {} as Person, // optionally, set the TData type for the table helper. Omit if this will be a table helper for multiple tables of all different data types }) diff --git a/examples/react/custom-features/src/main.tsx b/examples/react/custom-features/src/main.tsx index 61104b131e..12a59e2294 100644 --- a/examples/react/custom-features/src/main.tsx +++ b/examples/react/custom-features/src/main.tsx @@ -193,7 +193,7 @@ function App() { paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), }, - _processingFns: { + _rowModelFns: { filterFns, sortFns, }, diff --git a/examples/react/expanding/src/main.tsx b/examples/react/expanding/src/main.tsx index d70c157c05..d6bef2aa19 100644 --- a/examples/react/expanding/src/main.tsx +++ b/examples/react/expanding/src/main.tsx @@ -33,7 +33,7 @@ const tableHelper = createTableHelper({ rowSortingFeature, rowSelectionFeature, }, - _processingFns: { + _rowModelFns: { filterFns: filterFns, sortFns: sortFns, }, diff --git a/examples/react/filters-faceted/src/main.tsx b/examples/react/filters-faceted/src/main.tsx index 2e2a5adaff..afd000d233 100644 --- a/examples/react/filters-faceted/src/main.tsx +++ b/examples/react/filters-faceted/src/main.tsx @@ -102,7 +102,7 @@ function App() { const table = useTable({ _features, - _processingFns: { + _rowModelFns: { filterFns, sortFns, }, diff --git a/examples/react/filters-fuzzy/src/main.tsx b/examples/react/filters-fuzzy/src/main.tsx index b33caa64b7..3e61a10dd1 100644 --- a/examples/react/filters-fuzzy/src/main.tsx +++ b/examples/react/filters-fuzzy/src/main.tsx @@ -66,8 +66,8 @@ const fuzzySort: SortingFn = ( // Only sort by rank if the column has ranking information if (rowA.columnFiltersMeta[columnId]) { dir = compareItems( - rowA.columnFiltersMeta[columnId].itemRank, - rowB.columnFiltersMeta[columnId].itemRank, + rowA.columnFiltersMeta[columnId].itemRank!, + rowB.columnFiltersMeta[columnId].itemRank!, ) } @@ -131,7 +131,7 @@ function App() { const table = useTable({ _features, - _processingFns: { + _rowModelFns: { filterFns, }, _rowModels: { diff --git a/examples/react/filters/src/main.tsx b/examples/react/filters/src/main.tsx index c27a974b84..15dfa95305 100644 --- a/examples/react/filters/src/main.tsx +++ b/examples/react/filters/src/main.tsx @@ -109,7 +109,7 @@ function App() { sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), }, - _processingFns: { + _rowModelFns: { filterFns, // client side filtering sortFns, }, diff --git a/examples/react/pagination/src/main.tsx b/examples/react/pagination/src/main.tsx index a1a8873d6a..b71600a756 100644 --- a/examples/react/pagination/src/main.tsx +++ b/examples/react/pagination/src/main.tsx @@ -8,7 +8,7 @@ import { createSortedRowModel, filterFns, flexRender, - processingFns, + rowModelFns, rowPaginationFeature, rowSortingFeature, sortFns, @@ -30,7 +30,7 @@ const _features = tableFeatures({ rowSortingFeature, }) -const _processingFns = processingFns(_features, { +const _rowModelFns = rowModelFns(_features, { sortFns, filterFns, }) @@ -107,7 +107,7 @@ function MyTable({ const table = useTable({ _features, - _processingFns, + _rowModelFns, _rowModels: { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), diff --git a/examples/react/sorting/src/main.tsx b/examples/react/sorting/src/main.tsx index 0dd67f977d..bb444000fe 100644 --- a/examples/react/sorting/src/main.tsx +++ b/examples/react/sorting/src/main.tsx @@ -89,7 +89,7 @@ // const table = useTable({ // _features, -// _processingFns: { +// _rowModelFns: { // sortFns, // }, // _rowModels: { @@ -224,7 +224,7 @@ export const useReactTable = createTableHelper({ groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), }, - _processingFns: { + _rowModelFns: { sortFns, filterFns, aggregationFns, diff --git a/examples/solid/basic-table-helper/src/App.tsx b/examples/solid/basic-table-helper/src/App.tsx index 6a46606554..c61122cd46 100644 --- a/examples/solid/basic-table-helper/src/App.tsx +++ b/examples/solid/basic-table-helper/src/App.tsx @@ -45,7 +45,7 @@ const defaultData: Array = [ const tableHelper = createTableHelper({ _features: {}, _rowModels: {}, // client-side row models. `Core` row model is now included by default, but you can still override it here - _processingFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example + _rowModelFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example TData: {} as Person, debugTable: true, }) diff --git a/examples/solid/filters/src/App.tsx b/examples/solid/filters/src/App.tsx index 08be7cff9c..0b4edda989 100644 --- a/examples/solid/filters/src/App.tsx +++ b/examples/solid/filters/src/App.tsx @@ -95,7 +95,7 @@ function App() { facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), }, - _processingFns: { + _rowModelFns: { filterFns, }, get data() { diff --git a/examples/svelte/basic-table-helper/src/App.svelte b/examples/svelte/basic-table-helper/src/App.svelte index 9cbc7f0e82..47fc63fc97 100644 --- a/examples/svelte/basic-table-helper/src/App.svelte +++ b/examples/svelte/basic-table-helper/src/App.svelte @@ -46,7 +46,7 @@ const tableHelper = createTableHelper({ _features: { columnSizingFeature: {} }, _rowModels: {}, // client-side row models. `Core` row model is now included by default, but you can still override it here - _processingFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example + _rowModelFns: {}, // client-side processing functions used by the row models (sorting, filtering, etc.). Not needed in this basic example debugTable: true, // TData: {} as Person, // optionally, set the TData type for the table helper. Omit if this will be a table helper for multiple tables of all different data types }) diff --git a/examples/svelte/filtering/src/App.svelte b/examples/svelte/filtering/src/App.svelte index 2cbed09748..0679e4449c 100644 --- a/examples/svelte/filtering/src/App.svelte +++ b/examples/svelte/filtering/src/App.svelte @@ -63,7 +63,7 @@ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), }, - _processingFns: { + _rowModelFns: { filterFns: { fuzzy: fuzzyFilter, }, diff --git a/examples/svelte/sorting/src/App.svelte b/examples/svelte/sorting/src/App.svelte index 5509c83047..2370623753 100644 --- a/examples/svelte/sorting/src/App.svelte +++ b/examples/svelte/sorting/src/App.svelte @@ -85,7 +85,7 @@ _rowModels: { sortedRowModel: createSortedRowModel(), }, - _processingFns: { + _rowModelFns: { sortFns, }, get data() { diff --git a/packages/react-table/src/createTableHelper.ts b/packages/react-table/src/createTableHelper.ts index 3dfd07de89..0e6efe4da3 100644 --- a/packages/react-table/src/createTableHelper.ts +++ b/packages/react-table/src/createTableHelper.ts @@ -16,7 +16,7 @@ export type TableHelper< useTable: ( tableOptions: Omit< TableOptions, - '_features' | '_rowModels' | '_processingFns' + '_features' | '_rowModels' | '_rowModelFns' >, ) => Table } diff --git a/packages/solid-table/src/createTableHelper.ts b/packages/solid-table/src/createTableHelper.ts index 60e6caf4fe..ee5a1b90e9 100644 --- a/packages/solid-table/src/createTableHelper.ts +++ b/packages/solid-table/src/createTableHelper.ts @@ -16,7 +16,7 @@ export type TableHelper< createTable: ( tableOptions: Omit< TableOptions, - '_features' | '_rowModels' | '_processingFns' + '_features' | '_rowModels' | '_rowModelFns' >, ) => Table } diff --git a/packages/svelte-table/src/createTableHelper.ts b/packages/svelte-table/src/createTableHelper.ts index d6832ee913..d895244933 100644 --- a/packages/svelte-table/src/createTableHelper.ts +++ b/packages/svelte-table/src/createTableHelper.ts @@ -16,7 +16,7 @@ export type TableHelper< createTable: ( tableOptions: Omit< TableOptions, - '_features' | '_rowModels' | '_processingFns' + '_features' | '_rowModels' | '_rowModelFns' >, ) => Table } diff --git a/packages/table-core/src/core/table/constructTable.test.ts b/packages/table-core/src/core/table/constructTable.test.ts index 2b5496e0cc..a060547d9e 100644 --- a/packages/table-core/src/core/table/constructTable.test.ts +++ b/packages/table-core/src/core/table/constructTable.test.ts @@ -13,7 +13,7 @@ describe('constructTable', () => { expect(table).toBeDefined() // core table properties expect(table).toHaveProperty('_features') - expect(table).toHaveProperty('_processingFns') + expect(table).toHaveProperty('_rowModelFns') expect(table).toHaveProperty('_rowModels') expect(table).toHaveProperty('initialState') expect(table).toHaveProperty('options') diff --git a/packages/table-core/src/core/table/constructTable.ts b/packages/table-core/src/core/table/constructTable.ts index 72b800c9ef..ed7a81369b 100644 --- a/packages/table-core/src/core/table/constructTable.ts +++ b/packages/table-core/src/core/table/constructTable.ts @@ -27,7 +27,7 @@ export function constructTable< console.info('Constructing Table Instance...') } - const { _features = {} as TFeatures, _processingFns = {} } = options + const { _features = {} as TFeatures, _rowModelFns = {} } = options const featuresList: Array = Object.values(_features) @@ -41,8 +41,8 @@ export function constructTable< const coreInstance: Table_CoreProperties = { _features, // features get stored here immediately - _processingFns, // processing functions get stored here _rowModels: {} as CachedRowModels, // row models get cached here later + _rowModelFns, // row model processing functions get stored here options: { ...defaultOptions, ...options, diff --git a/packages/table-core/src/core/table/tablesFeature.types.ts b/packages/table-core/src/core/table/tablesFeature.types.ts index 595fc5eb63..403c7ffcdc 100644 --- a/packages/table-core/src/core/table/tablesFeature.types.ts +++ b/packages/table-core/src/core/table/tablesFeature.types.ts @@ -1,4 +1,4 @@ -import type { ProcessingFns } from '../../types/ProcessingFns' +import type { RowModelFns } from '../../types/RowModelFns' import type { RowData, Updater } from '../../types/type-utils' import type { CoreTableFeatures, @@ -24,11 +24,11 @@ export interface TableOptions_Table< */ _features: TFeatures /** - * The processing functions that are used to process the data by features. - * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_processingFns) + * The row model processing functions that are used to process the data by features. + * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_rowModelFns) * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ - _processingFns?: ProcessingFns> + _rowModelFns?: RowModelFns> /** * The row model options that you want to enable for the table. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_rowmodels) @@ -115,11 +115,11 @@ export interface Table_CoreProperties< */ _features: CoreTableFeatures & TFeatures /** - * The processing functions that are used to process the data by features. - * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_processingFns) + * The row model processing functions that are used to process the data by features. + * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_rowModelFns) * [Guide](https://tanstack.com/table/v8/docs/guide/tables) */ - _processingFns: ProcessingFns + _rowModelFns: RowModelFns /** * The row models that are enabled for the table. * [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_rowmodels) diff --git a/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts b/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts index aea4e3d401..c4bf5c4c3e 100644 --- a/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts +++ b/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts @@ -19,7 +19,7 @@ export function column_getAutoFilterFn< TData extends RowData, TValue extends CellData = CellData, >(column: Column) { - const filterFns = column.table._processingFns.filterFns as + const filterFns = column.table._rowModelFns.filterFns as | Record> | undefined @@ -60,7 +60,7 @@ export function column_getFilterFn< }, ): FilterFn | undefined { let filterFn = null - const filterFns = column.table._processingFns.filterFns as + const filterFns = column.table._rowModelFns.filterFns as | Record> | undefined filterFn = isFunction(column.columnDef.filterFn) diff --git a/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts b/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts index 6d7c368ff9..49de641981 100644 --- a/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts +++ b/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts @@ -98,7 +98,7 @@ export function column_getAutoAggregationFn< columnDef: Partial> }, ) { - const aggregationFns = column.table._processingFns.aggregationFns as + const aggregationFns = column.table._rowModelFns.aggregationFns as | Record> | undefined @@ -124,7 +124,7 @@ export function column_getAggregationFn< columnDef: Partial> }, ) { - const aggregationFns = column.table._processingFns.aggregationFns as + const aggregationFns = column.table._rowModelFns.aggregationFns as | Record> | undefined diff --git a/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts b/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts index 923d05ff05..4588723461 100644 --- a/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts +++ b/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts @@ -37,7 +37,7 @@ export function table_getGlobalFilterFn< table: Table_Internal, ): FilterFn | FilterFn | undefined { const { globalFilterFn: globalFilterFn } = table.options - const filterFns = table._processingFns.filterFns as + const filterFns = table._rowModelFns.filterFns as | Record> | undefined diff --git a/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts b/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts index b4aa08c66e..647a2ca876 100644 --- a/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts +++ b/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts @@ -42,7 +42,7 @@ export function column_getAutoSortingFn< >( column: Column_Internal, ): SortingFn { - const sortFns = column.table._processingFns.sortFns as + const sortFns = column.table._rowModelFns.sortFns as | Record> | undefined @@ -98,7 +98,7 @@ export function column_getSortingFn< >( column: Column_Internal, ): SortingFn { - const sortFns = column.table._processingFns.sortFns as + const sortFns = column.table._rowModelFns.sortFns as | Record> | undefined diff --git a/packages/table-core/src/helpers/tableHelper.ts b/packages/table-core/src/helpers/tableHelper.ts index 112099d523..a7f30e081f 100644 --- a/packages/table-core/src/helpers/tableHelper.ts +++ b/packages/table-core/src/helpers/tableHelper.ts @@ -37,7 +37,7 @@ export type TableHelper_Core< tableCreator: ( tableOptions: Omit< TableOptions, - '_features' | '_rowModels' | '_processingFns' + '_features' | '_rowModels' | '_rowModelFns' >, ) => Table } diff --git a/packages/table-core/src/index.ts b/packages/table-core/src/index.ts index 7fde9650b8..c8a9df984e 100755 --- a/packages/table-core/src/index.ts +++ b/packages/table-core/src/index.ts @@ -64,7 +64,7 @@ export * from './core/table/tablesFeature.types' export * from './core/table/tablesFeature.utils' /** - * ProcessingFns + * RowModelFns */ export * from './fns/aggregationFns' diff --git a/packages/table-core/src/types/ProcessingFns.ts b/packages/table-core/src/types/RowModelFns.ts similarity index 89% rename from packages/table-core/src/types/ProcessingFns.ts rename to packages/table-core/src/types/RowModelFns.ts index c4e3885c83..a950378d17 100644 --- a/packages/table-core/src/types/ProcessingFns.ts +++ b/packages/table-core/src/types/RowModelFns.ts @@ -4,12 +4,12 @@ import type { RowData, UnionToIntersection } from './type-utils' import type { TableFns_ColumnFiltering } from '../features/column-filtering/columnFilteringFeature.types' import type { TableFeatures } from './TableFeatures' -export interface ProcessingFns_Plugins {} +export interface RowModelFns_Plugins {} -export type ProcessingFns< +export type RowModelFns< TFeatures extends TableFeatures, TData extends RowData, -> = ProcessingFns_Plugins & +> = RowModelFns_Plugins & Partial< UnionToIntersection< | ('columnFilteringFeature' extends keyof TFeatures @@ -24,7 +24,7 @@ export type ProcessingFns< > > -export type ProcessingFns_All< +export type RowModelFns_All< TFeatures extends TableFeatures, TData extends RowData, > = Partial< diff --git a/packages/table-core/src/types/Table.ts b/packages/table-core/src/types/Table.ts index 68d4548022..d94c016b30 100644 --- a/packages/table-core/src/types/Table.ts +++ b/packages/table-core/src/types/Table.ts @@ -1,6 +1,6 @@ import type { Table_RowModels } from '../core/row-models/rowModelsFeature.types' import type { CachedRowModel_All, CreateRowModels_All } from './RowModel' -import type { ProcessingFns_All } from './ProcessingFns' +import type { RowModelFns_All } from './RowModelFns' import type { TableState_All } from './TableState' import type { RowData, UnionToIntersection } from './type-utils' import type { TableFeatures } from './TableFeatures' @@ -96,8 +96,8 @@ export type Table_Internal< TFeatures extends TableFeatures, TData extends RowData, > = Table & { - _processingFns: ProcessingFns_All _rowModels: CachedRowModel_All + _rowModelFns: RowModelFns_All options: TableOptions_All & { _rowModels?: CreateRowModels_All state?: TableState_All