@svgrid/grid 2.2.32 → 2.4.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 (405) hide show
  1. package/README.md +199 -199
  2. package/dist/DockNodeView.svelte +1 -1
  3. package/dist/FlexRender.svelte +96 -96
  4. package/dist/GridFooter.svelte +178 -179
  5. package/dist/GridMenus.svelte +705 -782
  6. package/dist/SvAutoComplete.svelte +165 -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 +275 -275
  14. package/dist/SvContextMenu.svelte +116 -116
  15. package/dist/SvCountryInput.svelte +160 -160
  16. package/dist/SvDateRangeInput.svelte +1 -1
  17. package/dist/SvDrawer.svelte +254 -254
  18. package/dist/SvDropDownList.svelte +374 -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.css +2814 -2804
  23. package/dist/SvGrid.svelte +3490 -3513
  24. package/dist/SvGridChart.svelte +1716 -1724
  25. package/dist/SvGridChartPanel.svelte +485 -485
  26. package/dist/SvGridChartView.svelte +70 -70
  27. package/dist/SvGridDropdown.svelte +728 -728
  28. package/dist/SvGridSelect.svelte +266 -268
  29. package/dist/SvGroupCell.svelte +116 -116
  30. package/dist/SvKbd.svelte +1 -1
  31. package/dist/SvList.svelte +1 -1
  32. package/dist/SvListBox.svelte +326 -326
  33. package/dist/SvMaskedInput.svelte +122 -122
  34. package/dist/SvMenu.svelte +124 -124
  35. package/dist/SvMenuList.svelte +146 -146
  36. package/dist/SvMenubar.svelte +1 -1
  37. package/dist/SvMultiSelect.svelte +289 -290
  38. package/dist/SvNumberInput.svelte +168 -168
  39. package/dist/SvOtpInput.svelte +158 -158
  40. package/dist/SvPasswordInput.svelte +151 -151
  41. package/dist/SvPhoneInput.svelte +133 -133
  42. package/dist/SvPopover.svelte +197 -197
  43. package/dist/SvProgress.svelte +116 -116
  44. package/dist/SvRadioGroup.svelte +107 -107
  45. package/dist/SvRating.svelte +112 -112
  46. package/dist/SvResult.svelte +73 -73
  47. package/dist/SvRichText.svelte +211 -207
  48. package/dist/SvRowGroupPanel.svelte +170 -170
  49. package/dist/SvScrollArea.svelte +61 -61
  50. package/dist/SvSlider.svelte +200 -200
  51. package/dist/SvSwitchButton.svelte +108 -108
  52. package/dist/SvTagsInput.svelte +112 -112
  53. package/dist/SvTextInput.svelte +147 -147
  54. package/dist/SvTimePicker.svelte +245 -245
  55. package/dist/SvToaster.svelte +159 -159
  56. package/dist/SvToggleButton.svelte +85 -85
  57. package/dist/SvTooltip.svelte +161 -161
  58. package/dist/SvTour.svelte +208 -204
  59. package/dist/SvTree.svelte +444 -444
  60. package/dist/SvTreeSelect.svelte +235 -237
  61. package/dist/cdn/{GridMenus-C6ixSGWW.js → GridMenus-BpVcKyUr.js} +5 -7
  62. package/dist/cdn/{GridMenus-Cyk3qpJ7.js → GridMenus-CeXL5IW4.js} +153 -152
  63. package/dist/cdn/{SvDateTimePicker-ClqtVIj3.js → SvDateTimePicker-DSUhIta8.js} +165 -165
  64. package/dist/cdn/{SvDateTimePicker-CdqaP61H.js → SvDateTimePicker-h9kPyszT.js} +572 -555
  65. package/dist/cdn/{SvGridChart-BcLCYvw9.js → SvGridChart-Bs2GIR2Q.js} +28 -21
  66. package/dist/cdn/{SvGridChart-BhnFdLd0.js → SvGridChart-CwhFz7GV.js} +2 -2
  67. package/dist/cdn/{SvGridChartPanel-Cmx9DHAS.js → SvGridChartPanel-1WXuStzM.js} +2 -2
  68. package/dist/cdn/{SvGridChartPanel-DvjwxLvK.js → SvGridChartPanel-e5_nqNP9.js} +22 -14
  69. package/dist/cdn/{SvGridChartView-PwqI4s02.js → SvGridChartView-SmPW10dI.js} +3 -3
  70. package/dist/cdn/{SvGridChartView-B40DTJSX.js → SvGridChartView-eSPuJE6g.js} +2 -2
  71. package/dist/cdn/{SvGridDropdown-D0VdjeR8.js → SvGridDropdown-B1ZcLpgs.js} +1 -1
  72. package/dist/cdn/{SvGridDropdown-Dh-2ej8j.js → SvGridDropdown-CtdbHcIS.js} +6 -5
  73. package/dist/cdn/{chart-T1usDN0o.js → chart-i4XcXyHJ.js} +12 -10
  74. package/dist/cdn/disclose-version-Dr7rEVv-.js +2866 -0
  75. package/dist/cdn/{export-format-JT5pWVT8.js → export-format-Cv1Dll6k.js} +66 -245
  76. package/dist/cdn/{src-CgD-wiuS.js → src-DbeN1ReZ.js} +9223 -8944
  77. package/dist/cdn/{src-BgHjWF0Q.js → src-DmEQFW5_.js} +9023 -8828
  78. package/dist/cdn/svgrid.js +9 -9
  79. package/dist/cdn/svgrid.svelte-external.js +9 -9
  80. package/dist/chart-export.js +8 -8
  81. package/dist/chart.d.ts +2 -0
  82. package/dist/chart.js +1 -4
  83. package/dist/columns.js +9 -2
  84. package/dist/createMenu.svelte.js +0 -1
  85. package/dist/createPopoverSelect.svelte.d.ts +2 -2
  86. package/dist/editing.js +1 -1
  87. package/dist/export-format.js +3 -0
  88. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +1 -0
  89. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +178 -0
  90. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +3843 -0
  91. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +1 -0
  92. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +23 -0
  93. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +1 -0
  94. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +1925 -0
  95. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +1 -0
  96. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +206 -0
  97. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +1 -0
  98. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +20 -0
  99. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +1 -0
  100. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +264 -0
  101. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +1 -0
  102. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +698 -0
  103. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +1 -0
  104. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +3 -0
  105. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +135 -0
  106. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +1 -0
  107. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +57 -0
  108. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +1 -0
  109. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +2 -0
  110. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +46691 -0
  111. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +1 -0
  112. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +239 -0
  113. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +1 -0
  114. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +2 -0
  115. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +6 -0
  116. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +1 -0
  117. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +7 -0
  118. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +6 -0
  119. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +1 -0
  120. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +7 -0
  121. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +1 -0
  122. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +7 -0
  123. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +1 -0
  124. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +7 -0
  125. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +1 -0
  126. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +6 -0
  127. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +85 -0
  128. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +1 -0
  129. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +561 -0
  130. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +1 -0
  131. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +26 -0
  132. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +1 -0
  133. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +124 -0
  134. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +1 -0
  135. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +2 -0
  136. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +91 -0
  137. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +1 -0
  138. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +242 -0
  139. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +1 -0
  140. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +497 -0
  141. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +1 -0
  142. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +4929 -0
  143. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +1 -0
  144. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +192 -0
  145. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +1 -0
  146. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +10 -0
  147. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +1 -0
  148. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +140 -0
  149. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js.map +1 -0
  150. package/dist/selection.js +0 -1
  151. package/package.json +11 -10
  152. package/src/DockNodeView.svelte +1 -1
  153. package/src/FlexRender.svelte +96 -96
  154. package/src/GridFooter.svelte +178 -179
  155. package/src/GridMenus.svelte +705 -782
  156. package/src/SvAutoComplete.svelte +165 -165
  157. package/src/SvAvatar.svelte +75 -75
  158. package/src/SvCalendar.svelte +503 -503
  159. package/src/SvCalendar.test.ts +226 -226
  160. package/src/SvCarousel.svelte +141 -141
  161. package/src/SvCheckBox.svelte +102 -102
  162. package/src/SvCircularProgress.svelte +109 -109
  163. package/src/SvColorInput.svelte +181 -181
  164. package/src/SvComboBox.svelte +275 -275
  165. package/src/SvContextMenu.svelte +116 -116
  166. package/src/SvCountryInput.svelte +160 -160
  167. package/src/SvDateRangeInput.svelte +1 -1
  168. package/src/SvDrawer.svelte +254 -254
  169. package/src/SvDropDownList.svelte +374 -374
  170. package/src/SvDurationInput.svelte +126 -126
  171. package/src/SvField.svelte +293 -293
  172. package/src/SvForm.svelte +437 -437
  173. package/src/SvForm.test.ts +411 -411
  174. package/src/SvGrid.controller.svelte.ts +3680 -3685
  175. package/src/SvGrid.css +2814 -2804
  176. package/src/SvGrid.svelte +3490 -3513
  177. package/src/SvGrid.types.ts +1708 -1709
  178. package/src/SvGridChart.svelte +1716 -1724
  179. package/src/SvGridChartPanel.svelte +485 -485
  180. package/src/SvGridChartView.svelte +70 -70
  181. package/src/SvGridDropdown.svelte +728 -728
  182. package/src/SvGridSelect.svelte +266 -268
  183. package/src/SvGroupCell.svelte +116 -116
  184. package/src/SvKbd.svelte +1 -1
  185. package/src/SvList.svelte +1 -1
  186. package/src/SvListBox.svelte +326 -326
  187. package/src/SvMaskedInput.svelte +122 -122
  188. package/src/SvMenu.svelte +124 -124
  189. package/src/SvMenu.test.ts +97 -97
  190. package/src/SvMenuList.svelte +146 -146
  191. package/src/SvMenubar.svelte +1 -1
  192. package/src/SvMultiSelect.svelte +289 -290
  193. package/src/SvNumberInput.svelte +168 -168
  194. package/src/SvOtpInput.svelte +158 -158
  195. package/src/SvPasswordInput.svelte +151 -151
  196. package/src/SvPhoneInput.svelte +133 -133
  197. package/src/SvPopover.svelte +197 -197
  198. package/src/SvProgress.svelte +116 -116
  199. package/src/SvRadioGroup.svelte +107 -107
  200. package/src/SvRating.svelte +112 -112
  201. package/src/SvResult.svelte +73 -73
  202. package/src/SvRichText.svelte +211 -207
  203. package/src/SvRowGroupPanel.svelte +170 -170
  204. package/src/SvScrollArea.svelte +61 -61
  205. package/src/SvSlider.svelte +200 -200
  206. package/src/SvSwitchButton.svelte +108 -108
  207. package/src/SvTagsInput.svelte +112 -112
  208. package/src/SvTextInput.svelte +147 -147
  209. package/src/SvTimePicker.svelte +245 -245
  210. package/src/SvToaster.svelte +159 -159
  211. package/src/SvToaster.test.ts +95 -95
  212. package/src/SvToggleButton.svelte +85 -85
  213. package/src/SvTooltip.svelte +161 -161
  214. package/src/SvTour.svelte +208 -204
  215. package/src/SvTree.svelte +444 -444
  216. package/src/SvTreeSelect.svelte +235 -237
  217. package/src/a11y/dismissable.test.ts +119 -119
  218. package/src/a11y/dismissable.ts +114 -114
  219. package/src/a11y.contract.test.ts +49 -49
  220. package/src/a11y.test.ts +59 -59
  221. package/src/a11y.ts +61 -61
  222. package/src/ai.test.ts +502 -502
  223. package/src/ai.ts +1391 -1391
  224. package/src/build-api.coverage.test.ts +633 -633
  225. package/src/build-api.ts +805 -910
  226. package/src/builtin-editors.grid.test.ts +85 -85
  227. package/src/cell-formatting.test.ts +1 -1
  228. package/src/cell-formatting.ts +169 -169
  229. package/src/cell-render.test.ts +513 -513
  230. package/src/cell-render.ts +496 -590
  231. package/src/cell-values.ts +118 -118
  232. package/src/chart-export.ts +201 -201
  233. package/src/chart-view.svelte.ts +36 -36
  234. package/src/chart.ts +2295 -2296
  235. package/src/clipboard.ts +0 -102
  236. package/src/collaboration.test.ts +104 -104
  237. package/src/collaboration.ts +167 -167
  238. package/src/columns.ts +7 -117
  239. package/src/core.performance.test.ts +30 -30
  240. package/src/core.ts +1261 -1261
  241. package/src/createAutocomplete.svelte.ts +132 -132
  242. package/src/createCombobox.svelte.ts +191 -191
  243. package/src/createCountryInput.svelte.ts +157 -157
  244. package/src/createDropdownList.svelte.ts +168 -168
  245. package/src/createForm.svelte.ts +386 -386
  246. package/src/createGrid.svelte.ts +42 -42
  247. package/src/createGrid.test.ts +10 -10
  248. package/src/createGridState.svelte.ts +17 -17
  249. package/src/createListbox.svelte.ts +250 -250
  250. package/src/createMenu.svelte.ts +224 -225
  251. package/src/createPopoverSelect.svelte.ts +213 -213
  252. package/src/createSlider.svelte.ts +191 -191
  253. package/src/createTooltip.svelte.ts +144 -144
  254. package/src/createTree.svelte.ts +319 -319
  255. package/src/editing.test.ts +949 -949
  256. package/src/editing.ts +606 -709
  257. package/src/editor-contract.ts +164 -164
  258. package/src/editor-registry.grid.test.ts +144 -146
  259. package/src/editor-registry.ts +122 -122
  260. package/src/export-data-api.test.ts +126 -126
  261. package/src/export-format.test.ts +107 -107
  262. package/src/export-format.ts +601 -598
  263. package/src/features.ts +0 -90
  264. package/src/filter-operators.ts +157 -157
  265. package/src/flex-render.ts +3 -3
  266. package/src/form-field.ts +127 -127
  267. package/src/group-display.test.ts +167 -167
  268. package/src/group-display.ts +200 -200
  269. package/src/index.ts +724 -724
  270. package/src/js-scroller.svelte.ts +173 -173
  271. package/src/keyboard-handlers.coverage.test.ts +1 -1
  272. package/src/keyboard-handlers.ts +270 -390
  273. package/src/keyboard.test.ts +59 -59
  274. package/src/keyboard.ts +97 -97
  275. package/src/list-nav.test.ts +49 -49
  276. package/src/list-nav.ts +29 -29
  277. package/src/list-option.test.ts +56 -56
  278. package/src/list-option.ts +172 -172
  279. package/src/menus.test.ts +0 -1
  280. package/src/menus.ts +567 -679
  281. package/src/merge-objects.ts +48 -48
  282. package/src/new-features.test.ts +3 -1
  283. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +1 -0
  284. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +178 -0
  285. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +3843 -0
  286. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +1 -0
  287. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +23 -0
  288. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +1 -0
  289. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +1925 -0
  290. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +1 -0
  291. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +206 -0
  292. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +1 -0
  293. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +20 -0
  294. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +1 -0
  295. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +264 -0
  296. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +1 -0
  297. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +698 -0
  298. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +1 -0
  299. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +3 -0
  300. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +135 -0
  301. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +1 -0
  302. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +57 -0
  303. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +1 -0
  304. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +2 -0
  305. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +46691 -0
  306. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +1 -0
  307. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +239 -0
  308. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +1 -0
  309. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +2 -0
  310. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +6 -0
  311. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +1 -0
  312. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +7 -0
  313. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +6 -0
  314. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +1 -0
  315. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +7 -0
  316. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +1 -0
  317. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +7 -0
  318. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +1 -0
  319. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +7 -0
  320. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +1 -0
  321. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +6 -0
  322. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +85 -0
  323. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +1 -0
  324. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +561 -0
  325. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +1 -0
  326. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +26 -0
  327. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +1 -0
  328. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +124 -0
  329. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +1 -0
  330. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +2 -0
  331. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +91 -0
  332. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +1 -0
  333. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +242 -0
  334. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +1 -0
  335. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +497 -0
  336. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +1 -0
  337. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +4929 -0
  338. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +1 -0
  339. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +192 -0
  340. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +1 -0
  341. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +10 -0
  342. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +1 -0
  343. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +140 -0
  344. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js.map +1 -0
  345. package/src/overlays.test.ts +90 -90
  346. package/src/render-component.ts +28 -28
  347. package/src/row-drag.test.ts +1 -1
  348. package/src/row-resize.test.ts +1 -2
  349. package/src/row-resize.ts +210 -210
  350. package/src/scheduler-model.test.ts +562 -562
  351. package/src/scheduler-model.ts +872 -872
  352. package/src/scroll-sync.test.ts +4 -7
  353. package/src/scroll-sync.ts +0 -122
  354. package/src/selection.test.ts +754 -754
  355. package/src/selection.ts +491 -600
  356. package/src/server-data-source.test.ts +289 -289
  357. package/src/server-data-source.ts +413 -413
  358. package/src/server-group-model.test.ts +2 -2
  359. package/src/sparkline.test.ts +68 -68
  360. package/src/sparkline.ts +169 -169
  361. package/src/spreadsheet.test.ts +488 -488
  362. package/src/spreadsheet.ts +312 -312
  363. package/src/static-functions.ts +11 -11
  364. package/src/subscribe.ts +38 -38
  365. package/src/summaries.ts +0 -112
  366. package/src/svgrid-wrapper.types.ts +526 -526
  367. package/src/svgrid.async-editor-options.test.ts +271 -271
  368. package/src/svgrid.auto-row-height.test.ts +204 -204
  369. package/src/svgrid.behavior.test.ts +705 -706
  370. package/src/svgrid.charting.test.ts +534 -534
  371. package/src/svgrid.column-reorder.test.ts +0 -8
  372. package/src/svgrid.comments-autocomplete.test.ts +123 -123
  373. package/src/svgrid.context-menu.test.ts +147 -147
  374. package/src/svgrid.features.test.ts +157 -157
  375. package/src/svgrid.filter-depth.test.ts +163 -163
  376. package/src/svgrid.filter-menu-listbox.svelte.test.ts +322 -322
  377. package/src/svgrid.filter-menu-scroll.test.ts +112 -112
  378. package/src/svgrid.footer-pagesize.svelte.test.ts +86 -0
  379. package/src/svgrid.grand-total.test.ts +188 -188
  380. package/src/svgrid.group-display-mode.test.ts +171 -171
  381. package/src/svgrid.group-footers.test.ts +121 -121
  382. package/src/svgrid.group-pagination.test.ts +153 -153
  383. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  384. package/src/svgrid.tree-data.test.ts +186 -186
  385. package/src/svgrid.wrapper.test.ts +40 -40
  386. package/src/svgriddropdown.async-panel.svelte.test.ts +195 -195
  387. package/src/test-setup.ts +62 -62
  388. package/src/themes/index.ts +257 -257
  389. package/src/toast-store.svelte.ts +246 -246
  390. package/src/toast-store.test.ts +147 -147
  391. package/src/tree-row-model.test.ts +168 -169
  392. package/src/ui-buttons.test.ts +144 -144
  393. package/src/ui-inputs.test.ts +118 -118
  394. package/src/ui-localization.test.ts +113 -113
  395. package/src/ui-range.test.ts +70 -70
  396. package/src/ui-selection.test.ts +155 -155
  397. package/src/ui-tier1.test.ts +142 -142
  398. package/src/virtual.test.ts +88 -88
  399. package/src/virtualization/column-virtualizer.test.ts +27 -27
  400. package/src/virtualization/column-virtualizer.ts +30 -30
  401. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  402. package/src/virtualization/types.ts +30 -30
  403. package/src/virtualization/virtualizer.test.ts +47 -47
  404. package/src/virtualization/virtualizer.ts +296 -296
  405. package/dist/cdn/disclose-version-DoD9AFD_.js +0 -2958
