@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
@@ -43,11 +43,10 @@ function _createSortedRowModel(table) {
43
43
  };
44
44
  });
45
45
  const sortData = (rows) => {
46
- const sortedData = rows.map((row) => {
47
- return Object.assign(Object.create(Object.getPrototypeOf(row)), row);
48
- });
46
+ const sortedData = rows.slice();
49
47
  sortedData.sort((rowA, rowB) => {
50
- for (const sortEntry of availableSorting) {
48
+ for (let i = 0; i < availableSorting.length; i++) {
49
+ const sortEntry = availableSorting[i];
51
50
  const columnInfo = columnInfoById[sortEntry.id];
52
51
  const sortUndefined = columnInfo.sortUndefined;
53
52
  const isDesc = sortEntry.desc;
@@ -72,10 +71,16 @@ function _createSortedRowModel(table) {
72
71
  }
73
72
  return rowA.index - rowB.index;
74
73
  });
75
- sortedData.forEach((row) => {
76
- sortedFlatRows.push(row);
77
- if (row.subRows.length) row.subRows = sortData(row.subRows);
78
- });
74
+ for (let i = 0; i < sortedData.length; i++) {
75
+ const row = sortedData[i];
76
+ if (row.subRows.length) {
77
+ const cloned = Object.create(Object.getPrototypeOf(row));
78
+ Object.assign(cloned, row);
79
+ cloned.subRows = sortData(row.subRows);
80
+ sortedData[i] = cloned;
81
+ sortedFlatRows.push(cloned);
82
+ } else sortedFlatRows.push(row);
83
+ }
79
84
  return sortedData;
80
85
  };
81
86
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"createSortedRowModel.js","names":[],"sources":["../../../src/features/row-sorting/createSortedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { column_getCanSort, column_getSortFn } from './rowSortingFeature.utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { SortFn, SortFns } from './rowSortingFeature.types'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized sorted 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 createSortedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n sortFns: Record<keyof SortFns, SortFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.sortFns) table._rowModelFns.sortFns = sortFns\n return tableMemo({\n feature: 'rowSortingFeature',\n table,\n fnName: 'table.getSortedRowModel',\n memoDeps: () => [\n table.atoms.sorting?.get(),\n table.getPreSortedRowModel(),\n ],\n fn: () => _createSortedRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createSortedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const preSortedRowModel = table.getPreSortedRowModel()\n const sorting = table.atoms.sorting?.get()\n\n if (!preSortedRowModel.rows.length || !sorting?.length) {\n return preSortedRowModel\n }\n\n const sortedFlatRows: Array<Row<TFeatures, TData>> = []\n\n // Filter out sortings that correspond to non existing columns\n const availableSorting = sorting.filter((sort) =>\n column_getCanSort(\n table.getColumn(sort.id) as Column_Internal<TFeatures, TData>,\n ),\n )\n\n const columnInfoById: Record<\n string,\n {\n sortUndefined?: false | -1 | 1 | 'first' | 'last'\n invertSorting?: boolean\n sortFn: SortFn<TFeatures, TData>\n }\n > = {}\n\n availableSorting.forEach((sortEntry) => {\n const column: Column_Internal<TFeatures, TData> | undefined =\n table.getColumn(sortEntry.id)\n if (!column) return\n\n columnInfoById[sortEntry.id] = {\n sortUndefined: column.columnDef.sortUndefined,\n invertSorting: column.columnDef.invertSorting,\n sortFn: column_getSortFn(column),\n }\n })\n\n const sortData = (rows: Array<Row<TFeatures, TData>>) => {\n // This will also perform a stable sorting using the row index\n // if needed.\n // Preserve prototype chain so methods like getValue() remain accessible\n const sortedData = rows.map((row) => {\n const cloned = Object.create(Object.getPrototypeOf(row))\n return Object.assign(cloned, row)\n })\n\n sortedData.sort((rowA, rowB) => {\n for (const sortEntry of availableSorting) {\n const columnInfo = columnInfoById[sortEntry.id]!\n const sortUndefined = columnInfo.sortUndefined\n const isDesc = sortEntry.desc\n\n let sortInt = 0\n\n // All sorting ints should always return in ascending order\n if (sortUndefined) {\n const aValue = rowA.getValue(sortEntry.id)\n const bValue = rowB.getValue(sortEntry.id)\n\n const aUndefined = aValue === undefined\n const bUndefined = bValue === undefined\n\n if (aUndefined || bUndefined) {\n if (sortUndefined === 'first') return aUndefined ? -1 : 1\n if (sortUndefined === 'last') return aUndefined ? 1 : -1\n sortInt =\n aUndefined && bUndefined\n ? 0\n : aUndefined\n ? sortUndefined\n : -sortUndefined\n }\n }\n\n if (sortInt === 0) {\n sortInt = columnInfo.sortFn(rowA, rowB, sortEntry.id)\n }\n\n // If sorting is non-zero, take care of desc and inversion\n if (sortInt !== 0) {\n if (isDesc) {\n sortInt *= -1\n }\n\n if (columnInfo.invertSorting) {\n sortInt *= -1\n }\n\n return sortInt\n }\n }\n return rowA.index - rowB.index\n })\n\n // If there are sub-rows, sort them\n sortedData.forEach((row) => {\n sortedFlatRows.push(row)\n if (row.subRows.length) {\n row.subRows = sortData(row.subRows)\n }\n })\n\n return sortedData\n }\n\n return {\n rows: sortData(preSortedRowModel.rows),\n flatRows: sortedFlatRows,\n rowsById: preSortedRowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,qBAId,SACsE;CACtE,QAAQ,WAAW;EACjB,MAAM,QAA0C;EAChD,IAAI,CAAC,MAAM,aAAa,SAAS,MAAM,aAAa,UAAU;EAC9D,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;oCACd,MAAM,MAAM,qFAAS,KAAK,EAC1B,MAAM,sBAAsB,CAC7B;;GACD,UAAU,sBAAsB,M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,MAAM,UAAU,GAAG;IAIvD,IAAI,YAAY,GAAG;KACjB,IAAI,QACF,WAAW;KAGb,IAAI,WAAW,eACb,WAAW;KAGb,OAAO;;;GAGX,OAAO,KAAK,QAAQ,KAAK;IACzB;EAGF,WAAW,SAAS,QAAQ;GAC1B,eAAe,KAAK,IAAI;GACxB,IAAI,IAAI,QAAQ,QACd,IAAI,UAAU,SAAS,IAAI,QAAQ;IAErC;EAEF,OAAO;;CAGT,OAAO;EACL,MAAM,SAAS,kBAAkB,KAAK;EACtC,UAAU;EACV,UAAU,kBAAkB;EAC7B"}
1
+ {"version":3,"file":"createSortedRowModel.js","names":[],"sources":["../../../src/features/row-sorting/createSortedRowModel.ts"],"sourcesContent":["import { tableMemo } from '../../utils'\nimport { table_autoResetPageIndex } from '../row-pagination/rowPaginationFeature.utils'\nimport { column_getCanSort, column_getSortFn } from './rowSortingFeature.utils'\nimport type { Column_Internal } from '../../types/Column'\nimport type { TableFeatures } from '../../types/TableFeatures'\nimport type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'\nimport type { Table, Table_Internal } from '../../types/Table'\nimport type { Row } from '../../types/Row'\nimport type { SortFn, SortFns } from './rowSortingFeature.types'\nimport type { RowData } from '../../types/type-utils'\n\n/**\n * Creates a memoized sorted 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 createSortedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(\n sortFns: Record<keyof SortFns, SortFn<TFeatures, TData>>,\n): (table: Table<TFeatures, TData>) => () => RowModel<TFeatures, TData> {\n return (_table) => {\n const table: Table_Internal<TFeatures, TData> = _table\n if (!table._rowModelFns.sortFns) table._rowModelFns.sortFns = sortFns\n return tableMemo({\n feature: 'rowSortingFeature',\n table,\n fnName: 'table.getSortedRowModel',\n memoDeps: () => [\n table.atoms.sorting?.get(),\n table.getPreSortedRowModel(),\n ],\n fn: () => _createSortedRowModel(table),\n onAfterUpdate: () => table_autoResetPageIndex(table),\n })\n }\n}\n\nfunction _createSortedRowModel<\n TFeatures extends TableFeatures,\n TData extends RowData = any,\n>(table: Table_Internal<TFeatures, TData>): RowModel<TFeatures, TData> {\n const preSortedRowModel = table.getPreSortedRowModel()\n const sorting = table.atoms.sorting?.get()\n\n if (!preSortedRowModel.rows.length || !sorting?.length) {\n return preSortedRowModel\n }\n\n const sortedFlatRows: Array<Row<TFeatures, TData>> = []\n\n // Filter out sortings that correspond to non existing columns\n const availableSorting = sorting.filter((sort) =>\n column_getCanSort(\n table.getColumn(sort.id) as Column_Internal<TFeatures, TData>,\n ),\n )\n\n const columnInfoById: Record<\n string,\n {\n sortUndefined?: false | -1 | 1 | 'first' | 'last'\n invertSorting?: boolean\n sortFn: SortFn<TFeatures, TData>\n }\n > = {}\n\n availableSorting.forEach((sortEntry) => {\n const column: Column_Internal<TFeatures, TData> | undefined =\n table.getColumn(sortEntry.id)\n if (!column) return\n\n columnInfoById[sortEntry.id] = {\n sortUndefined: column.columnDef.sortUndefined,\n invertSorting: column.columnDef.invertSorting,\n sortFn: column_getSortFn(column),\n }\n })\n\n const sortData = (rows: Array<Row<TFeatures, TData>>) => {\n const sortedData = rows.slice()\n\n sortedData.sort((rowA, rowB) => {\n for (let i = 0; i < availableSorting.length; i++) {\n const sortEntry = availableSorting[i]!\n const columnInfo = columnInfoById[sortEntry.id]!\n const sortUndefined = columnInfo.sortUndefined\n const isDesc = sortEntry.desc\n\n let sortInt = 0\n\n // All sorting ints should always return in ascending order\n if (sortUndefined) {\n const aValue = rowA.getValue(sortEntry.id)\n const bValue = rowB.getValue(sortEntry.id)\n\n const aUndefined = aValue === undefined\n const bUndefined = bValue === undefined\n\n if (aUndefined || bUndefined) {\n if (sortUndefined === 'first') return aUndefined ? -1 : 1\n if (sortUndefined === 'last') return aUndefined ? 1 : -1\n sortInt =\n aUndefined && bUndefined\n ? 0\n : aUndefined\n ? sortUndefined\n : -sortUndefined\n }\n }\n\n if (sortInt === 0) {\n sortInt = columnInfo.sortFn(rowA, rowB, sortEntry.id)\n }\n\n // If sorting is non-zero, take care of desc and inversion\n if (sortInt !== 0) {\n if (isDesc) {\n sortInt *= -1\n }\n\n if (columnInfo.invertSorting) {\n sortInt *= -1\n }\n\n return sortInt\n }\n }\n return rowA.index - rowB.index\n })\n\n // If there are sub-rows, sort them. Clone only rows that need mutation\n // (i.e. have subRows) so we don't corrupt the source row model.\n for (let i = 0; i < sortedData.length; i++) {\n const row = sortedData[i]!\n if (row.subRows.length) {\n // Preserve prototype chain so methods like getValue() remain accessible\n const cloned = Object.create(Object.getPrototypeOf(row))\n Object.assign(cloned, row)\n cloned.subRows = sortData(row.subRows)\n sortedData[i] = cloned\n sortedFlatRows.push(cloned)\n } else {\n sortedFlatRows.push(row)\n }\n }\n\n return sortedData\n }\n\n return {\n rows: sortData(preSortedRowModel.rows),\n flatRows: sortedFlatRows,\n rowsById: preSortedRowModel.rowsById,\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,qBAId,SACsE;CACtE,QAAQ,WAAW;EACjB,MAAM,QAA0C;EAChD,IAAI,CAAC,MAAM,aAAa,SAAS,MAAM,aAAa,UAAU;EAC9D,OAAO,UAAU;GACf,SAAS;GACT;GACA,QAAQ;GACR,gBAAgB;;oCACd,MAAM,MAAM,qFAAS,KAAK,EAC1B,MAAM,sBAAsB,CAC7B;;GACD,UAAU,sBAAsB,MAAM;GACtC,qBAAqB,yBAAyB,MAAM;GACrD,CAAC;;;AAIN,SAAS,sBAGP,OAAqE;;CACrE,MAAM,oBAAoB,MAAM,sBAAsB;CACtD,MAAM,mCAAU,MAAM,MAAM,uFAAS,KAAK;CAE1C,IAAI,CAAC,kBAAkB,KAAK,UAAU,oDAAC,QAAS,SAC9C,OAAO;CAGT,MAAM,iBAA+C,EAAE;CAGvD,MAAM,mBAAmB,QAAQ,QAAQ,SACvC,kBACE,MAAM,UAAU,KAAK,GAAG,CACzB,CACF;CAED,MAAM,iBAOF,EAAE;CAEN,iBAAiB,SA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ChB,eAAe,KAAK,OAAO;UAE3B,eAAe,KAAK,IAAI;;EAI5B,OAAO;;CAGT,OAAO;EACL,MAAM,SAAS,kBAAkB,KAAK;EACtC,UAAU;EACV,UAAU,kBAAkB;EAC7B"}
@@ -84,7 +84,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
84
84
  */
85
85
  getFirstSortDir: () => SortDirection;
86
86
  /**
87
- * Returns the current sort direction of this column.
87
+ * Reads this column's current sort direction, or `false` when unsorted.
88
88
  */
89
89
  getIsSorted: () => false | SortDirection;
90
90
  /**
@@ -92,7 +92,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
92
92
  */
93
93
  getNextSortingOrder: () => SortDirection | false;
94
94
  /**
95
- * Returns the index position of this column's sorting within the sorting state
95
+ * Finds this column's position in the ordered sorting state.
96
96
  */
97
97
  getSortIndex: () => number;
98
98
  /**
@@ -100,7 +100,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
100
100
  */
101
101
  getSortFn: () => SortFn<TFeatures, TData>;
102
102
  /**
103
- * Returns a function that can be used to toggle this column's sorting state. This is useful for attaching a click handler to the column header.
103
+ * Creates a header/control handler that toggles this column's sorting state.
104
104
  */
105
105
  getToggleSortingHandler: () => undefined | ((event: unknown) => void);
106
106
  /**
@@ -110,7 +110,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
110
110
  }
111
111
  interface TableOptions_RowSorting {
112
112
  /**
113
- * Enables/disables the ability to remove multi-sorts
113
+ * Allows multi-sort toggles to remove a column from sorting state.
114
114
  */
115
115
  enableMultiRemove?: boolean;
116
116
  /**
@@ -152,21 +152,23 @@ interface TableOptions_RowSorting {
152
152
  }
153
153
  interface Table_RowSorting<TFeatures extends TableFeatures, TData extends RowData> {
154
154
  /**
155
- * Resets the **sorting** state to `initialState.sorting`, or `true` can be passed to force a default blank state reset to `[]`.
155
+ * Resets `sorting` to `initialState.sorting`.
156
+ *
157
+ * Pass `true` to ignore initial state and reset to `[]`.
156
158
  */
157
159
  resetSorting: (defaultState?: boolean) => void;
158
160
  /**
159
- * Sets sorting state using a value or updater.
161
+ * Updates sorting state with a next ordered array or updater function.
160
162
  */
161
163
  setSorting: (updater: Updater<SortingState>) => void;
162
164
  }
163
165
  interface Table_RowModels_Sorted<TFeatures extends TableFeatures, TData extends RowData> {
164
166
  /**
165
- * Returns the row model for the table before any sorting has been applied.
167
+ * Reads the row model immediately before sorting.
166
168
  */
167
169
  getPreSortedRowModel: () => RowModel<TFeatures, TData>;
168
170
  /**
169
- * Returns the row model for the table after sorting has been applied.
171
+ * Resolves the row model after sorting has been applied.
170
172
  */
171
173
  getSortedRowModel: () => RowModel<TFeatures, TData>;
172
174
  }
@@ -84,7 +84,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
84
84
  */
85
85
  getFirstSortDir: () => SortDirection;
86
86
  /**
87
- * Returns the current sort direction of this column.
87
+ * Reads this column's current sort direction, or `false` when unsorted.
88
88
  */
89
89
  getIsSorted: () => false | SortDirection;
90
90
  /**
@@ -92,7 +92,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
92
92
  */
93
93
  getNextSortingOrder: () => SortDirection | false;
94
94
  /**
95
- * Returns the index position of this column's sorting within the sorting state
95
+ * Finds this column's position in the ordered sorting state.
96
96
  */
97
97
  getSortIndex: () => number;
98
98
  /**
@@ -100,7 +100,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
100
100
  */
101
101
  getSortFn: () => SortFn<TFeatures, TData>;
102
102
  /**
103
- * Returns a function that can be used to toggle this column's sorting state. This is useful for attaching a click handler to the column header.
103
+ * Creates a header/control handler that toggles this column's sorting state.
104
104
  */
105
105
  getToggleSortingHandler: () => undefined | ((event: unknown) => void);
106
106
  /**
@@ -110,7 +110,7 @@ interface Column_RowSorting<TFeatures extends TableFeatures, TData extends RowDa
110
110
  }
111
111
  interface TableOptions_RowSorting {
112
112
  /**
113
- * Enables/disables the ability to remove multi-sorts
113
+ * Allows multi-sort toggles to remove a column from sorting state.
114
114
  */
115
115
  enableMultiRemove?: boolean;
116
116
  /**
@@ -152,21 +152,23 @@ interface TableOptions_RowSorting {
152
152
  }
153
153
  interface Table_RowSorting<TFeatures extends TableFeatures, TData extends RowData> {
154
154
  /**
155
- * Resets the **sorting** state to `initialState.sorting`, or `true` can be passed to force a default blank state reset to `[]`.
155
+ * Resets `sorting` to `initialState.sorting`.
156
+ *
157
+ * Pass `true` to ignore initial state and reset to `[]`.
156
158
  */
157
159
  resetSorting: (defaultState?: boolean) => void;
158
160
  /**
159
- * Sets sorting state using a value or updater.
161
+ * Updates sorting state with a next ordered array or updater function.
160
162
  */
161
163
  setSorting: (updater: Updater<SortingState>) => void;
162
164
  }
163
165
  interface Table_RowModels_Sorted<TFeatures extends TableFeatures, TData extends RowData> {
164
166
  /**
165
- * Returns the row model for the table before any sorting has been applied.
167
+ * Reads the row model immediately before sorting.
166
168
  */
167
169
  getPreSortedRowModel: () => RowModel<TFeatures, TData>;
168
170
  /**
169
- * Returns the row model for the table after sorting has been applied.
171
+ * Resolves the row model after sorting has been applied.
170
172
  */
171
173
  getSortedRowModel: () => RowModel<TFeatures, TData>;
172
174
  }
@@ -3,26 +3,28 @@ const require_sortFns = require('../../fns/sortFns.cjs');
3
3
 
4
4
  //#region src/features/row-sorting/rowSortingFeature.utils.ts
5
5
  /**
6
- * Returns the default sorting state.
6
+ * Creates the default sorting state.
7
7
  *
8
- * Feature constructors use this value to initialize the table state or option defaults when no user value is provided.
8
+ * The feature default is an empty array, meaning no columns are sorted. Reset
9
+ * APIs use this value when `defaultState` is `true`.
9
10
  *
10
11
  * @example
11
12
  * ```ts
12
- * const initialValue = getDefaultSortingState()
13
+ * const sorting = getDefaultSortingState()
13
14
  * ```
14
15
  */
15
16
  function getDefaultSortingState() {
16
17
  return [];
17
18
  }
18
19
  /**
19
- * Updates the table's sorting state slice.
20
+ * Routes a sorting updater through the table's sorting change handler.
20
21
  *
21
- * The updater follows TanStack Table updater semantics and is routed through the corresponding `on*Change` option or backing atom.
22
+ * The updater may be a next `SortingState` array or a function of the previous
23
+ * sorting state, matching the instance `table.setSorting` behavior.
22
24
  *
23
25
  * @example
24
26
  * ```ts
25
- * table_setSorting(table, (old) => old)
27
+ * table_setSorting(table, (old) => [...old, { id: 'age', desc: true }])
26
28
  * ```
27
29
  */
28
30
  function table_setSorting(table, updater) {
@@ -30,9 +32,10 @@ function table_setSorting(table, updater) {
30
32
  (_table$options$onSort = (_table$options = table.options).onSortingChange) === null || _table$options$onSort === void 0 || _table$options$onSort.call(_table$options, updater);
31
33
  }
32
34
  /**
33
- * Resets the table's sorting state slice.
35
+ * Resets `sorting` to the configured initial state or feature default.
34
36
  *
35
- * By default the reset uses `table.initialState`; when supported, a blank/default reset bypasses the saved initial value.
37
+ * With no argument, the reset clones `table.initialState.sorting` when it
38
+ * exists. Passing `true` ignores initial state and resets to `[]`.
36
39
  *
37
40
  * @example
38
41
  * ```ts
@@ -44,13 +47,15 @@ function table_resetSorting(table, defaultState) {
44
47
  table_setSorting(table, defaultState ? [] : require_utils.cloneState(table.initialState.sorting ?? []));
45
48
  }
46
49
  /**
47
- * Infers sort fn for a column.
50
+ * Chooses a built-in sorting function from sampled filtered row values.
48
51
  *
49
- * The inference uses the column definition, table options, and sampled row values when needed.
52
+ * Date-like values use `datetime`, mixed text/numeric strings use
53
+ * `alphanumeric`, plain strings use `text`, and unknown values fall back to
54
+ * `basic`.
50
55
  *
51
56
  * @example
52
57
  * ```ts
53
- * const value = column_getAutoSortFn(column)
58
+ * const sortFn = column_getAutoSortFn(column)
54
59
  * ```
55
60
  */
56
61
  function column_getAutoSortFn(column) {
@@ -58,8 +63,8 @@ function column_getAutoSortFn(column) {
58
63
  let sortFn;
59
64
  const firstRows = column.table.getFilteredRowModel().flatRows.slice(10);
60
65
  let isString = false;
61
- for (const row of firstRows) {
62
- const value = row.getValue(column.id);
66
+ for (let i = 0; i < firstRows.length; i++) {
67
+ const value = firstRows[i].getValue(column.id);
63
68
  if (Object.prototype.toString.call(value) === "[object Date]") sortFn = sortFns === null || sortFns === void 0 ? void 0 : sortFns.datetime;
64
69
  if (typeof value === "string") {
65
70
  isString = true;
@@ -70,13 +75,14 @@ function column_getAutoSortFn(column) {
70
75
  return sortFn ?? require_sortFns.sortFn_basic;
71
76
  }
72
77
  /**
73
- * Infers sort dir for a column.
78
+ * Chooses the default first sort direction from the first filtered row value.
74
79
  *
75
- * The inference uses the column definition, table options, and sampled row values when needed.
80
+ * String columns start ascending so alphabetical order is natural; other value
81
+ * types start descending.
76
82
  *
77
83
  * @example
78
84
  * ```ts
79
- * const value = column_getAutoSortDir(column)
85
+ * const direction = column_getAutoSortDir(column)
80
86
  * ```
81
87
  */
82
88
  function column_getAutoSortDir(column) {
@@ -85,13 +91,15 @@ function column_getAutoSortDir(column) {
85
91
  return "desc";
86
92
  }
87
93
  /**
88
- * Returns sort fn for a column.
94
+ * Resolves the sorting function configured for a column.
89
95
  *
90
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
96
+ * Function-valued `columnDef.sortFn` is returned directly, `'auto'` delegates
97
+ * to `column_getAutoSortFn`, and string values are looked up in the table's
98
+ * sorting function registry before falling back to `basic`.
91
99
  *
92
100
  * @example
93
101
  * ```ts
94
- * const value = column_getSortFn(column)
102
+ * const sortFn = column_getSortFn(column)
95
103
  * ```
96
104
  */
97
105
  function column_getSortFn(column) {
@@ -99,13 +107,15 @@ function column_getSortFn(column) {
99
107
  return require_utils.isFunction(column.columnDef.sortFn) ? column.columnDef.sortFn : column.columnDef.sortFn === "auto" ? column_getAutoSortFn(column) : (sortFns === null || sortFns === void 0 ? void 0 : sortFns[column.columnDef.sortFn]) ?? require_sortFns.sortFn_basic;
100
108
  }
101
109
  /**
102
- * Toggles sorting for a column.
110
+ * Applies the next sorting state for this column.
103
111
  *
104
- * The update is applied through the owning table state slice and respects the feature options for that column.
112
+ * The toggle can add, replace, flip, or remove this column's sort entry. Multi
113
+ * sorting respects `enableMultiSort`, `maxMultiSortColCount`, and the `multi`
114
+ * argument.
105
115
  *
106
116
  * @example
107
117
  * ```ts
108
- * column_toggleSorting(column)
118
+ * column_toggleSorting(column, undefined, true)
109
119
  * ```
110
120
  */
111
121
  function column_toggleSorting(column, desc, multi) {
@@ -149,26 +159,28 @@ function column_toggleSorting(column, desc, multi) {
149
159
  });
150
160
  }
151
161
  /**
152
- * Returns first sort dir for a column.
162
+ * Resolves the first direction used when this column begins sorting.
153
163
  *
154
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
164
+ * Column-level `sortDescFirst` wins, then table-level `sortDescFirst`, then the
165
+ * auto direction inferred from sampled values.
155
166
  *
156
167
  * @example
157
168
  * ```ts
158
- * const value = column_getFirstSortDir(column)
169
+ * const firstDirection = column_getFirstSortDir(column)
159
170
  * ```
160
171
  */
161
172
  function column_getFirstSortDir(column) {
162
173
  return column.columnDef.sortDescFirst ?? column.table.options.sortDescFirst ?? column_getAutoSortDir(column) === "desc" ? "desc" : "asc";
163
174
  }
164
175
  /**
165
- * Returns next sorting order for a column.
176
+ * Resolves the next sort order for this column's toggle cycle.
166
177
  *
167
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
178
+ * The cycle starts with the first sort direction, flips between `asc` and
179
+ * `desc`, and can return `false` when sorting removal is enabled.
168
180
  *
169
181
  * @example
170
182
  * ```ts
171
- * const value = column_getNextSortingOrder(column)
183
+ * const nextOrder = column_getNextSortingOrder(column)
172
184
  * ```
173
185
  */
174
186
  function column_getNextSortingOrder(column, multi) {
@@ -179,39 +191,42 @@ function column_getNextSortingOrder(column, multi) {
179
191
  return isSorted === "desc" ? "asc" : "desc";
180
192
  }
181
193
  /**
182
- * Returns whether a column can use sort.
194
+ * Checks whether this accessor column can participate in sorting.
183
195
  *
184
- * This combines column options, table options, and any required accessor or feature state for the capability.
196
+ * The column must have an accessor and sorting must be enabled by both the
197
+ * column definition and table options.
185
198
  *
186
199
  * @example
187
200
  * ```ts
188
- * const value = column_getCanSort(column)
201
+ * const canSort = column_getCanSort(column)
189
202
  * ```
190
203
  */
191
204
  function column_getCanSort(column) {
192
205
  return (column.columnDef.enableSorting ?? true) && (column.table.options.enableSorting ?? true) && !!column.accessorFn;
193
206
  }
194
207
  /**
195
- * Returns whether a column can use multi sort.
208
+ * Checks whether this column can be added to a multi-sort state.
196
209
  *
197
- * This combines column options, table options, and any required accessor or feature state for the capability.
210
+ * Column-level `enableMultiSort` wins over table-level `enableMultiSort`; if
211
+ * neither is set, accessor columns can multi-sort by default.
198
212
  *
199
213
  * @example
200
214
  * ```ts
201
- * const value = column_getCanMultiSort(column)
215
+ * const canMultiSort = column_getCanMultiSort(column)
202
216
  * ```
203
217
  */
204
218
  function column_getCanMultiSort(column) {
205
219
  return column.columnDef.enableMultiSort ?? column.table.options.enableMultiSort ?? !!column.accessorFn;
206
220
  }
207
221
  /**
208
- * Returns is sorted for a column.
222
+ * Reads this column's current sort direction.
209
223
  *
210
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
224
+ * The result is `false` when the column is not sorted, otherwise `'asc'` or
225
+ * `'desc'` based on the column's entry in `state.sorting`.
211
226
  *
212
227
  * @example
213
228
  * ```ts
214
- * const value = column_getIsSorted(column)
229
+ * const direction = column_getIsSorted(column)
215
230
  * ```
216
231
  */
217
232
  function column_getIsSorted(column) {
@@ -220,13 +235,13 @@ function column_getIsSorted(column) {
220
235
  return !columnSort ? false : columnSort.desc ? "desc" : "asc";
221
236
  }
222
237
  /**
223
- * Returns sort index for a column.
238
+ * Finds this column's position in the ordered `state.sorting` array.
224
239
  *
225
- * This derives the value from the column definition, table options, and the feature state atoms registered on the table.
240
+ * The result is `-1` when the column is not sorted.
226
241
  *
227
242
  * @example
228
243
  * ```ts
229
- * const value = column_getSortIndex(column)
244
+ * const index = column_getSortIndex(column)
230
245
  * ```
231
246
  */
232
247
  function column_getSortIndex(column) {
@@ -234,26 +249,28 @@ function column_getSortIndex(column) {
234
249
  return ((_column$table$atoms$s2 = column.table.atoms.sorting) === null || _column$table$atoms$s2 === void 0 || (_column$table$atoms$s2 = _column$table$atoms$s2.get()) === null || _column$table$atoms$s2 === void 0 ? void 0 : _column$table$atoms$s2.findIndex((d) => d.id === column.id)) ?? -1;
235
250
  }
236
251
  /**
237
- * Clear Sorting. for a column.
252
+ * Removes this column from the sorting state.
238
253
  *
239
- * This is the static implementation behind the matching column instance API.
254
+ * Other sorted columns are preserved, including their relative order.
240
255
  *
241
256
  * @example
242
257
  * ```ts
243
- * const value = column_clearSorting(column)
258
+ * column_clearSorting(column)
244
259
  * ```
245
260
  */
246
261
  function column_clearSorting(column) {
247
262
  table_setSorting(column.table, (old) => old.length ? old.filter((d) => d.id !== column.id) : []);
248
263
  }
249
264
  /**
250
- * Returns an event handler for toggling sorting handler.
265
+ * Creates a header event handler that toggles this column's sorting.
251
266
  *
252
- * The handler is intended for direct use in column header controls such as buttons or checkboxes.
267
+ * The handler ignores events when the column cannot sort, persists React-style
268
+ * synthetic events when present, and asks `options.isMultiSortEvent` whether
269
+ * the event should add to a multi-sort.
253
270
  *
254
271
  * @example
255
272
  * ```ts
256
- * const value = column_getToggleSortingHandler(column)
273
+ * const onClick = column_getToggleSortingHandler(column)
257
274
  * ```
258
275
  */
259
276
  function column_getToggleSortingHandler(column) {
@@ -1 +1 @@
1
- {"version":3,"file":"rowSortingFeature.utils.cjs","names":["cloneState","reSplitAlphaNumeric","sortFn_basic","isFunction"],"sources":["../../../src/features/row-sorting/rowSortingFeature.utils.ts"],"sourcesContent":["import { reSplitAlphaNumeric, sortFn_basic } from '../../fns/sortFns'\nimport { cloneState, 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 SortDirection,\n SortFn,\n SortingState,\n} from './rowSortingFeature.types'\n\n// State Utils\n\n/**\n * Returns the default sorting 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 = getDefaultSortingState()\n * ```\n */\nexport function getDefaultSortingState(): SortingState {\n return []\n}\n\n/**\n * Updates the table's sorting 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_setSorting(table, (old) => old)\n * ```\n */\nexport function table_setSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<SortingState>) {\n table.options.onSortingChange?.(updater)\n}\n\n/**\n * Resets the table's sorting 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_resetSorting(table)\n * table_resetSorting(table, true)\n * ```\n */\nexport function table_resetSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setSorting(\n table,\n defaultState ? [] : cloneState(table.initialState.sorting ?? []),\n )\n}\n\n// Column Utils\n\n/**\n * Infers sort 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_getAutoSortFn(column)\n * ```\n */\nexport function column_getAutoSortFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {\n const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.sortFns\n\n let sortFn: SortFn<TFeatures, TData> | undefined\n\n const firstRows = column.table.getFilteredRowModel().flatRows.slice(10)\n\n let isString = false\n\n for (const row of firstRows) {\n const value = row.getValue(column.id)\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n sortFn = sortFns?.datetime\n }\n\n if (typeof value === 'string') {\n isString = true\n\n if (value.split(reSplitAlphaNumeric).length > 1) {\n sortFn = sortFns?.alphanumeric\n }\n }\n }\n\n if (isString) {\n sortFn = sortFns?.text\n }\n\n return sortFn ?? sortFn_basic\n}\n\n/**\n * Infers sort dir 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_getAutoSortDir(column)\n * ```\n */\nexport function column_getAutoSortDir<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const firstRow = column.table.getFilteredRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return 'asc'\n }\n\n return 'desc'\n}\n\n/**\n * Returns sort 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_getSortFn(column)\n * ```\n */\nexport function column_getSortFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {\n const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.sortFns\n\n return isFunction(column.columnDef.sortFn)\n ? column.columnDef.sortFn\n : column.columnDef.sortFn === 'auto'\n ? column_getAutoSortFn(column)\n : (sortFns?.[column.columnDef.sortFn as string] ?? sortFn_basic)\n}\n\n/**\n * Toggles sorting for a column.\n *\n * The update is applied through the owning table state slice and respects the feature options for that column.\n *\n * @example\n * ```ts\n * column_toggleSorting(column)\n * ```\n */\nexport function column_toggleSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n desc?: boolean,\n multi?: boolean,\n) {\n // if (column.columns.length) {\n // column.columns.forEach((c, i) => {\n // if (c.id) {\n // table.toggleColumnSorting(c.id, undefined, multi || !!i)\n // }\n // })\n // return\n // }\n\n // this needs to be outside of table.setSorting to be in sync with rerender\n const nextSortingOrder = column_getNextSortingOrder(column)\n const hasManualValue = typeof desc !== 'undefined'\n\n table_setSorting(column.table, (old) => {\n // Find any existing sorting for this column\n const existingSorting = old.find((d) => d.id === column.id)\n const existingIndex = old.findIndex((d) => d.id === column.id)\n\n let newSorting: SortingState = []\n\n // What should we do with this sort action?\n let sortAction: 'add' | 'remove' | 'toggle' | 'replace'\n const nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'\n\n // Multi-mode\n if (old.length && column_getCanMultiSort(column) && multi) {\n if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'add'\n }\n } else {\n // Normal mode\n if (old.length && existingIndex !== old.length - 1) {\n sortAction = 'replace'\n } else if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'replace'\n }\n }\n\n // Handle toggle states that will remove the sorting\n if (sortAction === 'toggle') {\n // If we are \"actually\" toggling (not a manual set value), should we remove the sorting?\n if (!hasManualValue) {\n // Is our intention to remove?\n if (!nextSortingOrder) {\n sortAction = 'remove'\n }\n }\n }\n\n if (sortAction === 'add') {\n newSorting = [\n ...old,\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n // Take latest n columns\n newSorting.splice(\n 0,\n newSorting.length -\n (column.table.options.maxMultiSortColCount ??\n Number.MAX_SAFE_INTEGER),\n )\n } else if (sortAction === 'toggle') {\n // This flips (or sets) the\n newSorting = old.map((d) => {\n if (d.id === column.id) {\n return {\n ...d,\n desc: nextDesc,\n }\n }\n return d\n })\n } else if (sortAction === 'remove') {\n newSorting = old.filter((d) => d.id !== column.id)\n } else {\n newSorting = [\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n }\n\n return newSorting\n })\n}\n\n/**\n * Returns first sort dir 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_getFirstSortDir(column)\n * ```\n */\nexport function column_getFirstSortDir<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const sortDescFirst =\n column.columnDef.sortDescFirst ??\n column.table.options.sortDescFirst ??\n column_getAutoSortDir(column) === 'desc'\n return sortDescFirst ? 'desc' : 'asc'\n}\n\n/**\n * Returns next sorting order 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_getNextSortingOrder(column)\n * ```\n */\nexport function column_getNextSortingOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, multi?: boolean) {\n const firstSortDirection = column_getFirstSortDir(column)\n const isSorted = column_getIsSorted(column)\n\n if (!isSorted) {\n return firstSortDirection\n }\n\n if (\n isSorted !== firstSortDirection &&\n (column.table.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general\n (multi ? (column.table.options.enableMultiRemove ?? true) : true) // If multi, don't allow if enableMultiRemove))\n ) {\n return false\n }\n return isSorted === 'desc' ? 'asc' : 'desc'\n}\n\n/**\n * Returns whether a column can use sort.\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_getCanSort(column)\n * ```\n */\nexport function column_getCanSort<\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.enableSorting ?? true) &&\n (column.table.options.enableSorting ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Returns whether a column can use multi sort.\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_getCanMultiSort(column)\n * ```\n */\nexport function column_getCanMultiSort<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return (\n column.columnDef.enableMultiSort ??\n column.table.options.enableMultiSort ??\n !!column.accessorFn\n )\n}\n\n/**\n * Returns is sorted 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_getIsSorted(column)\n * ```\n */\nexport function column_getIsSorted<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): false | SortDirection {\n const columnSort = column.table.atoms.sorting\n ?.get()\n ?.find((d) => d.id === column.id)\n return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'\n}\n\n/**\n * Returns sort 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_getSortIndex(column)\n * ```\n */\nexport function column_getSortIndex<\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.sorting?.get()?.findIndex((d) => d.id === column.id) ??\n -1\n )\n}\n\n/**\n * Clear Sorting. for a column.\n *\n * This is the static implementation behind the matching column instance API.\n *\n * @example\n * ```ts\n * const value = column_clearSorting(column)\n * ```\n */\nexport function column_clearSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n // clear sorting for just 1 column\n table_setSorting(column.table, (old) =>\n old.length ? old.filter((d) => d.id !== column.id) : [],\n )\n}\n\n/**\n * Returns an event handler for toggling sorting handler.\n *\n * The handler is intended for direct use in column header controls such as buttons or checkboxes.\n *\n * @example\n * ```ts\n * const value = column_getToggleSortingHandler(column)\n * ```\n */\nexport function column_getToggleSortingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canSort = column_getCanSort(column)\n\n return (e: unknown) => {\n if (!canSort) return\n ;(e as any).persist?.()\n column_toggleSorting(\n column,\n\n undefined,\n column_getCanMultiSort(column)\n ? column.table.options.isMultiSortEvent?.(e)\n : false,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,yBAAuC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M,QAAQ,wBAAwB,UAC7C,QAAS,OAAO,MAAM,QAAQ,qBAAqB,OAAQ,OAE5D,OAAO;CAET,OAAO,aAAa,SAAS,QAAQ;;;;;;;;;;;;AAavC,SAAgB,kBAId,QAAmD;CACnD,QACG,OAAO,UAAU,iBAAiB,UAClC,OAAO,MAAM,QAAQ,iBAAiB,SACvC,CAAC,CAAC,OAAO;;;;;;;;;;;;AAcb,SAAgB,uBAId,QAA4D;CAC5D,OACE,OAAO,UAAU,mBACjB,OAAO,MAAM,QAAQ,mBACrB,CAAC,CAAC,OAAO;;;;;;;;;;;;AAcb,SAAgB,mBAId,QAA0E;;CAC1E,MAAM,sCAAa,OAAO,MAAM,MAAM,wGAClC,KAAK,gFACL,MAAM,MAAM,EAAE,OAAO,OAAO,GAAG;CACnC,OAAO,CAAC,aAAa,QAAQ,WAAW,OAAO,SAAS;;;;;;;;;;;;AAa1D,SAAgB,oBAId,QAA2D;;CAC3D,kCACE,OAAO,MAAM,MAAM,2GAAS,KAAK,kFAAE,WAAW,MAAM,EAAE,OAAO,OAAO,GAAG,KACvE;;;;;;;;;;;;AAcJ,SAAgB,oBAId,QAAmD;CAEnD,iBAAiB,OAAO,QAAQ,QAC9B,IAAI,SAAS,IAAI,QAAQ,MAAM,EAAE,OAAO,OAAO,GAAG,GAAG,EAAE,CACxD;;;;;;;;;;;;AAaH,SAAgB,+BAId,QAAmD;CACnD,MAAM,UAAU,kBAAkB,OAAO;CAEzC,QAAQ,MAAe;;EACrB,IAAI,CAAC,SAAS;EACb,YAAC,EAAU,4DAAW;EACvB,qBACE,QAEA,QACA,uBAAuB,OAAO,sDAC1B,OAAO,MAAM,SAAQ,6HAAmB,EAAE,GAC1C,MACL"}
1
+ {"version":3,"file":"rowSortingFeature.utils.cjs","names":["cloneState","reSplitAlphaNumeric","sortFn_basic","isFunction"],"sources":["../../../src/features/row-sorting/rowSortingFeature.utils.ts"],"sourcesContent":["import { reSplitAlphaNumeric, sortFn_basic } from '../../fns/sortFns'\nimport { cloneState, 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 SortDirection,\n SortFn,\n SortingState,\n} from './rowSortingFeature.types'\n\n// State Utils\n\n/**\n * Creates the default sorting state.\n *\n * The feature default is an empty array, meaning no columns are sorted. Reset\n * APIs use this value when `defaultState` is `true`.\n *\n * @example\n * ```ts\n * const sorting = getDefaultSortingState()\n * ```\n */\nexport function getDefaultSortingState(): SortingState {\n return []\n}\n\n/**\n * Routes a sorting updater through the table's sorting change handler.\n *\n * The updater may be a next `SortingState` array or a function of the previous\n * sorting state, matching the instance `table.setSorting` behavior.\n *\n * @example\n * ```ts\n * table_setSorting(table, (old) => [...old, { id: 'age', desc: true }])\n * ```\n */\nexport function table_setSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, updater: Updater<SortingState>) {\n table.options.onSortingChange?.(updater)\n}\n\n/**\n * Resets `sorting` to the configured initial state or feature default.\n *\n * With no argument, the reset clones `table.initialState.sorting` when it\n * exists. Passing `true` ignores initial state and resets to `[]`.\n *\n * @example\n * ```ts\n * table_resetSorting(table)\n * table_resetSorting(table, true)\n * ```\n */\nexport function table_resetSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n>(table: Table_Internal<TFeatures, TData>, defaultState?: boolean) {\n table_setSorting(\n table,\n defaultState ? [] : cloneState(table.initialState.sorting ?? []),\n )\n}\n\n// Column Utils\n\n/**\n * Chooses a built-in sorting function from sampled filtered row values.\n *\n * Date-like values use `datetime`, mixed text/numeric strings use\n * `alphanumeric`, plain strings use `text`, and unknown values fall back to\n * `basic`.\n *\n * @example\n * ```ts\n * const sortFn = column_getAutoSortFn(column)\n * ```\n */\nexport function column_getAutoSortFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {\n const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.sortFns\n\n let sortFn: SortFn<TFeatures, TData> | undefined\n\n const firstRows = column.table.getFilteredRowModel().flatRows.slice(10)\n\n let isString = false\n\n for (let i = 0; i < firstRows.length; i++) {\n const value = firstRows[i]!.getValue(column.id)\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n sortFn = sortFns?.datetime\n }\n\n if (typeof value === 'string') {\n isString = true\n\n if (value.split(reSplitAlphaNumeric).length > 1) {\n sortFn = sortFns?.alphanumeric\n }\n }\n }\n\n if (isString) {\n sortFn = sortFns?.text\n }\n\n return sortFn ?? sortFn_basic\n}\n\n/**\n * Chooses the default first sort direction from the first filtered row value.\n *\n * String columns start ascending so alphabetical order is natural; other value\n * types start descending.\n *\n * @example\n * ```ts\n * const direction = column_getAutoSortDir(column)\n * ```\n */\nexport function column_getAutoSortDir<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const firstRow = column.table.getFilteredRowModel().flatRows[0]\n\n const value = firstRow ? firstRow.getValue(column.id) : undefined\n\n if (typeof value === 'string') {\n return 'asc'\n }\n\n return 'desc'\n}\n\n/**\n * Resolves the sorting function configured for a column.\n *\n * Function-valued `columnDef.sortFn` is returned directly, `'auto'` delegates\n * to `column_getAutoSortFn`, and string values are looked up in the table's\n * sorting function registry before falling back to `basic`.\n *\n * @example\n * ```ts\n * const sortFn = column_getSortFn(column)\n * ```\n */\nexport function column_getSortFn<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {\n const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =\n column.table._rowModelFns.sortFns\n\n return isFunction(column.columnDef.sortFn)\n ? column.columnDef.sortFn\n : column.columnDef.sortFn === 'auto'\n ? column_getAutoSortFn(column)\n : (sortFns?.[column.columnDef.sortFn as string] ?? sortFn_basic)\n}\n\n/**\n * Applies the next sorting state for this column.\n *\n * The toggle can add, replace, flip, or remove this column's sort entry. Multi\n * sorting respects `enableMultiSort`, `maxMultiSortColCount`, and the `multi`\n * argument.\n *\n * @example\n * ```ts\n * column_toggleSorting(column, undefined, true)\n * ```\n */\nexport function column_toggleSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(\n column: Column_Internal<TFeatures, TData, TValue>,\n desc?: boolean,\n multi?: boolean,\n) {\n // if (column.columns.length) {\n // column.columns.forEach((c, i) => {\n // if (c.id) {\n // table.toggleColumnSorting(c.id, undefined, multi || !!i)\n // }\n // })\n // return\n // }\n\n // this needs to be outside of table.setSorting to be in sync with rerender\n const nextSortingOrder = column_getNextSortingOrder(column)\n const hasManualValue = typeof desc !== 'undefined'\n\n table_setSorting(column.table, (old) => {\n // Find any existing sorting for this column\n const existingSorting = old.find((d) => d.id === column.id)\n const existingIndex = old.findIndex((d) => d.id === column.id)\n\n let newSorting: SortingState = []\n\n // What should we do with this sort action?\n let sortAction: 'add' | 'remove' | 'toggle' | 'replace'\n const nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'\n\n // Multi-mode\n if (old.length && column_getCanMultiSort(column) && multi) {\n if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'add'\n }\n } else {\n // Normal mode\n if (old.length && existingIndex !== old.length - 1) {\n sortAction = 'replace'\n } else if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'replace'\n }\n }\n\n // Handle toggle states that will remove the sorting\n if (sortAction === 'toggle') {\n // If we are \"actually\" toggling (not a manual set value), should we remove the sorting?\n if (!hasManualValue) {\n // Is our intention to remove?\n if (!nextSortingOrder) {\n sortAction = 'remove'\n }\n }\n }\n\n if (sortAction === 'add') {\n newSorting = [\n ...old,\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n // Take latest n columns\n newSorting.splice(\n 0,\n newSorting.length -\n (column.table.options.maxMultiSortColCount ??\n Number.MAX_SAFE_INTEGER),\n )\n } else if (sortAction === 'toggle') {\n // This flips (or sets) the\n newSorting = old.map((d) => {\n if (d.id === column.id) {\n return {\n ...d,\n desc: nextDesc,\n }\n }\n return d\n })\n } else if (sortAction === 'remove') {\n newSorting = old.filter((d) => d.id !== column.id)\n } else {\n newSorting = [\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n }\n\n return newSorting\n })\n}\n\n/**\n * Resolves the first direction used when this column begins sorting.\n *\n * Column-level `sortDescFirst` wins, then table-level `sortDescFirst`, then the\n * auto direction inferred from sampled values.\n *\n * @example\n * ```ts\n * const firstDirection = column_getFirstSortDir(column)\n * ```\n */\nexport function column_getFirstSortDir<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const sortDescFirst =\n column.columnDef.sortDescFirst ??\n column.table.options.sortDescFirst ??\n column_getAutoSortDir(column) === 'desc'\n return sortDescFirst ? 'desc' : 'asc'\n}\n\n/**\n * Resolves the next sort order for this column's toggle cycle.\n *\n * The cycle starts with the first sort direction, flips between `asc` and\n * `desc`, and can return `false` when sorting removal is enabled.\n *\n * @example\n * ```ts\n * const nextOrder = column_getNextSortingOrder(column)\n * ```\n */\nexport function column_getNextSortingOrder<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>, multi?: boolean) {\n const firstSortDirection = column_getFirstSortDir(column)\n const isSorted = column_getIsSorted(column)\n\n if (!isSorted) {\n return firstSortDirection\n }\n\n if (\n isSorted !== firstSortDirection &&\n (column.table.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general\n (multi ? (column.table.options.enableMultiRemove ?? true) : true) // If multi, don't allow if enableMultiRemove))\n ) {\n return false\n }\n return isSorted === 'desc' ? 'asc' : 'desc'\n}\n\n/**\n * Checks whether this accessor column can participate in sorting.\n *\n * The column must have an accessor and sorting must be enabled by both the\n * column definition and table options.\n *\n * @example\n * ```ts\n * const canSort = column_getCanSort(column)\n * ```\n */\nexport function column_getCanSort<\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.enableSorting ?? true) &&\n (column.table.options.enableSorting ?? true) &&\n !!column.accessorFn\n )\n}\n\n/**\n * Checks whether this column can be added to a multi-sort state.\n *\n * Column-level `enableMultiSort` wins over table-level `enableMultiSort`; if\n * neither is set, accessor columns can multi-sort by default.\n *\n * @example\n * ```ts\n * const canMultiSort = column_getCanMultiSort(column)\n * ```\n */\nexport function column_getCanMultiSort<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): boolean {\n return (\n column.columnDef.enableMultiSort ??\n column.table.options.enableMultiSort ??\n !!column.accessorFn\n )\n}\n\n/**\n * Reads this column's current sort direction.\n *\n * The result is `false` when the column is not sorted, otherwise `'asc'` or\n * `'desc'` based on the column's entry in `state.sorting`.\n *\n * @example\n * ```ts\n * const direction = column_getIsSorted(column)\n * ```\n */\nexport function column_getIsSorted<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): false | SortDirection {\n const columnSort = column.table.atoms.sorting\n ?.get()\n ?.find((d) => d.id === column.id)\n return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'\n}\n\n/**\n * Finds this column's position in the ordered `state.sorting` array.\n *\n * The result is `-1` when the column is not sorted.\n *\n * @example\n * ```ts\n * const index = column_getSortIndex(column)\n * ```\n */\nexport function column_getSortIndex<\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.sorting?.get()?.findIndex((d) => d.id === column.id) ??\n -1\n )\n}\n\n/**\n * Removes this column from the sorting state.\n *\n * Other sorted columns are preserved, including their relative order.\n *\n * @example\n * ```ts\n * column_clearSorting(column)\n * ```\n */\nexport function column_clearSorting<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n // clear sorting for just 1 column\n table_setSorting(column.table, (old) =>\n old.length ? old.filter((d) => d.id !== column.id) : [],\n )\n}\n\n/**\n * Creates a header event handler that toggles this column's sorting.\n *\n * The handler ignores events when the column cannot sort, persists React-style\n * synthetic events when present, and asks `options.isMultiSortEvent` whether\n * the event should add to a multi-sort.\n *\n * @example\n * ```ts\n * const onClick = column_getToggleSortingHandler(column)\n * ```\n */\nexport function column_getToggleSortingHandler<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>) {\n const canSort = column_getCanSort(column)\n\n return (e: unknown) => {\n if (!canSort) return\n ;(e as any).persist?.()\n column_toggleSorting(\n column,\n\n undefined,\n column_getCanMultiSort(column)\n ? column.table.options.isMultiSortEvent?.(e)\n : false,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyBA,SAAgB,yBAAuC;CACrD,OAAO,EAAE;;;;;;;;;;;;;AAcX,SAAgB,iBAGd,OAAyC,SAAgC;;CACzE,iDAAM,SAAQ,4GAAkB,QAAQ;;;;;;;;;;;;;;AAe1C,SAAgB,mBAGd,OAAyC,cAAwB;CACjE,iBACE,OACA,eAAe,EAAE,GAAGA,yBAAW,MAAM,aAAa,WAAW,EAAE,CAAC,CACjE;;;;;;;;;;;;;;AAiBH,SAAgB,qBAId,QAA6E;CAC7E,MAAM,UACJ,OAAO,MAAM,aAAa;CAE5B,IAAI;CAEJ,MAAM,YAAY,OAAO,MAAM,qBAAqB,CAAC,SAAS,MAAM,GAAG;CAEvE,IAAI,WAAW;CAEf,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EAC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