@svgrid/grid 2.6.21 → 2.7.0

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 (358) hide show
  1. package/CHANGELOG.md +150 -88
  2. package/README.md +221 -199
  3. package/dist/FlexRender.svelte +96 -96
  4. package/dist/GridFooter.svelte +181 -181
  5. package/dist/GridMenus.svelte +201 -18
  6. package/dist/SvAutoComplete.svelte +169 -165
  7. package/dist/SvAvatar.svelte +75 -75
  8. package/dist/SvCalendar.svelte +503 -503
  9. package/dist/SvCarousel.svelte +141 -141
  10. package/dist/SvCheckBox.svelte +102 -102
  11. package/dist/SvCircularProgress.svelte +109 -109
  12. package/dist/SvColorInput.svelte +181 -181
  13. package/dist/SvComboBox.svelte +279 -275
  14. package/dist/SvContextMenu.svelte +116 -116
  15. package/dist/SvCountryInput.svelte +163 -163
  16. package/dist/SvDateRangeInput.svelte +25 -3
  17. package/dist/SvDrawer.svelte +254 -254
  18. package/dist/SvDropDownList.svelte +378 -374
  19. package/dist/SvDurationInput.svelte +126 -126
  20. package/dist/SvField.svelte +293 -293
  21. package/dist/SvForm.svelte +437 -437
  22. package/dist/SvGrid.controller.svelte.d.ts +61 -9
  23. package/dist/SvGrid.controller.svelte.js +363 -123
  24. package/dist/SvGrid.css +222 -1
  25. package/dist/SvGrid.helpers.d.ts +55 -0
  26. package/dist/SvGrid.helpers.js +83 -0
  27. package/dist/SvGrid.svelte +255 -56
  28. package/dist/SvGrid.types.d.ts +146 -1
  29. package/dist/SvGridCellEditor.svelte +744 -662
  30. package/dist/SvGridChart.svelte +1716 -1716
  31. package/dist/SvGridChartPanel.svelte +485 -485
  32. package/dist/SvGridChartView.svelte +70 -70
  33. package/dist/SvGridDropdown.svelte +728 -728
  34. package/dist/SvGridSelect.svelte +270 -266
  35. package/dist/SvGridSelect.svelte.d.ts +1 -1
  36. package/dist/SvGroupCell.svelte +116 -116
  37. package/dist/SvListBox.svelte +334 -326
  38. package/dist/SvMaskedInput.svelte +122 -122
  39. package/dist/SvMenu.svelte +124 -124
  40. package/dist/SvMenuList.svelte +146 -146
  41. package/dist/SvMultiSelect.svelte +293 -289
  42. package/dist/SvMultiSelect.svelte.d.ts +1 -1
  43. package/dist/SvNumberInput.svelte +172 -168
  44. package/dist/SvOtpInput.svelte +158 -158
  45. package/dist/SvPasswordInput.svelte +151 -151
  46. package/dist/SvPhoneInput.svelte +133 -133
  47. package/dist/SvPopover.svelte +197 -197
  48. package/dist/SvProgress.svelte +116 -116
  49. package/dist/SvRadioGroup.svelte +107 -107
  50. package/dist/SvRating.svelte +112 -112
  51. package/dist/SvResult.svelte +73 -73
  52. package/dist/SvRichCell.svelte +125 -0
  53. package/dist/SvRichCell.svelte.d.ts +15 -0
  54. package/dist/SvRichText.svelte +211 -211
  55. package/dist/SvRowGroupPanel.svelte +170 -170
  56. package/dist/SvScrollArea.svelte +61 -61
  57. package/dist/SvSlider.svelte +203 -203
  58. package/dist/SvSwitchButton.svelte +108 -108
  59. package/dist/SvTagsInput.svelte +115 -115
  60. package/dist/SvTextArea.svelte +5 -1
  61. package/dist/SvTextInput.svelte +147 -147
  62. package/dist/SvTimePicker.svelte +245 -245
  63. package/dist/SvToaster.svelte +159 -159
  64. package/dist/SvToggleButton.svelte +85 -85
  65. package/dist/SvTooltip.svelte +161 -161
  66. package/dist/SvTour.svelte +208 -208
  67. package/dist/SvTree.svelte +444 -444
  68. package/dist/SvTreeSelect.svelte +239 -235
  69. package/dist/SvTreeSelect.svelte.d.ts +1 -1
  70. package/dist/builtin-editors.d.ts +2 -2
  71. package/dist/builtin-editors.js +19 -3
  72. package/dist/cdn/GridMenus-C4oLsJyj.js +600 -0
  73. package/dist/cdn/GridMenus-yEivjNwl.js +601 -0
  74. package/dist/cdn/SvDateRangeInput-Bh0A0JkF.js +199 -0
  75. package/dist/cdn/SvDateRangeInput-DflbiP7N.js +198 -0
  76. package/dist/cdn/SvDateTimePicker-BWwpfB_o.js +812 -0
  77. package/dist/cdn/SvDateTimePicker-Bivn8dAP.js +816 -0
  78. package/dist/cdn/SvGridCellEditor-AXL8cHGO.js +550 -0
  79. package/dist/cdn/SvGridCellEditor-Ba7rY3eu.js +549 -0
  80. package/dist/cdn/{SvGridChart-BwVos976.js → SvGridChart-Bs2GIR2Q.js} +1 -1
  81. package/dist/cdn/{SvGridChart-BEJmNNx9.js → SvGridChart-CwhFz7GV.js} +1 -1
  82. package/dist/cdn/{SvGridChartPanel-BOknOkrP.js → SvGridChartPanel-1WXuStzM.js} +1 -1
  83. package/dist/cdn/{SvGridChartPanel-D2PjII4O.js → SvGridChartPanel-e5_nqNP9.js} +1 -1
  84. package/dist/cdn/{SvGridChartView-00LPUHL1.js → SvGridChartView-SmPW10dI.js} +1 -1
  85. package/dist/cdn/{SvGridChartView-BhUEJ5ki.js → SvGridChartView-eSPuJE6g.js} +1 -1
  86. package/dist/cdn/{SvGridDropdown-D0VdjeR8.js → SvGridDropdown-B1ZcLpgs.js} +1 -1
  87. package/dist/cdn/{SvGridDropdown-D13MtJ2j.js → SvGridDropdown-CtdbHcIS.js} +1 -1
  88. package/dist/cdn/column-resize-DsfNXMom.js +102 -0
  89. package/dist/cdn/date-format-CcP1tafP.js +1395 -0
  90. package/dist/cdn/date-format-DZT7T1wf.js +1393 -0
  91. package/dist/cdn/{editor-registry-CiI0xlKg.js → editor-registry-BhgE3S84.js} +51 -25
  92. package/dist/cdn/row-resize-BRcimkUT.js +95 -0
  93. package/dist/cdn/{src-BYq-qyrp.js → src-COC0vnpg.js} +7846 -7317
  94. package/dist/cdn/{src-DBel9wRZ.js → src-pYGV2rMR.js} +10033 -9504
  95. package/dist/cdn/svgrid.js +15 -11
  96. package/dist/cdn/svgrid.svelte-external.js +15 -11
  97. package/dist/cell-values.d.ts +16 -0
  98. package/dist/cell-values.js +28 -0
  99. package/dist/chart-export.js +8 -8
  100. package/dist/clipboard.d.ts +22 -0
  101. package/dist/clipboard.js +405 -27
  102. package/dist/column-groups.js +1 -1
  103. package/dist/column-resize.d.ts +46 -0
  104. package/dist/column-resize.js +205 -0
  105. package/dist/columns.d.ts +0 -3
  106. package/dist/columns.js +0 -57
  107. package/dist/core.d.ts +19 -4
  108. package/dist/core.js +460 -119
  109. package/dist/editing.js +12 -7
  110. package/dist/editors/cell-editors.d.ts +11 -0
  111. package/dist/editors/cell-editors.js +18 -1
  112. package/dist/filtering/excel-filters.js +28 -0
  113. package/dist/grid-messages.d.ts +15 -0
  114. package/dist/grid-messages.js +15 -0
  115. package/dist/group-display.d.ts +1 -1
  116. package/dist/index.d.ts +6 -1
  117. package/dist/index.js +10 -0
  118. package/dist/list-option.d.ts +6 -0
  119. package/dist/menus.js +41 -8
  120. package/dist/row-resize.d.ts +11 -0
  121. package/dist/row-resize.js +7 -1
  122. package/dist/sanitize-html.d.ts +37 -0
  123. package/dist/sanitize-html.js +234 -0
  124. package/dist/selection-bar-view.svelte.d.ts +25 -0
  125. package/dist/selection-bar-view.svelte.js +13 -0
  126. package/dist/selection.d.ts +2 -1
  127. package/dist/selection.js +133 -8
  128. package/dist/spreadsheet.d.ts +1 -1
  129. package/dist/spreadsheet.js +1 -1
  130. package/package.json +11 -11
  131. package/src/FlexRender.svelte +96 -96
  132. package/src/GridFooter.svelte +181 -181
  133. package/src/GridMenus.svelte +201 -18
  134. package/src/SvAutoComplete.svelte +169 -165
  135. package/src/SvAvatar.svelte +75 -75
  136. package/src/SvCalendar.svelte +503 -503
  137. package/src/SvCalendar.test.ts +226 -226
  138. package/src/SvCarousel.svelte +141 -141
  139. package/src/SvCheckBox.svelte +102 -102
  140. package/src/SvCircularProgress.svelte +109 -109
  141. package/src/SvColorInput.svelte +181 -181
  142. package/src/SvComboBox.svelte +279 -275
  143. package/src/SvContextMenu.svelte +116 -116
  144. package/src/SvCountryInput.svelte +163 -163
  145. package/src/SvDateRangeInput.svelte +25 -3
  146. package/src/SvDrawer.svelte +254 -254
  147. package/src/SvDropDownList.svelte +378 -374
  148. package/src/SvDurationInput.svelte +126 -126
  149. package/src/SvField.svelte +293 -293
  150. package/src/SvForm.svelte +437 -437
  151. package/src/SvForm.test.ts +411 -411
  152. package/src/SvGrid.controller.svelte.ts +404 -133
  153. package/src/SvGrid.css +222 -1
  154. package/src/SvGrid.helpers.ts +87 -0
  155. package/src/SvGrid.svelte +255 -56
  156. package/src/SvGrid.types.ts +2092 -1940
  157. package/src/SvGridCellEditor.svelte +744 -662
  158. package/src/SvGridChart.svelte +1716 -1716
  159. package/src/SvGridChartPanel.svelte +485 -485
  160. package/src/SvGridChartView.svelte +70 -70
  161. package/src/SvGridDropdown.svelte +728 -728
  162. package/src/SvGridSelect.svelte +270 -266
  163. package/src/SvGroupCell.svelte +116 -116
  164. package/src/SvListBox.svelte +334 -326
  165. package/src/SvMaskedInput.svelte +122 -122
  166. package/src/SvMenu.svelte +124 -124
  167. package/src/SvMenu.test.ts +97 -97
  168. package/src/SvMenuList.svelte +146 -146
  169. package/src/SvMultiSelect.svelte +293 -289
  170. package/src/SvNumberInput.svelte +172 -168
  171. package/src/SvOtpInput.svelte +158 -158
  172. package/src/SvPasswordInput.svelte +151 -151
  173. package/src/SvPhoneInput.svelte +133 -133
  174. package/src/SvPopover.svelte +197 -197
  175. package/src/SvProgress.svelte +116 -116
  176. package/src/SvRadioGroup.svelte +107 -107
  177. package/src/SvRating.svelte +112 -112
  178. package/src/SvResult.svelte +73 -73
  179. package/src/SvRichCell.svelte +125 -0
  180. package/src/SvRichText.svelte +211 -211
  181. package/src/SvRowGroupPanel.svelte +170 -170
  182. package/src/SvScrollArea.svelte +61 -61
  183. package/src/SvSlider.svelte +203 -203
  184. package/src/SvSwitchButton.svelte +108 -108
  185. package/src/SvTagsInput.svelte +115 -115
  186. package/src/SvTextArea.svelte +5 -1
  187. package/src/SvTextInput.svelte +147 -147
  188. package/src/SvTimePicker.svelte +245 -245
  189. package/src/SvToaster.svelte +159 -159
  190. package/src/SvToaster.test.ts +95 -95
  191. package/src/SvToggleButton.svelte +85 -85
  192. package/src/SvTooltip.svelte +161 -161
  193. package/src/SvTour.svelte +208 -208
  194. package/src/SvTree.svelte +444 -444
  195. package/src/SvTreeSelect.svelte +239 -235
  196. package/src/a11y/dismissable.test.ts +119 -119
  197. package/src/a11y/dismissable.ts +114 -114
  198. package/src/a11y.contract.test.ts +49 -49
  199. package/src/a11y.test.ts +59 -59
  200. package/src/a11y.ts +61 -61
  201. package/src/ai.test.ts +502 -502
  202. package/src/ai.ts +1419 -1419
  203. package/src/build-api.coverage.test.ts +633 -633
  204. package/src/build-api.ts +846 -846
  205. package/src/builtin-editors.grid.test.ts +83 -83
  206. package/src/builtin-editors.test.ts +18 -1
  207. package/src/builtin-editors.ts +19 -3
  208. package/src/cell-formatting.ts +171 -171
  209. package/src/cell-render.test.ts +513 -513
  210. package/src/cell-render.ts +496 -496
  211. package/src/cell-values.ts +148 -118
  212. package/src/chart-export.ts +202 -202
  213. package/src/chart-view.svelte.ts +36 -36
  214. package/src/chart.ts +2321 -2321
  215. package/src/clipboard.test.ts +93 -20
  216. package/src/clipboard.ts +433 -33
  217. package/src/collaboration.test.ts +104 -104
  218. package/src/collaboration.ts +167 -167
  219. package/src/column-groups.ts +78 -78
  220. package/src/column-resize.test.ts +381 -0
  221. package/src/column-resize.ts +227 -0
  222. package/src/columns.test.ts +0 -103
  223. package/src/columns.ts +0 -58
  224. package/src/core.aggregate.test.ts +134 -0
  225. package/src/core.filter.test.ts +156 -0
  226. package/src/core.grouping.test.ts +146 -0
  227. package/src/core.performance.test.ts +30 -30
  228. package/src/core.row-shape.test.ts +119 -0
  229. package/src/core.rowmodel-cache.test.ts +121 -0
  230. package/src/core.sort.test.ts +293 -0
  231. package/src/core.ts +1865 -1468
  232. package/src/createAutocomplete.svelte.ts +132 -132
  233. package/src/createCombobox.svelte.ts +191 -191
  234. package/src/createCountryInput.svelte.ts +157 -157
  235. package/src/createDropdownList.svelte.ts +168 -168
  236. package/src/createForm.svelte.ts +386 -386
  237. package/src/createGrid.svelte.ts +42 -42
  238. package/src/createGrid.test.ts +10 -10
  239. package/src/createGridState.svelte.ts +17 -17
  240. package/src/createListbox.svelte.ts +250 -250
  241. package/src/createMenu.svelte.ts +224 -224
  242. package/src/createPopoverSelect.svelte.ts +213 -213
  243. package/src/createSlider.svelte.ts +191 -191
  244. package/src/createTooltip.svelte.ts +144 -144
  245. package/src/createTree.svelte.ts +322 -322
  246. package/src/date-string-column.test.ts +87 -0
  247. package/src/datetime/date-core.ts +206 -206
  248. package/src/datetime/date-restrict.ts +61 -61
  249. package/src/datetime/timezone.ts +135 -135
  250. package/src/dock-manager-model.ts +596 -596
  251. package/src/dock-model.ts +374 -374
  252. package/src/editing.test.ts +974 -949
  253. package/src/editing.ts +609 -606
  254. package/src/editor-block-prop.test.ts +132 -0
  255. package/src/editor-contract.ts +171 -171
  256. package/src/editor-registry.grid.test.ts +144 -144
  257. package/src/editor-registry.ts +122 -122
  258. package/src/editors/cell-editors.ts +27 -1
  259. package/src/export-data-api.test.ts +126 -126
  260. package/src/export-format.test.ts +107 -107
  261. package/src/export-format.ts +601 -601
  262. package/src/filter-operators.ts +160 -160
  263. package/src/filtering/excel-filters.ts +325 -295
  264. package/src/filtering/normalize-fast-path.test.ts +104 -0
  265. package/src/flex-render.ts +3 -3
  266. package/src/form-field.ts +127 -127
  267. package/src/grid-messages.ts +34 -0
  268. package/src/group-display.test.ts +167 -167
  269. package/src/group-display.ts +200 -200
  270. package/src/headless.ts +87 -87
  271. package/src/index.ts +25 -1
  272. package/src/js-scroller.svelte.ts +173 -173
  273. package/src/keyboard-handlers.ts +270 -270
  274. package/src/keyboard.test.ts +59 -59
  275. package/src/keyboard.ts +97 -97
  276. package/src/list-nav.test.ts +49 -49
  277. package/src/list-nav.ts +29 -29
  278. package/src/list-option.test.ts +56 -56
  279. package/src/list-option.ts +179 -173
  280. package/src/menus.test.ts +43 -0
  281. package/src/menus.ts +597 -567
  282. package/src/merge-objects.ts +48 -48
  283. package/src/move-cells.test.ts +850 -0
  284. package/src/number-editor-literal.test.ts +84 -0
  285. package/src/number-editor.grid.test.ts +160 -0
  286. package/src/overlays.test.ts +90 -90
  287. package/src/positioning.ts +268 -268
  288. package/src/render-component.ts +28 -28
  289. package/src/resize-props.test.ts +361 -0
  290. package/src/row-drag-touch.ts +211 -211
  291. package/src/row-drag.test.ts +353 -353
  292. package/src/row-drag.ts +415 -415
  293. package/src/row-resize.test.ts +524 -493
  294. package/src/row-resize.ts +228 -210
  295. package/src/sanitize-html.test.ts +182 -0
  296. package/src/sanitize-html.ts +235 -0
  297. package/src/scheduler-ical.ts +181 -181
  298. package/src/scheduler-model.test.ts +562 -562
  299. package/src/scheduler-model.ts +873 -873
  300. package/src/selection-bar-view.svelte.ts +36 -0
  301. package/src/selection.test.ts +900 -743
  302. package/src/selection.ts +135 -8
  303. package/src/server-data-source.test.ts +383 -383
  304. package/src/server-data-source.ts +469 -469
  305. package/src/sparkline.test.ts +68 -68
  306. package/src/sparkline.ts +169 -169
  307. package/src/spreadsheet.test.ts +488 -488
  308. package/src/spreadsheet.ts +312 -312
  309. package/src/static-functions.ts +11 -11
  310. package/src/subscribe.ts +38 -38
  311. package/src/summaries.ts +113 -113
  312. package/src/svgrid-wrapper.types.ts +563 -563
  313. package/src/svgrid.async-editor-options.test.ts +273 -273
  314. package/src/svgrid.auto-row-height.test.ts +204 -204
  315. package/src/svgrid.behavior.test.ts +910 -910
  316. package/src/svgrid.charting.test.ts +534 -534
  317. package/src/svgrid.comments-autocomplete.test.ts +127 -127
  318. package/src/svgrid.context-menu.test.ts +147 -147
  319. package/src/svgrid.features.test.ts +157 -157
  320. package/src/svgrid.filter-depth.test.ts +163 -163
  321. package/src/svgrid.filter-menu-listbox.svelte.test.ts +377 -331
  322. package/src/svgrid.filter-menu-scroll.test.ts +112 -112
  323. package/src/svgrid.grand-total.test.ts +188 -188
  324. package/src/svgrid.group-display-mode.test.ts +171 -171
  325. package/src/svgrid.group-footers.test.ts +121 -121
  326. package/src/svgrid.group-pagination.test.ts +153 -153
  327. package/src/svgrid.in-suggest-snapshot.svelte.test.ts +91 -0
  328. package/src/svgrid.menu-scroll-close.test.ts +204 -0
  329. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  330. package/src/svgrid.selection-bar-seam.test.ts +185 -0
  331. package/src/svgrid.tree-data.test.ts +186 -186
  332. package/src/svgrid.upsell-license.test.ts +117 -0
  333. package/src/svgrid.wrapper.test.ts +63 -63
  334. package/src/svgriddropdown.async-panel.svelte.test.ts +195 -195
  335. package/src/test-setup.ts +62 -62
  336. package/src/themes/index.ts +288 -288
  337. package/src/toast-store.svelte.ts +250 -250
  338. package/src/toast-store.test.ts +147 -147
  339. package/src/tree-row-model.test.ts +168 -168
  340. package/src/ui-buttons.test.ts +144 -144
  341. package/src/ui-inputs.test.ts +118 -118
  342. package/src/ui-localization.test.ts +113 -113
  343. package/src/ui-range.test.ts +70 -70
  344. package/src/ui-selection.test.ts +155 -155
  345. package/src/ui-tier1.test.ts +142 -142
  346. package/src/virtual.test.ts +88 -88
  347. package/src/virtualization/column-virtualizer.test.ts +27 -27
  348. package/src/virtualization/column-virtualizer.ts +30 -30
  349. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  350. package/src/virtualization/types.ts +30 -30
  351. package/src/virtualization/virtualizer.test.ts +47 -47
  352. package/src/virtualization/virtualizer.ts +322 -322
  353. package/dist/cdn/GridMenus-BfTAKn84.js +0 -488
  354. package/dist/cdn/GridMenus-C3bJd7w8.js +0 -489
  355. package/dist/cdn/SvDateTimePicker-CHnUkWcH.js +0 -2206
  356. package/dist/cdn/SvDateTimePicker-CRQH_U7E.js +0 -2201
  357. package/dist/cdn/SvGridCellEditor-BGUCzuPB.js +0 -523
  358. package/dist/cdn/SvGridCellEditor-G8IMWIws.js +0 -522
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Equivalence + work-budget tests for `createFilteredRowModel`.
3
+ *
4
+ * The filter path used to read a cell with
5
+ * `row.getAllCells().find((c) => c.column.id === id)?.getValue()`. That builds
6
+ * and caches the row's ENTIRE `Cell[]` just to read one field, which defeats
7
+ * the lazy-cell design the row factory goes out of its way to provide - a
8
+ * one-operator filter over 100k rows materialised 100,000 cell arrays
9
+ * (measured; `pnpm bench --case=filter-1op`).
10
+ *
11
+ * `getCellValueByColumnId` reads the same `cachedValues` array those cells read
12
+ * from, so the swap is a pure win - but "same array" is a claim about today's
13
+ * implementation, so the equivalence half of this file pins the observable
14
+ * behaviour rather than trusting it.
15
+ */
16
+ import { describe, expect, it } from 'vitest'
17
+ import {
18
+ createCoreRowModel,
19
+ createFilteredRowModel,
20
+ createSvGridCore,
21
+ filterFns,
22
+ tableFeatures,
23
+ type ColumnDef,
24
+ type ColumnFiltersState,
25
+ } from './core'
26
+
27
+ type Row = Record<string, unknown>
28
+
29
+ const COLUMNS = [
30
+ { field: 'text' },
31
+ { field: 'num' },
32
+ { field: 'flag' },
33
+ // A computed column: `fieldFn` rather than `field`, to prove the value path
34
+ // is the same one the cell objects use.
35
+ { field: 'derived', fieldFn: (r: Row) => `${String(r.text).toUpperCase()}!` },
36
+ ]
37
+
38
+ /** The original implementation, verbatim, as the oracle. */
39
+ function referenceFilter(rows: Row[], columns: typeof COLUMNS, filters: ColumnFiltersState): Row[] {
40
+ const value = (row: Row, id: string) => {
41
+ const col = columns.find((c) => c.field === id)
42
+ if (!col) return undefined
43
+ return col.fieldFn ? col.fieldFn(row) : row[col.field]
44
+ }
45
+ return rows.filter((row) =>
46
+ filters.every((filter) => {
47
+ const fn = filter.fn ? filterFns[filter.fn] : filterFns.includesString
48
+ return fn(value(row, filter.id), filter.value as never)
49
+ }),
50
+ )
51
+ }
52
+
53
+ function actualFilter(rows: Row[], filters: ColumnFiltersState): Row[] {
54
+ const grid = createSvGridCore({
55
+ _features: tableFeatures({}),
56
+ _rowModels: {
57
+ coreRowModel: createCoreRowModel(),
58
+ filteredRowModel: createFilteredRowModel(),
59
+ },
60
+ columns: COLUMNS as unknown as Array<ColumnDef<ReturnType<typeof tableFeatures>, Row>>,
61
+ data: rows,
62
+ state: { columnFilters: filters },
63
+ })
64
+ return grid.getRowModel().rows.map((r) => r.original as Row)
65
+ }
66
+
67
+ const ROWS: Row[] = [
68
+ { text: 'banana', num: 2, flag: true },
69
+ { text: 'Apple', num: 10, flag: false },
70
+ { text: 'apple', num: -3, flag: true },
71
+ { text: null, num: null, flag: null },
72
+ { text: undefined, num: undefined, flag: undefined },
73
+ { text: '', num: 0, flag: '' },
74
+ { text: 'APPLE pie', num: NaN, flag: 'yes' },
75
+ ]
76
+
77
+ describe('createFilteredRowModel - equivalence with the original', () => {
78
+ const cases: Array<[string, ColumnFiltersState]> = [
79
+ ['no filters', []],
80
+ ['substring, case-insensitive', [{ id: 'text', value: 'app' }]],
81
+ ['substring matching nothing', [{ id: 'text', value: 'zzz' }]],
82
+ ['empty needle matches everything', [{ id: 'text', value: '' }]],
83
+ ['equals operator', [{ id: 'num', value: 10, fn: 'equals' }]],
84
+ ['equals against null', [{ id: 'num', value: null, fn: 'equals' }]],
85
+ ['two filters ANDed', [{ id: 'text', value: 'a' }, { id: 'flag', value: 'true' }]],
86
+ ['unknown column id', [{ id: 'nope', value: 'x' }]],
87
+ ['computed column via fieldFn', [{ id: 'derived', value: 'APPLE' }]],
88
+ ['filter on undefined values', [{ id: 'flag', value: 'undefined' }]],
89
+ ]
90
+
91
+ for (const [name, filters] of cases) {
92
+ it(`matches: ${name}`, () => {
93
+ const actual = actualFilter(ROWS, filters)
94
+ const expected = referenceFilter(ROWS, COLUMNS, filters)
95
+ expect(actual.length).toBe(expected.length)
96
+ // Identity, so row order and object identity are both checked.
97
+ for (let i = 0; i < actual.length; i++) expect(actual[i]).toBe(expected[i])
98
+ })
99
+ }
100
+ })
101
+
102
+ describe('createFilteredRowModel - work budget', () => {
103
+ /**
104
+ * Count how many rows materialise their full `Cell[]` during filtering.
105
+ *
106
+ * Wrapping each row in a proxy that tallies `getAllCells` is the same
107
+ * technique tools/bench uses, kept in-process here so the invariant is
108
+ * enforced by the unit suite rather than only by the bench.
109
+ */
110
+ function countCellMaterialisations(rowCount: number, filters: ColumnFiltersState): number {
111
+ const rows: Row[] = Array.from({ length: rowCount }, (_, i) => ({
112
+ text: `row-${i % 7}`,
113
+ num: i,
114
+ flag: i % 2 === 0,
115
+ }))
116
+ let calls = 0
117
+ const grid = createSvGridCore({
118
+ _features: tableFeatures({}),
119
+ _rowModels: {
120
+ coreRowModel: createCoreRowModel(),
121
+ filteredRowModel: (args) =>
122
+ createFilteredRowModel<Row>()({
123
+ ...args,
124
+ rows: args.rows.map(
125
+ (row) =>
126
+ new Proxy(row, {
127
+ get(obj, prop, recv) {
128
+ if (prop === 'getAllCells') calls++
129
+ return Reflect.get(obj, prop, recv)
130
+ },
131
+ }) as typeof row,
132
+ ),
133
+ }),
134
+ },
135
+ columns: COLUMNS as unknown as Array<ColumnDef<ReturnType<typeof tableFeatures>, Row>>,
136
+ data: rows,
137
+ state: { columnFilters: filters },
138
+ })
139
+ grid.getRowModel()
140
+ return calls
141
+ }
142
+
143
+ it('never materialises a row\'s cell array to read one field', () => {
144
+ expect(countCellMaterialisations(2_000, [{ id: 'text', value: 'row-1' }])).toBe(0)
145
+ })
146
+
147
+ it('stays at zero with several filters', () => {
148
+ expect(
149
+ countCellMaterialisations(2_000, [
150
+ { id: 'text', value: 'row' },
151
+ { id: 'num', value: '1' },
152
+ { id: 'flag', value: 'true' },
153
+ ]),
154
+ ).toBe(0)
155
+ })
156
+ })
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Grouping: the ancestor short-circuit in `resolveColumnValue`.
3
+ *
4
+ * A group row shows, for each non-aggregated column, the value its children
5
+ * agree on - or `undefined` when they disagree. That used to be found by
6
+ * scanning every child, even for a column an ANCESTOR level had already grouped
7
+ * by, where the answer is fixed by construction. On a 100k x 9 two-level group
8
+ * that was ~100,000 reads for a value already in hand.
9
+ *
10
+ * The shortcut has one genuinely sharp edge, which is what most of this file is
11
+ * about: buckets are keyed by `String(value ?? '')`, so `null`, `undefined` and
12
+ * `''` all land in the SAME bucket. A scan of that bucket reports disagreement,
13
+ * so the shortcut has to report disagreement too rather than picking whichever
14
+ * raw value happened to arrive first.
15
+ */
16
+ import { describe, expect, it } from 'vitest'
17
+ import {
18
+ createCoreRowModel,
19
+ createGroupedRowModel,
20
+ createSvGridCore,
21
+ columnGroupingFeature,
22
+ tableFeatures,
23
+ type ColumnDef,
24
+ type Row,
25
+ } from './core'
26
+
27
+ type Data = Record<string, unknown>
28
+
29
+ function grouped(data: Data[], fields: string[], grouping: string[]) {
30
+ const grid = createSvGridCore({
31
+ _features: tableFeatures({ columnGroupingFeature }),
32
+ _rowModels: { coreRowModel: createCoreRowModel(), groupedRowModel: createGroupedRowModel() },
33
+ columns: fields.map((f) => ({ field: f })) as unknown as Array<
34
+ ColumnDef<ReturnType<typeof tableFeatures>, Data>
35
+ >,
36
+ data,
37
+ state: { grouping },
38
+ onGroupingChange: () => {},
39
+ })
40
+ return grid.getRowModel().rows
41
+ }
42
+
43
+ /** Walk to the group rows at a given depth. */
44
+ function atDepth(rows: Array<Row<Data>>, depth: number): Array<Row<Data>> {
45
+ const out: Array<Row<Data>> = []
46
+ const visit = (rs: Array<Row<Data>>) => {
47
+ for (const r of rs) {
48
+ if (r.depth === depth) out.push(r)
49
+ if (r.subRows?.length) visit(r.subRows as Array<Row<Data>>)
50
+ }
51
+ }
52
+ visit(rows)
53
+ return out
54
+ }
55
+
56
+ describe('createGroupedRowModel - ancestor value resolution', () => {
57
+ const FIELDS = ['region', 'status', 'owner', 'amount']
58
+
59
+ it('a second-level group still reports the first level value', () => {
60
+ const data: Data[] = [
61
+ { region: 'EMEA', status: 'open', owner: 'ada', amount: 1 },
62
+ { region: 'EMEA', status: 'open', owner: 'ada', amount: 2 },
63
+ { region: 'EMEA', status: 'shut', owner: 'bob', amount: 3 },
64
+ { region: 'APAC', status: 'open', owner: 'cy', amount: 4 },
65
+ ]
66
+ const inner = atDepth(grouped(data, FIELDS, ['region', 'status']), 1)
67
+ expect(inner.length).toBe(3)
68
+ for (const g of inner) {
69
+ // `region` is fixed by the ancestor bucket, so every inner group must
70
+ // report it rather than undefined.
71
+ expect(['EMEA', 'APAC']).toContain(g.getCellValueByColumnId('region'))
72
+ }
73
+ // And the columns that genuinely vary still resolve the old way.
74
+ const emeaOpen = inner.find((g) => g.getCellValueByColumnId('status') === 'open')!
75
+ expect(emeaOpen.getCellValueByColumnId('owner')).toBe('ada')
76
+ })
77
+
78
+ it('reports disagreement when a bucket mixed null, undefined and empty string', () => {
79
+ // All three key to '' and share one bucket. A scan would find they disagree,
80
+ // so the shortcut must not report whichever arrived first.
81
+ const data: Data[] = [
82
+ { region: null, status: 'x', owner: 'a', amount: 1 },
83
+ { region: undefined, status: 'y', owner: 'b', amount: 2 },
84
+ { region: '', status: 'z', owner: 'c', amount: 3 },
85
+ ]
86
+ const inner = atDepth(grouped(data, FIELDS, ['region', 'status']), 1)
87
+ expect(inner.length).toBe(3)
88
+ for (const g of inner) {
89
+ // Each inner bucket holds exactly one row, so `region` is whatever that
90
+ // row had - not a value borrowed from a sibling.
91
+ const status = g.getCellValueByColumnId('status')
92
+ const expected = data.find((d) => d.status === status)!.region
93
+ expect(g.getCellValueByColumnId('region')).toBe(expected)
94
+ }
95
+ })
96
+
97
+ it('a mixed ancestor bucket resolves to undefined at the deeper level', () => {
98
+ // One inner bucket spanning rows whose raw region values differ but key the
99
+ // same. `status` is identical so they stay together at level two.
100
+ const data: Data[] = [
101
+ { region: null, status: 'same', owner: 'a', amount: 1 },
102
+ { region: '', status: 'same', owner: 'a', amount: 2 },
103
+ ]
104
+ const inner = atDepth(grouped(data, FIELDS, ['region', 'status']), 1)
105
+ expect(inner.length).toBe(1)
106
+ // A scan of [null, ''] disagrees, so this must be undefined.
107
+ expect(inner[0]!.getCellValueByColumnId('region')).toBeUndefined()
108
+ })
109
+
110
+ it('preserves the raw type of an ancestor value rather than its bucket key', () => {
111
+ // Buckets are keyed by String(value), so a numeric grouping column would
112
+ // report '2024' instead of 2024 if the shortcut returned the key.
113
+ const data: Data[] = [
114
+ { region: 2024, status: 'a', owner: 'x', amount: 1 },
115
+ { region: 2024, status: 'b', owner: 'y', amount: 2 },
116
+ ]
117
+ const inner = atDepth(grouped(data, FIELDS, ['region', 'status']), 1)
118
+ expect(inner.length).toBe(2)
119
+ for (const g of inner) {
120
+ expect(g.getCellValueByColumnId('region')).toBe(2024)
121
+ }
122
+ })
123
+
124
+ it('handles three levels', () => {
125
+ const data: Data[] = [
126
+ { region: 'EMEA', status: 'open', owner: 'ada', amount: 1 },
127
+ { region: 'EMEA', status: 'open', owner: 'ada', amount: 2 },
128
+ { region: 'EMEA', status: 'open', owner: 'bob', amount: 3 },
129
+ ]
130
+ const deepest = atDepth(grouped(data, FIELDS, ['region', 'status', 'owner']), 2)
131
+ expect(deepest.length).toBe(2)
132
+ for (const g of deepest) {
133
+ expect(g.getCellValueByColumnId('region')).toBe('EMEA')
134
+ expect(g.getCellValueByColumnId('status')).toBe('open')
135
+ }
136
+ })
137
+
138
+ it('still returns undefined for a non-grouping column whose children disagree', () => {
139
+ const data: Data[] = [
140
+ { region: 'EMEA', status: 'open', owner: 'ada', amount: 1 },
141
+ { region: 'EMEA', status: 'open', owner: 'bob', amount: 2 },
142
+ ]
143
+ const inner = atDepth(grouped(data, FIELDS, ['region', 'status']), 1)
144
+ expect(inner[0]!.getCellValueByColumnId('owner')).toBeUndefined()
145
+ })
146
+ })
@@ -1,30 +1,30 @@
1
- import { describe, expect, it } from 'vitest'
2
- import { createCoreRowModel, createSortedRowModel, createSvGrid, sortFns, tableFeatures } from './index'
3
-
4
- describe('core performance smoke', () => {
5
- it('handles large synthetic shape with bounded row model call', () => {
6
- const columns = Array.from({ length: 50 }, (_, index) => ({
7
- field: `c${index}`,
8
- editorType: 'number' as const,
9
- }))
10
- const data = Array.from({ length: 5000 }, (_, rowIndex) => {
11
- const row: Record<string, number> = {}
12
- for (let col = 0; col < 50; col += 1) row[`c${col}`] = rowIndex + col
13
- return row
14
- })
15
- const grid = createSvGrid({
16
- _features: tableFeatures({}),
17
- _rowModels: {
18
- coreRowModel: createCoreRowModel(),
19
- sortedRowModel: createSortedRowModel(sortFns),
20
- },
21
- columns,
22
- data,
23
- state: { sorting: [{ id: 'c0', desc: true }, { id: 'c1', desc: false }] },
24
- })
25
-
26
- const rows = grid.getRowModel().rows
27
- expect(rows.length).toBe(5000)
28
- expect(rows[0]?.getCellValueByColumnId('c0')).toBe(4999)
29
- })
30
- })
1
+ import { describe, expect, it } from 'vitest'
2
+ import { createCoreRowModel, createSortedRowModel, createSvGrid, sortFns, tableFeatures } from './index'
3
+
4
+ describe('core performance smoke', () => {
5
+ it('handles large synthetic shape with bounded row model call', () => {
6
+ const columns = Array.from({ length: 50 }, (_, index) => ({
7
+ field: `c${index}`,
8
+ editorType: 'number' as const,
9
+ }))
10
+ const data = Array.from({ length: 5000 }, (_, rowIndex) => {
11
+ const row: Record<string, number> = {}
12
+ for (let col = 0; col < 50; col += 1) row[`c${col}`] = rowIndex + col
13
+ return row
14
+ })
15
+ const grid = createSvGrid({
16
+ _features: tableFeatures({}),
17
+ _rowModels: {
18
+ coreRowModel: createCoreRowModel(),
19
+ sortedRowModel: createSortedRowModel(sortFns),
20
+ },
21
+ columns,
22
+ data,
23
+ state: { sorting: [{ id: 'c0', desc: true }, { id: 'c1', desc: false }] },
24
+ })
25
+
26
+ const rows = grid.getRowModel().rows
27
+ expect(rows.length).toBe(5000)
28
+ expect(rows[0]?.getCellValueByColumnId('c0')).toBe(4999)
29
+ })
30
+ })
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The public shape of a `Row`.
3
+ *
4
+ * Rows were rewritten from object literals with per-row closures to objects
5
+ * carrying shared `this`-based methods, which cut mount allocation from 56.5 MB
6
+ * to 14.5 MB. Those shared methods need a pointer back to the table, and the
7
+ * first version stored it as a plain `_ctx` property - which made every row
8
+ * serialise the whole grid, because `options.data` is reachable through it.
9
+ * `JSON.stringify(oneRow)` grew with the dataset: 981 characters at 3 rows,
10
+ * 67,719 at 3,000. Stringifying a row model was quadratic.
11
+ *
12
+ * The fix is to key the internals with symbols: invisible to `JSON.stringify`,
13
+ * `Object.keys` and `for...in`, but still copied by object spread, which
14
+ * several row models rely on when they do `{ ...row, depth }`.
15
+ *
16
+ * These tests pin all four of those properties. `Row` is public API and its
17
+ * observable shape is part of the contract.
18
+ */
19
+ import { describe, expect, it } from 'vitest'
20
+ import {
21
+ createCoreRowModel,
22
+ createGroupedRowModel,
23
+ createSvGridCore,
24
+ columnGroupingFeature,
25
+ tableFeatures,
26
+ type ColumnDef,
27
+ } from './core'
28
+
29
+ type Data = Record<string, unknown>
30
+
31
+ function makeGrid(count: number, grouping: string[] = []) {
32
+ const data: Data[] = Array.from({ length: count }, (_, i) => ({
33
+ name: `row-${i}`,
34
+ score: i,
35
+ bucket: i % 2 === 0 ? 'even' : 'odd',
36
+ }))
37
+ return createSvGridCore({
38
+ _features: tableFeatures({ columnGroupingFeature }),
39
+ _rowModels: grouping.length
40
+ ? { coreRowModel: createCoreRowModel(), groupedRowModel: createGroupedRowModel() }
41
+ : { coreRowModel: createCoreRowModel() },
42
+ columns: [{ field: 'name' }, { field: 'score' }, { field: 'bucket' }] as unknown as Array<
43
+ ColumnDef<ReturnType<typeof tableFeatures>, Data>
44
+ >,
45
+ data,
46
+ state: { grouping },
47
+ onGroupingChange: () => {},
48
+ })
49
+ }
50
+
51
+ const PUBLIC_KEYS = [
52
+ 'id',
53
+ 'index',
54
+ 'original',
55
+ 'depth',
56
+ 'getCanExpand',
57
+ 'getIsExpanded',
58
+ 'toggleExpanded',
59
+ 'getIsSelected',
60
+ 'toggleSelected',
61
+ 'getAllCells',
62
+ 'getCellValueByColumnId',
63
+ ]
64
+
65
+ describe('Row public shape', () => {
66
+ it('exposes exactly the documented keys, with no internals', () => {
67
+ const row = makeGrid(10).getRowModel().rows[0]!
68
+ expect(Object.keys(row).sort()).toEqual([...PUBLIC_KEYS].sort())
69
+ })
70
+
71
+ it('does not leak internals through for...in', () => {
72
+ const row = makeGrid(10).getRowModel().rows[0]!
73
+ const seen: string[] = []
74
+ for (const k in row) seen.push(k)
75
+ expect(seen.sort()).toEqual([...PUBLIC_KEYS].sort())
76
+ })
77
+
78
+ it('serialises to a constant size regardless of dataset size', () => {
79
+ // The regression this guards: `_ctx` reached `options.data`, so a single
80
+ // row carried the entire grid into JSON. Sizes must not grow with count.
81
+ const sizes = [10, 100, 1000].map(
82
+ (n) => JSON.stringify(makeGrid(n).getRowModel().rows[0]).length,
83
+ )
84
+ expect(new Set(sizes).size).toBe(1)
85
+ // And it must stay small - this is 4 scalar fields, not a grid.
86
+ expect(sizes[0]!).toBeLessThan(200)
87
+ })
88
+
89
+ it('serialises a whole row model linearly, not quadratically', () => {
90
+ const small = JSON.stringify(makeGrid(50).getRowModel().rows).length
91
+ const large = JSON.stringify(makeGrid(500).getRowModel().rows).length
92
+ // Ten times the rows should cost about ten times the characters. Quadratic
93
+ // growth would put this well past 20x.
94
+ expect(large).toBeLessThan(small * 20)
95
+ })
96
+
97
+ it('survives an object spread with its methods intact', () => {
98
+ // `createGroupedRowModel` does `{ ...row, depth }` for leaf rows; the clone
99
+ // has to keep working, which is why the internals are symbol-keyed rather
100
+ // than non-enumerable.
101
+ const row = makeGrid(10).getRowModel().rows[0]!
102
+ const clone = { ...row, depth: 3 }
103
+ expect(clone.depth).toBe(3)
104
+ expect(typeof clone.getCellValueByColumnId).toBe('function')
105
+ expect(clone.getCellValueByColumnId('name')).toBe(row.getCellValueByColumnId('name'))
106
+ expect(clone.getIsSelected()).toBe(false)
107
+ // The clone must not have grown a public surface either.
108
+ expect(Object.keys(clone).sort()).toEqual([...PUBLIC_KEYS].sort())
109
+ })
110
+
111
+ it('keeps grouped leaf rows working after the model clones them', () => {
112
+ const rows = makeGrid(10, ['bucket']).getRowModel().rows
113
+ const group = rows[0]!
114
+ expect(group.subRows?.length).toBeGreaterThan(0)
115
+ const leaf = group.subRows![0]!
116
+ expect(leaf.getCellValueByColumnId('name')).toMatch(/^row-\d+$/)
117
+ expect(leaf.depth).toBe(1)
118
+ })
119
+ })
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Row-model memo invalidation.
3
+ *
4
+ * `getRowModel()` caches on the identity of the data, the columns, and a set of
5
+ * state slices. `rowSelection` was one of those slices, so ticking a single
6
+ * checkbox on a 100k-row grid re-ran the whole pipeline - re-filtering and
7
+ * re-sorting the entire dataset - to produce a row array that was, by
8
+ * construction, identical. Measured at 5 full re-runs for 5 toggles
9
+ * (`pnpm bench --case=selection-toggle`).
10
+ *
11
+ * Nothing in the pipeline reads selection. The two consumers, `getIsSelected`
12
+ * on data rows (core.ts) and on group rows, are closures that read
13
+ * `store.state` when called, so they see a selection change without the model
14
+ * being rebuilt. That is what the last test here pins: dropping the slice must
15
+ * not make a selected row report the wrong thing.
16
+ */
17
+ import { describe, expect, it } from 'vitest'
18
+ import {
19
+ createCoreRowModel,
20
+ createFilteredRowModel,
21
+ createSortedRowModel,
22
+ createSvGridCore,
23
+ rowSelectionFeature,
24
+ tableFeatures,
25
+ type ColumnDef,
26
+ type RowModelFactory,
27
+ } from './core'
28
+
29
+ type Row = { id: number; name: string; score: number }
30
+
31
+ const COLUMNS = [
32
+ { field: 'id', editorType: 'number' },
33
+ { field: 'name' },
34
+ { field: 'score', editorType: 'number' },
35
+ ]
36
+
37
+ function makeRows(n: number): Row[] {
38
+ return Array.from({ length: n }, (_, i) => ({
39
+ id: i,
40
+ name: `name-${(i * 7919) % n}`,
41
+ score: (i * 31) % 1000,
42
+ }))
43
+ }
44
+
45
+ /** Wrap a stage so we can count how many times the pipeline actually ran it. */
46
+ function counted<T extends Row>(factory: RowModelFactory<T>, tally: { n: number }): RowModelFactory<T> {
47
+ return (args) => {
48
+ tally.n++
49
+ return factory(args)
50
+ }
51
+ }
52
+
53
+ function makeGrid(rows: Row[], tallies: { filter: { n: number }; sort: { n: number } }) {
54
+ return createSvGridCore({
55
+ _features: tableFeatures({ rowSelectionFeature }),
56
+ _rowModels: {
57
+ coreRowModel: createCoreRowModel(),
58
+ filteredRowModel: counted(createFilteredRowModel<Row>(), tallies.filter),
59
+ sortedRowModel: counted(createSortedRowModel<Row>(), tallies.sort),
60
+ },
61
+ columns: COLUMNS as unknown as Array<ColumnDef<ReturnType<typeof tableFeatures>, Row>>,
62
+ data: rows,
63
+ state: {
64
+ columnFilters: [{ id: 'name', value: 'name-' }],
65
+ sorting: [{ id: 'score', desc: false }],
66
+ rowSelection: {},
67
+ },
68
+ })
69
+ }
70
+
71
+ describe('row-model cache: selection', () => {
72
+ it('does not re-run the pipeline when only the selection changes', () => {
73
+ const tallies = { filter: { n: 0 }, sort: { n: 0 } }
74
+ const grid = makeGrid(makeRows(500), tallies)
75
+
76
+ grid.getRowModel() // first build - expected to run
77
+ const after = { filter: tallies.filter.n, sort: tallies.sort.n }
78
+ expect(after.filter).toBe(1)
79
+ expect(after.sort).toBe(1)
80
+
81
+ for (let i = 0; i < 5; i++) {
82
+ grid.setRowSelection((prev) => ({ ...prev, [String(i)]: true }))
83
+ grid.getRowModel()
84
+ }
85
+
86
+ expect(tallies.filter.n - after.filter).toBe(0)
87
+ expect(tallies.sort.n - after.sort).toBe(0)
88
+ })
89
+
90
+ it('still re-runs when a slice the pipeline DOES read changes', () => {
91
+ const tallies = { filter: { n: 0 }, sort: { n: 0 } }
92
+ const grid = makeGrid(makeRows(200), tallies)
93
+ grid.getRowModel()
94
+ const before = tallies.sort.n
95
+
96
+ // No `setSorting` on the core - sorting is driven through the store (or a
97
+ // column's `toggleSorting`), which is also how <SvGrid> does it.
98
+ grid.store.setState((prev) => ({ ...prev, sorting: [{ id: 'score', desc: true }] }))
99
+ grid.getRowModel()
100
+
101
+ expect(tallies.sort.n).toBeGreaterThan(before)
102
+ })
103
+
104
+ it('reports selection correctly even though the model was not rebuilt', () => {
105
+ const tallies = { filter: { n: 0 }, sort: { n: 0 } }
106
+ const grid = makeGrid(makeRows(50), tallies)
107
+
108
+ const rows = grid.getRowModel().rows
109
+ const target = rows[3]!
110
+ expect(target.getIsSelected()).toBe(false)
111
+
112
+ grid.setRowSelection((prev) => ({ ...prev, [target.id]: true }))
113
+
114
+ // Same row object, no rebuild - the closure must observe the new state.
115
+ expect(grid.getRowModel().rows[3]).toBe(target)
116
+ expect(target.getIsSelected()).toBe(true)
117
+
118
+ grid.setRowSelection(() => ({}))
119
+ expect(target.getIsSelected()).toBe(false)
120
+ })
121
+ })