@@ -1,706 +1,705 @@
1
- /**
2
- * Broad behavioral test suite for the <SvGrid /> render component.
3
- *
4
- * The intent is wide coverage on a single file - SvGrid.svelte is ~3000
5
- * lines and most of its branches are reachable only when the component is
6
- * mounted with a particular prop combination. Each test below exercises a
7
- * different feature set so the whole file's effect graph is traversed.
8
- *
9
- * Pattern (re-used across files):
10
- * 1. mount SvGrid in jsdom with the props that trigger the feature
11
- * 2. wait one microtask for $effects to flush
12
- * 3. assert on the api object delivered via onApiReady, or on visible DOM
13
- * 4. unmount
14
- */
15
-
16
- import { describe, expect, it } from 'vitest'
17
- import { mount, unmount } from 'svelte'
18
- import SvGrid from './SvGrid.svelte'
19
- import {
20
- columnFilteringFeature,
21
- columnGroupingFeature,
22
- createCoreRowModel,
23
- createExpandedRowModel,
24
- createFilteredRowModel,
25
- createGroupedRowModel,
26
- createPaginatedRowModel,
27
- createSortedRowModel,
28
- renderSnippet,
29
- rowExpandingFeature,
30
- rowPaginationFeature,
31
- rowSelectionFeature,
32
- rowSortingFeature,
33
- sortFns,
34
- tableFeatures,
35
- } from './index'
36
- import type { ColumnDef, SvGridApi } from './index'
37
-
38
- type Person = {
39
- id: number
40
- name: string
41
- team: string
42
- age: number
43
- active: boolean
44
- joined: string
45
- salary: number
46
- }
47
-
48
- const fullFeatures = tableFeatures({
49
- columnFilteringFeature,
50
- columnGroupingFeature,
51
- rowExpandingFeature,
52
- rowPaginationFeature,
53
- rowSelectionFeature,
54
- rowSortingFeature,
55
- })
56
-
57
- const people: Person[] = [
58
- { id: 1, name: 'Ada Lovelace', team: 'Research', age: 38, active: true, joined: '2020-01-10', salary: 142_000 },
59
- { id: 2, name: 'Grace Hopper', team: 'Compilers', age: 42, active: true, joined: '2018-05-22', salary: 158_000 },
60
- { id: 3, name: 'Alan Turing', team: 'Research', age: 41, active: false, joined: '2021-09-01', salary: 138_000 },
61
- { id: 4, name: 'Margaret Hamilton', team: 'Apollo', age: 35, active: true, joined: '2019-03-15', salary: 165_000 },
62
- { id: 5, name: 'Linus Torvalds', team: 'Kernel', age: 54, active: true, joined: '2017-11-30', salary: 175_000 },
63
- { id: 6, name: 'Donald Knuth', team: 'Research', age: 86, active: false, joined: '2010-06-06', salary: 120_000 },
64
- { id: 7, name: 'Brian Kernighan', team: 'Compilers', age: 80, active: true, joined: '2012-02-02', salary: 160_000 },
65
- { id: 8, name: 'Dennis Ritchie', team: 'Kernel', age: 70, active: false, joined: '2009-07-14', salary: 110_000 },
66
- ]
67
-
68
- const personColumns: ColumnDef<typeof fullFeatures, Person>[] = [
69
- { field: 'name', header: 'Name', width: 200 },
70
- { field: 'team', header: 'Team', width: 160 },
71
- {
72
- field: 'age',
73
- header: 'Age',
74
- width: 100,
75
- editorType: 'number',
76
- format: { type: 'number' },
77
- },
78
- {
79
- field: 'active',
80
- header: 'Active',
81
- width: 100,
82
- editorType: 'checkbox',
83
- },
84
- {
85
- field: 'joined',
86
- header: 'Joined',
87
- width: 140,
88
- editorType: 'date',
89
- format: { type: 'number' },
90
- },
91
- {
92
- field: 'salary',
93
- header: 'Salary',
94
- width: 140,
95
- editorType: 'number',
96
- format: { type: 'currency', currency: 'USD' },
97
- },
98
- ]
99
-
100
- type MountResult = {
101
- api: SvGridApi<typeof fullFeatures, Person>
102
- target: HTMLElement
103
- destroy: () => void
104
- }
105
-
106
- function mountGrid(overrides: Record<string, unknown> = {}): Promise<MountResult> {
107
- return new Promise((resolveApi, rejectApi) => {
108
- const target = document.createElement('div')
109
- target.style.width = '1200px'
110
- target.style.height = '600px'
111
- document.body.appendChild(target)
112
-
113
- let capturedApi: SvGridApi<typeof fullFeatures, Person> | null = null
114
-
115
- const app = mount(SvGrid, {
116
- target,
117
- props: {
118
- data: people,
119
- columns: personColumns,
120
- features: fullFeatures,
121
- _rowModels: {
122
- coreRowModel: createCoreRowModel(),
123
- filteredRowModel: createFilteredRowModel(),
124
- sortedRowModel: createSortedRowModel(sortFns),
125
- groupedRowModel: createGroupedRowModel(),
126
- expandedRowModel: createExpandedRowModel(),
127
- paginatedRowModel: createPaginatedRowModel(),
128
- },
129
- rowHeight: 36,
130
- containerHeight: 480,
131
- virtualization: false,
132
- onApiReady(api: SvGridApi<typeof fullFeatures, Person>) {
133
- capturedApi = api
134
- resolveApi({
135
- api,
136
- target,
137
- destroy: () => {
138
- unmount(app)
139
- target.remove()
140
- },
141
- })
142
- },
143
- ...overrides,
144
- } as any,
145
- })
146
-
147
- queueMicrotask(() => {
148
- if (!capturedApi) rejectApi(new Error('onApiReady never fired'))
149
- })
150
- })
151
- }
152
-
153
- const tick = () => Promise.resolve()
154
-
155
- describe('SvGrid - core render', () => {
156
- it('mounts and renders the column headers', async () => {
157
- const { target, destroy } = await mountGrid()
158
- try {
159
- const headers = target.querySelectorAll('[data-svgrid-header-col]')
160
- // jsdom reports 0 for offsetWidth so column virtualization may render
161
- // a subset. The point of this assertion is just that the header row
162
- // exists and is populated.
163
- expect(headers.length).toBeGreaterThan(0)
164
- } finally {
165
- destroy()
166
- }
167
- })
168
-
169
- it('renders the rows in the body', async () => {
170
- const { target, destroy } = await mountGrid()
171
- try {
172
- await tick()
173
- const rows = target.querySelectorAll('[data-svgrid-row]')
174
- // Pagination defaults to off in our mount - all rows render.
175
- expect(rows.length).toBeGreaterThanOrEqual(people.length)
176
- } finally {
177
- destroy()
178
- }
179
- })
180
-
181
- it('renders the empty message when data is empty', async () => {
182
- const { target, destroy } = await mountGrid({ data: [], emptyMessage: 'No rows yet' })
183
- try {
184
- await tick()
185
- expect(target.textContent).toContain('No rows yet')
186
- } finally {
187
- destroy()
188
- }
189
- })
190
-
191
- it('renders a loading state when `loading` is true', async () => {
192
- const { target, destroy } = await mountGrid({ loading: true })
193
- try {
194
- await tick()
195
- const statusEls = target.querySelectorAll('[role="status"]')
196
- expect(statusEls.length).toBeGreaterThan(0)
197
- } finally {
198
- destroy()
199
- }
200
- })
201
-
202
- it('renders an error state when `error` is set', async () => {
203
- const { target, destroy } = await mountGrid({ error: 'Something broke' })
204
- try {
205
- await tick()
206
- expect(target.textContent).toContain('Something broke')
207
- } finally {
208
- destroy()
209
- }
210
- })
211
- })
212
-
213
- describe('SvGrid - sort', () => {
214
- it('setSort then clearSort updates filters via api', async () => {
215
- const { api, destroy } = await mountGrid()
216
- try {
217
- api.setSort('name', 'asc')
218
- await tick()
219
- api.setSort('name', 'desc')
220
- await tick()
221
- api.setSort('name', null)
222
- await tick()
223
- api.clearSort()
224
- await tick()
225
- // No throw + state consistent = pass.
226
- expect(api.getData().length).toBe(people.length)
227
- } finally {
228
- destroy()
229
- }
230
- })
231
- })
232
-
233
- describe('SvGrid - pagination', () => {
234
- it('shows fewer displayed rows than total when paginated', async () => {
235
- const { api, destroy } = await mountGrid({ showPagination: true, pageSize: 3 })
236
- try {
237
- await tick()
238
- const displayed = api.getDisplayedRows()
239
- expect(displayed.length).toBeLessThanOrEqual(3)
240
- } finally {
241
- destroy()
242
- }
243
- })
244
- })
245
-
246
- describe('SvGrid - global filter', () => {
247
- it('showGlobalFilter renders the input', async () => {
248
- const { target, destroy } = await mountGrid({ showGlobalFilter: true })
249
- try {
250
- await tick()
251
- const input = target.querySelector(
252
- '.sv-grid-global-filter input, input[type="text"]',
253
- )
254
- expect(input).not.toBeNull()
255
- } finally {
256
- destroy()
257
- }
258
- })
259
- })
260
-
261
- describe('SvGrid - column filter row', () => {
262
- it('showColumnFilters renders the filter row inputs', async () => {
263
- const { target, destroy } = await mountGrid({ showColumnFilters: true })
264
- try {
265
- await tick()
266
- const inputs = target.querySelectorAll('.sv-grid-column-filter')
267
- // One filter input per filterable column.
268
- expect(inputs.length).toBeGreaterThan(0)
269
- } finally {
270
- destroy()
271
- }
272
- })
273
- })
274
-
275
- describe('SvGrid - inline editing', () => {
276
- it('enables enableInlineEditing without throwing', async () => {
277
- const { api, destroy } = await mountGrid({ enableInlineEditing: true })
278
- try {
279
- // setCellValue should mutate internal data.
280
- api.setCellValue(0, 'name', 'Renamed Person')
281
- await tick()
282
- const data = api.getData()
283
- expect((data[0] as Person).name).toBe('Renamed Person')
284
- } finally {
285
- destroy()
286
- }
287
- })
288
- })
289
-
290
- describe('SvGrid - row selection', () => {
291
- it('showRowSelection renders the checkbox column', async () => {
292
- const { target, destroy } = await mountGrid({ showRowSelection: true })
293
- try {
294
- await tick()
295
- const checkboxes = target.querySelectorAll('.sv-grid-checkbox')
296
- // At least the header + one per row.
297
- expect(checkboxes.length).toBeGreaterThan(0)
298
- } finally {
299
- destroy()
300
- }
301
- })
302
- })
303
-
304
- describe('SvGrid - capability shortcuts', () => {
305
- it('sortable + filterable enable sorting/filtering UI with no features prop', async () => {
306
- const { target, destroy } = await mountGrid({
307
- features: undefined,
308
- sortable: true,
309
- filterable: true,
310
- })
311
- try {
312
- await tick()
313
- // rowSortingFeature injected -> headers expose aria-sort.
314
- expect(
315
- target.querySelectorAll('[role="columnheader"][aria-sort]').length,
316
- ).toBeGreaterThan(0)
317
- // columnFilteringFeature injected -> per-column filter button renders.
318
- expect(target.querySelector('.sv-grid-col-filter-btn')).toBeTruthy()
319
- } finally {
320
- destroy()
321
- }
322
- })
323
-
324
- it('sortable={false} overrides a rowSortingFeature passed via features', async () => {
325
- // The harness default `fullFeatures` includes rowSortingFeature.
326
- const { target, destroy } = await mountGrid({ sortable: false })
327
- try {
328
- await tick()
329
- expect(
330
- target.querySelector('[role="columnheader"][aria-sort]'),
331
- ).toBeNull()
332
- } finally {
333
- destroy()
334
- }
335
- })
336
-
337
- it('pageable toggles the pagination footer', async () => {
338
- const off = await mountGrid({ pageable: false })
339
- try {
340
- await tick()
341
- expect(off.target.querySelector('.sv-grid-pagination')).toBeNull()
342
- } finally {
343
- off.destroy()
344
- }
345
- const on = await mountGrid({ features: undefined, pageable: true })
346
- try {
347
- await tick()
348
- expect(on.target.querySelector('.sv-grid-pagination')).toBeTruthy()
349
- } finally {
350
- on.destroy()
351
- }
352
- })
353
-
354
- it('paginationPosition mounts + gates the bottom pager', async () => {
355
- // The top pager is gated on measurement (jsdom does not measure), so it's not
356
- // asserted here; the visible top pager is covered by the browser/e2e check.
357
- // This guards the mount path (a top footer rendered pre-measure used to crash).
358
- for (const paginationPosition of ['top', 'both', 'bottom'] as const) {
359
- const g = await mountGrid({ showPagination: true, paginationPosition })
360
- try {
361
- await tick()
362
- expect(g.api).toBeTruthy()
363
- const bottoms = [...g.target.querySelectorAll('.sv-grid-pagination')].filter((el) => !el.classList.contains('sv-grid-pagination-top'))
364
- expect(bottoms.length).toBe(paginationPosition === 'top' ? 0 : 1) // no bottom pager when position is 'top'
365
- } finally {
366
- g.destroy()
367
- }
368
- }
369
- })
370
-
371
- it('pageSizeOptions is accepted by the pager', async () => {
372
- const g = await mountGrid({ showPagination: true, pageSizeOptions: [5, 15, 45] })
373
- try {
374
- await tick()
375
- expect(g.target.querySelector('.sv-grid-pagination')).toBeTruthy()
376
- } finally {
377
- g.destroy()
378
- }
379
- })
380
-
381
- it('editable={false} blocks inline editing entry points', async () => {
382
- const { api, target, destroy } = await mountGrid({ editable: false })
383
- try {
384
- await tick()
385
- // Double-clicking a body cell must not open an editor when editing
386
- // is disabled via the shortcut.
387
- const cell = target.querySelector<HTMLElement>('.sv-grid-cell')
388
- cell?.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }))
389
- await tick()
390
- expect(target.querySelector('.sv-grid-cell-editor')).toBeNull()
391
- expect(api.getData().length).toBe(people.length)
392
- } finally {
393
- destroy()
394
- }
395
- })
396
- })
397
-
398
- describe('SvGrid - cell selection', () => {
399
- it('enableCellSelection mounts without error', async () => {
400
- const { api, destroy } = await mountGrid({ enableCellSelection: true })
401
- try {
402
- await tick()
403
- expect(api.getData().length).toBe(people.length)
404
- } finally {
405
- destroy()
406
- }
407
- })
408
- })
409
-
410
- describe('SvGrid - grouping + aggregation', () => {
411
- it('setGroupBy mounts + the codepath runs without throwing', async () => {
412
- const { api, target, destroy } = await mountGrid({
413
- enableRowSummaries: true,
414
- showGroupingControls: true,
415
- })
416
- try {
417
- api.setGroupBy(['team'])
418
- await tick()
419
- await tick()
420
- // Sanity: the grid is still mounted and the API responsive.
421
- const data = api.getData()
422
- expect(data.length).toBe(people.length)
423
- // Group rendering depends on row model + container dimensions in jsdom;
424
- // just verify the codepath does not throw.
425
- expect(target).toBeTruthy()
426
- } finally {
427
- destroy()
428
- }
429
- })
430
- })
431
-
432
- describe('SvGrid - column add / remove / visibility', () => {
433
- it('addColumn and removeColumn round-trip', async () => {
434
- const { api, destroy } = await mountGrid()
435
- try {
436
- api.addColumn({ id: 'id-col', field: 'id', header: 'ID', width: 60 } as any, 'left')
437
- await tick()
438
- api.addColumn(
439
- { id: 'extra-tag', field: 'team', header: 'Extra', width: 60 } as any,
440
- 'right',
441
- )
442
- await tick()
443
- api.addColumn(
444
- { id: 'mid-col', field: 'name', header: 'Mid', width: 60 } as any,
445
- 1,
446
- )
447
- await tick()
448
- api.removeColumn('id-col')
449
- await tick()
450
- // No throw means the codepath was exercised.
451
- expect(typeof api.getData).toBe('function')
452
- } finally {
453
- destroy()
454
- }
455
- })
456
-
457
- it('setColumnVisible toggles visibility flag', async () => {
458
- const { api, destroy } = await mountGrid()
459
- try {
460
- expect(api.isColumnVisible('name')).toBe(true)
461
- api.setColumnVisible('name', false)
462
- await tick()
463
- expect(api.isColumnVisible('name')).toBe(false)
464
- api.setColumnVisible('name', true)
465
- await tick()
466
- expect(api.isColumnVisible('name')).toBe(true)
467
- } finally {
468
- destroy()
469
- }
470
- })
471
-
472
- it('columns marked `visible: false` start hidden but stay listed', async () => {
473
- const columns: ColumnDef<typeof fullFeatures, Person>[] = personColumns.map(
474
- (c) => (c.field === 'team' ? { ...c, visible: false } : c),
475
- )
476
- const { api, destroy } = await mountGrid({ columns })
477
- try {
478
- // Starts hidden...
479
- expect(api.isColumnVisible('team')).toBe(false)
480
- // ...but is still listed in getColumns() (so a Choose Columns UI
481
- // can offer it), just with visible=false.
482
- const team = api.getColumns().find((c) => c.id === 'team')
483
- expect(team).toBeDefined()
484
- expect(team?.visible).toBe(false)
485
- // A later user toggle wins over the initial flag.
486
- api.setColumnVisible('team', true)
487
- await tick()
488
- expect(api.isColumnVisible('team')).toBe(true)
489
- } finally {
490
- destroy()
491
- }
492
- })
493
- })
494
-
495
- describe('SvGrid - row add / remove', () => {
496
- it('addRow at top / bottom / specific index', async () => {
497
- const { api, destroy } = await mountGrid()
498
- try {
499
- const before = api.getData().length
500
- api.addRow({ id: 99, name: 'Top', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 'top')
501
- api.addRow({ id: 100, name: 'Bottom', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 'bottom')
502
- api.addRow({ id: 101, name: 'Mid', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 2)
503
- await tick()
504
- expect(api.getData().length).toBe(before + 3)
505
- } finally {
506
- destroy()
507
- }
508
- })
509
-
510
- it('addRows / removeRow / removeRows', async () => {
511
- const { api, destroy } = await mountGrid()
512
- try {
513
- const before = api.getData().length
514
- api.addRows(
515
- [
516
- { id: 90, name: 'A', team: 'X', age: 1, active: true, joined: '2025', salary: 1 },
517
- { id: 91, name: 'B', team: 'X', age: 1, active: true, joined: '2025', salary: 1 },
518
- ],
519
- 'bottom',
520
- )
521
- await tick()
522
- api.removeRow(0)
523
- await tick()
524
- api.removeRows([0, 1])
525
- await tick()
526
- expect(api.getData().length).toBe(before + 2 - 3)
527
- } finally {
528
- destroy()
529
- }
530
- })
531
- })
532
-
533
- describe('SvGrid - getCellValue', () => {
534
- it('returns the cell value for a known row+column', async () => {
535
- const { api, destroy } = await mountGrid()
536
- try {
537
- const value = api.getCellValue(0, 'name')
538
- expect(value).toBe(people[0]!.name)
539
- } finally {
540
- destroy()
541
- }
542
- })
543
-
544
- it('returns undefined for unknown row or column', async () => {
545
- const { api, destroy } = await mountGrid()
546
- try {
547
- expect(api.getCellValue(999, 'name')).toBeUndefined()
548
- expect(api.getCellValue(0, 'no-such-col')).toBeUndefined()
549
- } finally {
550
- destroy()
551
- }
552
- })
553
- })
554
-
555
- describe('SvGrid - row number column', () => {
556
- it('showRowNumbers renders the leading row-number column', async () => {
557
- const { target, destroy } = await mountGrid({ showRowNumbers: true })
558
- try {
559
- await tick()
560
- const rnCells = target.querySelectorAll('.sv-grid-row-number-cell')
561
- expect(rnCells.length).toBeGreaterThan(0)
562
- } finally {
563
- destroy()
564
- }
565
- })
566
- })
567
-
568
- describe('SvGrid - external sort / filter', () => {
569
- it('externalSort + onSortingChange fires without re-ordering rows', async () => {
570
- let captured: Array<{ id: string; desc: boolean }> | null = null
571
- const { api, destroy } = await mountGrid({
572
- externalSort: true,
573
- onSortingChange: (s: any) => (captured = s),
574
- })
575
- try {
576
- api.setSort('age', 'desc')
577
- await tick()
578
- expect(captured).not.toBeNull()
579
- } finally {
580
- destroy()
581
- }
582
- })
583
-
584
- it('externalFilter + onFiltersChange fires when a filter is set', async () => {
585
- let calls = 0
586
- const { api, destroy } = await mountGrid({
587
- externalFilter: true,
588
- onFiltersChange: () => {
589
- calls += 1
590
- },
591
- })
592
- try {
593
- api.setFilter('team', { operator: 'contains', value: 'Research' })
594
- await tick()
595
- expect(calls).toBeGreaterThan(0)
596
- } finally {
597
- destroy()
598
- }
599
- })
600
- })
601
-
602
- describe('SvGrid - custom snippet cell', () => {
603
- it('accepts a custom cell renderer without throwing', async () => {
604
- // Build a snippet via raw object - the SvGrid component reads
605
- // `column.columnDef.cell` and pipes it through FlexRender. Returning a
606
- // plain string is the simplest renderer; tests only need to verify the
607
- // render path doesn't crash.
608
- const customCols: ColumnDef<typeof fullFeatures, Person>[] = personColumns.map((c) =>
609
- c.field === 'name'
610
- ? {
611
- ...c,
612
- cell: (ctx: any) => `★ ${(ctx.row.original as Person).name}`,
613
- }
614
- : c,
615
- )
616
- const { target, destroy } = await mountGrid({ columns: customCols })
617
- try {
618
- await tick()
619
- expect(target.textContent).toContain('★')
620
- } finally {
621
- destroy()
622
- }
623
- })
624
- })
625
-
626
- describe('SvGrid - filterMode shortcuts', () => {
627
- it('filterMode="row" + global filter input wiring', async () => {
628
- const { destroy } = await mountGrid({ filterMode: 'row' })
629
- try {
630
- await tick()
631
- // No assertion needed - exercising the codepath is enough.
632
- expect(true).toBe(true)
633
- } finally {
634
- destroy()
635
- }
636
- })
637
- it('filterMode="global"', async () => {
638
- const { destroy } = await mountGrid({ filterMode: 'global' })
639
- try {
640
- await tick()
641
- expect(true).toBe(true)
642
- } finally {
643
- destroy()
644
- }
645
- })
646
- it('filterMode="none"', async () => {
647
- const { destroy } = await mountGrid({ filterMode: 'none' })
648
- try {
649
- await tick()
650
- expect(true).toBe(true)
651
- } finally {
652
- destroy()
653
- }
654
- })
655
- })
656
-
657
- describe('SvGrid - selectionMode shortcuts', () => {
658
- it('selectionMode="row"', async () => {
659
- const { destroy } = await mountGrid({ selectionMode: 'row' })
660
- try {
661
- await tick()
662
- expect(true).toBe(true)
663
- } finally {
664
- destroy()
665
- }
666
- })
667
- it('selectionMode="cell"', async () => {
668
- const { destroy } = await mountGrid({ selectionMode: 'cell' })
669
- try {
670
- await tick()
671
- expect(true).toBe(true)
672
- } finally {
673
- destroy()
674
- }
675
- })
676
- it('selectionMode="both"', async () => {
677
- const { destroy } = await mountGrid({ selectionMode: 'both' })
678
- try {
679
- await tick()
680
- expect(true).toBe(true)
681
- } finally {
682
- destroy()
683
- }
684
- })
685
- it('selectionMode="none"', async () => {
686
- const { destroy } = await mountGrid({ selectionMode: 'none' })
687
- try {
688
- await tick()
689
- expect(true).toBe(true)
690
- } finally {
691
- destroy()
692
- }
693
- })
694
- })
695
-
696
- describe('SvGrid - fitColumns', () => {
697
- it('mounts with fitColumns=true without throwing', async () => {
698
- const { destroy } = await mountGrid({ fitColumns: true })
699
- try {
700
- await tick()
701
- expect(true).toBe(true)
702
- } finally {
703
- destroy()
704
- }
705
- })
706
- })
1
+ /**
2
+ * Broad behavioral test suite for the <SvGrid /> render component.
3
+ *
4
+ * The intent is wide coverage on a single file - SvGrid.svelte is ~3000
5
+ * lines and most of its branches are reachable only when the component is
6
+ * mounted with a particular prop combination. Each test below exercises a
7
+ * different feature set so the whole file's effect graph is traversed.
8
+ *
9
+ * Pattern (re-used across files):
10
+ * 1. mount SvGrid in jsdom with the props that trigger the feature
11
+ * 2. wait one microtask for $effects to flush
12
+ * 3. assert on the api object delivered via onApiReady, or on visible DOM
13
+ * 4. unmount
14
+ */
15
+
16
+ import { describe, expect, it } from 'vitest'
17
+ import { mount, unmount } from 'svelte'
18
+ import SvGrid from './SvGrid.svelte'
19
+ import {
20
+ columnFilteringFeature,
21
+ columnGroupingFeature,
22
+ createCoreRowModel,
23
+ createExpandedRowModel,
24
+ createFilteredRowModel,
25
+ createGroupedRowModel,
26
+ createPaginatedRowModel,
27
+ createSortedRowModel,
28
+ rowExpandingFeature,
29
+ rowPaginationFeature,
30
+ rowSelectionFeature,
31
+ rowSortingFeature,
32
+ sortFns,
33
+ tableFeatures,
34
+ } from './index'
35
+ import type { ColumnDef, SvGridApi } from './index'
36
+
37
+ type Person = {
38
+ id: number
39
+ name: string
40
+ team: string
41
+ age: number
42
+ active: boolean
43
+ joined: string
44
+ salary: number
45
+ }
46
+
47
+ const fullFeatures = tableFeatures({
48
+ columnFilteringFeature,
49
+ columnGroupingFeature,
50
+ rowExpandingFeature,
51
+ rowPaginationFeature,
52
+ rowSelectionFeature,
53
+ rowSortingFeature,
54
+ })
55
+
56
+ const people: Person[] = [
57
+ { id: 1, name: 'Ada Lovelace', team: 'Research', age: 38, active: true, joined: '2020-01-10', salary: 142_000 },
58
+ { id: 2, name: 'Grace Hopper', team: 'Compilers', age: 42, active: true, joined: '2018-05-22', salary: 158_000 },
59
+ { id: 3, name: 'Alan Turing', team: 'Research', age: 41, active: false, joined: '2021-09-01', salary: 138_000 },
60
+ { id: 4, name: 'Margaret Hamilton', team: 'Apollo', age: 35, active: true, joined: '2019-03-15', salary: 165_000 },
61
+ { id: 5, name: 'Linus Torvalds', team: 'Kernel', age: 54, active: true, joined: '2017-11-30', salary: 175_000 },
62
+ { id: 6, name: 'Donald Knuth', team: 'Research', age: 86, active: false, joined: '2010-06-06', salary: 120_000 },
63
+ { id: 7, name: 'Brian Kernighan', team: 'Compilers', age: 80, active: true, joined: '2012-02-02', salary: 160_000 },
64
+ { id: 8, name: 'Dennis Ritchie', team: 'Kernel', age: 70, active: false, joined: '2009-07-14', salary: 110_000 },
65
+ ]
66
+
67
+ const personColumns: ColumnDef<typeof fullFeatures, Person>[] = [
68
+ { field: 'name', header: 'Name', width: 200 },
69
+ { field: 'team', header: 'Team', width: 160 },
70
+ {
71
+ field: 'age',
72
+ header: 'Age',
73
+ width: 100,
74
+ editorType: 'number',
75
+ format: { type: 'number' },
76
+ },
77
+ {
78
+ field: 'active',
79
+ header: 'Active',
80
+ width: 100,
81
+ editorType: 'checkbox',
82
+ },
83
+ {
84
+ field: 'joined',
85
+ header: 'Joined',
86
+ width: 140,
87
+ editorType: 'date',
88
+ format: { type: 'number' },
89
+ },
90
+ {
91
+ field: 'salary',
92
+ header: 'Salary',
93
+ width: 140,
94
+ editorType: 'number',
95
+ format: { type: 'currency', currency: 'USD' },
96
+ },
97
+ ]
98
+
99
+ type MountResult = {
100
+ api: SvGridApi<typeof fullFeatures, Person>
101
+ target: HTMLElement
102
+ destroy: () => void
103
+ }
104
+
105
+ function mountGrid(overrides: Record<string, unknown> = {}): Promise<MountResult> {
106
+ return new Promise((resolveApi, rejectApi) => {
107
+ const target = document.createElement('div')
108
+ target.style.width = '1200px'
109
+ target.style.height = '600px'
110
+ document.body.appendChild(target)
111
+
112
+ let capturedApi: SvGridApi<typeof fullFeatures, Person> | null = null
113
+
114
+ const app = mount(SvGrid, {
115
+ target,
116
+ props: {
117
+ data: people,
118
+ columns: personColumns,
119
+ features: fullFeatures,
120
+ _rowModels: {
121
+ coreRowModel: createCoreRowModel(),
122
+ filteredRowModel: createFilteredRowModel(),
123
+ sortedRowModel: createSortedRowModel(sortFns),
124
+ groupedRowModel: createGroupedRowModel(),
125
+ expandedRowModel: createExpandedRowModel(),
126
+ paginatedRowModel: createPaginatedRowModel(),
127
+ },
128
+ rowHeight: 36,
129
+ containerHeight: 480,
130
+ virtualization: false,
131
+ onApiReady(api: SvGridApi<typeof fullFeatures, Person>) {
132
+ capturedApi = api
133
+ resolveApi({
134
+ api,
135
+ target,
136
+ destroy: () => {
137
+ unmount(app)
138
+ target.remove()
139
+ },
140
+ })
141
+ },
142
+ ...overrides,
143
+ } as any,
144
+ })
145
+
146
+ queueMicrotask(() => {
147
+ if (!capturedApi) rejectApi(new Error('onApiReady never fired'))
148
+ })
149
+ })
150
+ }
151
+
152
+ const tick = () => Promise.resolve()
153
+
154
+ describe('SvGrid - core render', () => {
155
+ it('mounts and renders the column headers', async () => {
156
+ const { target, destroy } = await mountGrid()
157
+ try {
158
+ const headers = target.querySelectorAll('[data-svgrid-header-col]')
159
+ // jsdom reports 0 for offsetWidth so column virtualization may render
160
+ // a subset. The point of this assertion is just that the header row
161
+ // exists and is populated.
162
+ expect(headers.length).toBeGreaterThan(0)
163
+ } finally {
164
+ destroy()
165
+ }
166
+ })
167
+
168
+ it('renders the rows in the body', async () => {
169
+ const { target, destroy } = await mountGrid()
170
+ try {
171
+ await tick()
172
+ const rows = target.querySelectorAll('[data-svgrid-row]')
173
+ // Pagination defaults to off in our mount - all rows render.
174
+ expect(rows.length).toBeGreaterThanOrEqual(people.length)
175
+ } finally {
176
+ destroy()
177
+ }
178
+ })
179
+
180
+ it('renders the empty message when data is empty', async () => {
181
+ const { target, destroy } = await mountGrid({ data: [], emptyMessage: 'No rows yet' })
182
+ try {
183
+ await tick()
184
+ expect(target.textContent).toContain('No rows yet')
185
+ } finally {
186
+ destroy()
187
+ }
188
+ })
189
+
190
+ it('renders a loading state when `loading` is true', async () => {
191
+ const { target, destroy } = await mountGrid({ loading: true })
192
+ try {
193
+ await tick()
194
+ const statusEls = target.querySelectorAll('[role="status"]')
195
+ expect(statusEls.length).toBeGreaterThan(0)
196
+ } finally {
197
+ destroy()
198
+ }
199
+ })
200
+
201
+ it('renders an error state when `error` is set', async () => {
202
+ const { target, destroy } = await mountGrid({ error: 'Something broke' })
203
+ try {
204
+ await tick()
205
+ expect(target.textContent).toContain('Something broke')
206
+ } finally {
207
+ destroy()
208
+ }
209
+ })
210
+ })
211
+
212
+ describe('SvGrid - sort', () => {
213
+ it('setSort then clearSort updates filters via api', async () => {
214
+ const { api, destroy } = await mountGrid()
215
+ try {
216
+ api.setSort('name', 'asc')
217
+ await tick()
218
+ api.setSort('name', 'desc')
219
+ await tick()
220
+ api.setSort('name', null)
221
+ await tick()
222
+ api.clearSort()
223
+ await tick()
224
+ // No throw + state consistent = pass.
225
+ expect(api.getData().length).toBe(people.length)
226
+ } finally {
227
+ destroy()
228
+ }
229
+ })
230
+ })
231
+
232
+ describe('SvGrid - pagination', () => {
233
+ it('shows fewer displayed rows than total when paginated', async () => {
234
+ const { api, destroy } = await mountGrid({ showPagination: true, pageSize: 3 })
235
+ try {
236
+ await tick()
237
+ const displayed = api.getDisplayedRows()
238
+ expect(displayed.length).toBeLessThanOrEqual(3)
239
+ } finally {
240
+ destroy()
241
+ }
242
+ })
243
+ })
244
+
245
+ describe('SvGrid - global filter', () => {
246
+ it('showGlobalFilter renders the input', async () => {
247
+ const { target, destroy } = await mountGrid({ showGlobalFilter: true })
248
+ try {
249
+ await tick()
250
+ const input = target.querySelector(
251
+ '.sv-grid-global-filter input, input[type="text"]',
252
+ )
253
+ expect(input).not.toBeNull()
254
+ } finally {
255
+ destroy()
256
+ }
257
+ })
258
+ })
259
+
260
+ describe('SvGrid - column filter row', () => {
261
+ it('showColumnFilters renders the filter row inputs', async () => {
262
+ const { target, destroy } = await mountGrid({ showColumnFilters: true })
263
+ try {
264
+ await tick()
265
+ const inputs = target.querySelectorAll('.sv-grid-column-filter')
266
+ // One filter input per filterable column.
267
+ expect(inputs.length).toBeGreaterThan(0)
268
+ } finally {
269
+ destroy()
270
+ }
271
+ })
272
+ })
273
+
274
+ describe('SvGrid - inline editing', () => {
275
+ it('enables enableInlineEditing without throwing', async () => {
276
+ const { api, destroy } = await mountGrid({ enableInlineEditing: true })
277
+ try {
278
+ // setCellValue should mutate internal data.
279
+ api.setCellValue(0, 'name', 'Renamed Person')
280
+ await tick()
281
+ const data = api.getData()
282
+ expect((data[0] as Person).name).toBe('Renamed Person')
283
+ } finally {
284
+ destroy()
285
+ }
286
+ })
287
+ })
288
+
289
+ describe('SvGrid - row selection', () => {
290
+ it('showRowSelection renders the checkbox column', async () => {
291
+ const { target, destroy } = await mountGrid({ showRowSelection: true })
292
+ try {
293
+ await tick()
294
+ const checkboxes = target.querySelectorAll('.sv-grid-checkbox')
295
+ // At least the header + one per row.
296
+ expect(checkboxes.length).toBeGreaterThan(0)
297
+ } finally {
298
+ destroy()
299
+ }
300
+ })
301
+ })
302
+
303
+ describe('SvGrid - capability shortcuts', () => {
304
+ it('sortable + filterable enable sorting/filtering UI with no features prop', async () => {
305
+ const { target, destroy } = await mountGrid({
306
+ features: undefined,
307
+ sortable: true,
308
+ filterable: true,
309
+ })
310
+ try {
311
+ await tick()
312
+ // rowSortingFeature injected -> headers expose aria-sort.
313
+ expect(
314
+ target.querySelectorAll('[role="columnheader"][aria-sort]').length,
315
+ ).toBeGreaterThan(0)
316
+ // columnFilteringFeature injected -> per-column filter button renders.
317
+ expect(target.querySelector('.sv-grid-col-filter-btn')).toBeTruthy()
318
+ } finally {
319
+ destroy()
320
+ }
321
+ })
322
+
323
+ it('sortable={false} overrides a rowSortingFeature passed via features', async () => {
324
+ // The harness default `fullFeatures` includes rowSortingFeature.
325
+ const { target, destroy } = await mountGrid({ sortable: false })
326
+ try {
327
+ await tick()
328
+ expect(
329
+ target.querySelector('[role="columnheader"][aria-sort]'),
330
+ ).toBeNull()
331
+ } finally {
332
+ destroy()
333
+ }
334
+ })
335
+
336
+ it('pageable toggles the pagination footer', async () => {
337
+ const off = await mountGrid({ pageable: false })
338
+ try {
339
+ await tick()
340
+ expect(off.target.querySelector('.sv-grid-pagination')).toBeNull()
341
+ } finally {
342
+ off.destroy()
343
+ }
344
+ const on = await mountGrid({ features: undefined, pageable: true })
345
+ try {
346
+ await tick()
347
+ expect(on.target.querySelector('.sv-grid-pagination')).toBeTruthy()
348
+ } finally {
349
+ on.destroy()
350
+ }
351
+ })
352
+
353
+ it('paginationPosition mounts + gates the bottom pager', async () => {
354
+ // The top pager is gated on measurement (jsdom does not measure), so it's not
355
+ // asserted here; the visible top pager is covered by the browser/e2e check.
356
+ // This guards the mount path (a top footer rendered pre-measure used to crash).
357
+ for (const paginationPosition of ['top', 'both', 'bottom'] as const) {
358
+ const g = await mountGrid({ showPagination: true, paginationPosition })
359
+ try {
360
+ await tick()
361
+ expect(g.api).toBeTruthy()
362
+ const bottoms = [...g.target.querySelectorAll('.sv-grid-pagination')].filter((el) => !el.classList.contains('sv-grid-pagination-top'))
363
+ expect(bottoms.length).toBe(paginationPosition === 'top' ? 0 : 1) // no bottom pager when position is 'top'
364
+ } finally {
365
+ g.destroy()
366
+ }
367
+ }
368
+ })
369
+
370
+ it('pageSizeOptions is accepted by the pager', async () => {
371
+ const g = await mountGrid({ showPagination: true, pageSizeOptions: [5, 15, 45] })
372
+ try {
373
+ await tick()
374
+ expect(g.target.querySelector('.sv-grid-pagination')).toBeTruthy()
375
+ } finally {
376
+ g.destroy()
377
+ }
378
+ })
379
+
380
+ it('editable={false} blocks inline editing entry points', async () => {
381
+ const { api, target, destroy } = await mountGrid({ editable: false })
382
+ try {
383
+ await tick()
384
+ // Double-clicking a body cell must not open an editor when editing
385
+ // is disabled via the shortcut.
386
+ const cell = target.querySelector<HTMLElement>('.sv-grid-cell')
387
+ cell?.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }))
388
+ await tick()
389
+ expect(target.querySelector('.sv-grid-cell-editor')).toBeNull()
390
+ expect(api.getData().length).toBe(people.length)
391
+ } finally {
392
+ destroy()
393
+ }
394
+ })
395
+ })
396
+
397
+ describe('SvGrid - cell selection', () => {
398
+ it('enableCellSelection mounts without error', async () => {
399
+ const { api, destroy } = await mountGrid({ enableCellSelection: true })
400
+ try {
401
+ await tick()
402
+ expect(api.getData().length).toBe(people.length)
403
+ } finally {
404
+ destroy()
405
+ }
406
+ })
407
+ })
408
+
409
+ describe('SvGrid - grouping + aggregation', () => {
410
+ it('setGroupBy mounts + the codepath runs without throwing', async () => {
411
+ const { api, target, destroy } = await mountGrid({
412
+ enableRowSummaries: true,
413
+ showGroupingControls: true,
414
+ })
415
+ try {
416
+ api.setGroupBy(['team'])
417
+ await tick()
418
+ await tick()
419
+ // Sanity: the grid is still mounted and the API responsive.
420
+ const data = api.getData()
421
+ expect(data.length).toBe(people.length)
422
+ // Group rendering depends on row model + container dimensions in jsdom;
423
+ // just verify the codepath does not throw.
424
+ expect(target).toBeTruthy()
425
+ } finally {
426
+ destroy()
427
+ }
428
+ })
429
+ })
430
+
431
+ describe('SvGrid - column add / remove / visibility', () => {
432
+ it('addColumn and removeColumn round-trip', async () => {
433
+ const { api, destroy } = await mountGrid()
434
+ try {
435
+ api.addColumn({ id: 'id-col', field: 'id', header: 'ID', width: 60 } as any, 'left')
436
+ await tick()
437
+ api.addColumn(
438
+ { id: 'extra-tag', field: 'team', header: 'Extra', width: 60 } as any,
439
+ 'right',
440
+ )
441
+ await tick()
442
+ api.addColumn(
443
+ { id: 'mid-col', field: 'name', header: 'Mid', width: 60 } as any,
444
+ 1,
445
+ )
446
+ await tick()
447
+ api.removeColumn('id-col')
448
+ await tick()
449
+ // No throw means the codepath was exercised.
450
+ expect(typeof api.getData).toBe('function')
451
+ } finally {
452
+ destroy()
453
+ }
454
+ })
455
+
456
+ it('setColumnVisible toggles visibility flag', async () => {
457
+ const { api, destroy } = await mountGrid()
458
+ try {
459
+ expect(api.isColumnVisible('name')).toBe(true)
460
+ api.setColumnVisible('name', false)
461
+ await tick()
462
+ expect(api.isColumnVisible('name')).toBe(false)
463
+ api.setColumnVisible('name', true)
464
+ await tick()
465
+ expect(api.isColumnVisible('name')).toBe(true)
466
+ } finally {
467
+ destroy()
468
+ }
469
+ })
470
+
471
+ it('columns marked `visible: false` start hidden but stay listed', async () => {
472
+ const columns: ColumnDef<typeof fullFeatures, Person>[] = personColumns.map(
473
+ (c) => (c.field === 'team' ? { ...c, visible: false } : c),
474
+ )
475
+ const { api, destroy } = await mountGrid({ columns })
476
+ try {
477
+ // Starts hidden...
478
+ expect(api.isColumnVisible('team')).toBe(false)
479
+ // ...but is still listed in getColumns() (so a Choose Columns UI
480
+ // can offer it), just with visible=false.
481
+ const team = api.getColumns().find((c) => c.id === 'team')
482
+ expect(team).toBeDefined()
483
+ expect(team?.visible).toBe(false)
484
+ // A later user toggle wins over the initial flag.
485
+ api.setColumnVisible('team', true)
486
+ await tick()
487
+ expect(api.isColumnVisible('team')).toBe(true)
488
+ } finally {
489
+ destroy()
490
+ }
491
+ })
492
+ })
493
+
494
+ describe('SvGrid - row add / remove', () => {
495
+ it('addRow at top / bottom / specific index', async () => {
496
+ const { api, destroy } = await mountGrid()
497
+ try {
498
+ const before = api.getData().length
499
+ api.addRow({ id: 99, name: 'Top', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 'top')
500
+ api.addRow({ id: 100, name: 'Bottom', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 'bottom')
501
+ api.addRow({ id: 101, name: 'Mid', team: 'X', age: 20, active: true, joined: '2025', salary: 1 }, 2)
502
+ await tick()
503
+ expect(api.getData().length).toBe(before + 3)
504
+ } finally {
505
+ destroy()
506
+ }
507
+ })
508
+
509
+ it('addRows / removeRow / removeRows', async () => {
510
+ const { api, destroy } = await mountGrid()
511
+ try {
512
+ const before = api.getData().length
513
+ api.addRows(
514
+ [
515
+ { id: 90, name: 'A', team: 'X', age: 1, active: true, joined: '2025', salary: 1 },
516
+ { id: 91, name: 'B', team: 'X', age: 1, active: true, joined: '2025', salary: 1 },
517
+ ],
518
+ 'bottom',
519
+ )
520
+ await tick()
521
+ api.removeRow(0)
522
+ await tick()
523
+ api.removeRows([0, 1])
524
+ await tick()
525
+ expect(api.getData().length).toBe(before + 2 - 3)
526
+ } finally {
527
+ destroy()
528
+ }
529
+ })
530
+ })
531
+
532
+ describe('SvGrid - getCellValue', () => {
533
+ it('returns the cell value for a known row+column', async () => {
534
+ const { api, destroy } = await mountGrid()
535
+ try {
536
+ const value = api.getCellValue(0, 'name')
537
+ expect(value).toBe(people[0]!.name)
538
+ } finally {
539
+ destroy()
540
+ }
541
+ })
542
+
543
+ it('returns undefined for unknown row or column', async () => {
544
+ const { api, destroy } = await mountGrid()
545
+ try {
546
+ expect(api.getCellValue(999, 'name')).toBeUndefined()
547
+ expect(api.getCellValue(0, 'no-such-col')).toBeUndefined()
548
+ } finally {
549
+ destroy()
550
+ }
551
+ })
552
+ })
553
+
554
+ describe('SvGrid - row number column', () => {
555
+ it('showRowNumbers renders the leading row-number column', async () => {
556
+ const { target, destroy } = await mountGrid({ showRowNumbers: true })
557
+ try {
558
+ await tick()
559
+ const rnCells = target.querySelectorAll('.sv-grid-row-number-cell')
560
+ expect(rnCells.length).toBeGreaterThan(0)
561
+ } finally {
562
+ destroy()
563
+ }
564
+ })
565
+ })
566
+
567
+ describe('SvGrid - external sort / filter', () => {
568
+ it('externalSort + onSortingChange fires without re-ordering rows', async () => {
569
+ let captured: Array<{ id: string; desc: boolean }> | null = null
570
+ const { api, destroy } = await mountGrid({
571
+ externalSort: true,
572
+ onSortingChange: (s: any) => (captured = s),
573
+ })
574
+ try {
575
+ api.setSort('age', 'desc')
576
+ await tick()
577
+ expect(captured).not.toBeNull()
578
+ } finally {
579
+ destroy()
580
+ }
581
+ })
582
+
583
+ it('externalFilter + onFiltersChange fires when a filter is set', async () => {
584
+ let calls = 0
585
+ const { api, destroy } = await mountGrid({
586
+ externalFilter: true,
587
+ onFiltersChange: () => {
588
+ calls += 1
589
+ },
590
+ })
591
+ try {
592
+ api.setFilter('team', { operator: 'contains', value: 'Research' })
593
+ await tick()
594
+ expect(calls).toBeGreaterThan(0)
595
+ } finally {
596
+ destroy()
597
+ }
598
+ })
599
+ })
600
+
601
+ describe('SvGrid - custom snippet cell', () => {
602
+ it('accepts a custom cell renderer without throwing', async () => {
603
+ // Build a snippet via raw object - the SvGrid component reads
604
+ // `column.columnDef.cell` and pipes it through FlexRender. Returning a
605
+ // plain string is the simplest renderer; tests only need to verify the
606
+ // render path doesn't crash.
607
+ const customCols: ColumnDef<typeof fullFeatures, Person>[] = personColumns.map((c) =>
608
+ c.field === 'name'
609
+ ? {
610
+ ...c,
611
+ cell: (ctx: any) => `★ ${(ctx.row.original as Person).name}`,
612
+ }
613
+ : c,
614
+ )
615
+ const { target, destroy } = await mountGrid({ columns: customCols })
616
+ try {
617
+ await tick()
618
+ expect(target.textContent).toContain('★')
619
+ } finally {
620
+ destroy()
621
+ }
622
+ })
623
+ })
624
+
625
+ describe('SvGrid - filterMode shortcuts', () => {
626
+ it('filterMode="row" + global filter input wiring', async () => {
627
+ const { destroy } = await mountGrid({ filterMode: 'row' })
628
+ try {
629
+ await tick()
630
+ // No assertion needed - exercising the codepath is enough.
631
+ expect(true).toBe(true)
632
+ } finally {
633
+ destroy()
634
+ }
635
+ })
636
+ it('filterMode="global"', async () => {
637
+ const { destroy } = await mountGrid({ filterMode: 'global' })
638
+ try {
639
+ await tick()
640
+ expect(true).toBe(true)
641
+ } finally {
642
+ destroy()
643
+ }
644
+ })
645
+ it('filterMode="none"', async () => {
646
+ const { destroy } = await mountGrid({ filterMode: 'none' })
647
+ try {
648
+ await tick()
649
+ expect(true).toBe(true)
650
+ } finally {
651
+ destroy()
652
+ }
653
+ })
654
+ })
655
+
656
+ describe('SvGrid - selectionMode shortcuts', () => {
657
+ it('selectionMode="row"', async () => {
658
+ const { destroy } = await mountGrid({ selectionMode: 'row' })
659
+ try {
660
+ await tick()
661
+ expect(true).toBe(true)
662
+ } finally {
663
+ destroy()
664
+ }
665
+ })
666
+ it('selectionMode="cell"', async () => {
667
+ const { destroy } = await mountGrid({ selectionMode: 'cell' })
668
+ try {
669
+ await tick()
670
+ expect(true).toBe(true)
671
+ } finally {
672
+ destroy()
673
+ }
674
+ })
675
+ it('selectionMode="both"', async () => {
676
+ const { destroy } = await mountGrid({ selectionMode: 'both' })
677
+ try {
678
+ await tick()
679
+ expect(true).toBe(true)
680
+ } finally {
681
+ destroy()
682
+ }
683
+ })
684
+ it('selectionMode="none"', async () => {
685
+ const { destroy } = await mountGrid({ selectionMode: 'none' })
686
+ try {
687
+ await tick()
688
+ expect(true).toBe(true)
689
+ } finally {
690
+ destroy()
691
+ }
692
+ })
693
+ })
694
+
695
+ describe('SvGrid - fitColumns', () => {
696
+ it('mounts with fitColumns=true without throwing', async () => {
697
+ const { destroy } = await mountGrid({ fitColumns: true })
698
+ try {
699
+ await tick()
700
+ expect(true).toBe(true)
701
+ } finally {
702
+ destroy()
703
+ }
704
+ })
705
+ })