@tanstack/table-core 9.0.0-beta.45 → 9.0.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +43 -3
  2. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +43 -3
  3. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +18 -9
  4. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  5. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +6 -2
  6. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +6 -2
  7. package/dist/features/column-filtering/columnFilteringFeature.utils.js +18 -9
  8. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  9. package/dist/features/column-filtering/createFilteredRowModel.cjs +7 -2
  10. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  11. package/dist/features/column-filtering/createFilteredRowModel.d.cts +6 -2
  12. package/dist/features/column-filtering/createFilteredRowModel.d.ts +6 -2
  13. package/dist/features/column-filtering/createFilteredRowModel.js +7 -2
  14. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  15. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +41 -3
  16. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +41 -3
  17. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +17 -3
  18. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  19. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +5 -0
  20. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +5 -0
  21. package/dist/features/column-grouping/columnGroupingFeature.utils.js +17 -3
  22. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  23. package/dist/features/column-grouping/createGroupedRowModel.cjs +6 -3
  24. package/dist/features/column-grouping/createGroupedRowModel.cjs.map +1 -1
  25. package/dist/features/column-grouping/createGroupedRowModel.d.cts +6 -3
  26. package/dist/features/column-grouping/createGroupedRowModel.d.ts +6 -3
  27. package/dist/features/column-grouping/createGroupedRowModel.js +6 -3
  28. package/dist/features/column-grouping/createGroupedRowModel.js.map +1 -1
  29. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +3 -1
  30. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  31. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +2 -6
  32. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +2 -6
  33. package/dist/features/global-filtering/globalFilteringFeature.utils.js +3 -1
  34. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  35. package/dist/features/row-sorting/createSortedRowModel.cjs +6 -2
  36. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  37. package/dist/features/row-sorting/createSortedRowModel.d.cts +6 -2
  38. package/dist/features/row-sorting/createSortedRowModel.d.ts +6 -2
  39. package/dist/features/row-sorting/createSortedRowModel.js +6 -2
  40. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  41. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +31 -2
  42. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +31 -2
  43. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +19 -4
  44. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  45. package/dist/features/row-sorting/rowSortingFeature.utils.js +19 -4
  46. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  47. package/dist/fns/aggregationFns.cjs +128 -57
  48. package/dist/fns/aggregationFns.cjs.map +1 -1
  49. package/dist/fns/aggregationFns.d.cts +72 -18
  50. package/dist/fns/aggregationFns.d.ts +72 -18
  51. package/dist/fns/aggregationFns.js +126 -58
  52. package/dist/fns/aggregationFns.js.map +1 -1
  53. package/dist/fns/filterFns.cjs +254 -97
  54. package/dist/fns/filterFns.cjs.map +1 -1
  55. package/dist/fns/filterFns.d.cts +126 -94
  56. package/dist/fns/filterFns.d.ts +126 -94
  57. package/dist/fns/filterFns.js +247 -98
  58. package/dist/fns/filterFns.js.map +1 -1
  59. package/dist/fns/sortFns.cjs +68 -21
  60. package/dist/fns/sortFns.cjs.map +1 -1
  61. package/dist/fns/sortFns.d.cts +48 -15
  62. package/dist/fns/sortFns.d.ts +48 -15
  63. package/dist/fns/sortFns.js +68 -22
  64. package/dist/fns/sortFns.js.map +1 -1
  65. package/dist/helpers/tableFeatures.cjs +5 -4
  66. package/dist/helpers/tableFeatures.cjs.map +1 -1
  67. package/dist/helpers/tableFeatures.d.cts +5 -4
  68. package/dist/helpers/tableFeatures.d.ts +5 -4
  69. package/dist/helpers/tableFeatures.js +5 -4
  70. package/dist/helpers/tableFeatures.js.map +1 -1
  71. package/dist/index.cjs +12 -0
  72. package/dist/index.d.cts +8 -8
  73. package/dist/index.d.ts +8 -8
  74. package/dist/index.js +4 -4
  75. package/dist/types/TableFeatures.d.cts +15 -7
  76. package/dist/types/TableFeatures.d.ts +15 -7
  77. package/dist/types/type-utils.d.cts +8 -1
  78. package/dist/types/type-utils.d.ts +8 -1
  79. package/package.json +1 -1
  80. package/skills/api-not-found/SKILL.md +1 -1
  81. package/skills/client-vs-server/SKILL.md +1 -1
  82. package/skills/column-faceting/SKILL.md +11 -5
  83. package/skills/column-filtering/SKILL.md +8 -3
  84. package/skills/column-ordering/SKILL.md +1 -1
  85. package/skills/column-pinning/SKILL.md +1 -1
  86. package/skills/column-resizing/SKILL.md +1 -1
  87. package/skills/column-sizing/SKILL.md +1 -1
  88. package/skills/column-visibility/SKILL.md +1 -1
  89. package/skills/core/SKILL.md +1 -1
  90. package/skills/custom-features/SKILL.md +1 -1
  91. package/skills/expanding/SKILL.md +1 -1
  92. package/skills/global-filtering/SKILL.md +3 -3
  93. package/skills/grouping/SKILL.md +8 -3
  94. package/skills/migrate-v8-to-v9/SKILL.md +7 -7
  95. package/skills/pagination/SKILL.md +1 -1
  96. package/skills/row-pinning/SKILL.md +1 -1
  97. package/skills/row-selection/SKILL.md +1 -1
  98. package/skills/sorting/SKILL.md +9 -3
  99. package/skills/table-features/SKILL.md +16 -13
  100. package/skills/typescript/SKILL.md +1 -1
  101. package/src/features/column-filtering/columnFilteringFeature.types.ts +60 -0
  102. package/src/features/column-filtering/columnFilteringFeature.utils.ts +33 -19
  103. package/src/features/column-filtering/createFilteredRowModel.ts +13 -3
  104. package/src/features/column-grouping/columnGroupingFeature.types.ts +63 -8
  105. package/src/features/column-grouping/columnGroupingFeature.utils.ts +43 -9
  106. package/src/features/column-grouping/createGroupedRowModel.ts +6 -3
  107. package/src/features/global-filtering/globalFilteringFeature.utils.ts +8 -0
  108. package/src/features/row-sorting/createSortedRowModel.ts +6 -2
  109. package/src/features/row-sorting/rowSortingFeature.types.ts +53 -1
  110. package/src/features/row-sorting/rowSortingFeature.utils.ts +45 -13
  111. package/src/fns/aggregationFns.ts +204 -146
  112. package/src/fns/filterFns.ts +361 -280
  113. package/src/fns/sortFns.ts +95 -78
  114. package/src/helpers/tableFeatures.ts +5 -4
  115. package/src/types/TableFeatures.ts +15 -7
  116. package/src/types/type-utils.ts +8 -0
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -23,17 +23,22 @@ This skill builds on `core`, `table-features`, and `client-vs-server`. Filtering
23
23
  import {
24
24
  columnFilteringFeature,
25
25
  createFilteredRowModel,
26
- filterFns,
26
+ filterFn_includesString,
27
27
  tableFeatures,
28
28
  } from '@tanstack/table-core'
