diff --git a/_artifacts/domain_map.yaml b/_artifacts/domain_map.yaml index 09c32a45ed..6da3039d33 100644 --- a/_artifacts/domain_map.yaml +++ b/_artifacts/domain_map.yaml @@ -1,6 +1,6 @@ library: name: '@tanstack/table' - version: '9.0.0-beta.46' + version: '9.0.0-beta.47' repository: 'https://github.com/TanStack/table' homepage: 'https://tanstack.com/table' description: 'Headless, framework-agnostic data-grid state and row-processing primitives with tree-shakeable v9 features and framework adapters.' diff --git a/_artifacts/skill_tree.yaml b/_artifacts/skill_tree.yaml index 0fbfc47a27..763b62a543 100644 --- a/_artifacts/skill_tree.yaml +++ b/_artifacts/skill_tree.yaml @@ -1,6 +1,6 @@ library: name: '@tanstack/table' - version: '9.0.0-beta.46' + version: '9.0.0-beta.47' repository: 'https://github.com/TanStack/table' description: 'Headless data-grid state and row processing with tree-shakeable v9 features and framework adapters.' package_version_overrides: diff --git a/docs/framework/alpine/guide/column-filtering.md b/docs/framework/alpine/guide/column-filtering.md index b3400dfac0..d696fe9b87 100644 --- a/docs/framework/alpine/guide/column-filtering.md +++ b/docs/framework/alpine/guide/column-filtering.md @@ -20,14 +20,18 @@ import { columnFilteringFeature, createFilteredRowModel, createTable, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, tableFeatures, } from '@tanstack/alpine-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -39,6 +43,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Alpine) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -86,21 +92,25 @@ const table = createTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```ts import { columnFilteringFeature, createFilteredRowModel, createTable, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, tableFeatures, } from '@tanstack/alpine-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -227,28 +237,34 @@ const table = createTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -282,7 +298,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -298,7 +314,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -321,34 +338,48 @@ const table = createTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Wiring up the filter UI TanStack Table will not add filter inputs to your table. Add them yourself on real elements (Alpine does not initialize directives inside content set with `x-html`). Read the current value with `column.getFilterValue()` and write it with `column.setFilterValue()`. Use `column.getCanFilter()` to decide whether to render an input. @@ -461,7 +492,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -486,7 +520,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ diff --git a/docs/framework/alpine/guide/fuzzy-filtering.md b/docs/framework/alpine/guide/fuzzy-filtering.md index ef63d72a10..9f32f9a56b 100644 --- a/docs/framework/alpine/guide/fuzzy-filtering.md +++ b/docs/framework/alpine/guide/fuzzy-filtering.md @@ -20,10 +20,8 @@ import { createFilteredRowModel, createSortedRowModel, createTable, - filterFns, globalFilteringFeature, rowSortingFeature, - sortFns, tableFeatures, } from '@tanstack/alpine-table' @@ -33,8 +31,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, }) const table = createTable({ @@ -46,6 +44,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Alpine) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -124,8 +124,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -140,11 +140,9 @@ import { createFilteredRowModel, createSortedRowModel, createTable, - filterFns, globalFilteringFeature, metaHelper, rowSortingFeature, - sortFns, tableFeatures, } from '@tanstack/alpine-table' @@ -154,8 +152,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -171,7 +169,7 @@ const table = createTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot on `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```ts const column = [ @@ -194,7 +192,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```ts import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/alpine-table' +import { sortFn_alphanumeric } from '@tanstack/alpine-table' import type { SortFn } from '@tanstack/alpine-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -209,7 +207,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -228,4 +226,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips that step. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips that step. diff --git a/docs/framework/alpine/guide/global-filtering.md b/docs/framework/alpine/guide/global-filtering.md index b34e7219a4..81ec204372 100644 --- a/docs/framework/alpine/guide/global-filtering.md +++ b/docs/framework/alpine/guide/global-filtering.md @@ -20,7 +20,7 @@ import { columnFilteringFeature, createFilteredRowModel, createTable, - filterFns, + filterFn_includesString, globalFilteringFeature, tableFeatures, } from '@tanstack/alpine-table' @@ -29,7 +29,7 @@ const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -41,6 +41,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Alpine) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -103,7 +105,7 @@ import { columnFilteringFeature, createFilteredRowModel, createTable, - filterFns, + filterFn_includesString, globalFilteringFeature, tableFeatures, } from '@tanstack/alpine-table' @@ -112,7 +114,7 @@ const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -123,7 +125,7 @@ const table = createTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot on `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```ts const table = createTable({ diff --git a/docs/framework/alpine/guide/grouping.md b/docs/framework/alpine/guide/grouping.md index 831f82678a..5a3f78fd6f 100644 --- a/docs/framework/alpine/guide/grouping.md +++ b/docs/framework/alpine/guide/grouping.md @@ -16,7 +16,7 @@ Here's how you set up your table to use grouping features. Adding the grouping f ```ts import { - aggregationFns, + aggregationFn_sum, columnGroupingFeature, createGroupedRowModel, createTable, @@ -26,7 +26,7 @@ import { const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -38,6 +38,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Alpine) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -52,7 +54,7 @@ To use the grouping feature, add the `columnGroupingFeature` and the `groupedRow ```ts import { - aggregationFns, + aggregationFn_sum, columnGroupingFeature, createGroupedRowModel, createTable, @@ -62,7 +64,7 @@ import { const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -80,7 +82,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -124,7 +126,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -137,6 +139,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -147,7 +151,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -170,6 +174,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). The slot is the registry; no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/alpine/guide/sorting.md b/docs/framework/alpine/guide/sorting.md index 37627f587a..be332c305e 100644 --- a/docs/framework/alpine/guide/sorting.md +++ b/docs/framework/alpine/guide/sorting.md @@ -19,14 +19,20 @@ import { createSortedRowModel, createTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const table = createTable({ @@ -38,6 +44,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Alpine) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -181,21 +189,27 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```ts import { createSortedRowModel, createTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const table = createTable({ @@ -280,7 +294,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn: (rowA, rowB, columnId) => rowA.original[columnId] > rowB.original[columnId] ? 1 @@ -301,6 +316,46 @@ const table = createTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). The slot is the registry; no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/angular/guide/column-filtering.md b/docs/framework/angular/guide/column-filtering.md index 809acab726..d278440be9 100644 --- a/docs/framework/angular/guide/column-filtering.md +++ b/docs/framework/angular/guide/column-filtering.md @@ -21,13 +21,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/angular-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) export class App { @@ -41,6 +45,8 @@ export class App { } ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Angular) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -86,7 +92,7 @@ readonly table = injectTable(() => ({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```ts import { @@ -94,13 +100,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/angular-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) readonly table = injectTable(() => ({ @@ -216,28 +226,34 @@ readonly table = injectTable(() => ({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -271,7 +287,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -287,7 +303,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -308,34 +325,48 @@ readonly table = injectTable(() => ({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -380,7 +411,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) readonly table = injectTable(() => ({ @@ -403,7 +437,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) readonly table = injectTable(() => ({ diff --git a/docs/framework/angular/guide/fuzzy-filtering.md b/docs/framework/angular/guide/fuzzy-filtering.md index e7e76ac709..17b9662255 100644 --- a/docs/framework/angular/guide/fuzzy-filtering.md +++ b/docs/framework/angular/guide/fuzzy-filtering.md @@ -22,8 +22,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/angular-table' import type { RankingInfo } from '@tanstack/match-sorter-utils' @@ -38,8 +36,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, // fuzzyFilter defined below - sortFns: { ...sortFns, fuzzy: fuzzySort }, // fuzzySort defined below + filterFns: { fuzzy: fuzzyFilter }, // fuzzyFilter defined below + sortFns: { fuzzy: fuzzySort }, // fuzzySort defined below filterMeta: metaHelper(), }) @@ -54,6 +52,8 @@ export class App { } ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Angular) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -113,7 +113,7 @@ const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) ``` @@ -133,8 +133,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/angular-table' @@ -144,8 +142,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -182,7 +180,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/angular-table' +import { sortFn_alphanumeric } from '@tanstack/angular-table' import type { SortFn } from '@tanstack/angular-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -197,7 +195,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` diff --git a/docs/framework/angular/guide/global-filtering.md b/docs/framework/angular/guide/global-filtering.md index 25cff7782f..ae01fd167e 100644 --- a/docs/framework/angular/guide/global-filtering.md +++ b/docs/framework/angular/guide/global-filtering.md @@ -21,14 +21,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/angular-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) export class App { @@ -42,6 +42,8 @@ export class App { } ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Angular) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -101,14 +103,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/angular-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) readonly table = injectTable(() => ({ @@ -119,7 +121,7 @@ readonly table = injectTable(() => ({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot of `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot of `tableFeatures`, or a filter function passed directly. ```ts readonly table = injectTable(() => ({ diff --git a/docs/framework/angular/guide/grouping.md b/docs/framework/angular/guide/grouping.md index 389bc817a7..f190cecd58 100644 --- a/docs/framework/angular/guide/grouping.md +++ b/docs/framework/angular/guide/grouping.md @@ -19,13 +19,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/angular-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) export class App { @@ -39,6 +39,8 @@ export class App { } ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Angular) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -57,13 +59,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/angular-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) readonly table = injectTable(() => ({ @@ -81,7 +83,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) readonly table = injectTable(() => ({ @@ -125,7 +127,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -138,6 +140,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -148,7 +152,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -171,6 +175,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/angular/guide/migrating.md b/docs/framework/angular/guide/migrating.md index 909dc603a0..622aec7083 100644 --- a/docs/framework/angular/guide/migrating.md +++ b/docs/framework/angular/guide/migrating.md @@ -322,6 +322,34 @@ const v9Table = injectTable(() => ({ })) ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```ts +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/angular-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/angular-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -858,7 +886,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/angular/guide/sorting.md b/docs/framework/angular/guide/sorting.md index 9fee9d1f88..d2c031c814 100644 --- a/docs/framework/angular/guide/sorting.md +++ b/docs/framework/angular/guide/sorting.md @@ -19,13 +19,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/angular-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) export class App { @@ -39,6 +45,8 @@ export class App { } ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Angular) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -179,7 +187,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```ts import { @@ -187,13 +195,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/angular-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) readonly table = injectTable(() => ({ @@ -257,7 +271,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn, }, }) @@ -297,6 +312,46 @@ readonly table = injectTable(() => ({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/ember/guide/column-filtering.md b/docs/framework/ember/guide/column-filtering.md index 83d62558de..b11ac73243 100644 --- a/docs/framework/ember/guide/column-filtering.md +++ b/docs/framework/ember/guide/column-filtering.md @@ -20,13 +20,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/ember-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) // inside your component class @@ -37,6 +41,8 @@ table = useTable(() => ({ })) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Ember) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -82,7 +88,7 @@ table = useTable(() => ({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```gts import { @@ -90,13 +96,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/ember-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) table = useTable(() => ({ @@ -214,28 +224,34 @@ table = useTable(() => ({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -267,7 +283,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn, startsWith: startsWithFilterFn, // defined elsewhere }, @@ -308,34 +325,48 @@ table = useTable(() => ({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -379,7 +410,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) table = useTable(() => ({ @@ -402,7 +436,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) table = useTable(() => ({ diff --git a/docs/framework/ember/guide/fuzzy-filtering.md b/docs/framework/ember/guide/fuzzy-filtering.md index 6a00efefce..be4c21e1bb 100644 --- a/docs/framework/ember/guide/fuzzy-filtering.md +++ b/docs/framework/ember/guide/fuzzy-filtering.md @@ -21,8 +21,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/ember-table' @@ -32,8 +30,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -45,6 +43,8 @@ table = useTable(() => ({ })) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Ember) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -104,8 +104,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -125,8 +125,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/ember-table' @@ -136,8 +134,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -152,7 +150,7 @@ table = useTable(() => ({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot on `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```ts const columns = columnHelper.columns([ @@ -174,7 +172,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/ember-table' +import { sortFn_alphanumeric } from '@tanstack/ember-table' import type { SortFn } from '@tanstack/ember-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -188,7 +186,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` diff --git a/docs/framework/ember/guide/global-filtering.md b/docs/framework/ember/guide/global-filtering.md index e714e90616..773f78b33e 100644 --- a/docs/framework/ember/guide/global-filtering.md +++ b/docs/framework/ember/guide/global-filtering.md @@ -20,14 +20,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/ember-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) // inside your component class @@ -38,6 +38,8 @@ table = useTable(() => ({ })) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Ember) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -100,14 +102,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/ember-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) table = useTable(() => ({ @@ -118,7 +120,7 @@ table = useTable(() => ({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot on `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```gts table = useTable(() => ({ diff --git a/docs/framework/ember/guide/grouping.md b/docs/framework/ember/guide/grouping.md index aedebdc9a6..c0ad3d930b 100644 --- a/docs/framework/ember/guide/grouping.md +++ b/docs/framework/ember/guide/grouping.md @@ -18,13 +18,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/ember-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable(() => ({ @@ -34,6 +34,8 @@ const table = useTable(() => ({ })) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Ember) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -52,13 +54,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/ember-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable(() => ({ @@ -76,7 +78,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable(() => ({ @@ -120,7 +122,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -133,6 +135,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -146,7 +150,7 @@ const myCustomAggregation = (columnId, leafRows, childRows) => { const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns: { ...aggregationFns, myCustomAggregation }, + aggregationFns: { sum: aggregationFn_sum, myCustomAggregation }, }) const table = useTable(() => ({ @@ -165,6 +169,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/ember/guide/sorting.md b/docs/framework/ember/guide/sorting.md index aa6be44bea..e7aad18711 100644 --- a/docs/framework/ember/guide/sorting.md +++ b/docs/framework/ember/guide/sorting.md @@ -18,13 +18,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/ember-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) // inside your component class @@ -35,6 +41,8 @@ table = useTable(() => ({ })) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Ember) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -176,7 +184,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```gts import { @@ -184,13 +192,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/ember-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) table = useTable(() => ({ @@ -257,7 +271,11 @@ const myCustomSortFn: SortFn = ( const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns: { ...sortFns, myCustomSortFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + myCustomSortFn, + }, }) const columns = columnHelper.columns([ @@ -291,6 +309,46 @@ table = useTable(() => ({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/lit/guide/column-filtering.md b/docs/framework/lit/guide/column-filtering.md index e6653df63c..6bdfa07d87 100644 --- a/docs/framework/lit/guide/column-filtering.md +++ b/docs/framework/lit/guide/column-filtering.md @@ -22,13 +22,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/lit-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) @customElement('my-table') @@ -50,6 +54,8 @@ class MyTable extends LitElement { } ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Lit) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -95,7 +101,7 @@ const table = this.tableController.table({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` to your features and the `filteredRowModel` factory as a slot on `tableFeatures`. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` to your features and the `filteredRowModel` factory as a slot on `tableFeatures`. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```ts import { @@ -103,13 +109,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/lit-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = this.tableController.table({ @@ -228,18 +238,24 @@ const table = this.tableController.table({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) @@ -299,7 +315,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -320,34 +337,48 @@ const table = this.tableController.table({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -392,7 +423,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = this.tableController.table({ @@ -415,7 +449,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = this.tableController.table({ diff --git a/docs/framework/lit/guide/fuzzy-filtering.md b/docs/framework/lit/guide/fuzzy-filtering.md index a1eb9ccf40..a315222ff3 100644 --- a/docs/framework/lit/guide/fuzzy-filtering.md +++ b/docs/framework/lit/guide/fuzzy-filtering.md @@ -23,8 +23,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, } from '@tanstack/lit-table' const features = tableFeatures({ @@ -33,8 +31,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, }) @customElement('my-table') @@ -56,6 +54,8 @@ class MyTable extends LitElement { } ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Lit) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -121,8 +121,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -140,8 +140,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/lit-table' @@ -151,8 +149,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -189,7 +187,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/lit-table' +import { sortFn_alphanumeric } from '@tanstack/lit-table' import type { SortFn } from '@tanstack/lit-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -204,7 +202,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -223,4 +221,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips registration entirely. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips registration entirely. diff --git a/docs/framework/lit/guide/global-filtering.md b/docs/framework/lit/guide/global-filtering.md index 59a35e047b..b7ca4fe7e1 100644 --- a/docs/framework/lit/guide/global-filtering.md +++ b/docs/framework/lit/guide/global-filtering.md @@ -22,14 +22,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/lit-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) @customElement('my-table') @@ -51,6 +51,8 @@ class MyTable extends LitElement { } ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Lit) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -113,14 +115,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/lit-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = this.tableController.table({ @@ -131,7 +133,7 @@ const table = this.tableController.table({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot on `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```ts const table = this.tableController.table({ diff --git a/docs/framework/lit/guide/grouping.md b/docs/framework/lit/guide/grouping.md index 35b4df9293..56680e1fba 100644 --- a/docs/framework/lit/guide/grouping.md +++ b/docs/framework/lit/guide/grouping.md @@ -20,13 +20,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/lit-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) @customElement('my-table') @@ -48,6 +48,8 @@ class MyTable extends LitElement { } ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Lit) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -66,13 +68,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/lit-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = this.tableController.table({ @@ -90,7 +92,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = this.tableController.table({ @@ -134,7 +136,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -147,6 +149,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -157,7 +161,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -180,6 +184,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** String references like `aggregationFn: 'myCustomAggregation'` are automatically typed when the function is registered in the `aggregationFns` slot on `tableFeatures`. The registry slot replaces the old `declare module` augmentation approach. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/lit/guide/migrating.md b/docs/framework/lit/guide/migrating.md index 1985e972fa..3ce56b03c0 100644 --- a/docs/framework/lit/guide/migrating.md +++ b/docs/framework/lit/guide/migrating.md @@ -304,6 +304,34 @@ protected render() { } ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```ts +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/lit-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/lit-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -724,7 +752,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/lit/guide/sorting.md b/docs/framework/lit/guide/sorting.md index b59e3e65cf..3d56139453 100644 --- a/docs/framework/lit/guide/sorting.md +++ b/docs/framework/lit/guide/sorting.md @@ -21,13 +21,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/lit-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) @customElement('my-table') @@ -49,6 +55,8 @@ class MyTable extends LitElement { } ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Lit) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -198,7 +206,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` to your features and the `sortedRowModel` to your row models. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` to your features and the `sortedRowModel` to your row models. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```ts import { @@ -206,13 +214,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/lit-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = this.tableController.table({ @@ -295,7 +309,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn: (rowA, rowB, columnId) => rowA.original[columnId] > rowB.original[columnId] ? 1 @@ -314,6 +329,46 @@ const table = this.tableController.table({ > **TypeScript Note:** String references like `sortFn: 'myCustomSortFn'` are automatically typed when the function is registered in the `sortFns` slot on `tableFeatures`. The registry slot replaces the old `declare module` augmentation approach. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/preact/guide/column-filtering.md b/docs/framework/preact/guide/column-filtering.md index 2babd549b6..f20c6af5fd 100644 --- a/docs/framework/preact/guide/column-filtering.md +++ b/docs/framework/preact/guide/column-filtering.md @@ -20,13 +20,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/preact-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -36,6 +40,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Preact) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -81,7 +87,7 @@ const table = useTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature`, the `filteredRowModel` factory, and `filterFns` to your `tableFeatures` call. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature`, the `filteredRowModel` factory, and a `filterFns` registry to your `tableFeatures` call. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```tsx import { @@ -89,13 +95,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/preact-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -206,28 +216,34 @@ const table = useTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -261,7 +277,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -285,7 +301,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn, startsWith: startsWithFilterFn, // defined elsewhere }, @@ -304,34 +321,48 @@ const table = useTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```tsx -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```tsx +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -376,7 +407,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -399,7 +433,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ diff --git a/docs/framework/preact/guide/fuzzy-filtering.md b/docs/framework/preact/guide/fuzzy-filtering.md index 3b0263f290..d47350761a 100644 --- a/docs/framework/preact/guide/fuzzy-filtering.md +++ b/docs/framework/preact/guide/fuzzy-filtering.md @@ -21,8 +21,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/preact-table' import type { RankingInfo } from '@tanstack/match-sorter-utils' @@ -37,8 +35,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -49,6 +47,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Preact) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -114,8 +114,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -135,8 +135,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/preact-table' @@ -146,8 +144,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -161,7 +159,7 @@ const table = useTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot on `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```typescript const column = [ @@ -184,7 +182,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/preact-table' +import { sortFn_alphanumeric } from '@tanstack/preact-table' import type { SortFn } from '@tanstack/preact-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -199,7 +197,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -218,4 +216,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would require you to also add it to the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips registration. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would require you to also add it to the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips registration. diff --git a/docs/framework/preact/guide/global-filtering.md b/docs/framework/preact/guide/global-filtering.md index 0e30a26a59..2df81292c5 100644 --- a/docs/framework/preact/guide/global-filtering.md +++ b/docs/framework/preact/guide/global-filtering.md @@ -20,14 +20,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/preact-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -37,6 +37,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Preact) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -99,14 +101,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/preact-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -117,7 +119,7 @@ const table = useTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the registry passed to `createFilteredRowModel`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```tsx const table = useTable({ diff --git a/docs/framework/preact/guide/grouping.md b/docs/framework/preact/guide/grouping.md index 734de2e3df..26a1ab8418 100644 --- a/docs/framework/preact/guide/grouping.md +++ b/docs/framework/preact/guide/grouping.md @@ -18,13 +18,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/preact-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -34,6 +34,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Preact) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -52,13 +54,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/preact-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -76,7 +78,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -120,7 +122,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -133,6 +135,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -151,7 +155,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation, }, }) @@ -172,6 +176,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). TypeScript infers the registered names from the slot automatically. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```tsx +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/preact/guide/migrating.md b/docs/framework/preact/guide/migrating.md index ec7e766277..b3c131815d 100644 --- a/docs/framework/preact/guide/migrating.md +++ b/docs/framework/preact/guide/migrating.md @@ -282,6 +282,34 @@ const table = useTable({ }) ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```tsx +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/preact-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/preact-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -713,7 +741,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/preact/guide/sorting.md b/docs/framework/preact/guide/sorting.md index 70c09d7f63..e3fc549a37 100644 --- a/docs/framework/preact/guide/sorting.md +++ b/docs/framework/preact/guide/sorting.md @@ -18,13 +18,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/preact-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -34,6 +40,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Preact) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -168,7 +176,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your `tableFeatures` call. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your `tableFeatures` call. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```tsx import { @@ -176,13 +184,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/preact-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -276,7 +290,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn, }, }) @@ -290,6 +305,46 @@ const table = useTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). TypeScript will infer the registered names from the slot automatically. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```tsx +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```tsx +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/react/guide/column-filtering.md b/docs/framework/react/guide/column-filtering.md index e43dd90a23..15b95084e7 100644 --- a/docs/framework/react/guide/column-filtering.md +++ b/docs/framework/react/guide/column-filtering.md @@ -20,13 +20,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/react-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -36,6 +40,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (React) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -81,7 +87,7 @@ const table = useTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```tsx import { @@ -89,13 +95,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/react-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -206,28 +216,34 @@ const table = useTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -259,7 +275,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn, startsWith: startsWithFilterFn, // defined elsewhere }, @@ -304,34 +321,48 @@ const table = useTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```tsx -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```tsx +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -376,7 +407,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -399,7 +433,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ diff --git a/docs/framework/react/guide/fuzzy-filtering.md b/docs/framework/react/guide/fuzzy-filtering.md index c90a553a17..1bff5b8a64 100644 --- a/docs/framework/react/guide/fuzzy-filtering.md +++ b/docs/framework/react/guide/fuzzy-filtering.md @@ -21,8 +21,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/react-table' @@ -32,8 +30,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -44,6 +42,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (React) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -103,8 +103,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -124,8 +124,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/react-table' @@ -135,8 +133,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -150,7 +148,7 @@ const table = useTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot on `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```typescript const column = [ @@ -173,7 +171,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/react-table' +import { sortFn_alphanumeric } from '@tanstack/react-table' import type { SortFn } from '@tanstack/react-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -188,7 +186,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` diff --git a/docs/framework/react/guide/global-filtering.md b/docs/framework/react/guide/global-filtering.md index 25edd62e29..2b9b6e08fb 100644 --- a/docs/framework/react/guide/global-filtering.md +++ b/docs/framework/react/guide/global-filtering.md @@ -20,14 +20,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/react-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -37,6 +37,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (React) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -99,14 +101,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/react-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -117,7 +119,7 @@ const table = useTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot on `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```tsx const table = useTable({ diff --git a/docs/framework/react/guide/grouping.md b/docs/framework/react/guide/grouping.md index 50d221c22d..17896f3f22 100644 --- a/docs/framework/react/guide/grouping.md +++ b/docs/framework/react/guide/grouping.md @@ -18,13 +18,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/react-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -34,6 +34,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (React) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -52,13 +54,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/react-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -76,7 +78,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -120,7 +122,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -133,6 +135,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -146,7 +150,7 @@ const myCustomAggregation = (columnId, leafRows, childRows) => { const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns: { ...aggregationFns, myCustomAggregation }, + aggregationFns: { sum: aggregationFn_sum, myCustomAggregation }, }) const table = useTable({ @@ -165,6 +169,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```tsx +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/react/guide/migrating.md b/docs/framework/react/guide/migrating.md index 173d25b63f..8f081fe47e 100644 --- a/docs/framework/react/guide/migrating.md +++ b/docs/framework/react/guide/migrating.md @@ -279,6 +279,34 @@ const table = useTable({ }) ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```tsx +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/react-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/react-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -1068,7 +1096,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/react/guide/sorting.md b/docs/framework/react/guide/sorting.md index 0023c0d909..946f30ae2c 100644 --- a/docs/framework/react/guide/sorting.md +++ b/docs/framework/react/guide/sorting.md @@ -18,13 +18,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/react-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -34,6 +40,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (React) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -168,7 +176,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```tsx import { @@ -176,13 +184,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/react-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -249,7 +263,11 @@ const myCustomSortFn: SortFn = ( const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns: { ...sortFns, myCustomSortFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + myCustomSortFn, + }, }) const columns = [ @@ -287,6 +305,46 @@ const table = useTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```tsx +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```tsx +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/solid/guide/column-filtering.md b/docs/framework/solid/guide/column-filtering.md index dd9758b1d2..2a0c24e7a8 100644 --- a/docs/framework/solid/guide/column-filtering.md +++ b/docs/framework/solid/guide/column-filtering.md @@ -22,13 +22,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/solid-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -40,6 +44,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Solid) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -85,7 +91,7 @@ const table = createTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` and the `filteredRowModel` factory to your features. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```tsx import { @@ -93,13 +99,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/solid-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -211,28 +221,34 @@ const table = createTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -266,7 +282,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -282,7 +298,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -303,34 +320,48 @@ const table = createTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```tsx -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```tsx +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -375,7 +406,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -398,7 +432,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ diff --git a/docs/framework/solid/guide/fuzzy-filtering.md b/docs/framework/solid/guide/fuzzy-filtering.md index fc78046ac0..1fc7326768 100644 --- a/docs/framework/solid/guide/fuzzy-filtering.md +++ b/docs/framework/solid/guide/fuzzy-filtering.md @@ -23,8 +23,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, } from '@tanstack/solid-table' const features = tableFeatures({ @@ -33,8 +31,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, }) const table = createTable({ @@ -46,6 +44,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Solid) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -120,8 +120,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -140,8 +140,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, } from '@tanstack/solid-table' const features = tableFeatures({ @@ -150,8 +148,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -165,7 +163,7 @@ const table = createTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot on `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```typescript const column = [ @@ -188,7 +186,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/solid-table' +import { sortFn_alphanumeric } from '@tanstack/solid-table' import type { SortFn } from '@tanstack/solid-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -203,7 +201,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -222,4 +220,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips that step. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot on `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips that step. diff --git a/docs/framework/solid/guide/global-filtering.md b/docs/framework/solid/guide/global-filtering.md index 5088a5b4e9..a8be7760c0 100644 --- a/docs/framework/solid/guide/global-filtering.md +++ b/docs/framework/solid/guide/global-filtering.md @@ -22,14 +22,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/solid-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -41,6 +41,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Solid) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -103,14 +105,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/solid-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -121,7 +123,7 @@ const table = createTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot on `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot on `tableFeatures`, or a filter function passed directly. ```tsx const table = createTable({ diff --git a/docs/framework/solid/guide/grouping.md b/docs/framework/solid/guide/grouping.md index 4974ac1db7..14831f23d8 100644 --- a/docs/framework/solid/guide/grouping.md +++ b/docs/framework/solid/guide/grouping.md @@ -20,13 +20,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/solid-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -38,6 +38,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Solid) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -56,13 +58,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/solid-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -80,7 +82,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -124,7 +126,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -137,6 +139,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -147,7 +151,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -170,6 +174,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot on `tableFeatures` (as shown above). The slot is the registry; no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```tsx +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/solid/guide/migrating.md b/docs/framework/solid/guide/migrating.md index f8418299a5..bf104da27d 100644 --- a/docs/framework/solid/guide/migrating.md +++ b/docs/framework/solid/guide/migrating.md @@ -284,6 +284,34 @@ const table = createTable({ }) ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```tsx +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/solid-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/solid-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -679,7 +707,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/solid/guide/sorting.md b/docs/framework/solid/guide/sorting.md index f2217b6a79..2608da3eea 100644 --- a/docs/framework/solid/guide/sorting.md +++ b/docs/framework/solid/guide/sorting.md @@ -20,13 +20,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/solid-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = createTable({ @@ -38,6 +44,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Solid) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -173,7 +181,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` and the `sortedRowModel` factory to your features. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```tsx import { @@ -181,13 +189,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/solid-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = createTable({ @@ -270,7 +284,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn: (rowA, rowB, columnId) => rowA.original[columnId] > rowB.original[columnId] ? 1 @@ -289,6 +304,46 @@ const table = createTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot on `tableFeatures` (as shown above). The slot is the registry; no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```tsx +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```tsx +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/svelte/guide/column-filtering.md b/docs/framework/svelte/guide/column-filtering.md index 24eb700700..6e60b0a7e2 100644 --- a/docs/framework/svelte/guide/column-filtering.md +++ b/docs/framework/svelte/guide/column-filtering.md @@ -22,13 +22,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/svelte-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -40,6 +44,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Svelte) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -85,7 +91,7 @@ const table = createTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature` to your features and the `filteredRowModel` to your row models. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature` to your features and the `filteredRowModel` to your row models. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```ts import { @@ -93,13 +99,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/svelte-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -220,28 +230,34 @@ const table = createTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -275,7 +291,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -291,7 +307,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -312,34 +329,48 @@ const table = createTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -384,7 +415,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ @@ -407,7 +441,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = createTable({ diff --git a/docs/framework/svelte/guide/fuzzy-filtering.md b/docs/framework/svelte/guide/fuzzy-filtering.md index afcbae07e9..926e7ab23b 100644 --- a/docs/framework/svelte/guide/fuzzy-filtering.md +++ b/docs/framework/svelte/guide/fuzzy-filtering.md @@ -23,8 +23,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/svelte-table' @@ -34,8 +32,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -48,6 +46,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Svelte) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -109,8 +109,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` @@ -128,8 +128,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/svelte-table' @@ -139,8 +137,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -154,7 +152,7 @@ const table = createTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, pass your fuzzy filter function to `createFilteredRowModel` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot of `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```typescript const column = [ @@ -177,7 +175,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/svelte-table' +import { sortFn_alphanumeric } from '@tanstack/svelte-table' import type { SortFn } from '@tanstack/svelte-table' const fuzzySort: SortFn = (rowA, rowB, columnId) => { @@ -192,7 +190,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -211,4 +209,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot of `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips registration. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also registered the function in the `sortFns` slot of `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips registration. diff --git a/docs/framework/svelte/guide/global-filtering.md b/docs/framework/svelte/guide/global-filtering.md index 30e163ff02..1eeda63345 100644 --- a/docs/framework/svelte/guide/global-filtering.md +++ b/docs/framework/svelte/guide/global-filtering.md @@ -22,14 +22,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/svelte-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -41,6 +41,8 @@ const table = createTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Svelte) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -103,14 +105,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/svelte-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = createTable({ @@ -121,7 +123,7 @@ const table = createTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the `filterFns` slot of `tableFeatures`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot of `tableFeatures`, or a filter function passed directly. ```ts const table = createTable({ diff --git a/docs/framework/svelte/guide/grouping.md b/docs/framework/svelte/guide/grouping.md index 47030b107e..0b51c44f14 100644 --- a/docs/framework/svelte/guide/grouping.md +++ b/docs/framework/svelte/guide/grouping.md @@ -20,13 +20,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/svelte-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -38,6 +38,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Svelte) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -56,13 +58,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/svelte-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -80,7 +82,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = createTable({ @@ -124,7 +126,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -137,6 +139,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -147,7 +151,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -170,6 +174,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot of `tableFeatures({...})` as shown above. TypeScript infers the available aggregation function names from that registry. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/svelte/guide/migrating.md b/docs/framework/svelte/guide/migrating.md index 2a43cec883..433e292a1b 100644 --- a/docs/framework/svelte/guide/migrating.md +++ b/docs/framework/svelte/guide/migrating.md @@ -303,6 +303,34 @@ Function registries move to slots too: pass `filterFns`, `sortFns`, and `aggrega ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```ts +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/svelte-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/svelte-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -757,7 +785,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/svelte/guide/sorting.md b/docs/framework/svelte/guide/sorting.md index b3aad6846c..1ce517a60f 100644 --- a/docs/framework/svelte/guide/sorting.md +++ b/docs/framework/svelte/guide/sorting.md @@ -20,13 +20,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/svelte-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = createTable({ @@ -38,6 +44,8 @@ const table = createTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Svelte) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -182,7 +190,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature` to your features and the `sortedRowModel` to your row models. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature` to your features and the `sortedRowModel` to your row models. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```ts import { @@ -190,13 +198,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/svelte-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = createTable({ @@ -279,7 +293,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn: (rowA, rowB, columnId) => rowA.original[columnId] > rowB.original[columnId] ? 1 @@ -298,6 +313,46 @@ const table = createTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot of `tableFeatures({...})` as shown above. TypeScript infers the available sort function names from that registry. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/framework/vue/guide/column-filtering.md b/docs/framework/vue/guide/column-filtering.md index 170708d282..e7f7f7a29c 100644 --- a/docs/framework/vue/guide/column-filtering.md +++ b/docs/framework/vue/guide/column-filtering.md @@ -22,13 +22,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/vue-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -38,6 +42,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter functions this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `filterFn` column option with no registration at all. + ## Column Filtering (Vue) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -83,7 +89,7 @@ const table = useTable({ ### Client-Side Filtering -If you are using the built-in client-side filtering features, add the `columnFilteringFeature`, `filteredRowModel`, and `filterFns` to your `tableFeatures` call. Import `createFilteredRowModel` and `filterFns` from TanStack Table: +If you are using the built-in client-side filtering features, add the `columnFilteringFeature`, `filteredRowModel`, and `filterFns` to your `tableFeatures` call. Import `createFilteredRowModel` and the filter functions you need from TanStack Table: ```ts import { @@ -91,13 +97,17 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, } from '@tanstack/vue-table' const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -216,28 +226,34 @@ const table = useTable({ Each column can have its own unique filtering logic. Choose from any of the filter functions that are provided by TanStack Table, or create your own. -By default there are 12 built-in filter functions to choose from: +By default there are 18 built-in filter functions to choose from: - `includesString` - Case-insensitive string inclusion - `includesStringSensitive` - Case-sensitive string inclusion +- `startsWith` - Case-insensitive string prefix match +- `endsWith` - Case-insensitive string suffix match - `equalsString` - Case-insensitive string equality +- `equalsStringSensitive` - Case-sensitive string equality - `equals` - Strict equality `===` - `weakEquals` - Weak equality `==` +- `empty` - The row's value is nullish or whitespace-only (the filter value is an on/off flag) +- `notEmpty` - The row's value is not nullish or whitespace-only (the filter value is an on/off flag) - `arrIncludes` - The row's array (or string) value includes at least one of the filter values - `arrIncludesAll` - The row's array value includes every filter value - `arrIncludesSome` - The row's array value includes at least one of the filter values - `arrHas` - The row's scalar value equals at least one of the filter values - `inNumberRange` - Inclusive `[min, max]` number range (endpoints normalized and swapped if reversed) +- `inDateRange` - Inclusive `[min, max]` date range accepting `Date` objects, timestamps, or date strings (blank endpoints are open-ended) - `between` - Exclusive min/max range (blank endpoints are open-ended) - `betweenInclusive` - Inclusive min/max range (blank endpoints are open-ended) -You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the filter function registry that you pass to `createFilteredRowModel`. +You can also define your own custom filter functions, either inline as the `filterFn` column option, or by name in the `filterFns` registry slot on `tableFeatures`. #### Custom Filter Functions > **Note:** These filter functions only run during client-side filtering. -Whether you register a custom filter function in the registry passed to `createFilteredRowModel` or pass it directly as a `filterFn` column option, it should have the following signature: +Whether you register a custom filter function in the `filterFns` slot on `tableFeatures` or pass it directly as a `filterFn` column option, it should have the following signature: ```ts const myCustomFilterFn: FilterFn = ( @@ -271,7 +287,7 @@ const columns = [ { header: () => 'Birthday', accessorKey: 'birthday', - filterFn: 'myCustomFilterFn', // reference a custom filter function registered with createFilteredRowModel + filterFn: 'myCustomFilterFn', // reference a custom filter function registered in features }, { header: () => 'Profile', @@ -287,7 +303,8 @@ const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { - ...filterFns, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, myCustomFilterFn: (row, columnId, filterValue) => { return // true or false based on your custom logic }, @@ -308,34 +325,48 @@ const table = useTable({ You can attach a few other properties to filter functions to customize their behavior: -- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. +- `filterFn.resolveFilterValue` - This optional "hanging" method on any given `filterFn` allows the filter function to transform/sanitize/format the filter value before it is passed to the filter function. The table applies it once per filter (not once per row), so it is also the right place for expensive preparation work. + +- `filterFn.resolveDataValue` - This optional "hanging" method normalizes each row's value before it is compared against the filter value. It is honored by every filter function built with the `constructFilterFn` helper, which includes all built-in filter functions. - `filterFn.autoRemove` - This optional "hanging" method on any given `filterFn` is passed a filter value and expected to return `true` if the filter value should be removed from the filter state. eg. Some boolean-style filters may want to remove the filter value from the table state if the filter value is set to `false`. +The `constructFilterFn` helper builds a filter function from a value-level comparator plus those optional resolvers: + ```ts -const startsWithFilterFn = < - TFeatures extends TableFeatures, - TData extends RowData, ->( - row: Row, - columnId: string, - filterValue: string, // resolveFilterValue below transforms the raw value to a string -) => - row - .getValue(columnId) - .toString() - .toLowerCase() - .trim() - .startsWith(filterValue) // toString, toLowerCase, and trim the filter value in `resolveFilterValue` +const startsWithFilterFn = constructFilterFn({ + // compare the (resolved) row value against the (resolved) filter value + filter: (dataValue, filterValue) => + Boolean(dataValue?.startsWith(filterValue)), + // normalize the filter value once, before any rows are tested + resolveFilterValue: (value) => String(value).toLowerCase().trim(), + // normalize each row's value before it reaches the comparator + resolveDataValue: (value) => String(value ?? '').toLowerCase(), + // remove the filter value from filter state if it is falsy (empty string in this case) + autoRemove: (value) => !value, +}) +``` -// remove the filter value from filter state if it is falsy (empty string in this case) -startsWithFilterFn.autoRemove = (val: any) => !val +Keeping the comparison in `filter` and the normalization in the resolvers pays off when you need a variant of an existing filter function: the definition is attached to the returned function, so you can spread any filter function built with `constructFilterFn` and override only what differs. For example, a version of `includesString` that also ignores diacritics (so a search for "eric" matches "Éric"): -// transform/sanitize/format the filter value before it is passed to the filter function -startsWithFilterFn.resolveFilterValue = (val: any) => - val.toString().toLowerCase().trim() +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, // reuse the comparator and autoRemove behavior + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) ``` +Register the variant by name in the `filterFns` registry or pass it directly to the `filterFn` column option, just like any other custom filter function. + +> **Note:** The table applies `resolveFilterValue` once per filter before any rows are tested. If you ever call a filter function directly (outside of a table), resolve the filter value yourself: `myFilterFn(row, columnId, myFilterFn.resolveFilterValue?.(rawValue) ?? rawValue)`. + ### Customize Column Filtering There are a lot of table and column options that you can use to further customize the column filtering behavior. @@ -381,7 +412,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ @@ -404,7 +438,10 @@ const features = tableFeatures({ rowExpandingFeature, filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const table = useTable({ diff --git a/docs/framework/vue/guide/fuzzy-filtering.md b/docs/framework/vue/guide/fuzzy-filtering.md index 16ad055bb6..b8e5bba8b9 100644 --- a/docs/framework/vue/guide/fuzzy-filtering.md +++ b/docs/framework/vue/guide/fuzzy-filtering.md @@ -23,8 +23,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/vue-table' import type { FilterFn, SortFn, RowData } from '@tanstack/vue-table' @@ -39,8 +37,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering sortedRowModel: createSortedRowModel(), // if using client-side sorting - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -51,6 +49,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` and `sortFns` registries above list only the custom `fuzzy` functions this guide uses. Spreading the entire built-in registries (`filterFns: { ...filterFns, fuzzy: fuzzyFilter }`) still works, but it puts every built-in function in your bundle. Register just the functions you use, or pass functions directly to the `filterFn` and `sortFn` column options with no registration. + ## Fuzzy Filtering (Vue) Guide Fuzzy filtering is a technique that allows you to filter data based on approximate matches. This can be useful when you want to search for data that is similar to a given value, rather than an exact match. @@ -108,15 +108,15 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` ### Using Fuzzy Filtering with Global Filtering -To use fuzzy filtering with global filtering, register the fuzzy filter function in the registry passed to `createFilteredRowModel` and reference it in the `globalFilterFn` option of the table: +To use fuzzy filtering with global filtering, register the fuzzy filter function in the `filterFns` slot of `tableFeatures` and reference it in the `globalFilterFn` option of the table: ```typescript import { @@ -127,8 +127,6 @@ import { rowSortingFeature, createFilteredRowModel, createSortedRowModel, - filterFns, - sortFns, metaHelper, } from '@tanstack/vue-table' @@ -138,8 +136,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), // needed if you want sorting with fuzzy rank - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) @@ -153,7 +151,7 @@ const table = useTable({ ### Using Fuzzy Filtering with Column Filtering -To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot of `tableFeatures` (merging it with the built-in `filterFns`). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: +To use fuzzy filtering with column filtering, register your fuzzy filter function in the `filterFns` slot of `tableFeatures` (as shown above). You can then specify the fuzzy filter by name in the `filterFn` option of the column definition: ```typescript const column = [ @@ -176,7 +174,7 @@ When using fuzzy filtering with column filtering, you might also want to sort th ```typescript import { compareItems } from '@tanstack/match-sorter-utils' -import { sortFns } from '@tanstack/vue-table' +import { sortFn_alphanumeric } from '@tanstack/vue-table' import type { SortFn, TableFeatures } from '@tanstack/vue-table' type FuzzyFeatures = TableFeatures & { filterMeta: FuzzyFilterMeta } @@ -193,7 +191,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } ``` @@ -212,4 +210,4 @@ You can then pass this sorting function directly to the `sortFn` option of the c } ``` -> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also added `fuzzySort` to the `sortFns` slot in `tableFeatures` (e.g. `sortFns: { ...sortFns, fuzzySort }`). Passing the function directly skips that step. +> **Note:** Unlike `filterFn: 'fuzzy'` above, `fuzzySort` is passed as a function rather than a string. A string reference like `sortFn: 'fuzzySort'` would only work if you also added `fuzzySort` to the `sortFns` slot in `tableFeatures` (e.g. `sortFns: { fuzzySort }`). Passing the function directly skips that step. diff --git a/docs/framework/vue/guide/global-filtering.md b/docs/framework/vue/guide/global-filtering.md index 0e27197f27..1827b6d089 100644 --- a/docs/framework/vue/guide/global-filtering.md +++ b/docs/framework/vue/guide/global-filtering.md @@ -22,14 +22,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/vue-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), // if using client-side filtering - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -39,6 +39,8 @@ const table = useTable({ }) ``` +> **Note:** The `filterFns` registry above lists only the built-in filter function this table uses. Spreading the entire built-in `filterFns` registry (`filterFns: { ...filterFns }`) still works, but it puts every built-in filter function in your bundle. Register just the functions you use, or pass a function directly to the `globalFilterFn` option with no registration at all. + ## Global Filtering (Vue) Guide Filtering comes in 2 flavors: Column Filtering and Global Filtering. @@ -101,14 +103,14 @@ import { columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, } from '@tanstack/vue-table' const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns, + filterFns: { includesString: filterFn_includesString }, }) const table = useTable({ @@ -119,7 +121,7 @@ const table = useTable({ ### Global Filter Function -The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a built-in filter function, a string that references a custom filter function registered in the registry passed to `createFilteredRowModel`, or a custom filter function passed directly. +The `globalFilterFn` option allows you to specify the filter function that will be used for global filtering. The filter function can be a string that references a filter function (built-in or custom) registered in the `filterFns` slot of `tableFeatures`, or a filter function passed directly. ```ts const table = useTable({ diff --git a/docs/framework/vue/guide/grouping.md b/docs/framework/vue/guide/grouping.md index c1018839e3..9d9ab018b9 100644 --- a/docs/framework/vue/guide/grouping.md +++ b/docs/framework/vue/guide/grouping.md @@ -20,13 +20,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/vue-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), // if using client-side grouping - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -36,6 +36,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`aggregationFns: { ...aggregationFns }`) still works, but it puts every built-in aggregation function in your bundle. Registering just the functions you use, or passing a function directly to the `aggregationFn` column option, is recommended. + ## Grouping (Vue) Guide Grouping in TanStack table is a feature that applies to columns and allows you to categorize and organize the table rows based on specific columns. This can be useful in cases where you have a large amount of data and you want to group them together based on certain criteria. @@ -54,13 +56,13 @@ import { tableFeatures, columnGroupingFeature, createGroupedRowModel, - aggregationFns, + aggregationFn_sum, } from '@tanstack/vue-table' const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -78,7 +80,7 @@ const features = tableFeatures({ rowExpandingFeature, groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - aggregationFns, + aggregationFns: { sum: aggregationFn_sum }, }) const table = useTable({ @@ -122,7 +124,7 @@ const column = columnHelper.accessor('key', { ``` In the above example, the sum aggregation function will be used to aggregate the data in the grouped rows. -By default, numeric columns will use the sum aggregation function, and non-numeric columns will use the count aggregation function. You can override this behavior by specifying the aggregationFn option in the column definition. +By default (`aggregationFn: 'auto'`), numeric columns use the `sum` aggregation function and date columns use the `extent` aggregation function, resolved from the `aggregationFns` registry (a development warning fires if the chosen function is not registered). Other column types are left unaggregated. You can override this behavior by specifying the `aggregationFn` option in the column definition. There are several built-in aggregation functions that you can use: @@ -135,6 +137,8 @@ There are several built-in aggregation functions that you can use: - median - Finds the median of the values in the grouped rows. - unique - Returns an array of unique values in the grouped rows. - uniqueCount - Counts the number of unique values in the grouped rows. +- first - Returns the first leaf value in the grouped rows. +- last - Returns the last leaf value in the grouped rows. #### Custom Aggregations @@ -145,7 +149,7 @@ const features = tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { - ...aggregationFns, + sum: aggregationFn_sum, myCustomAggregation: (columnId, leafRows, childRows) => { // return the aggregated value }, @@ -168,6 +172,28 @@ const column = columnHelper.accessor('key', { > **TypeScript Note:** For `aggregationFn: 'myCustomAggregation'` string references to typecheck, register the function in the `aggregationFns` slot of `tableFeatures`. When the function is registered there, TypeScript infers the available string keys from the registry, so no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `aggregationFn` column option. +#### Customize Aggregation Function Behavior + +Aggregation functions support an optional "hanging" property: + +- `aggregationFn.resolveDataValue` - normalizes each row's value before it is aggregated. It is honored by every aggregation function built with the `constructAggregationFn` helper, which includes the value-based built-in aggregation functions (`count`, `first`, and `last` are plain row-level functions that never read every value). + +The `constructAggregationFn` helper builds an aggregation function from a value-level reducer (`aggregate`) plus that optional resolver and a `fromRows` setting that picks between the group's `leafRows` (the default) and its immediate `childRows`. The definition is attached to the returned function, so you can spread any constructed aggregation function and override only what differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, // reuse the numeric reducer + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) + +const features = tableFeatures({ + columnGroupingFeature, + groupedRowModel: createGroupedRowModel(), + aggregationFns: { min: aggregationFn_min, earliest }, +}) +``` + ### Manual Grouping If you are doing server-side grouping and aggregation, you can enable manual grouping using the manualGrouping option. When this option is set to true, the table will not automatically group rows using getGroupedRowModel() and instead will expect you to manually group the rows before passing them to the table. diff --git a/docs/framework/vue/guide/migrating.md b/docs/framework/vue/guide/migrating.md index f305625497..6a4c465cfd 100644 --- a/docs/framework/vue/guide/migrating.md +++ b/docs/framework/vue/guide/migrating.md @@ -274,6 +274,34 @@ const table = useTable({ }) ``` +### Prefer Individual Fn Imports Over Full Registries + +The `filterFns`, `sortFns`, and `aggregationFns` registry exports are now deprecated in favor of importing individual `filterFn_*`, `sortFn_*`, and `aggregationFn_*` functions and registering only the ones you use (or passing functions directly in column definitions with no registration at all). The full registries still work, but spreading them puts every built-in function in your bundle. Keep in mind that string names, including the default `'auto'`, only resolve functions you have registered. + +```ts +// Before: registers every built-in function +import { filterFns, sortFns } from '@tanstack/vue-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns, + sortFns, +}) + +// After: registers only the functions you use +import { + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, +} from '@tanstack/vue-table' + +const features = tableFeatures({ + // ...other features and row models + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, +}) +``` + --- ## State Management Changes @@ -699,7 +727,7 @@ interface FuzzyFilterMeta { const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { fuzzy: fuzzyFilter }, filterMeta: metaHelper(), }) diff --git a/docs/framework/vue/guide/sorting.md b/docs/framework/vue/guide/sorting.md index 14dfdc0c54..8599104098 100644 --- a/docs/framework/vue/guide/sorting.md +++ b/docs/framework/vue/guide/sorting.md @@ -20,13 +20,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/vue-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), // if using client-side sorting - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -36,6 +42,8 @@ const table = useTable({ }) ``` +> **NOTE**: Spreading the entire built-in registry (`sortFns: { ...sortFns }`) still works, but it puts every built-in sorting function in your bundle. Registering just the functions you use, or passing a function directly to the `sortFn` column option, is recommended. The default `sortFn: 'auto'` resolves to `alphanumeric`, `text`, or `datetime` from the registry based on the column's data type, so register the ones your columns rely on. + ## Sorting (Vue) Guide TanStack Table provides solutions for just about any sorting use-case you might have. This guide will walk you through the various options that you can use to customize the built-in client-side sorting functionality, as well as how to opt out of client-side sorting in favor of manual server-side sorting. @@ -174,7 +182,7 @@ Hoisting the sorting state into your own scope (with an external atom or the `st ### Client-Side Sorting -To implement client-side sorting, add the `rowSortingFeature`, `sortedRowModel`, and `sortFns` to your `tableFeatures` call. Import `createSortedRowModel` and `sortFns` from TanStack Table: +To implement client-side sorting, add the `rowSortingFeature`, `sortedRowModel`, and `sortFns` to your `tableFeatures` call. Import `createSortedRowModel` and the individual sorting functions you use from TanStack Table: ```ts import { @@ -182,13 +190,19 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, + sortFn_datetime, } from '@tanstack/vue-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + datetime: sortFn_datetime, + }, }) const table = useTable({ @@ -271,7 +285,8 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, myCustomSortFn: (rowA, rowB, columnId) => rowA.original[columnId] > rowB.original[columnId] ? 1 @@ -290,6 +305,46 @@ const table = useTable({ > **TypeScript Note:** For `sortFn: 'myCustomSortFn'` string references to typecheck, register the function in the `sortFns` slot of `tableFeatures`. When the function is registered there, TypeScript infers the available string keys from the registry, so no `declare module` augmentation is needed. Alternatively, skip the registry entirely by passing the function directly to the `sortFn` column option. +#### Customize Sorting Function Behavior + +Sorting functions support an optional "hanging" property: + +- `sortFn.resolveDataValue` - normalizes each row's value before the two sides are compared. It is honored by every sorting function built with the `constructSortFn` helper, which includes all built-in sorting functions. + +The `constructSortFn` helper builds a sorting function from a value-level comparator (`sort`) plus that optional resolver. Keeping the comparison in `sort` and the normalization in `resolveDataValue` means a variant of an existing sorting function only has to swap the resolver: the definition is attached to the returned function, so you can spread any sorting function built with `constructSortFn` and override only what differs. + +For example, a version of `alphanumeric` that ignores diacritics, so that "Éric Bernard" sorts next to "Eric Brandon" instead of after "Zak O'Sullivan": + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, // reuse the comparator + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) + +const features = tableFeatures({ + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, alphanumericIgnoreDiacritics }, +}) +``` + +The same pattern works when defining a new sorting function from scratch: + +```ts +const byLastName = constructSortFn({ + sort: (dataValueA, dataValueB) => + dataValueA === dataValueB ? 0 : dataValueA > dataValueB ? 1 : -1, + resolveDataValue: (value) => + String(value ?? '') + .split(' ') + .at(-1) ?? '', +}) +``` + ### Customize Sorting There are a lot of table and column options that you can use to further customize the sorting UX and behavior. diff --git a/docs/guide/helpers.md b/docs/guide/helpers.md index 0fcd334652..3aec0956f8 100644 --- a/docs/guide/helpers.md +++ b/docs/guide/helpers.md @@ -31,9 +31,10 @@ import { columnFilteringFeature, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/react-table' @@ -42,11 +43,13 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, }) ``` +> Note: the full built-in registries (`filterFns`, `sortFns`, `aggregationFns`) can still be spread into these slots, but they are deprecated because they put every built-in function in your bundle. Register only the functions you use under their conventional string keys, or pass functions directly to the `filterFn`, `sortFn`, and `aggregationFn` column options with no registration at all. String keys, including the default `'auto'`, only resolve functions that are registered. + Keep `features` stable. In most apps, define it outside your component or in shared table setup code. Since `typeof features` is used throughout the table's types, stable features also make it easier to reuse column helpers, column definitions, and shared options. ### What goes in `tableFeatures` @@ -91,7 +94,6 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, tableFeatures, } from '@tanstack/react-table' @@ -103,7 +105,6 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { - ...sortFns, byRank: (rowA, rowB, columnId) => { return rowA.getValue(columnId) - rowB.getValue(columnId) }, diff --git a/docs/guide/row-models.md b/docs/guide/row-models.md index 64ce3878e7..2faf7f6357 100644 --- a/docs/guide/row-models.md +++ b/docs/guide/row-models.md @@ -54,8 +54,9 @@ import { createFilteredRowModel, createSortedRowModel, createPaginatedRowModel, - filterFns, - sortFns, + filterFn_includesString, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/react-table' const features = tableFeatures({ @@ -65,8 +66,8 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, - sortFns, + filterFns: { includesString: filterFn_includesString }, + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, }) const table = useTable({ @@ -76,6 +77,8 @@ const table = useTable({ }) ``` +> Note: the full built-in registries (`filterFns`, `sortFns`, `aggregationFns`) can still be spread into these slots, but they are deprecated because they pull every built-in function into your bundle. Register only the functions you use under their conventional string keys, or pass functions directly to the `filterFn`, `sortFn`, and `aggregationFn` column options with no registration at all. String keys, including the default `'auto'`, only resolve functions that are registered. + ## Function Registries `tableFeatures()` accepts three named registry slots: `filterFns`, `sortFns`, and `aggregationFns`. Each slot is an object whose keys become valid, fully type-safe string values for `filterFn`, `sortFn`, `globalFilterFn`, and `aggregationFn` in your column definitions and table options. You only pay for the functions you register. @@ -85,7 +88,6 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, } from '@tanstack/react-table' const myFuzzyFilter: FilterFn = ( @@ -101,7 +103,7 @@ const myFuzzyFilter: FilterFn = ( const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), - filterFns: { ...filterFns, fuzzy: myFuzzyFilter }, + filterFns: { fuzzy: myFuzzyFilter }, }) // 'fuzzy' is now a valid type-safe value for filterFn in column defs: @@ -112,10 +114,10 @@ columnHelper.accessor('name', { filterFn: 'fuzzy' }) The same pattern applies for sorting and grouping: -- `sortFns: { ...sortFns, myCustomSort }` makes `'myCustomSort'` valid for `sortFn` in column defs. -- `aggregationFns: { ...aggregationFns, myAgg }` makes `'myAgg'` valid for `aggregationFn` in column defs. +- `sortFns: { myCustomSort }` makes `'myCustomSort'` valid for `sortFn` in column defs. +- `aggregationFns: { myAgg }` makes `'myAgg'` valid for `aggregationFn` in column defs. -You can spread in the built-in maps (`filterFns`, `sortFns`, `aggregationFns`) to retain the defaults, add your own, or pass only your own to keep the bundle lean. +To use built-in functions by string name, import them individually (`filterFn_includesString`, `sortFn_alphanumeric`, `aggregationFn_sum`, and so on) and register them under their conventional keys, e.g. `filterFns: { includesString: filterFn_includesString }`. If a column option accepts a function directly, you can also skip registration entirely and pass the imported function as the `filterFn`, `sortFn`, or `aggregationFn` value. ## Customize/Fork Row Models diff --git a/docs/guide/table-and-column-meta.md b/docs/guide/table-and-column-meta.md index aa836a83ba..3aa0f32cdf 100644 --- a/docs/guide/table-and-column-meta.md +++ b/docs/guide/table-and-column-meta.md @@ -452,8 +452,7 @@ import { createFilteredRowModel, createSortedRowModel, createPaginatedRowModel, - filterFns, - sortFns, + sortFn_alphanumeric, } from '@tanstack/react-table' import type { FilterFn, @@ -491,10 +490,10 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId]?.itemRank!, ) } - return dir === 0 ? sortingFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } -// 4. Register everything on tableFeatures() — including the filterMeta slot +// 4. Register everything on tableFeatures(), including the filterMeta slot const features = tableFeatures({ columnFilteringFeature, globalFilteringFeature, @@ -503,12 +502,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { fuzzy: fuzzySort }, filterMeta: metaHelper(), }) ``` +> Note: the `filterFns` and `sortFns` slots above register only the functions this table uses. The full built-in registries (`filterFns`, `sortFns`, `aggregationFns` exported from the package) can still be spread into these slots, but they are deprecated because they put every built-in function in your bundle. Import individual functions such as `sortFn_alphanumeric` instead, or pass functions directly in your column definitions. + Now `columnFiltersMeta` on every row is typed as `FuzzyFilterMeta` for tables built from this `features` object. The `filterMeta` slot is, like `tableMeta` and `columnMeta`, a phantom type-only entry: `metaHelper()` returns `{}` at runtime and is stripped from the registered features. See the [React filters-fuzzy example](../framework/react/examples/filters-fuzzy) for a complete, runnable implementation. diff --git a/docs/reference/index/functions/aggregationFn_count.md b/docs/reference/index/functions/aggregationFn_count.md index c44c02b963..d4e1fd4af8 100644 --- a/docs/reference/index/functions/aggregationFn_count.md +++ b/docs/reference/index/functions/aggregationFn_count.md @@ -9,11 +9,13 @@ title: aggregationFn_count function aggregationFn_count(_columnId, leafRows): number; ``` -Defined in: [fns/aggregationFns.ts:221](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L221) +Defined in: [fns/aggregationFns.ts:242](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L242) Counts the number of leaf rows in the group. The column id is ignored because the result is based only on group size. +This is a plain row-level function (not built with +`constructAggregationFn`) because it never reads row values. ## Type Parameters diff --git a/docs/reference/index/functions/aggregationFn_extent.md b/docs/reference/index/functions/aggregationFn_extent.md deleted file mode 100644 index dba9d405ac..0000000000 --- a/docs/reference/index/functions/aggregationFn_extent.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -id: aggregationFn_extent -title: aggregationFn_extent ---- - -# Function: aggregationFn\_extent() - -```ts -function aggregationFn_extent( - columnId, - _leafRows, - childRows): (number | undefined)[]; -``` - -Defined in: [fns/aggregationFns.ts:94](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L94) - -Finds the numeric extent for a grouped column. - -Returns `[min, max]`, where each entry is `undefined` when no numeric value is -present. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -(`number` \| `undefined`)[] diff --git a/docs/reference/index/functions/aggregationFn_first.md b/docs/reference/index/functions/aggregationFn_first.md new file mode 100644 index 0000000000..bda2ba51ab --- /dev/null +++ b/docs/reference/index/functions/aggregationFn_first.md @@ -0,0 +1,41 @@ +--- +id: aggregationFn_first +title: aggregationFn_first +--- + +# Function: aggregationFn\_first() + +```ts +function aggregationFn_first(columnId, leafRows): unknown; +``` + +Defined in: [fns/aggregationFns.ts:255](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L255) + +Returns the first leaf-row value for a grouped column. + +This is a plain row-level function (not built with +`constructAggregationFn`) because it only reads one positional value. + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Parameters + +### columnId + +`string` + +### leafRows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +## Returns + +`unknown` diff --git a/docs/reference/index/functions/aggregationFn_last.md b/docs/reference/index/functions/aggregationFn_last.md new file mode 100644 index 0000000000..afe5638ddc --- /dev/null +++ b/docs/reference/index/functions/aggregationFn_last.md @@ -0,0 +1,41 @@ +--- +id: aggregationFn_last +title: aggregationFn_last +--- + +# Function: aggregationFn\_last() + +```ts +function aggregationFn_last(columnId, leafRows): unknown; +``` + +Defined in: [fns/aggregationFns.ts:268](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L268) + +Returns the last leaf-row value for a grouped column. + +This is a plain row-level function (not built with +`constructAggregationFn`) because it only reads one positional value. + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Parameters + +### columnId + +`string` + +### leafRows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +## Returns + +`unknown` diff --git a/docs/reference/index/functions/aggregationFn_max.md b/docs/reference/index/functions/aggregationFn_max.md deleted file mode 100644 index 6cc4da806e..0000000000 --- a/docs/reference/index/functions/aggregationFn_max.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -id: aggregationFn_max -title: aggregationFn_max ---- - -# Function: aggregationFn\_max() - -```ts -function aggregationFn_max( - columnId, - _leafRows, - childRows): number | undefined; -``` - -Defined in: [fns/aggregationFns.ts:65](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L65) - -Finds the maximum numeric child-row value for a grouped column. - -Nullish and non-number values are ignored. Returns `undefined` when no -numeric value is found. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` \| `undefined` diff --git a/docs/reference/index/functions/aggregationFn_mean.md b/docs/reference/index/functions/aggregationFn_mean.md deleted file mode 100644 index 38b2c7e549..0000000000 --- a/docs/reference/index/functions/aggregationFn_mean.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -id: aggregationFn_mean -title: aggregationFn_mean ---- - -# Function: aggregationFn\_mean() - -```ts -function aggregationFn_mean(columnId, leafRows): number | undefined; -``` - -Defined in: [fns/aggregationFns.ts:126](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L126) - -Averages numeric leaf-row values for a grouped column. - -Number-like values are coerced with unary `+`; nullish and non-numeric values -are ignored. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` \| `undefined` diff --git a/docs/reference/index/functions/aggregationFn_median.md b/docs/reference/index/functions/aggregationFn_median.md deleted file mode 100644 index 115ee3d544..0000000000 --- a/docs/reference/index/functions/aggregationFn_median.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -id: aggregationFn_median -title: aggregationFn_median ---- - -# Function: aggregationFn\_median() - -```ts -function aggregationFn_median(columnId, leafRows): number | undefined; -``` - -Defined in: [fns/aggregationFns.ts:158](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L158) - -Computes the median of numeric leaf-row values for a grouped column. - -All values must be numbers. If any value is non-numeric, or no leaf rows are -present, the result is `undefined`. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` \| `undefined` diff --git a/docs/reference/index/functions/aggregationFn_min.md b/docs/reference/index/functions/aggregationFn_min.md deleted file mode 100644 index 34638a29b4..0000000000 --- a/docs/reference/index/functions/aggregationFn_min.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -id: aggregationFn_min -title: aggregationFn_min ---- - -# Function: aggregationFn\_min() - -```ts -function aggregationFn_min( - columnId, - _leafRows, - childRows): number | undefined; -``` - -Defined in: [fns/aggregationFns.ts:35](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L35) - -Finds the minimum numeric child-row value for a grouped column. - -Nullish and non-number values are ignored. Returns `undefined` when no -numeric value is found. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` \| `undefined` diff --git a/docs/reference/index/functions/aggregationFn_sum.md b/docs/reference/index/functions/aggregationFn_sum.md deleted file mode 100644 index 6b0949ab18..0000000000 --- a/docs/reference/index/functions/aggregationFn_sum.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -id: aggregationFn_sum -title: aggregationFn_sum ---- - -# Function: aggregationFn\_sum() - -```ts -function aggregationFn_sum( - columnId, - _leafRows, - childRows): number; -``` - -Defined in: [fns/aggregationFns.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L11) - -Sums numeric child-row values for a grouped column. - -Non-number values contribute `0`. Child rows are used so nested group totals -can reuse already aggregated values. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` diff --git a/docs/reference/index/functions/aggregationFn_unique.md b/docs/reference/index/functions/aggregationFn_unique.md deleted file mode 100644 index e6c3a39973..0000000000 --- a/docs/reference/index/functions/aggregationFn_unique.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: aggregationFn_unique -title: aggregationFn_unique ---- - -# Function: aggregationFn\_unique() - -```ts -function aggregationFn_unique(columnId, leafRows): unknown[]; -``` - -Defined in: [fns/aggregationFns.ts:189](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L189) - -Collects unique leaf-row values for a grouped column. - -Values are compared with JavaScript `Set` semantics. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`unknown`[] diff --git a/docs/reference/index/functions/aggregationFn_uniqueCount.md b/docs/reference/index/functions/aggregationFn_uniqueCount.md deleted file mode 100644 index 9f3f17f8a4..0000000000 --- a/docs/reference/index/functions/aggregationFn_uniqueCount.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: aggregationFn_uniqueCount -title: aggregationFn_uniqueCount ---- - -# Function: aggregationFn\_uniqueCount() - -```ts -function aggregationFn_uniqueCount(columnId, leafRows): number; -``` - -Defined in: [fns/aggregationFns.ts:205](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L205) - -Counts unique leaf-row values for a grouped column. - -Values are compared with JavaScript `Set` semantics. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### columnId - -`string` - -### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`number` diff --git a/docs/reference/index/functions/constructAggregationFn.md b/docs/reference/index/functions/constructAggregationFn.md new file mode 100644 index 0000000000..2d7f852b79 --- /dev/null +++ b/docs/reference/index/functions/constructAggregationFn.md @@ -0,0 +1,56 @@ +--- +id: constructAggregationFn +title: constructAggregationFn +--- + +# Function: constructAggregationFn() + +```ts +function constructAggregationFn(def): CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L34) + +Builds an `AggregationFn` from a value-level reducer plus optional +`resolveDataValue` and `fromRows` settings. + +The `aggregate` reducer receives an array of the group rows' values, each +already passed through `resolveDataValue` when one is defined. Keeping +normalization in the resolver means a variant of an existing aggregation +function only has to swap the resolver, not re-implement the computation. + +The definition is attached to the returned function, so a variant can be +created by spreading a built-in aggregation function and overriding what +differs. For example, a `min` that works on date columns: + +```ts +const earliest = constructAggregationFn({ + ...aggregationFn_min, + resolveDataValue: (value) => + value instanceof Date ? value.getTime() : value, +}) +``` + +The built-in `count`, `first`, and `last` aggregation functions are plain +row-level functions instead: they read group position or size and never +look at every value, so materializing a values array would be wasted work. + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) = `any` + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) = `any` + +## Parameters + +### def + +[`AggregationFnDef`](../interfaces/AggregationFnDef.md)\<`TFeatures`, `TData`\> + +## Returns + +[`CreatedAggregationFn`](../interfaces/CreatedAggregationFn.md)\<`TFeatures`, `TData`\> diff --git a/docs/reference/index/functions/constructFilterFn.md b/docs/reference/index/functions/constructFilterFn.md new file mode 100644 index 0000000000..7f510ef617 --- /dev/null +++ b/docs/reference/index/functions/constructFilterFn.md @@ -0,0 +1,61 @@ +--- +id: constructFilterFn +title: constructFilterFn +--- + +# Function: constructFilterFn() + +```ts +function constructFilterFn(def): CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:40](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L40) + +Builds a `FilterFn` from a value-level comparator plus optional resolvers. + +The `filter` comparator receives the row's data value (already passed +through `resolveDataValue` when one is defined) and the filter value +(already passed through `resolveFilterValue` by the table). Keeping +normalization in the resolvers means a variant of an existing filter +function only has to swap the resolvers, not re-implement the comparison. + +The definition is attached to the returned function, so a variant can be +created by spreading a built-in filter function and overriding what differs: + +```ts +const normalize = (value: unknown) => + String(value ?? '') + .toLowerCase() + .normalize('NFD') + .replace(/\p{Diacritic}/gu, '') + +const includesStringIgnoreDiacritics = constructFilterFn({ + ...filterFn_includesString, + resolveFilterValue: normalize, + resolveDataValue: normalize, +}) +``` + +Note: the table applies `resolveFilterValue` once per filter before any rows +are tested. When calling a filter function directly (outside of a table), +apply it yourself: `fn(row, columnId, fn.resolveFilterValue?.(value) ?? value)`. + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) = `any` + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) = `any` + +## Parameters + +### def + +[`FilterFnDef`](../interfaces/FilterFnDef.md)\<`TFeatures`, `TData`\> + +## Returns + +[`CreatedFilterFn`](../interfaces/CreatedFilterFn.md)\<`TFeatures`, `TData`\> diff --git a/docs/reference/index/functions/constructSortFn.md b/docs/reference/index/functions/constructSortFn.md new file mode 100644 index 0000000000..2ce50e69df --- /dev/null +++ b/docs/reference/index/functions/constructSortFn.md @@ -0,0 +1,55 @@ +--- +id: constructSortFn +title: constructSortFn +--- + +# Function: constructSortFn() + +```ts +function constructSortFn(def): CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:41](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L41) + +Builds a `SortFn` from a value-level comparator plus an optional +`resolveDataValue` normalizer. + +The `sort` comparator receives both rows' data values, each already passed +through `resolveDataValue` when one is defined. Keeping normalization in the +resolver means a variant of an existing sorting function only has to swap +the resolver, not re-implement the comparison. + +The definition is attached to the returned function, so a variant can be +created by spreading a built-in sorting function and overriding what +differs: + +```ts +const stripDiacritics = (value: string) => + value.normalize('NFD').replace(/\p{Diacritic}/gu, '') + +const alphanumericIgnoreDiacritics = constructSortFn({ + ...sortFn_alphanumeric, + resolveDataValue: (value) => + stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)), +}) +``` + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) = `any` + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) = `any` + +## Parameters + +### def + +[`SortFnDef`](../interfaces/SortFnDef.md)\<`TFeatures`, `TData`\> + +## Returns + +[`CreatedSortFn`](../interfaces/CreatedSortFn.md)\<`TFeatures`, `TData`\> diff --git a/docs/reference/index/functions/createFilteredRowModel.md b/docs/reference/index/functions/createFilteredRowModel.md index 23d120103f..63462c74da 100644 --- a/docs/reference/index/functions/createFilteredRowModel.md +++ b/docs/reference/index/functions/createFilteredRowModel.md @@ -9,14 +9,18 @@ title: createFilteredRowModel function createFilteredRowModel(): (table) => () => RowModel; ``` -Defined in: [features/column-filtering/createFilteredRowModel.ts:28](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/createFilteredRowModel.ts#L28) +Defined in: [features/column-filtering/createFilteredRowModel.ts:32](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/createFilteredRowModel.ts#L32) Creates a memoized filtered row model factory. The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline. -Register filter functions with the `filterFns` slot on the `features` option: -`tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`. +Register the filter functions you use with the `filterFns` slot on the +`features` option: +`tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { includesString: filterFn_includesString } })`. +Importing individual `filterFn_*` functions keeps unused built-ins out of +your bundle; filter functions passed directly to the `filterFn` column +option need no registration at all. ## Type Parameters diff --git a/docs/reference/index/functions/createGroupedRowModel.md b/docs/reference/index/functions/createGroupedRowModel.md index 08cac55b01..2667411496 100644 --- a/docs/reference/index/functions/createGroupedRowModel.md +++ b/docs/reference/index/functions/createGroupedRowModel.md @@ -9,15 +9,18 @@ title: createGroupedRowModel function createGroupedRowModel(): (table) => () => RowModel; ``` -Defined in: [features/column-grouping/createGroupedRowModel.ts:27](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts#L27) +Defined in: [features/column-grouping/createGroupedRowModel.ts:30](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/createGroupedRowModel.ts#L30) Creates a memoized grouped row model factory. The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline. -Register aggregation functions with the `aggregationFns` slot on the -`features` option: -`tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns })`. +Register the aggregation functions you use with the `aggregationFns` slot +on the `features` option: +`tableFeatures({ columnGroupingFeature, groupedRowModel: createGroupedRowModel(), aggregationFns: { sum: aggregationFn_sum } })`. +Importing individual `aggregationFn_*` functions keeps unused built-ins out +of your bundle; aggregation functions passed directly to the +`aggregationFn` column option need no registration at all. ## Type Parameters diff --git a/docs/reference/index/functions/createSortedRowModel.md b/docs/reference/index/functions/createSortedRowModel.md index 4969ad920d..e38afade95 100644 --- a/docs/reference/index/functions/createSortedRowModel.md +++ b/docs/reference/index/functions/createSortedRowModel.md @@ -9,14 +9,18 @@ title: createSortedRowModel function createSortedRowModel(): (table) => () => RowModel; ``` -Defined in: [features/row-sorting/createSortedRowModel.ts:20](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/createSortedRowModel.ts#L20) +Defined in: [features/row-sorting/createSortedRowModel.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/createSortedRowModel.ts#L24) Creates a memoized sorted row model factory. The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline. -Register sorting functions with the `sortFns` slot on the `features` option: -`tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns })`. +Register the sorting functions you use with the `sortFns` slot on the +`features` option: +`tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns: { alphanumeric: sortFn_alphanumeric } })`. +Importing individual `sortFn_*` functions keeps unused built-ins out of +your bundle; sorting functions passed directly to the `sortFn` column +option need no registration at all. ## Type Parameters diff --git a/docs/reference/index/functions/sortFn_alphanumeric.md b/docs/reference/index/functions/sortFn_alphanumeric.md deleted file mode 100644 index d091acc940..0000000000 --- a/docs/reference/index/functions/sortFn_alphanumeric.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_alphanumeric -title: sortFn_alphanumeric ---- - -# Function: sortFn\_alphanumeric() - -```ts -function sortFn_alphanumeric( - rowA, - rowB, - columnId): number; -``` - -Defined in: [fns/sortFns.ts:18](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L18) - -Sorts rows with the built-in alphanumeric strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`number` diff --git a/docs/reference/index/functions/sortFn_alphanumericCaseSensitive.md b/docs/reference/index/functions/sortFn_alphanumericCaseSensitive.md deleted file mode 100644 index 33fa9bd69d..0000000000 --- a/docs/reference/index/functions/sortFn_alphanumericCaseSensitive.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_alphanumericCaseSensitive -title: sortFn_alphanumericCaseSensitive ---- - -# Function: sortFn\_alphanumericCaseSensitive() - -```ts -function sortFn_alphanumericCaseSensitive( - rowA, - rowB, - columnId): number; -``` - -Defined in: [fns/sortFns.ts:37](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L37) - -Sorts rows with the built-in alphanumeric case sensitive strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`number` diff --git a/docs/reference/index/functions/sortFn_basic.md b/docs/reference/index/functions/sortFn_basic.md deleted file mode 100644 index 33d938da75..0000000000 --- a/docs/reference/index/functions/sortFn_basic.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_basic -title: sortFn_basic ---- - -# Function: sortFn\_basic() - -```ts -function sortFn_basic( - rowA, - rowB, - columnId): -1 | 0 | 1; -``` - -Defined in: [fns/sortFns.ts:120](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L120) - -Sorts rows with the built-in basic strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`-1` \| `0` \| `1` diff --git a/docs/reference/index/functions/sortFn_datetime.md b/docs/reference/index/functions/sortFn_datetime.md deleted file mode 100644 index b0a4cf9e62..0000000000 --- a/docs/reference/index/functions/sortFn_datetime.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_datetime -title: sortFn_datetime ---- - -# Function: sortFn\_datetime() - -```ts -function sortFn_datetime( - rowA, - rowB, - columnId): -1 | 0 | 1; -``` - -Defined in: [fns/sortFns.ts:98](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L98) - -Sorts rows with the built-in datetime strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`-1` \| `0` \| `1` diff --git a/docs/reference/index/functions/sortFn_text.md b/docs/reference/index/functions/sortFn_text.md deleted file mode 100644 index be1b0e0b7d..0000000000 --- a/docs/reference/index/functions/sortFn_text.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_text -title: sortFn_text ---- - -# Function: sortFn\_text() - -```ts -function sortFn_text( - rowA, - rowB, - columnId): -1 | 0 | 1; -``` - -Defined in: [fns/sortFns.ts:58](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L58) - -Sorts rows with the built-in text strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`-1` \| `0` \| `1` diff --git a/docs/reference/index/functions/sortFn_textCaseSensitive.md b/docs/reference/index/functions/sortFn_textCaseSensitive.md deleted file mode 100644 index 99f962b079..0000000000 --- a/docs/reference/index/functions/sortFn_textCaseSensitive.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -id: sortFn_textCaseSensitive -title: sortFn_textCaseSensitive ---- - -# Function: sortFn\_textCaseSensitive() - -```ts -function sortFn_textCaseSensitive( - rowA, - rowB, - columnId): -1 | 0 | 1; -``` - -Defined in: [fns/sortFns.ts:79](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L79) - -Sorts rows with the built-in text case sensitive strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -## Parameters - -### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -### columnId - -`string` - -## Returns - -`-1` \| `0` \| `1` diff --git a/docs/reference/index/functions/tableFeatures.md b/docs/reference/index/functions/tableFeatures.md index 33d83a7af6..e805d766b9 100644 --- a/docs/reference/index/functions/tableFeatures.md +++ b/docs/reference/index/functions/tableFeatures.md @@ -9,7 +9,7 @@ title: tableFeatures function tableFeatures(features): TFeatures; ``` -Defined in: [helpers/tableFeatures.ts:45](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableFeatures.ts#L45) +Defined in: [helpers/tableFeatures.ts:46](https://github.com/TanStack/table/blob/main/packages/table-core/src/helpers/tableFeatures.ts#L46) 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. @@ -49,9 +49,10 @@ import { columnFilteringFeature, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/react-table' const features = tableFeatures({ @@ -59,8 +60,8 @@ const features = tableFeatures({ rowSortingFeature, filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, myCustomFilterFn }, - sortFns, + 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' }, }); diff --git a/docs/reference/index/index.md b/docs/reference/index/index.md index 499fa3bd39..57ec560013 100644 --- a/docs/reference/index/index.md +++ b/docs/reference/index/index.md @@ -7,6 +7,8 @@ title: index ## Interfaces +- [AggregationFn](interfaces/AggregationFn.md) +- [AggregationFnDef](interfaces/AggregationFnDef.md) - [AggregationFns](interfaces/AggregationFns.md) - [API](interfaces/API.md) - [CachedRowModel\_All](interfaces/CachedRowModel_All.md) @@ -61,8 +63,12 @@ title: index - [columnResizingState](interfaces/columnResizingState.md) - [ColumnSort](interfaces/ColumnSort.md) - [CoreFeatures](interfaces/CoreFeatures.md) +- [CreatedAggregationFn](interfaces/CreatedAggregationFn.md) +- [CreatedFilterFn](interfaces/CreatedFilterFn.md) +- [CreatedSortFn](interfaces/CreatedSortFn.md) - [FeatureSlotPrereqs](interfaces/FeatureSlotPrereqs.md) - [FilterFn](interfaces/FilterFn.md) +- [FilterFnDef](interfaces/FilterFnDef.md) - [FilterFns](interfaces/FilterFns.md) - [FilterMeta](interfaces/FilterMeta.md) - [Header\_ColumnResizing](interfaces/Header_ColumnResizing.md) @@ -102,6 +108,7 @@ title: index - [RowPinningDefaultOptions](interfaces/RowPinningDefaultOptions.md) - [RowPinningState](interfaces/RowPinningState.md) - [SortFn](interfaces/SortFn.md) +- [SortFnDef](interfaces/SortFnDef.md) - [SortFns](interfaces/SortFns.md) - [StockFeatures](interfaces/StockFeatures.md) - [StringHeaderIdentifier](interfaces/StringHeaderIdentifier.md) @@ -181,7 +188,6 @@ title: index - [AccessorFnColumnDefBase](type-aliases/AccessorFnColumnDefBase.md) - [AccessorKeyColumnDef](type-aliases/AccessorKeyColumnDef.md) - [AccessorKeyColumnDefBase](type-aliases/AccessorKeyColumnDefBase.md) -- [AggregationFn](type-aliases/AggregationFn.md) - [AggregationFnOption](type-aliases/AggregationFnOption.md) - [APIObject](type-aliases/APIObject.md) - [Atoms](type-aliases/Atoms.md) @@ -257,6 +263,7 @@ title: index - [TableOptions](type-aliases/TableOptions.md) - [TableOptions\_All](type-aliases/TableOptions_All.md) - [TableState](type-aliases/TableState.md) +- [TransformDataValueFn](type-aliases/TransformDataValueFn.md) - [TransformFilterValueFn](type-aliases/TransformFilterValueFn.md) - [UnionToIntersection](type-aliases/UnionToIntersection.md) - [Updater](type-aliases/Updater.md) @@ -265,7 +272,15 @@ title: index ## Variables -- [aggregationFns](variables/aggregationFns.md) +- [aggregationFn\_extent](variables/aggregationFn_extent.md) +- [aggregationFn\_max](variables/aggregationFn_max.md) +- [aggregationFn\_mean](variables/aggregationFn_mean.md) +- [aggregationFn\_median](variables/aggregationFn_median.md) +- [aggregationFn\_min](variables/aggregationFn_min.md) +- [aggregationFn\_sum](variables/aggregationFn_sum.md) +- [aggregationFn\_unique](variables/aggregationFn_unique.md) +- [aggregationFn\_uniqueCount](variables/aggregationFn_uniqueCount.md) +- [~~aggregationFns~~](variables/aggregationFns.md) - [columnFacetingFeature](variables/columnFacetingFeature.md) - [columnFilteringFeature](variables/columnFilteringFeature.md) - [columnGroupingFeature](variables/columnGroupingFeature.md) @@ -285,6 +300,8 @@ title: index - [filterFn\_arrIncludes](variables/filterFn_arrIncludes.md) - [filterFn\_arrIncludesAll](variables/filterFn_arrIncludesAll.md) - [filterFn\_arrIncludesSome](variables/filterFn_arrIncludesSome.md) +- [filterFn\_empty](variables/filterFn_empty.md) +- [filterFn\_endsWith](variables/filterFn_endsWith.md) - [filterFn\_equals](variables/filterFn_equals.md) - [filterFn\_equalsString](variables/filterFn_equalsString.md) - [filterFn\_equalsStringSensitive](variables/filterFn_equalsStringSensitive.md) @@ -292,11 +309,14 @@ title: index - [filterFn\_greaterThanOrEqualTo](variables/filterFn_greaterThanOrEqualTo.md) - [filterFn\_includesString](variables/filterFn_includesString.md) - [filterFn\_includesStringSensitive](variables/filterFn_includesStringSensitive.md) +- [filterFn\_inDateRange](variables/filterFn_inDateRange.md) - [filterFn\_inNumberRange](variables/filterFn_inNumberRange.md) - [filterFn\_lessThan](variables/filterFn_lessThan.md) - [filterFn\_lessThanOrEqualTo](variables/filterFn_lessThanOrEqualTo.md) +- [filterFn\_notEmpty](variables/filterFn_notEmpty.md) +- [filterFn\_startsWith](variables/filterFn_startsWith.md) - [filterFn\_weakEquals](variables/filterFn_weakEquals.md) -- [filterFns](variables/filterFns.md) +- [~~filterFns~~](variables/filterFns.md) - [globalFilteringFeature](variables/globalFilteringFeature.md) - [reSplitAlphaNumeric](variables/reSplitAlphaNumeric.md) - [rowExpandingFeature](variables/rowExpandingFeature.md) @@ -304,29 +324,32 @@ title: index - [rowPinningFeature](variables/rowPinningFeature.md) - [rowSelectionFeature](variables/rowSelectionFeature.md) - [rowSortingFeature](variables/rowSortingFeature.md) -- [sortFns](variables/sortFns.md) +- [sortFn\_alphanumeric](variables/sortFn_alphanumeric.md) +- [sortFn\_alphanumericCaseSensitive](variables/sortFn_alphanumericCaseSensitive.md) +- [sortFn\_basic](variables/sortFn_basic.md) +- [sortFn\_datetime](variables/sortFn_datetime.md) +- [sortFn\_text](variables/sortFn_text.md) +- [sortFn\_textCaseSensitive](variables/sortFn_textCaseSensitive.md) +- [~~sortFns~~](variables/sortFns.md) - [stockFeatures](variables/stockFeatures.md) ## Functions - [aggregationFn\_count](functions/aggregationFn_count.md) -- [aggregationFn\_extent](functions/aggregationFn_extent.md) -- [aggregationFn\_max](functions/aggregationFn_max.md) -- [aggregationFn\_mean](functions/aggregationFn_mean.md) -- [aggregationFn\_median](functions/aggregationFn_median.md) -- [aggregationFn\_min](functions/aggregationFn_min.md) -- [aggregationFn\_sum](functions/aggregationFn_sum.md) -- [aggregationFn\_unique](functions/aggregationFn_unique.md) -- [aggregationFn\_uniqueCount](functions/aggregationFn_uniqueCount.md) +- [aggregationFn\_first](functions/aggregationFn_first.md) +- [aggregationFn\_last](functions/aggregationFn_last.md) - [assignPrototypeAPIs](functions/assignPrototypeAPIs.md) - [assignTableAPIs](functions/assignTableAPIs.md) - [buildHeaderGroups](functions/buildHeaderGroups.md) - [callMemoOrStaticFn](functions/callMemoOrStaticFn.md) - [cloneState](functions/cloneState.md) +- [constructAggregationFn](functions/constructAggregationFn.md) - [constructCell](functions/constructCell.md) - [constructColumn](functions/constructColumn.md) +- [constructFilterFn](functions/constructFilterFn.md) - [constructHeader](functions/constructHeader.md) - [constructRow](functions/constructRow.md) +- [constructSortFn](functions/constructSortFn.md) - [constructTable](functions/constructTable.md) - [copyInstancePropertiesWithoutMemos](functions/copyInstancePropertiesWithoutMemos.md) - [createColumnHelper](functions/createColumnHelper.md) @@ -350,12 +373,6 @@ title: index - [makeStateUpdater](functions/makeStateUpdater.md) - [memo](functions/memo.md) - [metaHelper](functions/metaHelper.md) -- [sortFn\_alphanumeric](functions/sortFn_alphanumeric.md) -- [sortFn\_alphanumericCaseSensitive](functions/sortFn_alphanumericCaseSensitive.md) -- [sortFn\_basic](functions/sortFn_basic.md) -- [sortFn\_datetime](functions/sortFn_datetime.md) -- [sortFn\_text](functions/sortFn_text.md) -- [sortFn\_textCaseSensitive](functions/sortFn_textCaseSensitive.md) - [tableFeatures](functions/tableFeatures.md) - [tableMemo](functions/tableMemo.md) - [tableOptions](functions/tableOptions.md) diff --git a/docs/reference/index/interfaces/AggregationFn.md b/docs/reference/index/interfaces/AggregationFn.md new file mode 100644 index 0000000000..2a191660ca --- /dev/null +++ b/docs/reference/index/interfaces/AggregationFn.md @@ -0,0 +1,59 @@ +--- +id: AggregationFn +title: AggregationFn +--- + +# Interface: AggregationFn()\ + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:30](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L30) + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +```ts +AggregationFn( + columnId, + leafRows, + childRows): any; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L34) + +## Parameters + +### columnId + +`string` + +### leafRows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +### childRows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +## Returns + +`any` + +## Properties + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:44](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L44) + +Normalizes each row's value before it is aggregated. Only honored by +aggregation functions built with `constructAggregationFn` (including the +value-based built-in aggregation functions). diff --git a/docs/reference/index/interfaces/AggregationFnDef.md b/docs/reference/index/interfaces/AggregationFnDef.md new file mode 100644 index 0000000000..fd3680752b --- /dev/null +++ b/docs/reference/index/interfaces/AggregationFnDef.md @@ -0,0 +1,81 @@ +--- +id: AggregationFnDef +title: AggregationFnDef +--- + +# Interface: AggregationFnDef\ + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:54](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L54) + +The definition object accepted by `constructAggregationFn`. + +`aggregate` is a value-level reducer: it receives the rows' (resolved) +values instead of the rows themselves, so normalization concerns stay in +`resolveDataValue`. + +## Extended by + +- [`CreatedAggregationFn`](CreatedAggregationFn.md) + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Properties + +### aggregate() + +```ts +aggregate: (values, rows, columnId) => any; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:58](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L58) + +#### Parameters + +##### values + +`any`[] + +##### rows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +##### columnId + +`string` + +#### Returns + +`any` + +*** + +### fromRows? + +```ts +optional fromRows: "leafRows" | "childRows"; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L69) + +Which of the group's rows feed the aggregation: all of its `leafRows` +(the default) or its immediate `childRows`. For nested groups, child rows +expose already-aggregated values, which is faster for reaggregatable +computations like sums and extents. + +*** + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:70](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L70) diff --git a/docs/reference/index/interfaces/AggregationFns.md b/docs/reference/index/interfaces/AggregationFns.md index 498f30c76e..a342522625 100644 --- a/docs/reference/index/interfaces/AggregationFns.md +++ b/docs/reference/index/interfaces/AggregationFns.md @@ -5,4 +5,4 @@ title: AggregationFns # Interface: AggregationFns -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:27](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L27) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:28](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L28) diff --git a/docs/reference/index/interfaces/CachedRowModel_All.md b/docs/reference/index/interfaces/CachedRowModel_All.md index 7c063bc7bb..5cff43a4ef 100644 --- a/docs/reference/index/interfaces/CachedRowModel_All.md +++ b/docs/reference/index/interfaces/CachedRowModel_All.md @@ -117,7 +117,7 @@ Partial.facetedUniqueValues optional filteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:247](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L247) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:307](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L307) #### Returns @@ -197,7 +197,7 @@ Partial.globalFacetedUniqueValues optional groupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:233](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L233) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:288](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L288) #### Returns @@ -237,7 +237,7 @@ Partial.paginatedRowModel optional sortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:235](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L235) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:287](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L287) #### Returns diff --git a/docs/reference/index/interfaces/CachedRowModel_Filtered.md b/docs/reference/index/interfaces/CachedRowModel_Filtered.md index e54c902996..b42a5967b9 100644 --- a/docs/reference/index/interfaces/CachedRowModel_Filtered.md +++ b/docs/reference/index/interfaces/CachedRowModel_Filtered.md @@ -5,7 +5,7 @@ title: CachedRowModel_Filtered # Interface: CachedRowModel\_Filtered\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:243](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L243) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:303](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L303) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:243](http filteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:247](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L247) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:307](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L307) #### Returns diff --git a/docs/reference/index/interfaces/CachedRowModel_Grouped.md b/docs/reference/index/interfaces/CachedRowModel_Grouped.md index 712e82ca71..174beb5271 100644 --- a/docs/reference/index/interfaces/CachedRowModel_Grouped.md +++ b/docs/reference/index/interfaces/CachedRowModel_Grouped.md @@ -5,7 +5,7 @@ title: CachedRowModel_Grouped # Interface: CachedRowModel\_Grouped\ -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:229](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L229) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:284](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L284) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:229](https: groupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:233](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L233) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:288](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L288) #### Returns diff --git a/docs/reference/index/interfaces/CachedRowModel_Sorted.md b/docs/reference/index/interfaces/CachedRowModel_Sorted.md index 7b91671c09..669972cfc4 100644 --- a/docs/reference/index/interfaces/CachedRowModel_Sorted.md +++ b/docs/reference/index/interfaces/CachedRowModel_Sorted.md @@ -5,7 +5,7 @@ title: CachedRowModel_Sorted # Interface: CachedRowModel\_Sorted\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:231](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L231) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:283](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L283) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:231](https://github sortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:235](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L235) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:287](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L287) #### Returns diff --git a/docs/reference/index/interfaces/Cell_ColumnGrouping.md b/docs/reference/index/interfaces/Cell_ColumnGrouping.md index 37c4475021..39e565a0ff 100644 --- a/docs/reference/index/interfaces/Cell_ColumnGrouping.md +++ b/docs/reference/index/interfaces/Cell_ColumnGrouping.md @@ -5,7 +5,7 @@ title: Cell_ColumnGrouping # Interface: Cell\_ColumnGrouping -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:156](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L156) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:211](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L211) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:156](https: getIsAggregated: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:160](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L160) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:215](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L215) Checks whether this cell should render an aggregated value. @@ -31,7 +31,7 @@ Checks whether this cell should render an aggregated value. getIsGrouped: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:164](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L164) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:219](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L219) Checks whether this cell represents the active grouping column. @@ -47,7 +47,7 @@ Checks whether this cell represents the active grouping column. getIsPlaceholder: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:168](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L168) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:223](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L223) Checks whether this cell is hidden as a grouping placeholder. diff --git a/docs/reference/index/interfaces/ColumnDef_ColumnFiltering.md b/docs/reference/index/interfaces/ColumnDef_ColumnFiltering.md index 5656c8257c..e25e458463 100644 --- a/docs/reference/index/interfaces/ColumnDef_ColumnFiltering.md +++ b/docs/reference/index/interfaces/ColumnDef_ColumnFiltering.md @@ -5,7 +5,7 @@ title: ColumnDef_ColumnFiltering # Interface: ColumnDef\_ColumnFiltering\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:112](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L112) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:172](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L172) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:112](http optional enableColumnFilter: boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:122](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L122) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:182](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L182) Enables this column to participate in column-specific filtering. @@ -40,6 +40,6 @@ must also allow filtering. optional filterFn: FilterFnOption; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:126](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L126) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:186](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L186) The filter function to use with this column. Can be the name of a built-in filter function or a custom filter function. diff --git a/docs/reference/index/interfaces/ColumnDef_ColumnGrouping.md b/docs/reference/index/interfaces/ColumnDef_ColumnGrouping.md index 6c1dd578ac..c41866b4af 100644 --- a/docs/reference/index/interfaces/ColumnDef_ColumnGrouping.md +++ b/docs/reference/index/interfaces/ColumnDef_ColumnGrouping.md @@ -5,7 +5,7 @@ title: ColumnDef_ColumnGrouping # Interface: ColumnDef\_ColumnGrouping\ -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:68](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L68) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:123](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L123) ## Type Parameters @@ -29,7 +29,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:68](https:/ optional aggregatedCell: ColumnDefTemplate["getContext"]>>; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:76](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L76) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:131](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L131) The cell to display each row for the column if the cell is an aggregate. If a function is passed, it will be passed a props object with the context of the cell and should return the property type for your adapter (the exact type depends on the adapter being used). @@ -41,7 +41,7 @@ The cell to display each row for the column if the cell is an aggregate. If a fu optional aggregationFn: AggregationFnOption; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:82](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L82) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L137) The resolved aggregation function for the column. @@ -53,7 +53,7 @@ The resolved aggregation function for the column. optional enableGrouping: boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:88](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L88) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:143](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L143) Allows this column to be added to grouping state. @@ -67,7 +67,7 @@ Defaults to `true`; table-level `enableGrouping` must also allow grouping. optional getGroupingValue: (originalRow, index, row) => any; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:95](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L95) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:150](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L150) Returns the value used to group rows for this column. diff --git a/docs/reference/index/interfaces/ColumnDef_RowSorting.md b/docs/reference/index/interfaces/ColumnDef_RowSorting.md index dc71c6d0d3..b3161929cd 100644 --- a/docs/reference/index/interfaces/ColumnDef_RowSorting.md +++ b/docs/reference/index/interfaces/ColumnDef_RowSorting.md @@ -5,7 +5,7 @@ title: ColumnDef_RowSorting # Interface: ColumnDef\_RowSorting\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:66](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L66) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:118](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L118) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:66](https://github. optional enableMultiSort: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:73](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L73) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:125](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L125) Enables/Disables multi-sorting for this column. @@ -37,7 +37,7 @@ Enables/Disables multi-sorting for this column. optional enableSorting: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:77](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L77) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:129](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L129) Enables/Disables sorting for this column. @@ -49,7 +49,7 @@ Enables/Disables sorting for this column. optional invertSorting: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:81](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L81) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:133](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L133) Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better, eg. a ranking (1st, 2nd, 3rd) or golf-like scoring @@ -61,7 +61,7 @@ Inverts the order of the sorting for this column. This is useful for values that optional sortDescFirst: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:85](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L85) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L137) Set to `true` for sorting toggles on this column to start in the descending direction. @@ -73,7 +73,7 @@ Set to `true` for sorting toggles on this column to start in the descending dire optional sortFn: SortFnOption; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:91](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L91) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:143](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L143) The sorting function to use with this column. - A `string` referencing a built-in sorting function @@ -84,10 +84,10 @@ The sorting function to use with this column. ### sortUndefined? ```ts -optional sortUndefined: false | 1 | -1 | "first" | "last"; +optional sortUndefined: false | 1 | "first" | "last" | -1; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:101](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L101) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:153](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L153) The priority of undefined values when sorting this column. - `false` diff --git a/docs/reference/index/interfaces/ColumnDefaultOptions.md b/docs/reference/index/interfaces/ColumnDefaultOptions.md index 8e4a46433c..899c6ec3b9 100644 --- a/docs/reference/index/interfaces/ColumnDefaultOptions.md +++ b/docs/reference/index/interfaces/ColumnDefaultOptions.md @@ -5,7 +5,7 @@ title: ColumnDefaultOptions # Interface: ColumnDefaultOptions -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:171](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L171) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L226) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:171](https: enableGrouping: boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:172](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L172) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:227](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L227) *** @@ -25,4 +25,4 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:172](https: onGroupingChange: OnChangeFn; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:173](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L173) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L228) diff --git a/docs/reference/index/interfaces/ColumnFilter.md b/docs/reference/index/interfaces/ColumnFilter.md index 65b9bdd0db..bb144715cd 100644 --- a/docs/reference/index/interfaces/ColumnFilter.md +++ b/docs/reference/index/interfaces/ColumnFilter.md @@ -5,7 +5,7 @@ title: ColumnFilter # Interface: ColumnFilter -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:38](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L38) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:39](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L39) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:38](https id: string; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:39](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L39) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:40](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L40) *** @@ -25,4 +25,4 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:39](https value: unknown; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:40](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L40) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:41](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L41) diff --git a/docs/reference/index/interfaces/ColumnSort.md b/docs/reference/index/interfaces/ColumnSort.md index 36ff070745..70521e1268 100644 --- a/docs/reference/index/interfaces/ColumnSort.md +++ b/docs/reference/index/interfaces/ColumnSort.md @@ -5,7 +5,7 @@ title: ColumnSort # Interface: ColumnSort -Defined in: [features/row-sorting/rowSortingFeature.types.ts:9](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L9) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L14) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:9](https://github.c desc: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:10](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L10) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L15) *** @@ -25,4 +25,4 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:10](https://github. id: string; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L11) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:16](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L16) diff --git a/docs/reference/index/interfaces/Column_ColumnFiltering.md b/docs/reference/index/interfaces/Column_ColumnFiltering.md index 6a13e58caf..003637aa95 100644 --- a/docs/reference/index/interfaces/Column_ColumnFiltering.md +++ b/docs/reference/index/interfaces/Column_ColumnFiltering.md @@ -5,7 +5,7 @@ title: Column_ColumnFiltering # Interface: Column\_ColumnFiltering\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:129](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L129) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:189](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L189) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:129](http getAutoFilterFn: () => FilterFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L136) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:196](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L196) Returns an automatically calculated filter function for the column based off of the columns first known value. @@ -41,7 +41,7 @@ Returns an automatically calculated filter function for the column based off of getCanFilter: () => boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:140](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L140) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:200](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L200) Checks whether this accessor column can currently be column-filtered. @@ -57,7 +57,7 @@ Checks whether this accessor column can currently be column-filtered. getFilterFn: () => FilterFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:144](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L144) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:204](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L204) Returns the filter function (either user-defined or automatic, depending on configuration) for the columnId specified. @@ -73,7 +73,7 @@ Returns the filter function (either user-defined or automatic, depending on conf getFilterIndex: () => number; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:148](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L148) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:208](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L208) Returns the index (including `-1`) of the column filter in the table's `state.columnFilters` array. @@ -89,7 +89,7 @@ Returns the index (including `-1`) of the column filter in the table's `state.co getFilterValue: () => unknown; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:152](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L152) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:212](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L212) Reads this column's current value from `state.columnFilters`. @@ -105,7 +105,7 @@ Reads this column's current value from `state.columnFilters`. getIsFiltered: () => boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:156](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L156) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:216](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L216) Checks whether this column has an active entry in `state.columnFilters`. @@ -121,7 +121,7 @@ Checks whether this column has an active entry in `state.columnFilters`. setFilterValue: (updater) => void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:163](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L163) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:223](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L223) Adds, updates, or removes this column's filter value. diff --git a/docs/reference/index/interfaces/Column_ColumnGrouping.md b/docs/reference/index/interfaces/Column_ColumnGrouping.md index 5e22a6baca..86da5fd020 100644 --- a/docs/reference/index/interfaces/Column_ColumnGrouping.md +++ b/docs/reference/index/interfaces/Column_ColumnGrouping.md @@ -5,7 +5,7 @@ title: Column_ColumnGrouping # Interface: Column\_ColumnGrouping\ -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:102](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L102) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:157](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L157) ## Type Parameters @@ -22,38 +22,32 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:102](https: ### getAggregationFn() ```ts -getAggregationFn: () => - | AggregationFn - | undefined; +getAggregationFn: () => AggregationFn | undefined; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:109](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L109) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:164](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L164) Returns the aggregation function for the column. #### Returns - \| [`AggregationFn`](../type-aliases/AggregationFn.md)\<`TFeatures`, `TData`\> - \| `undefined` +[`AggregationFn`](AggregationFn.md)\<`TFeatures`, `TData`\> \| `undefined` *** ### getAutoAggregationFn() ```ts -getAutoAggregationFn: () => - | AggregationFn - | undefined; +getAutoAggregationFn: () => AggregationFn | undefined; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:113](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L113) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:168](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L168) Returns the automatically inferred aggregation function for the column. #### Returns - \| [`AggregationFn`](../type-aliases/AggregationFn.md)\<`TFeatures`, `TData`\> - \| `undefined` +[`AggregationFn`](AggregationFn.md)\<`TFeatures`, `TData`\> \| `undefined` *** @@ -63,7 +57,7 @@ Returns the automatically inferred aggregation function for the column. getCanGroup: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:117](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L117) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:172](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L172) Checks whether this column can currently be grouped. @@ -79,7 +73,7 @@ Checks whether this column can currently be grouped. getGroupedIndex: () => number; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:121](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L121) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:176](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L176) Finds this column's position in the ordered grouping state. @@ -95,7 +89,7 @@ Finds this column's position in the ordered grouping state. getIsGrouped: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:125](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L125) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L180) Checks whether this column id is present in grouping state. @@ -111,7 +105,7 @@ Checks whether this column id is present in grouping state. getToggleGroupingHandler: () => () => void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:129](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L129) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:184](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L184) Returns a function that toggles the grouping state of the column. This is useful for passing to the `onClick` prop of a button. @@ -133,7 +127,7 @@ Returns a function that toggles the grouping state of the column. This is useful toggleGrouping: () => void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:133](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L133) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:188](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L188) Toggles the grouping state of the column. diff --git a/docs/reference/index/interfaces/Column_RowSorting.md b/docs/reference/index/interfaces/Column_RowSorting.md index e059707d25..ba10e53780 100644 --- a/docs/reference/index/interfaces/Column_RowSorting.md +++ b/docs/reference/index/interfaces/Column_RowSorting.md @@ -5,7 +5,7 @@ title: Column_RowSorting # Interface: Column\_RowSorting\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:104](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L104) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:156](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L156) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:104](https://github clearSorting: () => void; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:111](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L111) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:163](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L163) Removes this column from the table's sorting state @@ -41,7 +41,7 @@ Removes this column from the table's sorting state getAutoSortDir: () => SortDirection; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:115](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L115) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:167](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L167) Returns a sort direction automatically inferred based on the columns values. @@ -57,7 +57,7 @@ Returns a sort direction automatically inferred based on the columns values. getAutoSortFn: () => SortFn; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:119](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L119) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:171](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L171) Returns a sorting function automatically inferred based on the columns values. @@ -73,7 +73,7 @@ Returns a sorting function automatically inferred based on the columns values. getCanMultiSort: () => boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:123](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L123) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:175](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L175) Returns whether this column can be multi-sorted. @@ -89,7 +89,7 @@ Returns whether this column can be multi-sorted. getCanSort: () => boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:127](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L127) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:179](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L179) Returns whether this column can be sorted. @@ -105,7 +105,7 @@ Returns whether this column can be sorted. getFirstSortDir: () => SortDirection; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:131](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L131) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:183](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L183) Returns the first direction that should be used when sorting this column. @@ -121,7 +121,7 @@ Returns the first direction that should be used when sorting this column. getIsSorted: () => false | SortDirection; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:135](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L135) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:187](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L187) Reads this column's current sort direction, or `false` when unsorted. @@ -137,7 +137,7 @@ Reads this column's current sort direction, or `false` when unsorted. getNextSortingOrder: () => false | SortDirection; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:139](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L139) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:191](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L191) Returns the next sorting order. @@ -153,7 +153,7 @@ Returns the next sorting order. getSortFn: () => SortFn; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:147](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L147) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:199](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L199) Returns the resolved sorting function to be used for this column @@ -169,7 +169,7 @@ Returns the resolved sorting function to be used for this column getSortIndex: () => number; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:143](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L143) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:195](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L195) Finds this column's position in the ordered sorting state. @@ -185,7 +185,7 @@ Finds this column's position in the ordered sorting state. getToggleSortingHandler: () => (event) => void | undefined; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:151](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L151) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:203](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L203) Creates a header/control handler that toggles this column's sorting state. @@ -201,7 +201,7 @@ Creates a header/control handler that toggles this column's sorting state. toggleSorting: (desc?, isMulti?) => void; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:155](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L155) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:207](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L207) Toggles this columns sorting state. If `desc` is provided, it will force the sort direction to that value. If `isMulti` is provided, it will additivity multi-sort the column (or toggle it if it is already sorted). diff --git a/docs/reference/index/interfaces/CreatedAggregationFn.md b/docs/reference/index/interfaces/CreatedAggregationFn.md new file mode 100644 index 0000000000..116141d4d0 --- /dev/null +++ b/docs/reference/index/interfaces/CreatedAggregationFn.md @@ -0,0 +1,140 @@ +--- +id: CreatedAggregationFn +title: CreatedAggregationFn +--- + +# Interface: CreatedAggregationFn()\ + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:82](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L82) + +The shape returned by `constructAggregationFn`: an `AggregationFn` with its +definition attached, so variants can be built by spreading it into another +`constructAggregationFn` call. + +The call signature is generic so a created aggregation function can be used +with any table's rows, regardless of the feature set it was defined +against. + +## Extends + +- [`AggregationFnDef`](AggregationFnDef.md)\<`TFeatures`, `TData`\> + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +```ts +CreatedAggregationFn( + columnId, + leafRows, + childRows): any; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:86](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L86) + +The shape returned by `constructAggregationFn`: an `AggregationFn` with its +definition attached, so variants can be built by spreading it into another +`constructAggregationFn` call. + +The call signature is generic so a created aggregation function can be used +with any table's rows, regardless of the feature set it was defined +against. + +## Type Parameters + +### TRowFeatures + +`TRowFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TRowData + +`TRowData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Parameters + +### columnId + +`string` + +### leafRows + +[`Row`](../type-aliases/Row.md)\<`TRowFeatures`, `TRowData`\>[] + +### childRows + +[`Row`](../type-aliases/Row.md)\<`TRowFeatures`, `TRowData`\>[] + +## Returns + +`any` + +## Properties + +### aggregate() + +```ts +aggregate: (values, rows, columnId) => any; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:58](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L58) + +#### Parameters + +##### values + +`any`[] + +##### rows + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] + +##### columnId + +`string` + +#### Returns + +`any` + +#### Inherited from + +[`AggregationFnDef`](AggregationFnDef.md).[`aggregate`](AggregationFnDef.md#aggregate) + +*** + +### fromRows? + +```ts +optional fromRows: "leafRows" | "childRows"; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L69) + +Which of the group's rows feed the aggregation: all of its `leafRows` +(the default) or its immediate `childRows`. For nested groups, child rows +expose already-aggregated values, which is faster for reaggregatable +computations like sums and extents. + +#### Inherited from + +[`AggregationFnDef`](AggregationFnDef.md).[`fromRows`](AggregationFnDef.md#fromrows) + +*** + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:70](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L70) + +#### Inherited from + +[`AggregationFnDef`](AggregationFnDef.md).[`resolveDataValue`](AggregationFnDef.md#resolvedatavalue) diff --git a/docs/reference/index/interfaces/CreatedFilterFn.md b/docs/reference/index/interfaces/CreatedFilterFn.md new file mode 100644 index 0000000000..3855fa32de --- /dev/null +++ b/docs/reference/index/interfaces/CreatedFilterFn.md @@ -0,0 +1,180 @@ +--- +id: CreatedFilterFn +title: CreatedFilterFn +--- + +# Interface: CreatedFilterFn()\ + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:121](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L121) + +The shape returned by `constructFilterFn`: a `FilterFn` with its definition +attached, so variants can be built by spreading it into another +`constructFilterFn` call. + +The call signature is generic so a created filter function can be used with +any table's rows, regardless of the feature set it was defined against. + +## Extends + +- [`FilterFnDef`](FilterFnDef.md)\<`TFeatures`, `TData`\> + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +```ts +CreatedFilterFn( + row, + columnId, + filterValue, + addMeta?): boolean; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:125](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L125) + +The shape returned by `constructFilterFn`: a `FilterFn` with its definition +attached, so variants can be built by spreading it into another +`constructFilterFn` call. + +The call signature is generic so a created filter function can be used with +any table's rows, regardless of the feature set it was defined against. + +## Type Parameters + +### TRowFeatures + +`TRowFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TRowData + +`TRowData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Parameters + +### row + +[`Row`](../type-aliases/Row.md)\<`TRowFeatures`, `TRowData`\> + +### columnId + +`string` + +### filterValue + +`any` + +### addMeta? + +(`meta`) => `void` + +## Returns + +`boolean` + +## Properties + +### autoRemove()? + +```ts +optional autoRemove: (filterValue) => boolean; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:108](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L108) + +#### Parameters + +##### filterValue + +`any` + +#### Returns + +`boolean` + +#### Inherited from + +[`FilterFnDef`](FilterFnDef.md).[`autoRemove`](FilterFnDef.md#autoremove) + +*** + +### filter() + +```ts +filter: (dataValue, filterValue, row, columnId, addMeta?) => boolean; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:101](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L101) + +#### Parameters + +##### dataValue + +`any` + +##### filterValue + +`any` + +##### row + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### columnId + +`string` + +##### addMeta? + +(`meta`) => `void` + +#### Returns + +`boolean` + +#### Inherited from + +[`FilterFnDef`](FilterFnDef.md).[`filter`](FilterFnDef.md#filter) + +*** + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:110](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L110) + +#### Inherited from + +[`FilterFnDef`](FilterFnDef.md).[`resolveDataValue`](FilterFnDef.md#resolvedatavalue) + +*** + +### resolveFilterValue()? + +```ts +optional resolveFilterValue: (filterValue) => any; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:109](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L109) + +#### Parameters + +##### filterValue + +`any` + +#### Returns + +`any` + +#### Inherited from + +[`FilterFnDef`](FilterFnDef.md).[`resolveFilterValue`](FilterFnDef.md#resolvefiltervalue) diff --git a/docs/reference/index/interfaces/CreatedSortFn.md b/docs/reference/index/interfaces/CreatedSortFn.md new file mode 100644 index 0000000000..c062d101e1 --- /dev/null +++ b/docs/reference/index/interfaces/CreatedSortFn.md @@ -0,0 +1,129 @@ +--- +id: CreatedSortFn +title: CreatedSortFn +--- + +# Interface: CreatedSortFn()\ + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:81](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L81) + +The shape returned by `constructSortFn`: a `SortFn` with its definition +attached, so variants can be built by spreading it into another +`constructSortFn` call. + +The call signature is generic so a created sorting function can be used +with any table's rows, regardless of the feature set it was defined +against. + +## Extends + +- [`SortFnDef`](SortFnDef.md)\<`TFeatures`, `TData`\> + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +```ts +CreatedSortFn( + rowA, + rowB, + columnId): number; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:85](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L85) + +The shape returned by `constructSortFn`: a `SortFn` with its definition +attached, so variants can be built by spreading it into another +`constructSortFn` call. + +The call signature is generic so a created sorting function can be used +with any table's rows, regardless of the feature set it was defined +against. + +## Type Parameters + +### TRowFeatures + +`TRowFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TRowData + +`TRowData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Parameters + +### rowA + +[`Row`](../type-aliases/Row.md)\<`TRowFeatures`, `TRowData`\> + +### rowB + +[`Row`](../type-aliases/Row.md)\<`TRowFeatures`, `TRowData`\> + +### columnId + +`string` + +## Returns + +`number` + +## Properties + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L69) + +#### Inherited from + +[`SortFnDef`](SortFnDef.md).[`resolveDataValue`](SortFnDef.md#resolvedatavalue) + +*** + +### sort() + +```ts +sort: (dataValueA, dataValueB, rowA, rowB, columnId) => number; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:62](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L62) + +#### Parameters + +##### dataValueA + +`any` + +##### dataValueB + +`any` + +##### rowA + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### rowB + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### columnId + +`string` + +#### Returns + +`number` + +#### Inherited from + +[`SortFnDef`](SortFnDef.md).[`sort`](SortFnDef.md#sort) diff --git a/docs/reference/index/interfaces/FilterFn.md b/docs/reference/index/interfaces/FilterFn.md index 75e935d04c..0b5b1ae732 100644 --- a/docs/reference/index/interfaces/FilterFn.md +++ b/docs/reference/index/interfaces/FilterFn.md @@ -5,7 +5,7 @@ title: FilterFn # Interface: FilterFn()\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:59](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L59) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:60](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L60) ## Type Parameters @@ -25,7 +25,7 @@ FilterFn( addMeta?): boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:63](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L63) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:64](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L64) ## Parameters @@ -57,7 +57,24 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:63](https optional autoRemove: ColumnFilterAutoRemoveTestFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L69) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:74](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L74) + +Removes the filter from `state.columnFilters` when the filter value fails +this test (e.g. empty strings for text filters). + +*** + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:87](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L87) + +Normalizes each row's value before it is compared against the filter +value. Only honored by filter functions built with `constructFilterFn` +(including all built-in filter functions). *** @@ -67,4 +84,9 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:69](https optional resolveFilterValue: TransformFilterValueFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:70](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L70) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:81](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L81) + +Normalizes the filter value before filtering runs. + +The table applies this once per filter (not per row) and passes the +resolved value to the filter function as `filterValue`. diff --git a/docs/reference/index/interfaces/FilterFnDef.md b/docs/reference/index/interfaces/FilterFnDef.md new file mode 100644 index 0000000000..6300677fd3 --- /dev/null +++ b/docs/reference/index/interfaces/FilterFnDef.md @@ -0,0 +1,114 @@ +--- +id: FilterFnDef +title: FilterFnDef +--- + +# Interface: FilterFnDef\ + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:97](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L97) + +The definition object accepted by `constructFilterFn`. + +`filter` is a value-level comparator: it receives the row's (resolved) data +value and the (resolved) filter value instead of the whole row, so +normalization concerns stay in `resolveDataValue`/`resolveFilterValue`. + +## Extended by + +- [`CreatedFilterFn`](CreatedFilterFn.md) + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Properties + +### autoRemove()? + +```ts +optional autoRemove: (filterValue) => boolean; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:108](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L108) + +#### Parameters + +##### filterValue + +`any` + +#### Returns + +`boolean` + +*** + +### filter() + +```ts +filter: (dataValue, filterValue, row, columnId, addMeta?) => boolean; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:101](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L101) + +#### Parameters + +##### dataValue + +`any` + +##### filterValue + +`any` + +##### row + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### columnId + +`string` + +##### addMeta? + +(`meta`) => `void` + +#### Returns + +`boolean` + +*** + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:110](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L110) + +*** + +### resolveFilterValue()? + +```ts +optional resolveFilterValue: (filterValue) => any; +``` + +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:109](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L109) + +#### Parameters + +##### filterValue + +`any` + +#### Returns + +`any` diff --git a/docs/reference/index/interfaces/FilterFns.md b/docs/reference/index/interfaces/FilterFns.md index 083f94510e..af42009df3 100644 --- a/docs/reference/index/interfaces/FilterFns.md +++ b/docs/reference/index/interfaces/FilterFns.md @@ -5,4 +5,4 @@ title: FilterFns # Interface: FilterFns -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:30](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L30) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:31](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L31) diff --git a/docs/reference/index/interfaces/FilterMeta.md b/docs/reference/index/interfaces/FilterMeta.md index 792b8724c4..75b2577be3 100644 --- a/docs/reference/index/interfaces/FilterMeta.md +++ b/docs/reference/index/interfaces/FilterMeta.md @@ -5,4 +5,4 @@ title: FilterMeta # Interface: FilterMeta -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:13](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L13) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L14) diff --git a/docs/reference/index/interfaces/ResolvedColumnFilter.md b/docs/reference/index/interfaces/ResolvedColumnFilter.md index 22c439628a..19056db237 100644 --- a/docs/reference/index/interfaces/ResolvedColumnFilter.md +++ b/docs/reference/index/interfaces/ResolvedColumnFilter.md @@ -5,7 +5,7 @@ title: ResolvedColumnFilter # Interface: ResolvedColumnFilter\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:43](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L43) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:44](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L44) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:43](https filterFn: FilterFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:47](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L47) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:48](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L48) *** @@ -35,7 +35,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:47](https id: string; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:48](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L48) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:49](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L49) *** @@ -45,4 +45,4 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:48](https resolvedValue: unknown; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:49](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L49) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:50](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L50) diff --git a/docs/reference/index/interfaces/RowModelFns_All.md b/docs/reference/index/interfaces/RowModelFns_All.md index 036906aef0..045b77ed11 100644 --- a/docs/reference/index/interfaces/RowModelFns_All.md +++ b/docs/reference/index/interfaces/RowModelFns_All.md @@ -29,7 +29,7 @@ Defined in: [types/RowModelFns.ts:25](https://github.com/TanStack/table/blob/mai optional aggregationFns: Record>; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L24) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:25](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L25) #### Inherited from @@ -45,7 +45,7 @@ Partial.aggregationFns optional filterFns: Record>; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:56](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L56) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:57](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L57) #### Inherited from @@ -61,7 +61,7 @@ Partial.filterFns optional sortFns: Record>; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L24) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:29](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L29) #### Inherited from diff --git a/docs/reference/index/interfaces/RowModelFns_ColumnFiltering.md b/docs/reference/index/interfaces/RowModelFns_ColumnFiltering.md index 34ce0d7c18..b0cd371dbe 100644 --- a/docs/reference/index/interfaces/RowModelFns_ColumnFiltering.md +++ b/docs/reference/index/interfaces/RowModelFns_ColumnFiltering.md @@ -5,7 +5,7 @@ title: RowModelFns_ColumnFiltering # Interface: RowModelFns\_ColumnFiltering\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:52](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L52) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:53](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L53) ## Type Parameters @@ -25,4 +25,4 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:52](https filterFns: Record>; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:56](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L56) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:57](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L57) diff --git a/docs/reference/index/interfaces/RowModelFns_ColumnGrouping.md b/docs/reference/index/interfaces/RowModelFns_ColumnGrouping.md index 228ca5581b..4f85abfc53 100644 --- a/docs/reference/index/interfaces/RowModelFns_ColumnGrouping.md +++ b/docs/reference/index/interfaces/RowModelFns_ColumnGrouping.md @@ -5,7 +5,7 @@ title: RowModelFns_ColumnGrouping # Interface: RowModelFns\_ColumnGrouping\ -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:20](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L20) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:21](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L21) ## Type Parameters @@ -25,4 +25,4 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:20](https:/ aggregationFns: Record>; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L24) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:25](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L25) diff --git a/docs/reference/index/interfaces/RowModelFns_RowSorting.md b/docs/reference/index/interfaces/RowModelFns_RowSorting.md index 4a0246ba59..b0110dff94 100644 --- a/docs/reference/index/interfaces/RowModelFns_RowSorting.md +++ b/docs/reference/index/interfaces/RowModelFns_RowSorting.md @@ -5,7 +5,7 @@ title: RowModelFns_RowSorting # Interface: RowModelFns\_RowSorting\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:20](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L20) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:25](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L25) ## Type Parameters @@ -25,4 +25,4 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:20](https://github. sortFns: Record>; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L24) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:29](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L29) diff --git a/docs/reference/index/interfaces/Row_ColumnFiltering.md b/docs/reference/index/interfaces/Row_ColumnFiltering.md index 68327d38e8..144728d0e7 100644 --- a/docs/reference/index/interfaces/Row_ColumnFiltering.md +++ b/docs/reference/index/interfaces/Row_ColumnFiltering.md @@ -5,7 +5,7 @@ title: Row_ColumnFiltering # Interface: Row\_ColumnFiltering\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:166](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L166) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L226) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:166](http columnFilters: Record; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:173](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L173) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:233](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L233) The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID. @@ -37,6 +37,6 @@ The column filters map for the row. This object tracks whether a row is passing/ columnFiltersMeta: Record>; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:177](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L177) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:237](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L237) The column filters meta map for the row. This object tracks any filter meta for a row as optionally provided during the filtering process. diff --git a/docs/reference/index/interfaces/Row_ColumnGrouping.md b/docs/reference/index/interfaces/Row_ColumnGrouping.md index 0e0872bf30..65d438b0d0 100644 --- a/docs/reference/index/interfaces/Row_ColumnGrouping.md +++ b/docs/reference/index/interfaces/Row_ColumnGrouping.md @@ -5,7 +5,7 @@ title: Row_ColumnGrouping # Interface: Row\_ColumnGrouping -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L136) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:191](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L191) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:136](https: _groupingValuesCache: Record; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L137) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:192](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L192) *** @@ -25,7 +25,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:137](https: getGroupingValue: (columnId) => unknown; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:141](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L141) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:196](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L196) Reads the value used to group this row for a column id. @@ -47,7 +47,7 @@ Reads the value used to group this row for a column id. getIsGrouped: () => boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:145](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L145) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:200](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L200) Checks whether this row represents a grouped row. @@ -63,7 +63,7 @@ Checks whether this row represents a grouped row. optional groupingColumnId: string; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L149) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:204](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L204) If this row is grouped, this is the id of the column that this row is grouped by. @@ -75,6 +75,6 @@ If this row is grouped, this is the id of the column that this row is grouped by optional groupingValue: unknown; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:153](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L153) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:208](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L208) If this row is grouped, this is the unique/shared value for the `groupingColumnId` for all of the rows in this group. diff --git a/docs/reference/index/interfaces/SortFn.md b/docs/reference/index/interfaces/SortFn.md index ee7c5ff348..b2ce792bc6 100644 --- a/docs/reference/index/interfaces/SortFn.md +++ b/docs/reference/index/interfaces/SortFn.md @@ -5,7 +5,7 @@ title: SortFn # Interface: SortFn()\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:29](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L29) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L34) ## Type Parameters @@ -24,7 +24,7 @@ SortFn( columnId): number; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:33](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L33) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:38](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L38) ## Parameters @@ -43,3 +43,17 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:33](https://github. ## Returns `number` + +## Properties + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:48](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L48) + +Normalizes each row's value before the two sides are compared. Only +honored by sorting functions built with `constructSortFn` (including all +built-in sorting functions). diff --git a/docs/reference/index/interfaces/SortFnDef.md b/docs/reference/index/interfaces/SortFnDef.md new file mode 100644 index 0000000000..dbaafac6d8 --- /dev/null +++ b/docs/reference/index/interfaces/SortFnDef.md @@ -0,0 +1,74 @@ +--- +id: SortFnDef +title: SortFnDef +--- + +# Interface: SortFnDef\ + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:58](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L58) + +The definition object accepted by `constructSortFn`. + +`sort` is a value-level comparator: it receives both rows' (resolved) data +values instead of the whole rows, so normalization concerns stay in +`resolveDataValue`. + +## Extended by + +- [`CreatedSortFn`](CreatedSortFn.md) + +## Type Parameters + +### TFeatures + +`TFeatures` *extends* [`TableFeatures`](TableFeatures.md) + +### TData + +`TData` *extends* [`RowData`](../type-aliases/RowData.md) + +## Properties + +### resolveDataValue? + +```ts +optional resolveDataValue: TransformDataValueFn; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L69) + +*** + +### sort() + +```ts +sort: (dataValueA, dataValueB, rowA, rowB, columnId) => number; +``` + +Defined in: [features/row-sorting/rowSortingFeature.types.ts:62](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L62) + +#### Parameters + +##### dataValueA + +`any` + +##### dataValueB + +`any` + +##### rowA + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### rowB + +[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> + +##### columnId + +`string` + +#### Returns + +`number` diff --git a/docs/reference/index/interfaces/SortFns.md b/docs/reference/index/interfaces/SortFns.md index 8c42d56be2..5d7293009e 100644 --- a/docs/reference/index/interfaces/SortFns.md +++ b/docs/reference/index/interfaces/SortFns.md @@ -5,4 +5,4 @@ title: SortFns # Interface: SortFns -Defined in: [features/row-sorting/rowSortingFeature.types.ts:27](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L27) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:32](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L32) diff --git a/docs/reference/index/interfaces/TableFeature.md b/docs/reference/index/interfaces/TableFeature.md index 789458151c..637022ab06 100644 --- a/docs/reference/index/interfaces/TableFeature.md +++ b/docs/reference/index/interfaces/TableFeature.md @@ -5,7 +5,7 @@ title: TableFeature # Interface: TableFeature -Defined in: [types/TableFeatures.ts:308](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L308) +Defined in: [types/TableFeatures.ts:316](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L316) Lifecycle hooks and defaults contributed by a table feature. @@ -22,7 +22,7 @@ or column data. optional assignCellPrototype: (prototype, table) => void; ``` -Defined in: [types/TableFeatures.ts:317](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L317) +Defined in: [types/TableFeatures.ts:325](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L325) Adds feature methods to the shared cell prototype for a table. @@ -63,7 +63,7 @@ per-cell mutable data. optional assignColumnPrototype: (prototype, table) => void; ``` -Defined in: [types/TableFeatures.ts:332](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L332) +Defined in: [types/TableFeatures.ts:340](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L340) Adds feature methods to the shared column prototype for a table. @@ -104,7 +104,7 @@ than per-column mutable data. optional assignHeaderPrototype: (prototype, table) => void; ``` -Defined in: [types/TableFeatures.ts:347](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L347) +Defined in: [types/TableFeatures.ts:355](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L355) Adds feature methods to the shared header prototype for a table. @@ -145,7 +145,7 @@ than per-header mutable data. optional assignRowPrototype: (prototype, table) => void; ``` -Defined in: [types/TableFeatures.ts:362](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L362) +Defined in: [types/TableFeatures.ts:370](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L370) Adds feature methods to the shared row prototype for a table. @@ -186,7 +186,7 @@ mutable data. optional constructTableAPIs: (table) => void; ``` -Defined in: [types/TableFeatures.ts:375](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L375) +Defined in: [types/TableFeatures.ts:383](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L383) Adds feature APIs directly to the table instance. @@ -224,7 +224,7 @@ feature's `initTableInstanceData` hook has completed. optional getDefaultColumnDef: () => ColumnDefBase_All; ``` -Defined in: [types/TableFeatures.ts:385](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L385) +Defined in: [types/TableFeatures.ts:393](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L393) Returns default column definition options contributed by this feature. @@ -258,7 +258,7 @@ resolved, so users can override values supplied here. optional getDefaultTableOptions: (table) => Partial>; ``` -Defined in: [types/TableFeatures.ts:398](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L398) +Defined in: [types/TableFeatures.ts:406](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L406) Returns default table options contributed by this feature. @@ -295,7 +295,7 @@ here. optional getInitialState: (initialState) => TableState_All; ``` -Defined in: [types/TableFeatures.ts:412](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L412) +Defined in: [types/TableFeatures.ts:420](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L420) Returns this feature's initial table state. @@ -322,7 +322,7 @@ override feature defaults. optional initColumnInstanceData: (column) => void; ``` -Defined in: [types/TableFeatures.ts:437](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L437) +Defined in: [types/TableFeatures.ts:445](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L445) Initializes instance-specific data on each column. @@ -363,7 +363,7 @@ methods should be assigned via `assignColumnPrototype` instead. optional initRowInstanceData: (row) => void; ``` -Defined in: [types/TableFeatures.ts:452](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L452) +Defined in: [types/TableFeatures.ts:460](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L460) Initializes instance-specific data on each row. @@ -400,7 +400,7 @@ should be assigned via `assignRowPrototype` instead. optional initTableInstanceData: (table) => void; ``` -Defined in: [types/TableFeatures.ts:423](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L423) +Defined in: [types/TableFeatures.ts:431](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L431) Initializes mutable, non-reactive data owned by this feature on the table instance. @@ -439,7 +439,7 @@ methods. Table resets do not rerun this hook; use optional resetTableInstanceData: (table) => void; ``` -Defined in: [types/TableFeatures.ts:465](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L465) +Defined in: [types/TableFeatures.ts:473](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L473) Resets mutable, non-reactive table-instance data owned by this feature. diff --git a/docs/reference/index/interfaces/TableFeatures.md b/docs/reference/index/interfaces/TableFeatures.md index f39bbba623..3e6bc81f0a 100644 --- a/docs/reference/index/interfaces/TableFeatures.md +++ b/docs/reference/index/interfaces/TableFeatures.md @@ -27,14 +27,16 @@ options, and state types. optional aggregationFns: Record>; ``` -Defined in: [types/TableFeatures.ts:191](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L191) +Defined in: [types/TableFeatures.ts:193](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L193) Registry of aggregation functions available to this table by name. Keys registered here become the valid string values for `aggregationFn` on -column definitions, with full inference. Spread the exported -`aggregationFns` to register the built-in aggregation functions: -`aggregationFns: { ...aggregationFns, myCustomAggregationFn }`. +column definitions, with full inference. Import the built-in aggregation +functions you use individually and register them by their conventional +names: `aggregationFns: { sum: aggregationFn_sum, myCustomAggregationFn }`. +Spreading the exported `aggregationFns` registry also works, but puts +every built-in aggregation function in your bundle. *** @@ -86,7 +88,7 @@ Defined in: [features/stockFeatures.ts:19](https://github.com/TanStack/table/blo optional columnMeta: object; ``` -Defined in: [types/TableFeatures.ts:202](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L202) +Defined in: [types/TableFeatures.ts:204](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L204) Type-only slot for declaring the type of `columnDef.meta` for all columns of this table. @@ -231,7 +233,7 @@ Defined in: [core/coreFeatures.ts:10](https://github.com/TanStack/table/blob/mai optional coreRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:207](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L207) +Defined in: [types/TableFeatures.ts:209](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L209) Factory for the table's core (unmodified) row model. Defaults to the built-in `createCoreRowModel()` when omitted. @@ -302,7 +304,7 @@ Defined in: [core/coreFeatures.ts:16](https://github.com/TanStack/table/blob/mai optional expandedRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:213](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L213) +Defined in: [types/TableFeatures.ts:215](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L215) Factory for the client-side expanded row model. Pass the exported `createExpandedRowModel()` or implement your own. Not needed for @@ -332,7 +334,7 @@ server-side expansion. optional facetedMinMaxValues: (table, columnId) => () => [number, number] | undefined; ``` -Defined in: [types/TableFeatures.ts:219](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L219) +Defined in: [types/TableFeatures.ts:221](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L221) Factory for per-column faceted min/max values. Pass the exported `createFacetedMinMaxValues()` or implement your own. Not needed for @@ -366,7 +368,7 @@ server-side faceting. optional facetedRowModel: (table, columnId) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L228) +Defined in: [types/TableFeatures.ts:230](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L230) Factory for the per-column faceted row model. Pass the exported `createFacetedRowModel()` or implement your own. Not needed for @@ -400,7 +402,7 @@ server-side faceting. optional facetedUniqueValues: (table, columnId) => () => Map; ``` -Defined in: [types/TableFeatures.ts:234](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L234) +Defined in: [types/TableFeatures.ts:236](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L236) Factory for per-column faceted unique values. Pass the exported `createFacetedUniqueValues()` or implement your own. Not needed for @@ -434,7 +436,7 @@ server-side faceting. optional filteredRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L240) +Defined in: [types/TableFeatures.ts:242](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L242) Factory for the client-side filtered row model. Pass the exported `createFilteredRowModel()` or implement your own. Not needed for @@ -464,14 +466,17 @@ server-side filtering. optional filterFns: Record>; ``` -Defined in: [types/TableFeatures.ts:249](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L249) +Defined in: [types/TableFeatures.ts:254](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L254) Registry of filter functions available to this table by name. Keys registered here become the valid string values for `filterFn` on column definitions and the `globalFilterFn` option, with full inference. -Spread the exported `filterFns` to register the built-in filter functions: -`filterFns: { ...filterFns, myCustomFilterFn }`. +Import the built-in filter functions you use individually and register +them by their conventional names: +`filterFns: { includesString: filterFn_includesString, myCustomFilterFn }`. +Spreading the exported `filterFns` registry also works, but puts every +built-in filter function in your bundle. *** @@ -481,7 +486,7 @@ Spread the exported `filterFns` to register the built-in filter functions: optional filterMeta: object; ``` -Defined in: [types/TableFeatures.ts:261](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L261) +Defined in: [types/TableFeatures.ts:266](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L266) Type-only slot for declaring the type of the filter meta that filter functions attach to rows via `addMeta` and that is read back from @@ -515,7 +520,7 @@ Defined in: [features/stockFeatures.ts:25](https://github.com/TanStack/table/blo optional groupedRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:267](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L267) +Defined in: [types/TableFeatures.ts:272](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L272) Factory for the client-side grouped row model. Pass the exported `createGroupedRowModel()` or implement your own. Not needed for @@ -545,7 +550,7 @@ server-side grouping. optional paginatedRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:273](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L273) +Defined in: [types/TableFeatures.ts:278](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L278) Factory for the client-side paginated row model. Pass the exported `createPaginatedRowModel()` or implement your own. Not needed for @@ -645,7 +650,7 @@ Defined in: [features/stockFeatures.ts:30](https://github.com/TanStack/table/blo optional sortedRowModel: (table) => () => RowModel; ``` -Defined in: [types/TableFeatures.ts:279](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L279) +Defined in: [types/TableFeatures.ts:284](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L284) Factory for the client-side sorted row model. Pass the exported `createSortedRowModel()` or implement your own. Not needed for @@ -675,13 +680,16 @@ server-side sorting. optional sortFns: Record>; ``` -Defined in: [types/TableFeatures.ts:287](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L287) +Defined in: [types/TableFeatures.ts:295](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L295) Registry of sorting functions available to this table by name. Keys registered here become the valid string values for `sortFn` on column -definitions, with full inference. Spread the exported `sortFns` to register -the built-in sorting functions: `sortFns: { ...sortFns, myCustomSortFn }`. +definitions, with full inference. Import the built-in sorting functions +you use individually and register them by their conventional names: +`sortFns: { alphanumeric: sortFn_alphanumeric, myCustomSortFn }`. Spreading +the exported `sortFns` registry also works, but puts every built-in +sorting function in your bundle. *** @@ -691,7 +699,7 @@ the built-in sorting functions: `sortFns: { ...sortFns, myCustomSortFn }`. optional tableMeta: object; ``` -Defined in: [types/TableFeatures.ts:297](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L297) +Defined in: [types/TableFeatures.ts:305](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/TableFeatures.ts#L305) Type-only slot for declaring the type of this table's `options.meta`. diff --git a/docs/reference/index/interfaces/TableOptions_ColumnFiltering.md b/docs/reference/index/interfaces/TableOptions_ColumnFiltering.md index e472179597..2d959e1f6a 100644 --- a/docs/reference/index/interfaces/TableOptions_ColumnFiltering.md +++ b/docs/reference/index/interfaces/TableOptions_ColumnFiltering.md @@ -5,7 +5,7 @@ title: TableOptions_ColumnFiltering # Interface: TableOptions\_ColumnFiltering\<_TFeatures, _TData\> -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L180) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L240) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:180](http optional enableColumnFilters: boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:187](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L187) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:247](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L247) Enables column-specific filtering for all columns that also allow it. @@ -37,7 +37,7 @@ Enables column-specific filtering for all columns that also allow it. optional enableFilters: boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:193](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L193) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:253](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L253) Enables all filtering features for the table. @@ -51,7 +51,7 @@ Set this to `false` to disable both column filtering and global filtering. optional filterFromLeafRows: boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:197](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L197) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:257](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L257) By default, filtering is done from parent rows down (so if a parent row is filtered out, all of its children will be filtered out as well). Setting this option to `true` will cause filtering to be done from leaf rows up (which means parent rows will be included so long as one of their child or grand-child rows is also included). @@ -63,7 +63,7 @@ By default, filtering is done from parent rows down (so if a parent row is filte optional manualFiltering: boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:201](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L201) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:261](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L261) Disables the `getFilteredRowModel` from being used to filter data. This may be useful if your table needs to dynamically support both client-side and server-side filtering. @@ -75,7 +75,7 @@ Disables the `getFilteredRowModel` from being used to filter data. This may be u optional maxLeafRowFilterDepth: number; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:207](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L207) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:267](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L267) By default, filtering is done for all rows (max depth of 100), no matter if they are root level parent rows or the child leaf rows of a parent row. Setting this option to `0` will cause filtering to only be applied to the root level parent rows, with all sub-rows remaining unfiltered. Similarly, setting this option to `1` will cause filtering to only be applied to child leaf rows 1 level deep, and so on. @@ -89,7 +89,7 @@ This is useful for situations where you want a row's entire child hierarchy to b optional onColumnFiltersChange: OnChangeFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:213](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L213) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:273](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L273) Called with an updater when column filter state changes. Pair this with `state.columnFilters` when using external state; external atoms can own the diff --git a/docs/reference/index/interfaces/TableOptions_ColumnGrouping.md b/docs/reference/index/interfaces/TableOptions_ColumnGrouping.md index 4b35bf80dd..c1cfaf2ad8 100644 --- a/docs/reference/index/interfaces/TableOptions_ColumnGrouping.md +++ b/docs/reference/index/interfaces/TableOptions_ColumnGrouping.md @@ -5,7 +5,7 @@ title: TableOptions_ColumnGrouping # Interface: TableOptions\_ColumnGrouping -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:176](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L176) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:231](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L231) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:176](https: optional enableGrouping: boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L180) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:235](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L235) Allows columns to be grouped for this table. @@ -27,7 +27,7 @@ Allows columns to be grouped for this table. optional groupedColumnMode: false | "reorder" | "remove"; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:184](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L184) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:239](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L239) Grouping columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here. @@ -39,7 +39,7 @@ Grouping columns are automatically reordered by default to the start of the colu optional manualGrouping: boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:188](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L188) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:243](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L243) Enables manual grouping. If this option is set to `true`, the table will not automatically group rows using `getGroupedRowModel()` and instead will expect you to manually group the rows before passing them to the table. This is useful if you are doing server-side grouping and aggregation. @@ -51,7 +51,7 @@ Enables manual grouping. If this option is set to `true`, the table will not aut optional onGroupingChange: OnChangeFn; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:194](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L194) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:249](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L249) Called with an updater when grouping state changes. Pair this with `state.grouping` when using external state; external atoms can own the diff --git a/docs/reference/index/interfaces/TableOptions_RowSorting.md b/docs/reference/index/interfaces/TableOptions_RowSorting.md index 4e91f07578..12e0bf8d8f 100644 --- a/docs/reference/index/interfaces/TableOptions_RowSorting.md +++ b/docs/reference/index/interfaces/TableOptions_RowSorting.md @@ -5,7 +5,7 @@ title: TableOptions_RowSorting # Interface: TableOptions\_RowSorting -Defined in: [features/row-sorting/rowSortingFeature.types.ts:158](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L158) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:210](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L210) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:158](https://github optional enableMultiRemove: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:162](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L162) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:214](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L214) Allows multi-sort toggles to remove a column from sorting state. @@ -27,7 +27,7 @@ Allows multi-sort toggles to remove a column from sorting state. optional enableMultiSort: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:166](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L166) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:218](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L218) Enables/Disables multi-sorting for the table. @@ -39,7 +39,7 @@ Enables/Disables multi-sorting for the table. optional enableSorting: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:170](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L170) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L222) Enables/Disables sorting for the table. @@ -51,7 +51,7 @@ Enables/Disables sorting for the table. optional enableSortingRemoval: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:176](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L176) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L228) Enables/Disables the ability to remove sorting for the table. - If `true` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ... @@ -65,7 +65,7 @@ Enables/Disables the ability to remove sorting for the table. optional isMultiSortEvent: (e) => boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:180](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L180) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:232](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L232) Pass a custom function that will be used to determine if a multi-sort event should be triggered. It is passed the event from the sort toggle handler and should return `true` if the event should trigger a multi-sort. @@ -87,7 +87,7 @@ Pass a custom function that will be used to determine if a multi-sort event shou optional manualSorting: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:184](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L184) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:236](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L236) Enables manual sorting for the table. If this is `true`, you will be expected to sort your data before it is passed to the table. This is useful if you are doing server-side sorting. @@ -99,7 +99,7 @@ Enables manual sorting for the table. If this is `true`, you will be expected to optional maxMultiSortColCount: number; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:188](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L188) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L240) Set a maximum number of columns that can be multi-sorted. @@ -111,7 +111,7 @@ Set a maximum number of columns that can be multi-sorted. optional onSortingChange: OnChangeFn; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:194](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L194) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:246](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L246) Called with an updater when sorting state changes. Pair this with `state.sorting` when using external state; external atoms can own the slice @@ -125,6 +125,6 @@ without this callback. optional sortDescFirst: boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:198](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L198) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:250](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L250) If `true`, all sorts will default to descending as their first toggle state. diff --git a/docs/reference/index/interfaces/TableState_All.md b/docs/reference/index/interfaces/TableState_All.md index c2701aa8de..c652f9e88d 100644 --- a/docs/reference/index/interfaces/TableState_All.md +++ b/docs/reference/index/interfaces/TableState_All.md @@ -24,7 +24,7 @@ by other features. optional columnFilters: ColumnFiltersState; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:33](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L33) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L34) #### Inherited from @@ -136,7 +136,7 @@ Defined in: [features/global-filtering/globalFilteringFeature.types.ts:15](https optional grouping: GroupingState; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L17) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:18](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L18) #### Inherited from @@ -192,7 +192,7 @@ Defined in: [features/row-selection/rowSelectionFeature.types.ts:20](https://git optional sorting: SortingState; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L17) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:22](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L22) #### Inherited from diff --git a/docs/reference/index/interfaces/TableState_ColumnFiltering.md b/docs/reference/index/interfaces/TableState_ColumnFiltering.md index 294dfea629..ca1de51e5a 100644 --- a/docs/reference/index/interfaces/TableState_ColumnFiltering.md +++ b/docs/reference/index/interfaces/TableState_ColumnFiltering.md @@ -5,7 +5,7 @@ title: TableState_ColumnFiltering # Interface: TableState\_ColumnFiltering -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:32](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L32) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:33](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L33) ## Properties @@ -15,4 +15,4 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:32](https columnFilters: ColumnFiltersState; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:33](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L33) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:34](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L34) diff --git a/docs/reference/index/interfaces/TableState_ColumnGrouping.md b/docs/reference/index/interfaces/TableState_ColumnGrouping.md index c067ee5eb7..ab7605d5ef 100644 --- a/docs/reference/index/interfaces/TableState_ColumnGrouping.md +++ b/docs/reference/index/interfaces/TableState_ColumnGrouping.md @@ -5,7 +5,7 @@ title: TableState_ColumnGrouping # Interface: TableState\_ColumnGrouping -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:16](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L16) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L17) ## Properties @@ -15,4 +15,4 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:16](https:/ grouping: GroupingState; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L17) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:18](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L18) diff --git a/docs/reference/index/interfaces/TableState_RowSorting.md b/docs/reference/index/interfaces/TableState_RowSorting.md index d4b554d9b1..a9b1dce5ca 100644 --- a/docs/reference/index/interfaces/TableState_RowSorting.md +++ b/docs/reference/index/interfaces/TableState_RowSorting.md @@ -5,7 +5,7 @@ title: TableState_RowSorting # Interface: TableState\_RowSorting -Defined in: [features/row-sorting/rowSortingFeature.types.ts:16](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L16) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:21](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L21) ## Properties @@ -15,4 +15,4 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:16](https://github. sorting: SortingState; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L17) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:22](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L22) diff --git a/docs/reference/index/interfaces/Table_ColumnFiltering.md b/docs/reference/index/interfaces/Table_ColumnFiltering.md index 2f446b00ca..c8e6f567e2 100644 --- a/docs/reference/index/interfaces/Table_ColumnFiltering.md +++ b/docs/reference/index/interfaces/Table_ColumnFiltering.md @@ -5,7 +5,7 @@ title: Table_ColumnFiltering # Interface: Table\_ColumnFiltering -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:216](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L216) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:276](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L276) ## Properties @@ -15,7 +15,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:216](http resetColumnFilters: (defaultState?) => void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L222) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:282](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L282) Resets `columnFilters` to `initialState.columnFilters`. @@ -39,7 +39,7 @@ Pass `true` to ignore initial state and reset to `[]`. setColumnFilters: (updater) => void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L226) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:286](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L286) Updates column filter state with a next array or updater function. diff --git a/docs/reference/index/interfaces/Table_ColumnGrouping.md b/docs/reference/index/interfaces/Table_ColumnGrouping.md index b9d2923af4..65b8349d60 100644 --- a/docs/reference/index/interfaces/Table_ColumnGrouping.md +++ b/docs/reference/index/interfaces/Table_ColumnGrouping.md @@ -5,7 +5,7 @@ title: Table_ColumnGrouping # Interface: Table\_ColumnGrouping\<_TFeatures, _TData\> -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:199](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L199) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:254](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L254) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:199](https: resetGrouping: (defaultState?) => void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:208](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L208) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:263](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L263) Resets `grouping` to `initialState.grouping`. @@ -49,7 +49,7 @@ Pass `true` to ignore initial state and reset to `[]`. setGrouping: (updater) => void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:212](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L212) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:267](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L267) Updates grouping state with a next ordered id array or updater function. diff --git a/docs/reference/index/interfaces/Table_Core.md b/docs/reference/index/interfaces/Table_Core.md index 54bd19a957..3fab0987bb 100644 --- a/docs/reference/index/interfaces/Table_Core.md +++ b/docs/reference/index/interfaces/Table_Core.md @@ -460,7 +460,7 @@ Table_RowModels.getFacetedUniqueValues getFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:236](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L236) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:296](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L296) Resolves the row model after column and global filters have been applied. @@ -523,7 +523,7 @@ Builds footer groups by reversing the current header group order. getGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L222) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:277](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L277) Resolves the row model after grouping and aggregation have been applied. @@ -630,7 +630,7 @@ Table_RowModels.getPreExpandedRowModel getPreFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L240) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:300](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L300) Reads the row model immediately before filtering. @@ -652,7 +652,7 @@ Table_RowModels.getPreFilteredRowModel getPreGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L226) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:281](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L281) Reads the row model immediately before grouping. @@ -696,7 +696,7 @@ Table_RowModels.getPrePaginatedRowModel getPreSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:224](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L224) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:276](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L276) Reads the row model immediately before sorting. @@ -825,7 +825,7 @@ included in this order. This is the memoized source for getSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L228) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:280](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L280) Resolves the row model after sorting has been applied. diff --git a/docs/reference/index/interfaces/Table_Internal.md b/docs/reference/index/interfaces/Table_Internal.md index e29a2dd037..72bc765b9c 100644 --- a/docs/reference/index/interfaces/Table_Internal.md +++ b/docs/reference/index/interfaces/Table_Internal.md @@ -453,7 +453,7 @@ Table_RowModels.getFacetedUniqueValues getFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:236](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L236) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:296](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L296) Resolves the row model after column and global filters have been applied. @@ -516,7 +516,7 @@ Builds footer groups by reversing the current header group order. getGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L222) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:277](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L277) Resolves the row model after grouping and aggregation have been applied. @@ -623,7 +623,7 @@ Table_RowModels.getPreExpandedRowModel getPreFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L240) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:300](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L300) Reads the row model immediately before filtering. @@ -645,7 +645,7 @@ Table_RowModels.getPreFilteredRowModel getPreGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L226) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:281](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L281) Reads the row model immediately before grouping. @@ -689,7 +689,7 @@ Table_RowModels.getPrePaginatedRowModel getPreSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:224](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L224) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:276](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L276) Reads the row model immediately before sorting. @@ -818,7 +818,7 @@ included in this order. This is the memoized source for getSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L228) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:280](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L280) Resolves the row model after sorting has been applied. diff --git a/docs/reference/index/interfaces/Table_RowModels_Filtered.md b/docs/reference/index/interfaces/Table_RowModels_Filtered.md index fb40c79ab8..71ecc03862 100644 --- a/docs/reference/index/interfaces/Table_RowModels_Filtered.md +++ b/docs/reference/index/interfaces/Table_RowModels_Filtered.md @@ -5,7 +5,7 @@ title: Table_RowModels_Filtered # Interface: Table\_RowModels\_Filtered\ -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:229](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L229) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:289](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L289) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-filtering/columnFilteringFeature.types.ts:229](http getFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:236](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L236) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:296](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L296) Resolves the row model after column and global filters have been applied. @@ -41,7 +41,7 @@ Resolves the row model after column and global filters have been applied. getPreFilteredRowModel: () => RowModel; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:240](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L240) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:300](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L300) Reads the row model immediately before filtering. diff --git a/docs/reference/index/interfaces/Table_RowModels_Grouped.md b/docs/reference/index/interfaces/Table_RowModels_Grouped.md index a07fc08167..33eacf4da1 100644 --- a/docs/reference/index/interfaces/Table_RowModels_Grouped.md +++ b/docs/reference/index/interfaces/Table_RowModels_Grouped.md @@ -5,7 +5,7 @@ title: Table_RowModels_Grouped # Interface: Table\_RowModels\_Grouped\ -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:215](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L215) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:270](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L270) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/column-grouping/columnGroupingFeature.types.ts:215](https: getGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L222) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:277](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L277) Resolves the row model after grouping and aggregation have been applied. @@ -41,7 +41,7 @@ Resolves the row model after grouping and aggregation have been applied. getPreGroupedRowModel: () => RowModel; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:226](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L226) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:281](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L281) Reads the row model immediately before grouping. diff --git a/docs/reference/index/interfaces/Table_RowModels_Sorted.md b/docs/reference/index/interfaces/Table_RowModels_Sorted.md index 2593fb9f64..138122c174 100644 --- a/docs/reference/index/interfaces/Table_RowModels_Sorted.md +++ b/docs/reference/index/interfaces/Table_RowModels_Sorted.md @@ -5,7 +5,7 @@ title: Table_RowModels_Sorted # Interface: Table\_RowModels\_Sorted\ -Defined in: [features/row-sorting/rowSortingFeature.types.ts:217](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L217) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:269](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L269) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:217](https://github getPreSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:224](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L224) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:276](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L276) Reads the row model immediately before sorting. @@ -41,7 +41,7 @@ Reads the row model immediately before sorting. getSortedRowModel: () => RowModel; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:228](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L228) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:280](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L280) Resolves the row model after sorting has been applied. diff --git a/docs/reference/index/interfaces/Table_RowSorting.md b/docs/reference/index/interfaces/Table_RowSorting.md index 321e768237..25f1ea880e 100644 --- a/docs/reference/index/interfaces/Table_RowSorting.md +++ b/docs/reference/index/interfaces/Table_RowSorting.md @@ -5,7 +5,7 @@ title: Table_RowSorting # Interface: Table\_RowSorting\<_TFeatures, _TData\> -Defined in: [features/row-sorting/rowSortingFeature.types.ts:201](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L201) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:253](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L253) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [features/row-sorting/rowSortingFeature.types.ts:201](https://github resetSorting: (defaultState?) => void; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:210](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L210) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:262](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L262) Resets `sorting` to `initialState.sorting`. @@ -49,7 +49,7 @@ Pass `true` to ignore initial state and reset to `[]`. setSorting: (updater) => void; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:214](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L214) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:266](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L266) Updates sorting state with a next ordered array or updater function. diff --git a/docs/reference/index/type-aliases/AggregationFn.md b/docs/reference/index/type-aliases/AggregationFn.md deleted file mode 100644 index 84d4bb8d9a..0000000000 --- a/docs/reference/index/type-aliases/AggregationFn.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: AggregationFn -title: AggregationFn ---- - -# Type Alias: AggregationFn()\ - -```ts -type AggregationFn = (columnId, leafRows, childRows) => any; -``` - -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:29](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L29) - -## Type Parameters - -### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -### TData - -`TData` *extends* [`RowData`](RowData.md) - -## Parameters - -### columnId - -`string` - -### leafRows - -[`Row`](Row.md)\<`TFeatures`, `TData`\>[] - -### childRows - -[`Row`](Row.md)\<`TFeatures`, `TData`\>[] - -## Returns - -`any` diff --git a/docs/reference/index/type-aliases/AggregationFnOption.md b/docs/reference/index/type-aliases/AggregationFnOption.md index 60de1f82f7..08698bea8d 100644 --- a/docs/reference/index/type-aliases/AggregationFnOption.md +++ b/docs/reference/index/type-aliases/AggregationFnOption.md @@ -12,7 +12,7 @@ type AggregationFnOption = | AggregationFn; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:60](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L60) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:115](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L115) ## Type Parameters diff --git a/docs/reference/index/type-aliases/BuiltInAggregationFn.md b/docs/reference/index/type-aliases/BuiltInAggregationFn.md index 478e4eccf3..f85f0c1be5 100644 --- a/docs/reference/index/type-aliases/BuiltInAggregationFn.md +++ b/docs/reference/index/type-aliases/BuiltInAggregationFn.md @@ -9,4 +9,4 @@ title: BuiltInAggregationFn type BuiltInAggregationFn = keyof typeof aggregationFns; ``` -Defined in: [fns/aggregationFns.ts:245](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L245) +Defined in: [fns/aggregationFns.ts:303](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L303) diff --git a/docs/reference/index/type-aliases/BuiltInFilterFn.md b/docs/reference/index/type-aliases/BuiltInFilterFn.md index 498675ca6f..c9fe2ce8e1 100644 --- a/docs/reference/index/type-aliases/BuiltInFilterFn.md +++ b/docs/reference/index/type-aliases/BuiltInFilterFn.md @@ -9,4 +9,4 @@ title: BuiltInFilterFn type BuiltInFilterFn = keyof typeof filterFns; ``` -Defined in: [fns/filterFns.ts:446](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L446) +Defined in: [fns/filterFns.ts:455](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L455) diff --git a/docs/reference/index/type-aliases/BuiltInSortFn.md b/docs/reference/index/type-aliases/BuiltInSortFn.md index eb5c2f0ac0..ca0446f9cc 100644 --- a/docs/reference/index/type-aliases/BuiltInSortFn.md +++ b/docs/reference/index/type-aliases/BuiltInSortFn.md @@ -9,4 +9,4 @@ title: BuiltInSortFn type BuiltInSortFn = keyof typeof sortFns; ``` -Defined in: [fns/sortFns.ts:352](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L352) +Defined in: [fns/sortFns.ts:369](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L369) diff --git a/docs/reference/index/type-aliases/ColumnFilterAutoRemoveTestFn.md b/docs/reference/index/type-aliases/ColumnFilterAutoRemoveTestFn.md index 54b2d1c4a7..b317fb1ab7 100644 --- a/docs/reference/index/type-aliases/ColumnFilterAutoRemoveTestFn.md +++ b/docs/reference/index/type-aliases/ColumnFilterAutoRemoveTestFn.md @@ -9,7 +9,7 @@ title: ColumnFilterAutoRemoveTestFn type ColumnFilterAutoRemoveTestFn = (value, column?) => boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:79](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L79) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:139](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L139) ## Type Parameters diff --git a/docs/reference/index/type-aliases/ColumnFiltersState.md b/docs/reference/index/type-aliases/ColumnFiltersState.md index 617f12076d..64a5d33156 100644 --- a/docs/reference/index/type-aliases/ColumnFiltersState.md +++ b/docs/reference/index/type-aliases/ColumnFiltersState.md @@ -9,4 +9,4 @@ title: ColumnFiltersState type ColumnFiltersState = ColumnFilter[]; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:36](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L36) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:37](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L37) diff --git a/docs/reference/index/type-aliases/CustomAggregationFns.md b/docs/reference/index/type-aliases/CustomAggregationFns.md index 3db584aa24..6ff82f36d0 100644 --- a/docs/reference/index/type-aliases/CustomAggregationFns.md +++ b/docs/reference/index/type-aliases/CustomAggregationFns.md @@ -9,7 +9,7 @@ title: CustomAggregationFns type CustomAggregationFns = Record>; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:38](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L38) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:93](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L93) ## Type Parameters diff --git a/docs/reference/index/type-aliases/CustomFilterFns.md b/docs/reference/index/type-aliases/CustomFilterFns.md index 14ce591da9..e676660d68 100644 --- a/docs/reference/index/type-aliases/CustomFilterFns.md +++ b/docs/reference/index/type-aliases/CustomFilterFns.md @@ -9,7 +9,7 @@ title: CustomFilterFns type CustomFilterFns = Record>; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:85](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L85) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:145](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L145) ## Type Parameters diff --git a/docs/reference/index/type-aliases/CustomSortFns.md b/docs/reference/index/type-aliases/CustomSortFns.md index 58bc46e2d4..d7bca79e0e 100644 --- a/docs/reference/index/type-aliases/CustomSortFns.md +++ b/docs/reference/index/type-aliases/CustomSortFns.md @@ -9,7 +9,7 @@ title: CustomSortFns type CustomSortFns = Record>; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:40](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L40) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:92](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L92) ## Type Parameters diff --git a/docs/reference/index/type-aliases/DeepKeys.md b/docs/reference/index/type-aliases/DeepKeys.md index 492a70f0ca..6798bde81f 100644 --- a/docs/reference/index/type-aliases/DeepKeys.md +++ b/docs/reference/index/type-aliases/DeepKeys.md @@ -11,7 +11,7 @@ type DeepKeys = TDepth["length"] extends 5 ? never : unknown extends | DeepKeysPrefix, TDepth> : T extends any[] ? DeepKeys : T extends Date ? never : T extends object ? keyof T & string | DeepKeysPrefix : never; ``` -Defined in: [types/type-utils.ts:46](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L46) +Defined in: [types/type-utils.ts:54](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L54) ## Type Parameters diff --git a/docs/reference/index/type-aliases/DeepValue.md b/docs/reference/index/type-aliases/DeepValue.md index a218d29cef..4101923fb3 100644 --- a/docs/reference/index/type-aliases/DeepValue.md +++ b/docs/reference/index/type-aliases/DeepValue.md @@ -9,7 +9,7 @@ title: DeepValue type DeepValue = T extends Record ? TProp extends `${infer TBranch}.${infer TDeepProp}` ? DeepValue : T[TProp & string] : never; ``` -Defined in: [types/type-utils.ts:71](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L71) +Defined in: [types/type-utils.ts:79](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L79) ## Type Parameters diff --git a/docs/reference/index/type-aliases/ExtractAggregationFnKeys.md b/docs/reference/index/type-aliases/ExtractAggregationFnKeys.md index 581ba2aba2..b8173360fe 100644 --- a/docs/reference/index/type-aliases/ExtractAggregationFnKeys.md +++ b/docs/reference/index/type-aliases/ExtractAggregationFnKeys.md @@ -11,7 +11,7 @@ type ExtractAggregationFnKeys = IsAny extends true ? | BuiltInAggregationFn : TFeatures extends object ? Extract : keyof AggregationFns; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:53](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L53) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:108](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L108) Resolves the valid string names for `columnDef.aggregationFn` for a feature set. diff --git a/docs/reference/index/type-aliases/ExtractFilterFnKeys.md b/docs/reference/index/type-aliases/ExtractFilterFnKeys.md index 747fafdd47..d52544266d 100644 --- a/docs/reference/index/type-aliases/ExtractFilterFnKeys.md +++ b/docs/reference/index/type-aliases/ExtractFilterFnKeys.md @@ -11,7 +11,7 @@ type ExtractFilterFnKeys = IsAny extends true ? | BuiltInFilterFn : TFeatures extends object ? Extract : keyof FilterFns; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:100](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L100) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:160](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L160) Resolves the valid string names for `columnDef.filterFn` and `options.globalFilterFn` for a feature set. diff --git a/docs/reference/index/type-aliases/ExtractFilterMeta.md b/docs/reference/index/type-aliases/ExtractFilterMeta.md index e49f076923..c64701183a 100644 --- a/docs/reference/index/type-aliases/ExtractFilterMeta.md +++ b/docs/reference/index/type-aliases/ExtractFilterMeta.md @@ -9,7 +9,7 @@ title: ExtractFilterMeta type ExtractFilterMeta = IsAny extends true ? FilterMeta : TFeatures extends object ? TFilterMeta : FilterMeta; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:23](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L23) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:24](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L24) Resolves the type of the filter meta attached to rows for a feature set. diff --git a/docs/reference/index/type-aliases/ExtractSortFnKeys.md b/docs/reference/index/type-aliases/ExtractSortFnKeys.md index e32e6c3fb0..3bc5720872 100644 --- a/docs/reference/index/type-aliases/ExtractSortFnKeys.md +++ b/docs/reference/index/type-aliases/ExtractSortFnKeys.md @@ -11,7 +11,7 @@ type ExtractSortFnKeys = IsAny extends true ? | BuiltInSortFn : TFeatures extends object ? Extract : keyof SortFns; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:54](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L54) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:106](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L106) Resolves the valid string names for `columnDef.sortFn` for a feature set. diff --git a/docs/reference/index/type-aliases/FilterFnOption.md b/docs/reference/index/type-aliases/FilterFnOption.md index fc1ed17ab1..3499a8b13d 100644 --- a/docs/reference/index/type-aliases/FilterFnOption.md +++ b/docs/reference/index/type-aliases/FilterFnOption.md @@ -12,7 +12,7 @@ type FilterFnOption = | FilterFn; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:107](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L107) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:167](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L167) ## Type Parameters diff --git a/docs/reference/index/type-aliases/Getter.md b/docs/reference/index/type-aliases/Getter.md index 3f894da629..0001b0eec2 100644 --- a/docs/reference/index/type-aliases/Getter.md +++ b/docs/reference/index/type-aliases/Getter.md @@ -9,7 +9,7 @@ title: Getter type Getter = () => NoInfer; ``` -Defined in: [types/type-utils.ts:80](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L80) +Defined in: [types/type-utils.ts:88](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L88) ## Type Parameters diff --git a/docs/reference/index/type-aliases/GroupingColumnMode.md b/docs/reference/index/type-aliases/GroupingColumnMode.md index 5af0e2b933..a5c20518f8 100644 --- a/docs/reference/index/type-aliases/GroupingColumnMode.md +++ b/docs/reference/index/type-aliases/GroupingColumnMode.md @@ -9,4 +9,4 @@ title: GroupingColumnMode type GroupingColumnMode = false | "reorder" | "remove"; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:197](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L197) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:252](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L252) diff --git a/docs/reference/index/type-aliases/GroupingState.md b/docs/reference/index/type-aliases/GroupingState.md index 581f67fc0f..40690ac7cf 100644 --- a/docs/reference/index/type-aliases/GroupingState.md +++ b/docs/reference/index/type-aliases/GroupingState.md @@ -9,4 +9,4 @@ title: GroupingState type GroupingState = string[]; ``` -Defined in: [features/column-grouping/columnGroupingFeature.types.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L14) +Defined in: [features/column-grouping/columnGroupingFeature.types.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.types.ts#L15) diff --git a/docs/reference/index/type-aliases/NoInfer.md b/docs/reference/index/type-aliases/NoInfer.md index d114f1f8cc..48925eb990 100644 --- a/docs/reference/index/type-aliases/NoInfer.md +++ b/docs/reference/index/type-aliases/NoInfer.md @@ -9,7 +9,7 @@ title: NoInfer type NoInfer = [T][T extends any ? 0 : never]; ``` -Defined in: [types/type-utils.ts:78](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L78) +Defined in: [types/type-utils.ts:86](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L86) ## Type Parameters diff --git a/docs/reference/index/type-aliases/PartialKeys.md b/docs/reference/index/type-aliases/PartialKeys.md index 560bb4cfbf..de5acf421c 100644 --- a/docs/reference/index/type-aliases/PartialKeys.md +++ b/docs/reference/index/type-aliases/PartialKeys.md @@ -9,7 +9,7 @@ title: PartialKeys type PartialKeys = Omit & Partial>; ``` -Defined in: [types/type-utils.ts:9](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L9) +Defined in: [types/type-utils.ts:17](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L17) ## Type Parameters diff --git a/docs/reference/index/type-aliases/Prettify.md b/docs/reference/index/type-aliases/Prettify.md index 308b5177aa..bd22d7cbe7 100644 --- a/docs/reference/index/type-aliases/Prettify.md +++ b/docs/reference/index/type-aliases/Prettify.md @@ -9,7 +9,7 @@ title: Prettify type Prettify = { [K in keyof T]: T[K] } & unknown; ``` -Defined in: [types/type-utils.ts:82](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L82) +Defined in: [types/type-utils.ts:90](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L90) ## Type Parameters diff --git a/docs/reference/index/type-aliases/RequiredKeys.md b/docs/reference/index/type-aliases/RequiredKeys.md index bbf82b7740..a965a69f3f 100644 --- a/docs/reference/index/type-aliases/RequiredKeys.md +++ b/docs/reference/index/type-aliases/RequiredKeys.md @@ -9,7 +9,7 @@ title: RequiredKeys type RequiredKeys = Omit & Required>; ``` -Defined in: [types/type-utils.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L11) +Defined in: [types/type-utils.ts:19](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L19) ## Type Parameters diff --git a/docs/reference/index/type-aliases/SortDirection.md b/docs/reference/index/type-aliases/SortDirection.md index 696145ec78..5a57841574 100644 --- a/docs/reference/index/type-aliases/SortDirection.md +++ b/docs/reference/index/type-aliases/SortDirection.md @@ -9,4 +9,4 @@ title: SortDirection type SortDirection = "asc" | "desc"; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:7](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L7) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L12) diff --git a/docs/reference/index/type-aliases/SortFnOption.md b/docs/reference/index/type-aliases/SortFnOption.md index 798dcbd917..bf22fe77c3 100644 --- a/docs/reference/index/type-aliases/SortFnOption.md +++ b/docs/reference/index/type-aliases/SortFnOption.md @@ -12,7 +12,7 @@ type SortFnOption = | SortFn; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:61](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L61) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:113](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L113) ## Type Parameters diff --git a/docs/reference/index/type-aliases/SortingState.md b/docs/reference/index/type-aliases/SortingState.md index 096d66c7bb..b54ed1f036 100644 --- a/docs/reference/index/type-aliases/SortingState.md +++ b/docs/reference/index/type-aliases/SortingState.md @@ -9,4 +9,4 @@ title: SortingState type SortingState = ColumnSort[]; ``` -Defined in: [features/row-sorting/rowSortingFeature.types.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L14) +Defined in: [features/row-sorting/rowSortingFeature.types.ts:19](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.types.ts#L19) diff --git a/docs/reference/index/type-aliases/TransformDataValueFn.md b/docs/reference/index/type-aliases/TransformDataValueFn.md new file mode 100644 index 0000000000..7366d1c3a4 --- /dev/null +++ b/docs/reference/index/type-aliases/TransformDataValueFn.md @@ -0,0 +1,27 @@ +--- +id: TransformDataValueFn +title: TransformDataValueFn +--- + +# Type Alias: TransformDataValueFn() + +```ts +type TransformDataValueFn = (dataValue) => any; +``` + +Defined in: [types/type-utils.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L15) + +Normalizes a row's value before a filter or sort comparator sees it. + +Attach as `resolveDataValue` on filter/sort functions built with +`constructFilterFn`/`constructSortFn` (e.g. to lowercase or strip diacritics). + +## Parameters + +### dataValue + +`any` + +## Returns + +`any` diff --git a/docs/reference/index/type-aliases/TransformFilterValueFn.md b/docs/reference/index/type-aliases/TransformFilterValueFn.md index 6ce39ec142..e31a08c492 100644 --- a/docs/reference/index/type-aliases/TransformFilterValueFn.md +++ b/docs/reference/index/type-aliases/TransformFilterValueFn.md @@ -9,7 +9,7 @@ title: TransformFilterValueFn type TransformFilterValueFn = (value, column?) => TValue; ``` -Defined in: [features/column-filtering/columnFilteringFeature.types.ts:73](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L73) +Defined in: [features/column-filtering/columnFilteringFeature.types.ts:133](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.types.ts#L133) ## Type Parameters diff --git a/docs/reference/index/type-aliases/UnionToIntersection.md b/docs/reference/index/type-aliases/UnionToIntersection.md index f320f56a9f..b25aac29f8 100644 --- a/docs/reference/index/type-aliases/UnionToIntersection.md +++ b/docs/reference/index/type-aliases/UnionToIntersection.md @@ -9,7 +9,7 @@ title: UnionToIntersection type UnionToIntersection = T extends any ? (x) => any : never extends (x) => any ? R : never; ``` -Defined in: [types/type-utils.ts:14](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L14) +Defined in: [types/type-utils.ts:22](https://github.com/TanStack/table/blob/main/packages/table-core/src/types/type-utils.ts#L22) ## Type Parameters diff --git a/docs/reference/index/variables/aggregationFn_extent.md b/docs/reference/index/variables/aggregationFn_extent.md new file mode 100644 index 0000000000..b92be49bbc --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_extent.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_extent +title: aggregationFn_extent +--- + +# Variable: aggregationFn\_extent + +```ts +const aggregationFn_extent: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L136) + +Finds the numeric extent for a grouped column. + +Returns `[min, max]`, where each entry is `undefined` when no numeric value is +present. diff --git a/docs/reference/index/variables/aggregationFn_max.md b/docs/reference/index/variables/aggregationFn_max.md new file mode 100644 index 0000000000..f3f576bd5d --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_max.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_max +title: aggregationFn_max +--- + +# Variable: aggregationFn\_max + +```ts +const aggregationFn_max: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:111](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L111) + +Finds the maximum numeric child-row value for a grouped column. + +Nullish and non-number values are ignored. Returns `undefined` when no +numeric value is found. diff --git a/docs/reference/index/variables/aggregationFn_mean.md b/docs/reference/index/variables/aggregationFn_mean.md new file mode 100644 index 0000000000..177203757d --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_mean.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_mean +title: aggregationFn_mean +--- + +# Variable: aggregationFn\_mean + +```ts +const aggregationFn_mean: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:164](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L164) + +Averages numeric leaf-row values for a grouped column. + +Number-like values are coerced with unary `+`; nullish and non-numeric values +are ignored. diff --git a/docs/reference/index/variables/aggregationFn_median.md b/docs/reference/index/variables/aggregationFn_median.md new file mode 100644 index 0000000000..8a0c96173f --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_median.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_median +title: aggregationFn_median +--- + +# Variable: aggregationFn\_median + +```ts +const aggregationFn_median: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:195](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L195) + +Computes the median of numeric leaf-row values for a grouped column. + +All values must be numbers. If any value is non-numeric, or no leaf rows are +present, the result is `undefined`. diff --git a/docs/reference/index/variables/aggregationFn_min.md b/docs/reference/index/variables/aggregationFn_min.md new file mode 100644 index 0000000000..3f8f707efe --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_min.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_min +title: aggregationFn_min +--- + +# Variable: aggregationFn\_min + +```ts +const aggregationFn_min: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:86](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L86) + +Finds the minimum numeric child-row value for a grouped column. + +Nullish and non-number values are ignored. Returns `undefined` when no +numeric value is found. diff --git a/docs/reference/index/variables/aggregationFn_sum.md b/docs/reference/index/variables/aggregationFn_sum.md new file mode 100644 index 0000000000..c55bfd38d9 --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_sum.md @@ -0,0 +1,17 @@ +--- +id: aggregationFn_sum +title: aggregationFn_sum +--- + +# Variable: aggregationFn\_sum + +```ts +const aggregationFn_sum: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:68](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L68) + +Sums numeric child-row values for a grouped column. + +Non-number values contribute `0`. Child rows are used so nested group totals +can reuse already aggregated values. diff --git a/docs/reference/index/variables/aggregationFn_unique.md b/docs/reference/index/variables/aggregationFn_unique.md new file mode 100644 index 0000000000..6d7f7be58e --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_unique.md @@ -0,0 +1,16 @@ +--- +id: aggregationFn_unique +title: aggregationFn_unique +--- + +# Variable: aggregationFn\_unique + +```ts +const aggregationFn_unique: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L222) + +Collects unique leaf-row values for a grouped column. + +Values are compared with JavaScript `Set` semantics. diff --git a/docs/reference/index/variables/aggregationFn_uniqueCount.md b/docs/reference/index/variables/aggregationFn_uniqueCount.md new file mode 100644 index 0000000000..baa8906fed --- /dev/null +++ b/docs/reference/index/variables/aggregationFn_uniqueCount.md @@ -0,0 +1,16 @@ +--- +id: aggregationFn_uniqueCount +title: aggregationFn_uniqueCount +--- + +# Variable: aggregationFn\_uniqueCount + +```ts +const aggregationFn_uniqueCount: CreatedAggregationFn; +``` + +Defined in: [fns/aggregationFns.ts:231](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L231) + +Counts unique leaf-row values for a grouped column. + +Values are compared with JavaScript `Set` semantics. diff --git a/docs/reference/index/variables/aggregationFns.md b/docs/reference/index/variables/aggregationFns.md index b2af0fe775..f20c2205d9 100644 --- a/docs/reference/index/variables/aggregationFns.md +++ b/docs/reference/index/variables/aggregationFns.md @@ -3,21 +3,25 @@ id: aggregationFns title: aggregationFns --- -# Variable: aggregationFns +# ~~Variable: aggregationFns~~ ```ts const aggregationFns: object; ``` -Defined in: [fns/aggregationFns.ts:233](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L233) +Defined in: [fns/aggregationFns.ts:289](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/aggregationFns.ts#L289) The built-in aggregation function registry. -Pass this object to grouped row model creation or extend it with custom aggregation functions for grouped columns. +Registering this full object opts out of tree-shaking: every built-in +aggregation function ends up in your bundle. Prefer importing the +`aggregationFn_*` functions you actually use and registering just those in +the `aggregationFns` slot, or passing them directly to the `aggregationFn` +column option. ## Type Declaration -### count() +### ~~count()~~ ```ts count: (_columnId, leafRows) => number = aggregationFn_count; @@ -26,6 +30,8 @@ count: (_columnId, leafRows) => number = aggregationFn_count; Counts the number of leaf rows in the group. The column id is ignored because the result is based only on group size. +This is a plain row-level function (not built with +`constructAggregationFn`) because it never reads row values. #### Type Parameters @@ -51,55 +57,22 @@ The column id is ignored because the result is based only on group size. `number` -### extent() +### ~~extent~~ ```ts -extent: (columnId, _leafRows, childRows) => (number | undefined)[] = aggregationFn_extent; +extent: CreatedAggregationFn = aggregationFn_extent; ``` -Finds the numeric extent for a grouped column. - -Returns `[min, max]`, where each entry is `undefined` when no numeric value is -present. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId - -`string` - -##### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -##### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -#### Returns - -(`number` \| `undefined`)[] - -### max() +### ~~first()~~ ```ts -max: (columnId, _leafRows, childRows) => number | undefined = aggregationFn_max; +first: (columnId, leafRows) => unknown = aggregationFn_first; ``` -Finds the maximum numeric child-row value for a grouped column. +Returns the first leaf-row value for a grouped column. -Nullish and non-number values are ignored. Returns `undefined` when no -numeric value is found. +This is a plain row-level function (not built with +`constructAggregationFn`) because it only reads one positional value. #### Type Parameters @@ -117,28 +90,24 @@ numeric value is found. `string` -##### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -##### childRows +##### leafRows [`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] #### Returns -`number` \| `undefined` +`unknown` -### mean() +### ~~last()~~ ```ts -mean: (columnId, leafRows) => number | undefined = aggregationFn_mean; +last: (columnId, leafRows) => unknown = aggregationFn_last; ``` -Averages numeric leaf-row values for a grouped column. +Returns the last leaf-row value for a grouped column. -Number-like values are coerced with unary `+`; nullish and non-numeric values -are ignored. +This is a plain row-level function (not built with +`constructAggregationFn`) because it only reads one positional value. #### Type Parameters @@ -162,185 +131,53 @@ are ignored. #### Returns -`number` \| `undefined` +`unknown` -### median() +### ~~max~~ ```ts -median: (columnId, leafRows) => number | undefined = aggregationFn_median; +max: CreatedAggregationFn = aggregationFn_max; ``` -Computes the median of numeric leaf-row values for a grouped column. - -All values must be numbers. If any value is non-numeric, or no leaf rows are -present, the result is `undefined`. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId - -`string` - -##### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -#### Returns - -`number` \| `undefined` - -### min() +### ~~mean~~ ```ts -min: (columnId, _leafRows, childRows) => number | undefined = aggregationFn_min; +mean: CreatedAggregationFn = aggregationFn_mean; ``` -Finds the minimum numeric child-row value for a grouped column. - -Nullish and non-number values are ignored. Returns `undefined` when no -numeric value is found. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId - -`string` - -##### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -##### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -#### Returns - -`number` \| `undefined` - -### sum() +### ~~median~~ ```ts -sum: (columnId, _leafRows, childRows) => number = aggregationFn_sum; +median: CreatedAggregationFn = aggregationFn_median; ``` -Sums numeric child-row values for a grouped column. - -Non-number values contribute `0`. Child rows are used so nested group totals -can reuse already aggregated values. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId - -`string` - -##### \_leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -##### childRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -#### Returns - -`number` - -### unique() +### ~~min~~ ```ts -unique: (columnId, leafRows) => unknown[] = aggregationFn_unique; +min: CreatedAggregationFn = aggregationFn_min; ``` -Collects unique leaf-row values for a grouped column. - -Values are compared with JavaScript `Set` semantics. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId - -`string` - -##### leafRows - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] - -#### Returns - -`unknown`[] - -### uniqueCount() +### ~~sum~~ ```ts -uniqueCount: (columnId, leafRows) => number = aggregationFn_uniqueCount; +sum: CreatedAggregationFn = aggregationFn_sum; ``` -Counts unique leaf-row values for a grouped column. - -Values are compared with JavaScript `Set` semantics. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### columnId +### ~~unique~~ -`string` +```ts +unique: CreatedAggregationFn = aggregationFn_unique; +``` -##### leafRows +### ~~uniqueCount~~ -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\>[] +```ts +uniqueCount: CreatedAggregationFn = aggregationFn_uniqueCount; +``` -#### Returns +## Deprecated -`number` +Import individual `aggregationFn_*` functions instead for a +smaller bundle. This export still works and is not going away in v9, but +built-in name resolution (including `aggregationFn: 'auto'`) only finds +functions you register yourself. diff --git a/docs/reference/index/variables/filterFn_arrHas.md b/docs/reference/index/variables/filterFn_arrHas.md index 6577aedf0e..a908304532 100644 --- a/docs/reference/index/variables/filterFn_arrHas.md +++ b/docs/reference/index/variables/filterFn_arrHas.md @@ -6,27 +6,9 @@ title: filterFn_arrHas # Variable: filterFn\_arrHas ```ts -const filterFn_arrHas: (row, columnId, filterValue) => boolean & object; +const filterFn_arrHas: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:341](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L341) +Defined in: [fns/filterFns.ts:356](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L356) Keeps rows whose scalar column value equals at least one filter value. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_arrIncludes.md b/docs/reference/index/variables/filterFn_arrIncludes.md index 4cec21b997..43ddcffdc3 100644 --- a/docs/reference/index/variables/filterFn_arrIncludes.md +++ b/docs/reference/index/variables/filterFn_arrIncludes.md @@ -6,27 +6,9 @@ title: filterFn_arrIncludes # Variable: filterFn\_arrIncludes ```ts -const filterFn_arrIncludes: (row, columnId, filterValue) => boolean & object; +const filterFn_arrIncludes: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:361](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L361) +Defined in: [fns/filterFns.ts:371](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L371) Keeps rows whose array or string column value includes at least one filter value. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_arrIncludesAll.md b/docs/reference/index/variables/filterFn_arrIncludesAll.md index 3ad8a10e2b..e9f4cdfb0e 100644 --- a/docs/reference/index/variables/filterFn_arrIncludesAll.md +++ b/docs/reference/index/variables/filterFn_arrIncludesAll.md @@ -6,27 +6,9 @@ title: filterFn_arrIncludesAll # Variable: filterFn\_arrIncludesAll ```ts -const filterFn_arrIncludesAll: (row, columnId, filterValue) => boolean & object; +const filterFn_arrIncludesAll: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:385](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L385) +Defined in: [fns/filterFns.ts:390](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L390) Keeps rows whose array column value includes every filter value. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_arrIncludesSome.md b/docs/reference/index/variables/filterFn_arrIncludesSome.md index 4d00e4907e..c5c14f133a 100644 --- a/docs/reference/index/variables/filterFn_arrIncludesSome.md +++ b/docs/reference/index/variables/filterFn_arrIncludesSome.md @@ -6,27 +6,9 @@ title: filterFn_arrIncludesSome # Variable: filterFn\_arrIncludesSome ```ts -const filterFn_arrIncludesSome: (row, columnId, filterValue) => boolean & object; +const filterFn_arrIncludesSome: CreatedFilterFn; ``` Defined in: [fns/filterFns.ts:406](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L406) Keeps rows whose array column value includes at least one filter value. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_empty.md b/docs/reference/index/variables/filterFn_empty.md new file mode 100644 index 0000000000..f516234c75 --- /dev/null +++ b/docs/reference/index/variables/filterFn_empty.md @@ -0,0 +1,18 @@ +--- +id: filterFn_empty +title: filterFn_empty +--- + +# Variable: filterFn\_empty + +```ts +const filterFn_empty: CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:185](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L185) + +Keeps rows whose column value is empty. + +A value is empty when it is nullish or stringifies to whitespace only. The +filter value acts as an on/off flag: `false` and blank values are +auto-removed. diff --git a/docs/reference/index/variables/filterFn_endsWith.md b/docs/reference/index/variables/filterFn_endsWith.md new file mode 100644 index 0000000000..97a05c2e79 --- /dev/null +++ b/docs/reference/index/variables/filterFn_endsWith.md @@ -0,0 +1,17 @@ +--- +id: filterFn_endsWith +title: filterFn_endsWith +--- + +# Variable: filterFn\_endsWith + +```ts +const filterFn_endsWith: CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:168](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L168) + +Keeps rows whose stringified column value ends with the filter text. + +Both values are lowercased before comparison, and empty filter values are +auto-removed. diff --git a/docs/reference/index/variables/filterFn_equals.md b/docs/reference/index/variables/filterFn_equals.md index f97a170a3a..0d20997896 100644 --- a/docs/reference/index/variables/filterFn_equals.md +++ b/docs/reference/index/variables/filterFn_equals.md @@ -6,29 +6,11 @@ title: filterFn_equals # Variable: filterFn\_equals ```ts -const filterFn_equals: (row, columnId, filterValue) => boolean & object; +const filterFn_equals: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:12](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L12) +Defined in: [fns/filterFns.ts:77](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L77) Keeps rows whose column value is strictly equal to the filter value. Uses JavaScript `===` comparison and auto-removes empty filter values. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_equalsString.md b/docs/reference/index/variables/filterFn_equalsString.md index 5bb90eb76d..1aa0e33d68 100644 --- a/docs/reference/index/variables/filterFn_equalsString.md +++ b/docs/reference/index/variables/filterFn_equalsString.md @@ -6,46 +6,12 @@ title: filterFn_equalsString # Variable: filterFn\_equalsString ```ts -const filterFn_equalsString: (row, columnId, filterValue) => boolean & object; +const filterFn_equalsString: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:95](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L95) +Defined in: [fns/filterFns.ts:127](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L127) Keeps rows whose stringified column value equals the filter text. Both values are lowercased before comparison, and empty filter values are auto-removed. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` - -### resolveFilterValue() - -```ts -resolveFilterValue: (val) => string; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`string` diff --git a/docs/reference/index/variables/filterFn_equalsStringSensitive.md b/docs/reference/index/variables/filterFn_equalsStringSensitive.md index bd65d4b876..455b800108 100644 --- a/docs/reference/index/variables/filterFn_equalsStringSensitive.md +++ b/docs/reference/index/variables/filterFn_equalsStringSensitive.md @@ -6,45 +6,11 @@ title: filterFn_equalsStringSensitive # Variable: filterFn\_equalsStringSensitive ```ts -const filterFn_equalsStringSensitive: (row, columnId, filterValue) => boolean & object; +const filterFn_equalsStringSensitive: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:117](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L117) +Defined in: [fns/filterFns.ts:140](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L140) Keeps rows whose stringified column value exactly equals the filter text. Matching is case-sensitive and empty filter values are auto-removed. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` - -### resolveFilterValue() - -```ts -resolveFilterValue: (val) => string; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`string` diff --git a/docs/reference/index/variables/filterFn_greaterThan.md b/docs/reference/index/variables/filterFn_greaterThan.md index 1cbaade901..17fa18d4f8 100644 --- a/docs/reference/index/variables/filterFn_greaterThan.md +++ b/docs/reference/index/variables/filterFn_greaterThan.md @@ -6,30 +6,12 @@ title: filterFn_greaterThan # Variable: filterFn\_greaterThan ```ts -const filterFn_greaterThan: (row, columnId, filterValue) => boolean & object; +const filterFn_greaterThan: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:139](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L139) +Defined in: [fns/filterFns.ts:210](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L210) Keeps rows whose value is greater than the filter value. Numeric values are compared numerically when both sides can be coerced to numbers; otherwise normalized strings are compared. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_greaterThanOrEqualTo.md b/docs/reference/index/variables/filterFn_greaterThanOrEqualTo.md index 72bf957a04..6f75052fd9 100644 --- a/docs/reference/index/variables/filterFn_greaterThanOrEqualTo.md +++ b/docs/reference/index/variables/filterFn_greaterThanOrEqualTo.md @@ -6,29 +6,11 @@ title: filterFn_greaterThanOrEqualTo # Variable: filterFn\_greaterThanOrEqualTo ```ts -const filterFn_greaterThanOrEqualTo: (row, columnId, filterValue) => boolean & object; +const filterFn_greaterThanOrEqualTo: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:166](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L166) +Defined in: [fns/filterFns.ts:221](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L221) Keeps rows whose value is greater than or equal to the filter value. -Delegates to the built-in greater-than and equality comparisons. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` +Delegates to the built-in greater-than and strict-equality comparisons. diff --git a/docs/reference/index/variables/filterFn_inDateRange.md b/docs/reference/index/variables/filterFn_inDateRange.md new file mode 100644 index 0000000000..a08004161e --- /dev/null +++ b/docs/reference/index/variables/filterFn_inDateRange.md @@ -0,0 +1,18 @@ +--- +id: filterFn_inDateRange +title: filterFn_inDateRange +--- + +# Variable: filterFn\_inDateRange + +```ts +const filterFn_inDateRange: CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:323](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L323) + +Keeps rows whose date value is inside an inclusive `[min, max]` date range. + +Row values and range endpoints may be `Date` objects, timestamps, or +parseable date strings. Blank or invalid endpoints become open-ended and +reversed endpoints are swapped. Rows without a valid date never match. diff --git a/docs/reference/index/variables/filterFn_inNumberRange.md b/docs/reference/index/variables/filterFn_inNumberRange.md index bc621e8f50..bca6c3f449 100644 --- a/docs/reference/index/variables/filterFn_inNumberRange.md +++ b/docs/reference/index/variables/filterFn_inNumberRange.md @@ -6,46 +6,12 @@ title: filterFn_inNumberRange # Variable: filterFn\_inNumberRange ```ts -const filterFn_inNumberRange: (row, columnId, filterValue) => boolean & object; +const filterFn_inNumberRange: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:298](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L298) +Defined in: [fns/filterFns.ts:283](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L283) Keeps rows whose numeric value is inside an inclusive `[min, max]` range. Filter values are normalized so blank endpoints become open-ended and reversed endpoints are swapped. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` - -### resolveFilterValue() - -```ts -resolveFilterValue: (val) => readonly [number, number]; -``` - -#### Parameters - -##### val - -\[`any`, `any`\] - -#### Returns - -readonly \[`number`, `number`\] diff --git a/docs/reference/index/variables/filterFn_includesString.md b/docs/reference/index/variables/filterFn_includesString.md index a1a729109f..0d375724fd 100644 --- a/docs/reference/index/variables/filterFn_includesString.md +++ b/docs/reference/index/variables/filterFn_includesString.md @@ -6,46 +6,12 @@ title: filterFn_includesString # Variable: filterFn\_includesString ```ts -const filterFn_includesString: (row, columnId, filterValue) => boolean & object; +const filterFn_includesString: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:69](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L69) +Defined in: [fns/filterFns.ts:113](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L113) Keeps rows whose stringified column value includes the filter text. Both values are lowercased before comparison, and empty filter values are auto-removed. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` - -### resolveFilterValue() - -```ts -resolveFilterValue: (val) => string; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`string` diff --git a/docs/reference/index/variables/filterFn_includesStringSensitive.md b/docs/reference/index/variables/filterFn_includesStringSensitive.md index 074ee83b5d..49872f2c33 100644 --- a/docs/reference/index/variables/filterFn_includesStringSensitive.md +++ b/docs/reference/index/variables/filterFn_includesStringSensitive.md @@ -6,45 +6,11 @@ title: filterFn_includesStringSensitive # Variable: filterFn\_includesStringSensitive ```ts -const filterFn_includesStringSensitive: (row, columnId, filterValue) => boolean & object; +const filterFn_includesStringSensitive: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:47](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L47) +Defined in: [fns/filterFns.ts:100](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L100) Keeps rows whose stringified column value includes the filter text. Matching is case-sensitive and empty filter values are auto-removed. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` - -### resolveFilterValue() - -```ts -resolveFilterValue: (val) => string; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`string` diff --git a/docs/reference/index/variables/filterFn_lessThan.md b/docs/reference/index/variables/filterFn_lessThan.md index 0ff254e226..f0b22efe58 100644 --- a/docs/reference/index/variables/filterFn_lessThan.md +++ b/docs/reference/index/variables/filterFn_lessThan.md @@ -6,29 +6,11 @@ title: filterFn_lessThan # Variable: filterFn\_lessThan ```ts -const filterFn_lessThan: (row, columnId, filterValue) => boolean & object; +const filterFn_lessThan: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:185](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L185) +Defined in: [fns/filterFns.ts:232](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L232) Keeps rows whose value is less than the filter value. This is implemented as the inverse of greater-than-or-equal comparison. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_lessThanOrEqualTo.md b/docs/reference/index/variables/filterFn_lessThanOrEqualTo.md index 5f9a797a17..ce7bea7f40 100644 --- a/docs/reference/index/variables/filterFn_lessThanOrEqualTo.md +++ b/docs/reference/index/variables/filterFn_lessThanOrEqualTo.md @@ -6,29 +6,11 @@ title: filterFn_lessThanOrEqualTo # Variable: filterFn\_lessThanOrEqualTo ```ts -const filterFn_lessThanOrEqualTo: (row, columnId, filterValue) => boolean & object; +const filterFn_lessThanOrEqualTo: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:201](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L201) +Defined in: [fns/filterFns.ts:243](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L243) Keeps rows whose value is less than or equal to the filter value. This is implemented as the inverse of greater-than comparison. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFn_notEmpty.md b/docs/reference/index/variables/filterFn_notEmpty.md new file mode 100644 index 0000000000..639e51c0c6 --- /dev/null +++ b/docs/reference/index/variables/filterFn_notEmpty.md @@ -0,0 +1,18 @@ +--- +id: filterFn_notEmpty +title: filterFn_notEmpty +--- + +# Variable: filterFn\_notEmpty + +```ts +const filterFn_notEmpty: CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:197](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L197) + +Keeps rows whose column value is not empty. + +A value is empty when it is nullish or stringifies to whitespace only. The +filter value acts as an on/off flag: `false` and blank values are +auto-removed. diff --git a/docs/reference/index/variables/filterFn_startsWith.md b/docs/reference/index/variables/filterFn_startsWith.md new file mode 100644 index 0000000000..ff02cfe315 --- /dev/null +++ b/docs/reference/index/variables/filterFn_startsWith.md @@ -0,0 +1,17 @@ +--- +id: filterFn_startsWith +title: filterFn_startsWith +--- + +# Variable: filterFn\_startsWith + +```ts +const filterFn_startsWith: CreatedFilterFn; +``` + +Defined in: [fns/filterFns.ts:153](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L153) + +Keeps rows whose stringified column value starts with the filter text. + +Both values are lowercased before comparison, and empty filter values are +auto-removed. diff --git a/docs/reference/index/variables/filterFn_weakEquals.md b/docs/reference/index/variables/filterFn_weakEquals.md index 111ff4599a..3b8977c0e5 100644 --- a/docs/reference/index/variables/filterFn_weakEquals.md +++ b/docs/reference/index/variables/filterFn_weakEquals.md @@ -6,30 +6,12 @@ title: filterFn_weakEquals # Variable: filterFn\_weakEquals ```ts -const filterFn_weakEquals: (row, columnId, filterValue) => boolean & object; +const filterFn_weakEquals: CreatedFilterFn; ``` -Defined in: [fns/filterFns.ts:29](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L29) +Defined in: [fns/filterFns.ts:88](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L88) Keeps rows whose column value is loosely equal to the filter value. Uses JavaScript `==` comparison and auto-removes empty filter values. This is useful for matching string input against numeric row values. - -## Type Declaration - -### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -#### Parameters - -##### val - -`any` - -#### Returns - -`boolean` diff --git a/docs/reference/index/variables/filterFns.md b/docs/reference/index/variables/filterFns.md index 44ae0dfe7a..cddd04886d 100644 --- a/docs/reference/index/variables/filterFns.md +++ b/docs/reference/index/variables/filterFns.md @@ -3,368 +3,134 @@ id: filterFns title: filterFns --- -# Variable: filterFns +# ~~Variable: filterFns~~ ```ts const filterFns: object; ``` -Defined in: [fns/filterFns.ts:431](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L431) +Defined in: [fns/filterFns.ts:434](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/filterFns.ts#L434) The built-in filter function registry. -Pass this object to filtered row model creation or extend it with custom filter functions. +Registering this full object opts out of tree-shaking: every built-in +filter function ends up in your bundle. Prefer importing the `filterFn_*` +functions you actually use and registering just those in the `filterFns` +slot, or passing them directly to the `filterFn` column option. ## Type Declaration -### arrHas +### ~~arrHas~~ ```ts -arrHas: (row, columnId, filterValue) => boolean & object = filterFn_arrHas; +arrHas: CreatedFilterFn = filterFn_arrHas; ``` -#### Type Declaration - -##### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### arrIncludes - -```ts -arrIncludes: (row, columnId, filterValue) => boolean & object = filterFn_arrIncludes; -``` - -#### Type Declaration - -##### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### arrIncludesAll - -```ts -arrIncludesAll: (row, columnId, filterValue) => boolean & object = filterFn_arrIncludesAll; -``` - -#### Type Declaration - -##### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### arrIncludesSome - -```ts -arrIncludesSome: (row, columnId, filterValue) => boolean & object = filterFn_arrIncludesSome; -``` - -#### Type Declaration - -##### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### between - -```ts -between: (row, columnId, filterValues) => boolean & object = filterFn_between; -``` - -#### Type Declaration - -##### autoRemove() - -```ts -autoRemove: (val) => boolean; -``` - -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### betweenInclusive +### ~~arrIncludes~~ ```ts -betweenInclusive: (row, columnId, filterValues) => boolean & object = filterFn_betweenInclusive; +arrIncludes: CreatedFilterFn = filterFn_arrIncludes; ``` -#### Type Declaration - -##### autoRemove() +### ~~arrIncludesAll~~ ```ts -autoRemove: (val) => boolean; +arrIncludesAll: CreatedFilterFn = filterFn_arrIncludesAll; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### equals +### ~~arrIncludesSome~~ ```ts -equals: (row, columnId, filterValue) => boolean & object = filterFn_equals; +arrIncludesSome: CreatedFilterFn = filterFn_arrIncludesSome; ``` -#### Type Declaration - -##### autoRemove() +### ~~between~~ ```ts -autoRemove: (val) => boolean; +between: CreatedFilterFn = filterFn_between; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -### equalsString +### ~~betweenInclusive~~ ```ts -equalsString: (row, columnId, filterValue) => boolean & object = filterFn_equalsString; +betweenInclusive: CreatedFilterFn = filterFn_betweenInclusive; ``` -#### Type Declaration - -##### autoRemove() +### ~~empty~~ ```ts -autoRemove: (val) => boolean; +empty: CreatedFilterFn = filterFn_empty; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -##### resolveFilterValue() +### ~~endsWith~~ ```ts -resolveFilterValue: (val) => string; +endsWith: CreatedFilterFn = filterFn_endsWith; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`string` - -### includesString +### ~~equals~~ ```ts -includesString: (row, columnId, filterValue) => boolean & object = filterFn_includesString; +equals: CreatedFilterFn = filterFn_equals; ``` -#### Type Declaration - -##### autoRemove() +### ~~equalsString~~ ```ts -autoRemove: (val) => boolean; +equalsString: CreatedFilterFn = filterFn_equalsString; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -##### resolveFilterValue() +### ~~equalsStringSensitive~~ ```ts -resolveFilterValue: (val) => string; +equalsStringSensitive: CreatedFilterFn = filterFn_equalsStringSensitive; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`string` - -### includesStringSensitive - -```ts -includesStringSensitive: (row, columnId, filterValue) => boolean & object = filterFn_includesStringSensitive; -``` - -#### Type Declaration - -##### autoRemove() +### ~~includesString~~ ```ts -autoRemove: (val) => boolean; +includesString: CreatedFilterFn = filterFn_includesString; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -##### resolveFilterValue() +### ~~includesStringSensitive~~ ```ts -resolveFilterValue: (val) => string; +includesStringSensitive: CreatedFilterFn = filterFn_includesStringSensitive; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`string` - -### inNumberRange +### ~~inDateRange~~ ```ts -inNumberRange: (row, columnId, filterValue) => boolean & object = filterFn_inNumberRange; +inDateRange: CreatedFilterFn = filterFn_inDateRange; ``` -#### Type Declaration - -##### autoRemove() +### ~~inNumberRange~~ ```ts -autoRemove: (val) => boolean; +inNumberRange: CreatedFilterFn = filterFn_inNumberRange; ``` -###### Parameters - -###### val - -`any` - -###### Returns - -`boolean` - -##### resolveFilterValue() +### ~~notEmpty~~ ```ts -resolveFilterValue: (val) => readonly [number, number]; +notEmpty: CreatedFilterFn = filterFn_notEmpty; ``` -###### Parameters - -###### val - -\[`any`, `any`\] - -###### Returns - -readonly \[`number`, `number`\] - -### weakEquals +### ~~startsWith~~ ```ts -weakEquals: (row, columnId, filterValue) => boolean & object = filterFn_weakEquals; +startsWith: CreatedFilterFn = filterFn_startsWith; ``` -#### Type Declaration - -##### autoRemove() +### ~~weakEquals~~ ```ts -autoRemove: (val) => boolean; +weakEquals: CreatedFilterFn = filterFn_weakEquals; ``` -###### Parameters - -###### val - -`any` - -###### Returns +## Deprecated -`boolean` +Import individual `filterFn_*` functions instead for a smaller +bundle. This export still works and is not going away in v9, but built-in +name resolution (including `filterFn: 'auto'`) only finds functions you +register yourself. diff --git a/docs/reference/index/variables/reSplitAlphaNumeric.md b/docs/reference/index/variables/reSplitAlphaNumeric.md index abf627c26b..a95b118ca3 100644 --- a/docs/reference/index/variables/reSplitAlphaNumeric.md +++ b/docs/reference/index/variables/reSplitAlphaNumeric.md @@ -9,7 +9,7 @@ title: reSplitAlphaNumeric const reSplitAlphaNumeric: RegExp; ``` -Defined in: [fns/sortFns.ts:11](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L11) +Defined in: [fns/sortFns.ts:15](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L15) Regular expression used to split mixed text and numeric chunks. diff --git a/docs/reference/index/variables/sortFn_alphanumeric.md b/docs/reference/index/variables/sortFn_alphanumeric.md new file mode 100644 index 0000000000..ee447de220 --- /dev/null +++ b/docs/reference/index/variables/sortFn_alphanumeric.md @@ -0,0 +1,16 @@ +--- +id: sortFn_alphanumeric +title: sortFn_alphanumeric +--- + +# Variable: sortFn\_alphanumeric + +```ts +const sortFn_alphanumeric: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:78](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L78) + +Sorts rows with the built-in alphanumeric strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFn_alphanumericCaseSensitive.md b/docs/reference/index/variables/sortFn_alphanumericCaseSensitive.md new file mode 100644 index 0000000000..fa3d518304 --- /dev/null +++ b/docs/reference/index/variables/sortFn_alphanumericCaseSensitive.md @@ -0,0 +1,16 @@ +--- +id: sortFn_alphanumericCaseSensitive +title: sortFn_alphanumericCaseSensitive +--- + +# Variable: sortFn\_alphanumericCaseSensitive + +```ts +const sortFn_alphanumericCaseSensitive: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:88](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L88) + +Sorts rows with the built-in alphanumeric case sensitive strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFn_basic.md b/docs/reference/index/variables/sortFn_basic.md new file mode 100644 index 0000000000..ff3b38bec6 --- /dev/null +++ b/docs/reference/index/variables/sortFn_basic.md @@ -0,0 +1,16 @@ +--- +id: sortFn_basic +title: sortFn_basic +--- + +# Variable: sortFn\_basic + +```ts +const sortFn_basic: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:136](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L136) + +Sorts rows with the built-in basic strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFn_datetime.md b/docs/reference/index/variables/sortFn_datetime.md new file mode 100644 index 0000000000..3896ab2bd6 --- /dev/null +++ b/docs/reference/index/variables/sortFn_datetime.md @@ -0,0 +1,16 @@ +--- +id: sortFn_datetime +title: sortFn_datetime +--- + +# Variable: sortFn\_datetime + +```ts +const sortFn_datetime: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:122](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L122) + +Sorts rows with the built-in datetime strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFn_text.md b/docs/reference/index/variables/sortFn_text.md new file mode 100644 index 0000000000..88fc336e67 --- /dev/null +++ b/docs/reference/index/variables/sortFn_text.md @@ -0,0 +1,16 @@ +--- +id: sortFn_text +title: sortFn_text +--- + +# Variable: sortFn\_text + +```ts +const sortFn_text: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:100](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L100) + +Sorts rows with the built-in text strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFn_textCaseSensitive.md b/docs/reference/index/variables/sortFn_textCaseSensitive.md new file mode 100644 index 0000000000..193eb78e40 --- /dev/null +++ b/docs/reference/index/variables/sortFn_textCaseSensitive.md @@ -0,0 +1,16 @@ +--- +id: sortFn_textCaseSensitive +title: sortFn_textCaseSensitive +--- + +# Variable: sortFn\_textCaseSensitive + +```ts +const sortFn_textCaseSensitive: CreatedSortFn; +``` + +Defined in: [fns/sortFns.ts:112](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L112) + +Sorts rows with the built-in text case sensitive strategy. + +This comparator returns ascending-order results; descending order is applied by the sorting row model. diff --git a/docs/reference/index/variables/sortFns.md b/docs/reference/index/variables/sortFns.md index c9b88d7f73..e157510a31 100644 --- a/docs/reference/index/variables/sortFns.md +++ b/docs/reference/index/variables/sortFns.md @@ -3,244 +3,62 @@ id: sortFns title: sortFns --- -# Variable: sortFns +# ~~Variable: sortFns~~ ```ts const sortFns: object; ``` -Defined in: [fns/sortFns.ts:343](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L343) +Defined in: [fns/sortFns.ts:360](https://github.com/TanStack/table/blob/main/packages/table-core/src/fns/sortFns.ts#L360) The built-in sorting function registry. -Pass this object to sorted row model creation or extend it with custom sorting functions. +Registering this full object opts out of tree-shaking: every built-in +sorting function ends up in your bundle. Prefer importing the `sortFn_*` +functions you actually use and registering just those in the `sortFns` +slot, or passing them directly to the `sortFn` column option. ## Type Declaration -### alphanumeric() +### ~~alphanumeric~~ ```ts -alphanumeric: (rowA, rowB, columnId) => number = sortFn_alphanumeric; +alphanumeric: CreatedSortFn = sortFn_alphanumeric; ``` -Sorts rows with the built-in alphanumeric strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns - -`number` - -### alphanumericCaseSensitive() +### ~~alphanumericCaseSensitive~~ ```ts -alphanumericCaseSensitive: (rowA, rowB, columnId) => number = sortFn_alphanumericCaseSensitive; +alphanumericCaseSensitive: CreatedSortFn = sortFn_alphanumericCaseSensitive; ``` -Sorts rows with the built-in alphanumeric case sensitive strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns - -`number` - -### basic() +### ~~basic~~ ```ts -basic: (rowA, rowB, columnId) => -1 | 0 | 1 = sortFn_basic; +basic: CreatedSortFn = sortFn_basic; ``` -Sorts rows with the built-in basic strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns - -`-1` \| `0` \| `1` - -### datetime() +### ~~datetime~~ ```ts -datetime: (rowA, rowB, columnId) => -1 | 0 | 1 = sortFn_datetime; +datetime: CreatedSortFn = sortFn_datetime; ``` -Sorts rows with the built-in datetime strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns - -`-1` \| `0` \| `1` - -### text() +### ~~text~~ ```ts -text: (rowA, rowB, columnId) => -1 | 0 | 1 = sortFn_text; +text: CreatedSortFn = sortFn_text; ``` -Sorts rows with the built-in text strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns - -`-1` \| `0` \| `1` - -### textCaseSensitive() +### ~~textCaseSensitive~~ ```ts -textCaseSensitive: (rowA, rowB, columnId) => -1 | 0 | 1 = sortFn_textCaseSensitive; +textCaseSensitive: CreatedSortFn = sortFn_textCaseSensitive; ``` -Sorts rows with the built-in text case sensitive strategy. - -This comparator returns ascending-order results; descending order is applied by the sorting row model. - -#### Type Parameters - -##### TFeatures - -`TFeatures` *extends* [`TableFeatures`](../interfaces/TableFeatures.md) - -##### TData - -`TData` *extends* [`RowData`](../type-aliases/RowData.md) - -#### Parameters - -##### rowA - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### rowB - -[`Row`](../type-aliases/Row.md)\<`TFeatures`, `TData`\> - -##### columnId - -`string` - -#### Returns +## Deprecated -`-1` \| `0` \| `1` +Import individual `sortFn_*` functions instead for a smaller +bundle. This export still works and is not going away in v9, but built-in +name resolution (including `sortFn: 'auto'`) only finds functions you +register yourself. diff --git a/docs/reference/static-functions/functions/cell_getIsAggregated.md b/docs/reference/static-functions/functions/cell_getIsAggregated.md index f458917faa..5ce4d61a60 100644 --- a/docs/reference/static-functions/functions/cell_getIsAggregated.md +++ b/docs/reference/static-functions/functions/cell_getIsAggregated.md @@ -9,7 +9,7 @@ title: cell_getIsAggregated function cell_getIsAggregated(cell): boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:348](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L348) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:384](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L384) Checks whether this cell should render an aggregated value. diff --git a/docs/reference/static-functions/functions/cell_getIsGrouped.md b/docs/reference/static-functions/functions/cell_getIsGrouped.md index 47f7aa2f04..cbeade39b0 100644 --- a/docs/reference/static-functions/functions/cell_getIsGrouped.md +++ b/docs/reference/static-functions/functions/cell_getIsGrouped.md @@ -9,7 +9,7 @@ title: cell_getIsGrouped function cell_getIsGrouped(cell): boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:307](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L307) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:343](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L343) Checks whether this cell represents the grouped column for a grouped row. diff --git a/docs/reference/static-functions/functions/cell_getIsPlaceholder.md b/docs/reference/static-functions/functions/cell_getIsPlaceholder.md index 35e83b2874..87e8e13faf 100644 --- a/docs/reference/static-functions/functions/cell_getIsPlaceholder.md +++ b/docs/reference/static-functions/functions/cell_getIsPlaceholder.md @@ -9,7 +9,7 @@ title: cell_getIsPlaceholder function cell_getIsPlaceholder(cell): boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:329](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L329) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:365](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L365) Checks whether this cell is a placeholder hidden by grouping. diff --git a/docs/reference/static-functions/functions/column_clearSorting.md b/docs/reference/static-functions/functions/column_clearSorting.md index 1313874a44..5ba08eb8b3 100644 --- a/docs/reference/static-functions/functions/column_clearSorting.md +++ b/docs/reference/static-functions/functions/column_clearSorting.md @@ -9,7 +9,7 @@ title: column_clearSorting function column_clearSorting(column): void; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:439](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L439) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:473](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L473) Removes this column from the sorting state. diff --git a/docs/reference/static-functions/functions/column_getAggregationFn.md b/docs/reference/static-functions/functions/column_getAggregationFn.md index 5348d1f7fd..5bfebdd205 100644 --- a/docs/reference/static-functions/functions/column_getAggregationFn.md +++ b/docs/reference/static-functions/functions/column_getAggregationFn.md @@ -11,7 +11,7 @@ function column_getAggregationFn(column): | undefined; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:185](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L185) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:202](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L202) Resolves the aggregation function configured for a column. @@ -41,7 +41,7 @@ the table's aggregation function registry. ## Returns - \| [`AggregationFn`](../../index/type-aliases/AggregationFn.md)\<`TFeatures`, `TData`\> + \| [`AggregationFn`](../../index/interfaces/AggregationFn.md)\<`TFeatures`, `TData`\> \| `undefined` ## Example diff --git a/docs/reference/static-functions/functions/column_getAutoAggregationFn.md b/docs/reference/static-functions/functions/column_getAutoAggregationFn.md index 2342a63f54..64a2a77905 100644 --- a/docs/reference/static-functions/functions/column_getAutoAggregationFn.md +++ b/docs/reference/static-functions/functions/column_getAutoAggregationFn.md @@ -11,13 +11,18 @@ function column_getAutoAggregationFn(column): | undefined; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:149](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L149) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:154](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L154) Chooses a built-in aggregation function from the first core row value. Numeric columns default to `sum`, date-like values default to `extent`, and other value types leave aggregation unspecified. +The chosen aggregation function is looked up in the table's +`aggregationFns` registry. When it is not registered there, this returns +`undefined` and warns in development instead of substituting a different +aggregation function. + ## Type Parameters ### TFeatures @@ -40,7 +45,7 @@ other value types leave aggregation unspecified. ## Returns - \| [`AggregationFn`](../../index/type-aliases/AggregationFn.md)\<`TFeatures`, `TData`\> + \| [`AggregationFn`](../../index/interfaces/AggregationFn.md)\<`TFeatures`, `TData`\> \| `undefined` ## Example diff --git a/docs/reference/static-functions/functions/column_getAutoFilterFn.md b/docs/reference/static-functions/functions/column_getAutoFilterFn.md index 0ac61bfd70..dbdebaf127 100644 --- a/docs/reference/static-functions/functions/column_getAutoFilterFn.md +++ b/docs/reference/static-functions/functions/column_getAutoFilterFn.md @@ -11,13 +11,17 @@ function column_getAutoFilterFn(column): | undefined; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:38](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L38) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:42](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L42) Chooses a built-in filter function from the column's first core row value. Strings use `includesString`, numbers use `inNumberRange`, booleans and -objects use `equals`, arrays use `arrIncludes`, and unknown values fall back -to `weakEquals`. +objects use `equals`, dates use `inDateRange`, arrays use `arrIncludes`, +and unknown values fall back to `weakEquals`. + +The chosen filter function is looked up in the table's `filterFns` +registry. When it is not registered there, this returns `undefined` and +warns in development instead of substituting a different filter function. ## Type Parameters diff --git a/docs/reference/static-functions/functions/column_getAutoSortDir.md b/docs/reference/static-functions/functions/column_getAutoSortDir.md index e9def13e60..d98a9f2d85 100644 --- a/docs/reference/static-functions/functions/column_getAutoSortDir.md +++ b/docs/reference/static-functions/functions/column_getAutoSortDir.md @@ -9,7 +9,7 @@ title: column_getAutoSortDir function column_getAutoSortDir(column): "asc" | "desc"; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:134](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L134) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:154](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L154) Chooses the default first sort direction from the first filtered row value. diff --git a/docs/reference/static-functions/functions/column_getCanFilter.md b/docs/reference/static-functions/functions/column_getCanFilter.md index 68172809b7..1b25b345bd 100644 --- a/docs/reference/static-functions/functions/column_getCanFilter.md +++ b/docs/reference/static-functions/functions/column_getCanFilter.md @@ -9,7 +9,7 @@ title: column_getCanFilter function column_getCanFilter(column): boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:121](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L121) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:137](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L137) Checks whether column filtering is enabled for this accessor column. diff --git a/docs/reference/static-functions/functions/column_getCanMultiSort.md b/docs/reference/static-functions/functions/column_getCanMultiSort.md index 4323b9cc72..85f7690845 100644 --- a/docs/reference/static-functions/functions/column_getCanMultiSort.md +++ b/docs/reference/static-functions/functions/column_getCanMultiSort.md @@ -9,7 +9,7 @@ title: column_getCanMultiSort function column_getCanMultiSort(column): boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:374](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L374) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:408](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L408) Checks whether this column can be added to a multi-sort state. diff --git a/docs/reference/static-functions/functions/column_getCanSort.md b/docs/reference/static-functions/functions/column_getCanSort.md index d9ce1403c1..f1bfb62a3f 100644 --- a/docs/reference/static-functions/functions/column_getCanSort.md +++ b/docs/reference/static-functions/functions/column_getCanSort.md @@ -9,7 +9,7 @@ title: column_getCanSort function column_getCanSort(column): boolean; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:351](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L351) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:385](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L385) Checks whether this accessor column can participate in sorting. diff --git a/docs/reference/static-functions/functions/column_getFilterFn.md b/docs/reference/static-functions/functions/column_getFilterFn.md index 7aa73dc62b..e2d625f120 100644 --- a/docs/reference/static-functions/functions/column_getFilterFn.md +++ b/docs/reference/static-functions/functions/column_getFilterFn.md @@ -11,7 +11,7 @@ function column_getFilterFn(column): | undefined; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:85](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L85) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:95](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L95) Resolves the filter function configured for a column. diff --git a/docs/reference/static-functions/functions/column_getFilterIndex.md b/docs/reference/static-functions/functions/column_getFilterIndex.md index 82a81e8777..4404c57d91 100644 --- a/docs/reference/static-functions/functions/column_getFilterIndex.md +++ b/docs/reference/static-functions/functions/column_getFilterIndex.md @@ -9,7 +9,7 @@ title: column_getFilterIndex function column_getFilterIndex(column): number; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:183](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L183) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:199](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L199) Finds this column's position in the ordered `state.columnFilters` array. diff --git a/docs/reference/static-functions/functions/column_getFilterValue.md b/docs/reference/static-functions/functions/column_getFilterValue.md index a738645ae7..f7bfab5636 100644 --- a/docs/reference/static-functions/functions/column_getFilterValue.md +++ b/docs/reference/static-functions/functions/column_getFilterValue.md @@ -9,7 +9,7 @@ title: column_getFilterValue function column_getFilterValue(column): unknown; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:163](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L163) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:179](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L179) Reads this column's current filter value from `state.columnFilters`. diff --git a/docs/reference/static-functions/functions/column_getFirstSortDir.md b/docs/reference/static-functions/functions/column_getFirstSortDir.md index b8edc89056..21dd3ad871 100644 --- a/docs/reference/static-functions/functions/column_getFirstSortDir.md +++ b/docs/reference/static-functions/functions/column_getFirstSortDir.md @@ -9,7 +9,7 @@ title: column_getFirstSortDir function column_getFirstSortDir(column): "asc" | "desc"; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:295](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L295) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:329](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L329) Resolves the first direction used when this column begins sorting. diff --git a/docs/reference/static-functions/functions/column_getIsFiltered.md b/docs/reference/static-functions/functions/column_getIsFiltered.md index b4993a390c..548203ddc5 100644 --- a/docs/reference/static-functions/functions/column_getIsFiltered.md +++ b/docs/reference/static-functions/functions/column_getIsFiltered.md @@ -9,7 +9,7 @@ title: column_getIsFiltered function column_getIsFiltered(column): boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:145](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L145) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:161](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L161) Checks whether this column currently has an entry in `state.columnFilters`. diff --git a/docs/reference/static-functions/functions/column_getIsSorted.md b/docs/reference/static-functions/functions/column_getIsSorted.md index 1a31293241..1d4f43894a 100644 --- a/docs/reference/static-functions/functions/column_getIsSorted.md +++ b/docs/reference/static-functions/functions/column_getIsSorted.md @@ -9,7 +9,7 @@ title: column_getIsSorted function column_getIsSorted(column): false | SortDirection; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:397](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L397) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:431](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L431) Reads this column's current sort direction. diff --git a/docs/reference/static-functions/functions/column_getNextSortingOrder.md b/docs/reference/static-functions/functions/column_getNextSortingOrder.md index 2d23ad1317..5e483e0a76 100644 --- a/docs/reference/static-functions/functions/column_getNextSortingOrder.md +++ b/docs/reference/static-functions/functions/column_getNextSortingOrder.md @@ -9,7 +9,7 @@ title: column_getNextSortingOrder function column_getNextSortingOrder(column, multi?): false | "asc" | "desc"; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:318](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L318) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:352](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L352) Resolves the next sort order for this column's toggle cycle. diff --git a/docs/reference/static-functions/functions/column_getSortFn.md b/docs/reference/static-functions/functions/column_getSortFn.md index 10b175fbdc..096bb4a593 100644 --- a/docs/reference/static-functions/functions/column_getSortFn.md +++ b/docs/reference/static-functions/functions/column_getSortFn.md @@ -9,7 +9,7 @@ title: column_getSortFn function column_getSortFn(column): SortFn; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:162](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L162) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:182](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L182) Resolves the sorting function configured for a column. diff --git a/docs/reference/static-functions/functions/column_getSortIndex.md b/docs/reference/static-functions/functions/column_getSortIndex.md index fda9d6062e..661803c5b4 100644 --- a/docs/reference/static-functions/functions/column_getSortIndex.md +++ b/docs/reference/static-functions/functions/column_getSortIndex.md @@ -9,7 +9,7 @@ title: column_getSortIndex function column_getSortIndex(column): number; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:418](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L418) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:452](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L452) Finds this column's position in the ordered `state.sorting` array. diff --git a/docs/reference/static-functions/functions/column_getToggleSortingHandler.md b/docs/reference/static-functions/functions/column_getToggleSortingHandler.md index c611a75540..10b91fdee1 100644 --- a/docs/reference/static-functions/functions/column_getToggleSortingHandler.md +++ b/docs/reference/static-functions/functions/column_getToggleSortingHandler.md @@ -9,7 +9,7 @@ title: column_getToggleSortingHandler function column_getToggleSortingHandler(column): (e) => void; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:462](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L462) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:496](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L496) Creates a header event handler that toggles this column's sorting. diff --git a/docs/reference/static-functions/functions/column_setFilterValue.md b/docs/reference/static-functions/functions/column_setFilterValue.md index c7cef8b547..90f3573bb5 100644 --- a/docs/reference/static-functions/functions/column_setFilterValue.md +++ b/docs/reference/static-functions/functions/column_setFilterValue.md @@ -9,7 +9,7 @@ title: column_setFilterValue function column_setFilterValue(column, value): void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:206](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L206) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:222](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L222) Adds, updates, or removes this column's filter value. diff --git a/docs/reference/static-functions/functions/column_toggleSorting.md b/docs/reference/static-functions/functions/column_toggleSorting.md index 7dec304044..997443fb6d 100644 --- a/docs/reference/static-functions/functions/column_toggleSorting.md +++ b/docs/reference/static-functions/functions/column_toggleSorting.md @@ -12,7 +12,7 @@ function column_toggleSorting( multi?): void; ``` -Defined in: [features/row-sorting/rowSortingFeature.utils.ts:189](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L189) +Defined in: [features/row-sorting/rowSortingFeature.utils.ts:223](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L223) Applies the next sorting state for this column. diff --git a/docs/reference/static-functions/functions/row_getGroupingValue.md b/docs/reference/static-functions/functions/row_getGroupingValue.md index f278f163fb..bc24be8e7a 100644 --- a/docs/reference/static-functions/functions/row_getGroupingValue.md +++ b/docs/reference/static-functions/functions/row_getGroupingValue.md @@ -9,7 +9,7 @@ title: row_getGroupingValue function row_getGroupingValue(row, columnId): any; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:269](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L269) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:305](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L305) Reads and caches this row's grouping value for a column. diff --git a/docs/reference/static-functions/functions/row_getIsGrouped.md b/docs/reference/static-functions/functions/row_getIsGrouped.md index 70e3ba5b4b..773d0447ee 100644 --- a/docs/reference/static-functions/functions/row_getIsGrouped.md +++ b/docs/reference/static-functions/functions/row_getIsGrouped.md @@ -9,7 +9,7 @@ title: row_getIsGrouped function row_getIsGrouped(row): boolean; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:251](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L251) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:287](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L287) Checks whether this row was created as a grouped row. diff --git a/docs/reference/static-functions/functions/shouldAutoRemoveFilter.md b/docs/reference/static-functions/functions/shouldAutoRemoveFilter.md index fd191963f2..52ccfef782 100644 --- a/docs/reference/static-functions/functions/shouldAutoRemoveFilter.md +++ b/docs/reference/static-functions/functions/shouldAutoRemoveFilter.md @@ -12,7 +12,7 @@ function shouldAutoRemoveFilter( column?): boolean; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:315](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L315) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:331](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L331) Returns whether a filter value should be removed from filter state. diff --git a/docs/reference/static-functions/functions/table_getGlobalAutoFilterFn.md b/docs/reference/static-functions/functions/table_getGlobalAutoFilterFn.md index 721529d659..570f745ab0 100644 --- a/docs/reference/static-functions/functions/table_getGlobalAutoFilterFn.md +++ b/docs/reference/static-functions/functions/table_getGlobalAutoFilterFn.md @@ -6,7 +6,7 @@ title: table_getGlobalAutoFilterFn # Function: table\_getGlobalAutoFilterFn() ```ts -function table_getGlobalAutoFilterFn(): (row, columnId, filterValue) => boolean & object; +function table_getGlobalAutoFilterFn(): CreatedFilterFn; ``` Defined in: [features/global-filtering/globalFilteringFeature.utils.ts:45](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts#L45) @@ -18,7 +18,7 @@ matching across globally filterable columns. ## Returns -\<`TFeatures`, `TData`\>(`row`, `columnId`, `filterValue`) => `boolean` & `object` +[`CreatedFilterFn`](../../index/interfaces/CreatedFilterFn.md)\<`any`, `any`\> ## Example diff --git a/docs/reference/static-functions/functions/table_resetColumnFilters.md b/docs/reference/static-functions/functions/table_resetColumnFilters.md index 1baf333769..589caa6095 100644 --- a/docs/reference/static-functions/functions/table_resetColumnFilters.md +++ b/docs/reference/static-functions/functions/table_resetColumnFilters.md @@ -9,7 +9,7 @@ title: table_resetColumnFilters function table_resetColumnFilters(table, defaultState?): void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:295](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L295) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:311](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L311) Resets `columnFilters` to the configured initial state or feature default. diff --git a/docs/reference/static-functions/functions/table_resetGlobalFilter.md b/docs/reference/static-functions/functions/table_resetGlobalFilter.md index 303853834a..1e371ebf2f 100644 --- a/docs/reference/static-functions/functions/table_resetGlobalFilter.md +++ b/docs/reference/static-functions/functions/table_resetGlobalFilter.md @@ -9,7 +9,7 @@ title: table_resetGlobalFilter function table_resetGlobalFilter(table, defaultState?): void; ``` -Defined in: [features/global-filtering/globalFilteringFeature.utils.ts:110](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts#L110) +Defined in: [features/global-filtering/globalFilteringFeature.utils.ts:122](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts#L122) Resets `globalFilter` to the configured initial state or feature default. diff --git a/docs/reference/static-functions/functions/table_resetGrouping.md b/docs/reference/static-functions/functions/table_resetGrouping.md index 08950d6b2b..025f95e395 100644 --- a/docs/reference/static-functions/functions/table_resetGrouping.md +++ b/docs/reference/static-functions/functions/table_resetGrouping.md @@ -9,7 +9,7 @@ title: table_resetGrouping function table_resetGrouping(table, defaultState?): void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:231](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L231) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:267](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L267) Resets `grouping` to the configured initial state or feature default. diff --git a/docs/reference/static-functions/functions/table_setColumnFilters.md b/docs/reference/static-functions/functions/table_setColumnFilters.md index 370b533e0a..abcc4415e7 100644 --- a/docs/reference/static-functions/functions/table_setColumnFilters.md +++ b/docs/reference/static-functions/functions/table_setColumnFilters.md @@ -9,7 +9,7 @@ title: table_setColumnFilters function table_setColumnFilters(table, updater): void; ``` -Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:255](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L255) +Defined in: [features/column-filtering/columnFilteringFeature.utils.ts:271](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-filtering/columnFilteringFeature.utils.ts#L271) Routes a column filter updater through the table's filter change handler. diff --git a/docs/reference/static-functions/functions/table_setGlobalFilter.md b/docs/reference/static-functions/functions/table_setGlobalFilter.md index c7d03febfb..d645e0803f 100644 --- a/docs/reference/static-functions/functions/table_setGlobalFilter.md +++ b/docs/reference/static-functions/functions/table_setGlobalFilter.md @@ -9,7 +9,7 @@ title: table_setGlobalFilter function table_setGlobalFilter(table, updater): void; ``` -Defined in: [features/global-filtering/globalFilteringFeature.utils.ts:91](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts#L91) +Defined in: [features/global-filtering/globalFilteringFeature.utils.ts:103](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/global-filtering/globalFilteringFeature.utils.ts#L103) Routes a global filter updater through the table's global filter handler. diff --git a/docs/reference/static-functions/functions/table_setGrouping.md b/docs/reference/static-functions/functions/table_setGrouping.md index dabff01095..c549c6bf06 100644 --- a/docs/reference/static-functions/functions/table_setGrouping.md +++ b/docs/reference/static-functions/functions/table_setGrouping.md @@ -9,7 +9,7 @@ title: table_setGrouping function table_setGrouping(table, updater): void; ``` -Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:212](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L212) +Defined in: [features/column-grouping/columnGroupingFeature.utils.ts:248](https://github.com/TanStack/table/blob/main/packages/table-core/src/features/column-grouping/columnGroupingFeature.utils.ts#L248) Routes a grouping updater through the table's grouping change handler. diff --git a/examples/alpine/basic-app-table/package.json b/examples/alpine/basic-app-table/package.json index e283911a08..55157ebcac 100644 --- a/examples/alpine/basic-app-table/package.json +++ b/examples/alpine/basic-app-table/package.json @@ -11,7 +11,7 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/basic-create-table/package.json b/examples/alpine/basic-create-table/package.json index ea27af80a0..539800bad0 100644 --- a/examples/alpine/basic-create-table/package.json +++ b/examples/alpine/basic-create-table/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/basic-dynamic-columns/package.json b/examples/alpine/basic-dynamic-columns/package.json index ff8f623540..a64bb294fd 100644 --- a/examples/alpine/basic-dynamic-columns/package.json +++ b/examples/alpine/basic-dynamic-columns/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/basic-dynamic-columns/src/main.ts b/examples/alpine/basic-dynamic-columns/src/main.ts index a2d68bb408..e8633ac82f 100644 --- a/examples/alpine/basic-dynamic-columns/src/main.ts +++ b/examples/alpine/basic-dynamic-columns/src/main.ts @@ -9,10 +9,13 @@ import { createFilteredRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -54,8 +57,17 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/alpine/basic-external-atoms/package.json b/examples/alpine/basic-external-atoms/package.json index f742b7da39..461d57db2a 100644 --- a/examples/alpine/basic-external-atoms/package.json +++ b/examples/alpine/basic-external-atoms/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "@tanstack/store": "^0.11.0", "alpinejs": "^3.15.12" }, diff --git a/examples/alpine/basic-external-atoms/src/main.ts b/examples/alpine/basic-external-atoms/src/main.ts index 27f6fb34d1..b8daf4563a 100644 --- a/examples/alpine/basic-external-atoms/src/main.ts +++ b/examples/alpine/basic-external-atoms/src/main.ts @@ -7,7 +7,8 @@ import { createTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { createAtom } from '@tanstack/store' @@ -26,7 +27,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/alpine/basic-external-state/package.json b/examples/alpine/basic-external-state/package.json index ee3ef13c0c..a898f0809a 100644 --- a/examples/alpine/basic-external-state/package.json +++ b/examples/alpine/basic-external-state/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/basic-external-state/src/main.ts b/examples/alpine/basic-external-state/src/main.ts index 601be6c0d6..7187e9a2bb 100644 --- a/examples/alpine/basic-external-state/src/main.ts +++ b/examples/alpine/basic-external-state/src/main.ts @@ -7,7 +7,8 @@ import { createTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -25,7 +26,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/alpine/column-groups/package.json b/examples/alpine/column-groups/package.json index ad86d2589b..b4200dd240 100644 --- a/examples/alpine/column-groups/package.json +++ b/examples/alpine/column-groups/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-ordering/package.json b/examples/alpine/column-ordering/package.json index 4222828258..7ddf6a39a0 100644 --- a/examples/alpine/column-ordering/package.json +++ b/examples/alpine/column-ordering/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-pinning-split/package.json b/examples/alpine/column-pinning-split/package.json index 2344874b44..b9da4cc70b 100644 --- a/examples/alpine/column-pinning-split/package.json +++ b/examples/alpine/column-pinning-split/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-pinning-sticky/package.json b/examples/alpine/column-pinning-sticky/package.json index 3f80196b26..ea84b75dd2 100644 --- a/examples/alpine/column-pinning-sticky/package.json +++ b/examples/alpine/column-pinning-sticky/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-pinning/package.json b/examples/alpine/column-pinning/package.json index 1cd53825be..18bb86b74a 100644 --- a/examples/alpine/column-pinning/package.json +++ b/examples/alpine/column-pinning/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-resizing-performant/package.json b/examples/alpine/column-resizing-performant/package.json index dfecbc2a7c..3d59155215 100644 --- a/examples/alpine/column-resizing-performant/package.json +++ b/examples/alpine/column-resizing-performant/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-resizing/package.json b/examples/alpine/column-resizing/package.json index 5542f00694..059f5e54c1 100644 --- a/examples/alpine/column-resizing/package.json +++ b/examples/alpine/column-resizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-sizing/package.json b/examples/alpine/column-sizing/package.json index 96b48a840a..f463d83c83 100644 --- a/examples/alpine/column-sizing/package.json +++ b/examples/alpine/column-sizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/column-visibility/package.json b/examples/alpine/column-visibility/package.json index 1ad6772f5a..1c3b1ef0b0 100644 --- a/examples/alpine/column-visibility/package.json +++ b/examples/alpine/column-visibility/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/custom-plugin/package.json b/examples/alpine/custom-plugin/package.json index 55f0cdbd3d..800f6f8ac8 100644 --- a/examples/alpine/custom-plugin/package.json +++ b/examples/alpine/custom-plugin/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/custom-plugin/src/main.ts b/examples/alpine/custom-plugin/src/main.ts index 644e5e011b..43b9532180 100644 --- a/examples/alpine/custom-plugin/src/main.ts +++ b/examples/alpine/custom-plugin/src/main.ts @@ -8,12 +8,14 @@ import { createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, functionalUpdate, makeStateUpdater, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -131,8 +133,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/alpine/expanding/package.json b/examples/alpine/expanding/package.json index fa77400456..530a75a5ec 100644 --- a/examples/alpine/expanding/package.json +++ b/examples/alpine/expanding/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/expanding/src/main.ts b/examples/alpine/expanding/src/main.ts index 6067dd30a5..8e14407c36 100644 --- a/examples/alpine/expanding/src/main.ts +++ b/examples/alpine/expanding/src/main.ts @@ -7,12 +7,14 @@ import { createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -30,8 +32,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) // The `firstName` column renders an interactive selection checkbox + expander in diff --git a/examples/alpine/filters-faceted/package.json b/examples/alpine/filters-faceted/package.json index ddc8cbcf11..a7a77c0ec1 100644 --- a/examples/alpine/filters-faceted/package.json +++ b/examples/alpine/filters-faceted/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/filters-faceted/src/main.ts b/examples/alpine/filters-faceted/src/main.ts index 6af9a02b15..b4036a793f 100644 --- a/examples/alpine/filters-faceted/src/main.ts +++ b/examples/alpine/filters-faceted/src/main.ts @@ -9,7 +9,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -29,7 +30,10 @@ const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columns: Array> = [ diff --git a/examples/alpine/filters/package.json b/examples/alpine/filters/package.json index ae32acef7a..73de94bc55 100644 --- a/examples/alpine/filters/package.json +++ b/examples/alpine/filters/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/filters/src/main.ts b/examples/alpine/filters/src/main.ts index 4670a0a4ea..4e79063a74 100644 --- a/examples/alpine/filters/src/main.ts +++ b/examples/alpine/filters/src/main.ts @@ -5,7 +5,9 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -25,7 +27,11 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -68,6 +74,7 @@ const columns: Array> = [ { accessorKey: 'status', header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -78,6 +85,8 @@ const columns: Array> = [ meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }, ] diff --git a/examples/alpine/grouping/package.json b/examples/alpine/grouping/package.json index 3cad40fffa..5cf6b957db 100644 --- a/examples/alpine/grouping/package.json +++ b/examples/alpine/grouping/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/grouping/src/main.ts b/examples/alpine/grouping/src/main.ts index b891b54775..144d3d5d73 100644 --- a/examples/alpine/grouping/src/main.ts +++ b/examples/alpine/grouping/src/main.ts @@ -1,7 +1,9 @@ import Alpine from 'alpinejs' import { FlexRender, - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createColumnHelper, @@ -11,11 +13,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -34,9 +38,19 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/alpine/pagination/package.json b/examples/alpine/pagination/package.json index 4a3a5abf6b..7cde522118 100644 --- a/examples/alpine/pagination/package.json +++ b/examples/alpine/pagination/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/row-pinning/package.json b/examples/alpine/row-pinning/package.json index 5740052b06..02cbcc2165 100644 --- a/examples/alpine/row-pinning/package.json +++ b/examples/alpine/row-pinning/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/row-pinning/src/main.ts b/examples/alpine/row-pinning/src/main.ts index cfdc9be7de..af7678e85c 100644 --- a/examples/alpine/row-pinning/src/main.ts +++ b/examples/alpine/row-pinning/src/main.ts @@ -6,7 +6,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, @@ -25,7 +26,10 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) // The `pin` column (pin buttons) and the `firstName` cell (expander + value) diff --git a/examples/alpine/row-selection/package.json b/examples/alpine/row-selection/package.json index c95d81a0f1..6ca54fedfe 100644 --- a/examples/alpine/row-selection/package.json +++ b/examples/alpine/row-selection/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/row-selection/src/main.ts b/examples/alpine/row-selection/src/main.ts index 55029d1496..c4f38e18ad 100644 --- a/examples/alpine/row-selection/src/main.ts +++ b/examples/alpine/row-selection/src/main.ts @@ -5,7 +5,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, tableFeatures, @@ -21,7 +22,10 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) // The `select` column renders interactive checkboxes in its header (select-all) diff --git a/examples/alpine/sorting-dynamic-data/package.json b/examples/alpine/sorting-dynamic-data/package.json index 1a7819a6fa..382f6ed4b2 100644 --- a/examples/alpine/sorting-dynamic-data/package.json +++ b/examples/alpine/sorting-dynamic-data/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/sorting-dynamic-data/src/main.ts b/examples/alpine/sorting-dynamic-data/src/main.ts index cc0e523b63..275d361d1a 100644 --- a/examples/alpine/sorting-dynamic-data/src/main.ts +++ b/examples/alpine/sorting-dynamic-data/src/main.ts @@ -4,7 +4,9 @@ import { createSortedRowModel, createTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -15,7 +17,11 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const sortStatusFn: SortFn = ( diff --git a/examples/alpine/sorting/package.json b/examples/alpine/sorting/package.json index 98ea57e1c3..9f0be8fbd0 100644 --- a/examples/alpine/sorting/package.json +++ b/examples/alpine/sorting/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/alpine/sorting/src/main.ts b/examples/alpine/sorting/src/main.ts index 03afe5b542..1505aef550 100644 --- a/examples/alpine/sorting/src/main.ts +++ b/examples/alpine/sorting/src/main.ts @@ -4,7 +4,9 @@ import { createSortedRowModel, createTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/alpine-table' import { makeData } from './makeData' @@ -15,7 +17,11 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const sortStatusFn: SortFn = ( diff --git a/examples/alpine/sub-components/package.json b/examples/alpine/sub-components/package.json index b368b207fd..9d69614696 100644 --- a/examples/alpine/sub-components/package.json +++ b/examples/alpine/sub-components/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.0.0-beta.46", + "@tanstack/alpine-table": "^9.0.0-beta.47", "alpinejs": "^3.15.12" }, "devDependencies": { diff --git a/examples/angular/basic-app-table/package.json b/examples/angular/basic-app-table/package.json index 993f037b1a..a0fce057ee 100644 --- a/examples/angular/basic-app-table/package.json +++ b/examples/angular/basic-app-table/package.json @@ -20,8 +20,8 @@ "@angular/platform-browser": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/basic-dynamic-columns/package.json b/examples/angular/basic-dynamic-columns/package.json index 5aeb508fd8..383d9b179f 100644 --- a/examples/angular/basic-dynamic-columns/package.json +++ b/examples/angular/basic-dynamic-columns/package.json @@ -21,7 +21,7 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-pacer": "^0.23.1", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/basic-dynamic-columns/src/app/app.ts b/examples/angular/basic-dynamic-columns/src/app/app.ts index 51507a26eb..fa4e9eb595 100644 --- a/examples/angular/basic-dynamic-columns/src/app/app.ts +++ b/examples/angular/basic-dynamic-columns/src/app/app.ts @@ -14,11 +14,14 @@ import { createFilteredRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, isFunction, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, } from '@tanstack/angular-table' import { makeData } from './makeData' @@ -61,8 +64,17 @@ export const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/angular/basic-external-atoms/package.json b/examples/angular/basic-external-atoms/package.json index f2dfe1331a..d20679cd0f 100644 --- a/examples/angular/basic-external-atoms/package.json +++ b/examples/angular/basic-external-atoms/package.json @@ -21,8 +21,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", "@tanstack/angular-store": "^0.11.0", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/basic-external-atoms/src/app/app.ts b/examples/angular/basic-external-atoms/src/app/app.ts index 99abe83fb2..c0d52d32f4 100644 --- a/examples/angular/basic-external-atoms/src/app/app.ts +++ b/examples/angular/basic-external-atoms/src/app/app.ts @@ -15,7 +15,8 @@ import { injectTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { injectTanStackTableDevtools } from '@tanstack/angular-table-devtools' @@ -28,7 +29,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/angular/basic-external-state/package.json b/examples/angular/basic-external-state/package.json index 0cc0446d2c..e5f31f1a15 100644 --- a/examples/angular/basic-external-state/package.json +++ b/examples/angular/basic-external-state/package.json @@ -21,8 +21,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", "@tanstack/angular-store": "^0.11.0", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/basic-external-state/src/app/app.ts b/examples/angular/basic-external-state/src/app/app.ts index 5ac11d6969..7f18c154c2 100644 --- a/examples/angular/basic-external-state/src/app/app.ts +++ b/examples/angular/basic-external-state/src/app/app.ts @@ -13,7 +13,8 @@ import { injectTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { injectTanStackTableDevtools } from '@tanstack/angular-table-devtools' @@ -30,7 +31,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/angular/basic-inject-table/package.json b/examples/angular/basic-inject-table/package.json index 74646bb602..001725cfb5 100644 --- a/examples/angular/basic-inject-table/package.json +++ b/examples/angular/basic-inject-table/package.json @@ -21,8 +21,8 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-groups/package.json b/examples/angular/column-groups/package.json index 4b3ebbdbc7..fdf28c7035 100644 --- a/examples/angular/column-groups/package.json +++ b/examples/angular/column-groups/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-ordering/package.json b/examples/angular/column-ordering/package.json index f253d2f460..7fbaa8907c 100644 --- a/examples/angular/column-ordering/package.json +++ b/examples/angular/column-ordering/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-pinning-split/package.json b/examples/angular/column-pinning-split/package.json index 4b8e6fca58..55b6fff0dd 100644 --- a/examples/angular/column-pinning-split/package.json +++ b/examples/angular/column-pinning-split/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-pinning-sticky/package.json b/examples/angular/column-pinning-sticky/package.json index 1098bb7b18..3b781c125e 100644 --- a/examples/angular/column-pinning-sticky/package.json +++ b/examples/angular/column-pinning-sticky/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-pinning/package.json b/examples/angular/column-pinning/package.json index dc777fdd4a..7da0830e13 100644 --- a/examples/angular/column-pinning/package.json +++ b/examples/angular/column-pinning/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-resizing-performant/package.json b/examples/angular/column-resizing-performant/package.json index e6364794c9..df9f3c8a63 100644 --- a/examples/angular/column-resizing-performant/package.json +++ b/examples/angular/column-resizing-performant/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-resizing/package.json b/examples/angular/column-resizing/package.json index a9c298a07a..582b89a1ee 100644 --- a/examples/angular/column-resizing/package.json +++ b/examples/angular/column-resizing/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-sizing/package.json b/examples/angular/column-sizing/package.json index 490f87751e..6335d0d3e4 100644 --- a/examples/angular/column-sizing/package.json +++ b/examples/angular/column-sizing/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/column-visibility/package.json b/examples/angular/column-visibility/package.json index 90d4913374..61d9deed1a 100644 --- a/examples/angular/column-visibility/package.json +++ b/examples/angular/column-visibility/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/composable-tables/package.json b/examples/angular/composable-tables/package.json index 6291b215db..12a79457a5 100644 --- a/examples/angular/composable-tables/package.json +++ b/examples/angular/composable-tables/package.json @@ -21,8 +21,8 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/composable-tables/src/app/table.ts b/examples/angular/composable-tables/src/app/table.ts index 5d6a897920..d09f458d30 100644 --- a/examples/angular/composable-tables/src/app/table.ts +++ b/examples/angular/composable-tables/src/app/table.ts @@ -11,11 +11,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' @@ -74,8 +76,14 @@ export const { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }), // set any default table options here too diff --git a/examples/angular/custom-plugin/package.json b/examples/angular/custom-plugin/package.json index fa3a60e5d5..d302f0851c 100644 --- a/examples/angular/custom-plugin/package.json +++ b/examples/angular/custom-plugin/package.json @@ -19,7 +19,7 @@ "@angular/forms": "^22.0.2", "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/editable/package.json b/examples/angular/editable/package.json index 000a69831e..e50eb0b0b8 100644 --- a/examples/angular/editable/package.json +++ b/examples/angular/editable/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/expanding/package.json b/examples/angular/expanding/package.json index 3e65fa2ac5..5abc25849f 100644 --- a/examples/angular/expanding/package.json +++ b/examples/angular/expanding/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/filters-faceted/package.json b/examples/angular/filters-faceted/package.json index 196cbd2f86..7ebb318d5d 100644 --- a/examples/angular/filters-faceted/package.json +++ b/examples/angular/filters-faceted/package.json @@ -21,7 +21,7 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-pacer": "^0.23.1", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/filters-faceted/src/app/app.ts b/examples/angular/filters-faceted/src/app/app.ts index 18ab0378df..1fea9d2d95 100644 --- a/examples/angular/filters-faceted/src/app/app.ts +++ b/examples/angular/filters-faceted/src/app/app.ts @@ -9,7 +9,9 @@ import { createFilteredRowModel, createPaginatedRowModel, createTableHook, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, isFunction, metaHelper, rowPaginationFeature, @@ -35,7 +37,11 @@ export const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, }) const { injectAppTable, createAppColumnHelper } = createTableHook({ @@ -70,6 +76,7 @@ const columns = columnHelper.columns([ }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -79,6 +86,8 @@ const columns = columnHelper.columns([ meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]) diff --git a/examples/angular/filters-fuzzy/package.json b/examples/angular/filters-fuzzy/package.json index bebad85e8f..58f18df1c7 100644 --- a/examples/angular/filters-fuzzy/package.json +++ b/examples/angular/filters-fuzzy/package.json @@ -21,7 +21,7 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-pacer": "^0.23.1", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "rxjs": "~7.8.2", "tslib": "^2.8.1" diff --git a/examples/angular/filters-fuzzy/src/app/app.ts b/examples/angular/filters-fuzzy/src/app/app.ts index 91dc3ab31d..95e2580d06 100644 --- a/examples/angular/filters-fuzzy/src/app/app.ts +++ b/examples/angular/filters-fuzzy/src/app/app.ts @@ -7,13 +7,13 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, injectTable, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { DebouncedInput } from './debounced-input/debounced-input' @@ -47,7 +47,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -58,8 +58,12 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { fuzzy: fuzzyFilter }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + fuzzy: fuzzySort, + text: sortFn_text, + }, filterMeta: metaHelper(), }) const columnHelper = createColumnHelper() diff --git a/examples/angular/filters/package.json b/examples/angular/filters/package.json index de03596aba..3cdb79585b 100644 --- a/examples/angular/filters/package.json +++ b/examples/angular/filters/package.json @@ -21,7 +21,7 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-pacer": "^0.23.1", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/filters/src/app/app.ts b/examples/angular/filters/src/app/app.ts index de31909604..1b67501aab 100644 --- a/examples/angular/filters/src/app/app.ts +++ b/examples/angular/filters/src/app/app.ts @@ -5,7 +5,9 @@ import { createFilteredRowModel, createPaginatedRowModel, createTableHook, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, isFunction, metaHelper, rowPaginationFeature, @@ -27,7 +29,11 @@ export const features = tableFeatures({ columnMeta: metaHelper(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, }) const { injectAppTable, createAppColumnHelper } = createTableHook({ @@ -67,6 +73,7 @@ const columns = columnHelper.columns([ }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -76,6 +83,8 @@ const columns = columnHelper.columns([ meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]) diff --git a/examples/angular/grouping/package.json b/examples/angular/grouping/package.json index e66c36bab5..2212dc1a37 100644 --- a/examples/angular/grouping/package.json +++ b/examples/angular/grouping/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/grouping/src/app/columns.ts b/examples/angular/grouping/src/app/columns.ts index 7990ef9b19..16f2dd79ba 100644 --- a/examples/angular/grouping/src/app/columns.ts +++ b/examples/angular/grouping/src/app/columns.ts @@ -1,5 +1,7 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createExpandedRowModel, @@ -7,7 +9,6 @@ import { createGroupedRowModel, createPaginatedRowModel, createTableHook, - filterFns, rowExpandingFeature, rowPaginationFeature, tableFeatures, @@ -23,8 +24,11 @@ const features = tableFeatures({ expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - aggregationFns, - filterFns, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) export const { createAppColumnHelper, injectAppTable: injectTable } = diff --git a/examples/angular/kitchen-sink/package.json b/examples/angular/kitchen-sink/package.json index e5cc8c4e63..5392b9cb01 100644 --- a/examples/angular/kitchen-sink/package.json +++ b/examples/angular/kitchen-sink/package.json @@ -21,8 +21,8 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "rxjs": "~7.8.2", "tslib": "^2.8.1" diff --git a/examples/angular/kitchen-sink/src/app/app.ts b/examples/angular/kitchen-sink/src/app/app.ts index 0938dbcfd7..7f5c6f97c5 100644 --- a/examples/angular/kitchen-sink/src/app/app.ts +++ b/examples/angular/kitchen-sink/src/app/app.ts @@ -9,7 +9,9 @@ import { NgStyle } from '@angular/common' import { faker } from '@faker-js/faker' import { FlexRender, - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, createColumnHelper, createExpandedRowModel, createFacetedMinMaxValues, @@ -19,10 +21,12 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, injectTable, metaHelper, - sortFns, + sortFn_alphanumeric, + sortFn_text, stockFeatures, tableFeatures, } from '@tanstack/angular-table' @@ -76,7 +80,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const sortStatusFn: SortFn = (rowA, rowB) => { @@ -98,9 +102,22 @@ export const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort, sortStatus: sortStatusFn }, - aggregationFns, + filterFns: { + fuzzy: fuzzyFilter, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + fuzzy: fuzzySort, + sortStatus: sortStatusFn, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, filterMeta: metaHelper(), }) diff --git a/examples/angular/pagination/package.json b/examples/angular/pagination/package.json index 86032e753c..6a6b59c6ce 100644 --- a/examples/angular/pagination/package.json +++ b/examples/angular/pagination/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/remote-data/package.json b/examples/angular/remote-data/package.json index 8daca2dda4..e8f6a48c72 100644 --- a/examples/angular/remote-data/package.json +++ b/examples/angular/remote-data/package.json @@ -25,7 +25,7 @@ "@angular/platform-server": "^22.0.2", "@angular/router": "^22.0.2", "@angular/ssr": "^22.0.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "express": "^5.2.1", "rxjs": "~7.8.2" }, diff --git a/examples/angular/row-dnd/package.json b/examples/angular/row-dnd/package.json index 2baa637f8b..9c88ddad47 100644 --- a/examples/angular/row-dnd/package.json +++ b/examples/angular/row-dnd/package.json @@ -21,7 +21,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/row-pinning/package.json b/examples/angular/row-pinning/package.json index 7d7c8eadb4..3d12dacbbf 100644 --- a/examples/angular/row-pinning/package.json +++ b/examples/angular/row-pinning/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/row-pinning/src/app/app.ts b/examples/angular/row-pinning/src/app/app.ts index 340e314898..d656146a2b 100644 --- a/examples/angular/row-pinning/src/app/app.ts +++ b/examples/angular/row-pinning/src/app/app.ts @@ -6,7 +6,6 @@ import { createExpandedRowModel, createFilteredRowModel, createPaginatedRowModel, - filterFns, injectTable, isFunction, rowExpandingFeature, @@ -32,7 +31,6 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, }) const columns: Array> = [ { diff --git a/examples/angular/row-selection-signal/package.json b/examples/angular/row-selection-signal/package.json index eec89081a2..c2f9e6d8f6 100644 --- a/examples/angular/row-selection-signal/package.json +++ b/examples/angular/row-selection-signal/package.json @@ -23,8 +23,8 @@ "@angular/platform-browser-dynamic": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/row-selection-signal/src/app/app.component.ts b/examples/angular/row-selection-signal/src/app/app.component.ts index 439bfebb49..1b657a48f2 100644 --- a/examples/angular/row-selection-signal/src/app/app.component.ts +++ b/examples/angular/row-selection-signal/src/app/app.component.ts @@ -13,7 +13,8 @@ import { columnVisibilityFeature, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, injectTable, rowPaginationFeature, rowSelectionFeature, @@ -37,7 +38,10 @@ export const features = tableFeatures({ rowSelectionFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) @Component({ diff --git a/examples/angular/row-selection/package.json b/examples/angular/row-selection/package.json index 07ba2176c7..66d1f0a5e2 100644 --- a/examples/angular/row-selection/package.json +++ b/examples/angular/row-selection/package.json @@ -22,8 +22,8 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/row-selection/src/app/table.ts b/examples/angular/row-selection/src/app/table.ts index dd1efb8c4a..0bc4ad616c 100644 --- a/examples/angular/row-selection/src/app/table.ts +++ b/examples/angular/row-selection/src/app/table.ts @@ -3,7 +3,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTableHook, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -17,7 +18,10 @@ export const features = tableFeatures({ rowSelectionFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) export const { diff --git a/examples/angular/signal-input/package.json b/examples/angular/signal-input/package.json index f127ac5d57..d831ff7178 100644 --- a/examples/angular/signal-input/package.json +++ b/examples/angular/signal-input/package.json @@ -21,7 +21,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/sorting/package.json b/examples/angular/sorting/package.json index 1e01407d3f..ca4c599f16 100644 --- a/examples/angular/sorting/package.json +++ b/examples/angular/sorting/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/sorting/src/app/app.ts b/examples/angular/sorting/src/app/app.ts index b2f32455f7..5b164f782b 100644 --- a/examples/angular/sorting/src/app/app.ts +++ b/examples/angular/sorting/src/app/app.ts @@ -4,7 +4,9 @@ import { createSortedRowModel, injectTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { makeData } from './makeData' @@ -14,7 +16,11 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const sortStatusFn: SortFn = (rowA, rowB) => { diff --git a/examples/angular/sub-components/package.json b/examples/angular/sub-components/package.json index 558451a468..8ab11c436b 100644 --- a/examples/angular/sub-components/package.json +++ b/examples/angular/sub-components/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/angular/virtualized-columns/package.json b/examples/angular/virtualized-columns/package.json index 2853dd35fa..735212a96d 100644 --- a/examples/angular/virtualized-columns/package.json +++ b/examples/angular/virtualized-columns/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "@tanstack/angular-virtual": "^5.0.7", "rxjs": "~7.8.2", "tslib": "^2.8.1" diff --git a/examples/angular/virtualized-columns/src/app/app.ts b/examples/angular/virtualized-columns/src/app/app.ts index d90b171844..51436284ce 100644 --- a/examples/angular/virtualized-columns/src/app/app.ts +++ b/examples/angular/virtualized-columns/src/app/app.ts @@ -16,7 +16,8 @@ import { createSortedRowModel, injectTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { injectVirtualizer } from '@tanstack/angular-virtual' @@ -30,7 +31,10 @@ const features = tableFeatures({ columnVisibilityFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/angular/virtualized-infinite-scrolling/package.json b/examples/angular/virtualized-infinite-scrolling/package.json index ce73adb51c..33d3793bb3 100644 --- a/examples/angular/virtualized-infinite-scrolling/package.json +++ b/examples/angular/virtualized-infinite-scrolling/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "@tanstack/angular-virtual": "^5.0.7", "rxjs": "~7.8.2", "tslib": "^2.8.1" diff --git a/examples/angular/virtualized-infinite-scrolling/src/app/app.ts b/examples/angular/virtualized-infinite-scrolling/src/app/app.ts index fc6f5850c9..60652fd5e7 100644 --- a/examples/angular/virtualized-infinite-scrolling/src/app/app.ts +++ b/examples/angular/virtualized-infinite-scrolling/src/app/app.ts @@ -14,7 +14,9 @@ import { functionalUpdate, injectTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { injectVirtualizer } from '@tanstack/angular-virtual' @@ -29,7 +31,11 @@ const features = tableFeatures({ columnSizingFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/angular/virtualized-rows/package.json b/examples/angular/virtualized-rows/package.json index 9c80107e08..c940f2b159 100644 --- a/examples/angular/virtualized-rows/package.json +++ b/examples/angular/virtualized-rows/package.json @@ -20,7 +20,7 @@ "@angular/platform-browser": "^22.0.2", "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "@tanstack/angular-virtual": "^5.0.7", "rxjs": "~7.8.2", "tslib": "^2.8.1" diff --git a/examples/angular/virtualized-rows/src/app/app.ts b/examples/angular/virtualized-rows/src/app/app.ts index 1ac567baa7..52e5caf186 100644 --- a/examples/angular/virtualized-rows/src/app/app.ts +++ b/examples/angular/virtualized-rows/src/app/app.ts @@ -13,7 +13,9 @@ import { injectTable, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { injectVirtualizer } from '@tanstack/angular-virtual' @@ -27,7 +29,11 @@ const features = tableFeatures({ rowSelectionFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/angular/with-tanstack-form/package.json b/examples/angular/with-tanstack-form/package.json index ccb7623d95..7c464bf0b8 100644 --- a/examples/angular/with-tanstack-form/package.json +++ b/examples/angular/with-tanstack-form/package.json @@ -22,8 +22,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/angular-devtools": "^0.0.7", "@tanstack/angular-form": "^1.33.1", - "@tanstack/angular-table": "^9.0.0-beta.46", - "@tanstack/angular-table-devtools": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", + "@tanstack/angular-table-devtools": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1", "zod": "^4.4.3" diff --git a/examples/angular/with-tanstack-form/src/app/table.ts b/examples/angular/with-tanstack-form/src/app/table.ts index 418413a8d3..daa21b6af2 100644 --- a/examples/angular/with-tanstack-form/src/app/table.ts +++ b/examples/angular/with-tanstack-form/src/app/table.ts @@ -4,10 +4,12 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/angular-table' import { ColumnFilter, SortIndicator } from './header-components' @@ -20,8 +22,14 @@ export const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) export const { diff --git a/examples/angular/with-tanstack-query/package.json b/examples/angular/with-tanstack-query/package.json index da43b09f7f..4461a0bf4e 100644 --- a/examples/angular/with-tanstack-query/package.json +++ b/examples/angular/with-tanstack-query/package.json @@ -21,7 +21,7 @@ "@angular/router": "^22.0.2", "@faker-js/faker": "^10.5.0", "@tanstack/angular-query-experimental": "^5.101.2", - "@tanstack/angular-table": "^9.0.0-beta.46", + "@tanstack/angular-table": "^9.0.0-beta.47", "rxjs": "~7.8.2", "tslib": "^2.8.1" }, diff --git a/examples/ember/basic-app-table/package.json b/examples/ember/basic-app-table/package.json index b6872150d9..f3b60d78f5 100644 --- a/examples/ember/basic-app-table/package.json +++ b/examples/ember/basic-app-table/package.json @@ -43,7 +43,7 @@ "@glint/tsserver-plugin": "2.5.17", "@nullvoxpopuli/ember-vite": "1.0.3", "@rollup/plugin-babel": "7.1.0", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "babel-plugin-ember-template-compilation": "4.0.0", "typescript": "6.0.3", "vite": "^8.1.0" diff --git a/examples/ember/basic-external-atoms/app/templates/application.gts b/examples/ember/basic-external-atoms/app/templates/application.gts index 5f41d9fc30..098f9ea235 100644 --- a/examples/ember/basic-external-atoms/app/templates/application.gts +++ b/examples/ember/basic-external-atoms/app/templates/application.gts @@ -11,7 +11,8 @@ import { rowPaginationFeature, createSortedRowModel, createPaginatedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, createColumnHelper, type Column, type Row, @@ -26,7 +27,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/basic-external-atoms/package.json b/examples/ember/basic-external-atoms/package.json index 8683462d1e..56fdff9b92 100644 --- a/examples/ember/basic-external-atoms/package.json +++ b/examples/ember/basic-external-atoms/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/basic-external-state/app/templates/application.gts b/examples/ember/basic-external-state/app/templates/application.gts index fa07688099..4acf3dc5f9 100644 --- a/examples/ember/basic-external-state/app/templates/application.gts +++ b/examples/ember/basic-external-state/app/templates/application.gts @@ -10,7 +10,8 @@ import { rowPaginationFeature, createSortedRowModel, createPaginatedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, createColumnHelper, type Column, type Row, @@ -25,7 +26,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/basic-external-state/package.json b/examples/ember/basic-external-state/package.json index cf197b03de..51827f9add 100644 --- a/examples/ember/basic-external-state/package.json +++ b/examples/ember/basic-external-state/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/basic-table/package.json b/examples/ember/basic-table/package.json index 771d80583a..f326444e9a 100644 --- a/examples/ember/basic-table/package.json +++ b/examples/ember/basic-table/package.json @@ -43,7 +43,7 @@ "@glint/tsserver-plugin": "2.5.17", "@nullvoxpopuli/ember-vite": "1.0.3", "@rollup/plugin-babel": "7.1.0", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "babel-plugin-ember-template-compilation": "4.0.0", "typescript": "6.0.3", "vite": "^8.1.0" diff --git a/examples/ember/column-groups/package.json b/examples/ember/column-groups/package.json index fca9e21fed..9e24b54211 100644 --- a/examples/ember/column-groups/package.json +++ b/examples/ember/column-groups/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-ordering/package.json b/examples/ember/column-ordering/package.json index 92e5ebdc5e..7197332bb0 100644 --- a/examples/ember/column-ordering/package.json +++ b/examples/ember/column-ordering/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-pinning-split/package.json b/examples/ember/column-pinning-split/package.json index 3c83dd9216..c09171fa28 100644 --- a/examples/ember/column-pinning-split/package.json +++ b/examples/ember/column-pinning-split/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-pinning-sticky/package.json b/examples/ember/column-pinning-sticky/package.json index 160977b472..2383a2fda4 100644 --- a/examples/ember/column-pinning-sticky/package.json +++ b/examples/ember/column-pinning-sticky/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-pinning/package.json b/examples/ember/column-pinning/package.json index 0ecc11927e..986a29cd7f 100644 --- a/examples/ember/column-pinning/package.json +++ b/examples/ember/column-pinning/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-resizing-performant/package.json b/examples/ember/column-resizing-performant/package.json index beeefe2f14..d81f64d884 100644 --- a/examples/ember/column-resizing-performant/package.json +++ b/examples/ember/column-resizing-performant/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-resizing/package.json b/examples/ember/column-resizing/package.json index f1ab71cae5..f6a0babecf 100644 --- a/examples/ember/column-resizing/package.json +++ b/examples/ember/column-resizing/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-sizing/package.json b/examples/ember/column-sizing/package.json index c886b44d37..7e6948d8ba 100644 --- a/examples/ember/column-sizing/package.json +++ b/examples/ember/column-sizing/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/column-visibility/package.json b/examples/ember/column-visibility/package.json index 366cdfb385..ca17b849ac 100644 --- a/examples/ember/column-visibility/package.json +++ b/examples/ember/column-visibility/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/custom-plugin/app/templates/application.gts b/examples/ember/custom-plugin/app/templates/application.gts index c4bacc4cce..1dab892c12 100644 --- a/examples/ember/custom-plugin/app/templates/application.gts +++ b/examples/ember/custom-plugin/app/templates/application.gts @@ -9,10 +9,12 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, rowPaginationFeature, createPaginatedRowModel, createColumnHelper, @@ -136,8 +138,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/custom-plugin/package.json b/examples/ember/custom-plugin/package.json index 1aee9eb461..8bc43fba2c 100644 --- a/examples/ember/custom-plugin/package.json +++ b/examples/ember/custom-plugin/package.json @@ -28,8 +28,8 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", - "@tanstack/table-core": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", + "@tanstack/table-core": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/editable/package.json b/examples/ember/editable/package.json index 54e05f567c..e027269df8 100644 --- a/examples/ember/editable/package.json +++ b/examples/ember/editable/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/expanding/app/templates/application.gts b/examples/ember/expanding/app/templates/application.gts index 28c57d7ffc..6c65364f26 100644 --- a/examples/ember/expanding/app/templates/application.gts +++ b/examples/ember/expanding/app/templates/application.gts @@ -15,8 +15,11 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, - sortFns, + filterFn_between, + filterFn_includesString, + filterFn_inNumberRange, + sortFn_alphanumeric, + sortFn_text, createColumnHelper, type Column, type Row, @@ -35,8 +38,15 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + between: filterFn_between, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/expanding/package.json b/examples/ember/expanding/package.json index 81dde32ce8..23f4573d23 100644 --- a/examples/ember/expanding/package.json +++ b/examples/ember/expanding/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/filters-faceted/app/templates/application.gts b/examples/ember/filters-faceted/app/templates/application.gts index d7ec8c3d1c..ac1be3bb8c 100644 --- a/examples/ember/filters-faceted/app/templates/application.gts +++ b/examples/ember/filters-faceted/app/templates/application.gts @@ -12,7 +12,9 @@ import { createFacetedRowModel, createFacetedMinMaxValues, createFacetedUniqueValues, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_inNumberRange, rowPaginationFeature, createPaginatedRowModel, metaHelper, @@ -41,7 +43,11 @@ const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, }) const columnHelper = createColumnHelper() @@ -66,11 +72,14 @@ const columns = columnHelper.columns([ }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select' }, }), columnHelper.accessor('progress', { header: 'Profile Progress', meta: { filterVariant: 'range' }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]) diff --git a/examples/ember/filters-faceted/package.json b/examples/ember/filters-faceted/package.json index 5bfa2d0ee3..b79decd01c 100644 --- a/examples/ember/filters-faceted/package.json +++ b/examples/ember/filters-faceted/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/filters-fuzzy/app/templates/application.gts b/examples/ember/filters-fuzzy/app/templates/application.gts index 29737adb62..1ea65e387a 100644 --- a/examples/ember/filters-fuzzy/app/templates/application.gts +++ b/examples/ember/filters-fuzzy/app/templates/application.gts @@ -13,8 +13,10 @@ import { createFilteredRowModel, createSortedRowModel, createPaginatedRowModel, - filterFns, - sortFns, + filterFn_includesString, + filterFn_inNumberRange, + sortFn_alphanumeric, + sortFn_text, metaHelper, createColumnHelper, type Column, @@ -61,7 +63,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { if (rankA && rankB) { dir = compareItems(rankA, rankB) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -72,8 +74,16 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, filterMeta: metaHelper(), }) diff --git a/examples/ember/filters-fuzzy/package.json b/examples/ember/filters-fuzzy/package.json index c8da593903..8224742e8a 100644 --- a/examples/ember/filters-fuzzy/package.json +++ b/examples/ember/filters-fuzzy/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", diff --git a/examples/ember/filters/app/templates/application.gts b/examples/ember/filters/app/templates/application.gts index fb0db44627..260964f487 100644 --- a/examples/ember/filters/app/templates/application.gts +++ b/examples/ember/filters/app/templates/application.gts @@ -8,7 +8,9 @@ import { tableFeatures, columnFilteringFeature, createFilteredRowModel, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_inNumberRange, rowPaginationFeature, createPaginatedRowModel, metaHelper, @@ -34,7 +36,11 @@ const features = tableFeatures({ columnMeta: metaHelper(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, }) const columnHelper = createColumnHelper() @@ -64,11 +70,14 @@ const columns = columnHelper.columns([ }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select' }, }), columnHelper.accessor('progress', { header: 'Profile Progress', meta: { filterVariant: 'range' }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]) diff --git a/examples/ember/filters/package.json b/examples/ember/filters/package.json index 78eef87d6a..728f027fcf 100644 --- a/examples/ember/filters/package.json +++ b/examples/ember/filters/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/grouping/app/templates/application.gts b/examples/ember/grouping/app/templates/application.gts index df1e5de2ee..3d4b123b85 100644 --- a/examples/ember/grouping/app/templates/application.gts +++ b/examples/ember/grouping/app/templates/application.gts @@ -18,9 +18,13 @@ import { createPaginatedRowModel, createFilteredRowModel, createSortedRowModel, - aggregationFns, - filterFns, - sortFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, + filterFn_includesString, + filterFn_inNumberRange, + sortFn_alphanumeric, + sortFn_text, createColumnHelper, type Column, type Row, @@ -43,9 +47,19 @@ const features = tableFeatures({ paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), sortedRowModel: createSortedRowModel(), - aggregationFns, - filterFns, - sortFns, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/grouping/package.json b/examples/ember/grouping/package.json index 60a51370be..ca467f07e9 100644 --- a/examples/ember/grouping/package.json +++ b/examples/ember/grouping/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/kitchen-sink/app/templates/application.gts b/examples/ember/kitchen-sink/app/templates/application.gts index 8b37da344a..a9f562e907 100644 --- a/examples/ember/kitchen-sink/app/templates/application.gts +++ b/examples/ember/kitchen-sink/app/templates/application.gts @@ -15,9 +15,13 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, - sortFns, - aggregationFns, + filterFn_includesString, + filterFn_inNumberRange, + sortFn_alphanumeric, + sortFn_text, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, metaHelper, createColumnHelper, type Column, @@ -71,7 +75,7 @@ const fuzzySort: SortFn = ( if (rankA && rankB) { dir = compareItems(rankA, rankB) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const sortStatusFn: SortFn = (rowA, rowB) => { @@ -94,9 +98,22 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort, sortStatus: sortStatusFn }, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + sortStatus: sortStatusFn, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) type Feats = typeof features diff --git a/examples/ember/kitchen-sink/package.json b/examples/ember/kitchen-sink/package.json index 8f4f877ce1..2980795755 100644 --- a/examples/ember/kitchen-sink/package.json +++ b/examples/ember/kitchen-sink/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", diff --git a/examples/ember/pagination/package.json b/examples/ember/pagination/package.json index 20c2ec7b21..e54d683f4b 100644 --- a/examples/ember/pagination/package.json +++ b/examples/ember/pagination/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/remote-data/package.json b/examples/ember/remote-data/package.json index 44c1dde365..4a5edd2302 100644 --- a/examples/ember/remote-data/package.json +++ b/examples/ember/remote-data/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/row-dnd/package.json b/examples/ember/row-dnd/package.json index 6cdd606119..fc125bdc7f 100644 --- a/examples/ember/row-dnd/package.json +++ b/examples/ember/row-dnd/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/row-pinning/app/templates/application.gts b/examples/ember/row-pinning/app/templates/application.gts index a561766f39..dedce38135 100644 --- a/examples/ember/row-pinning/app/templates/application.gts +++ b/examples/ember/row-pinning/app/templates/application.gts @@ -15,7 +15,8 @@ import { createExpandedRowModel, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, createColumnHelper, type Row, type Cell, @@ -34,7 +35,10 @@ const features = tableFeatures({ expandedRowModel: createExpandedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/ember/row-pinning/package.json b/examples/ember/row-pinning/package.json index 8b4c56d444..7bada2a22d 100644 --- a/examples/ember/row-pinning/package.json +++ b/examples/ember/row-pinning/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/row-selection/app/templates/application.gts b/examples/ember/row-selection/app/templates/application.gts index d7549f3e58..4d5a9be8fe 100644 --- a/examples/ember/row-selection/app/templates/application.gts +++ b/examples/ember/row-selection/app/templates/application.gts @@ -15,7 +15,8 @@ import { globalFilteringFeature, createPaginatedRowModel, createFilteredRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, createColumnHelper, type Row, type Cell, @@ -34,7 +35,10 @@ const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) // --- Selection checkbox components (rendered via flexRenderComponent) --- diff --git a/examples/ember/row-selection/package.json b/examples/ember/row-selection/package.json index 768b91a195..2db940e243 100644 --- a/examples/ember/row-selection/package.json +++ b/examples/ember/row-selection/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/sorting/app/templates/application.gts b/examples/ember/sorting/app/templates/application.gts index 32792750da..15614a6f06 100644 --- a/examples/ember/sorting/app/templates/application.gts +++ b/examples/ember/sorting/app/templates/application.gts @@ -9,7 +9,8 @@ import { tableFeatures, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, createColumnHelper, type Column, type Row, @@ -23,7 +24,10 @@ import { makeData, type Person } from '../utils/make-data' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) // Custom sorting function for the `status` column: orders statuses in a diff --git a/examples/ember/sorting/package.json b/examples/ember/sorting/package.json index 2214ea6bee..ab448dcc00 100644 --- a/examples/ember/sorting/package.json +++ b/examples/ember/sorting/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/ember/sub-components/package.json b/examples/ember/sub-components/package.json index 219cea0cf0..b9dafa760f 100644 --- a/examples/ember/sub-components/package.json +++ b/examples/ember/sub-components/package.json @@ -28,7 +28,7 @@ "@embroider/router": "3.0.6", "@faker-js/faker": "^10.5.0", "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.0.0-beta.46", + "@tanstack/ember-table": "^9.0.0-beta.47", "decorator-transforms": "2.4.0", "ember-source": "7.0.0", "ember-strict-application-resolver": "0.1.1" diff --git a/examples/lit/basic-app-table/package.json b/examples/lit/basic-app-table/package.json index 7af56e5adc..ebb37fbc18 100644 --- a/examples/lit/basic-app-table/package.json +++ b/examples/lit/basic-app-table/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@lit/context": "^1.1.6", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/basic-app-table/src/main.ts b/examples/lit/basic-app-table/src/main.ts index 73616df908..6fa1a3757c 100644 --- a/examples/lit/basic-app-table/src/main.ts +++ b/examples/lit/basic-app-table/src/main.ts @@ -5,7 +5,8 @@ import { createSortedRowModel, createTableHook, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' @@ -18,7 +19,10 @@ const { useAppTable, createAppColumnHelper } = createTableHook({ features: tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }), debugTable: true, }) diff --git a/examples/lit/basic-dynamic-columns/package.json b/examples/lit/basic-dynamic-columns/package.json index 2ad1b70efa..c4ee601d4e 100644 --- a/examples/lit/basic-dynamic-columns/package.json +++ b/examples/lit/basic-dynamic-columns/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/basic-dynamic-columns/src/main.ts b/examples/lit/basic-dynamic-columns/src/main.ts index 39b96777ff..89b71c343f 100644 --- a/examples/lit/basic-dynamic-columns/src/main.ts +++ b/examples/lit/basic-dynamic-columns/src/main.ts @@ -11,10 +11,13 @@ import { createFacetedUniqueValues, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' @@ -56,8 +59,17 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/lit/basic-external-atoms/package.json b/examples/lit/basic-external-atoms/package.json index 118d946a20..e10c162f57 100644 --- a/examples/lit/basic-external-atoms/package.json +++ b/examples/lit/basic-external-atoms/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/store": "^0.11.0", "lit": "^3.3.3" }, diff --git a/examples/lit/basic-external-atoms/src/main.ts b/examples/lit/basic-external-atoms/src/main.ts index 67b5ab4012..21f1b56e0c 100644 --- a/examples/lit/basic-external-atoms/src/main.ts +++ b/examples/lit/basic-external-atoms/src/main.ts @@ -9,7 +9,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { createAtom } from '@tanstack/store' @@ -27,7 +28,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/lit/basic-external-state/package.json b/examples/lit/basic-external-state/package.json index 311c374eff..6a879b59e4 100644 --- a/examples/lit/basic-external-state/package.json +++ b/examples/lit/basic-external-state/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/basic-external-state/src/main.ts b/examples/lit/basic-external-state/src/main.ts index 4956748154..3e4ebf96dc 100644 --- a/examples/lit/basic-external-state/src/main.ts +++ b/examples/lit/basic-external-state/src/main.ts @@ -9,7 +9,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' @@ -23,7 +24,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/lit/basic-subscribe/package.json b/examples/lit/basic-subscribe/package.json index 5c42b8d1a0..d1200cbc14 100644 --- a/examples/lit/basic-subscribe/package.json +++ b/examples/lit/basic-subscribe/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/lit-store": "^0.14.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/basic-subscribe/src/main.ts b/examples/lit/basic-subscribe/src/main.ts index 5e159d0c0f..e2d5c1d2ab 100644 --- a/examples/lit/basic-subscribe/src/main.ts +++ b/examples/lit/basic-subscribe/src/main.ts @@ -8,7 +8,8 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -38,7 +39,10 @@ const features = tableFeatures({ // filters and paginates `table.getRowModel()`. filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/lit/basic-table-controller/package.json b/examples/lit/basic-table-controller/package.json index db36fba109..31281f93a4 100644 --- a/examples/lit/basic-table-controller/package.json +++ b/examples/lit/basic-table-controller/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-groups/package.json b/examples/lit/column-groups/package.json index 8876707ff6..032a29f8c9 100644 --- a/examples/lit/column-groups/package.json +++ b/examples/lit/column-groups/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-ordering/package.json b/examples/lit/column-ordering/package.json index cdfb82a605..c9323f3e13 100644 --- a/examples/lit/column-ordering/package.json +++ b/examples/lit/column-ordering/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-pinning-split/package.json b/examples/lit/column-pinning-split/package.json index a32cf03b10..3f8244230b 100644 --- a/examples/lit/column-pinning-split/package.json +++ b/examples/lit/column-pinning-split/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-pinning-sticky/package.json b/examples/lit/column-pinning-sticky/package.json index 44b116a16e..c7d26be435 100644 --- a/examples/lit/column-pinning-sticky/package.json +++ b/examples/lit/column-pinning-sticky/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-pinning/package.json b/examples/lit/column-pinning/package.json index 0dca21b9e8..024422c417 100644 --- a/examples/lit/column-pinning/package.json +++ b/examples/lit/column-pinning/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-resizing-performant/package.json b/examples/lit/column-resizing-performant/package.json index 1983c4e251..1f5fdce4cb 100644 --- a/examples/lit/column-resizing-performant/package.json +++ b/examples/lit/column-resizing-performant/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-resizing/package.json b/examples/lit/column-resizing/package.json index bc23e2204d..e002636e5c 100644 --- a/examples/lit/column-resizing/package.json +++ b/examples/lit/column-resizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-sizing/package.json b/examples/lit/column-sizing/package.json index 939edd7664..a9dadfc3e6 100644 --- a/examples/lit/column-sizing/package.json +++ b/examples/lit/column-sizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/column-visibility/package.json b/examples/lit/column-visibility/package.json index 99ffbf41f1..52ac63cd52 100644 --- a/examples/lit/column-visibility/package.json +++ b/examples/lit/column-visibility/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/composable-tables/package.json b/examples/lit/composable-tables/package.json index c037b4a191..c887a51f0c 100644 --- a/examples/lit/composable-tables/package.json +++ b/examples/lit/composable-tables/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@lit/context": "^1.1.6", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/composable-tables/src/hooks/table.ts b/examples/lit/composable-tables/src/hooks/table.ts index 58c0e5f4f6..0d05cd4e85 100644 --- a/examples/lit/composable-tables/src/hooks/table.ts +++ b/examples/lit/composable-tables/src/hooks/table.ts @@ -4,11 +4,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { @@ -39,8 +41,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) export const { createAppColumnHelper, useAppTable, useTableContext } = diff --git a/examples/lit/expanding/package.json b/examples/lit/expanding/package.json index 65ad56aba2..8177b38e99 100644 --- a/examples/lit/expanding/package.json +++ b/examples/lit/expanding/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/expanding/src/main.ts b/examples/lit/expanding/src/main.ts index 65b2568556..47cac430a5 100644 --- a/examples/lit/expanding/src/main.ts +++ b/examples/lit/expanding/src/main.ts @@ -9,12 +9,14 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' @@ -31,8 +33,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) function indeterminateCheckbox(options: { diff --git a/examples/lit/filters-faceted/package.json b/examples/lit/filters-faceted/package.json index 442dffaa0b..e6c437e730 100644 --- a/examples/lit/filters-faceted/package.json +++ b/examples/lit/filters-faceted/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/filters-faceted/src/main.ts b/examples/lit/filters-faceted/src/main.ts index 91fd3edc8b..73b1b90684 100644 --- a/examples/lit/filters-faceted/src/main.ts +++ b/examples/lit/filters-faceted/src/main.ts @@ -11,7 +11,8 @@ import { createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -37,7 +38,10 @@ const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columns: Array> = [ diff --git a/examples/lit/filters-fuzzy/package.json b/examples/lit/filters-fuzzy/package.json index 9668c7670c..a39f2db3e1 100644 --- a/examples/lit/filters-fuzzy/package.json +++ b/examples/lit/filters-fuzzy/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "lit": "^3.3.3" }, diff --git a/examples/lit/filters-fuzzy/src/main.ts b/examples/lit/filters-fuzzy/src/main.ts index 95673c4248..a3a8948c15 100644 --- a/examples/lit/filters-fuzzy/src/main.ts +++ b/examples/lit/filters-fuzzy/src/main.ts @@ -9,12 +9,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_includesStringSensitive, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { compareItems, rankItem } from '@tanstack/match-sorter-utils' @@ -53,7 +56,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -64,8 +67,17 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + equalsString: filterFn_equalsString, + includesString: filterFn_includesString, + includesStringSensitive: filterFn_includesStringSensitive, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, filterMeta: metaHelper(), }) diff --git a/examples/lit/filters/package.json b/examples/lit/filters/package.json index 6ae65532a0..af16ce6f40 100644 --- a/examples/lit/filters/package.json +++ b/examples/lit/filters/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/filters/src/main.ts b/examples/lit/filters/src/main.ts index f4a249d922..a369c2452f 100644 --- a/examples/lit/filters/src/main.ts +++ b/examples/lit/filters/src/main.ts @@ -7,7 +7,9 @@ import { columnFilteringFeature, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -26,7 +28,11 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -69,6 +75,7 @@ const columns: Array> = [ { accessorKey: 'status', header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -79,6 +86,8 @@ const columns: Array> = [ meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }, ] diff --git a/examples/lit/grouping/package.json b/examples/lit/grouping/package.json index a907bbb2c9..15c2b34b51 100644 --- a/examples/lit/grouping/package.json +++ b/examples/lit/grouping/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/grouping/src/main.ts b/examples/lit/grouping/src/main.ts index 50046fd0e1..6ef9296b8b 100644 --- a/examples/lit/grouping/src/main.ts +++ b/examples/lit/grouping/src/main.ts @@ -4,7 +4,9 @@ import { repeat } from 'lit/directives/repeat.js' import { FlexRender, TableController, - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createColumnHelper, @@ -13,11 +15,13 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' @@ -35,9 +39,19 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/lit/kitchen-sink/package.json b/examples/lit/kitchen-sink/package.json index 2f5822046e..e7f9d85652 100644 --- a/examples/lit/kitchen-sink/package.json +++ b/examples/lit/kitchen-sink/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "lit": "^3.3.3" }, diff --git a/examples/lit/kitchen-sink/src/main.ts b/examples/lit/kitchen-sink/src/main.ts index a445168be8..254d74384b 100644 --- a/examples/lit/kitchen-sink/src/main.ts +++ b/examples/lit/kitchen-sink/src/main.ts @@ -6,7 +6,9 @@ import { faker } from '@faker-js/faker' import { FlexRender, TableController, - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, createColumnHelper, createExpandedRowModel, createFacetedMinMaxValues, @@ -16,9 +18,11 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, - sortFns, + sortFn_alphanumeric, + sortFn_text, stockFeatures, tableFeatures, } from '@tanstack/lit-table' @@ -67,7 +71,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -82,9 +86,21 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) const sortStatusFn: SortFn = (rowA, rowB) => { diff --git a/examples/lit/pagination/package.json b/examples/lit/pagination/package.json index 7c5e2f44b8..77d9b6948a 100644 --- a/examples/lit/pagination/package.json +++ b/examples/lit/pagination/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/row-pinning/package.json b/examples/lit/row-pinning/package.json index ba9086cf8d..a1389dcc2d 100644 --- a/examples/lit/row-pinning/package.json +++ b/examples/lit/row-pinning/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/row-pinning/src/main.ts b/examples/lit/row-pinning/src/main.ts index 22dc04302c..f3b59dd108 100644 --- a/examples/lit/row-pinning/src/main.ts +++ b/examples/lit/row-pinning/src/main.ts @@ -8,7 +8,8 @@ import { createExpandedRowModel, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, @@ -26,7 +27,10 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) function renderFilter( diff --git a/examples/lit/row-selection/package.json b/examples/lit/row-selection/package.json index 87707689ab..3f8416695b 100644 --- a/examples/lit/row-selection/package.json +++ b/examples/lit/row-selection/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/row-selection/src/main.ts b/examples/lit/row-selection/src/main.ts index 5feb570eda..83c1cbbe1b 100644 --- a/examples/lit/row-selection/src/main.ts +++ b/examples/lit/row-selection/src/main.ts @@ -7,7 +7,8 @@ import { columnFilteringFeature, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, tableFeatures, @@ -22,7 +23,10 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columns: Array> = [ diff --git a/examples/lit/sorting-dynamic-data/package.json b/examples/lit/sorting-dynamic-data/package.json index 691dbcfbf6..71d8211c68 100644 --- a/examples/lit/sorting-dynamic-data/package.json +++ b/examples/lit/sorting-dynamic-data/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/sorting-dynamic-data/src/main.ts b/examples/lit/sorting-dynamic-data/src/main.ts index 1a8cdcf2cd..e0880fd518 100644 --- a/examples/lit/sorting-dynamic-data/src/main.ts +++ b/examples/lit/sorting-dynamic-data/src/main.ts @@ -8,7 +8,9 @@ import { TableController, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { Person, makeData } from './makeData' @@ -17,7 +19,11 @@ import type { SortFn } from '@tanstack/lit-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const sortStatusFn: SortFn = ( diff --git a/examples/lit/sorting/package.json b/examples/lit/sorting/package.json index 1c2e3bfa17..ed83c4fb10 100644 --- a/examples/lit/sorting/package.json +++ b/examples/lit/sorting/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/sorting/src/main.ts b/examples/lit/sorting/src/main.ts index e1ab5505ae..8de19992db 100644 --- a/examples/lit/sorting/src/main.ts +++ b/examples/lit/sorting/src/main.ts @@ -6,7 +6,9 @@ import { TableController, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { Person, makeData } from './makeData' @@ -15,7 +17,11 @@ import type { ColumnDef, SortFn } from '@tanstack/lit-table' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const sortStatusFn: SortFn = ( diff --git a/examples/lit/sub-components/package.json b/examples/lit/sub-components/package.json index 9581cd7ca4..4b1de2e0ed 100644 --- a/examples/lit/sub-components/package.json +++ b/examples/lit/sub-components/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "lit": "^3.3.3" }, "devDependencies": { diff --git a/examples/lit/virtualized-columns/package.json b/examples/lit/virtualized-columns/package.json index cc067af949..6af4cad980 100644 --- a/examples/lit/virtualized-columns/package.json +++ b/examples/lit/virtualized-columns/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/lit-virtual": "^3.13.32", "lit": "^3.3.3" }, diff --git a/examples/lit/virtualized-columns/src/main.ts b/examples/lit/virtualized-columns/src/main.ts index ac22247254..9a42077b0d 100644 --- a/examples/lit/virtualized-columns/src/main.ts +++ b/examples/lit/virtualized-columns/src/main.ts @@ -9,7 +9,8 @@ import { columnVisibilityFeature, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { styleMap } from 'lit/directives/style-map.js' @@ -24,7 +25,10 @@ const features = tableFeatures({ columnVisibilityFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const DEFAULT_ROW_COUNT = 1_000 diff --git a/examples/lit/virtualized-infinite-scrolling/package.json b/examples/lit/virtualized-infinite-scrolling/package.json index c2de166de9..e3613f3b7d 100644 --- a/examples/lit/virtualized-infinite-scrolling/package.json +++ b/examples/lit/virtualized-infinite-scrolling/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/lit-virtual": "^3.13.32", "lit": "^3.3.3" }, diff --git a/examples/lit/virtualized-infinite-scrolling/src/main.ts b/examples/lit/virtualized-infinite-scrolling/src/main.ts index d582ebb360..e18315b818 100644 --- a/examples/lit/virtualized-infinite-scrolling/src/main.ts +++ b/examples/lit/virtualized-infinite-scrolling/src/main.ts @@ -7,7 +7,9 @@ import { columnSizingFeature, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { styleMap } from 'lit/directives/style-map.js' @@ -23,7 +25,11 @@ const features = tableFeatures({ columnSizingFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columns: Array> = [ diff --git a/examples/lit/virtualized-rows/package.json b/examples/lit/virtualized-rows/package.json index 650aabe16b..b7df30b6da 100644 --- a/examples/lit/virtualized-rows/package.json +++ b/examples/lit/virtualized-rows/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.0.0-beta.46", + "@tanstack/lit-table": "^9.0.0-beta.47", "@tanstack/lit-virtual": "^3.13.32", "lit": "^3.3.3" }, diff --git a/examples/lit/virtualized-rows/src/main.ts b/examples/lit/virtualized-rows/src/main.ts index f23bf7ee9f..7bad97298c 100644 --- a/examples/lit/virtualized-rows/src/main.ts +++ b/examples/lit/virtualized-rows/src/main.ts @@ -8,7 +8,9 @@ import { createSortedRowModel, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/lit-table' import { styleMap } from 'lit/directives/style-map.js' @@ -22,7 +24,11 @@ const features = tableFeatures({ rowSelectionFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columns: Array> = [ diff --git a/examples/preact/basic-dynamic-columns/package.json b/examples/preact/basic-dynamic-columns/package.json index a3360c91be..46432c452b 100644 --- a/examples/preact/basic-dynamic-columns/package.json +++ b/examples/preact/basic-dynamic-columns/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-pacer": "^0.22.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/basic-dynamic-columns/src/main.tsx b/examples/preact/basic-dynamic-columns/src/main.tsx index 6f90333b9a..e7a7adb9df 100644 --- a/examples/preact/basic-dynamic-columns/src/main.tsx +++ b/examples/preact/basic-dynamic-columns/src/main.tsx @@ -9,10 +9,13 @@ import { createFacetedUniqueValues, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -61,8 +64,17 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name below + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name below + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/preact/basic-external-atoms/package.json b/examples/preact/basic-external-atoms/package.json index f9a266c753..b8479b8bf9 100644 --- a/examples/preact/basic-external-atoms/package.json +++ b/examples/preact/basic-external-atoms/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/basic-external-atoms/src/main.tsx b/examples/preact/basic-external-atoms/src/main.tsx index afc722687f..bfdfeb8b12 100644 --- a/examples/preact/basic-external-atoms/src/main.tsx +++ b/examples/preact/basic-external-atoms/src/main.tsx @@ -9,7 +9,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -34,7 +35,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/basic-external-state/package.json b/examples/preact/basic-external-state/package.json index db2a728b4b..4e8ed5b972 100644 --- a/examples/preact/basic-external-state/package.json +++ b/examples/preact/basic-external-state/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/basic-external-state/src/main.tsx b/examples/preact/basic-external-state/src/main.tsx index dd4076e60c..c0c55dabed 100644 --- a/examples/preact/basic-external-state/src/main.tsx +++ b/examples/preact/basic-external-state/src/main.tsx @@ -8,7 +8,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -33,7 +34,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/basic-subscribe/package.json b/examples/preact/basic-subscribe/package.json index b21eeed488..3fc5079409 100644 --- a/examples/preact/basic-subscribe/package.json +++ b/examples/preact/basic-subscribe/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/basic-subscribe/src/main.tsx b/examples/preact/basic-subscribe/src/main.tsx index 60f40109dc..45f9aa2009 100644 --- a/examples/preact/basic-subscribe/src/main.tsx +++ b/examples/preact/basic-subscribe/src/main.tsx @@ -7,7 +7,8 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -36,7 +37,10 @@ const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/basic-use-app-table/package.json b/examples/preact/basic-use-app-table/package.json index 161d53a034..f1261cf725 100644 --- a/examples/preact/basic-use-app-table/package.json +++ b/examples/preact/basic-use-app-table/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "@tanstack/preact-devtools": "^0.10.8", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/basic-use-table/package.json b/examples/preact/basic-use-table/package.json index b27605eac5..8d69412f8f 100644 --- a/examples/preact/basic-use-table/package.json +++ b/examples/preact/basic-use-table/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "@tanstack/preact-devtools": "^0.10.8", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-groups/package.json b/examples/preact/column-groups/package.json index 461ae07288..08f0a5e3ce 100644 --- a/examples/preact/column-groups/package.json +++ b/examples/preact/column-groups/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-ordering/package.json b/examples/preact/column-ordering/package.json index 45e7fa8ada..e80cb7f1cb 100644 --- a/examples/preact/column-ordering/package.json +++ b/examples/preact/column-ordering/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-pinning-split/package.json b/examples/preact/column-pinning-split/package.json index 89b373eb75..c253a01f64 100644 --- a/examples/preact/column-pinning-split/package.json +++ b/examples/preact/column-pinning-split/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-pinning-sticky/package.json b/examples/preact/column-pinning-sticky/package.json index 4aac397b59..cffb0b6b5a 100644 --- a/examples/preact/column-pinning-sticky/package.json +++ b/examples/preact/column-pinning-sticky/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-pinning/package.json b/examples/preact/column-pinning/package.json index 6f9143fd33..543210ce86 100644 --- a/examples/preact/column-pinning/package.json +++ b/examples/preact/column-pinning/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-resizing-performant/package.json b/examples/preact/column-resizing-performant/package.json index 56d64e0ee4..1f1ef863f9 100644 --- a/examples/preact/column-resizing-performant/package.json +++ b/examples/preact/column-resizing-performant/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-resizing/package.json b/examples/preact/column-resizing/package.json index fa2aba8bf4..6297c3c7c9 100644 --- a/examples/preact/column-resizing/package.json +++ b/examples/preact/column-resizing/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-sizing/package.json b/examples/preact/column-sizing/package.json index ab2fa2b11a..3ad4548a3f 100644 --- a/examples/preact/column-sizing/package.json +++ b/examples/preact/column-sizing/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/column-visibility/package.json b/examples/preact/column-visibility/package.json index 7821bbc831..0502bd88b6 100644 --- a/examples/preact/column-visibility/package.json +++ b/examples/preact/column-visibility/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/composable-tables/package.json b/examples/preact/composable-tables/package.json index 56a6853211..2cc05d27ee 100644 --- a/examples/preact/composable-tables/package.json +++ b/examples/preact/composable-tables/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/composable-tables/src/hooks/table.ts b/examples/preact/composable-tables/src/hooks/table.ts index 7d5a6a906f..b3aa8cb99f 100644 --- a/examples/preact/composable-tables/src/hooks/table.ts +++ b/examples/preact/composable-tables/src/hooks/table.ts @@ -11,11 +11,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/preact-table' @@ -71,8 +73,14 @@ export const { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }), // set any default table options here too diff --git a/examples/preact/custom-plugin/package.json b/examples/preact/custom-plugin/package.json index 29e409c57f..1db38b04c1 100644 --- a/examples/preact/custom-plugin/package.json +++ b/examples/preact/custom-plugin/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/custom-plugin/src/main.tsx b/examples/preact/custom-plugin/src/main.tsx index e15b1f43b3..f6a9841ade 100644 --- a/examples/preact/custom-plugin/src/main.tsx +++ b/examples/preact/custom-plugin/src/main.tsx @@ -8,12 +8,14 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, functionalUpdate, makeStateUpdater, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -132,8 +134,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/expanding/package.json b/examples/preact/expanding/package.json index 054b97aab6..19c9e3b65f 100644 --- a/examples/preact/expanding/package.json +++ b/examples/preact/expanding/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/expanding/src/main.tsx b/examples/preact/expanding/src/main.tsx index dcc80e64cd..aa7c8836b7 100644 --- a/examples/preact/expanding/src/main.tsx +++ b/examples/preact/expanding/src/main.tsx @@ -7,12 +7,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_between, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -32,8 +35,15 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + between: filterFn_between, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/filters-faceted/package.json b/examples/preact/filters-faceted/package.json index 31f0d6c721..fb3e340ca9 100644 --- a/examples/preact/filters-faceted/package.json +++ b/examples/preact/filters-faceted/package.json @@ -15,7 +15,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/preact-pacer": "^0.22.1", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/filters-faceted/src/main.tsx b/examples/preact/filters-faceted/src/main.tsx index dc7ee143af..8b2e38fe43 100644 --- a/examples/preact/filters-faceted/src/main.tsx +++ b/examples/preact/filters-faceted/src/main.tsx @@ -10,7 +10,9 @@ import { createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -36,7 +38,11 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedMinMaxValues: createFacetedMinMaxValues(), facetedUniqueValues: createFacetedUniqueValues(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -68,6 +74,7 @@ function App() { }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -77,6 +84,8 @@ function App() { meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]), [], diff --git a/examples/preact/filters-fuzzy/package.json b/examples/preact/filters-fuzzy/package.json index 4304152526..c1d78ffa9b 100644 --- a/examples/preact/filters-fuzzy/package.json +++ b/examples/preact/filters-fuzzy/package.json @@ -15,7 +15,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/preact-pacer": "^0.22.1", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/filters-fuzzy/src/main.tsx b/examples/preact/filters-fuzzy/src/main.tsx index 6993456611..707fe46647 100644 --- a/examples/preact/filters-fuzzy/src/main.tsx +++ b/examples/preact/filters-fuzzy/src/main.tsx @@ -7,12 +7,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_includesStringSensitive, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -74,7 +77,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -85,8 +88,17 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + equalsString: filterFn_equalsString, + includesString: filterFn_includesString, + includesStringSensitive: filterFn_includesStringSensitive, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, filterMeta: metaHelper(), }) diff --git a/examples/preact/filters/package.json b/examples/preact/filters/package.json index cc731effa5..fb9cc6c992 100644 --- a/examples/preact/filters/package.json +++ b/examples/preact/filters/package.json @@ -15,7 +15,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/preact-pacer": "^0.22.1", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/filters/src/main.tsx b/examples/preact/filters/src/main.tsx index c6128d055b..c8d51c74f9 100644 --- a/examples/preact/filters/src/main.tsx +++ b/examples/preact/filters/src/main.tsx @@ -6,7 +6,9 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -28,7 +30,11 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -70,6 +76,7 @@ function App() { }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -79,6 +86,8 @@ function App() { meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]), [], diff --git a/examples/preact/grouping/package.json b/examples/preact/grouping/package.json index d9d3d065be..410344711f 100644 --- a/examples/preact/grouping/package.json +++ b/examples/preact/grouping/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/grouping/src/main.tsx b/examples/preact/grouping/src/main.tsx index 046c6f794c..d9ae8599b8 100644 --- a/examples/preact/grouping/src/main.tsx +++ b/examples/preact/grouping/src/main.tsx @@ -2,7 +2,9 @@ import { useMemo, useState } from 'preact/hooks' import { render } from 'preact' import './index.css' import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createExpandedRowModel, @@ -11,11 +13,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/preact-table' import { makeData } from './makeData' import type { Person } from './makeData' @@ -33,9 +37,19 @@ const { useAppTable, createAppColumnHelper } = createTableHook({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }, }) diff --git a/examples/preact/kitchen-sink/package.json b/examples/preact/kitchen-sink/package.json index 52756de4d0..f8f7268853 100644 --- a/examples/preact/kitchen-sink/package.json +++ b/examples/preact/kitchen-sink/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/preact-devtools": "^0.10.8", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/kitchen-sink/src/main.tsx b/examples/preact/kitchen-sink/src/main.tsx index f3973ea9ba..f95b7ee74e 100644 --- a/examples/preact/kitchen-sink/src/main.tsx +++ b/examples/preact/kitchen-sink/src/main.tsx @@ -3,7 +3,9 @@ import { TanStackDevtools } from '@tanstack/preact-devtools' import { useEffect, useMemo, useRef, useState } from 'preact/hooks' import { faker } from '@faker-js/faker' import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, createColumnHelper, createExpandedRowModel, createFacetedMinMaxValues, @@ -13,9 +15,11 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, - sortFns, + sortFn_alphanumeric, + sortFn_text, stockFeatures, tableFeatures, useTable, @@ -74,7 +78,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -87,9 +91,14 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + fuzzy: fuzzyFilter, + }, sortFns: { - ...sortFns, + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, fuzzy: fuzzySort, sortStatus: (rowA: any, rowB: any) => { const statusOrder = ['single', 'complicated', 'relationship'] @@ -99,7 +108,11 @@ const features = tableFeatures({ ) }, }, - aggregationFns, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, filterMeta: metaHelper(), columnMeta: metaHelper(), }) diff --git a/examples/preact/pagination/package.json b/examples/preact/pagination/package.json index 88edaaa178..6c99b9fcd9 100644 --- a/examples/preact/pagination/package.json +++ b/examples/preact/pagination/package.json @@ -14,7 +14,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/row-pinning/package.json b/examples/preact/row-pinning/package.json index 0bdda01685..a63001ee04 100644 --- a/examples/preact/row-pinning/package.json +++ b/examples/preact/row-pinning/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/row-pinning/src/main.tsx b/examples/preact/row-pinning/src/main.tsx index e9e2faf601..bab7dda660 100644 --- a/examples/preact/row-pinning/src/main.tsx +++ b/examples/preact/row-pinning/src/main.tsx @@ -7,7 +7,8 @@ import { createExpandedRowModel, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, @@ -34,7 +35,10 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/row-selection/package.json b/examples/preact/row-selection/package.json index e1818ee8c9..381ca8102f 100644 --- a/examples/preact/row-selection/package.json +++ b/examples/preact/row-selection/package.json @@ -15,8 +15,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/row-selection/src/main.tsx b/examples/preact/row-selection/src/main.tsx index dd5660dc22..2a85db0661 100644 --- a/examples/preact/row-selection/src/main.tsx +++ b/examples/preact/row-selection/src/main.tsx @@ -6,7 +6,8 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -36,7 +37,10 @@ const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/sorting/package.json b/examples/preact/sorting/package.json index 0c47bc30b2..c4dfa3ca68 100644 --- a/examples/preact/sorting/package.json +++ b/examples/preact/sorting/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/sorting/src/main.tsx b/examples/preact/sorting/src/main.tsx index bf44236ae7..5b2ffcc289 100644 --- a/examples/preact/sorting/src/main.tsx +++ b/examples/preact/sorting/src/main.tsx @@ -4,7 +4,9 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, useTable, } from '@tanstack/preact-table' @@ -15,7 +17,11 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/preact/sub-components/package.json b/examples/preact/sub-components/package.json index 154fc2aa9b..e20b66d4c7 100644 --- a/examples/preact/sub-components/package.json +++ b/examples/preact/sub-components/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/preact/with-tanstack-form/package.json b/examples/preact/with-tanstack-form/package.json index de5dd69950..99a5fd9e47 100644 --- a/examples/preact/with-tanstack-form/package.json +++ b/examples/preact/with-tanstack-form/package.json @@ -16,8 +16,8 @@ "@tanstack/preact-devtools": "^0.10.8", "@tanstack/preact-form": "^1.30.1", "@tanstack/preact-pacer": "^0.22.1", - "@tanstack/preact-table": "^9.0.0-beta.46", - "@tanstack/preact-table-devtools": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", + "@tanstack/preact-table-devtools": "^9.0.0-beta.47", "@tanstack/react-form-devtools": "^0.2.30", "preact": "^10.29.2", "zod": "^4.4.3" diff --git a/examples/preact/with-tanstack-form/src/table.tsx b/examples/preact/with-tanstack-form/src/table.tsx index 1d5b1d4ef1..04e2c39907 100644 --- a/examples/preact/with-tanstack-form/src/table.tsx +++ b/examples/preact/with-tanstack-form/src/table.tsx @@ -5,10 +5,12 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/preact-table' import { useDebouncedCallback } from '@tanstack/preact-pacer/debouncer' @@ -222,8 +224,14 @@ export const { filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }), tableComponents: { PaginationControls, diff --git a/examples/preact/with-tanstack-query/package.json b/examples/preact/with-tanstack-query/package.json index dbacdabc11..2cb8e260c8 100644 --- a/examples/preact/with-tanstack-query/package.json +++ b/examples/preact/with-tanstack-query/package.json @@ -15,7 +15,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/preact-query": "^5.101.2", "@tanstack/preact-store": "^0.13.1", - "@tanstack/preact-table": "^9.0.0-beta.46", + "@tanstack/preact-table": "^9.0.0-beta.47", "preact": "^10.29.2" }, "devDependencies": { diff --git a/examples/react/basic-dynamic-columns/package.json b/examples/react/basic-dynamic-columns/package.json index 8e9f586de2..c7f768af83 100644 --- a/examples/react/basic-dynamic-columns/package.json +++ b/examples/react/basic-dynamic-columns/package.json @@ -14,8 +14,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-dynamic-columns/src/main.tsx b/examples/react/basic-dynamic-columns/src/main.tsx index 62ef8a8a2a..d712c37432 100644 --- a/examples/react/basic-dynamic-columns/src/main.tsx +++ b/examples/react/basic-dynamic-columns/src/main.tsx @@ -9,10 +9,13 @@ import { createFacetedUniqueValues, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, useTable, } from '@tanstack/react-table' @@ -61,8 +64,17 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/react/basic-external-atoms/package.json b/examples/react/basic-external-atoms/package.json index ac1b59682d..e5a899a09d 100644 --- a/examples/react/basic-external-atoms/package.json +++ b/examples/react/basic-external-atoms/package.json @@ -14,8 +14,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-external-atoms/src/main.tsx b/examples/react/basic-external-atoms/src/main.tsx index 56ed098b44..6a1dd8a7c8 100644 --- a/examples/react/basic-external-atoms/src/main.tsx +++ b/examples/react/basic-external-atoms/src/main.tsx @@ -9,7 +9,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -34,7 +35,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/basic-external-state/package.json b/examples/react/basic-external-state/package.json index f22cfc4460..d99fb2077c 100644 --- a/examples/react/basic-external-state/package.json +++ b/examples/react/basic-external-state/package.json @@ -14,8 +14,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-external-state/src/main.tsx b/examples/react/basic-external-state/src/main.tsx index cfd1d7a7a9..94631fbbe2 100644 --- a/examples/react/basic-external-state/src/main.tsx +++ b/examples/react/basic-external-state/src/main.tsx @@ -8,7 +8,8 @@ import { createSortedRowModel, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -33,7 +34,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/basic-subscribe/package.json b/examples/react/basic-subscribe/package.json index ac10e9a02e..7841f19bf9 100644 --- a/examples/react/basic-subscribe/package.json +++ b/examples/react/basic-subscribe/package.json @@ -15,8 +15,8 @@ "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-subscribe/src/main.tsx b/examples/react/basic-subscribe/src/main.tsx index 95da66f23c..e5901be486 100644 --- a/examples/react/basic-subscribe/src/main.tsx +++ b/examples/react/basic-subscribe/src/main.tsx @@ -7,7 +7,8 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -37,7 +38,10 @@ const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/basic-use-app-table/package.json b/examples/react/basic-use-app-table/package.json index 2781e8d752..1625df10ab 100644 --- a/examples/react/basic-use-app-table/package.json +++ b/examples/react/basic-use-app-table/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@tanstack/react-devtools": "^0.10.8", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-use-legacy-table/package.json b/examples/react/basic-use-legacy-table/package.json index b94eded3f7..081458d6ce 100644 --- a/examples/react/basic-use-legacy-table/package.json +++ b/examples/react/basic-use-legacy-table/package.json @@ -14,8 +14,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/basic-use-table/package.json b/examples/react/basic-use-table/package.json index 396afec847..4bce04c803 100644 --- a/examples/react/basic-use-table/package.json +++ b/examples/react/basic-use-table/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@tanstack/react-devtools": "^0.10.8", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-dnd/package.json b/examples/react/column-dnd/package.json index 6144787587..6208004d3b 100644 --- a/examples/react/column-dnd/package.json +++ b/examples/react/column-dnd/package.json @@ -16,7 +16,7 @@ "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-groups/package.json b/examples/react/column-groups/package.json index 9a36a93c38..7f1b23499f 100644 --- a/examples/react/column-groups/package.json +++ b/examples/react/column-groups/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-ordering/package.json b/examples/react/column-ordering/package.json index f2c24650d5..8790aaa2e4 100644 --- a/examples/react/column-ordering/package.json +++ b/examples/react/column-ordering/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-pinning-split/package.json b/examples/react/column-pinning-split/package.json index 3c51935067..ff41b0e017 100644 --- a/examples/react/column-pinning-split/package.json +++ b/examples/react/column-pinning-split/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-pinning-sticky/package.json b/examples/react/column-pinning-sticky/package.json index 0c4cc68fa4..c5271d0a16 100644 --- a/examples/react/column-pinning-sticky/package.json +++ b/examples/react/column-pinning-sticky/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-pinning/package.json b/examples/react/column-pinning/package.json index 475d2645be..37985e92f7 100644 --- a/examples/react/column-pinning/package.json +++ b/examples/react/column-pinning/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-resizing-performant/package.json b/examples/react/column-resizing-performant/package.json index 7e743c6dc6..56ebfafa22 100644 --- a/examples/react/column-resizing-performant/package.json +++ b/examples/react/column-resizing-performant/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-resizing/package.json b/examples/react/column-resizing/package.json index 8a6411b8a1..ee0beee8eb 100644 --- a/examples/react/column-resizing/package.json +++ b/examples/react/column-resizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-sizing/package.json b/examples/react/column-sizing/package.json index 6a1098c99b..a304f14859 100644 --- a/examples/react/column-sizing/package.json +++ b/examples/react/column-sizing/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/column-visibility/package.json b/examples/react/column-visibility/package.json index 0a1903b75c..d8d9762ba4 100644 --- a/examples/react/column-visibility/package.json +++ b/examples/react/column-visibility/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/composable-tables/package.json b/examples/react/composable-tables/package.json index 88e5553fa4..00eff5970c 100644 --- a/examples/react/composable-tables/package.json +++ b/examples/react/composable-tables/package.json @@ -14,8 +14,8 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/composable-tables/src/hooks/table.ts b/examples/react/composable-tables/src/hooks/table.ts index 028ed4348a..76a54c1719 100644 --- a/examples/react/composable-tables/src/hooks/table.ts +++ b/examples/react/composable-tables/src/hooks/table.ts @@ -11,11 +11,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/react-table' @@ -71,8 +73,14 @@ export const { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }), // set any default table options here too diff --git a/examples/react/custom-plugin/package.json b/examples/react/custom-plugin/package.json index 9c5f82c377..81af7d1148 100644 --- a/examples/react/custom-plugin/package.json +++ b/examples/react/custom-plugin/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/custom-plugin/src/main.tsx b/examples/react/custom-plugin/src/main.tsx index fe4af80347..05a9956a1c 100644 --- a/examples/react/custom-plugin/src/main.tsx +++ b/examples/react/custom-plugin/src/main.tsx @@ -8,12 +8,14 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, functionalUpdate, makeStateUpdater, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -133,8 +135,14 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/expanding/package.json b/examples/react/expanding/package.json index 0a816b0ff2..b4bed4b2fc 100644 --- a/examples/react/expanding/package.json +++ b/examples/react/expanding/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/expanding/src/main.tsx b/examples/react/expanding/src/main.tsx index c0ad9486ba..a528b485bb 100644 --- a/examples/react/expanding/src/main.tsx +++ b/examples/react/expanding/src/main.tsx @@ -7,12 +7,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, + filterFn_inNumberRange, + filterFn_includesString, filterFns, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -33,8 +36,15 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + between: filterFns.between, // no individual export for this fn (yet) + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/filters-faceted/package.json b/examples/react/filters-faceted/package.json index 5814f69952..e349d0e9ce 100644 --- a/examples/react/filters-faceted/package.json +++ b/examples/react/filters-faceted/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/filters-faceted/src/main.tsx b/examples/react/filters-faceted/src/main.tsx index 1791bfdace..68cdecb4c7 100644 --- a/examples/react/filters-faceted/src/main.tsx +++ b/examples/react/filters-faceted/src/main.tsx @@ -10,7 +10,9 @@ import { createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -35,7 +37,11 @@ const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedMinMaxValues: createFacetedMinMaxValues(), facetedUniqueValues: createFacetedUniqueValues(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -67,6 +73,7 @@ function App() { }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -76,6 +83,8 @@ function App() { meta: { filterVariant: 'range', }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]), [], diff --git a/examples/react/filters-fuzzy/package.json b/examples/react/filters-fuzzy/package.json index 2a7a348f9b..da07dfdb1b 100644 --- a/examples/react/filters-fuzzy/package.json +++ b/examples/react/filters-fuzzy/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/filters-fuzzy/src/main.tsx b/examples/react/filters-fuzzy/src/main.tsx index b8a81cca53..9ca37dfe9c 100644 --- a/examples/react/filters-fuzzy/src/main.tsx +++ b/examples/react/filters-fuzzy/src/main.tsx @@ -7,12 +7,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_includesStringSensitive, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -73,7 +76,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { } // Provide an alphanumeric fallback for when the item ranks are equal - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -84,8 +87,17 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + equalsString: filterFn_equalsString, + includesString: filterFn_includesString, + includesStringSensitive: filterFn_includesStringSensitive, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, filterMeta: metaHelper(), }) diff --git a/examples/react/filters/package.json b/examples/react/filters/package.json index 4fff5928ba..6c4d104641 100644 --- a/examples/react/filters/package.json +++ b/examples/react/filters/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/filters/src/main.tsx b/examples/react/filters/src/main.tsx index 1b3d2bad4f..b4bfa12353 100644 --- a/examples/react/filters/src/main.tsx +++ b/examples/react/filters/src/main.tsx @@ -6,7 +6,9 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_equalsString, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowPaginationFeature, tableFeatures, @@ -27,7 +29,11 @@ const features = tableFeatures({ rowPaginationFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + equalsString: filterFn_equalsString, + }, columnMeta: metaHelper(), }) @@ -69,6 +75,7 @@ function App() { }), columnHelper.accessor('status', { header: 'Status', + filterFn: 'equalsString', // filterFn string to pick from filterFns meta: { filterVariant: 'select', }, @@ -78,13 +85,8 @@ function App() { meta: { filterVariant: 'range', }, - // custom filter function - filterFn: (row, _columnId, filterValue) => { - return ( - row.original.progress >= filterValue[0] && - row.original.progress <= filterValue[1] - ) - }, + filterFn: filterFn_inNumberRange, // or just reference static filterFn from import + // you could also write your own custom filter function here }), ]), [], diff --git a/examples/react/grouping/package.json b/examples/react/grouping/package.json index 382651374b..4717d5bca5 100644 --- a/examples/react/grouping/package.json +++ b/examples/react/grouping/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/grouping/src/main.tsx b/examples/react/grouping/src/main.tsx index 1e397175e4..d42515016d 100644 --- a/examples/react/grouping/src/main.tsx +++ b/examples/react/grouping/src/main.tsx @@ -2,7 +2,9 @@ import React from 'react' import ReactDOM from 'react-dom/client' import './index.css' import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createExpandedRowModel, @@ -11,11 +13,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/react-table' import { makeData } from './makeData' import type { Person } from './makeData' @@ -33,9 +37,19 @@ const { useAppTable, createAppColumnHelper } = createTableHook({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }, }) diff --git a/examples/react/kitchen-sink-chakra-ui/package.json b/examples/react/kitchen-sink-chakra-ui/package.json index 2168ee59f5..63a8cc92af 100644 --- a/examples/react/kitchen-sink-chakra-ui/package.json +++ b/examples/react/kitchen-sink-chakra-ui/package.json @@ -22,8 +22,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "date-fns": "^4.4.0", "next-themes": "^0.4.6", "react": "^19.2.7", diff --git a/examples/react/kitchen-sink-chakra-ui/src/hooks/features.ts b/examples/react/kitchen-sink-chakra-ui/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-chakra-ui/src/hooks/features.ts +++ b/examples/react/kitchen-sink-chakra-ui/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-chakra-ui/src/types/index.ts b/examples/react/kitchen-sink-chakra-ui/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-chakra-ui/src/types/index.ts +++ b/examples/react/kitchen-sink-chakra-ui/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-hero-ui/package.json b/examples/react/kitchen-sink-hero-ui/package.json index c17d53e2f9..def3b1e6bc 100644 --- a/examples/react/kitchen-sink-hero-ui/package.json +++ b/examples/react/kitchen-sink-hero-ui/package.json @@ -23,8 +23,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "date-fns": "^4.4.0", "react": "^19.2.7", "react-dom": "^19.2.7", diff --git a/examples/react/kitchen-sink-hero-ui/src/hooks/features.ts b/examples/react/kitchen-sink-hero-ui/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-hero-ui/src/hooks/features.ts +++ b/examples/react/kitchen-sink-hero-ui/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-hero-ui/src/types/index.ts b/examples/react/kitchen-sink-hero-ui/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-hero-ui/src/types/index.ts +++ b/examples/react/kitchen-sink-hero-ui/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-mantine/package.json b/examples/react/kitchen-sink-mantine/package.json index 5e6870c1b3..30194e3f77 100644 --- a/examples/react/kitchen-sink-mantine/package.json +++ b/examples/react/kitchen-sink-mantine/package.json @@ -22,8 +22,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "date-fns": "^4.4.0", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/kitchen-sink-mantine/src/hooks/features.ts b/examples/react/kitchen-sink-mantine/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-mantine/src/hooks/features.ts +++ b/examples/react/kitchen-sink-mantine/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-mantine/src/types/index.ts b/examples/react/kitchen-sink-mantine/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-mantine/src/types/index.ts +++ b/examples/react/kitchen-sink-mantine/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-material-ui/package.json b/examples/react/kitchen-sink-material-ui/package.json index aeea8cebc4..c45b577043 100644 --- a/examples/react/kitchen-sink-material-ui/package.json +++ b/examples/react/kitchen-sink-material-ui/package.json @@ -23,8 +23,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "date-fns": "^4.4.0", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/kitchen-sink-material-ui/src/hooks/features.ts b/examples/react/kitchen-sink-material-ui/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-material-ui/src/hooks/features.ts +++ b/examples/react/kitchen-sink-material-ui/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-material-ui/src/types/index.ts b/examples/react/kitchen-sink-material-ui/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-material-ui/src/types/index.ts +++ b/examples/react/kitchen-sink-material-ui/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-react-aria/package.json b/examples/react/kitchen-sink-react-aria/package.json index 2af61eed80..63eae8676c 100644 --- a/examples/react/kitchen-sink-react-aria/package.json +++ b/examples/react/kitchen-sink-react-aria/package.json @@ -21,8 +21,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "date-fns": "^4.4.0", "react": "^19.2.7", "react-aria-components": "^1.19.0", diff --git a/examples/react/kitchen-sink-react-aria/src/hooks/features.ts b/examples/react/kitchen-sink-react-aria/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-react-aria/src/hooks/features.ts +++ b/examples/react/kitchen-sink-react-aria/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-react-aria/src/types/index.ts b/examples/react/kitchen-sink-react-aria/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-react-aria/src/types/index.ts +++ b/examples/react/kitchen-sink-react-aria/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-shadcn-base/package.json b/examples/react/kitchen-sink-shadcn-base/package.json index a2c61c38c7..c79a89618c 100644 --- a/examples/react/kitchen-sink-shadcn-base/package.json +++ b/examples/react/kitchen-sink-shadcn-base/package.json @@ -23,8 +23,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "1.1.1", diff --git a/examples/react/kitchen-sink-shadcn-base/src/hooks/features.ts b/examples/react/kitchen-sink-shadcn-base/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-shadcn-base/src/hooks/features.ts +++ b/examples/react/kitchen-sink-shadcn-base/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-shadcn-base/src/types/index.ts b/examples/react/kitchen-sink-shadcn-base/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-shadcn-base/src/types/index.ts +++ b/examples/react/kitchen-sink-shadcn-base/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink-shadcn-radix/package.json b/examples/react/kitchen-sink-shadcn-radix/package.json index 212ced3fa6..7b032b0bf5 100644 --- a/examples/react/kitchen-sink-shadcn-radix/package.json +++ b/examples/react/kitchen-sink-shadcn-radix/package.json @@ -22,8 +22,8 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "1.1.1", diff --git a/examples/react/kitchen-sink-shadcn-radix/src/hooks/features.ts b/examples/react/kitchen-sink-shadcn-radix/src/hooks/features.ts index 730a2273ba..8d94b9fbad 100644 --- a/examples/react/kitchen-sink-shadcn-radix/src/hooks/features.ts +++ b/examples/react/kitchen-sink-shadcn-radix/src/hooks/features.ts @@ -1,5 +1,6 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_min, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, @@ -15,14 +16,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, globalFilteringFeature, metaHelper, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { rankItem } from '@tanstack/match-sorter-utils' @@ -66,7 +68,14 @@ export const features = tableFeatures({ sortedRowModel: createSortedRowModel(), groupedRowModel: createGroupedRowModel(), expandedRowModel: createExpandedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns, - aggregationFns, + filterFns: { fuzzy: fuzzyFilterFn }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + min: aggregationFn_min, + }, }) diff --git a/examples/react/kitchen-sink-shadcn-radix/src/types/index.ts b/examples/react/kitchen-sink-shadcn-radix/src/types/index.ts index 4958d1736a..81e5da72ed 100644 --- a/examples/react/kitchen-sink-shadcn-radix/src/types/index.ts +++ b/examples/react/kitchen-sink-shadcn-radix/src/types/index.ts @@ -1,7 +1,7 @@ import type { + BuiltInFilterFn, ColumnFilter, TableFeatures, - filterFns, } from '@tanstack/react-table' export type TableFilterFeatures = Pick< @@ -10,7 +10,7 @@ export type TableFilterFeatures = Pick< > export type FilterOperator = - | keyof typeof filterFns + | BuiltInFilterFn | 'notIncludesString' | 'notEqualsString' | 'notEquals' diff --git a/examples/react/kitchen-sink/package.json b/examples/react/kitchen-sink/package.json index fb938b4818..d370e36513 100644 --- a/examples/react/kitchen-sink/package.json +++ b/examples/react/kitchen-sink/package.json @@ -23,8 +23,8 @@ "@tanstack/react-router": "^1.170.17", "@tanstack/react-start": "^1.168.27", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/lib-chakra-ui/package.json b/examples/react/lib-chakra-ui/package.json index 113330c717..b97f84dcb2 100644 --- a/examples/react/lib-chakra-ui/package.json +++ b/examples/react/lib-chakra-ui/package.json @@ -16,7 +16,7 @@ "@emotion/react": "^11.14.0", "@faker-js/faker": "^10.5.0", "@tabler/icons-react": "^3.44.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/lib-chakra-ui/src/main.tsx b/examples/react/lib-chakra-ui/src/main.tsx index ba751fc096..006fecbe9d 100644 --- a/examples/react/lib-chakra-ui/src/main.tsx +++ b/examples/react/lib-chakra-ui/src/main.tsx @@ -25,11 +25,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -45,8 +46,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-hero-ui/package.json b/examples/react/lib-hero-ui/package.json index 94790ddef4..6b6ce3c321 100644 --- a/examples/react/lib-hero-ui/package.json +++ b/examples/react/lib-hero-ui/package.json @@ -16,7 +16,7 @@ "@heroui/react": "^3.2.1", "@heroui/styles": "^3.2.1", "@tailwindcss/vite": "^4.3.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7", "tailwindcss": "^4.3.1" diff --git a/examples/react/lib-hero-ui/src/main.tsx b/examples/react/lib-hero-ui/src/main.tsx index 20c29ae961..012f8d55fd 100644 --- a/examples/react/lib-hero-ui/src/main.tsx +++ b/examples/react/lib-hero-ui/src/main.tsx @@ -16,11 +16,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -38,8 +39,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-mantine/package.json b/examples/react/lib-mantine/package.json index 6bdf0b1f39..e75133a4c0 100644 --- a/examples/react/lib-mantine/package.json +++ b/examples/react/lib-mantine/package.json @@ -16,7 +16,7 @@ "@mantine/core": "^9.4.0", "@mantine/hooks": "^9.4.0", "@tabler/icons-react": "^3.44.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/lib-mantine/src/main.tsx b/examples/react/lib-mantine/src/main.tsx index 292a493fe3..a8ddaa26cd 100644 --- a/examples/react/lib-mantine/src/main.tsx +++ b/examples/react/lib-mantine/src/main.tsx @@ -28,11 +28,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -48,8 +49,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-material-ui/package.json b/examples/react/lib-material-ui/package.json index 9d99967600..8b9f4d5033 100644 --- a/examples/react/lib-material-ui/package.json +++ b/examples/react/lib-material-ui/package.json @@ -17,7 +17,7 @@ "@faker-js/faker": "^10.5.0", "@mui/icons-material": "^9.1.1", "@mui/material": "^9.1.2", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/lib-material-ui/src/main.tsx b/examples/react/lib-material-ui/src/main.tsx index 2cf090db4e..a38c8281ae 100644 --- a/examples/react/lib-material-ui/src/main.tsx +++ b/examples/react/lib-material-ui/src/main.tsx @@ -29,11 +29,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -49,8 +50,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-react-aria/package.json b/examples/react/lib-react-aria/package.json index 192b38b215..748312077a 100644 --- a/examples/react/lib-react-aria/package.json +++ b/examples/react/lib-react-aria/package.json @@ -14,7 +14,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tailwindcss/vite": "^4.3.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-aria-components": "^1.19.0", "react-dom": "^19.2.7", diff --git a/examples/react/lib-react-aria/src/main.tsx b/examples/react/lib-react-aria/src/main.tsx index f4c7b435ce..e8ec4b7ad5 100644 --- a/examples/react/lib-react-aria/src/main.tsx +++ b/examples/react/lib-react-aria/src/main.tsx @@ -22,11 +22,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -44,8 +45,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-shadcn-base/package.json b/examples/react/lib-shadcn-base/package.json index 9bfa1c8c29..b685d31927 100644 --- a/examples/react/lib-shadcn-base/package.json +++ b/examples/react/lib-shadcn-base/package.json @@ -16,7 +16,7 @@ "@faker-js/faker": "^10.5.0", "@tailwindcss/vite": "^4.3.1", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "lucide-react": "^1.21.0", diff --git a/examples/react/lib-shadcn-base/src/main.tsx b/examples/react/lib-shadcn-base/src/main.tsx index 8d7103870f..9d2b80e30e 100644 --- a/examples/react/lib-shadcn-base/src/main.tsx +++ b/examples/react/lib-shadcn-base/src/main.tsx @@ -6,11 +6,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -57,8 +58,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/lib-shadcn-radix/package.json b/examples/react/lib-shadcn-radix/package.json index 80336e9119..bfc2bae4a2 100644 --- a/examples/react/lib-shadcn-radix/package.json +++ b/examples/react/lib-shadcn-radix/package.json @@ -15,7 +15,7 @@ "@faker-js/faker": "^10.5.0", "@tailwindcss/vite": "^4.3.1", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "lucide-react": "^1.21.0", diff --git a/examples/react/lib-shadcn-radix/src/main.tsx b/examples/react/lib-shadcn-radix/src/main.tsx index 8d7103870f..9d2b80e30e 100644 --- a/examples/react/lib-shadcn-radix/src/main.tsx +++ b/examples/react/lib-shadcn-radix/src/main.tsx @@ -6,11 +6,12 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -57,8 +58,13 @@ const features = tableFeatures({ sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), filteredRowModel: createFilteredRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/mantine-react-table/package.json b/examples/react/mantine-react-table/package.json index 202f70bb3a..1812b74f5d 100644 --- a/examples/react/mantine-react-table/package.json +++ b/examples/react/mantine-react-table/package.json @@ -18,7 +18,7 @@ "@tabler/icons-react": "^3.44.0", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "clsx": "^2.1.1", "dayjs": "^1.11.21", diff --git a/examples/react/material-react-table/package.json b/examples/react/material-react-table/package.json index c0abb2d14a..bde425da1e 100644 --- a/examples/react/material-react-table/package.json +++ b/examples/react/material-react-table/package.json @@ -21,7 +21,7 @@ "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/react-pacer": "^0.22.1", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "highlight-words": "^2.0.0", "react": "^19.2.7", diff --git a/examples/react/pagination/package.json b/examples/react/pagination/package.json index 55edc59519..24a1ebecac 100644 --- a/examples/react/pagination/package.json +++ b/examples/react/pagination/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/row-dnd/package.json b/examples/react/row-dnd/package.json index 8848058159..f82eb0a30f 100644 --- a/examples/react/row-dnd/package.json +++ b/examples/react/row-dnd/package.json @@ -16,7 +16,7 @@ "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/row-pinning/package.json b/examples/react/row-pinning/package.json index 8e3b6cbeec..ee03293f5b 100644 --- a/examples/react/row-pinning/package.json +++ b/examples/react/row-pinning/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/row-pinning/src/main.tsx b/examples/react/row-pinning/src/main.tsx index 3c0739df04..a57af14f02 100644 --- a/examples/react/row-pinning/src/main.tsx +++ b/examples/react/row-pinning/src/main.tsx @@ -7,7 +7,8 @@ import { createExpandedRowModel, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, @@ -35,7 +36,10 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/row-selection/package.json b/examples/react/row-selection/package.json index 0e7ee38c47..df8c396c55 100644 --- a/examples/react/row-selection/package.json +++ b/examples/react/row-selection/package.json @@ -15,8 +15,8 @@ "@tanstack/react-devtools": "^0.10.8", "@tanstack/react-pacer": "^0.22.1", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/row-selection/src/main.tsx b/examples/react/row-selection/src/main.tsx index 7b882a3385..f2e1c1f198 100644 --- a/examples/react/row-selection/src/main.tsx +++ b/examples/react/row-selection/src/main.tsx @@ -6,7 +6,8 @@ import { createColumnHelper, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -32,7 +33,10 @@ const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/sorting/package.json b/examples/react/sorting/package.json index 0126add54c..3091e5e430 100644 --- a/examples/react/sorting/package.json +++ b/examples/react/sorting/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/sorting/src/main.tsx b/examples/react/sorting/src/main.tsx index 9bdae03de8..8b2e7915af 100644 --- a/examples/react/sorting/src/main.tsx +++ b/examples/react/sorting/src/main.tsx @@ -5,7 +5,9 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -16,7 +18,11 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/sub-components/package.json b/examples/react/sub-components/package.json index 258f7ca821..29e46a8499 100644 --- a/examples/react/sub-components/package.json +++ b/examples/react/sub-components/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/virtualized-columns-experimental/package.json b/examples/react/virtualized-columns-experimental/package.json index 8c9e40cb09..c325b4a745 100644 --- a/examples/react/virtualized-columns-experimental/package.json +++ b/examples/react/virtualized-columns-experimental/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/virtualized-columns-experimental/src/main.tsx b/examples/react/virtualized-columns-experimental/src/main.tsx index fba4724906..4d660f678a 100644 --- a/examples/react/virtualized-columns-experimental/src/main.tsx +++ b/examples/react/virtualized-columns-experimental/src/main.tsx @@ -8,7 +8,8 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, useTable, } from '@tanstack/react-table' import { useVirtualizer } from '@tanstack/react-virtual' @@ -28,7 +29,10 @@ const features = { columnSizingFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, } const columnHelper = createColumnHelper() diff --git a/examples/react/virtualized-columns/package.json b/examples/react/virtualized-columns/package.json index 70c1d258b5..73f7b33312 100644 --- a/examples/react/virtualized-columns/package.json +++ b/examples/react/virtualized-columns/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/virtualized-columns/src/main.tsx b/examples/react/virtualized-columns/src/main.tsx index 9f7574c294..98f232410e 100644 --- a/examples/react/virtualized-columns/src/main.tsx +++ b/examples/react/virtualized-columns/src/main.tsx @@ -8,7 +8,8 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, useTable, } from '@tanstack/react-table' import { useVirtualizer } from '@tanstack/react-virtual' @@ -29,7 +30,10 @@ const features = { columnVisibilityFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, } const columnHelper = createColumnHelper() diff --git a/examples/react/virtualized-infinite-scrolling/package.json b/examples/react/virtualized-infinite-scrolling/package.json index 3188f907b6..072bb72ade 100644 --- a/examples/react/virtualized-infinite-scrolling/package.json +++ b/examples/react/virtualized-infinite-scrolling/package.json @@ -13,7 +13,7 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/react-query": "^5.101.2", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/virtualized-infinite-scrolling/src/main.tsx b/examples/react/virtualized-infinite-scrolling/src/main.tsx index ba7e72352c..730f438e07 100644 --- a/examples/react/virtualized-infinite-scrolling/src/main.tsx +++ b/examples/react/virtualized-infinite-scrolling/src/main.tsx @@ -8,7 +8,9 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, useTable, } from '@tanstack/react-table' @@ -29,7 +31,11 @@ const features = tableFeatures({ columnSizingFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/react/virtualized-rows-experimental/package.json b/examples/react/virtualized-rows-experimental/package.json index 674685fcfd..f53c99888c 100644 --- a/examples/react/virtualized-rows-experimental/package.json +++ b/examples/react/virtualized-rows-experimental/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/virtualized-rows-experimental/src/main.tsx b/examples/react/virtualized-rows-experimental/src/main.tsx index 8f44f2b4e5..f866ad3dee 100644 --- a/examples/react/virtualized-rows-experimental/src/main.tsx +++ b/examples/react/virtualized-rows-experimental/src/main.tsx @@ -6,7 +6,9 @@ import { createColumnHelper, createSortedRowModel, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, useTable, } from '@tanstack/react-table' import { useVirtualizer } from '@tanstack/react-virtual' @@ -20,7 +22,11 @@ const features = { columnSizingFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, } const columnHelper = createColumnHelper() diff --git a/examples/react/virtualized-rows/package.json b/examples/react/virtualized-rows/package.json index 8cb9bef29a..8fd9e426e1 100644 --- a/examples/react/virtualized-rows/package.json +++ b/examples/react/virtualized-rows/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "@tanstack/react-virtual": "^3.14.5", "react": "^19.2.7", "react-dom": "^19.2.7" diff --git a/examples/react/virtualized-rows/src/main.tsx b/examples/react/virtualized-rows/src/main.tsx index 21b71a5aae..b4f682d079 100644 --- a/examples/react/virtualized-rows/src/main.tsx +++ b/examples/react/virtualized-rows/src/main.tsx @@ -9,7 +9,9 @@ import { createSortedRowModel, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, useTable, } from '@tanstack/react-table' import { useVirtualizer } from '@tanstack/react-virtual' @@ -24,7 +26,11 @@ const features = { rowSelectionFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, } const columnHelper = createColumnHelper() diff --git a/examples/react/web-worker-row-models/package.json b/examples/react/web-worker-row-models/package.json index cd32390a16..2056916dd8 100644 --- a/examples/react/web-worker-row-models/package.json +++ b/examples/react/web-worker-row-models/package.json @@ -17,8 +17,8 @@ "@tanstack/react-router": "^1.170.17", "@tanstack/react-start": "^1.168.27", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/web-worker-row-models/src/tableConfig.tsx b/examples/react/web-worker-row-models/src/tableConfig.tsx index e1292694c5..54510662e8 100644 --- a/examples/react/web-worker-row-models/src/tableConfig.tsx +++ b/examples/react/web-worker-row-models/src/tableConfig.tsx @@ -1,5 +1,8 @@ import { - aggregationFns, + aggregationFn_extent, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createColumnHelper, @@ -8,13 +11,15 @@ import { createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, globalFilteringFeature, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_datetime, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { workerRowModelsFeature } from '@tanstack/react-table/experimental-worker-plugin' @@ -50,9 +55,20 @@ export const sharedFeatures = tableFeatures({ sortedRowModel: createSortedRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, - aggregationFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + datetime: sortFn_datetime, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + }, + aggregationFns: { + extent: aggregationFn_extent, + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) export const columnHelper = createColumnHelper() diff --git a/examples/react/with-tanstack-form/package.json b/examples/react/with-tanstack-form/package.json index 1378c8182a..0a3bdbc531 100644 --- a/examples/react/with-tanstack-form/package.json +++ b/examples/react/with-tanstack-form/package.json @@ -16,8 +16,8 @@ "@tanstack/react-form": "^1.33.1", "@tanstack/react-form-devtools": "^0.2.30", "@tanstack/react-pacer": "^0.22.1", - "@tanstack/react-table": "^9.0.0-beta.46", - "@tanstack/react-table-devtools": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", + "@tanstack/react-table-devtools": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7", "zod": "^4.4.3" diff --git a/examples/react/with-tanstack-form/src/table.tsx b/examples/react/with-tanstack-form/src/table.tsx index c33695c7d7..7dfb4c0283 100644 --- a/examples/react/with-tanstack-form/src/table.tsx +++ b/examples/react/with-tanstack-form/src/table.tsx @@ -5,10 +5,12 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/react-table' import { useDebouncedCallback } from '@tanstack/react-pacer/debouncer' @@ -219,8 +221,14 @@ export const { filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }), tableComponents: { PaginationControls, diff --git a/examples/react/with-tanstack-query/package.json b/examples/react/with-tanstack-query/package.json index 12d1094e36..ae4bfdc4b4 100644 --- a/examples/react/with-tanstack-query/package.json +++ b/examples/react/with-tanstack-query/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@tanstack/react-query": "^5.101.2", "@tanstack/react-store": "^0.11.0", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/react/with-tanstack-router/package.json b/examples/react/with-tanstack-router/package.json index 9a7512999a..5d2f80f6e3 100644 --- a/examples/react/with-tanstack-router/package.json +++ b/examples/react/with-tanstack-router/package.json @@ -14,7 +14,7 @@ "@tanstack/react-pacer": "^0.22.1", "@tanstack/react-query": "^5.101.2", "@tanstack/react-router": "^1.170.17", - "@tanstack/react-table": "^9.0.0-beta.46", + "@tanstack/react-table": "^9.0.0-beta.47", "react": "^19.2.7", "react-dom": "^19.2.7" }, diff --git a/examples/solid/basic-app-table/package.json b/examples/solid/basic-app-table/package.json index 51a28f1c08..eef633397a 100644 --- a/examples/solid/basic-app-table/package.json +++ b/examples/solid/basic-app-table/package.json @@ -19,8 +19,8 @@ "dependencies": { "@faker-js/faker": "^10.5.0", "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/basic-dynamic-columns/package.json b/examples/solid/basic-dynamic-columns/package.json index 93758d3072..7746034c5b 100644 --- a/examples/solid/basic-dynamic-columns/package.json +++ b/examples/solid/basic-dynamic-columns/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@tanstack/solid-pacer": "^0.21.1", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/basic-dynamic-columns/src/App.tsx b/examples/solid/basic-dynamic-columns/src/App.tsx index 6c37179af7..63b767ffec 100644 --- a/examples/solid/basic-dynamic-columns/src/App.tsx +++ b/examples/solid/basic-dynamic-columns/src/App.tsx @@ -8,10 +8,13 @@ import { createFilteredRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, } from '@tanstack/solid-table' import { For, Show, createMemo, createSignal } from 'solid-js' @@ -53,8 +56,17 @@ export const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort fns we reference by name below + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + // register only the built-in filter fns we reference by name below + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/solid/basic-external-atoms/package.json b/examples/solid/basic-external-atoms/package.json index 1c13c0a46b..41812a158c 100644 --- a/examples/solid/basic-external-atoms/package.json +++ b/examples/solid/basic-external-atoms/package.json @@ -20,8 +20,8 @@ "dependencies": { "@tanstack/solid-devtools": "^0.8.8", "@tanstack/solid-store": "^0.11.0", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/basic-external-atoms/src/App.tsx b/examples/solid/basic-external-atoms/src/App.tsx index e8678bee93..6524ea3068 100644 --- a/examples/solid/basic-external-atoms/src/App.tsx +++ b/examples/solid/basic-external-atoms/src/App.tsx @@ -6,7 +6,8 @@ import { createTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { useTanStackTableDevtools } from '@tanstack/solid-table-devtools' @@ -26,7 +27,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/solid/basic-external-state/package.json b/examples/solid/basic-external-state/package.json index c10ff00bc9..e3112c0253 100644 --- a/examples/solid/basic-external-state/package.json +++ b/examples/solid/basic-external-state/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/basic-external-state/src/App.tsx b/examples/solid/basic-external-state/src/App.tsx index 047671397a..9a8a8cf44b 100644 --- a/examples/solid/basic-external-state/src/App.tsx +++ b/examples/solid/basic-external-state/src/App.tsx @@ -6,7 +6,8 @@ import { createTable, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { useTanStackTableDevtools } from '@tanstack/solid-table-devtools' @@ -22,7 +23,10 @@ const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/solid/basic-use-table/package.json b/examples/solid/basic-use-table/package.json index 73b6585118..07ab601e3b 100644 --- a/examples/solid/basic-use-table/package.json +++ b/examples/solid/basic-use-table/package.json @@ -18,8 +18,8 @@ }, "dependencies": { "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-groups/package.json b/examples/solid/column-groups/package.json index 8535bc244d..37a7bdf620 100644 --- a/examples/solid/column-groups/package.json +++ b/examples/solid/column-groups/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-ordering/package.json b/examples/solid/column-ordering/package.json index b4ade7c83d..834fa86b08 100644 --- a/examples/solid/column-ordering/package.json +++ b/examples/solid/column-ordering/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-pinning-split/package.json b/examples/solid/column-pinning-split/package.json index 3b43bbcb68..42059ec798 100644 --- a/examples/solid/column-pinning-split/package.json +++ b/examples/solid/column-pinning-split/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-pinning-sticky/package.json b/examples/solid/column-pinning-sticky/package.json index ae86482150..1dee9276d7 100644 --- a/examples/solid/column-pinning-sticky/package.json +++ b/examples/solid/column-pinning-sticky/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-pinning/package.json b/examples/solid/column-pinning/package.json index e54fcc9c82..b02af7b579 100644 --- a/examples/solid/column-pinning/package.json +++ b/examples/solid/column-pinning/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-resizing-performant/package.json b/examples/solid/column-resizing-performant/package.json index e632e03973..ec621741c1 100644 --- a/examples/solid/column-resizing-performant/package.json +++ b/examples/solid/column-resizing-performant/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-resizing/package.json b/examples/solid/column-resizing/package.json index f5a9dca965..d1cd6e5540 100644 --- a/examples/solid/column-resizing/package.json +++ b/examples/solid/column-resizing/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-sizing/package.json b/examples/solid/column-sizing/package.json index b4c648c37e..32eefff4fc 100644 --- a/examples/solid/column-sizing/package.json +++ b/examples/solid/column-sizing/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/column-visibility/package.json b/examples/solid/column-visibility/package.json index add07d469d..05da46868f 100644 --- a/examples/solid/column-visibility/package.json +++ b/examples/solid/column-visibility/package.json @@ -18,7 +18,7 @@ }, "dependencies": { "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/composable-tables/package.json b/examples/solid/composable-tables/package.json index 3be96e0eac..5e57974f4f 100644 --- a/examples/solid/composable-tables/package.json +++ b/examples/solid/composable-tables/package.json @@ -18,8 +18,8 @@ }, "dependencies": { "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/composable-tables/src/hooks/table.ts b/examples/solid/composable-tables/src/hooks/table.ts index 377aed21e8..ef110cec71 100644 --- a/examples/solid/composable-tables/src/hooks/table.ts +++ b/examples/solid/composable-tables/src/hooks/table.ts @@ -11,11 +11,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' @@ -71,8 +73,14 @@ export const { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }), // set any default table options here too diff --git a/examples/solid/expanding/package.json b/examples/solid/expanding/package.json index 995e910a2f..9274b753af 100644 --- a/examples/solid/expanding/package.json +++ b/examples/solid/expanding/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/expanding/src/App.tsx b/examples/solid/expanding/src/App.tsx index 52a760a8d4..f27c53a270 100644 --- a/examples/solid/expanding/src/App.tsx +++ b/examples/solid/expanding/src/App.tsx @@ -6,12 +6,15 @@ import { createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_between, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { For, Show, createEffect, createSignal } from 'solid-js' @@ -29,8 +32,15 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + between: filterFn_between, + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/solid/filters-faceted/package.json b/examples/solid/filters-faceted/package.json index d5dc0c9fa3..eb0d07ec7a 100644 --- a/examples/solid/filters-faceted/package.json +++ b/examples/solid/filters-faceted/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@tanstack/solid-pacer": "^0.21.1", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/filters-faceted/src/App.tsx b/examples/solid/filters-faceted/src/App.tsx index 3ad017826b..e35c836b68 100644 --- a/examples/solid/filters-faceted/src/App.tsx +++ b/examples/solid/filters-faceted/src/App.tsx @@ -8,7 +8,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -30,7 +31,10 @@ export const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columns: Array> = [ diff --git a/examples/solid/filters-fuzzy/package.json b/examples/solid/filters-fuzzy/package.json index 8198c538ce..2210f6687f 100644 --- a/examples/solid/filters-fuzzy/package.json +++ b/examples/solid/filters-fuzzy/package.json @@ -20,7 +20,7 @@ "dependencies": { "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/solid-pacer": "^0.21.1", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/filters-fuzzy/src/App.tsx b/examples/solid/filters-fuzzy/src/App.tsx index 73fe68e94c..01c34a4f25 100644 --- a/examples/solid/filters-fuzzy/src/App.tsx +++ b/examples/solid/filters-fuzzy/src/App.tsx @@ -5,12 +5,15 @@ import { createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_includesStringSensitive, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { createDebouncer } from '@tanstack/solid-pacer/debouncer' @@ -52,7 +55,7 @@ const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } const features = tableFeatures({ @@ -63,8 +66,17 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + equalsString: filterFn_equalsString, + includesString: filterFn_includesString, + includesStringSensitive: filterFn_includesStringSensitive, + fuzzy: fuzzyFilter, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySort, + }, filterMeta: metaHelper(), }) diff --git a/examples/solid/filters/package.json b/examples/solid/filters/package.json index 6a385207cc..cc23c75f0e 100644 --- a/examples/solid/filters/package.json +++ b/examples/solid/filters/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@tanstack/solid-pacer": "^0.21.1", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/filters/src/App.tsx b/examples/solid/filters/src/App.tsx index 628d5b6d61..865b6087ff 100644 --- a/examples/solid/filters/src/App.tsx +++ b/examples/solid/filters/src/App.tsx @@ -8,7 +8,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -30,7 +31,10 @@ export const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) const columns: Array> = [ diff --git a/examples/solid/grouping/package.json b/examples/solid/grouping/package.json index e6357d12c3..3ac05ba460 100644 --- a/examples/solid/grouping/package.json +++ b/examples/solid/grouping/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/grouping/src/App.tsx b/examples/solid/grouping/src/App.tsx index e66631d306..4b6832a380 100644 --- a/examples/solid/grouping/src/App.tsx +++ b/examples/solid/grouping/src/App.tsx @@ -1,5 +1,7 @@ import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, columnFilteringFeature, columnGroupingFeature, createExpandedRowModel, @@ -8,11 +10,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/solid-table' import { For, createSignal } from 'solid-js' import { makeData } from './makeData' @@ -30,9 +34,19 @@ const { createAppTable, createAppColumnHelper } = createTableHook({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }, }) diff --git a/examples/solid/kitchen-sink/package.json b/examples/solid/kitchen-sink/package.json index ac9914ba95..56bc21272c 100644 --- a/examples/solid/kitchen-sink/package.json +++ b/examples/solid/kitchen-sink/package.json @@ -20,8 +20,8 @@ "dependencies": { "@tanstack/match-sorter-utils": "^9.0.0-beta.41", "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/kitchen-sink/src/App.tsx b/examples/solid/kitchen-sink/src/App.tsx index 2534e441fb..b5962e4d9c 100644 --- a/examples/solid/kitchen-sink/src/App.tsx +++ b/examples/solid/kitchen-sink/src/App.tsx @@ -1,6 +1,8 @@ import { faker } from '@faker-js/faker' import { - aggregationFns, + aggregationFn_mean, + aggregationFn_median, + aggregationFn_sum, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, @@ -10,9 +12,11 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, metaHelper, - sortFns, + sortFn_alphanumeric, + sortFn_text, stockFeatures, tableFeatures, } from '@tanstack/solid-table' @@ -65,7 +69,7 @@ const fuzzySortFn: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank!, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } interface MyColumnMeta { @@ -84,9 +88,21 @@ const features = tableFeatures({ groupedRowModel: createGroupedRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilterFn }, - sortFns: { ...sortFns, fuzzy: fuzzySortFn }, - aggregationFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + fuzzy: fuzzyFilterFn, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + fuzzy: fuzzySortFn, + }, + aggregationFns: { + mean: aggregationFn_mean, + median: aggregationFn_median, + sum: aggregationFn_sum, + }, }) const { createAppTable, createAppColumnHelper } = createTableHook({ diff --git a/examples/solid/pagination/package.json b/examples/solid/pagination/package.json index d27d5364cb..d509ba1338 100644 --- a/examples/solid/pagination/package.json +++ b/examples/solid/pagination/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/row-pinning/package.json b/examples/solid/row-pinning/package.json index 54d42adc64..dd4dcf9d26 100644 --- a/examples/solid/row-pinning/package.json +++ b/examples/solid/row-pinning/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/row-pinning/src/App.tsx b/examples/solid/row-pinning/src/App.tsx index c2a2d01e78..e82d331923 100644 --- a/examples/solid/row-pinning/src/App.tsx +++ b/examples/solid/row-pinning/src/App.tsx @@ -4,7 +4,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, @@ -30,7 +31,10 @@ const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), expandedRowModel: createExpandedRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) function App() { diff --git a/examples/solid/row-selection/package.json b/examples/solid/row-selection/package.json index 867aaf597a..8e9319244b 100644 --- a/examples/solid/row-selection/package.json +++ b/examples/solid/row-selection/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@tanstack/solid-devtools": "^0.8.8", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/row-selection/src/App.tsx b/examples/solid/row-selection/src/App.tsx index 75e30c39f2..4611f93d9b 100644 --- a/examples/solid/row-selection/src/App.tsx +++ b/examples/solid/row-selection/src/App.tsx @@ -5,7 +5,8 @@ import { createFilteredRowModel, createPaginatedRowModel, createTable, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, @@ -29,7 +30,10 @@ export const features = tableFeatures({ globalFilteringFeature, filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) function App() { diff --git a/examples/solid/sorting/package.json b/examples/solid/sorting/package.json index 2f5e735316..e993a5c30b 100644 --- a/examples/solid/sorting/package.json +++ b/examples/solid/sorting/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/sorting/src/App.tsx b/examples/solid/sorting/src/App.tsx index 2d637db6a1..e2493ec6f2 100644 --- a/examples/solid/sorting/src/App.tsx +++ b/examples/solid/sorting/src/App.tsx @@ -3,7 +3,8 @@ import { createSortedRowModel, createTable, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { For, Show, createSignal } from 'solid-js' @@ -14,7 +15,10 @@ import type { Person } from './makeData' const features = tableFeatures({ rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) function App() { diff --git a/examples/solid/sub-components/package.json b/examples/solid/sub-components/package.json index 5d9b943d6d..4ae574dfc0 100644 --- a/examples/solid/sub-components/package.json +++ b/examples/solid/sub-components/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/virtualized-columns/package.json b/examples/solid/virtualized-columns/package.json index 500fe9df41..9e695799d1 100644 --- a/examples/solid/virtualized-columns/package.json +++ b/examples/solid/virtualized-columns/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "@tanstack/solid-virtual": "^3.13.32", "solid-js": "^1.9.13" } diff --git a/examples/solid/virtualized-infinite-scrolling/package.json b/examples/solid/virtualized-infinite-scrolling/package.json index b4f56e94b0..ed91bf5601 100644 --- a/examples/solid/virtualized-infinite-scrolling/package.json +++ b/examples/solid/virtualized-infinite-scrolling/package.json @@ -20,7 +20,7 @@ "dependencies": { "@tanstack/solid-query": "^5.101.2", "@tanstack/solid-store": "^0.11.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "@tanstack/solid-virtual": "^3.13.32", "solid-js": "^1.9.13" } diff --git a/examples/solid/virtualized-rows/package.json b/examples/solid/virtualized-rows/package.json index 7bd565e298..9ce7543cc9 100644 --- a/examples/solid/virtualized-rows/package.json +++ b/examples/solid/virtualized-rows/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "@tanstack/solid-virtual": "^3.13.32", "solid-js": "^1.9.13" } diff --git a/examples/solid/with-tanstack-form/package.json b/examples/solid/with-tanstack-form/package.json index 194fd05b27..24db896709 100644 --- a/examples/solid/with-tanstack-form/package.json +++ b/examples/solid/with-tanstack-form/package.json @@ -21,8 +21,8 @@ "@tanstack/solid-devtools": "^0.8.8", "@tanstack/solid-form": "^1.33.1", "@tanstack/solid-form-devtools": "^0.2.30", - "@tanstack/solid-table": "^9.0.0-beta.46", - "@tanstack/solid-table-devtools": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", + "@tanstack/solid-table-devtools": "^9.0.0-beta.47", "solid-js": "^1.9.13", "zod": "^4.4.3" } diff --git a/examples/solid/with-tanstack-form/src/table.tsx b/examples/solid/with-tanstack-form/src/table.tsx index 21deae192a..27a934bd1f 100644 --- a/examples/solid/with-tanstack-form/src/table.tsx +++ b/examples/solid/with-tanstack-form/src/table.tsx @@ -4,10 +4,12 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_inNumberRange, + filterFn_includesString, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/solid-table' import { For, Show, createMemo, createSignal } from 'solid-js' @@ -212,8 +214,14 @@ export const { filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }), tableComponents: { PaginationControls, diff --git a/examples/solid/with-tanstack-query/package.json b/examples/solid/with-tanstack-query/package.json index 2cb53f3b45..80502e0823 100644 --- a/examples/solid/with-tanstack-query/package.json +++ b/examples/solid/with-tanstack-query/package.json @@ -20,7 +20,7 @@ "dependencies": { "@tanstack/solid-query": "^5.101.2", "@tanstack/solid-store": "^0.11.0", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/solid/with-tanstack-router/package.json b/examples/solid/with-tanstack-router/package.json index a4dec4541e..211d1e015c 100644 --- a/examples/solid/with-tanstack-router/package.json +++ b/examples/solid/with-tanstack-router/package.json @@ -22,7 +22,7 @@ "@tanstack/solid-pacer": "^0.21.1", "@tanstack/solid-query": "^5.101.2", "@tanstack/solid-router": "^1.170.17", - "@tanstack/solid-table": "^9.0.0-beta.46", + "@tanstack/solid-table": "^9.0.0-beta.47", "solid-js": "^1.9.13" } } diff --git a/examples/svelte/basic-app-table/package.json b/examples/svelte/basic-app-table/package.json index 76b1f1de87..843777ffc5 100644 --- a/examples/svelte/basic-app-table/package.json +++ b/examples/svelte/basic-app-table/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/basic-app-table/src/App.svelte b/examples/svelte/basic-app-table/src/App.svelte index 00a273bcbd..59d7950221 100644 --- a/examples/svelte/basic-app-table/src/App.svelte +++ b/examples/svelte/basic-app-table/src/App.svelte @@ -8,7 +8,8 @@ FlexRender, rowSortingFeature, createSortedRowModel, - sortFns, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/svelte-table' import { makeData, type Person } from './makeData' import './index.css' @@ -16,7 +17,11 @@ // 1. New in V9! Tell the table which features and row models we want to use. const { createAppTable, createAppColumnHelper } = createTableHook({ - features: { rowSortingFeature, sortedRowModel: createSortedRowModel(), sortFns }, + features: { + rowSortingFeature, + sortedRowModel: createSortedRowModel(), + sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text }, + }, debugTable: true, }) diff --git a/examples/svelte/basic-create-table/package.json b/examples/svelte/basic-create-table/package.json index ec88f043f0..7c854b9274 100644 --- a/examples/svelte/basic-create-table/package.json +++ b/examples/svelte/basic-create-table/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/basic-dynamic-columns/package.json b/examples/svelte/basic-dynamic-columns/package.json index b5a5daf911..c8061631ce 100644 --- a/examples/svelte/basic-dynamic-columns/package.json +++ b/examples/svelte/basic-dynamic-columns/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/basic-dynamic-columns/src/features.ts b/examples/svelte/basic-dynamic-columns/src/features.ts index 48a32d1c8d..0d4f483205 100644 --- a/examples/svelte/basic-dynamic-columns/src/features.ts +++ b/examples/svelte/basic-dynamic-columns/src/features.ts @@ -6,10 +6,13 @@ import { createFacetedUniqueValues, createFilteredRowModel, createSortedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, metaHelper, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_basic, + sortFn_datetime, tableFeatures, } from '@tanstack/svelte-table' import type { @@ -47,8 +50,16 @@ export const features = tableFeatures({ facetedRowModel: createFacetedRowModel(), facetedUniqueValues: createFacetedUniqueValues(), // powers the enum select options facetedMinMaxValues: createFacetedMinMaxValues(), // powers the numeric range hints - sortFns, // register the built-in sort fns so we can reference them by name - filterFns, // register the built-in filter fns so we can reference them by name + // register only the built-in sort/filter fns we reference by name below + sortFns: { + alphanumeric: sortFn_alphanumeric, + basic: sortFn_basic, + datetime: sortFn_datetime, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, columnMeta: metaHelper(), }) diff --git a/examples/svelte/basic-external-atoms/package.json b/examples/svelte/basic-external-atoms/package.json index 8de148fad9..bb759fe6bc 100644 --- a/examples/svelte/basic-external-atoms/package.json +++ b/examples/svelte/basic-external-atoms/package.json @@ -17,7 +17,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/basic-external-atoms/src/App.svelte b/examples/svelte/basic-external-atoms/src/App.svelte index 646c4c5ccc..549e1e2d08 100644 --- a/examples/svelte/basic-external-atoms/src/App.svelte +++ b/examples/svelte/basic-external-atoms/src/App.svelte @@ -12,7 +12,8 @@ FlexRender, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/svelte-table' import { createAtom, useSelector } from '@tanstack/svelte-store' @@ -26,7 +27,10 @@ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/svelte/basic-external-state/package.json b/examples/svelte/basic-external-state/package.json index 42d07d1fe5..e6b3378ac5 100644 --- a/examples/svelte/basic-external-state/package.json +++ b/examples/svelte/basic-external-state/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/basic-external-state/src/App.svelte b/examples/svelte/basic-external-state/src/App.svelte index dfef3d59d8..704ff6f623 100644 --- a/examples/svelte/basic-external-state/src/App.svelte +++ b/examples/svelte/basic-external-state/src/App.svelte @@ -11,7 +11,8 @@ FlexRender, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/svelte-table' import { makeData } from './makeData' @@ -24,7 +25,10 @@ rowSortingFeature, sortedRowModel: createSortedRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() diff --git a/examples/svelte/basic-snippets/package.json b/examples/svelte/basic-snippets/package.json index 5b5f808626..d241959b1d 100644 --- a/examples/svelte/basic-snippets/package.json +++ b/examples/svelte/basic-snippets/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-groups/package.json b/examples/svelte/column-groups/package.json index 5498bf08b1..00b0f0bd8f 100644 --- a/examples/svelte/column-groups/package.json +++ b/examples/svelte/column-groups/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-ordering/package.json b/examples/svelte/column-ordering/package.json index 8d64b9cdc6..ed60218efe 100644 --- a/examples/svelte/column-ordering/package.json +++ b/examples/svelte/column-ordering/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-pinning-split/package.json b/examples/svelte/column-pinning-split/package.json index 3175d3d421..0879b07e21 100644 --- a/examples/svelte/column-pinning-split/package.json +++ b/examples/svelte/column-pinning-split/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-pinning-sticky/package.json b/examples/svelte/column-pinning-sticky/package.json index b6d4dc0271..53d17750e6 100644 --- a/examples/svelte/column-pinning-sticky/package.json +++ b/examples/svelte/column-pinning-sticky/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-pinning/package.json b/examples/svelte/column-pinning/package.json index 45fa7b30c1..efdc05cec5 100644 --- a/examples/svelte/column-pinning/package.json +++ b/examples/svelte/column-pinning/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-pinning/src/App.svelte b/examples/svelte/column-pinning/src/App.svelte index 51b6069e63..ea609b1809 100644 --- a/examples/svelte/column-pinning/src/App.svelte +++ b/examples/svelte/column-pinning/src/App.svelte @@ -17,7 +17,8 @@ createTable, createTableState, tableFeatures, - sortFns, + sortFn_alphanumeric, + sortFn_text, } from '@tanstack/svelte-table' import './index.css' import { makeData, type Person } from './makeData' @@ -28,7 +29,10 @@ columnVisibilityFeature, rowSortingFeature, sortedRowModel: createSortedRowModel(), - sortFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columns: ColumnDef[] = [ diff --git a/examples/svelte/column-resizing-performant/package.json b/examples/svelte/column-resizing-performant/package.json index 25f4a21248..e6c85285d2 100644 --- a/examples/svelte/column-resizing-performant/package.json +++ b/examples/svelte/column-resizing-performant/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-resizing/package.json b/examples/svelte/column-resizing/package.json index 75169a760a..281a8fea08 100644 --- a/examples/svelte/column-resizing/package.json +++ b/examples/svelte/column-resizing/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-sizing/package.json b/examples/svelte/column-sizing/package.json index ca605c7303..14213d74a6 100644 --- a/examples/svelte/column-sizing/package.json +++ b/examples/svelte/column-sizing/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/column-visibility/package.json b/examples/svelte/column-visibility/package.json index aaa3ffaa8f..9177253b2e 100644 --- a/examples/svelte/column-visibility/package.json +++ b/examples/svelte/column-visibility/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/composable-tables/package.json b/examples/svelte/composable-tables/package.json index d392d177a9..75fca6cc0d 100644 --- a/examples/svelte/composable-tables/package.json +++ b/examples/svelte/composable-tables/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/composable-tables/src/hooks/table.ts b/examples/svelte/composable-tables/src/hooks/table.ts index fcff4aca29..97ea7be144 100644 --- a/examples/svelte/composable-tables/src/hooks/table.ts +++ b/examples/svelte/composable-tables/src/hooks/table.ts @@ -11,11 +11,13 @@ import { createPaginatedRowModel, createSortedRowModel, createTableHook, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/svelte-table' @@ -66,8 +68,14 @@ export const { sortedRowModel: createSortedRowModel(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - sortFns, - filterFns, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }), // set any default table options here too diff --git a/examples/svelte/expanding/package.json b/examples/svelte/expanding/package.json index 42126a7cab..5840e53dd2 100644 --- a/examples/svelte/expanding/package.json +++ b/examples/svelte/expanding/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/expanding/src/App.svelte b/examples/svelte/expanding/src/App.svelte index 084e405344..cb55346607 100644 --- a/examples/svelte/expanding/src/App.svelte +++ b/examples/svelte/expanding/src/App.svelte @@ -7,13 +7,15 @@ createPaginatedRowModel, createSortedRowModel, createTable, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, FlexRender, rowExpandingFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/svelte-table' import type { Column, SvelteTable } from '@tanstack/svelte-table' @@ -31,8 +33,14 @@ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns, - sortFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + text: sortFn_text, + }, }) const columnHelper = createColumnHelper() @@ -71,7 +79,7 @@ columnHelper.accessor('age', { header: () => 'Age', footer: (props) => props.column.id, - filterFn: 'between', + filterFn: 'inNumberRange', }), columnHelper.accessor('visits', { header: () => 'Visits', diff --git a/examples/svelte/filtering/package.json b/examples/svelte/filtering/package.json index d89ab5ed2e..9d51c6d55a 100644 --- a/examples/svelte/filtering/package.json +++ b/examples/svelte/filtering/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/filtering/src/features.ts b/examples/svelte/filtering/src/features.ts index 71bcb1199c..2a543aa0bc 100644 --- a/examples/svelte/filtering/src/features.ts +++ b/examples/svelte/filtering/src/features.ts @@ -6,7 +6,8 @@ import { createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -22,5 +23,8 @@ export const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) diff --git a/examples/svelte/filters-faceted/package.json b/examples/svelte/filters-faceted/package.json index f5119ac858..2912e49213 100644 --- a/examples/svelte/filters-faceted/package.json +++ b/examples/svelte/filters-faceted/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/filters-faceted/src/features.ts b/examples/svelte/filters-faceted/src/features.ts index 71bcb1199c..2a543aa0bc 100644 --- a/examples/svelte/filters-faceted/src/features.ts +++ b/examples/svelte/filters-faceted/src/features.ts @@ -6,7 +6,8 @@ import { createFacetedUniqueValues, createFilteredRowModel, createPaginatedRowModel, - filterFns, + filterFn_includesString, + filterFn_inNumberRange, globalFilteringFeature, rowPaginationFeature, tableFeatures, @@ -22,5 +23,8 @@ export const features = tableFeatures({ facetedUniqueValues: createFacetedUniqueValues(), filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), - filterFns, + filterFns: { + includesString: filterFn_includesString, + inNumberRange: filterFn_inNumberRange, + }, }) diff --git a/examples/svelte/filters-fuzzy/package.json b/examples/svelte/filters-fuzzy/package.json index b9dffa2771..0d3cd26aa0 100644 --- a/examples/svelte/filters-fuzzy/package.json +++ b/examples/svelte/filters-fuzzy/package.json @@ -15,7 +15,7 @@ "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", "@tanstack/match-sorter-utils": "^9.0.0-beta.41", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/filters-fuzzy/src/features.ts b/examples/svelte/filters-fuzzy/src/features.ts index a88deedbcf..2ef4239992 100644 --- a/examples/svelte/filters-fuzzy/src/features.ts +++ b/examples/svelte/filters-fuzzy/src/features.ts @@ -3,12 +3,15 @@ import { createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, - filterFns, + filterFn_equalsString, + filterFn_includesString, + filterFn_includesStringSensitive, globalFilteringFeature, metaHelper, rowPaginationFeature, rowSortingFeature, - sortFns, + sortFn_alphanumeric, + sortFn_text, tableFeatures, } from '@tanstack/svelte-table' import { compareItems, rankItem } from '@tanstack/match-sorter-utils' @@ -42,7 +45,7 @@ export const fuzzySort: SortFn = (rowA, rowB, columnId) => { rowB.columnFiltersMeta[columnId].itemRank as RankingInfo, ) } - return dir === 0 ? sortFns.alphanumeric(rowA, rowB, columnId) : dir + return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir } export const features = tableFeatures({ @@ -53,7 +56,16 @@ export const features = tableFeatures({ filteredRowModel: createFilteredRowModel(), paginatedRowModel: createPaginatedRowModel(), sortedRowModel: createSortedRowModel(), - filterFns: { ...filterFns, fuzzy: fuzzyFilter }, - sortFns: { ...sortFns, fuzzy: fuzzySort }, + filterFns: { + equalsString: filterFn_equalsString, + fuzzy: fuzzyFilter, + includesString: filterFn_includesString, + includesStringSensitive: filterFn_includesStringSensitive, + }, + sortFns: { + alphanumeric: sortFn_alphanumeric, + fuzzy: fuzzySort, + text: sortFn_text, + }, filterMeta: metaHelper(), }) diff --git a/examples/svelte/grouping/package.json b/examples/svelte/grouping/package.json index 6e70c94373..a23fdcf5fd 100644 --- a/examples/svelte/grouping/package.json +++ b/examples/svelte/grouping/package.json @@ -14,7 +14,7 @@ "@faker-js/faker": "^10.5.0", "@rollup/plugin-replace": "^6.0.3", "@sveltejs/vite-plugin-svelte": "^7.1.2", - "@tanstack/svelte-table": "^9.0.0-beta.46", + "@tanstack/svelte-table": "^9.0.0-beta.47", "@tsconfig/svelte": "^5.0.8", "svelte": "^5.56.2", "svelte-check": "^4.6.0", diff --git a/examples/svelte/grouping/src/App.svelte b/examples/svelte/grouping/src/App.svelte index 401fc40f92..55ad65bce6 100644 --- a/examples/svelte/grouping/src/App.svelte +++ b/examples/svelte/grouping/src/App.svelte @@ -1,6 +1,8 @@