@svgrid/grid 1.2.33 → 2.0.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 (490) hide show
  1. package/README.md +6 -5
  2. package/dist/FlexRender.svelte +96 -96
  3. package/dist/GridFooter.svelte +178 -178
  4. package/dist/SvAccordion.svelte +109 -0
  5. package/dist/SvAccordion.svelte.d.ts +28 -0
  6. package/dist/SvAlert.svelte +92 -0
  7. package/dist/SvAlert.svelte.d.ts +27 -0
  8. package/dist/SvAutoComplete.svelte +47 -18
  9. package/dist/SvAutoComplete.svelte.d.ts +2 -5
  10. package/dist/SvAvatar.svelte +75 -0
  11. package/dist/SvAvatar.svelte.d.ts +14 -0
  12. package/dist/SvAvatarGroup.svelte +48 -0
  13. package/dist/SvAvatarGroup.svelte.d.ts +16 -0
  14. package/dist/SvBadge.svelte +54 -0
  15. package/dist/SvBadge.svelte.d.ts +23 -0
  16. package/dist/SvBreadcrumb.svelte +88 -0
  17. package/dist/SvBreadcrumb.svelte.d.ts +23 -0
  18. package/dist/SvButtonGroup.svelte +121 -0
  19. package/dist/SvButtonGroup.svelte.d.ts +16 -0
  20. package/dist/SvCalendar.svelte +72 -9
  21. package/dist/SvCalendar.svelte.d.ts +34 -1
  22. package/dist/SvCard.svelte +71 -0
  23. package/dist/SvCard.svelte.d.ts +28 -0
  24. package/dist/SvCarousel.svelte +134 -0
  25. package/dist/SvCarousel.svelte.d.ts +28 -0
  26. package/dist/SvCheckBox.svelte +36 -21
  27. package/dist/SvCheckBox.svelte.d.ts +2 -5
  28. package/dist/SvChip.svelte +88 -0
  29. package/dist/SvChip.svelte.d.ts +31 -0
  30. package/dist/SvCircularProgress.svelte +109 -0
  31. package/dist/SvCircularProgress.svelte.d.ts +31 -0
  32. package/dist/SvColorInput.svelte +54 -27
  33. package/dist/SvColorInput.svelte.d.ts +10 -6
  34. package/dist/SvComboBox.svelte +119 -33
  35. package/dist/SvComboBox.svelte.d.ts +18 -6
  36. package/dist/SvCommand.svelte +197 -0
  37. package/dist/SvCommand.svelte.d.ts +26 -0
  38. package/dist/SvContextMenu.svelte +96 -0
  39. package/dist/SvContextMenu.svelte.d.ts +25 -0
  40. package/dist/SvCountryInput.svelte +56 -21
  41. package/dist/SvCountryInput.svelte.d.ts +9 -5
  42. package/dist/SvDateRangeInput.svelte +256 -0
  43. package/dist/SvDateRangeInput.svelte.d.ts +37 -0
  44. package/dist/SvDateTimePicker.svelte +57 -20
  45. package/dist/SvDateTimePicker.svelte.d.ts +12 -4
  46. package/dist/SvDivider.svelte +61 -0
  47. package/dist/SvDivider.svelte.d.ts +22 -0
  48. package/dist/SvDrawer.svelte +226 -0
  49. package/dist/SvDrawer.svelte.d.ts +43 -0
  50. package/dist/SvDropDownList.svelte +114 -35
  51. package/dist/SvDropDownList.svelte.d.ts +7 -6
  52. package/dist/SvDurationInput.svelte +108 -0
  53. package/dist/SvDurationInput.svelte.d.ts +15 -0
  54. package/dist/SvEmptyState.svelte +59 -0
  55. package/dist/SvEmptyState.svelte.d.ts +25 -0
  56. package/dist/SvField.svelte +85 -0
  57. package/dist/SvField.svelte.d.ts +30 -0
  58. package/dist/SvFileUpload.svelte +169 -0
  59. package/dist/SvFileUpload.svelte.d.ts +24 -0
  60. package/dist/SvForm.svelte +7 -1
  61. package/dist/SvForm.svelte.d.ts +3 -0
  62. package/dist/SvGauge.svelte +7 -1
  63. package/dist/SvGauge.svelte.d.ts +11 -0
  64. package/dist/SvGrid.controller.svelte.d.ts +6 -0
  65. package/dist/SvGrid.controller.svelte.js +64 -9
  66. package/dist/SvGrid.css +2376 -2343
  67. package/dist/SvGrid.svelte +2764 -2651
  68. package/dist/SvGrid.types.d.ts +366 -0
  69. package/dist/SvGridBoard.svelte +2281 -0
  70. package/dist/SvGridBoard.svelte.d.ts +31 -0
  71. package/dist/SvGridDropdown.svelte +666 -665
  72. package/dist/SvGridSelect.svelte +255 -0
  73. package/dist/SvGridSelect.svelte.d.ts +32 -0
  74. package/dist/SvGroupCell.svelte +109 -0
  75. package/dist/SvGroupCell.svelte.d.ts +41 -0
  76. package/dist/SvListBox.svelte +123 -36
  77. package/dist/SvListBox.svelte.d.ts +12 -8
  78. package/dist/SvMaskedInput.svelte +53 -13
  79. package/dist/SvMaskedInput.svelte.d.ts +16 -6
  80. package/dist/SvMenu.svelte +101 -0
  81. package/dist/SvMenu.svelte.d.ts +26 -0
  82. package/dist/SvMenuList.svelte +143 -0
  83. package/dist/SvMenuList.svelte.d.ts +24 -0
  84. package/dist/SvModal.svelte +220 -0
  85. package/dist/SvModal.svelte.d.ts +31 -0
  86. package/dist/SvMultiSelect.svelte +277 -0
  87. package/dist/SvMultiSelect.svelte.d.ts +31 -0
  88. package/dist/SvNavPane.svelte +314 -0
  89. package/dist/SvNavPane.svelte.d.ts +59 -0
  90. package/dist/SvNumberInput.svelte +23 -9
  91. package/dist/SvNumberInput.svelte.d.ts +2 -0
  92. package/dist/SvOtpInput.svelte +157 -0
  93. package/dist/SvOtpInput.svelte.d.ts +16 -0
  94. package/dist/SvPagination.svelte +100 -0
  95. package/dist/SvPagination.svelte.d.ts +16 -0
  96. package/dist/SvPasswordInput.svelte +42 -12
  97. package/dist/SvPasswordInput.svelte.d.ts +13 -6
  98. package/dist/SvPhoneInput.svelte +43 -11
  99. package/dist/SvPhoneInput.svelte.d.ts +10 -11
  100. package/dist/SvPopover.svelte +127 -0
  101. package/dist/SvPopover.svelte.d.ts +35 -0
  102. package/dist/SvProgress.svelte +116 -0
  103. package/dist/SvProgress.svelte.d.ts +32 -0
  104. package/dist/SvRadioGroup.svelte +40 -22
  105. package/dist/SvRadioGroup.svelte.d.ts +2 -10
  106. package/dist/SvRating.svelte +51 -30
  107. package/dist/SvRating.svelte.d.ts +10 -7
  108. package/dist/SvRichText.svelte +192 -0
  109. package/dist/SvRichText.svelte.d.ts +16 -0
  110. package/dist/SvRowGroupPanel.svelte +147 -0
  111. package/dist/SvRowGroupPanel.svelte.d.ts +17 -0
  112. package/dist/SvScrollArea.svelte +50 -0
  113. package/dist/SvScrollArea.svelte.d.ts +22 -0
  114. package/dist/SvSkeleton.svelte +76 -0
  115. package/dist/SvSkeleton.svelte.d.ts +25 -0
  116. package/dist/SvSlider.svelte +41 -9
  117. package/dist/SvSlider.svelte.d.ts +4 -4
  118. package/dist/SvSparkline.svelte +77 -0
  119. package/dist/SvSparkline.svelte.d.ts +28 -0
  120. package/dist/SvSplitter.svelte +138 -0
  121. package/dist/SvSplitter.svelte.d.ts +32 -0
  122. package/dist/SvStat.svelte +86 -0
  123. package/dist/SvStat.svelte.d.ts +30 -0
  124. package/dist/SvStepper.svelte +91 -0
  125. package/dist/SvStepper.svelte.d.ts +24 -0
  126. package/dist/SvSwitchButton.svelte +39 -24
  127. package/dist/SvSwitchButton.svelte.d.ts +2 -5
  128. package/dist/SvTabs.svelte +147 -28
  129. package/dist/SvTabs.svelte.d.ts +16 -4
  130. package/dist/SvTagsInput.svelte +59 -22
  131. package/dist/SvTagsInput.svelte.d.ts +9 -4
  132. package/dist/SvTextArea.svelte +113 -0
  133. package/dist/SvTextArea.svelte.d.ts +18 -0
  134. package/dist/SvTextInput.svelte +115 -0
  135. package/dist/SvTextInput.svelte.d.ts +20 -0
  136. package/dist/SvTimePicker.svelte +19 -5
  137. package/dist/SvTimePicker.svelte.d.ts +12 -0
  138. package/dist/SvTimeline.svelte +75 -0
  139. package/dist/SvTimeline.svelte.d.ts +24 -0
  140. package/dist/SvToaster.svelte +124 -0
  141. package/dist/SvToaster.svelte.d.ts +10 -0
  142. package/dist/SvToggleButton.svelte +37 -12
  143. package/dist/SvToggleButton.svelte.d.ts +2 -4
  144. package/dist/SvTooltip.svelte +113 -0
  145. package/dist/SvTooltip.svelte.d.ts +22 -0
  146. package/dist/SvTour.svelte +151 -0
  147. package/dist/SvTour.svelte.d.ts +25 -0
  148. package/dist/SvTree.svelte +286 -44
  149. package/dist/SvTree.svelte.d.ts +26 -9
  150. package/dist/SvTreeSelect.svelte +222 -0
  151. package/dist/SvTreeSelect.svelte.d.ts +24 -0
  152. package/dist/a11y/dismissable.d.ts +32 -0
  153. package/dist/a11y/dismissable.js +54 -0
  154. package/dist/a11y/focus-trap.d.ts +39 -0
  155. package/dist/a11y/focus-trap.js +142 -0
  156. package/dist/a11y/live-region.d.ts +8 -0
  157. package/dist/a11y/live-region.js +60 -0
  158. package/dist/a11y/scroll-lock.d.ts +4 -0
  159. package/dist/a11y/scroll-lock.js +41 -0
  160. package/dist/a11y.d.ts +3 -1
  161. package/dist/a11y.js +1 -1
  162. package/dist/avatar.d.ts +10 -0
  163. package/dist/avatar.js +22 -0
  164. package/dist/builtin-editors.d.ts +5 -0
  165. package/dist/builtin-editors.js +55 -0
  166. package/dist/cdn/svgrid.js +16022 -8235
  167. package/dist/cdn/svgrid.svelte-external.js +14543 -6765
  168. package/dist/columns.js +3 -2
  169. package/dist/core.d.ts +7 -1
  170. package/dist/countries.d.ts +12 -0
  171. package/dist/countries.js +24 -0
  172. package/dist/createAccordion.svelte.d.ts +71 -0
  173. package/dist/createAccordion.svelte.js +99 -0
  174. package/dist/createAutocomplete.svelte.d.ts +13 -4
  175. package/dist/createAutocomplete.svelte.js +11 -1
  176. package/dist/createButtonGroup.svelte.d.ts +62 -0
  177. package/dist/createButtonGroup.svelte.js +154 -0
  178. package/dist/createCalendar.svelte.d.ts +5 -0
  179. package/dist/createCalendar.svelte.js +2 -0
  180. package/dist/createCheckbox.svelte.d.ts +9 -17
  181. package/dist/createCheckbox.svelte.js +28 -1
  182. package/dist/createColorInput.svelte.d.ts +12 -22
  183. package/dist/createColorInput.svelte.js +13 -0
  184. package/dist/createCombobox.svelte.d.ts +16 -5
  185. package/dist/createCombobox.svelte.js +13 -2
  186. package/dist/createCountryInput.svelte.d.ts +14 -3
  187. package/dist/createCountryInput.svelte.js +12 -2
  188. package/dist/createDateTimePicker.svelte.d.ts +17 -2
  189. package/dist/createDateTimePicker.svelte.js +12 -2
  190. package/dist/createDropdownList.svelte.d.ts +14 -5
  191. package/dist/createDropdownList.svelte.js +50 -1
  192. package/dist/createFileUpload.svelte.d.ts +68 -0
  193. package/dist/createFileUpload.svelte.js +122 -0
  194. package/dist/createListbox.svelte.d.ts +10 -1
  195. package/dist/createListbox.svelte.js +48 -1
  196. package/dist/createMaskedInput.svelte.d.ts +11 -2
  197. package/dist/createMaskedInput.svelte.js +11 -1
  198. package/dist/createNumberInput.svelte.d.ts +1 -0
  199. package/dist/createNumberInput.svelte.js +1 -0
  200. package/dist/createPasswordInput.svelte.d.ts +19 -21
  201. package/dist/createPasswordInput.svelte.js +16 -4
  202. package/dist/createPhoneInput.svelte.d.ts +26 -7
  203. package/dist/createPhoneInput.svelte.js +24 -3
  204. package/dist/createPopoverSelect.svelte.d.ts +86 -0
  205. package/dist/createPopoverSelect.svelte.js +196 -0
  206. package/dist/createRadioGroup.svelte.d.ts +9 -0
  207. package/dist/createRadioGroup.svelte.js +11 -1
  208. package/dist/createRating.svelte.d.ts +11 -0
  209. package/dist/createRating.svelte.js +12 -1
  210. package/dist/createSlider.svelte.d.ts +2 -0
  211. package/dist/createSlider.svelte.js +16 -5
  212. package/dist/createSplitter.svelte.d.ts +67 -0
  213. package/dist/createSplitter.svelte.js +99 -0
  214. package/dist/createSwitch.svelte.d.ts +9 -16
  215. package/dist/createSwitch.svelte.js +28 -1
  216. package/dist/createTabs.svelte.d.ts +7 -0
  217. package/dist/createTabs.svelte.js +17 -2
  218. package/dist/createTagsInput.svelte.d.ts +13 -1
  219. package/dist/createTagsInput.svelte.js +12 -3
  220. package/dist/createToggle.svelte.d.ts +9 -0
  221. package/dist/createToggle.svelte.js +12 -1
  222. package/dist/createTree.svelte.d.ts +19 -0
  223. package/dist/createTree.svelte.js +108 -15
  224. package/dist/debounce.d.ts +11 -0
  225. package/dist/debounce.js +30 -0
  226. package/dist/duration.d.ts +15 -0
  227. package/dist/duration.js +51 -0
  228. package/dist/editor-contract.d.ts +62 -7
  229. package/dist/editor-contract.js +45 -5
  230. package/dist/editor-registry.d.ts +67 -0
  231. package/dist/editor-registry.js +38 -0
  232. package/dist/editors/cell-editors.d.ts +1 -1
  233. package/dist/editors/cell-editors.js +5 -0
  234. package/dist/fuzzy.d.ts +3 -0
  235. package/dist/fuzzy.js +41 -0
  236. package/dist/grid-select.d.ts +9 -0
  237. package/dist/grid-select.js +8 -0
  238. package/dist/index.d.ts +79 -6
  239. package/dist/index.js +78 -4
  240. package/dist/keyboard-handlers.js +19 -0
  241. package/dist/list-option.d.ts +36 -0
  242. package/dist/list-option.js +68 -0
  243. package/dist/otp.d.ts +16 -0
  244. package/dist/otp.js +26 -0
  245. package/dist/paginate.d.ts +20 -0
  246. package/dist/paginate.js +40 -0
  247. package/dist/popover.d.ts +15 -1
  248. package/dist/popover.js +29 -3
  249. package/dist/recurrence.d.ts +36 -0
  250. package/dist/recurrence.js +90 -0
  251. package/dist/server-data-source.d.ts +89 -0
  252. package/dist/server-data-source.js +4 -0
  253. package/dist/server-group-model.d.ts +98 -0
  254. package/dist/server-group-model.js +263 -0
  255. package/dist/toast-store.svelte.d.ts +41 -0
  256. package/dist/toast-store.svelte.js +113 -0
  257. package/dist/tree-select.d.ts +19 -0
  258. package/dist/tree-select.js +40 -0
  259. package/dist/ui-app.types.d.ts +80 -0
  260. package/dist/ui-app.types.js +7 -0
  261. package/dist/validators.d.ts +43 -0
  262. package/dist/validators.js +53 -0
  263. package/dist/virtual.d.ts +35 -0
  264. package/dist/virtual.js +34 -0
  265. package/package.json +85 -85
  266. package/src/FlexRender.svelte +96 -96
  267. package/src/GridFooter.svelte +178 -178
  268. package/src/SvAccordion.svelte +109 -0
  269. package/src/SvAccordion.test.ts +66 -0
  270. package/src/SvAlert.svelte +92 -0
  271. package/src/SvAutoComplete.svelte +47 -18
  272. package/src/SvAvatar.svelte +75 -0
  273. package/src/SvAvatarGroup.svelte +48 -0
  274. package/src/SvBadge.svelte +54 -0
  275. package/src/SvBreadcrumb.svelte +88 -0
  276. package/src/SvButtonGroup.svelte +121 -0
  277. package/src/SvButtonGroup.test.ts +72 -0
  278. package/src/SvCalendar.svelte +72 -9
  279. package/src/SvCard.svelte +71 -0
  280. package/src/SvCarousel.svelte +134 -0
  281. package/src/SvCheckBox.svelte +36 -21
  282. package/src/SvChip.svelte +88 -0
  283. package/src/SvCircularProgress.svelte +109 -0
  284. package/src/SvColorInput.svelte +54 -27
  285. package/src/SvComboBox.svelte +119 -33
  286. package/src/SvCommand.svelte +197 -0
  287. package/src/SvContextMenu.svelte +96 -0
  288. package/src/SvCountryInput.svelte +56 -21
  289. package/src/SvDateRangeInput.svelte +256 -0
  290. package/src/SvDateRangeInput.test.ts +80 -0
  291. package/src/SvDateTimePicker.svelte +57 -20
  292. package/src/SvDivider.svelte +61 -0
  293. package/src/SvDrawer.svelte +226 -0
  294. package/src/SvDrawer.test.ts +125 -0
  295. package/src/SvDropDownList.svelte +114 -35
  296. package/src/SvDurationInput.svelte +108 -0
  297. package/src/SvEmptyState.svelte +59 -0
  298. package/src/SvField.svelte +85 -0
  299. package/src/SvFileUpload.svelte +169 -0
  300. package/src/SvFileUpload.test.ts +59 -0
  301. package/src/SvForm.svelte +7 -1
  302. package/src/SvGauge.svelte +7 -1
  303. package/src/SvGrid.controller.svelte.ts +2553 -2494
  304. package/src/SvGrid.css +2376 -2343
  305. package/src/SvGrid.svelte +2764 -2651
  306. package/src/SvGrid.types.ts +944 -570
  307. package/src/SvGridBoard.svelte +2281 -0
  308. package/src/SvGridDropdown.svelte +666 -665
  309. package/src/SvGridSelect.svelte +255 -0
  310. package/src/SvGridSelect.test.ts +100 -0
  311. package/src/SvGroupCell.svelte +109 -0
  312. package/src/SvListBox.svelte +123 -36
  313. package/src/SvMaskedInput.svelte +53 -13
  314. package/src/SvMenu.svelte +101 -0
  315. package/src/SvMenu.test.ts +73 -0
  316. package/src/SvMenuList.svelte +143 -0
  317. package/src/SvModal.svelte +220 -0
  318. package/src/SvMultiSelect.svelte +277 -0
  319. package/src/SvMultiSelect.test.ts +167 -0
  320. package/src/SvNavPane.svelte +314 -0
  321. package/src/SvNavPane.test.ts +70 -0
  322. package/src/SvNumberInput.svelte +23 -9
  323. package/src/SvOtpInput.svelte +157 -0
  324. package/src/SvPagination.svelte +100 -0
  325. package/src/SvPasswordInput.svelte +42 -12
  326. package/src/SvPhoneInput.svelte +43 -11
  327. package/src/SvPopover.svelte +127 -0
  328. package/src/SvProgress.svelte +116 -0
  329. package/src/SvRadioGroup.svelte +40 -22
  330. package/src/SvRating.svelte +51 -30
  331. package/src/SvRichText.svelte +192 -0
  332. package/src/SvRowGroupPanel.svelte +147 -0
  333. package/src/SvScrollArea.svelte +50 -0
  334. package/src/SvSkeleton.svelte +76 -0
  335. package/src/SvSlider.svelte +41 -9
  336. package/src/SvSparkline.svelte +77 -0
  337. package/src/SvSplitter.svelte +138 -0
  338. package/src/SvSplitter.test.ts +55 -0
  339. package/src/SvStat.svelte +86 -0
  340. package/src/SvStepper.svelte +91 -0
  341. package/src/SvSwitchButton.svelte +39 -24
  342. package/src/SvTabs.svelte +147 -28
  343. package/src/SvTagsInput.svelte +59 -22
  344. package/src/SvTextArea.svelte +113 -0
  345. package/src/SvTextInput.svelte +115 -0
  346. package/src/SvTimePicker.svelte +19 -5
  347. package/src/SvTimeline.svelte +75 -0
  348. package/src/SvToaster.svelte +124 -0
  349. package/src/SvToaster.test.ts +63 -0
  350. package/src/SvToggleButton.svelte +37 -12
  351. package/src/SvTooltip.svelte +113 -0
  352. package/src/SvTour.svelte +151 -0
  353. package/src/SvTree.svelte +286 -44
  354. package/src/SvTreeSelect.svelte +222 -0
  355. package/src/SvTreeSelect.test.ts +87 -0
  356. package/src/a11y/dismissable.test.ts +95 -0
  357. package/src/a11y/dismissable.ts +94 -0
  358. package/src/a11y/focus-trap.test.ts +110 -0
  359. package/src/a11y/focus-trap.ts +134 -0
  360. package/src/a11y/live-region.test.ts +40 -0
  361. package/src/a11y/live-region.ts +65 -0
  362. package/src/a11y/scroll-lock.test.ts +38 -0
  363. package/src/a11y/scroll-lock.ts +41 -0
  364. package/src/a11y.contract.test.ts +49 -49
  365. package/src/a11y.test.ts +59 -59
  366. package/src/a11y.ts +61 -59
  367. package/src/avatar.test.ts +32 -0
  368. package/src/avatar.ts +21 -0
  369. package/src/board.test.ts +927 -0
  370. package/src/build-api.ts +798 -798
  371. package/src/builtin-editors.grid.test.ts +85 -0
  372. package/src/builtin-editors.test.ts +58 -0
  373. package/src/builtin-editors.ts +56 -0
  374. package/src/cell-formatting.ts +169 -169
  375. package/src/cell-render.ts +469 -469
  376. package/src/collaboration.test.ts +104 -104
  377. package/src/collaboration.ts +167 -167
  378. package/src/columns.ts +3 -2
  379. package/src/core.performance.test.ts +30 -30
  380. package/src/core.ts +1111 -1101
  381. package/src/countries.ts +25 -0
  382. package/src/createAccordion.svelte.ts +126 -0
  383. package/src/createAutocomplete.svelte.ts +18 -1
  384. package/src/createButtonGroup.svelte.ts +166 -0
  385. package/src/createCalendar.svelte.ts +6 -0
  386. package/src/createCheckbox.svelte.ts +23 -1
  387. package/src/createColorInput.svelte.ts +20 -0
  388. package/src/createCombobox.svelte.ts +22 -2
  389. package/src/createCountryInput.svelte.ts +21 -2
  390. package/src/createDateTimePicker.svelte.ts +23 -2
  391. package/src/createDropdownList.svelte.ts +31 -2
  392. package/src/createFileUpload.svelte.ts +144 -0
  393. package/src/createGrid.svelte.ts +42 -42
  394. package/src/createGrid.test.ts +10 -10
  395. package/src/createGridState.svelte.ts +17 -17
  396. package/src/createListbox.svelte.ts +35 -3
  397. package/src/createMaskedInput.svelte.ts +18 -1
  398. package/src/createNumberInput.svelte.ts +2 -0
  399. package/src/createPasswordInput.svelte.ts +31 -5
  400. package/src/createPhoneInput.svelte.ts +38 -4
  401. package/src/createPopoverSelect.svelte.ts +208 -0
  402. package/src/createRadioGroup.svelte.ts +23 -1
  403. package/src/createRating.svelte.ts +26 -1
  404. package/src/createSlider.svelte.ts +14 -3
  405. package/src/createSplitter.svelte.ts +119 -0
  406. package/src/createSwitch.svelte.ts +26 -3
  407. package/src/createTabs.svelte.ts +20 -3
  408. package/src/createTagsInput.svelte.ts +24 -3
  409. package/src/createToggle.svelte.ts +25 -2
  410. package/src/createTree.svelte.ts +104 -14
  411. package/src/debounce.test.ts +50 -0
  412. package/src/debounce.ts +41 -0
  413. package/src/duration.test.ts +41 -0
  414. package/src/duration.ts +51 -0
  415. package/src/editing.test.ts +859 -859
  416. package/src/editing.ts +675 -675
  417. package/src/editor-contract.ts +87 -8
  418. package/src/editor-registry.grid.test.ts +98 -0
  419. package/src/editor-registry.test.ts +86 -0
  420. package/src/editor-registry.ts +106 -0
  421. package/src/editors/cell-editors.ts +10 -1
  422. package/src/export-data-api.test.ts +126 -126
  423. package/src/export-format.test.ts +107 -107
  424. package/src/export-format.ts +598 -598
  425. package/src/flex-render.ts +3 -3
  426. package/src/fuzzy.test.ts +40 -0
  427. package/src/fuzzy.ts +39 -0
  428. package/src/grid-select.test.ts +28 -0
  429. package/src/grid-select.ts +20 -0
  430. package/src/index.ts +463 -318
  431. package/src/keyboard-handlers.ts +20 -0
  432. package/src/keyboard.test.ts +59 -59
  433. package/src/keyboard.ts +97 -97
  434. package/src/list-option.ts +74 -0
  435. package/src/list-power.test.ts +71 -0
  436. package/src/menus.ts +582 -582
  437. package/src/merge-objects.ts +48 -48
  438. package/src/otp.test.ts +28 -0
  439. package/src/otp.ts +28 -0
  440. package/src/overlays.test.ts +85 -0
  441. package/src/paginate.test.ts +41 -0
  442. package/src/paginate.ts +61 -0
  443. package/src/phone-valid.test.ts +26 -0
  444. package/src/popover.ts +31 -3
  445. package/src/progress.test.ts +55 -0
  446. package/src/recurrence.test.ts +91 -0
  447. package/src/recurrence.ts +111 -0
  448. package/src/render-component.ts +28 -28
  449. package/src/selection.test.ts +754 -754
  450. package/src/selection.ts +600 -600
  451. package/src/server-data-source.test.ts +289 -289
  452. package/src/server-data-source.ts +413 -311
  453. package/src/server-group-model.test.ts +294 -0
  454. package/src/server-group-model.ts +370 -0
  455. package/src/sparkline.test.ts +68 -68
  456. package/src/sparkline.ts +169 -169
  457. package/src/spreadsheet.test.ts +489 -489
  458. package/src/spreadsheet.ts +304 -304
  459. package/src/static-functions.ts +11 -11
  460. package/src/subscribe.ts +38 -38
  461. package/src/svgrid-wrapper.types.ts +439 -439
  462. package/src/svgrid.behavior.test.ts +706 -706
  463. package/src/svgrid.features.test.ts +157 -157
  464. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  465. package/src/svgrid.responsive.test.ts +72 -0
  466. package/src/svgrid.wrapper.test.ts +40 -40
  467. package/src/toast-store.svelte.ts +148 -0
  468. package/src/toast-store.test.ts +86 -0
  469. package/src/tree-edit.test.ts +49 -0
  470. package/src/tree-filter.test.ts +56 -0
  471. package/src/tree-select.test.ts +48 -0
  472. package/src/tree-select.ts +62 -0
  473. package/src/ui-app.test.ts +130 -0
  474. package/src/ui-app.types.ts +88 -0
  475. package/src/ui-display.test.ts +79 -0
  476. package/src/ui-inputs.test.ts +1 -1
  477. package/src/ui-status.test.ts +141 -0
  478. package/src/ui-tier1.test.ts +142 -0
  479. package/src/ui-tier2.test.ts +124 -0
  480. package/src/ui-tier3.test.ts +139 -0
  481. package/src/validators.test.ts +58 -0
  482. package/src/validators.ts +105 -0
  483. package/src/virtual.test.ts +72 -0
  484. package/src/virtual.ts +67 -0
  485. package/src/virtualization/column-virtualizer.test.ts +27 -27
  486. package/src/virtualization/column-virtualizer.ts +30 -30
  487. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  488. package/src/virtualization/types.ts +30 -30
  489. package/src/virtualization/virtualizer.test.ts +47 -47
  490. package/src/virtualization/virtualizer.ts +296 -296