29
29
 
30
30
  export const features = tableFeatures({
31
31
  columnFilteringFeature,
32
32
  filteredRowModel: createFilteredRowModel(),
33
- filterFns,
33
+ filterFns: { includesString: filterFn_includesString },
34
34
  })
35
35
  ```
36
36
 
37
+ Import individual `filterFn_*` built-ins and register only those your columns
38
+ reference by string name or that `filterFn: 'auto'` should resolve for your
39
+ data types. The full `filterFns` registry object still works but bundles every
40
+ built-in.
41
+
37
42
  ## Core Patterns
38
43
 
39
44
  ```ts
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'column-sizing']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'column-sizing']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: core
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.45'
8
+ library_version: '9.0.0-beta.47'
9
9
  sources:
10
10
  - 'TanStack/table:docs/overview.md'
11
11
  - 'TanStack/table:docs/guide/tables.md'
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.45'
8
+ library_version: '9.0.0-beta.47'
9
9
  requires: ['core', 'table-features', 'typescript']
10
10
  sources:
11
11
  - 'TanStack/table:docs/framework/react/guide/custom-features.md'
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server', 'column-filtering']
12
12
  sources:
@@ -23,7 +23,7 @@ This skill builds on `core`, `table-features`, `client-vs-server`, and `column-f
23
23
  import {
24
24
  columnFilteringFeature,
25
25
  createFilteredRowModel,
26
- filterFns,
26
+ filterFn_includesString,
27
27
  globalFilteringFeature,
28
28
  tableFeatures,
29
29
  } from '@tanstack/table-core'
@@ -32,7 +32,7 @@ export const features = tableFeatures({
32
32
  columnFilteringFeature,
33
33
  globalFilteringFeature,
34
34
  filteredRowModel: createFilteredRowModel(),
35
- filterFns,
35
+ filterFns: { includesString: filterFn_includesString },
36
36
  })
37
37
  ```
