@tanstack/table-core 9.0.0-alpha.46 → 9.0.0-alpha.48

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 (339) hide show
  1. package/README.md +10 -0
  2. package/dist/core/cells/constructCell.cjs +4 -3
  3. package/dist/core/cells/constructCell.cjs.map +1 -1
  4. package/dist/core/cells/constructCell.js +4 -3
  5. package/dist/core/cells/constructCell.js.map +1 -1
  6. package/dist/core/cells/coreCellsFeature.utils.cjs +11 -8
  7. package/dist/core/cells/coreCellsFeature.utils.cjs.map +1 -1
  8. package/dist/core/cells/coreCellsFeature.utils.d.cts +11 -8
  9. package/dist/core/cells/coreCellsFeature.utils.d.ts +11 -8
  10. package/dist/core/cells/coreCellsFeature.utils.js +11 -8
  11. package/dist/core/cells/coreCellsFeature.utils.js.map +1 -1
  12. package/dist/core/columns/constructColumn.cjs +6 -4
  13. package/dist/core/columns/constructColumn.cjs.map +1 -1
  14. package/dist/core/columns/constructColumn.js +6 -4
  15. package/dist/core/columns/constructColumn.js.map +1 -1
  16. package/dist/core/columns/coreColumnsFeature.types.d.cts +7 -6
  17. package/dist/core/columns/coreColumnsFeature.types.d.ts +7 -6
  18. package/dist/core/columns/coreColumnsFeature.utils.cjs +47 -29
  19. package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
  20. package/dist/core/columns/coreColumnsFeature.utils.d.cts +37 -27
  21. package/dist/core/columns/coreColumnsFeature.utils.d.ts +37 -27
  22. package/dist/core/columns/coreColumnsFeature.utils.js +47 -29
  23. package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
  24. package/dist/core/headers/buildHeaderGroups.cjs +27 -19
  25. package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
  26. package/dist/core/headers/buildHeaderGroups.js +27 -19
  27. package/dist/core/headers/buildHeaderGroups.js.map +1 -1
  28. package/dist/core/headers/constructHeader.cjs +4 -3
  29. package/dist/core/headers/constructHeader.cjs.map +1 -1
  30. package/dist/core/headers/constructHeader.js +4 -3
  31. package/dist/core/headers/constructHeader.js.map +1 -1
  32. package/dist/core/headers/coreHeadersFeature.cjs +1 -6
  33. package/dist/core/headers/coreHeadersFeature.cjs.map +1 -1
  34. package/dist/core/headers/coreHeadersFeature.js +2 -7
  35. package/dist/core/headers/coreHeadersFeature.js.map +1 -1
  36. package/dist/core/headers/coreHeadersFeature.types.d.cts +6 -4
  37. package/dist/core/headers/coreHeadersFeature.types.d.ts +6 -4
  38. package/dist/core/headers/coreHeadersFeature.utils.cjs +43 -36
  39. package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
  40. package/dist/core/headers/coreHeadersFeature.utils.d.cts +24 -19
  41. package/dist/core/headers/coreHeadersFeature.utils.d.ts +24 -19
  42. package/dist/core/headers/coreHeadersFeature.utils.js +44 -37
  43. package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
  44. package/dist/core/reactivity/coreReactivityFeature.types.d.cts +4 -0
  45. package/dist/core/reactivity/coreReactivityFeature.types.d.ts +4 -0
  46. package/dist/core/row-models/coreRowModelsFeature.utils.cjs +48 -36
  47. package/dist/core/row-models/coreRowModelsFeature.utils.cjs.map +1 -1
  48. package/dist/core/row-models/coreRowModelsFeature.utils.d.cts +48 -36
  49. package/dist/core/row-models/coreRowModelsFeature.utils.d.ts +48 -36
  50. package/dist/core/row-models/coreRowModelsFeature.utils.js +48 -36
  51. package/dist/core/row-models/coreRowModelsFeature.utils.js.map +1 -1
  52. package/dist/core/rows/constructRow.cjs +8 -6
  53. package/dist/core/rows/constructRow.cjs.map +1 -1
  54. package/dist/core/rows/constructRow.js +8 -6
  55. package/dist/core/rows/constructRow.js.map +1 -1
  56. package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
  57. package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
  58. package/dist/core/rows/coreRowsFeature.utils.cjs +43 -32
  59. package/dist/core/rows/coreRowsFeature.utils.cjs.map +1 -1
  60. package/dist/core/rows/coreRowsFeature.utils.d.cts +34 -28
  61. package/dist/core/rows/coreRowsFeature.utils.d.ts +34 -28
  62. package/dist/core/rows/coreRowsFeature.utils.js +43 -32
  63. package/dist/core/rows/coreRowsFeature.utils.js.map +1 -1
  64. package/dist/core/table/constructTable.cjs +9 -5
  65. package/dist/core/table/constructTable.cjs.map +1 -1
  66. package/dist/core/table/constructTable.js +9 -5
  67. package/dist/core/table/constructTable.js.map +1 -1
  68. package/dist/core/table/coreTablesFeature.types.d.cts +6 -2
  69. package/dist/core/table/coreTablesFeature.types.d.ts +6 -2
  70. package/dist/core/table/coreTablesFeature.utils.cjs +7 -3
  71. package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
  72. package/dist/core/table/coreTablesFeature.utils.d.cts +2 -2
  73. package/dist/core/table/coreTablesFeature.utils.d.ts +2 -2
  74. package/dist/core/table/coreTablesFeature.utils.js +7 -3
  75. package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
  76. package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +16 -10
  77. package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +16 -10
  78. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs +26 -18
  79. package/dist/features/column-faceting/columnFacetingFeature.utils.cjs.map +1 -1
  80. package/dist/features/column-faceting/columnFacetingFeature.utils.d.cts +26 -18
  81. package/dist/features/column-faceting/columnFacetingFeature.utils.d.ts +26 -18
  82. package/dist/features/column-faceting/columnFacetingFeature.utils.js +26 -18
  83. package/dist/features/column-faceting/columnFacetingFeature.utils.js.map +1 -1
  84. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs +8 -5
  85. package/dist/features/column-faceting/createFacetedMinMaxValues.cjs.map +1 -1
  86. package/dist/features/column-faceting/createFacetedMinMaxValues.js +8 -5
  87. package/dist/features/column-faceting/createFacetedMinMaxValues.js.map +1 -1
  88. package/dist/features/column-faceting/createFacetedRowModel.cjs +8 -3
  89. package/dist/features/column-faceting/createFacetedRowModel.cjs.map +1 -1
  90. package/dist/features/column-faceting/createFacetedRowModel.js +8 -3
  91. package/dist/features/column-faceting/createFacetedRowModel.js.map +1 -1
  92. package/dist/features/column-faceting/createFacetedUniqueValues.cjs +7 -4
  93. package/dist/features/column-faceting/createFacetedUniqueValues.cjs.map +1 -1
  94. package/dist/features/column-faceting/createFacetedUniqueValues.js +7 -4
  95. package/dist/features/column-faceting/createFacetedUniqueValues.js.map +1 -1
  96. package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +21 -11
  97. package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +21 -11
  98. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs +39 -28
  99. package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
  100. package/dist/features/column-filtering/columnFilteringFeature.utils.d.cts +39 -28
  101. package/dist/features/column-filtering/columnFilteringFeature.utils.d.ts +39 -28
  102. package/dist/features/column-filtering/columnFilteringFeature.utils.js +39 -28
  103. package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
  104. package/dist/features/column-filtering/createFilteredRowModel.cjs +11 -5
  105. package/dist/features/column-filtering/createFilteredRowModel.cjs.map +1 -1
  106. package/dist/features/column-filtering/createFilteredRowModel.js +11 -5
  107. package/dist/features/column-filtering/createFilteredRowModel.js.map +1 -1
  108. package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +18 -14
  109. package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +18 -14
  110. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs +55 -43
  111. package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
  112. package/dist/features/column-grouping/columnGroupingFeature.utils.d.cts +55 -43
  113. package/dist/features/column-grouping/columnGroupingFeature.utils.d.ts +55 -43
  114. package/dist/features/column-grouping/columnGroupingFeature.utils.js +55 -43
  115. package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
  116. package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +14 -5
  117. package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +14 -5
  118. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +46 -29
  119. package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
  120. package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +30 -23
  121. package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +30 -23
  122. package/dist/features/column-ordering/columnOrderingFeature.utils.js +46 -29
  123. package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
  124. package/dist/features/column-pinning/columnPinningFeature.types.d.cts +43 -31
  125. package/dist/features/column-pinning/columnPinningFeature.types.d.ts +43 -31
  126. package/dist/features/column-pinning/columnPinningFeature.utils.cjs +152 -115
  127. package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
  128. package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +116 -95
  129. package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +116 -95
  130. package/dist/features/column-pinning/columnPinningFeature.utils.js +153 -116
  131. package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
  132. package/dist/features/column-resizing/columnResizingFeature.types.d.cts +9 -9
  133. package/dist/features/column-resizing/columnResizingFeature.types.d.ts +9 -9
  134. package/dist/features/column-resizing/columnResizingFeature.utils.cjs +28 -19
  135. package/dist/features/column-resizing/columnResizingFeature.utils.cjs.map +1 -1
  136. package/dist/features/column-resizing/columnResizingFeature.utils.d.cts +28 -19
  137. package/dist/features/column-resizing/columnResizingFeature.utils.d.ts +28 -19
  138. package/dist/features/column-resizing/columnResizingFeature.utils.js +28 -19
  139. package/dist/features/column-resizing/columnResizingFeature.utils.js.map +1 -1
  140. package/dist/features/column-sizing/columnSizingFeature.cjs +28 -4
  141. package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
  142. package/dist/features/column-sizing/columnSizingFeature.js +28 -4
  143. package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
  144. package/dist/features/column-sizing/columnSizingFeature.types.d.cts +19 -12
  145. package/dist/features/column-sizing/columnSizingFeature.types.d.ts +19 -12
  146. package/dist/features/column-sizing/columnSizingFeature.utils.cjs +52 -41
  147. package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
  148. package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +52 -41
  149. package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +52 -41
  150. package/dist/features/column-sizing/columnSizingFeature.utils.js +52 -41
  151. package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
  152. package/dist/features/column-visibility/columnVisibilityFeature.cjs +23 -14
  153. package/dist/features/column-visibility/columnVisibilityFeature.cjs.map +1 -1
  154. package/dist/features/column-visibility/columnVisibilityFeature.js +24 -15
  155. package/dist/features/column-visibility/columnVisibilityFeature.js.map +1 -1
  156. package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +19 -12
  157. package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +19 -12
  158. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +91 -52
  159. package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
  160. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +63 -40
  161. package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +63 -40
  162. package/dist/features/column-visibility/columnVisibilityFeature.utils.js +91 -53
  163. package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
  164. package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +10 -5
  165. package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +10 -5
  166. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs +20 -14
  167. package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
  168. package/dist/features/global-filtering/globalFilteringFeature.utils.d.cts +20 -14
  169. package/dist/features/global-filtering/globalFilteringFeature.utils.d.ts +20 -14
  170. package/dist/features/global-filtering/globalFilteringFeature.utils.js +20 -14
  171. package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
  172. package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +16 -15
  173. package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +16 -15
  174. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs +58 -43
  175. package/dist/features/row-expanding/rowExpandingFeature.utils.cjs.map +1 -1
  176. package/dist/features/row-expanding/rowExpandingFeature.utils.d.cts +56 -41
  177. package/dist/features/row-expanding/rowExpandingFeature.utils.d.ts +56 -41
  178. package/dist/features/row-expanding/rowExpandingFeature.utils.js +58 -43
  179. package/dist/features/row-expanding/rowExpandingFeature.utils.js.map +1 -1
  180. package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +19 -12
  181. package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +19 -12
  182. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs +49 -32
  183. package/dist/features/row-pagination/rowPaginationFeature.utils.cjs.map +1 -1
  184. package/dist/features/row-pagination/rowPaginationFeature.utils.d.cts +49 -32
  185. package/dist/features/row-pagination/rowPaginationFeature.utils.d.ts +49 -32
  186. package/dist/features/row-pagination/rowPaginationFeature.utils.js +49 -32
  187. package/dist/features/row-pagination/rowPaginationFeature.utils.js.map +1 -1
  188. package/dist/features/row-pinning/rowPinningFeature.types.d.cts +12 -8
  189. package/dist/features/row-pinning/rowPinningFeature.types.d.ts +12 -8
  190. package/dist/features/row-pinning/rowPinningFeature.utils.cjs +52 -36
  191. package/dist/features/row-pinning/rowPinningFeature.utils.cjs.map +1 -1
  192. package/dist/features/row-pinning/rowPinningFeature.utils.d.cts +39 -29
  193. package/dist/features/row-pinning/rowPinningFeature.utils.d.ts +39 -29
  194. package/dist/features/row-pinning/rowPinningFeature.utils.js +52 -36
  195. package/dist/features/row-pinning/rowPinningFeature.utils.js.map +1 -1
  196. package/dist/features/row-selection/rowSelectionFeature.types.d.cts +30 -24
  197. package/dist/features/row-selection/rowSelectionFeature.types.d.ts +30 -24
  198. package/dist/features/row-selection/rowSelectionFeature.utils.cjs +95 -72
  199. package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
  200. package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +89 -69
  201. package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +89 -69
  202. package/dist/features/row-selection/rowSelectionFeature.utils.js +95 -72
  203. package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
  204. package/dist/features/row-sorting/createSortedRowModel.cjs +13 -8
  205. package/dist/features/row-sorting/createSortedRowModel.cjs.map +1 -1
  206. package/dist/features/row-sorting/createSortedRowModel.js +13 -8
  207. package/dist/features/row-sorting/createSortedRowModel.js.map +1 -1
  208. package/dist/features/row-sorting/rowSortingFeature.types.d.cts +10 -8
  209. package/dist/features/row-sorting/rowSortingFeature.types.d.ts +10 -8
  210. package/dist/features/row-sorting/rowSortingFeature.utils.cjs +63 -46
  211. package/dist/features/row-sorting/rowSortingFeature.utils.cjs.map +1 -1
  212. package/dist/features/row-sorting/rowSortingFeature.utils.d.cts +61 -44
  213. package/dist/features/row-sorting/rowSortingFeature.utils.d.ts +61 -44
  214. package/dist/features/row-sorting/rowSortingFeature.utils.js +63 -46
  215. package/dist/features/row-sorting/rowSortingFeature.utils.js.map +1 -1
  216. package/dist/fns/aggregationFns.cjs +47 -16
  217. package/dist/fns/aggregationFns.cjs.map +1 -1
  218. package/dist/fns/aggregationFns.d.cts +33 -9
  219. package/dist/fns/aggregationFns.d.ts +33 -9
  220. package/dist/fns/aggregationFns.js +47 -17
  221. package/dist/fns/aggregationFns.js.map +1 -1
  222. package/dist/fns/filterFns.cjs +48 -17
  223. package/dist/fns/filterFns.cjs.map +1 -1
  224. package/dist/fns/filterFns.d.cts +42 -15
  225. package/dist/fns/filterFns.d.ts +42 -15
  226. package/dist/fns/filterFns.js +48 -17
  227. package/dist/fns/filterFns.js.map +1 -1
  228. package/dist/helpers/columnHelper.cjs +9 -4
  229. package/dist/helpers/columnHelper.cjs.map +1 -1
  230. package/dist/helpers/columnHelper.d.cts +9 -4
  231. package/dist/helpers/columnHelper.d.ts +9 -4
  232. package/dist/helpers/columnHelper.js +9 -4
  233. package/dist/helpers/columnHelper.js.map +1 -1
  234. package/dist/helpers/tableOptions.cjs.map +1 -1
  235. package/dist/helpers/tableOptions.d.cts +12 -9
  236. package/dist/helpers/tableOptions.d.ts +12 -9
  237. package/dist/helpers/tableOptions.js.map +1 -1
  238. package/dist/index.cjs +0 -4
  239. package/dist/index.d.cts +2 -2
  240. package/dist/index.d.ts +2 -2
  241. package/dist/index.js +2 -2
  242. package/dist/static-functions.cjs +1 -0
  243. package/dist/static-functions.d.cts +2 -2
  244. package/dist/static-functions.d.ts +2 -2
  245. package/dist/static-functions.js +2 -2
  246. package/dist/store-reactivity-bindings.cjs +1 -0
  247. package/dist/store-reactivity-bindings.cjs.map +1 -1
  248. package/dist/store-reactivity-bindings.js +1 -0
  249. package/dist/store-reactivity-bindings.js.map +1 -1
  250. package/dist/types/ColumnDef.d.cts +38 -0
  251. package/dist/types/ColumnDef.d.ts +38 -0
  252. package/dist/types/TableOptions.d.cts +15 -0
  253. package/dist/types/TableOptions.d.ts +15 -0
  254. package/dist/types/TableState.d.cts +12 -0
  255. package/dist/types/TableState.d.ts +12 -0
  256. package/dist/utils.cjs +18 -39
  257. package/dist/utils.cjs.map +1 -1
  258. package/dist/utils.d.cts +1 -23
  259. package/dist/utils.d.ts +1 -23
  260. package/dist/utils.js +19 -36
  261. package/dist/utils.js.map +1 -1
  262. package/package.json +5 -3
  263. package/skills/column-definitions/SKILL.md +333 -0
  264. package/skills/column-layout/SKILL.md +328 -0
  265. package/skills/column-layout/references/subsystems.md +220 -0
  266. package/skills/customizing-feature-behavior/SKILL.md +416 -0
  267. package/skills/filtering/SKILL.md +357 -0
  268. package/skills/filtering/references/faceting-and-fuzzy.md +191 -0
  269. package/skills/grouping/SKILL.md +448 -0
  270. package/skills/migrate-v8-to-v9/SKILL.md +495 -0
  271. package/skills/pagination/SKILL.md +385 -0
  272. package/skills/row-expanding/SKILL.md +348 -0
  273. package/skills/row-pinning/SKILL.md +269 -0
  274. package/skills/row-selection/SKILL.md +391 -0
  275. package/skills/setup/SKILL.md +400 -0
  276. package/skills/sorting/SKILL.md +344 -0
  277. package/skills/state-management/SKILL.md +388 -0
  278. package/src/core/cells/constructCell.ts +3 -2
  279. package/src/core/cells/coreCellsFeature.utils.ts +11 -8
  280. package/src/core/columns/constructColumn.ts +5 -3
  281. package/src/core/columns/coreColumnsFeature.types.ts +7 -6
  282. package/src/core/columns/coreColumnsFeature.utils.ts +43 -29
  283. package/src/core/headers/buildHeaderGroups.ts +29 -30
  284. package/src/core/headers/constructHeader.ts +3 -2
  285. package/src/core/headers/coreHeadersFeature.ts +2 -27
  286. package/src/core/headers/coreHeadersFeature.types.ts +6 -4
  287. package/src/core/headers/coreHeadersFeature.utils.ts +52 -61
  288. package/src/core/reactivity/coreReactivityFeature.types.ts +4 -0
  289. package/src/core/row-models/coreRowModelsFeature.utils.ts +48 -36
  290. package/src/core/rows/constructRow.ts +6 -4
  291. package/src/core/rows/coreRowsFeature.types.ts +4 -4
  292. package/src/core/rows/coreRowsFeature.utils.ts +45 -32
  293. package/src/core/table/constructTable.ts +6 -4
  294. package/src/core/table/coreTablesFeature.types.ts +6 -2
  295. package/src/core/table/coreTablesFeature.utils.ts +5 -3
  296. package/src/features/column-faceting/columnFacetingFeature.types.ts +16 -10
  297. package/src/features/column-faceting/columnFacetingFeature.utils.ts +26 -18
  298. package/src/features/column-faceting/createFacetedMinMaxValues.ts +8 -10
  299. package/src/features/column-faceting/createFacetedRowModel.ts +10 -6
  300. package/src/features/column-faceting/createFacetedUniqueValues.ts +4 -3
  301. package/src/features/column-filtering/columnFilteringFeature.types.ts +21 -11
  302. package/src/features/column-filtering/columnFilteringFeature.utils.ts +39 -28
  303. package/src/features/column-filtering/createFilteredRowModel.ts +14 -8
  304. package/src/features/column-grouping/columnGroupingFeature.types.ts +18 -14
  305. package/src/features/column-grouping/columnGroupingFeature.utils.ts +55 -43
  306. package/src/features/column-ordering/columnOrderingFeature.types.ts +14 -5
  307. package/src/features/column-ordering/columnOrderingFeature.utils.ts +44 -29
  308. package/src/features/column-pinning/columnPinningFeature.types.ts +43 -31
  309. package/src/features/column-pinning/columnPinningFeature.utils.ts +164 -128
  310. package/src/features/column-resizing/columnResizingFeature.types.ts +9 -9
  311. package/src/features/column-resizing/columnResizingFeature.utils.ts +28 -19
  312. package/src/features/column-sizing/columnSizingFeature.ts +16 -0
  313. package/src/features/column-sizing/columnSizingFeature.types.ts +19 -12
  314. package/src/features/column-sizing/columnSizingFeature.utils.ts +52 -41
  315. package/src/features/column-visibility/columnVisibilityFeature.ts +8 -0
  316. package/src/features/column-visibility/columnVisibilityFeature.types.ts +22 -12
  317. package/src/features/column-visibility/columnVisibilityFeature.utils.ts +101 -56
  318. package/src/features/global-filtering/globalFilteringFeature.types.ts +10 -5
  319. package/src/features/global-filtering/globalFilteringFeature.utils.ts +20 -14
  320. package/src/features/row-expanding/rowExpandingFeature.types.ts +16 -15
  321. package/src/features/row-expanding/rowExpandingFeature.utils.ts +58 -43
  322. package/src/features/row-pagination/rowPaginationFeature.types.ts +19 -12
  323. package/src/features/row-pagination/rowPaginationFeature.utils.ts +49 -32
  324. package/src/features/row-pinning/rowPinningFeature.types.ts +12 -8
  325. package/src/features/row-pinning/rowPinningFeature.utils.ts +59 -47
  326. package/src/features/row-selection/rowSelectionFeature.types.ts +30 -24
  327. package/src/features/row-selection/rowSelectionFeature.utils.ts +109 -88
  328. package/src/features/row-sorting/createSortedRowModel.ts +16 -13
  329. package/src/features/row-sorting/rowSortingFeature.types.ts +10 -8
  330. package/src/features/row-sorting/rowSortingFeature.utils.ts +63 -46
  331. package/src/fns/aggregationFns.ts +53 -17
  332. package/src/fns/filterFns.ts +48 -17
  333. package/src/helpers/columnHelper.ts +9 -4
  334. package/src/helpers/tableOptions.ts +12 -9
  335. package/src/store-reactivity-bindings.ts +1 -0
  336. package/src/types/ColumnDef.ts +38 -0
  337. package/src/types/TableOptions.ts +15 -0
  338. package/src/types/TableState.ts +12 -0
  339. package/src/utils.ts +19 -46
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedMinMaxValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedMinMaxValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted min max values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number] {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n fn: (flatRows) => _createFacetedMinMaxValues(columnId, flatRows),\n fnName: 'table.getFacetedMinMaxValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n table,\n })\n }\n}\n\nfunction _createFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n columnId: string,\n flatRows: Array<Row<TFeatures, TData>>,\n): undefined | [number, number] {\n if (!flatRows.length) return undefined\n\n const numericValues = flatRows\n .map((flatRow) => flatRow.getValue(columnId))\n .map(Number)\n .filter((value) => !Number.isNaN(value))\n\n if (!numericValues.length) return undefined\n\n let facetedMinValue = numericValues[0]!\n let facetedMaxValue = numericValues[0]!\n\n for (const value of numericValues) {\n if (value < facetedMinValue) facetedMinValue = value\n if (value > facetedMaxValue) facetedMaxValue = value\n }\n\n return [facetedMinValue, facetedMaxValue]\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMwB;CACtC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT,KAAK,aAAa,2BAA2B,UAAU,SAAS;GAChE,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,MACD,CAAC,SACH;;GAEH;GACD,CAAC;;;AAIN,SAAS,2BAIP,UACA,UAC8B;CAC9B,IAAI,CAAC,SAAS,QAAQ,OAAO;CAE7B,MAAM,gBAAgB,SACnB,KAAK,YAAY,QAAQ,SAAS,SAAS,CAAC,CAC5C,IAAI,OAAO,CACX,QAAQ,UAAU,CAAC,OAAO,MAAM,MAAM,CAAC;CAE1C,IAAI,CAAC,cAAc,QAAQ,OAAO;CAElC,IAAI,kBAAkB,cAAc;CACpC,IAAI,kBAAkB,cAAc;CAEpC,KAAK,MAAM,SAAS,eAAe;EACjC,IAAI,QAAQ,iBAAiB,kBAAkB;EAC/C,IAAI,QAAQ,iBAAiB,kBAAkB;;CAGjD,OAAO,CAAC,iBAAiB,gBAAgB"}
1
+ {"version":3,"file":"createFacetedMinMaxValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedMinMaxValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted min max values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => undefined | [number, number] {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n fn: (flatRows) => _createFacetedMinMaxValues(columnId, flatRows),\n fnName: 'table.getFacetedMinMaxValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n table,\n })\n }\n}\n\nfunction _createFacetedMinMaxValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n columnId: string,\n flatRows: Array<Row<TFeatures, TData>>,\n): undefined | [number, number] {\n if (!flatRows.length) return undefined\n\n let facetedMinValue = Number.POSITIVE_INFINITY\n let facetedMaxValue = Number.NEGATIVE_INFINITY\n let foundAny = false\n\n for (let i = 0; i < flatRows.length; i++) {\n const value = Number(flatRows[i]!.getValue(columnId))\n if (Number.isNaN(value)) continue\n foundAny = true\n if (value < facetedMinValue) facetedMinValue = value\n if (value > facetedMaxValue) facetedMaxValue = value\n }\n\n if (!foundAny) return undefined\n return [facetedMinValue, facetedMaxValue]\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMwB;CACtC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT,KAAK,aAAa,2BAA2B,UAAU,SAAS;GAChE,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,MACD,CAAC,SACH;;GAEH;GACD,CAAC;;;AAIN,SAAS,2BAIP,UACA,UAC8B;CAC9B,IAAI,CAAC,SAAS,QAAQ,OAAO;CAE7B,IAAI,kBAAkB,OAAO;CAC7B,IAAI,kBAAkB,OAAO;CAC7B,IAAI,WAAW;CAEf,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,QAAQ,OAAO,SAAS,GAAI,SAAS,SAAS,CAAC;EACrD,IAAI,OAAO,MAAM,MAAM,EAAE;EACzB,WAAW;EACX,IAAI,QAAQ,iBAAiB,kBAAkB;EAC/C,IAAI,QAAQ,iBAAiB,kBAAkB;;CAGjD,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO,CAAC,iBAAiB,gBAAgB"}
@@ -29,11 +29,16 @@ function createFacetedRowModel() {
29
29
  }
30
30
  function _createFacetedRowModel(table, columnId, preRowModel, columnFilters, globalFilter) {
31
31
  if (!preRowModel.rows.length || !(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.length) && !globalFilter) return preRowModel;
32
- const filterableIds = [...(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.map((d) => d.id).filter((d) => d !== columnId)) ?? [], globalFilter ? "__global__" : void 0].filter(Boolean);
32
+ const filterableIds = [];
33
+ if (columnFilters) for (let i = 0; i < columnFilters.length; i++) {
34
+ const id = columnFilters[i].id;
35
+ if (id !== columnId) filterableIds.push(id);
36
+ }
37
+ if (globalFilter) filterableIds.push("__global__");
33
38
  const filterRowsImpl = (row) => {
34
- for (const colId of filterableIds) {
39
+ for (let i = 0; i < filterableIds.length; i++) {
35
40
  var _row$columnFilters;
36
- if (((_row$columnFilters = row.columnFilters) === null || _row$columnFilters === void 0 ? void 0 : _row$columnFilters[colId]) === false) return false;
41
+ if (((_row$columnFilters = row.columnFilters) === null || _row$columnFilters === void 0 ? void 0 : _row$columnFilters[filterableIds[i]]) === false) return false;
37
42
  }
38
43
  return true;
39
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedRowModel.cjs","names":["tableMemo","filterRows"],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;EAEH,KAAK,MAAM,SAAS,eAAe;;GACjC,2BAAI,IAAI,uFAAgB,YAAW,OACjC,OAAO;;EAGX,OAAO;;CAGT,OAAOC,mCAAW,YAAY,MAAM,gBAAgB,MAAM"}
1
+ {"version":3,"file":"createFacetedRowModel.cjs","names":["tableMemo","filterRows"],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,EAAE;CACvC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,GAAI;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,GAAG;;CAG/C,IAAI,cAAc,cAAc,KAAK,aAAa;CAElD,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;;EAGX,OAAO;;CAGT,OAAOC,mCAAW,YAAY,MAAM,gBAAgB,MAAM"}
@@ -29,11 +29,16 @@ function createFacetedRowModel() {
29
29
  }
30
30
  function _createFacetedRowModel(table, columnId, preRowModel, columnFilters, globalFilter) {
31
31
  if (!preRowModel.rows.length || !(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.length) && !globalFilter) return preRowModel;
32
- const filterableIds = [...(columnFilters === null || columnFilters === void 0 ? void 0 : columnFilters.map((d) => d.id).filter((d) => d !== columnId)) ?? [], globalFilter ? "__global__" : void 0].filter(Boolean);
32
+ const filterableIds = [];
33
+ if (columnFilters) for (let i = 0; i < columnFilters.length; i++) {
34
+ const id = columnFilters[i].id;
35
+ if (id !== columnId) filterableIds.push(id);
36
+ }
37
+ if (globalFilter) filterableIds.push("__global__");
33
38
  const filterRowsImpl = (row) => {
34
- for (const colId of filterableIds) {
39
+ for (let i = 0; i < filterableIds.length; i++) {
35
40
  var _row$columnFilters;
36
- if (((_row$columnFilters = row.columnFilters) === null || _row$columnFilters === void 0 ? void 0 : _row$columnFilters[colId]) === false) return false;
41
+ if (((_row$columnFilters = row.columnFilters) === null || _row$columnFilters === void 0 ? void 0 : _row$columnFilters[filterableIds[i]]) === false) return false;
37
42
  }
38
43
  return true;
39
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedRowModel.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds = [\n ...(columnFilters?.map((d) => d.id).filter((d) => d !== columnId) ?? []),\n globalFilter ? '__global__' : undefined,\n ].filter(Boolean) as Array<string>\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (const colId of filterableIds) {\n if (row.columnFilters?.[colId] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAAgB,CACpB,kEAAI,cAAe,KAAK,MAAM,EAAE,GAAG,CAAC,QAAQ,MAAM,MAAM,SAAS,KAAI,EAAE,EACvE,eAAe,eAAe,OAC/B,CAAC,OAAO,QAAQ;CAEjB,MAAM,kBACJ,QACG;EAEH,KAAK,MAAM,SAAS,eAAe;;GACjC,2BAAI,IAAI,uFAAgB,YAAW,OACjC,OAAO;;EAGX,OAAO;;CAGT,OAAO,WAAW,YAAY,MAAM,gBAAgB,MAAM"}
1
+ {"version":3,"file":"createFacetedRowModel.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { filterRows } from '../column-filtering/filterRowsUtils'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type {\n ColumnFiltersState,\n Row_ColumnFiltering,\n} from '../column-filtering/columnFilteringFeature.types'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Row } from '../../types/Row'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted row model factory.\n *\n * The factory reads the relevant table state atoms and options, then returns a row model function used by the table row-model pipeline.\n */\nexport function createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => RowModel<TFeatures, TData> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'createFacetedRowModel',\n memoDeps: () => [\n table.getPreFilteredRowModel(),\n table.atoms.columnFilters?.get(),\n table.atoms.globalFilter?.get(),\n table.getFilteredRowModel(),\n ],\n fn: (preRowModel, columnFilters, globalFilter) =>\n _createFacetedRowModel(\n table,\n columnId,\n preRowModel,\n columnFilters,\n globalFilter,\n ),\n })\n }\n}\n\nfunction _createFacetedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(\n table: Table_Internal<TFeatures, TData>,\n columnId: string,\n preRowModel: RowModel<TFeatures, TData>,\n columnFilters?: ColumnFiltersState,\n globalFilter?: string,\n) {\n if (!preRowModel.rows.length || (!columnFilters?.length && !globalFilter)) {\n return preRowModel\n }\n\n const filterableIds: Array<string> = []\n if (columnFilters) {\n for (let i = 0; i < columnFilters.length; i++) {\n const id = columnFilters[i]!.id\n if (id !== columnId) filterableIds.push(id)\n }\n }\n if (globalFilter) filterableIds.push('__global__')\n\n const filterRowsImpl = (\n row: Row<TFeatures, TData> & Partial<Row_ColumnFiltering<TFeatures, TData>>,\n ) => {\n // Horizontally filter rows through each column\n for (let i = 0; i < filterableIds.length; i++) {\n if (row.columnFilters?.[filterableIds[i]!] === false) {\n return false\n }\n }\n return true\n }\n\n return filterRows(preRowModel.rows, filterRowsImpl, table)\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,wBAMsB;CACpC,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;;KACd,MAAM,wBAAwB;8BAC9B,MAAM,MAAM,6FAAe,KAAK;8BAChC,MAAM,MAAM,4FAAc,KAAK;KAC/B,MAAM,qBAAqB;KAC5B;;GACD,KAAK,aAAa,eAAe,iBAC/B,uBACE,OACA,UACA,aACA,eACA,aACD;GACJ,CAAC;;;AAIN,SAAS,uBAIP,OACA,UACA,aACA,eACA,cACA;CACA,IAAI,CAAC,YAAY,KAAK,UAAW,gEAAC,cAAe,WAAU,CAAC,cAC1D,OAAO;CAGT,MAAM,gBAA+B,EAAE;CACvC,IAAI,eACF,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;EAC7C,MAAM,KAAK,cAAc,GAAI;EAC7B,IAAI,OAAO,UAAU,cAAc,KAAK,GAAG;;CAG/C,IAAI,cAAc,cAAc,KAAK,aAAa;CAElD,MAAM,kBACJ,QACG;EAEH,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK;;GAC7C,2BAAI,IAAI,uFAAgB,cAAc,SAAS,OAC7C,OAAO;;EAGX,OAAO;;CAGT,OAAO,WAAW,YAAY,MAAM,gBAAgB,MAAM"}
@@ -25,10 +25,13 @@ function createFacetedUniqueValues() {
25
25
  }
26
26
  function _createFacetedUniqueValues(columnId, flatRows) {
27
27
  const facetedUniqueValues = /* @__PURE__ */ new Map();
28
- for (const row of flatRows) {
29
- const values = row.getUniqueValues(columnId);
30
- for (const value of values) if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
31
- else facetedUniqueValues.set(value, 1);
28
+ for (let i = 0; i < flatRows.length; i++) {
29
+ const values = flatRows[i].getUniqueValues(columnId);
30
+ for (let j = 0; j < values.length; j++) {
31
+ const value = values[j];
32
+ if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
33
+ else facetedUniqueValues.set(value, 1);
34
+ }
32
35
  }
33
36
  return facetedUniqueValues;
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedUniqueValues.cjs","names":["tableMemo","callMemoOrStaticFn","column_getFacetedRowModel"],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (const row of flatRows) {\n const values = row.getUniqueValues(columnId)\n\n for (const value of values) {\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACLC,iCACE,QACA,sBACAC,+DACA,MACD,CAAC,SACH;;GAEH,KAAK,aAAa,2BAA2B,UAAU,SAAS;GACjE,CAAC;;;AAIN,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,KAAkB;CAElD,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,SAAS,IAAI,gBAAgB,SAAS;EAE5C,KAAK,MAAM,SAAS,QAClB,IAAI,oBAAoB,IAAI,MAAM,EAChC,oBAAoB,IAClB,QACC,oBAAoB,IAAI,MAAM,IAAI,KAAK,EACzC;OAED,oBAAoB,IAAI,OAAO,EAAE;;CAKvC,OAAO"}
1
+ {"version":3,"file":"createFacetedUniqueValues.cjs","names":["tableMemo","callMemoOrStaticFn","column_getFacetedRowModel"],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAOA,wBAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACLC,iCACE,QACA,sBACAC,+DACA,MACD,CAAC,SACH;;GAEH,KAAK,aAAa,2BAA2B,UAAU,SAAS;GACjE,CAAC;;;AAIN,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,KAAkB;CAElD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,GAAI,gBAAgB,SAAS;EAErD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,IAAI,oBAAoB,IAAI,MAAM,EAChC,oBAAoB,IAClB,QACC,oBAAoB,IAAI,MAAM,IAAI,KAAK,EACzC;QAED,oBAAoB,IAAI,OAAO,EAAE;;;CAKvC,OAAO"}
@@ -25,10 +25,13 @@ function createFacetedUniqueValues() {
25
25
  }
26
26
  function _createFacetedUniqueValues(columnId, flatRows) {
27
27
  const facetedUniqueValues = /* @__PURE__ */ new Map();
28
- for (const row of flatRows) {
29
- const values = row.getUniqueValues(columnId);
30
- for (const value of values) if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
31
- else facetedUniqueValues.set(value, 1);
28
+ for (let i = 0; i < flatRows.length; i++) {
29
+ const values = flatRows[i].getUniqueValues(columnId);
30
+ for (let j = 0; j < values.length; j++) {
31
+ const value = values[j];
32
+ if (facetedUniqueValues.has(value)) facetedUniqueValues.set(value, (facetedUniqueValues.get(value) ?? 0) + 1);
33
+ else facetedUniqueValues.set(value, 1);
34
+ }
32
35
  }
33
36
  return facetedUniqueValues;
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createFacetedUniqueValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (const row of flatRows) {\n const values = row.getUniqueValues(columnId)\n\n for (const value of values) {\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,MACD,CAAC,SACH;;GAEH,KAAK,aAAa,2BAA2B,UAAU,SAAS;GACjE,CAAC;;;AAIN,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,KAAkB;CAElD,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,SAAS,IAAI,gBAAgB,SAAS;EAE5C,KAAK,MAAM,SAAS,QAClB,IAAI,oBAAoB,IAAI,MAAM,EAChC,oBAAoB,IAClB,QACC,oBAAoB,IAAI,MAAM,IAAI,KAAK,EACzC;OAED,oBAAoB,IAAI,OAAO,EAAE;;CAKvC,OAAO"}
1
+ {"version":3,"file":"createFacetedUniqueValues.js","names":[],"sources":["../../../src/features/column-faceting/createFacetedUniqueValues.ts"],"sourcesContent":["import { callMemoOrStaticFn, tableMemo } from '../../utils'\nimport { column_getFacetedRowModel } from './columnFacetingFeature.utils'\nimport type { Row } from '../../types/Row'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized faceted unique values helper for faceted filtering.\n *\n * The returned function derives facet data from the table row model and relevant filter state so filter UIs can display available values.\n */\nexport function createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(): (\n table: Table<TFeatures, TData>,\n columnId: string,\n) => () => Map<any, number> {\n return (_table, columnId) => {\n const table: Table_Internal<TFeatures, TData> = _table\n return tableMemo({\n feature: 'columnFacetingFeature',\n table,\n fnName: 'table.getFacetedUniqueValues',\n memoDeps: () => {\n const column = table.getColumn(columnId)\n if (!column) return [table.getPreFilteredRowModel().flatRows]\n return [\n callMemoOrStaticFn(\n column,\n 'getFacetedRowModel',\n column_getFacetedRowModel,\n table,\n ).flatRows,\n ]\n },\n fn: (flatRows) => _createFacetedUniqueValues(columnId, flatRows),\n })\n }\n}\n\nfunction _createFacetedUniqueValues<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(columnId: string, flatRows: Array<Row<TFeatures, TData>>): Map<any, number> {\n const facetedUniqueValues = new Map<any, number>()\n\n for (let i = 0; i < flatRows.length; i++) {\n const values = flatRows[i]!.getUniqueValues(columnId)\n\n for (let j = 0; j < values.length; j++) {\n const value = values[j]\n if (facetedUniqueValues.has(value)) {\n facetedUniqueValues.set(\n value,\n (facetedUniqueValues.get(value) ?? 0) + 1,\n )\n } else {\n facetedUniqueValues.set(value, 1)\n }\n }\n }\n\n return facetedUniqueValues\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,4BAMY;CAC1B,QAAQ,QAAQ,aAAa;EAC3B,MAAM,QAA0C;EAChD,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;IACd,MAAM,SAAS,MAAM,UAAU,SAAS;IACxC,IAAI,CAAC,QAAQ,OAAO,CAAC,MAAM,wBAAwB,CAAC,SAAS;IAC7D,OAAO,CACL,mBACE,QACA,sBACA,2BACA,MACD,CAAC,SACH;;GAEH,KAAK,aAAa,2BAA2B,UAAU,SAAS;GACjE,CAAC;;;AAIN,SAAS,2BAGP,UAAkB,UAA0D;CAC5E,MAAM,sCAAsB,IAAI,KAAkB;CAElD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,GAAI,gBAAgB,SAAS;EAErD,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,QAAQ,OAAO;GACrB,IAAI,oBAAoB,IAAI,MAAM,EAChC,oBAAoB,IAClB,QACC,oBAAoB,IAAI,MAAM,IAAI,KAAK,EACzC;QAED,oBAAoB,IAAI,OAAO,EAAE;;;CAKvC,OAAO"}
@@ -36,7 +36,10 @@ type CustomFilterFns<TFeatures extends TableFeatures, TData extends RowData> = R
36
36
  type FilterFnOption<TFeatures extends TableFeatures, TData extends RowData> = 'auto' | BuiltInFilterFn | keyof FilterFns | FilterFn<TFeatures, TData>;
37
37
  interface ColumnDef_ColumnFiltering<TFeatures extends TableFeatures, TData extends RowData> {
38
38
  /**
39
- * Enables/disables the **column** filter for this column.
39
+ * Enables this column to participate in column-specific filtering.
40
+ *
41
+ * Defaults to `true`; table-level `enableColumnFilters` and `enableFilters`
42
+ * must also allow filtering.
40
43
  */
41
44
  enableColumnFilter?: boolean;
42
45
  /**
@@ -50,7 +53,7 @@ interface Column_ColumnFiltering<TFeatures extends TableFeatures, TData extends
50
53
  */
51
54
  getAutoFilterFn: () => FilterFn<TFeatures, TData>;
52
55
  /**
53
- * Returns whether or not the column can be **column** filtered.
56
+ * Checks whether this accessor column can currently be column-filtered.
54
57
  */
55
58
  getCanFilter: () => boolean;
56
59
  /**
@@ -62,15 +65,18 @@ interface Column_ColumnFiltering<TFeatures extends TableFeatures, TData extends
62
65
  */
63
66
  getFilterIndex: () => number;
64
67
  /**
65
- * Returns the current filter value for the column.
68
+ * Reads this column's current value from `state.columnFilters`.
66
69
  */
67
70
  getFilterValue: () => unknown;
68
71
  /**
69
- * Returns whether or not the column is currently filtered.
72
+ * Checks whether this column has an active entry in `state.columnFilters`.
70
73
  */
71
74
  getIsFiltered: () => boolean;
72
75
  /**
73
- * A function that sets the current filter value for the column. You can pass it a value or an updater function for immutability-safe operations on existing values.
76
+ * Adds, updates, or removes this column's filter value.
77
+ *
78
+ * Updater functions receive the previous filter value. Values that satisfy
79
+ * the filter function's `autoRemove` rule are removed from filter state.
74
80
  */
75
81
  setFilterValue: (updater: Updater<any>) => void;
76
82
  }
@@ -86,11 +92,13 @@ interface Row_ColumnFiltering<TFeatures extends TableFeatures, TData extends Row
86
92
  }
87
93
  interface TableOptions_ColumnFiltering<TFeatures extends TableFeatures, TData extends RowData> {
88
94
  /**
89
- * Enables/disables **column** filtering for all columns.
95
+ * Enables column-specific filtering for all columns that also allow it.
90
96
  */
91
97
  enableColumnFilters?: boolean;
92
98
  /**
93
- * Enables/disables all filtering for the table.
99
+ * Enables all filtering features for the table.
100
+ *
101
+ * Set this to `false` to disable both column filtering and global filtering.
94
102
  */
95
103
  enableFilters?: boolean;
96
104
  /**
@@ -115,21 +123,23 @@ interface TableOptions_ColumnFiltering<TFeatures extends TableFeatures, TData ex
115
123
  }
116
124
  interface Table_ColumnFiltering {
117
125
  /**
118
- * Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.
126
+ * Resets `columnFilters` to `initialState.columnFilters`.
127
+ *
128
+ * Pass `true` to ignore initial state and reset to `[]`.
119
129
  */
120
130
  resetColumnFilters: (defaultState?: boolean) => void;
121
131
  /**
122
- * Sets column filter state using a value or updater.
132
+ * Updates column filter state with a next array or updater function.
123
133
  */
124
134
  setColumnFilters: (updater: Updater<ColumnFiltersState>) => void;
125
135
  }
126
136
  interface Table_RowModels_Filtered<TFeatures extends TableFeatures, TData extends RowData> {
127
137
  /**
128
- * Returns the row model for the table after **column** filtering has been applied.
138
+ * Resolves the row model after column and global filters have been applied.
129
139
  */
130
140
  getFilteredRowModel: () => RowModel<TFeatures, TData>;
131
141
  /**
132
- * Returns the row model for the table before any **column** filtering has been applied.
142
+ * Reads the row model immediately before filtering.
133
143
  */
134
144
  getPreFilteredRowModel: () => RowModel<TFeatures, TData>;
135
145
  }
@@ -36,7 +36,10 @@ type CustomFilterFns<TFeatures extends TableFeatures, TData extends RowData> = R
36
36
  type FilterFnOption<TFeatures extends TableFeatures, TData extends RowData> = 'auto' | BuiltInFilterFn | keyof FilterFns | FilterFn<TFeatures, TData>;
37
37
  interface ColumnDef_ColumnFiltering<TFeatures extends TableFeatures, TData extends RowData> {
38
38
  /**
39
- * Enables/disables the **column** filter for this column.
39
+ * Enables this column to participate in column-specific filtering.
40
+ *
41
+ * Defaults to `true`; table-level `enableColumnFilters` and `enableFilters`
42
+ * must also allow filtering.
40
43
  */
41
44
  enableColumnFilter?: boolean;
42
45
  /**
@@ -50,7 +53,7 @@ interface Column_ColumnFiltering<TFeatures extends TableFeatures, TData extends
50
53
  */
51
54
  getAutoFilterFn: () => FilterFn<TFeatures, TData>;
52
55
  /**
53
- * Returns whether or not the column can be **column** filtered.
56
+ * Checks whether this accessor column can currently be column-filtered.
54
57
  */
55
58
  getCanFilter: () => boolean;
56
59
  /**
@@ -62,15 +65,18 @@ interface Column_ColumnFiltering<TFeatures extends TableFeatures, TData extends
62
65
  */
63
66
  getFilterIndex: () => number;
64
67
  /**
65
- * Returns the current filter value for the column.
68
+ * Reads this column's current value from `state.columnFilters`.
66
69
  */
67
70
  getFilterValue: () => unknown;
68
71
  /**
69
- * Returns whether or not the column is currently filtered.
72
+ * Checks whether this column has an active entry in `state.columnFilters`.
70
73
  */
71
74
  getIsFiltered: () => boolean;
72
75
  /**
73
- * A function that sets the current filter value for the column. You can pass it a value or an updater function for immutability-safe operations on existing values.
76
+ * Adds, updates, or removes this column's filter value.
77
+ *
78
+ * Updater functions receive the previous filter value. Values that satisfy
79
+ * the filter function's `autoRemove` rule are removed from filter state.
74
80
  */
75
81
  setFilterValue: (updater: Updater<any>) => void;
76
82
  }
@@ -86,11 +92,13 @@ interface Row_ColumnFiltering<TFeatures extends TableFeatures, TData extends Row
86
92
  }
87
93
  interface TableOptions_ColumnFiltering<TFeatures extends TableFeatures, TData extends RowData> {
88
94
  /**
89
- * Enables/disables **column** filtering for all columns.
95
+ * Enables column-specific filtering for all columns that also allow it.
90
96
  */
91
97
  enableColumnFilters?: boolean;
92
98
  /**
93
- * Enables/disables all filtering for the table.
99
+ * Enables all filtering features for the table.
100
+ *
101
+ * Set this to `false` to disable both column filtering and global filtering.
94
102
  */
95
103
  enableFilters?: boolean;
96
104
  /**
@@ -115,21 +123,23 @@ interface TableOptions_ColumnFiltering<TFeatures extends TableFeatures, TData ex
115
123
  }
116
124
  interface Table_ColumnFiltering {
117
125
  /**
118
- * Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.
126
+ * Resets `columnFilters` to `initialState.columnFilters`.
127
+ *
128
+ * Pass `true` to ignore initial state and reset to `[]`.
119
129
  */
120
130
  resetColumnFilters: (defaultState?: boolean) => void;
121
131
  /**
122
- * Sets column filter state using a value or updater.
132
+ * Updates column filter state with a next array or updater function.
123
133
  */
124
134
  setColumnFilters: (updater: Updater<ColumnFiltersState>) => void;
125
135
  }
126
136
  interface Table_RowModels_Filtered<TFeatures extends TableFeatures, TData extends RowData> {
127
137
  /**
128
- * Returns the row model for the table after **column** filtering has been applied.
138
+ * Resolves the row model after column and global filters have been applied.
129
139
  */
130
140
  getFilteredRowModel: () => RowModel<TFeatures, TData>;
131
141
  /**
132
- * Returns the row model for the table before any **column** filtering has been applied.
142
+ * Reads the row model immediately before filtering.
133
143
  */
134
144
  getPreFilteredRowModel: () => RowModel<TFeatures, TData>;
135
145
  }
@@ -2,26 +2,29 @@ const require_utils = require('../../utils.cjs');
2
2
 
3
3
  //#region src/features/column-filtering/columnFilteringFeature.utils.ts
4
4
  /**
5
- * Returns the default column filters state.
5
+ * Creates the default column filter state.
6
6
  *
7
- * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.
7
+ * The feature default is an empty array, meaning no column filters are active.
8
+ * Reset APIs use this value when `defaultState` is `true`.
8
9
  *
9
10
  * @example
10
11
  * ```ts
11
- * const initialValue = getDefaultColumnFiltersState()
12
+ * const filters = getDefaultColumnFiltersState()
12
13
  * ```
13
14
  */
14
15
  function getDefaultColumnFiltersState() {
15
16
  return [];
16
17
  }
17
18
  /**
18
- * Infers filter fn for a column.
19
+ * Chooses a built-in filter function from the column's first core row value.
19
20
  *
20
- * The inference uses the column definition, table options, and sampled row values when needed.
21
+ * Strings use `includesString`, numbers use `inNumberRange`, booleans and
22
+ * objects use `equals`, arrays use `arrIncludes`, and unknown values fall back
23
+ * to `weakEquals`.
21
24
  *
22
25
  * @example
23
26
  * ```ts
24
- * const value = column_getAutoFilterFn(column)
27
+ * const filterFn = column_getAutoFilterFn(column)
25
28
  * ```
26
29
  */
27
30
  function column_getAutoFilterFn(column) {
@@ -36,13 +39,15 @@ function column_getAutoFilterFn(column) {
36
39
  return filterFns === null || filterFns === void 0 ? void 0 : filterFns.weakEquals;
37
40
  }
38
41
  /**
39
- * Returns filter fn for a column.
42
+ * Resolves the filter function configured for a column.
40
43
  *
41
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
44
+ * Function-valued `columnDef.filterFn` is returned directly, `'auto'` delegates
45
+ * to `column_getAutoFilterFn`, and string values are looked up in the table's
46
+ * filter function registry.
42
47
  *
43
48
  * @example
44
49
  * ```ts
45
- * const value = column_getFilterFn(column)
50
+ * const filterFn = column_getFilterFn(column)
46
51
  * ```
47
52
  */
48
53
  function column_getFilterFn(column) {
@@ -53,35 +58,37 @@ function column_getFilterFn(column) {
53
58
  return filterFn;
54
59
  }
55
60
  /**
56
- * Returns whether a column can use filter.
61
+ * Checks whether column filtering is enabled for this accessor column.
57
62
  *
58
- * This combines column options, table options, and any required accessor or feature state for the capability.
63
+ * The column must have an accessor and filtering must be enabled by the column
64
+ * definition, `enableColumnFilters`, and the table-wide `enableFilters` option.
59
65
  *
60
66
  * @example
61
67
  * ```ts
62
- * const value = column_getCanFilter(column)
68
+ * const canFilter = column_getCanFilter(column)
63
69
  * ```
64
70
  */
65
71
  function column_getCanFilter(column) {
66
72
  return (column.columnDef.enableColumnFilter ?? true) && (column.table.options.enableColumnFilters ?? true) && (column.table.options.enableFilters ?? true) && !!column.accessorFn;
67
73
  }
68
74
  /**
69
- * Returns is filtered for a column.
75
+ * Checks whether this column currently has an entry in `state.columnFilters`.
70
76
  *
71
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
77
+ * This only reflects filter state presence; it does not indicate whether the
78
+ * filter removes any rows.
72
79
  *
73
80
  * @example
74
81
  * ```ts
75
- * const value = column_getIsFiltered(column)
82
+ * const isFiltered = column_getIsFiltered(column)
76
83
  * ```
77
84
  */
78
85
  function column_getIsFiltered(column) {
79
86
  return column_getFilterIndex(column) > -1;
80
87
  }
81
88
  /**
82
- * Returns filter value for a column.
89
+ * Reads this column's current filter value from `state.columnFilters`.
83
90
  *
84
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
91
+ * Missing filter entries return `undefined`.
85
92
  *
86
93
  * @example
87
94
  * ```ts
@@ -93,13 +100,13 @@ function column_getFilterValue(column) {
93
100
  return (_column$table$atoms$c = column.table.atoms.columnFilters) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.get()) === null || _column$table$atoms$c === void 0 || (_column$table$atoms$c = _column$table$atoms$c.find((d) => d.id === column.id)) === null || _column$table$atoms$c === void 0 ? void 0 : _column$table$atoms$c.value;
94
101
  }
95
102
  /**
96
- * Returns filter index for a column.
103
+ * Finds this column's position in the ordered `state.columnFilters` array.
97
104
  *
98
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
105
+ * The result is `-1` when the column has no active filter.
99
106
  *
100
107
  * @example
101
108
  * ```ts
102
- * const value = column_getFilterIndex(column)
109
+ * const index = column_getFilterIndex(column)
103
110
  * ```
104
111
  */
105
112
  function column_getFilterIndex(column) {
@@ -107,13 +114,14 @@ function column_getFilterIndex(column) {
107
114
  return ((_column$table$atoms$c2 = column.table.atoms.columnFilters) === null || _column$table$atoms$c2 === void 0 || (_column$table$atoms$c2 = _column$table$atoms$c2.get()) === null || _column$table$atoms$c2 === void 0 ? void 0 : _column$table$atoms$c2.findIndex((d) => d.id === column.id)) ?? -1;
108
115
  }
109
116
  /**
110
- * Updates filter value for a column.
117
+ * Adds, updates, or removes this column's filter value.
111
118
  *
112
- * This delegates to the owning table state updater so external state, external atoms, and internal state stay synchronized.
119
+ * The incoming value may be an updater. After resolution, `autoRemove` rules
120
+ * decide whether the filter should be removed instead of stored.
113
121
  *
114
122
  * @example
115
123
  * ```ts
116
- * column_setFilterValue(column, (old) => old)
124
+ * column_setFilterValue(column, (old) => String(old ?? '').trim())
117
125
  * ```
118
126
  */
119
127
  function column_setFilterValue(column, value) {
@@ -135,13 +143,15 @@ function column_setFilterValue(column, value) {
135
143
  });
136
144
  }
137
145
  /**
138
- * Updates the table's column filters state slice.
146
+ * Routes a column filter updater through the table's filter change handler.
139
147
  *
140
- * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.
148
+ * The resolved filters are cleaned before they are emitted: filters for known
149
+ * columns are removed when their filter function says the value should be
150
+ * auto-removed.
141
151
  *
142
152
  * @example
143
153
  * ```ts
144
- * table_setColumnFilters(table, (old) => old)
154
+ * table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))
145
155
  * ```
146
156
  */
147
157
  function table_setColumnFilters(table, updater) {
@@ -159,9 +169,10 @@ function table_setColumnFilters(table, updater) {
159
169
  (_table$options$onColu = (_table$options = table.options).onColumnFiltersChange) === null || _table$options$onColu === void 0 || _table$options$onColu.call(_table$options, updateFn);
160
170
  }
161
171
  /**
162
- * Resets the table's column filters state slice.
172
+ * Resets `columnFilters` to the configured initial state or feature default.
163
173
  *
164
- * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.
174
+ * With no argument, the reset clones `table.initialState.columnFilters` when it
175
+ * exists. Passing `true` ignores initial state and resets to `[]`.
165
176
  *
166
177
  * @example
167
178
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"columnFilteringFeature.utils.cjs","names":["isFunction","functionalUpdate","cloneState"],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate, isFunction } from '../../utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\n/**\n * Returns the default column filters state.\n *\n * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.\n *\n * @example\n * ```ts\n * const initialValue = getDefaultColumnFiltersState()\n * ```\n */\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return []\n}\n\n/**\n * Infers filter fn for a column.\n *\n * The inference uses the column definition, table options, and sampled row values when needed.\n *\n * @example\n * ```ts\n * const value = column_getAutoFilterFn(column)\n * ```\n */\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\n/**\n * Returns filter fn for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterFn(column)\n * ```\n */\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\n/**\n * Returns whether a column can use filter.\n *\n * This combines column options, table options, and any required accessor or feature state for the capability.\n *\n * @example\n * ```ts\n * const value = column_getCanFilter(column)\n * ```\n */\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Returns is filtered for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getIsFiltered(column)\n * ```\n */\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\n/**\n * Returns filter value for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterValue(column)\n * ```\n */\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.atoms.columnFilters\n ?.get()\n ?.find((d) => d.id === column.id)?.value\n}\n\n/**\n * Returns filter index for a column.\n *\n * This derives the value from the column definition, table options, and the feature state atoms registered on the table.\n *\n * @example\n * ```ts\n * const value = column_getFilterIndex(column)\n * ```\n */\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.atoms.columnFilters\n ?.get()\n ?.findIndex((d) => d.id === column.id) ?? -1\n )\n}\n\n/**\n * Updates filter value for a column.\n *\n * This delegates to the owning table state updater so external state, external atoms, and internal state stay synchronized.\n *\n * @example\n * ```ts\n * column_setFilterValue(column, (old) => old)\n * ```\n */\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\n/**\n * Updates the table's column filters state slice.\n *\n * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.\n *\n * @example\n * ```ts\n * table_setColumnFilters(table, (old) => old)\n * ```\n */\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumnsById[filter.id]\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\n/**\n * Resets the table's column filters state slice.\n *\n * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.\n *\n * @example\n * ```ts\n * table_resetColumnFilters(table)\n * table_resetColumnFilters(table, true)\n * ```\n */\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : cloneState(table.initialState.columnFilters ?? []),\n )\n}\n\n/**\n * Returns whether a filter value should be removed from filter state.\n *\n * This checks the filter function's `autoRemove` hook and built-in empty-value rules.\n *\n * @example\n * ```ts\n * const removeFilter = shouldAutoRemoveFilter(filterFn, value, column)\n * ```\n */\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"columnFilteringFeature.utils.cjs","names":["isFunction","functionalUpdate","cloneState"],"sources":["../../../src/features/column-filtering/columnFilteringFeature.utils.ts"],"sourcesContent":["import { cloneState, functionalUpdate, isFunction } from '../../utils'\nimport type { CellData, RowData, Updater } from '../../types/type-utils'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { Table_Internal } from '../../types/Table'\nimport type { Column_Internal } from '../../types/Column'\nimport type {\n ColumnFiltersState,\n FilterFn,\n} from './columnFilteringFeature.types'\n\n/**\n * Creates the default column filter state.\n *\n * The feature default is an empty array, meaning no column filters are active.\n * Reset APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const filters = getDefaultColumnFiltersState()\n * ```\n */\nexport function getDefaultColumnFiltersState(): ColumnFiltersState {\n return []\n}\n\n/**\n * Chooses a built-in filter function from the column's first core row value.\n *\n * Strings use `includesString`, numbers use `inNumberRange`, booleans and\n * objects use `equals`, arrays use `arrIncludes`, and unknown values fall back\n * to `weakEquals`.\n *\n * @example\n * ```ts\n * const filterFn = column_getAutoFilterFn(column)\n * ```\n */\nexport function column_getAutoFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n\n const firstRow = column.table.getCoreRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return filterFns?.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns?.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns?.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns?.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns?.arrIncludes\n }\n\n return filterFns?.weakEquals\n}\n\n/**\n * Resolves the filter function configured for a column.\n *\n * Function-valued `columnDef.filterFn` is returned directly, `'auto'` delegates\n * to `column_getAutoFilterFn`, and string values are looked up in the table's\n * filter function registry.\n *\n * @example\n * ```ts\n * const filterFn = column_getFilterFn(column)\n * ```\n */\nexport function column_getFilterFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n): FilterFn<TFeatures, TData> | undefined {\n let filterFn = null\n const filterFns: Record<string, FilterFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.filterFns\n filterFn = isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column_getAutoFilterFn(column)\n : filterFns?.[column.columnDef.filterFn as string]\n\n if (process.env.NODE_ENV === 'development' && !filterFn) {\n console.warn(\n `Could not find a valid 'column.filterFn' for column with the ID: ${column.id}.`,\n )\n }\n\n return filterFn\n}\n\n/**\n * Checks whether column filtering is enabled for this accessor column.\n *\n * The column must have an accessor and filtering must be enabled by the column\n * definition, `enableColumnFilters`, and the table-wide `enableFilters` option.\n *\n * @example\n * ```ts\n * const canFilter = column_getCanFilter(column)\n * ```\n */\nexport function column_getCanFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (column.table.options.enableColumnFilters ?? true) &&\n (column.table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Checks whether this column currently has an entry in `state.columnFilters`.\n *\n * This only reflects filter state presence; it does not indicate whether the\n * filter removes any rows.\n *\n * @example\n * ```ts\n * const isFiltered = column_getIsFiltered(column)\n * ```\n */\nexport function column_getIsFiltered<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column_getFilterIndex(column) > -1\n}\n\n/**\n * Reads this column's current filter value from `state.columnFilters`.\n *\n * Missing filter entries return `undefined`.\n *\n * @example\n * ```ts\n * const value = column_getFilterValue(column)\n * ```\n */\nexport function column_getFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n return column.table.atoms.columnFilters\n ?.get()\n ?.find((d) => d.id === column.id)?.value\n}\n\n/**\n * Finds this column's position in the ordered `state.columnFilters` array.\n *\n * The result is `-1` when the column has no active filter.\n *\n * @example\n * ```ts\n * const index = column_getFilterIndex(column)\n * ```\n */\nexport function column_getFilterIndex<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): number {\n return (\n column.table.atoms.columnFilters\n ?.get()\n ?.findIndex((d) => d.id === column.id) ?? -1\n )\n}\n\n/**\n * Adds, updates, or removes this column's filter value.\n *\n * The incoming value may be an updater. After resolution, `autoRemove` rules\n * decide whether the filter should be removed instead of stored.\n *\n * @example\n * ```ts\n * column_setFilterValue(column, (old) => String(old ?? '').trim())\n * ```\n */\nexport function column_setFilterValue<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, value: any) {\n table_setColumnFilters(column.table, (old) => {\n const filterFn = column_getFilterFn(column)\n const previousFilter = old.find((d) => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined,\n )\n\n if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {\n return old.filter((d) => d.id !== column.id)\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return old.map((d) => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n })\n }\n\n if (old.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n}\n\n/**\n * Routes a column filter updater through the table's filter change handler.\n *\n * The resolved filters are cleaned before they are emitted: filters for known\n * columns are removed when their filter function says the value should be\n * auto-removed.\n *\n * @example\n * ```ts\n * table_setColumnFilters(table, (old) => old.filter((filter) => filter.id !== 'age'))\n * ```\n */\nexport function table_setColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n table: Table_Internal<TFeatures, TData>,\n updater: Updater<ColumnFiltersState>,\n) {\n const leafColumnsById = table.getAllLeafColumnsById()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old).filter((filter) => {\n const column = leafColumnsById[filter.id]\n\n if (column) {\n const filterFn = column_getFilterFn(column)\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n}\n\n/**\n * Resets `columnFilters` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.columnFilters` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetColumnFilters(table)\n * table_resetColumnFilters(table, true)\n * ```\n */\nexport function table_resetColumnFilters<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setColumnFilters(\n table,\n defaultState ? [] : cloneState(table.initialState.columnFilters ?? []),\n )\n}\n\n/**\n * Returns whether a filter value should be removed from filter state.\n *\n * This checks the filter function's `autoRemove` hook and built-in empty-value rules.\n *\n * @example\n * ```ts\n * const removeFilter = shouldAutoRemoveFilter(filterFn, value, column)\n * ```\n */\nexport function shouldAutoRemoveFilter<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n filterFn?: FilterFn<TFeatures, TData>,\n value?: any,\n column?: Column_Internal<TFeatures, TData, TValue>,\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"mappings":"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"}