package/src/menus.ts CHANGED
@@ -1,582 +1,582 @@
1
- // menus handlers extracted from the controller. Imperative event handlers
2
- // reading/writing controller state via the `ctx` handle; the reactive core
3
- // ($state/$derived/$effect) stays in the controller.
4
- import {
5
- applyExcelFilter,
6
- normalizeForFilter,
7
- createColumnVirtualizer,
8
- createCoreRowModel,
9
- createExpandedRowModel,
10
- createFilteredRowModel,
11
- createGroupedRowModel,
12
- createPaginatedRowModel,
13
- createSvelteVirtualizer,
14
- createSortedRowModel,
15
- createSvGrid,
16
- filterFns,
17
- getGridCellA11yProps,
18
- getGridCellDomId,
19
- getGridHeaderA11yProps,
20
- getGridRootA11yProps,
21
- getGridRowA11yProps,
22
- parseEditorValue,
23
- normalizeEditorOptions,
24
- sortFns,
25
- tableFeatures,
26
- rowSortingFeature,
27
- columnFilteringFeature,
28
- columnGroupingFeature,
29
- type CellContext,
30
- type EditorContext,
31
- type CellEditorOption,
32
- type CellEditorType,
33
- type CellFormatter,
34
- type CellFormatConfig,
35
- type Column,
36
- type ColumnDef,
37
- type Row,
38
- type RowData,
39
- type SvGridApi,
40
- type TableFeatures,
41
- } from "./index";
42
- import "./sv-grid-scrollbar";
43
- import type { Snippet } from "svelte";
44
- import { getKeyboardIntent, getNextActiveCell } from "./keyboard";
45
- import {
46
- formatNumericWithConfig,
47
- getDateFormatter,
48
- resolveDatePattern,
49
- } from "./cell-formatting";
50
- import {
51
- RenderSnippetConfig,
52
- RenderComponentConfig,
53
- } from "./render-component";
54
- import { buildFillPattern } from "./fill-patterns";
55
- import { buildSparkline, toSparklineValues } from "./sparkline";
56
- import {
57
- resolveCellFormat,
58
- computeColumnStat,
59
- formatsNeedingStats,
60
- type ColumnStat,
61
- type ResolvedCellFormat,
62
- } from "./conditional-formatting";
63
- import SvGridDropdown from "./SvGridDropdown.svelte";
64
- import type {
65
- Props,
66
- SelectionPoint,
67
- SelectionRange,
68
- CellEditState,
69
- FilterOperator,
70
- FilterOption,
71
- MenuPosition,
72
- } from "./SvGrid.types";
73
- import {
74
- cfTextStyle,
75
- fmtStat,
76
- getCellKey,
77
- resolveClassList,
78
- toDateInputValue,
79
- toDateTimeLocalInputValue,
80
- getEditableInputValue,
81
- getEditorInputType,
82
- toValueArray,
83
- getOptionLabel,
84
- getOptionColor,
85
- colorfulChipStyle,
86
- getEditorClass,
87
- asDate,
88
- clampMenuX,
89
- cssEscape,
90
- rawToNumber,
91
- formatFacetNumber,
92
- formatFacetDate,
93
- } from "./SvGrid.helpers";
94
- import { createCellRender } from "./cell-render";
95
- import { createEditing } from "./editing";
96
- import { createSelection } from "./selection";
97
- import { createColumns } from "./columns";
98
- import { createGridApi } from "./build-api";
99
- import { createClipboard } from "./clipboard";
100
- import {
101
- filterOperatorOptions,
102
- fallbackOperatorOption,
103
- TEXT_OPERATORS,
104
- NUMBER_OPERATORS,
105
- DATE_OPERATORS,
106
- CHECKBOX_OPERATORS,
107
- operatorOption,
108
- operatorsForColumn,
109
- defaultOperatorFor,
110
- operatorLabelFor,
111
- } from "./filter-operators";
112
- import {
113
- type FacetBucket,
114
- isBucketableColumn,
115
- buildBuckets,
116
- isInBucket,
117
- } from "./facet-buckets";
118
- import {
119
- getColumnBaseValue,
120
- isGroupRow,
121
- toolPanelHeaderLabel,
122
- formatSummaryNumeric,
123
- getColumnAlign,
124
- getPinnedCellValue,
125
- getColumnAccessorValue,
126
- columnDefMatchesId,
127
- } from "./cell-values";
128
-
129
- export function createMenus<
130
- TFeatures extends TableFeatures = TableFeatures,
131
- TData extends RowData = RowData,
132
- >(ctx: any) {
133
- function updateFilterRow(columnId: string, value: string) {
134
- ctx.filterRowValues = { ...ctx.filterRowValues, [columnId]: value };
135
- const current = ctx.filterMenuValues[columnId] ?? {
136
- operator: "contains" as const,
137
- value: "",
138
- };
139
- ctx.filterMenuValues = {
140
- ...ctx.filterMenuValues,
141
- [columnId]: { ...current, value },
142
- };
143
- }
144
-
145
- function updateFilterOperator(columnId: string, operator: FilterOperator) {
146
- const current = ctx.filterMenuValues[columnId] ?? {
147
- operator: "contains" as const,
148
- value: "",
149
- };
150
- ctx.filterMenuValues = {
151
- ...ctx.filterMenuValues,
152
- [columnId]: { ...current, operator },
153
- };
154
- }
155
-
156
- function updateFilterMenuValue(columnId: string, value: string) {
157
- const current = ctx.filterMenuValues[columnId] ?? {
158
- operator: "contains" as const,
159
- value: "",
160
- };
161
- ctx.filterMenuValues = {
162
- ...ctx.filterMenuValues,
163
- [columnId]: { ...current, value },
164
- };
165
- ctx.filterRowValues = { ...ctx.filterRowValues, [columnId]: value };
166
- }
167
-
168
- /** Upper-bound input for the `between` operator. Only relevant when
169
- * the column's current operator is `between`; harmless to call
170
- * otherwise. */
171
- function updateFilterMenuValueTo(columnId: string, valueTo: string) {
172
- const current = ctx.filterMenuValues[columnId] ?? {
173
- operator: "between" as const,
174
- value: "",
175
- };
176
- ctx.filterMenuValues = {
177
- ...ctx.filterMenuValues,
178
- [columnId]: { ...current, valueTo },
179
- };
180
- }
181
-
182
- function toggleCheckboxWithKeyboard(
183
- event: KeyboardEvent,
184
- toggle: () => void,
185
- ) {
186
- if (event.key !== "Enter" && event.key !== " ") return;
187
- event.preventDefault();
188
- toggle();
189
- }
190
-
191
- function isColumnFiltered(columnId: string) {
192
- if (ctx.valueFilters[columnId]) return true;
193
- const menuFilter = ctx.filterMenuValues[columnId];
194
- return Boolean(
195
- menuFilter &&
196
- (menuFilter.operator === "isBlank" || menuFilter.value.trim()),
197
- );
198
- }
199
-
200
- function closeMenus() {
201
- ctx.columnMenuFor = null;
202
- ctx.filterMenuFor = null;
203
- ctx.operatorMenuFor = null;
204
- ctx.chooseColumnsPos = null;
205
- }
206
-
207
- function openChooseColumns(event: MouseEvent) {
208
- event.stopPropagation();
209
- // Submenu behavior: keep the parent operations menu open and float the
210
- // Choose Columns panel out to the right of it (AG-Grid style). Falls
211
- // back to below the item if the popover would clip the viewport.
212
- const trigger = event.currentTarget as HTMLElement;
213
- const menuEl = trigger.closest(".sv-grid-menu") as HTMLElement | null;
214
- const anchor = (menuEl ?? trigger).getBoundingClientRect();
215
- const panelWidth = 240;
216
- const wantRight = anchor.right + 4;
217
- const x =
218
- wantRight + panelWidth + 8 > window.innerWidth
219
- ? clampMenuX(anchor.left - panelWidth - 4, panelWidth)
220
- : clampMenuX(wantRight, panelWidth);
221
- ctx.chooseColumnsPos = { x, y: anchor.top };
222
- }
223
-
224
- function openColumnMenu(event: MouseEvent, columnId: string) {
225
- event.stopPropagation();
226
- const wasOpen = ctx.columnMenuFor === columnId;
227
- closeMenus();
228
- if (wasOpen) return;
229
- const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
230
- ctx.columnMenuPos = {
231
- x: clampMenuX(rect.right - 240, 240),
232
- y: rect.bottom + 4,
233
- };
234
- ctx.columnMenuTab = "general";
235
- ctx.columnMenuFor = columnId;
236
- }
237
-
238
- function openFilterMenu(event: MouseEvent, columnId: string) {
239
- event.stopPropagation();
240
- const wasOpen = ctx.filterMenuFor === columnId;
241
- closeMenus();
242
- if (wasOpen) return;
243
-
244
- // If the consumer is running in row-mode (or any mode where the
245
- // funnel popover wouldn't render), redirect the click to the
246
- // inline filter input for this column. Without this the funnel
247
- // would be a dead button - it visibly clicks but nothing happens
248
- // because the menu is gated behind `showColumnFiltersEffective`.
249
- if (!ctx.showColumnFiltersEffective && ctx.showFilterRowEffective) {
250
- // Find the row-mode filter input and focus it. The input is
251
- // tagged with `data-svgrid-filter-col` so we can target by id
252
- // without depending on column position.
253
- const input = (ctx.scrollContainer as HTMLElement | null)?.querySelector<HTMLInputElement>(
254
- `[data-svgrid-filter-col="${cssEscape(columnId)}"]`,
255
- );
256
- if (input) {
257
- input.focus();
258
- input.select();
259
- // Brief pulse so the user sees where focus landed.
260
- input.classList.add("sv-grid-filter-value-pulse");
261
- setTimeout(() => input.classList.remove("sv-grid-filter-value-pulse"), 700);
262
- }
263
- return;
264
- }
265
-
266
- const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
267
- ctx.filterMenuPos = {
268
- x: clampMenuX(rect.right - 260, 260),
269
- y: rect.bottom + 4,
270
- };
271
- ctx.columnMenuSearch = "";
272
- ctx.filterMenuFor = columnId;
273
- }
274
-
275
- function openOperatorMenu(event: MouseEvent, columnId: string) {
276
- event.stopPropagation();
277
- const wasOpen = ctx.operatorMenuFor === columnId;
278
- closeMenus();
279
- if (wasOpen) return;
280
- const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
281
- ctx.operatorMenuPos = { x: clampMenuX(rect.left, 184), y: rect.bottom + 4 };
282
- ctx.operatorMenuFor = columnId;
283
- }
284
-
285
- function sortColumnFromMenu(columnId: string, desc: boolean) {
286
- ctx.grid.store.setState((prev: any) => ({
287
- ...prev,
288
- sorting: [{ id: columnId, desc }],
289
- }));
290
- closeMenus();
291
- }
292
-
293
- function clearColumnSort(columnId: string) {
294
- ctx.grid.store.setState((prev: any) => ({
295
- ...prev,
296
- sorting: (prev.sorting ?? []).filter(
297
- (entry: { id: string }) => entry.id !== columnId,
298
- ),
299
- }));
300
- closeMenus();
301
- }
302
-
303
- function groupByColumnFromMenu(columnId: string) {
304
- const current = ctx.grid.getState().grouping ?? [];
305
- if (current.includes(columnId)) {
306
- closeMenus();
307
- return;
308
- }
309
- ctx.grid.setGrouping([...current, columnId]);
310
- closeMenus();
311
- }
312
-
313
- function clearGroupingFromMenu(columnId: string) {
314
- const current = ctx.grid.getState().grouping ?? [];
315
- ctx.grid.setGrouping(current.filter((id: string) => id !== columnId));
316
- closeMenus();
317
- }
318
-
319
- function isFacetChecked(columnId: string, value: string) {
320
- const selected = ctx.valueFilters[columnId];
321
- return selected ? selected.has(value) : true;
322
- }
323
-
324
- function toggleFacetValue(columnId: string, value: string) {
325
- const allValues = ctx.columnMenuFacetValues;
326
- const next = new Set(ctx.valueFilters[columnId] ?? allValues);
327
- if (next.has(value)) next.delete(value);
328
- else next.add(value);
329
- if (next.size === allValues.length) {
330
- const copy = { ...ctx.valueFilters };
331
- delete copy[columnId];
332
- ctx.valueFilters = copy;
333
- } else {
334
- ctx.valueFilters = { ...ctx.valueFilters, [columnId]: next };
335
- }
336
- }
337
-
338
- function isAllFacetsChecked(columnId: string) {
339
- const selected = ctx.valueFilters[columnId];
340
- return !selected || selected.size >= ctx.columnMenuFacetValues.length;
341
- }
342
-
343
- function toggleAllFacets(columnId: string) {
344
- if (isAllFacetsChecked(columnId)) {
345
- ctx.valueFilters = { ...ctx.valueFilters, [columnId]: new Set<string>() };
346
- } else {
347
- const copy = { ...ctx.valueFilters };
348
- delete copy[columnId];
349
- ctx.valueFilters = copy;
350
- }
351
- }
352
-
353
- function clearColumnFilter(columnId: string) {
354
- if (ctx.valueFilters[columnId]) {
355
- const next = { ...ctx.valueFilters };
356
- delete next[columnId];
357
- ctx.valueFilters = next;
358
- }
359
- if (ctx.filterMenuValues[columnId]) {
360
- const next = { ...ctx.filterMenuValues };
361
- delete next[columnId];
362
- ctx.filterMenuValues = next;
363
- }
364
- if (ctx.filterRowValues[columnId]) {
365
- const next = { ...ctx.filterRowValues };
366
- delete next[columnId];
367
- ctx.filterRowValues = next;
368
- }
369
- }
370
-
371
- // External pagination is controlled: emit the requested page/size and let
372
- // the consumer fetch + update props. Never mutate local pagination state.
373
- function emitExternalPagination(pageIndex: number, pageSize: number): boolean {
374
- if (ctx.props.externalPagination !== true) return false;
375
- ctx.props.onPaginationChange?.({ pageIndex: Math.max(0, pageIndex), pageSize });
376
- ctx.scrollContainer?.scrollTo?.({ top: 0 });
377
- return true;
378
- }
379
-
380
- function changePage(delta: number) {
381
- if (
382
- emitExternalPagination(
383
- (ctx.props.pageIndex ?? 0) + delta,
384
- ctx.props.pageSize ?? 10,
385
- )
386
- )
387
- return;
388
- ctx.grid.setPagination((prev: any) => ({
389
- ...prev,
390
- pageIndex: Math.max((prev?.pageIndex ?? 0) + delta, 0),
391
- }));
392
- ctx.scrollContainer?.scrollTo?.({ top: 0 });
393
- }
394
-
395
- function goToPage(pageIndex: number) {
396
- if (emitExternalPagination(pageIndex, ctx.props.pageSize ?? 10)) return;
397
- ctx.grid.setPagination((prev: any) => ({
398
- ...prev,
399
- pageIndex: Math.max(0, pageIndex),
400
- }));
401
- ctx.scrollContainer?.scrollTo?.({ top: 0 });
402
- }
403
-
404
- function setPageSize(pageSize: number) {
405
- // External mode: changing page size resets to the first page.
406
- if (emitExternalPagination(0, pageSize)) return;
407
- ctx.grid.setPagination((prev: any) => {
408
- const oldSize = prev?.pageSize ?? 10;
409
- const oldIndex = prev?.pageIndex ?? 0;
410
- // Keep the first visible row in view when the page size changes.
411
- const firstVisibleRow = oldIndex * oldSize;
412
- return {
413
- ...prev,
414
- pageSize,
415
- pageIndex: Math.max(0, Math.floor(firstVisibleRow / pageSize)),
416
- };
417
- });
418
- }
419
-
420
- // ---- Right-click context menu --------------------------------------
421
- type CtxTarget = { rowIndex: number; colIndex: number; columnId: string; rowId: string; row: TData | null };
422
- type ResolvedItem = { key: string; label: string; separator?: boolean; disabled?: boolean; run?: () => void };
423
-
424
- function insertRowAt(t: CtxTarget, offset: number) {
425
- const data = ctx.internalData.slice() as TData[];
426
- const idx = t.row ? data.indexOf(t.row) : -1;
427
- const at = idx < 0 ? data.length : idx + offset;
428
- data.splice(at, 0, {} as TData);
429
- ctx.internalData = data;
430
- }
431
- function removeRowAt(t: CtxTarget) {
432
- if (!t.row) return;
433
- ctx.internalData = (ctx.internalData as TData[]).filter((r) => r !== t.row);
434
- }
435
- function removeColAt(t: CtxTarget) {
436
- ctx.internalColumns = ctx.internalColumns.filter(
437
- (d: any) => (d.id ?? d.field) !== t.columnId,
438
- );
439
- }
440
-
441
- // Built-in items, keyed. `run` reads the live target passed at click time.
442
- const builtins: Record<string, { label: string; run: (t: CtxTarget) => void }> = {
443
- copy: { label: "Copy", run: () => ctx.copySelectionToClipboard() },
444
- cut: { label: "Cut", run: () => ctx.cutSelectionToClipboard() },
445
- paste: { label: "Paste", run: () => void ctx.pasteFromClipboard() },
446
- clear: { label: "Clear", run: () => ctx.clearSelectedCells() },
447
- row_above: { label: "Insert row above", run: (t) => insertRowAt(t, 0) },
448
- row_below: { label: "Insert row below", run: (t) => insertRowAt(t, 1) },
449
- remove_row: { label: "Remove row", run: removeRowAt },
450
- remove_col: { label: "Remove column", run: removeColAt },
451
- comment: { label: "Edit comment", run: (t) => openCommentEditor(t) },
452
- };
453
- const DEFAULT_ITEMS = [
454
- "copy", "cut", "paste", "clear", "separator",
455
- "row_above", "row_below", "remove_row", "separator", "remove_col",
456
- ];
457
-
458
- function openContextMenu(
459
- event: MouseEvent,
460
- rowIndex: number,
461
- colIndex: number,
462
- columnId: string,
463
- ) {
464
- if (!ctx.props.contextMenu) return;
465
- event.preventDefault();
466
- closeMenus();
467
- ctx.contextMenuFor = null;
468
- const rowModel = ctx.allRows[rowIndex];
469
- const row = rowModel?.original ?? null;
470
- const rowId = rowModel?.id ?? String(rowIndex);
471
- // Reserve ~280px for the menu body. If the click is in the bottom third,
472
- // flip the menu above the cursor so it stays fully in the viewport.
473
- const menuHeight = 280;
474
- const y = event.clientY + menuHeight > window.innerHeight
475
- ? Math.max(8, event.clientY - menuHeight)
476
- : event.clientY;
477
- ctx.contextMenuPos = {
478
- x: clampMenuX(event.clientX, 220),
479
- y,
480
- };
481
- ctx.contextMenuFor = { rowIndex, colIndex, columnId, rowId, row };
482
- }
483
-
484
- function closeContextMenu() {
485
- ctx.contextMenuFor = null;
486
- }
487
-
488
- // ---- Editable comments ---------------------------------------------
489
- function openCommentEditor(t: CtxTarget) {
490
- const cur =
491
- ctx.noteOverrides?.[t.rowId]?.[t.columnId] ??
492
- ctx.props.notes?.[t.rowId]?.[t.columnId] ??
493
- "";
494
- ctx.commentDraft = cur;
495
- ctx.commentEditFor = { rowId: t.rowId, columnId: t.columnId, x: ctx.contextMenuPos.x, y: ctx.contextMenuPos.y };
496
- ctx.contextMenuFor = null;
497
- }
498
- function writeNote(rowId: string, columnId: string, note: string) {
499
- const next = { ...ctx.noteOverrides };
500
- next[rowId] = { ...(next[rowId] ?? {}), [columnId]: note };
501
- ctx.noteOverrides = next;
502
- ctx.props.onNoteChange?.({ rowId, columnId, note });
503
- }
504
- function saveComment() {
505
- const e = ctx.commentEditFor;
506
- if (!e) return;
507
- writeNote(e.rowId, e.columnId, ctx.commentDraft);
508
- ctx.commentEditFor = null;
509
- }
510
- function removeComment() {
511
- const e = ctx.commentEditFor;
512
- if (!e) return;
513
- writeNote(e.rowId, e.columnId, "");
514
- ctx.commentEditFor = null;
515
- }
516
- function closeCommentEditor() {
517
- ctx.commentEditFor = null;
518
- }
519
-
520
- /** Resolve the configured items against the current target for rendering. */
521
- function contextMenuItems(): ResolvedItem[] {
522
- const target = ctx.contextMenuFor as CtxTarget | null;
523
- if (!target) return [];
524
- const cfg = ctx.props.contextMenu;
525
- const entries: any[] = Array.isArray(cfg)
526
- ? cfg
527
- : [...DEFAULT_ITEMS, ...(ctx.props.editableComments ? ["separator", "comment"] : [])];
528
- const out: ResolvedItem[] = [];
529
- for (const entry of entries) {
530
- if (entry === "separator") { out.push({ key: "sep" + out.length, label: "", separator: true }); continue; }
531
- if (typeof entry === "string") {
532
- const b = builtins[entry];
533
- if (!b) continue;
534
- out.push({ key: entry, label: b.label, run: () => b.run(target) });
535
- continue;
536
- }
537
- if (entry.hidden?.(target)) continue;
538
- out.push({
539
- key: entry.key,
540
- label: entry.label,
541
- disabled: entry.disabled?.(target) ?? false,
542
- run: () => entry.action(target),
543
- });
544
- }
545
- // Drop leading/trailing/double separators.
546
- return out.filter((it, i, a) =>
547
- !it.separator || (i > 0 && i < a.length - 1 && !a[i - 1]?.separator),
548
- );
549
- }
550
-
551
- return {
552
- updateFilterRow,
553
- updateFilterOperator,
554
- updateFilterMenuValue,
555
- updateFilterMenuValueTo,
556
- toggleCheckboxWithKeyboard,
557
- isColumnFiltered,
558
- closeMenus,
559
- openChooseColumns,
560
- openColumnMenu,
561
- openFilterMenu,
562
- openOperatorMenu,
563
- sortColumnFromMenu,
564
- clearColumnSort,
565
- groupByColumnFromMenu,
566
- clearGroupingFromMenu,
567
- isFacetChecked,
568
- toggleFacetValue,
569
- isAllFacetsChecked,
570
- toggleAllFacets,
571
- clearColumnFilter,
572
- changePage,
573
- goToPage,
574
- setPageSize,
575
- openContextMenu,
576
- closeContextMenu,
577
- contextMenuItems,
578
- saveComment,
579
- removeComment,
580
- closeCommentEditor,
581
- };
582
- }
1
+ // menus handlers extracted from the controller. Imperative event handlers
2
+ // reading/writing controller state via the `ctx` handle; the reactive core
3
+ // ($state/$derived/$effect) stays in the controller.
4
+ import {
5
+ applyExcelFilter,
6
+ normalizeForFilter,
7
+ createColumnVirtualizer,
8
+ createCoreRowModel,
9
+ createExpandedRowModel,
10
+ createFilteredRowModel,
11
+ createGroupedRowModel,
12
+ createPaginatedRowModel,
13
+ createSvelteVirtualizer,
14
+ createSortedRowModel,
15
+ createSvGrid,
16
+ filterFns,
17
+ getGridCellA11yProps,
18
+ getGridCellDomId,
19
+ getGridHeaderA11yProps,
20
+ getGridRootA11yProps,
21
+ getGridRowA11yProps,
22
+ parseEditorValue,
23
+ normalizeEditorOptions,
24
+ sortFns,
25
+ tableFeatures,
26
+ rowSortingFeature,
27
+ columnFilteringFeature,
28
+ columnGroupingFeature,
29
+ type CellContext,
30
+ type EditorContext,
31
+ type CellEditorOption,
32
+ type CellEditorType,
33
+ type CellFormatter,
34
+ type CellFormatConfig,
35
+ type Column,
36
+ type ColumnDef,
37
+ type Row,
38
+ type RowData,
39
+ type SvGridApi,
40
+ type TableFeatures,
41
+ } from "./index";
42
+ import "./sv-grid-scrollbar";
43
+ import type { Snippet } from "svelte";
44
+ import { getKeyboardIntent, getNextActiveCell } from "./keyboard";
45
+ import {
46
+ formatNumericWithConfig,
47
+ getDateFormatter,
48
+ resolveDatePattern,
49
+ } from "./cell-formatting";
50
+ import {
51
+ RenderSnippetConfig,
52
+ RenderComponentConfig,
53
+ } from "./render-component";
54
+ import { buildFillPattern } from "./fill-patterns";
55
+ import { buildSparkline, toSparklineValues } from "./sparkline";
56
+ import {
57
+ resolveCellFormat,
58
+ computeColumnStat,
59
+ formatsNeedingStats,
60
+ type ColumnStat,
61
+ type ResolvedCellFormat,
62
+ } from "./conditional-formatting";
63
+ import SvGridDropdown from "./SvGridDropdown.svelte";
64
+ import type {
65
+ Props,
66
+ SelectionPoint,
67
+ SelectionRange,
68
+ CellEditState,
69
+ FilterOperator,
70
+ FilterOption,
71
+ MenuPosition,
72
+ } from "./SvGrid.types";
73
+ import {
74
+ cfTextStyle,
75
+ fmtStat,
76
+ getCellKey,
77
+ resolveClassList,
78
+ toDateInputValue,
79
+ toDateTimeLocalInputValue,
80
+ getEditableInputValue,
81
+ getEditorInputType,
82
+ toValueArray,
83
+ getOptionLabel,
84
+ getOptionColor,
85
+ colorfulChipStyle,
86
+ getEditorClass,
87
+ asDate,
88
+ clampMenuX,
89
+ cssEscape,
90
+ rawToNumber,
91
+ formatFacetNumber,
92
+ formatFacetDate,
93
+ } from "./SvGrid.helpers";
94
+ import { createCellRender } from "./cell-render";
95
+ import { createEditing } from "./editing";
96
+ import { createSelection } from "./selection";
97
+ import { createColumns } from "./columns";
98
+ import { createGridApi } from "./build-api";
99
+ import { createClipboard } from "./clipboard";
100
+ import {
101
+ filterOperatorOptions,
102
+ fallbackOperatorOption,
103
+ TEXT_OPERATORS,
104
+ NUMBER_OPERATORS,
105
+ DATE_OPERATORS,
106
+ CHECKBOX_OPERATORS,
107
+ operatorOption,
108
+ operatorsForColumn,
109
+ defaultOperatorFor,
110
+ operatorLabelFor,
111
+ } from "./filter-operators";
112
+ import {
113
+ type FacetBucket,
114
+ isBucketableColumn,
115
+ buildBuckets,
116
+ isInBucket,
117
+ } from "./facet-buckets";
118
+ import {
119
+ getColumnBaseValue,
120
+ isGroupRow,
121
+ toolPanelHeaderLabel,
122
+ formatSummaryNumeric,
123
+ getColumnAlign,
124
+ getPinnedCellValue,
125
+ getColumnAccessorValue,
126
+ columnDefMatchesId,
127
+ } from "./cell-values";
128
+
129
+ export function createMenus<
130
+ TFeatures extends TableFeatures = TableFeatures,
131
+ TData extends RowData = RowData,
132
+ >(ctx: any) {
133
+ function updateFilterRow(columnId: string, value: string) {
134
+ ctx.filterRowValues = { ...ctx.filterRowValues, [columnId]: value };
135
+ const current = ctx.filterMenuValues[columnId] ?? {
136
+ operator: "contains" as const,
137
+ value: "",
138
+ };
139
+ ctx.filterMenuValues = {
140
+ ...ctx.filterMenuValues,
141
+ [columnId]: { ...current, value },
142
+ };
143
+ }
144
+
145
+ function updateFilterOperator(columnId: string, operator: FilterOperator) {
146
+ const current = ctx.filterMenuValues[columnId] ?? {
147
+ operator: "contains" as const,
148
+ value: "",
149
+ };
150
+ ctx.filterMenuValues = {
151
+ ...ctx.filterMenuValues,
152
+ [columnId]: { ...current, operator },
153
+ };
154
+ }
155
+
156
+ function updateFilterMenuValue(columnId: string, value: string) {
157
+ const current = ctx.filterMenuValues[columnId] ?? {
158
+ operator: "contains" as const,
159
+ value: "",
160
+ };
161
+ ctx.filterMenuValues = {
162
+ ...ctx.filterMenuValues,
163
+ [columnId]: { ...current, value },
164
+ };
165
+ ctx.filterRowValues = { ...ctx.filterRowValues, [columnId]: value };
166
+ }
167
+
168
+ /** Upper-bound input for the `between` operator. Only relevant when
169
+ * the column's current operator is `between`; harmless to call
170
+ * otherwise. */
171
+ function updateFilterMenuValueTo(columnId: string, valueTo: string) {
172
+ const current = ctx.filterMenuValues[columnId] ?? {
173
+ operator: "between" as const,
174
+ value: "",
175
+ };
176
+ ctx.filterMenuValues = {
177
+ ...ctx.filterMenuValues,
178
+ [columnId]: { ...current, valueTo },
179
+ };
180
+ }
181
+
182
+ function toggleCheckboxWithKeyboard(
183
+ event: KeyboardEvent,
184
+ toggle: () => void,
185
+ ) {
186
+ if (event.key !== "Enter" && event.key !== " ") return;
187
+ event.preventDefault();
188
+ toggle();
189
+ }
190
+
191
+ function isColumnFiltered(columnId: string) {
192
+ if (ctx.valueFilters[columnId]) return true;
193
+ const menuFilter = ctx.filterMenuValues[columnId];
194
+ return Boolean(
195
+ menuFilter &&
196
+ (menuFilter.operator === "isBlank" || menuFilter.value.trim()),
197
+ );
198
+ }
199
+
200
+ function closeMenus() {
201
+ ctx.columnMenuFor = null;
202
+ ctx.filterMenuFor = null;
203
+ ctx.operatorMenuFor = null;
204
+ ctx.chooseColumnsPos = null;
205
+ }
206
+
207
+ function openChooseColumns(event: MouseEvent) {
208
+ event.stopPropagation();
209
+ // Submenu behavior: keep the parent operations menu open and float the
210
+ // Choose Columns panel out to the right of it (AG-Grid style). Falls
211
+ // back to below the item if the popover would clip the viewport.
212
+ const trigger = event.currentTarget as HTMLElement;
213
+ const menuEl = trigger.closest(".sv-grid-menu") as HTMLElement | null;
214
+ const anchor = (menuEl ?? trigger).getBoundingClientRect();
215
+ const panelWidth = 240;
216
+ const wantRight = anchor.right + 4;
217
+ const x =
218
+ wantRight + panelWidth + 8 > window.innerWidth
219
+ ? clampMenuX(anchor.left - panelWidth - 4, panelWidth)
220
+ : clampMenuX(wantRight, panelWidth);
221
+ ctx.chooseColumnsPos = { x, y: anchor.top };
222
+ }
223
+
224
+ function openColumnMenu(event: MouseEvent, columnId: string) {
225
+ event.stopPropagation();
226
+ const wasOpen = ctx.columnMenuFor === columnId;
227
+ closeMenus();
228
+ if (wasOpen) return;
229
+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
230
+ ctx.columnMenuPos = {
231
+ x: clampMenuX(rect.right - 240, 240),
232
+ y: rect.bottom + 4,
233
+ };
234
+ ctx.columnMenuTab = "general";
235
+ ctx.columnMenuFor = columnId;
236
+ }
237
+
238
+ function openFilterMenu(event: MouseEvent, columnId: string) {
239
+ event.stopPropagation();
240
+ const wasOpen = ctx.filterMenuFor === columnId;
241
+ closeMenus();
242
+ if (wasOpen) return;
243
+
244
+ // If the consumer is running in row-mode (or any mode where the
245
+ // funnel popover wouldn't render), redirect the click to the
246
+ // inline filter input for this column. Without this the funnel
247
+ // would be a dead button - it visibly clicks but nothing happens
248
+ // because the menu is gated behind `showColumnFiltersEffective`.
249
+ if (!ctx.showColumnFiltersEffective && ctx.showFilterRowEffective) {
250
+ // Find the row-mode filter input and focus it. The input is
251
+ // tagged with `data-svgrid-filter-col` so we can target by id
252
+ // without depending on column position.
253
+ const input = (ctx.scrollContainer as HTMLElement | null)?.querySelector<HTMLInputElement>(
254
+ `[data-svgrid-filter-col="${cssEscape(columnId)}"]`,
255
+ );
256
+ if (input) {
257
+ input.focus();
258
+ input.select();
259
+ // Brief pulse so the user sees where focus landed.
260
+ input.classList.add("sv-grid-filter-value-pulse");
261
+ setTimeout(() => input.classList.remove("sv-grid-filter-value-pulse"), 700);
262
+ }
263
+ return;
264
+ }
265
+
266
+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
267
+ ctx.filterMenuPos = {
268
+ x: clampMenuX(rect.right - 260, 260),
269
+ y: rect.bottom + 4,
270
+ };
271
+ ctx.columnMenuSearch = "";
272
+ ctx.filterMenuFor = columnId;
273
+ }
274
+
275
+ function openOperatorMenu(event: MouseEvent, columnId: string) {
276
+ event.stopPropagation();
277
+ const wasOpen = ctx.operatorMenuFor === columnId;
278
+ closeMenus();
279
+ if (wasOpen) return;
280
+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
281
+ ctx.operatorMenuPos = { x: clampMenuX(rect.left, 184), y: rect.bottom + 4 };
282
+ ctx.operatorMenuFor = columnId;
283
+ }
284
+
285
+ function sortColumnFromMenu(columnId: string, desc: boolean) {
286
+ ctx.grid.store.setState((prev: any) => ({
287
+ ...prev,
288
+ sorting: [{ id: columnId, desc }],
289
+ }));
290
+ closeMenus();
291
+ }
292
+
293
+ function clearColumnSort(columnId: string) {
294
+ ctx.grid.store.setState((prev: any) => ({
295
+ ...prev,
296
+ sorting: (prev.sorting ?? []).filter(
297
+ (entry: { id: string }) => entry.id !== columnId,
298
+ ),
299
+ }));
300
+ closeMenus();
301
+ }
302
+
303
+ function groupByColumnFromMenu(columnId: string) {
304
+ const current = ctx.grid.getState().grouping ?? [];
305
+ if (current.includes(columnId)) {
306
+ closeMenus();
307
+ return;
308
+ }
309
+ ctx.grid.setGrouping([...current, columnId]);
310
+ closeMenus();
311
+ }
312
+
313
+ function clearGroupingFromMenu(columnId: string) {
314
+ const current = ctx.grid.getState().grouping ?? [];
315
+ ctx.grid.setGrouping(current.filter((id: string) => id !== columnId));
316
+ closeMenus();
317
+ }
318
+
319
+ function isFacetChecked(columnId: string, value: string) {
320
+ const selected = ctx.valueFilters[columnId];
321
+ return selected ? selected.has(value) : true;
322
+ }
323
+
324
+ function toggleFacetValue(columnId: string, value: string) {
325
+ const allValues = ctx.columnMenuFacetValues;
326
+ const next = new Set(ctx.valueFilters[columnId] ?? allValues);
327
+ if (next.has(value)) next.delete(value);
328
+ else next.add(value);
329
+ if (next.size === allValues.length) {
330
+ const copy = { ...ctx.valueFilters };
331
+ delete copy[columnId];
332
+ ctx.valueFilters = copy;
333
+ } else {
334
+ ctx.valueFilters = { ...ctx.valueFilters, [columnId]: next };
335
+ }
336
+ }
337
+
338
+ function isAllFacetsChecked(columnId: string) {
339
+ const selected = ctx.valueFilters[columnId];
340
+ return !selected || selected.size >= ctx.columnMenuFacetValues.length;
341
+ }
342
+
343
+ function toggleAllFacets(columnId: string) {
344
+ if (isAllFacetsChecked(columnId)) {
345
+ ctx.valueFilters = { ...ctx.valueFilters, [columnId]: new Set<string>() };
346
+ } else {
347
+ const copy = { ...ctx.valueFilters };
348
+ delete copy[columnId];
349
+ ctx.valueFilters = copy;
350
+ }
351
+ }
352
+
353
+ function clearColumnFilter(columnId: string) {
354
+ if (ctx.valueFilters[columnId]) {
355
+ const next = { ...ctx.valueFilters };
356
+ delete next[columnId];
357
+ ctx.valueFilters = next;
358
+ }
359
+ if (ctx.filterMenuValues[columnId]) {
360
+ const next = { ...ctx.filterMenuValues };
361
+ delete next[columnId];
362
+ ctx.filterMenuValues = next;
363
+ }
364
+ if (ctx.filterRowValues[columnId]) {
365
+ const next = { ...ctx.filterRowValues };
366
+ delete next[columnId];
367
+ ctx.filterRowValues = next;
368
+ }
369
+ }
370
+
371
+ // External pagination is controlled: emit the requested page/size and let
372
+ // the consumer fetch + update props. Never mutate local pagination state.
373
+ function emitExternalPagination(pageIndex: number, pageSize: number): boolean {
374
+ if (ctx.props.externalPagination !== true) return false;
375
+ ctx.props.onPaginationChange?.({ pageIndex: Math.max(0, pageIndex), pageSize });
376
+ ctx.scrollContainer?.scrollTo?.({ top: 0 });
377
+ return true;
378
+ }
379
+
380
+ function changePage(delta: number) {
381
+ if (
382
+ emitExternalPagination(
383
+ (ctx.props.pageIndex ?? 0) + delta,
384
+ ctx.props.pageSize ?? 10,
385
+ )
386
+ )
387
+ return;
388
+ ctx.grid.setPagination((prev: any) => ({
389
+ ...prev,
390
+ pageIndex: Math.max((prev?.pageIndex ?? 0) + delta, 0),
391
+ }));
392
+ ctx.scrollContainer?.scrollTo?.({ top: 0 });
393
+ }
394
+
395
+ function goToPage(pageIndex: number) {
396
+ if (emitExternalPagination(pageIndex, ctx.props.pageSize ?? 10)) return;
397
+ ctx.grid.setPagination((prev: any) => ({
398
+ ...prev,
399
+ pageIndex: Math.max(0, pageIndex),
400
+ }));
401
+ ctx.scrollContainer?.scrollTo?.({ top: 0 });
402
+ }
403
+
404
+ function setPageSize(pageSize: number) {
405
+ // External mode: changing page size resets to the first page.
406
+ if (emitExternalPagination(0, pageSize)) return;
407
+ ctx.grid.setPagination((prev: any) => {
408
+ const oldSize = prev?.pageSize ?? 10;
409
+ const oldIndex = prev?.pageIndex ?? 0;
410
+ // Keep the first visible row in view when the page size changes.
411
+ const firstVisibleRow = oldIndex * oldSize;
412
+ return {
413
+ ...prev,
414
+ pageSize,
415
+ pageIndex: Math.max(0, Math.floor(firstVisibleRow / pageSize)),
416
+ };
417
+ });
418
+ }
419
+
420
+ // ---- Right-click context menu --------------------------------------
421
+ type CtxTarget = { rowIndex: number; colIndex: number; columnId: string; rowId: string; row: TData | null };
422
+ type ResolvedItem = { key: string; label: string; separator?: boolean; disabled?: boolean; run?: () => void };
423
+
424
+ function insertRowAt(t: CtxTarget, offset: number) {
425
+ const data = ctx.internalData.slice() as TData[];
426
+ const idx = t.row ? data.indexOf(t.row) : -1;
427
+ const at = idx < 0 ? data.length : idx + offset;
428
+ data.splice(at, 0, {} as TData);
429
+ ctx.internalData = data;
430
+ }
431
+ function removeRowAt(t: CtxTarget) {
432
+ if (!t.row) return;
433
+ ctx.internalData = (ctx.internalData as TData[]).filter((r) => r !== t.row);
434
+ }
435
+ function removeColAt(t: CtxTarget) {
436
+ ctx.internalColumns = ctx.internalColumns.filter(
437
+ (d: any) => (d.id ?? d.field) !== t.columnId,
438
+ );
439
+ }
440
+
441
+ // Built-in items, keyed. `run` reads the live target passed at click time.
442
+ const builtins: Record<string, { label: string; run: (t: CtxTarget) => void }> = {
443
+ copy: { label: "Copy", run: () => ctx.copySelectionToClipboard() },
444
+ cut: { label: "Cut", run: () => ctx.cutSelectionToClipboard() },
445
+ paste: { label: "Paste", run: () => void ctx.pasteFromClipboard() },
446
+ clear: { label: "Clear", run: () => ctx.clearSelectedCells() },
447
+ row_above: { label: "Insert row above", run: (t) => insertRowAt(t, 0) },
448
+ row_below: { label: "Insert row below", run: (t) => insertRowAt(t, 1) },
449
+ remove_row: { label: "Remove row", run: removeRowAt },
450
+ remove_col: { label: "Remove column", run: removeColAt },
451
+ comment: { label: "Edit comment", run: (t) => openCommentEditor(t) },
452
+ };
453
+ const DEFAULT_ITEMS = [
454
+ "copy", "cut", "paste", "clear", "separator",
455
+ "row_above", "row_below", "remove_row", "separator", "remove_col",
456
+ ];
457
+
458
+ function openContextMenu(
459
+ event: MouseEvent,
460
+ rowIndex: number,
461
+ colIndex: number,
462
+ columnId: string,
463
+ ) {
464
+ if (!ctx.props.contextMenu) return;
465
+ event.preventDefault();
466
+ closeMenus();
467
+ ctx.contextMenuFor = null;
468
+ const rowModel = ctx.allRows[rowIndex];
469
+ const row = rowModel?.original ?? null;
470
+ const rowId = rowModel?.id ?? String(rowIndex);
471
+ // Reserve ~280px for the menu body. If the click is in the bottom third,
472
+ // flip the menu above the cursor so it stays fully in the viewport.
473
+ const menuHeight = 280;
474
+ const y = event.clientY + menuHeight > window.innerHeight
475
+ ? Math.max(8, event.clientY - menuHeight)
476
+ : event.clientY;
477
+ ctx.contextMenuPos = {
478
+ x: clampMenuX(event.clientX, 220),
479
+ y,
480
+ };
481
+ ctx.contextMenuFor = { rowIndex, colIndex, columnId, rowId, row };
482
+ }
483
+
484
+ function closeContextMenu() {
485
+ ctx.contextMenuFor = null;
486
+ }
487
+
488
+ // ---- Editable comments ---------------------------------------------
489
+ function openCommentEditor(t: CtxTarget) {
490
+ const cur =
491
+ ctx.noteOverrides?.[t.rowId]?.[t.columnId] ??
492
+ ctx.props.notes?.[t.rowId]?.[t.columnId] ??
493
+ "";
494
+ ctx.commentDraft = cur;
495
+ ctx.commentEditFor = { rowId: t.rowId, columnId: t.columnId, x: ctx.contextMenuPos.x, y: ctx.contextMenuPos.y };
496
+ ctx.contextMenuFor = null;
497
+ }
498
+ function writeNote(rowId: string, columnId: string, note: string) {
499
+ const next = { ...ctx.noteOverrides };
500
+ next[rowId] = { ...(next[rowId] ?? {}), [columnId]: note };
501
+ ctx.noteOverrides = next;
502
+ ctx.props.onNoteChange?.({ rowId, columnId, note });
503
+ }
504
+ function saveComment() {
505
+ const e = ctx.commentEditFor;
506
+ if (!e) return;
507
+ writeNote(e.rowId, e.columnId, ctx.commentDraft);
508
+ ctx.commentEditFor = null;
509
+ }
510
+ function removeComment() {
511
+ const e = ctx.commentEditFor;
512
+ if (!e) return;
513
+ writeNote(e.rowId, e.columnId, "");
514
+ ctx.commentEditFor = null;
515
+ }
516
+ function closeCommentEditor() {
517
+ ctx.commentEditFor = null;
518
+ }
519
+
520
+ /** Resolve the configured items against the current target for rendering. */
521
+ function contextMenuItems(): ResolvedItem[] {
522
+ const target = ctx.contextMenuFor as CtxTarget | null;
523
+ if (!target) return [];
524
+ const cfg = ctx.props.contextMenu;
525
+ const entries: any[] = Array.isArray(cfg)
526
+ ? cfg
527
+ : [...DEFAULT_ITEMS, ...(ctx.props.editableComments ? ["separator", "comment"] : [])];
528
+ const out: ResolvedItem[] = [];
529
+ for (const entry of entries) {
530
+ if (entry === "separator") { out.push({ key: "sep" + out.length, label: "", separator: true }); continue; }
531
+ if (typeof entry === "string") {
532
+ const b = builtins[entry];
533
+ if (!b) continue;
534
+ out.push({ key: entry, label: b.label, run: () => b.run(target) });
535
+ continue;
536
+ }
537
+ if (entry.hidden?.(target)) continue;
538
+ out.push({
539
+ key: entry.key,
540
+ label: entry.label,
541
+ disabled: entry.disabled?.(target) ?? false,
542
+ run: () => entry.action(target),
543
+ });
544
+ }
545
+ // Drop leading/trailing/double separators.
546
+ return out.filter((it, i, a) =>
547
+ !it.separator || (i > 0 && i < a.length - 1 && !a[i - 1]?.separator),
548
+ );
549
+ }
550
+
551
+ return {
552
+ updateFilterRow,
553
+ updateFilterOperator,
554
+ updateFilterMenuValue,
555
+ updateFilterMenuValueTo,
556
+ toggleCheckboxWithKeyboard,
557
+ isColumnFiltered,
558
+ closeMenus,
559
+ openChooseColumns,
560
+ openColumnMenu,
561
+ openFilterMenu,
562
+ openOperatorMenu,
563
+ sortColumnFromMenu,
564
+ clearColumnSort,
565
+ groupByColumnFromMenu,
566
+ clearGroupingFromMenu,
567
+ isFacetChecked,
568
+ toggleFacetValue,
569
+ isAllFacetsChecked,
570
+ toggleAllFacets,
571
+ clearColumnFilter,
572
+ changePage,
573
+ goToPage,
574
+ setPageSize,
575
+ openContextMenu,
576
+ closeContextMenu,
577
+ contextMenuItems,
578
+ saveComment,
579
+ removeComment,
580
+ closeCommentEditor,
581
+ };
582
+ }