38
38
 
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -21,7 +21,7 @@ This skill builds on `core`, `table-features`, and `client-vs-server`. Grouping
21
21
 
22
22
  ```ts
23
23
  import {
24
- aggregationFns,
24
+ aggregationFn_sum,
25
25
  columnGroupingFeature,
26
26
  createGroupedRowModel,
27
27
  tableFeatures,
@@ -30,10 +30,15 @@ import {
30
30
  export const features = tableFeatures({
31
31
  columnGroupingFeature,
32
32
  groupedRowModel: createGroupedRowModel(),
33
- aggregationFns,
33
+ aggregationFns: { sum: aggregationFn_sum },
34
34
  })
35
35
  ```
36
36
 
37
+ Import individual `aggregationFn_*` built-ins and register only those your
38
+ columns reference by string name or that `aggregationFn: 'auto'` should
39
+ resolve (numbers resolve to `sum`, dates to `extent`). The full
40
+ `aggregationFns` registry object still works but bundles every built-in.
41
+
37
42
  ## Core Patterns
38
43
 
39
44
  ```ts
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: lifecycle
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.45'
8
+ library_version: '9.0.0-beta.47'
9
9
  requires: ['core', 'table-features', 'typescript']
10
10
  sources:
11
11
  - 'TanStack/table:docs/framework/react/guide/migrating.md'
@@ -42,9 +42,9 @@ import {
42
42
  createFilteredRowModel,
43
43
  createSortedRowModel,
44
44
  columnFilteringFeature,
45
- filterFns,
45
+ filterFn_includesString,
46
46
  rowSortingFeature,
47
- sortFns,
47
+ sortFn_alphanumeric,
48
48
  tableFeatures,
49
49
  } from '@tanstack/table-core'
50
50
 
@@ -53,8 +53,8 @@ export const features = tableFeatures({
53
53
  rowSortingFeature,
54
54
  filteredRowModel: createFilteredRowModel(),
55
55
  sortedRowModel: createSortedRowModel(),
56
- filterFns,
57
- sortFns,
56
+ filterFns: { includesString: filterFn_includesString },
57
+ sortFns: { alphanumeric: sortFn_alphanumeric },
58
58
  })
59
59
  ```
60
60
 
@@ -118,7 +118,7 @@ Move registries from table options or factory arguments into these feature slots
118
118
  | `filterFns` | `filterFns` |
119
119
  | `aggregationFns` | `aggregationFns` |
120
120
 
121
- Register built-ins only when needed, or spread them with custom functions. A slot's keys become the valid string names in column definitions.
121
+ Register only the built-ins the table references by string name, importing each individually (`filterFn_includesString`, `sortFn_alphanumeric`, `aggregationFn_sum`, and so on) alongside any custom functions. The full registry objects (`filterFns`, `sortFns`, `aggregationFns` exports) still work but bundle every built-in. A slot's keys become the valid string names in column definitions, and `'auto'` resolves only registered functions.
122
122
 
123
123
  ### 3. Migrate state reads and whole-state observation
124
124
 
@@ -279,7 +279,7 @@ Do not confuse new capabilities with required breakages. After the table works,
279
279
  - [ ] Remove `getCoreRowModel()` unless supplying a deliberate custom `coreRowModel` slot.
280
280
  - [ ] Move all remaining `get*RowModel()` options or earlier-beta `rowModels` entries to `create*RowModel()` feature slots.
281
281
  - [ ] Register each dependent feature before its row-model slot.
282
- - [ ] Move `filterFns`, `sortingFns`/`sortFns`, and `aggregationFns` into feature slots; pass no registries to factories.
282
+ - [ ] Move `filterFns`, `sortingFns`/`sortFns`, and `aggregationFns` into feature slots, registering individually imported built-ins; pass no registries to factories.
283
283
  - [ ] Register `columnFilteringFeature` before global filtering and filter/facet dependencies.
284
284
  - [ ] Register `columnSizingFeature` before `columnResizingFeature`.
285
285
  - [ ] Replace `table.getState()` and top-level `onStateChange` according to the adapter state guide.
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features']
12
12
  sources:
@@ -6,7 +6,7 @@ metadata:
6
6
  {
7
7
  type: sub-skill,
8
8
  library: '@tanstack/table-core',
9
- library_version: '9.0.0-beta.45',
9
+ library_version: '9.0.0-beta.47',
10
10
  }
11
11
  requires: ['core', 'table-features', 'client-vs-server']
12
12
  sources:
@@ -23,17 +23,23 @@ This skill builds on `core`, `table-features`, and `client-vs-server`. Sorting s
23
23
  import {
24
24
  createSortedRowModel,
25
25
  rowSortingFeature,
26
- sortFns,
26
+ sortFn_alphanumeric,
27
+ sortFn_text,
27
28
  tableFeatures,
28
29
  } from '@tanstack/table-core'
29
30
 
30
31
  export const features = tableFeatures({
31
32
  rowSortingFeature,
32
33
  sortedRowModel: createSortedRowModel(),
33
- sortFns,
34
+ sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text },
34
35
  })
35
36
  ```
36
37
 
38
+ Import individual `sortFn_*` built-ins and register only those your columns
39
+ reference by string name or that `sortFn: 'auto'` should resolve for your data
40
+ types. The full `sortFns` registry object still works but bundles every
41
+ built-in; numeric columns fall back to a basic comparator without registration.
42
+
37
43
  ## Core Patterns
38
44
 
39
45
  ```ts
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.45'
8
+ library_version: '9.0.0-beta.47'
9
9
  requires: ['core']
10
10
  sources:
11
11
  - 'TanStack/table:docs/guide/row-models.md'
@@ -22,26 +22,26 @@ This skill builds on `core`. Read it first for the headless model and stable inp
22
22
 
23
23
  ```ts
24
24
  import {
25
- aggregationFns,
25
+ aggregationFn_sum,
26
26
  columnGroupingFeature,
27
27
  createFilteredRowModel,
28
28
  createSortedRowModel,
29
29
  columnFilteringFeature,
30
- filterFns,
30
+ filterFn_includesString,
31
31
  rowSortingFeature,
32
- sortFns,
32
+ sortFn_alphanumeric,
33
33
  tableFeatures,
34
34
  } from '@tanstack/table-core'
35
35
 
36
36
  export const features = tableFeatures({
37
37
  columnFilteringFeature,
38
38
  filteredRowModel: createFilteredRowModel(),
39
- filterFns,
39
+ filterFns: { includesString: filterFn_includesString },
40
40
  columnGroupingFeature,
41
- aggregationFns,
41
+ aggregationFns: { sum: aggregationFn_sum },
42
42
  rowSortingFeature,
43
43
  sortedRowModel: createSortedRowModel(),
44
- sortFns,
44
+ sortFns: { alphanumeric: sortFn_alphanumeric },
45
45
  })
46
46
  ```
47
47
 
@@ -63,19 +63,22 @@ const features = tableFeatures({
63
63
  ```ts
64
64
  const features = tableFeatures({
65
65
  columnFilteringFeature,
66
- filterFns,
66
+ filterFns: { includesString: filterFn_includesString },
67
67
  rowSortingFeature,
68
- sortFns,
68
+ sortFns: { alphanumeric: sortFn_alphanumeric },
69
69
  columnGroupingFeature,
70
- aggregationFns,
70
+ aggregationFns: { sum: aggregationFn_sum },
71
71
  })
72
72
  ```
73
73
 
74
74
  `filterFns`, `sortFns`, and `aggregationFns` are feature slots, not table
75
75
  options. They respectively require `columnFilteringFeature`,
76
- `rowSortingFeature`, and `columnGroupingFeature`. A registered key can be used
77
- as a typed string name; pass a function directly when no registry name is
78
- needed.
76
+ `rowSortingFeature`, and `columnGroupingFeature`. Import individual built-ins
77
+ (`filterFn_*`, `sortFn_*`, `aggregationFn_*`) and register them under their
78
+ conventional keys; the full registry objects (`filterFns`, `sortFns`,
79
+ `aggregationFns` exports) still work but bundle every built-in. A registered
80
+ key can be used as a typed string name, and `'auto'` resolves only registered
81
+ functions; pass a function directly when no registry name is needed.
79
82
 
80
83
  ### Prefer explicit features
81
84
 
@@ -5,7 +5,7 @@ description: >
5
5
  metadata:
6
6
  type: sub-skill
7
7
  library: '@tanstack/table-core'
8
- library_version: '9.0.0-beta.45'
8
+ library_version: '9.0.0-beta.47'
9
9
  requires: ['core', 'table-features']
10
10
  sources:
11
11
  - 'TanStack/table:docs/guide/helpers.md'
@@ -3,6 +3,7 @@ import type {
3
3
  CellData,
4
4
  OnChangeFn,
5
5
  RowData,
6
+ TransformDataValueFn,
6
7
  Updater,
7
8
  } from '../../types/type-utils'
8
9
  import type { IsAny, TableFeatures } from '../../types/TableFeatures'
@@ -66,8 +67,67 @@ export interface FilterFn<
66
67
  filterValue: any,
67
68
  addMeta?: (meta: ExtractFilterMeta<TFeatures>) => void,
68
69
  ): boolean
70
+ /**
71
+ * Removes the filter from `state.columnFilters` when the filter value fails
72
+ * this test (e.g. empty strings for text filters).
73
+ */
69
74
  autoRemove?: ColumnFilterAutoRemoveTestFn<TFeatures, TData>
75
+ /**
76
+ * Normalizes the filter value before filtering runs.
77
+ *
78
+ * The table applies this once per filter (not per row) and passes the
79
+ * resolved value to the filter function as `filterValue`.
80
+ */
70
81
  resolveFilterValue?: TransformFilterValueFn<TFeatures, TData>
82
+ /**
83
+ * Normalizes each row's value before it is compared against the filter
84
+ * value. Only honored by filter functions built with `constructFilterFn`
85
+ * (including all built-in filter functions).
86
+ */
87
+ resolveDataValue?: TransformDataValueFn
88
+ }
89
+
90
+ /**
91
+ * The definition object accepted by `constructFilterFn`.
92
+ *
93
+ * `filter` is a value-level comparator: it receives the row's (resolved) data
94
+ * value and the (resolved) filter value instead of the whole row, so
95
+ * normalization concerns stay in `resolveDataValue`/`resolveFilterValue`.
96
+ */
97
+ export interface FilterFnDef<
98
+ in out TFeatures extends TableFeatures,
99
+ in out TData extends RowData,
100
+ > {
101
+ filter: (
102
+ dataValue: any,
103
+ filterValue: any,
104
+ row: Row<TFeatures, TData>,
105
+ columnId: string,
106
+ addMeta?: (meta: ExtractFilterMeta<TFeatures>) => void,
107
+ ) => boolean
108
+ autoRemove?: (filterValue: any) => boolean
109
+ resolveFilterValue?: (filterValue: any) => any
110
+ resolveDataValue?: TransformDataValueFn
111
+ }
112
+
113
+ /**
114
+ * The shape returned by `constructFilterFn`: a `FilterFn` with its definition
115
+ * attached, so variants can be built by spreading it into another
116
+ * `constructFilterFn` call.
117
+ *
118
+ * The call signature is generic so a created filter function can be used with
119
+ * any table's rows, regardless of the feature set it was defined against.
120
+ */
121
+ export interface CreatedFilterFn<
122
+ in out TFeatures extends TableFeatures,
123
+ in out TData extends RowData,
124
+ > extends FilterFnDef<TFeatures, TData> {
125
+ <TRowFeatures extends TableFeatures, TRowData extends RowData>(
126
+ row: Row<TRowFeatures, TRowData>,
127
+ columnId: string,
128
+ filterValue: any,
129
+ addMeta?: (meta: ExtractFilterMeta<TRowFeatures>) => void,
130
+ ): boolean
71
131
  }
72
132
 
73
133
  export type TransformFilterValueFn<
@@ -27,8 +27,12 @@ export function getDefaultColumnFiltersState(): ColumnFiltersState {
27
27
  * Chooses a built-in filter function from the column's first core row value.
28
28
  *
29
29
  * Strings use `includesString`, numbers use `inNumberRange`, booleans and
30
- * objects use `equals`, arrays use `arrIncludes`, and unknown values fall back
31
- * to `weakEquals`.
30
+ * objects use `equals`, dates use `inDateRange`, arrays use `arrIncludes`,
31
+ * and unknown values fall back to `weakEquals`.
32
+ *
33
+ * The chosen filter function is looked up in the table's `filterFns`
34
+ * registry. When it is not registered there, this returns `undefined` and
35
+ * warns in development instead of substituting a different filter function.
32
36
  *
33
37
  * @example
34
38
  * ```ts
@@ -47,27 +51,33 @@ export function column_getAutoFilterFn<
47
51
 
48
52
  const value = firstRow ? firstRow.getValue(column.id) : undefined
49
53
 
50
- if (typeof value === 'string') {
51
- return filterFns?.includesString
52
- }
54
+ let filterFnName: string
53
55
 
54
- if (typeof value === 'number') {
55
- return filterFns?.inNumberRange
56
+ if (typeof value === 'string') {
57
+ filterFnName = 'includesString'
58
+ } else if (typeof value === 'number') {
59
+ filterFnName = 'inNumberRange'
60
+ } else if (typeof value === 'boolean') {
61
+ filterFnName = 'equals'
62
+ } else if (Array.isArray(value)) {
63
+ filterFnName = 'arrIncludes'
64
+ } else if (Object.prototype.toString.call(value) === '[object Date]') {
65
+ filterFnName = 'inDateRange'
66
+ } else if (value !== null && typeof value === 'object') {
67
+ filterFnName = 'equals'
68
+ } else {
69
+ filterFnName = 'weakEquals'
56
70
  }
57
71
 
58
- if (typeof value === 'boolean') {
59
- return filterFns?.equals
60
- }
72
+ const filterFn = filterFns?.[filterFnName]
61
73
 
62
- if (Array.isArray(value)) {
63
- return filterFns?.arrIncludes
64
- }
65
-
66
- if (value !== null && typeof value === 'object') {
67
- return filterFns?.equals
74
+ if (process.env.NODE_ENV === 'development' && !filterFn) {
75
+ console.warn(
76
+ `filterFn '${filterFnName}' (auto) for column '${column.id}' is not registered`,
77
+ )
68
78
  }
69
79
 
70
- return filterFns?.weakEquals
80
+ return filterFn
71
81
  }
72
82
 
73
83
  /**
@@ -98,9 +108,13 @@ export function column_getFilterFn<
98
108
  ? column_getAutoFilterFn(column)
99
109
  : filterFns?.[column.columnDef.filterFn as string]
100
110
 
101
- if (process.env.NODE_ENV === 'development' && !filterFn) {
111
+ if (
112
+ process.env.NODE_ENV === 'development' &&
113
+ !filterFn &&
114
+ column.columnDef.filterFn !== 'auto' // the auto picker warns on its own
115
+ ) {
102
116
  console.warn(
103
- `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,
117
+ `filterFn '${String(column.columnDef.filterFn)}' for column '${column.id}' is not registered`,
104
118
  )
105
119
  }
106
120
 
@@ -22,8 +22,12 @@ import type {
22
22
  *
23
23
  * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.
24
24
  *
25
- * Register filter functions with the `filterFns` slot on the `features` option:
26
- * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns })`.
25
+ * Register the filter functions you use with the `filterFns` slot on the
26
+ * `features` option:
27
+ * `tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), filterFns: { includesString: filterFn_includesString } })`.
28
+ * Importing individual `filterFn_*` functions keeps unused built-ins out of
29
+ * your bundle; filter functions passed directly to the `filterFn` column
30
+ * option need no registration at all.
27
31
  */
28
32
  export function createFilteredRowModel<
29
33
  TFeatures extends TableFeatures,
@@ -78,7 +82,13 @@ function _createFilteredRowModel<
78
82
  return
79
83
  }
80
84
 
81
- const filterFn = column_getFilterFn(column)!
85
+ const filterFn = column_getFilterFn(column)
86
+
87
+ // A dev warning has already fired in column_getFilterFn; ignore the
88
+ // filter instead of crashing when its filter fn is not registered.
89
+ if (!filterFn) {
90
+ return
91
+ }
82
92
 
83
93
  resolvedColumnFilters.push({
84
94
  id: columnFilter.id,
@@ -4,6 +4,7 @@ import type {
4
4
  CellData,
5
5
  OnChangeFn,
6
6
  RowData,
7
+ TransformDataValueFn,
7
8
  Updater,
8
9
  } from '../../types/type-utils'
9
10
  import type { IsAny, TableFeatures } from '../../types/TableFeatures'
@@ -26,14 +27,68 @@ export interface RowModelFns_ColumnGrouping<
26
27
 
27
28
  export interface AggregationFns {}
28
29
 
29
- export type AggregationFn<
30
- TFeatures extends TableFeatures,
31
- TData extends RowData,
32
- > = (
33
- columnId: string,
34
- leafRows: Array<Row<TFeatures, TData>>,
35
- childRows: Array<Row<TFeatures, TData>>,
36
- ) => any
30
+ export interface AggregationFn<
31
+ in out TFeatures extends TableFeatures,
32
+ in out TData extends RowData,
33
+ > {
34
+ (
35
+ columnId: string,
36
+ leafRows: Array<Row<TFeatures, TData>>,
37
+ childRows: Array<Row<TFeatures, TData>>,
38
+ ): any
39
+ /**
40
+ * Normalizes each row's value before it is aggregated. Only honored by
41
+ * aggregation functions built with `constructAggregationFn` (including the
42
+ * value-based built-in aggregation functions).
43
+ */
44
+ resolveDataValue?: TransformDataValueFn
45
+ }
46
+
47
+ /**
48
+ * The definition object accepted by `constructAggregationFn`.
49
+ *
50
+ * `aggregate` is a value-level reducer: it receives the rows' (resolved)
51
+ * values instead of the rows themselves, so normalization concerns stay in
52
+ * `resolveDataValue`.
53
+ */
54
+ export interface AggregationFnDef<
55
+ in out TFeatures extends TableFeatures,
56
+ in out TData extends RowData,
57
+ > {
58
+ aggregate: (
59
+ values: Array<any>,
60
+ rows: Array<Row<TFeatures, TData>>,
61
+ columnId: string,
62
+ ) => any
63
+ /**
64
+ * Which of the group's rows feed the aggregation: all of its `leafRows`
65
+ * (the default) or its immediate `childRows`. For nested groups, child rows
66
+ * expose already-aggregated values, which is faster for reaggregatable
67
+ * computations like sums and extents.
68
+ */
69
+ fromRows?: 'leafRows' | 'childRows'
70
+ resolveDataValue?: TransformDataValueFn
71
+ }
72
+
73
+ /**
74
+ * The shape returned by `constructAggregationFn`: an `AggregationFn` with its
75
+ * definition attached, so variants can be built by spreading it into another
76
+ * `constructAggregationFn` call.
77
+ *
78
+ * The call signature is generic so a created aggregation function can be used
79
+ * with any table's rows, regardless of the feature set it was defined
80
+ * against.
81
+ */
82
+ export interface CreatedAggregationFn<
83
+ in out TFeatures extends TableFeatures,
84
+ in out TData extends RowData,
85
+ > extends AggregationFnDef<TFeatures, TData> {
86
+ <TRowFeatures extends TableFeatures, TRowData extends RowData>(
87
+ columnId: string,
88
+ leafRows: Array<Row<TRowFeatures, TRowData>>,
89
+ childRows: Array<Row<TRowFeatures, TRowData>>,
90
+ ): any
91
+ }
37
92
 
38
93
  export type CustomAggregationFns<
39
94
  TFeatures extends TableFeatures,