@svgrid/grid 2.6.7 → 2.6.9

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 (381) hide show
  1. package/CHANGELOG.md +346 -346
  2. package/README.md +199 -199
  3. package/dist/FlexRender.svelte +96 -96
  4. package/dist/GridFooter.svelte +178 -178
  5. package/dist/GridMenus.svelte +705 -705
  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 +163 -163
  16. package/dist/SvDrawer.svelte +254 -254
  17. package/dist/SvDropDownList.svelte +374 -374
  18. package/dist/SvDurationInput.svelte +126 -126
  19. package/dist/SvField.svelte +293 -293
  20. package/dist/SvForm.svelte +437 -437
  21. package/dist/SvGrid.controller.svelte.js +42 -11
  22. package/dist/SvGrid.css +2856 -2856
  23. package/dist/SvGrid.svelte +2956 -2956
  24. package/dist/SvGridCellEditor.svelte +662 -662
  25. package/dist/SvGridChart.svelte +1716 -1716
  26. package/dist/SvGridChartPanel.svelte +485 -485
  27. package/dist/SvGridChartView.svelte +70 -70
  28. package/dist/SvGridDropdown.svelte +728 -728
  29. package/dist/SvGridSelect.svelte +266 -266
  30. package/dist/SvGroupCell.svelte +116 -116
  31. package/dist/SvListBox.svelte +326 -326
  32. package/dist/SvMaskedInput.svelte +122 -122
  33. package/dist/SvMenu.svelte +124 -124
  34. package/dist/SvMenuList.svelte +146 -146
  35. package/dist/SvMultiSelect.svelte +289 -289
  36. package/dist/SvNumberInput.svelte +168 -168
  37. package/dist/SvOtpInput.svelte +158 -158
  38. package/dist/SvPasswordInput.svelte +151 -151
  39. package/dist/SvPhoneInput.svelte +133 -133
  40. package/dist/SvPopover.svelte +197 -197
  41. package/dist/SvProgress.svelte +116 -116
  42. package/dist/SvRadioGroup.svelte +107 -107
  43. package/dist/SvRating.svelte +112 -112
  44. package/dist/SvResult.svelte +73 -73
  45. package/dist/SvRichText.svelte +211 -211
  46. package/dist/SvRowGroupPanel.svelte +170 -170
  47. package/dist/SvScrollArea.svelte +61 -61
  48. package/dist/SvSlider.svelte +203 -203
  49. package/dist/SvSwitchButton.svelte +108 -108
  50. package/dist/SvTagsInput.svelte +115 -115
  51. package/dist/SvTextInput.svelte +147 -147
  52. package/dist/SvTimePicker.svelte +245 -245
  53. package/dist/SvToaster.svelte +159 -159
  54. package/dist/SvToggleButton.svelte +85 -85
  55. package/dist/SvTooltip.svelte +161 -161
  56. package/dist/SvTour.svelte +208 -208
  57. package/dist/SvTree.svelte +444 -444
  58. package/dist/SvTreeSelect.svelte +235 -235
  59. package/dist/cdn/{GridMenus-C7SFm3Dp.js → GridMenus-BLajq_RP.js} +2 -2
  60. package/dist/cdn/{GridMenus-0i2QnChI.js → GridMenus-CPdy5dxw.js} +2 -2
  61. package/dist/cdn/{SvDateTimePicker-DSUhIta8.js → SvDateTimePicker-CHnUkWcH.js} +2 -2
  62. package/dist/cdn/{SvDateTimePicker-h9kPyszT.js → SvDateTimePicker-CRQH_U7E.js} +2 -2
  63. package/dist/cdn/{SvGridCellEditor-DkyQO6FV.js → SvGridCellEditor-BGUCzuPB.js} +1 -1
  64. package/dist/cdn/{SvGridCellEditor-JpJSRhDx.js → SvGridCellEditor-G8IMWIws.js} +1 -1
  65. package/dist/cdn/{SvGridChart-CwhFz7GV.js → SvGridChart-BEJmNNx9.js} +1 -1
  66. package/dist/cdn/{SvGridChart-Bs2GIR2Q.js → SvGridChart-BwVos976.js} +1 -1
  67. package/dist/cdn/{SvGridChartPanel-1WXuStzM.js → SvGridChartPanel-BOknOkrP.js} +1 -1
  68. package/dist/cdn/{SvGridChartPanel-e5_nqNP9.js → SvGridChartPanel-D2PjII4O.js} +1 -1
  69. package/dist/cdn/{SvGridChartView-SmPW10dI.js → SvGridChartView-00LPUHL1.js} +1 -1
  70. package/dist/cdn/{SvGridChartView-eSPuJE6g.js → SvGridChartView-BhUEJ5ki.js} +1 -1
  71. package/dist/cdn/{SvGridDropdown-B1ZcLpgs.js → SvGridDropdown-D0VdjeR8.js} +1 -1
  72. package/dist/cdn/{SvGridDropdown-CtdbHcIS.js → SvGridDropdown-D13MtJ2j.js} +1 -1
  73. package/dist/cdn/{src-V2_KUw2j.js → src-CKpl94Cx.js} +2751 -2738
  74. package/dist/cdn/{src-BkucJd50.js → src-ogpR-lHu.js} +2650 -2637
  75. package/dist/cdn/svgrid.js +6 -6
  76. package/dist/cdn/svgrid.svelte-external.js +6 -6
  77. package/dist/chart-export.js +8 -8
  78. package/dist/virtualization/virtualizer.d.ts +14 -0
  79. package/dist/virtualization/virtualizer.js +21 -0
  80. package/package.json +11 -11
  81. package/src/FlexRender.svelte +96 -96
  82. package/src/GridFooter.svelte +178 -178
  83. package/src/GridMenus.svelte +705 -705
  84. package/src/SvAutoComplete.svelte +165 -165
  85. package/src/SvAvatar.svelte +75 -75
  86. package/src/SvCalendar.svelte +503 -503
  87. package/src/SvCalendar.test.ts +226 -226
  88. package/src/SvCarousel.svelte +141 -141
  89. package/src/SvCheckBox.svelte +102 -102
  90. package/src/SvCircularProgress.svelte +109 -109
  91. package/src/SvColorInput.svelte +181 -181
  92. package/src/SvComboBox.svelte +275 -275
  93. package/src/SvContextMenu.svelte +116 -116
  94. package/src/SvCountryInput.svelte +163 -163
  95. package/src/SvDrawer.svelte +254 -254
  96. package/src/SvDropDownList.svelte +374 -374
  97. package/src/SvDurationInput.svelte +126 -126
  98. package/src/SvField.svelte +293 -293
  99. package/src/SvForm.svelte +437 -437
  100. package/src/SvForm.test.ts +411 -411
  101. package/src/SvGrid.controller.svelte.ts +3898 -3859
  102. package/src/SvGrid.css +2856 -2856
  103. package/src/SvGrid.svelte +2956 -2956
  104. package/src/SvGrid.types.ts +1769 -1769
  105. package/src/SvGridCellEditor.svelte +662 -662
  106. package/src/SvGridChart.svelte +1716 -1716
  107. package/src/SvGridChartPanel.svelte +485 -485
  108. package/src/SvGridChartView.svelte +70 -70
  109. package/src/SvGridDropdown.svelte +728 -728
  110. package/src/SvGridSelect.svelte +266 -266
  111. package/src/SvGroupCell.svelte +116 -116
  112. package/src/SvListBox.svelte +326 -326
  113. package/src/SvMaskedInput.svelte +122 -122
  114. package/src/SvMenu.svelte +124 -124
  115. package/src/SvMenu.test.ts +97 -97
  116. package/src/SvMenuList.svelte +146 -146
  117. package/src/SvMultiSelect.svelte +289 -289
  118. package/src/SvNumberInput.svelte +168 -168
  119. package/src/SvOtpInput.svelte +158 -158
  120. package/src/SvPasswordInput.svelte +151 -151
  121. package/src/SvPhoneInput.svelte +133 -133
  122. package/src/SvPopover.svelte +197 -197
  123. package/src/SvProgress.svelte +116 -116
  124. package/src/SvRadioGroup.svelte +107 -107
  125. package/src/SvRating.svelte +112 -112
  126. package/src/SvResult.svelte +73 -73
  127. package/src/SvRichText.svelte +211 -211
  128. package/src/SvRowGroupPanel.svelte +170 -170
  129. package/src/SvScrollArea.svelte +61 -61
  130. package/src/SvSlider.svelte +203 -203
  131. package/src/SvSwitchButton.svelte +108 -108
  132. package/src/SvTagsInput.svelte +115 -115
  133. package/src/SvTextInput.svelte +147 -147
  134. package/src/SvTimePicker.svelte +245 -245
  135. package/src/SvToaster.svelte +159 -159
  136. package/src/SvToaster.test.ts +95 -95
  137. package/src/SvToggleButton.svelte +85 -85
  138. package/src/SvTooltip.svelte +161 -161
  139. package/src/SvTour.svelte +208 -208
  140. package/src/SvTree.svelte +444 -444
  141. package/src/SvTreeSelect.svelte +235 -235
  142. package/src/a11y/dismissable.test.ts +119 -119
  143. package/src/a11y/dismissable.ts +114 -114
  144. package/src/a11y.contract.test.ts +49 -49
  145. package/src/a11y.test.ts +59 -59
  146. package/src/a11y.ts +61 -61
  147. package/src/ai.test.ts +502 -502
  148. package/src/ai.ts +1391 -1391
  149. package/src/build-api.coverage.test.ts +633 -633
  150. package/src/build-api.ts +846 -846
  151. package/src/builtin-editors.grid.test.ts +83 -83
  152. package/src/cell-formatting.ts +169 -169
  153. package/src/cell-render.test.ts +513 -513
  154. package/src/cell-render.ts +496 -496
  155. package/src/cell-values.ts +118 -118
  156. package/src/chart-export.ts +201 -201
  157. package/src/chart-view.svelte.ts +36 -36
  158. package/src/chart.ts +2295 -2295
  159. package/src/collaboration.test.ts +104 -104
  160. package/src/collaboration.ts +167 -167
  161. package/src/core.performance.test.ts +30 -30
  162. package/src/core.ts +1261 -1261
  163. package/src/createAutocomplete.svelte.ts +132 -132
  164. package/src/createCombobox.svelte.ts +191 -191
  165. package/src/createCountryInput.svelte.ts +157 -157
  166. package/src/createDropdownList.svelte.ts +168 -168
  167. package/src/createForm.svelte.ts +386 -386
  168. package/src/createGrid.svelte.ts +42 -42
  169. package/src/createGrid.test.ts +10 -10
  170. package/src/createGridState.svelte.ts +17 -17
  171. package/src/createListbox.svelte.ts +250 -250
  172. package/src/createMenu.svelte.ts +224 -224
  173. package/src/createPopoverSelect.svelte.ts +213 -213
  174. package/src/createSlider.svelte.ts +191 -191
  175. package/src/createTooltip.svelte.ts +144 -144
  176. package/src/createTree.svelte.ts +319 -319
  177. package/src/editing.test.ts +949 -949
  178. package/src/editing.ts +606 -606
  179. package/src/editor-contract.ts +170 -170
  180. package/src/editor-registry.grid.test.ts +144 -144
  181. package/src/editor-registry.ts +122 -122
  182. package/src/export-data-api.test.ts +126 -126
  183. package/src/export-format.test.ts +107 -107
  184. package/src/export-format.ts +601 -601
  185. package/src/filter-operators.ts +160 -160
  186. package/src/flex-render.ts +3 -3
  187. package/src/form-field.ts +127 -127
  188. package/src/group-display.test.ts +167 -167
  189. package/src/group-display.ts +200 -200
  190. package/src/headless.ts +80 -80
  191. package/src/index.ts +754 -754
  192. package/src/js-scroller.svelte.ts +173 -173
  193. package/src/keyboard-handlers.ts +270 -270
  194. package/src/keyboard.test.ts +59 -59
  195. package/src/keyboard.ts +97 -97
  196. package/src/list-nav.test.ts +49 -49
  197. package/src/list-nav.ts +29 -29
  198. package/src/list-option.test.ts +56 -56
  199. package/src/list-option.ts +172 -172
  200. package/src/menus.ts +567 -567
  201. package/src/merge-objects.ts +48 -48
  202. package/src/overlays.test.ts +90 -90
  203. package/src/render-component.ts +28 -28
  204. package/src/row-drag-touch.ts +211 -211
  205. package/src/row-drag.test.ts +353 -353
  206. package/src/row-drag.ts +415 -415
  207. package/src/row-resize.ts +210 -210
  208. package/src/scheduler-model.test.ts +562 -562
  209. package/src/scheduler-model.ts +872 -872
  210. package/src/selection.test.ts +754 -754
  211. package/src/selection.ts +491 -491
  212. package/src/server-data-source.test.ts +383 -383
  213. package/src/server-data-source.ts +469 -469
  214. package/src/sparkline.test.ts +68 -68
  215. package/src/sparkline.ts +169 -169
  216. package/src/spreadsheet.test.ts +488 -488
  217. package/src/spreadsheet.ts +312 -312
  218. package/src/static-functions.ts +11 -11
  219. package/src/subscribe.ts +38 -38
  220. package/src/svgrid-wrapper.types.ts +558 -558
  221. package/src/svgrid.async-editor-options.test.ts +273 -273
  222. package/src/svgrid.auto-row-height.test.ts +204 -204
  223. package/src/svgrid.behavior.test.ts +705 -705
  224. package/src/svgrid.charting.test.ts +534 -534
  225. package/src/svgrid.comments-autocomplete.test.ts +127 -127
  226. package/src/svgrid.context-menu.test.ts +147 -147
  227. package/src/svgrid.features.test.ts +157 -157
  228. package/src/svgrid.filter-depth.test.ts +163 -163
  229. package/src/svgrid.filter-menu-listbox.svelte.test.ts +331 -331
  230. package/src/svgrid.filter-menu-scroll.test.ts +112 -112
  231. package/src/svgrid.grand-total.test.ts +188 -188
  232. package/src/svgrid.group-display-mode.test.ts +171 -171
  233. package/src/svgrid.group-footers.test.ts +121 -121
  234. package/src/svgrid.group-pagination.test.ts +153 -153
  235. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  236. package/src/svgrid.tree-data.test.ts +186 -186
  237. package/src/svgrid.wrapper.test.ts +63 -63
  238. package/src/svgriddropdown.async-panel.svelte.test.ts +195 -195
  239. package/src/test-setup.ts +62 -62
  240. package/src/themes/index.ts +286 -286
  241. package/src/toast-store.svelte.ts +246 -246
  242. package/src/toast-store.test.ts +147 -147
  243. package/src/tree-row-model.test.ts +168 -168
  244. package/src/ui-buttons.test.ts +144 -144
  245. package/src/ui-inputs.test.ts +118 -118
  246. package/src/ui-localization.test.ts +113 -113
  247. package/src/ui-range.test.ts +70 -70
  248. package/src/ui-selection.test.ts +155 -155
  249. package/src/ui-tier1.test.ts +142 -142
  250. package/src/virtual.test.ts +88 -88
  251. package/src/virtualization/column-virtualizer.test.ts +27 -27
  252. package/src/virtualization/column-virtualizer.ts +30 -30
  253. package/src/virtualization/pre-measure.test.ts +65 -0
  254. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  255. package/src/virtualization/types.ts +30 -30
  256. package/src/virtualization/virtualizer.test.ts +47 -47
  257. package/src/virtualization/virtualizer.ts +322 -296
  258. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +0 -1
  259. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +0 -178
  260. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +0 -3843
  261. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +0 -1
  262. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +0 -23
  263. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +0 -1
  264. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +0 -1925
  265. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +0 -1
  266. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +0 -206
  267. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +0 -1
  268. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +0 -20
  269. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +0 -1
  270. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +0 -264
  271. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +0 -1
  272. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +0 -698
  273. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +0 -1
  274. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +0 -3
  275. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +0 -135
  276. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +0 -1
  277. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +0 -57
  278. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +0 -1
  279. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +0 -2
  280. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +0 -46691
  281. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +0 -1
  282. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +0 -239
  283. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +0 -1
  284. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +0 -2
  285. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +0 -6
  286. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +0 -1
  287. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +0 -7
  288. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +0 -6
  289. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +0 -1
  290. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +0 -7
  291. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +0 -1
  292. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +0 -7
  293. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +0 -1
  294. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +0 -7
  295. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +0 -1
  296. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +0 -6
  297. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +0 -85
  298. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +0 -1
  299. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +0 -561
  300. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +0 -1
  301. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +0 -26
  302. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +0 -1
  303. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +0 -124
  304. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +0 -1
  305. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +0 -2
  306. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +0 -91
  307. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +0 -1
  308. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +0 -242
  309. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +0 -1
  310. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +0 -497
  311. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +0 -1
  312. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +0 -4929
  313. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +0 -1
  314. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +0 -192
  315. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +0 -1
  316. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +0 -10
  317. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +0 -1
  318. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +0 -140
  319. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js.map +0 -1
  320. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +0 -1
  321. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +0 -178
  322. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +0 -3843
  323. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +0 -1
  324. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +0 -23
  325. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +0 -1
  326. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +0 -1925
  327. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +0 -1
  328. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +0 -206
  329. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +0 -1
  330. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +0 -20
  331. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +0 -1
  332. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +0 -264
  333. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +0 -1
  334. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +0 -698
  335. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +0 -1
  336. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +0 -3
  337. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +0 -135
  338. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +0 -1
  339. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +0 -57
  340. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +0 -1
  341. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +0 -2
  342. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +0 -46691
  343. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +0 -1
  344. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +0 -239
  345. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +0 -1
  346. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +0 -2
  347. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +0 -6
  348. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +0 -1
  349. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +0 -7
  350. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +0 -6
  351. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +0 -1
  352. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +0 -7
  353. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +0 -1
  354. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +0 -7
  355. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +0 -1
  356. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +0 -7
  357. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +0 -1
  358. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +0 -6
  359. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +0 -85
  360. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +0 -1
  361. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +0 -561
  362. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +0 -1
  363. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +0 -26
  364. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +0 -1
  365. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +0 -124
  366. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +0 -1
  367. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +0 -2
  368. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +0 -91
  369. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +0 -1
  370. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +0 -242
  371. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +0 -1
  372. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +0 -497
  373. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +0 -1
  374. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +0 -4929
  375. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +0 -1
  376. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +0 -192
  377. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +0 -1
  378. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +0 -10
  379. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +0 -1
  380. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +0 -140
  381. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js.map +0 -1
@@ -1,662 +1,662 @@
1
- <script lang="ts" generics="TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData">
2
- /**
3
- * The in-cell and full-row editor UI, lifted out of SvGrid.svelte.
4
- *
5
- * Editing is off by default (`editable` / `enableInlineEditing` both default
6
- * to false) and this markup only ever renders while a cell is actually being
7
- * edited, so it has no business sitting in the base bundle. SvGrid.svelte
8
- * loads it with `import()` the moment editing is enabled - well before any
9
- * double-click can happen - so behaviour is unchanged either way.
10
- *
11
- * Keep `SvGridDropdown` and `SvDateTimePicker` DYNAMIC below. Importing
12
- * either statically would drag ~22 KB into this chunk for every text edit,
13
- * and a static import from anywhere reachable by SvGrid.svelte has silently
14
- * defeated a lazy boundary in this codebase before.
15
- */
16
- import {
17
- type CellEditorOption,
18
- type Column,
19
- type EditorContext,
20
- type Row,
21
- type RowData,
22
- type TableFeatures,
23
- } from "./index";
24
- import {
25
- dateToTimeString,
26
- getEditableInputValue,
27
- getEditorClass,
28
- getEditorInputType,
29
- timeStringToDate,
30
- toValueArray,
31
- } from "./SvGrid.helpers";
32
- import {
33
- getCellEditor,
34
- hasCellEditor,
35
- resolveEditorProps,
36
- type CellEditorContext,
37
- } from "./editor-registry";
38
- import type { SvGridController } from "./SvGrid.controller.svelte";
39
-
40
- let {
41
- ctrl,
42
- column,
43
- row,
44
- fullRow = false,
45
- }: {
46
- ctrl: SvGridController<TFeatures, TData>;
47
- column: Column<TData>;
48
- row: Row<TData>;
49
- /** Render the full-row editor for this cell instead of the single-cell one. */
50
- fullRow?: boolean;
51
- } = $props();
52
-
53
- // Heavy editors stay behind their own `import()` so a text edit never pays
54
- // for the dropdown or the date picker.
55
- let DropdownEditor = $state<typeof import("./SvGridDropdown.svelte").default | null>(null);
56
- let DateEditor = $state<typeof import("./SvDateTimePicker.svelte").default | null>(null);
57
- $effect(() => {
58
- const t = ctrl.editingCell?.editorType;
59
- if (
60
- (t === "list" || t === "chips" || t === "select" || t === "rich-select") &&
61
- !DropdownEditor
62
- )
63
- import("./SvGridDropdown.svelte").then((m) => (DropdownEditor = m.default));
64
- if ((t === "date" || t === "datetime" || t === "time") && !DateEditor)
65
- import("./SvDateTimePicker.svelte").then((m) => (DateEditor = m.default));
66
- });
67
-
68
- const grid = $derived(ctrl.grid);
69
- const fullRowEdit = $derived(ctrl.fullRowEdit);
70
- const getColumnEditorOptions = $derived(ctrl.getColumnEditorOptions);
71
- const areEditorOptionsLoading = $derived(ctrl.areEditorOptionsLoading);
72
- const saveEditingCell = $derived(ctrl.saveEditingCell);
73
- const updateEditingCellValue = $derived(ctrl.updateEditingCellValue);
74
- const onEditorKeyDown = $derived(ctrl.onEditorKeyDown);
75
- const focusOnMount = $derived(ctrl.focusOnMount);
76
- const toggleCheckboxWithKeyboard = $derived(ctrl.toggleCheckboxWithKeyboard);
77
-
78
- function fullRowKeydown(e: KeyboardEvent) {
79
- if (e.key === "Enter") {
80
- e.preventDefault();
81
- ctrl.commitFullRowEdit();
82
- ctrl.gridRootEl?.focus({ preventScroll: true });
83
- } else if (e.key === "Escape") {
84
- e.preventDefault();
85
- ctrl.cancelFullRowEdit();
86
- ctrl.gridRootEl?.focus({ preventScroll: true });
87
- }
88
- }
89
- function optionValueOf(o: unknown): string {
90
- return typeof o === "object" && o !== null && "value" in o
91
- ? String((o as { value: unknown }).value)
92
- : String(o);
93
- }
94
- function optionLabelOf(o: unknown): string {
95
- return typeof o === "object" && o !== null && "label" in o
96
- ? String((o as { label: unknown }).label)
97
- : String(o);
98
- }
99
-
100
- // Build the interaction context handed to a CUSTOM cell editor registered via
101
- // `registerCellEditor`. Maps the grid's editing lifecycle onto the uniform
102
- // change / commit / cancel contract every registered editor speaks.
103
- function buildRegisteredEditorContext(): CellEditorContext {
104
- const cell = ctrl.editingCell;
105
- return {
106
- value: cell?.value,
107
- rowId: cell?.rowId ?? "",
108
- columnId: cell?.columnId ?? "",
109
- onChange: (v: unknown) => updateEditingCellValue(v),
110
- onCommit: (v?: unknown) => {
111
- if (v !== undefined) updateEditingCellValue(v);
112
- saveEditingCell();
113
- },
114
- onCancel: () => {
115
- ctrl.editingCell = null;
116
- ctrl.gridRootEl?.focus({ preventScroll: true });
117
- },
118
- // Tab out of an editor: commit, then step to the adjacent cell. Without
119
- // this a registered editor's Tab walks focus out of the grid (#48) - the
120
- // built-in editors already route through the same helper.
121
- onCommitAndMove: (v: unknown, direction: 1 | -1) => {
122
- if (v !== undefined) updateEditingCellValue(v);
123
- ctrl.commitAndMoveByTab(direction === -1);
124
- },
125
- // Close a popover editor without committing. Same effect as cancel today;
126
- // named separately so an editor can distinguish "dismiss my panel" from
127
- // "abandon the edit" if that ever diverges.
128
- onRequestClose: () => {
129
- ctrl.editingCell = null;
130
- ctrl.gridRootEl?.focus({ preventScroll: true });
131
- },
132
- inCell: true,
133
- };
134
- }
135
- </script>
136
-
137
- {#snippet chipsEditor(
138
- opts: CellEditorOption[],
139
- multi: boolean,
140
- selectedArr: Array<string | number>,
141
- optsLoading: boolean,
142
- )}
143
- {#if opts.length > 0}
144
- <!-- Options-driven chips editor: defer to the custom dropdown,
145
- which renders the selected values as chips in its trigger and
146
- pops out a styled listbox. Identical UX to the list editor
147
- with renderChipsInTrigger flipped on. -->
148
- {#if DropdownEditor}
149
- <DropdownEditor
150
- options={opts}
151
- loading={optsLoading}
152
- value={ctrl.editingCell?.value}
153
- multiple={multi}
154
- placeholder="Pick…"
155
- renderChipsInTrigger={true}
156
- onChange={(next) => {
157
- ctrl.editingCell = ctrl.editingCell
158
- ? { ...ctrl.editingCell, value: next }
159
- : ctrl.editingCell;
160
- }}
161
- onCommit={() => saveEditingCell()}
162
- onCancel={() => {
163
- ctrl.editingCell = null;
164
- ctrl.gridRootEl?.focus({ preventScroll: true });
165
- }}
166
- />
167
- {/if}
168
- {:else}
169
- <!-- Free-form chips: typed tags. Enter / comma commits a chip,
170
- Backspace on empty input removes the last chip, blur saves. -->
171
- <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
172
- <div
173
- class="sv-grid-cell-editor sv-grid-cell-editor-chips"
174
- role="group"
175
- tabindex={-1}
176
- >
177
- <div class="sv-grid-chips-row">
178
- {#each selectedArr as v, idx (String(v) + "_" + idx)}
179
- <span class="sv-grid-chip sv-grid-chip-removable">
180
- {String(v)}
181
- <button
182
- type="button"
183
- class="sv-grid-chip-remove"
184
- aria-label="Remove {String(v)}"
185
- onmousedown={(event) => event.preventDefault()}
186
- onclick={() => {
187
- const next = selectedArr.filter((_, i) => i !== idx);
188
- ctrl.editingCell = ctrl.editingCell
189
- ? {
190
- ...ctrl.editingCell,
191
- value: multi ? next : (next[0] ?? null),
192
- }
193
- : ctrl.editingCell;
194
- }}>×</button
195
- >
196
- </span>
197
- {/each}
198
- <input
199
- use:focusOnMount
200
- class="sv-grid-chip-input"
201
- type="text"
202
- placeholder={multi ? "Type, Enter to add" : "Type a value"}
203
- onkeydown={(event) => {
204
- if (event.key === "Enter" || (multi && event.key === ",")) {
205
- event.preventDefault();
206
- event.stopPropagation();
207
- const input = event.currentTarget as HTMLInputElement;
208
- const raw = input.value.trim();
209
- if (raw) {
210
- const next = multi ? [...selectedArr, raw] : [raw];
211
- ctrl.editingCell = ctrl.editingCell
212
- ? { ...ctrl.editingCell, value: multi ? next : raw }
213
- : ctrl.editingCell;
214
- input.value = "";
215
- if (!multi) saveEditingCell();
216
- }
217
- } else if (event.key === "Escape") {
218
- onEditorKeyDown(event);
219
- } else if (event.key === "Backspace") {
220
- const input = event.currentTarget as HTMLInputElement;
221
- if (input.value === "" && selectedArr.length > 0) {
222
- event.preventDefault();
223
- const next = selectedArr.slice(0, -1);
224
- ctrl.editingCell = ctrl.editingCell
225
- ? {
226
- ...ctrl.editingCell,
227
- value: multi ? next : (next[0] ?? null),
228
- }
229
- : ctrl.editingCell;
230
- }
231
- }
232
- }}
233
- onblur={() => saveEditingCell()}
234
- />
235
- {#if multi}
236
- <button
237
- type="button"
238
- class="sv-grid-chip-commit"
239
- onmousedown={(event) => event.preventDefault()}
240
- onclick={() => saveEditingCell()}
241
- aria-label="Commit chip selection">Done</button
242
- >
243
- {/if}
244
- </div>
245
- </div>
246
- {/if}
247
- {/snippet}
248
-
249
- {#if fullRow}
250
- {@const et = column.columnDef.editorType ?? "text"}
251
- {@const val = fullRowEdit?.draft[column.id]}
252
- {#if et === "checkbox"}
253
- <input
254
- type="checkbox"
255
- class="sv-grid-fr-editor sv-grid-fr-checkbox"
256
- checked={Boolean(val)}
257
- onchange={(e) =>
258
- ctrl.setFullRowDraft(column.id, e.currentTarget.checked)}
259
- onkeydown={fullRowKeydown}
260
- onpointerdown={(e) => e.stopPropagation()}
261
- onclick={(e) => e.stopPropagation()}
262
- />
263
- {:else if et === "list" || et === "select" || et === "rich-select"}
264
- {@const opts = getColumnEditorOptions(column, row)}
265
- <select
266
- class="sv-grid-cell-editor sv-grid-fr-editor"
267
- value={String(val ?? "")}
268
- onchange={(e) => ctrl.setFullRowDraft(column.id, e.currentTarget.value)}
269
- onkeydown={fullRowKeydown}
270
- onpointerdown={(e) => e.stopPropagation()}
271
- onclick={(e) => e.stopPropagation()}
272
- >
273
- {#each opts as o (optionValueOf(o))}
274
- <option value={optionValueOf(o)}>{optionLabelOf(o)}</option>
275
- {/each}
276
- </select>
277
- {:else}
278
- {@const inputType =
279
- et === "number"
280
- ? "number"
281
- : et === "date"
282
- ? "date"
283
- : et === "datetime"
284
- ? "datetime-local"
285
- : et === "time"
286
- ? "time"
287
- : et === "password"
288
- ? "password"
289
- : "text"}
290
- <input
291
- type={inputType}
292
- class="sv-grid-cell-editor sv-grid-fr-editor"
293
- value={String(val ?? "")}
294
- oninput={(e) => ctrl.setFullRowDraft(column.id, e.currentTarget.value)}
295
- onkeydown={fullRowKeydown}
296
- onpointerdown={(e) => e.stopPropagation()}
297
- onclick={(e) => e.stopPropagation()}
298
- />
299
- {/if}
300
- {:else}
301
- {#if column.columnDef.cellEditor}
302
- <!-- Custom editor slot. The columnDef provides a snippet that
303
- receives the editor context (value + commit + cancel) so the
304
- consumer fully owns the in-cell UI. -->
305
- {@const customEditor = column.columnDef
306
- .cellEditor as unknown as import("svelte").Snippet<
307
- [EditorContext<TData>]
308
- >}
309
- {@render customEditor({
310
- cell: row.getAllCells().find((c) => c.column.id === column.id)!,
311
- row,
312
- column,
313
- table: grid,
314
- getValue: () => ctrl.editingCell?.value,
315
- value: ctrl.editingCell?.value,
316
- update: (next: unknown) => {
317
- // Stage the draft without closing. Live-preview controls
318
- // (sliders, color pickers) call this on every input tick.
319
- ctrl.editingCell = ctrl.editingCell
320
- ? { ...ctrl.editingCell, value: next }
321
- : ctrl.editingCell;
322
- },
323
- commit: (next?: unknown) => {
324
- // Write + close. If the caller passed a value, stage it
325
- // first; otherwise save whatever update() last wrote.
326
- if (next !== undefined) {
327
- ctrl.editingCell = ctrl.editingCell
328
- ? { ...ctrl.editingCell, value: next }
329
- : ctrl.editingCell;
330
- }
331
- saveEditingCell();
332
- },
333
- cancel: () => {
334
- ctrl.editingCell = null;
335
- ctrl.gridRootEl?.focus({ preventScroll: true });
336
- },
337
- })}
338
- {:else if ctrl.editingCell?.editorType === "checkbox"}
339
- <button
340
- type="button"
341
- class="sv-grid-checkbox"
342
- role="checkbox"
343
- aria-checked={Boolean(ctrl.editingCell.value)}
344
- aria-label="Edit checkbox value"
345
- onclick={(event) => {
346
- event.stopPropagation();
347
- const nextValue = !ctrl.editingCell?.value;
348
- ctrl.editingCell = ctrl.editingCell
349
- ? { ...ctrl.editingCell, value: nextValue }
350
- : ctrl.editingCell;
351
- saveEditingCell();
352
- }}
353
- onkeydown={(event) =>
354
- toggleCheckboxWithKeyboard(event, () => {
355
- event.stopPropagation();
356
- const nextValue = !ctrl.editingCell?.value;
357
- ctrl.editingCell = ctrl.editingCell
358
- ? { ...ctrl.editingCell, value: nextValue }
359
- : ctrl.editingCell;
360
- saveEditingCell();
361
- })}
362
- onblur={() => saveEditingCell()}
363
- ></button>
364
- {:else if ctrl.editingCell?.editorType === "list"}
365
- {@const opts = getColumnEditorOptions(column, row)}
366
- {@const optsLoading = areEditorOptionsLoading(column, row)}
367
- {@const multi = column.columnDef.editorMultiple === true}
368
- {#if DropdownEditor}
369
- <DropdownEditor
370
- options={opts}
371
- loading={optsLoading}
372
- value={ctrl.editingCell?.value}
373
- multiple={multi}
374
- placeholder="Select…"
375
- onChange={(next) => {
376
- ctrl.editingCell = ctrl.editingCell
377
- ? { ...ctrl.editingCell, value: next }
378
- : ctrl.editingCell;
379
- }}
380
- onCommit={() => saveEditingCell()}
381
- onCancel={() => {
382
- ctrl.editingCell = null;
383
- ctrl.gridRootEl?.focus({ preventScroll: true });
384
- }}
385
- />
386
- {/if}
387
- {:else if ctrl.editingCell?.editorType === "chips"}
388
- {@const opts = getColumnEditorOptions(column, row)}
389
- {@const optsLoading = areEditorOptionsLoading(column, row)}
390
- {@const multi = column.columnDef.editorMultiple === true}
391
- {@const selectedArr = toValueArray(ctrl.editingCell?.value)}
392
- {@render chipsEditor(opts, multi, selectedArr, optsLoading)}
393
- {:else if ctrl.editingCell?.editorType === "rating"}
394
- {@const ratingVal = Math.max(
395
- 0,
396
- Math.min(5, Math.round(Number(ctrl.editingCell?.value) || 0)),
397
- )}
398
- <span class="sv-grid-rating-editor" role="radiogroup" aria-label="Rating">
399
- {#each [1, 2, 3, 4, 5] as n (n)}
400
- <button
401
- type="button"
402
- role="radio"
403
- aria-checked={ratingVal >= n}
404
- aria-label={`${n} ${n === 1 ? "star" : "stars"}`}
405
- class={`sv-grid-rating-star ${ratingVal >= n ? "sv-grid-rating-star-on" : ""}`}
406
- onmousedown={(event) => event.preventDefault()}
407
- onclick={(event) => {
408
- event.stopPropagation();
409
- ctrl.editingCell = ctrl.editingCell
410
- ? { ...ctrl.editingCell, value: n }
411
- : ctrl.editingCell;
412
- saveEditingCell();
413
- }}
414
- onkeydown={onEditorKeyDown}>★</button
415
- >
416
- {/each}
417
- <button
418
- type="button"
419
- aria-label="Clear rating"
420
- class="sv-grid-rating-clear"
421
- onmousedown={(event) => event.preventDefault()}
422
- onclick={(event) => {
423
- event.stopPropagation();
424
- ctrl.editingCell = ctrl.editingCell
425
- ? { ...ctrl.editingCell, value: 0 }
426
- : ctrl.editingCell;
427
- saveEditingCell();
428
- }}>×</button
429
- >
430
- </span>
431
- {:else if ctrl.editingCell?.editorType === "select"}
432
- <!-- Custom dropdown: opens a themed popover identical in feel to
433
- the existing 'list' editor (single-select, no typeahead). -->
434
- {@const selectOpts = getColumnEditorOptions(column, row)}
435
- {@const optsLoading = areEditorOptionsLoading(column, row)}
436
- {#if DropdownEditor}
437
- <DropdownEditor
438
- options={selectOpts}
439
- loading={optsLoading}
440
- value={ctrl.editingCell?.value}
441
- multiple={false}
442
- placeholder="Select…"
443
- onChange={(next) => {
444
- ctrl.editingCell = ctrl.editingCell
445
- ? { ...ctrl.editingCell, value: next }
446
- : ctrl.editingCell;
447
- }}
448
- onCommit={() => saveEditingCell()}
449
- onCancel={() => {
450
- ctrl.editingCell = null;
451
- ctrl.gridRootEl?.focus({ preventScroll: true });
452
- }}
453
- />
454
- {/if}
455
- {:else if ctrl.editingCell?.editorType === "rich-select"}
456
- <!-- Searchable combobox: same popover as 'select' with a
457
- typeahead filter input baked in at the top. -->
458
- {@const richOpts = getColumnEditorOptions(column, row)}
459
- {@const optsLoading = areEditorOptionsLoading(column, row)}
460
- {#if DropdownEditor}
461
- <DropdownEditor
462
- options={richOpts}
463
- loading={optsLoading}
464
- value={ctrl.editingCell?.value}
465
- multiple={false}
466
- searchable={true}
467
- placeholder="Search…"
468
- onChange={(next) => {
469
- ctrl.editingCell = ctrl.editingCell
470
- ? { ...ctrl.editingCell, value: next }
471
- : ctrl.editingCell;
472
- }}
473
- onCommit={() => saveEditingCell()}
474
- onCancel={() => {
475
- ctrl.editingCell = null;
476
- ctrl.gridRootEl?.focus({ preventScroll: true });
477
- }}
478
- />
479
- {/if}
480
- {:else if ctrl.editingCell?.editorType === "textarea"}
481
- <!-- Multi-line editor. Commits on Tab, Ctrl/Cmd+Enter, or blur.
482
- Plain Enter inserts a newline (the whole point of textarea).
483
- Esc cancels. -->
484
- <textarea
485
- use:focusOnMount
486
- class="sv-grid-cell-editor sv-grid-cell-editor-textarea"
487
- rows="4"
488
- value={String(ctrl.editingCell?.value ?? "")}
489
- onpointerdown={(event) => event.stopPropagation()}
490
- oninput={(event) =>
491
- updateEditingCellValue(
492
- (event.currentTarget as HTMLTextAreaElement).value,
493
- )}
494
- onkeydown={(event) => {
495
- event.stopPropagation();
496
- if (event.key === "Escape") {
497
- event.preventDefault();
498
- ctrl.editingCell = null;
499
- ctrl.gridRootEl?.focus({ preventScroll: true });
500
- return;
501
- }
502
- // Tab and Ctrl/Cmd+Enter both commit. Plain Enter inserts a newline.
503
- // Tab goes through the shared helper so it advances the active cell
504
- // like every other editor does (#48).
505
- if (event.key === "Tab") {
506
- event.preventDefault();
507
- ctrl.commitAndMoveByTab(event.shiftKey);
508
- return;
509
- }
510
- if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
511
- event.preventDefault();
512
- saveEditingCell();
513
- ctrl.gridRootEl?.focus({ preventScroll: true });
514
- }
515
- }}
516
- onblur={() => saveEditingCell()}
517
- ></textarea>
518
- {:else if ctrl.editingCell?.editorType === "autocomplete"}
519
- <!-- Free-text autocomplete: a text input with a live-filtered
520
- suggestion list. Typing edits the value freely; clicking a
521
- suggestion (or blur) commits. Accepts values not in the list. -->
522
- {@const acOpts = getColumnEditorOptions(column, row)}
523
- {@const acText = String(ctrl.editingCell?.value ?? "")}
524
- {@const acFiltered = acText.trim()
525
- ? acOpts.filter((o) =>
526
- String(o.label).toLowerCase().includes(acText.toLowerCase()),
527
- )
528
- : acOpts}
529
- <div class="sv-grid-autocomplete">
530
- <input
531
- use:focusOnMount
532
- class="sv-grid-cell-editor sv-grid-cell-editor-autocomplete"
533
- type="text"
534
- value={acText}
535
- onpointerdown={(event) => event.stopPropagation()}
536
- oninput={(event) =>
537
- updateEditingCellValue(
538
- (event.currentTarget as HTMLInputElement).value,
539
- )}
540
- onblur={() => saveEditingCell()}
541
- onkeydown={onEditorKeyDown}
542
- />
543
- {#if acFiltered.length > 0}
544
- <div class="sv-grid-autocomplete-list" role="listbox">
545
- {#each acFiltered.slice(0, 50) as opt (opt.value)}
546
- <button
547
- type="button"
548
- class="sv-grid-autocomplete-option"
549
- role="option"
550
- aria-selected={String(opt.value) === acText}
551
- onmousedown={(event) => {
552
- event.preventDefault();
553
- ctrl.editingCell = ctrl.editingCell
554
- ? { ...ctrl.editingCell, value: opt.value }
555
- : ctrl.editingCell;
556
- saveEditingCell();
557
- }}>{opt.label}</button
558
- >
559
- {/each}
560
- </div>
561
- {/if}
562
- </div>
563
- {:else if ctrl.editingCell?.editorType === "date"}
564
- <!-- Rich date editor: SvCalendar popover over a formatted input. Opts
565
- out to the native <input type="date"> via editorType 'date-native'. -->
566
- {#if DateEditor}
567
- <DateEditor
568
- value={ctrl.editingCell?.value as string | number | Date | null}
569
- formatString="yyyy-MM-dd"
570
- dropDownDisplayMode="calendar"
571
- autoOpen
572
- block
573
- onChange={(d) => updateEditingCellValue(d)}
574
- onCommit={() => saveEditingCell()}
575
- onCancel={() => {
576
- ctrl.editingCell = null;
577
- ctrl.gridRootEl?.focus({ preventScroll: true });
578
- }}
579
- />
580
- {/if}
581
- {:else if ctrl.editingCell?.editorType === "datetime"}
582
- {#if DateEditor}
583
- <DateEditor
584
- value={ctrl.editingCell?.value as string | number | Date | null}
585
- formatString="yyyy-MM-dd HH:mm"
586
- dropDownDisplayMode="both"
587
- autoOpen
588
- block
589
- onChange={(d) => updateEditingCellValue(d)}
590
- onCommit={() => saveEditingCell()}
591
- onCancel={() => {
592
- ctrl.editingCell = null;
593
- ctrl.gridRootEl?.focus({ preventScroll: true });
594
- }}
595
- />
596
- {/if}
597
- {:else if ctrl.editingCell?.editorType === "time"}
598
- <!-- Rich time editor: SvTimePicker dial. Stores the 'HH:MM' string the
599
- `time` parser expects; opts out via editorType 'time-native'. -->
600
- {#if DateEditor}
601
- <DateEditor
602
- value={timeStringToDate(ctrl.editingCell?.value)}
603
- formatString="HH:mm"
604
- dropDownDisplayMode="time"
605
- autoOpen
606
- block
607
- onChange={(d) => updateEditingCellValue(dateToTimeString(d))}
608
- onCommit={() => saveEditingCell()}
609
- onCancel={() => {
610
- ctrl.editingCell = null;
611
- ctrl.gridRootEl?.focus({ preventScroll: true });
612
- }}
613
- />
614
- {/if}
615
- {:else if ctrl.editingCell?.editorType === "color"}
616
- <!-- Native <input type="color"> opens its picker in a separate OS
617
- overlay; once the picker closes, focus stays on the input so
618
- `blur` never fires on its own. Commit on `change` (which fires
619
- exactly once when the picker is dismissed) so the chosen color
620
- is saved without needing the user to click elsewhere. -->
621
- <input
622
- use:focusOnMount
623
- class={getEditorClass("color")}
624
- type="color"
625
- value={getEditableInputValue("color", ctrl.editingCell?.value)}
626
- oninput={(event) =>
627
- updateEditingCellValue(
628
- (event.currentTarget as HTMLInputElement).value,
629
- )}
630
- onchange={(event) => {
631
- updateEditingCellValue(
632
- (event.currentTarget as HTMLInputElement).value,
633
- );
634
- saveEditingCell();
635
- }}
636
- onblur={() => saveEditingCell()}
637
- onkeydown={onEditorKeyDown}
638
- />
639
- {:else if hasCellEditor(String(ctrl.editingCell?.editorType ?? ""))}
640
- <!-- Custom editor registered via `registerCellEditor(type, Component)`:
641
- mount it and hand it the uniform change / commit / cancel context. -->
642
- {@const _reg = getCellEditor(String(ctrl.editingCell?.editorType))!}
643
- {@const CustomCellEditor = _reg.component}
644
- <CustomCellEditor {...resolveEditorProps(_reg, buildRegisteredEditorContext())} />
645
- {:else}
646
- <input
647
- use:focusOnMount
648
- class={getEditorClass(ctrl.editingCell?.editorType ?? "text")}
649
- type={getEditorInputType(ctrl.editingCell?.editorType ?? "text")}
650
- value={getEditableInputValue(
651
- ctrl.editingCell?.editorType ?? "text",
652
- ctrl.editingCell?.value,
653
- )}
654
- oninput={(event) =>
655
- updateEditingCellValue(
656
- (event.currentTarget as HTMLInputElement).value,
657
- )}
658
- onblur={() => saveEditingCell()}
659
- onkeydown={onEditorKeyDown}
660
- />
661
- {/if}
662
- {/if}
1
+ <script lang="ts" generics="TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData">
2
+ /**
3
+ * The in-cell and full-row editor UI, lifted out of SvGrid.svelte.
4
+ *
5
+ * Editing is off by default (`editable` / `enableInlineEditing` both default
6
+ * to false) and this markup only ever renders while a cell is actually being
7
+ * edited, so it has no business sitting in the base bundle. SvGrid.svelte
8
+ * loads it with `import()` the moment editing is enabled - well before any
9
+ * double-click can happen - so behaviour is unchanged either way.
10
+ *
11
+ * Keep `SvGridDropdown` and `SvDateTimePicker` DYNAMIC below. Importing
12
+ * either statically would drag ~22 KB into this chunk for every text edit,
13
+ * and a static import from anywhere reachable by SvGrid.svelte has silently
14
+ * defeated a lazy boundary in this codebase before.
15
+ */
16
+ import {
17
+ type CellEditorOption,
18
+ type Column,
19
+ type EditorContext,
20
+ type Row,
21
+ type RowData,
22
+ type TableFeatures,
23
+ } from "./index";
24
+ import {
25
+ dateToTimeString,
26
+ getEditableInputValue,
27
+ getEditorClass,
28
+ getEditorInputType,
29
+ timeStringToDate,
30
+ toValueArray,
31
+ } from "./SvGrid.helpers";
32
+ import {
33
+ getCellEditor,
34
+ hasCellEditor,
35
+ resolveEditorProps,
36
+ type CellEditorContext,
37
+ } from "./editor-registry";
38
+ import type { SvGridController } from "./SvGrid.controller.svelte";
39
+
40
+ let {
41
+ ctrl,
42
+ column,
43
+ row,
44
+ fullRow = false,
45
+ }: {
46
+ ctrl: SvGridController<TFeatures, TData>;
47
+ column: Column<TData>;
48
+ row: Row<TData>;
49
+ /** Render the full-row editor for this cell instead of the single-cell one. */
50
+ fullRow?: boolean;
51
+ } = $props();
52
+
53
+ // Heavy editors stay behind their own `import()` so a text edit never pays
54
+ // for the dropdown or the date picker.
55
+ let DropdownEditor = $state<typeof import("./SvGridDropdown.svelte").default | null>(null);
56
+ let DateEditor = $state<typeof import("./SvDateTimePicker.svelte").default | null>(null);
57
+ $effect(() => {
58
+ const t = ctrl.editingCell?.editorType;
59
+ if (
60
+ (t === "list" || t === "chips" || t === "select" || t === "rich-select") &&
61
+ !DropdownEditor
62
+ )
63
+ import("./SvGridDropdown.svelte").then((m) => (DropdownEditor = m.default));
64
+ if ((t === "date" || t === "datetime" || t === "time") && !DateEditor)
65
+ import("./SvDateTimePicker.svelte").then((m) => (DateEditor = m.default));
66
+ });
67
+
68
+ const grid = $derived(ctrl.grid);
69
+ const fullRowEdit = $derived(ctrl.fullRowEdit);
70
+ const getColumnEditorOptions = $derived(ctrl.getColumnEditorOptions);
71
+ const areEditorOptionsLoading = $derived(ctrl.areEditorOptionsLoading);
72
+ const saveEditingCell = $derived(ctrl.saveEditingCell);
73
+ const updateEditingCellValue = $derived(ctrl.updateEditingCellValue);
74
+ const onEditorKeyDown = $derived(ctrl.onEditorKeyDown);
75
+ const focusOnMount = $derived(ctrl.focusOnMount);
76
+ const toggleCheckboxWithKeyboard = $derived(ctrl.toggleCheckboxWithKeyboard);
77
+
78
+ function fullRowKeydown(e: KeyboardEvent) {
79
+ if (e.key === "Enter") {
80
+ e.preventDefault();
81
+ ctrl.commitFullRowEdit();
82
+ ctrl.gridRootEl?.focus({ preventScroll: true });
83
+ } else if (e.key === "Escape") {
84
+ e.preventDefault();
85
+ ctrl.cancelFullRowEdit();
86
+ ctrl.gridRootEl?.focus({ preventScroll: true });
87
+ }
88
+ }
89
+ function optionValueOf(o: unknown): string {
90
+ return typeof o === "object" && o !== null && "value" in o
91
+ ? String((o as { value: unknown }).value)
92
+ : String(o);
93
+ }
94
+ function optionLabelOf(o: unknown): string {
95
+ return typeof o === "object" && o !== null && "label" in o
96
+ ? String((o as { label: unknown }).label)
97
+ : String(o);
98
+ }
99
+
100
+ // Build the interaction context handed to a CUSTOM cell editor registered via
101
+ // `registerCellEditor`. Maps the grid's editing lifecycle onto the uniform
102
+ // change / commit / cancel contract every registered editor speaks.
103
+ function buildRegisteredEditorContext(): CellEditorContext {
104
+ const cell = ctrl.editingCell;
105
+ return {
106
+ value: cell?.value,
107
+ rowId: cell?.rowId ?? "",
108
+ columnId: cell?.columnId ?? "",
109
+ onChange: (v: unknown) => updateEditingCellValue(v),
110
+ onCommit: (v?: unknown) => {
111
+ if (v !== undefined) updateEditingCellValue(v);
112
+ saveEditingCell();
113
+ },
114
+ onCancel: () => {
115
+ ctrl.editingCell = null;
116
+ ctrl.gridRootEl?.focus({ preventScroll: true });
117
+ },
118
+ // Tab out of an editor: commit, then step to the adjacent cell. Without
119
+ // this a registered editor's Tab walks focus out of the grid (#48) - the
120
+ // built-in editors already route through the same helper.
121
+ onCommitAndMove: (v: unknown, direction: 1 | -1) => {
122
+ if (v !== undefined) updateEditingCellValue(v);
123
+ ctrl.commitAndMoveByTab(direction === -1);
124
+ },
125
+ // Close a popover editor without committing. Same effect as cancel today;
126
+ // named separately so an editor can distinguish "dismiss my panel" from
127
+ // "abandon the edit" if that ever diverges.
128
+ onRequestClose: () => {
129
+ ctrl.editingCell = null;
130
+ ctrl.gridRootEl?.focus({ preventScroll: true });
131
+ },
132
+ inCell: true,
133
+ };
134
+ }
135
+ </script>
136
+
137
+ {#snippet chipsEditor(
138
+ opts: CellEditorOption[],
139
+ multi: boolean,
140
+ selectedArr: Array<string | number>,
141
+ optsLoading: boolean,
142
+ )}
143
+ {#if opts.length > 0}
144
+ <!-- Options-driven chips editor: defer to the custom dropdown,
145
+ which renders the selected values as chips in its trigger and
146
+ pops out a styled listbox. Identical UX to the list editor
147
+ with renderChipsInTrigger flipped on. -->
148
+ {#if DropdownEditor}
149
+ <DropdownEditor
150
+ options={opts}
151
+ loading={optsLoading}
152
+ value={ctrl.editingCell?.value}
153
+ multiple={multi}
154
+ placeholder="Pick…"
155
+ renderChipsInTrigger={true}
156
+ onChange={(next) => {
157
+ ctrl.editingCell = ctrl.editingCell
158
+ ? { ...ctrl.editingCell, value: next }
159
+ : ctrl.editingCell;
160
+ }}
161
+ onCommit={() => saveEditingCell()}
162
+ onCancel={() => {
163
+ ctrl.editingCell = null;
164
+ ctrl.gridRootEl?.focus({ preventScroll: true });
165
+ }}
166
+ />
167
+ {/if}
168
+ {:else}
169
+ <!-- Free-form chips: typed tags. Enter / comma commits a chip,
170
+ Backspace on empty input removes the last chip, blur saves. -->
171
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
172
+ <div
173
+ class="sv-grid-cell-editor sv-grid-cell-editor-chips"
174
+ role="group"
175
+ tabindex={-1}
176
+ >
177
+ <div class="sv-grid-chips-row">
178
+ {#each selectedArr as v, idx (String(v) + "_" + idx)}
179
+ <span class="sv-grid-chip sv-grid-chip-removable">
180
+ {String(v)}
181
+ <button
182
+ type="button"
183
+ class="sv-grid-chip-remove"
184
+ aria-label="Remove {String(v)}"
185
+ onmousedown={(event) => event.preventDefault()}
186
+ onclick={() => {
187
+ const next = selectedArr.filter((_, i) => i !== idx);
188
+ ctrl.editingCell = ctrl.editingCell
189
+ ? {
190
+ ...ctrl.editingCell,
191
+ value: multi ? next : (next[0] ?? null),
192
+ }
193
+ : ctrl.editingCell;
194
+ }}>×</button
195
+ >
196
+ </span>
197
+ {/each}
198
+ <input
199
+ use:focusOnMount
200
+ class="sv-grid-chip-input"
201
+ type="text"
202
+ placeholder={multi ? "Type, Enter to add" : "Type a value"}
203
+ onkeydown={(event) => {
204
+ if (event.key === "Enter" || (multi && event.key === ",")) {
205
+ event.preventDefault();
206
+ event.stopPropagation();
207
+ const input = event.currentTarget as HTMLInputElement;
208
+ const raw = input.value.trim();
209
+ if (raw) {
210
+ const next = multi ? [...selectedArr, raw] : [raw];
211
+ ctrl.editingCell = ctrl.editingCell
212
+ ? { ...ctrl.editingCell, value: multi ? next : raw }
213
+ : ctrl.editingCell;
214
+ input.value = "";
215
+ if (!multi) saveEditingCell();
216
+ }
217
+ } else if (event.key === "Escape") {
218
+ onEditorKeyDown(event);
219
+ } else if (event.key === "Backspace") {
220
+ const input = event.currentTarget as HTMLInputElement;
221
+ if (input.value === "" && selectedArr.length > 0) {
222
+ event.preventDefault();
223
+ const next = selectedArr.slice(0, -1);
224
+ ctrl.editingCell = ctrl.editingCell
225
+ ? {
226
+ ...ctrl.editingCell,
227
+ value: multi ? next : (next[0] ?? null),
228
+ }
229
+ : ctrl.editingCell;
230
+ }
231
+ }
232
+ }}
233
+ onblur={() => saveEditingCell()}
234
+ />
235
+ {#if multi}
236
+ <button
237
+ type="button"
238
+ class="sv-grid-chip-commit"
239
+ onmousedown={(event) => event.preventDefault()}
240
+ onclick={() => saveEditingCell()}
241
+ aria-label="Commit chip selection">Done</button
242
+ >
243
+ {/if}
244
+ </div>
245
+ </div>
246
+ {/if}
247
+ {/snippet}
248
+
249
+ {#if fullRow}
250
+ {@const et = column.columnDef.editorType ?? "text"}
251
+ {@const val = fullRowEdit?.draft[column.id]}
252
+ {#if et === "checkbox"}
253
+ <input
254
+ type="checkbox"
255
+ class="sv-grid-fr-editor sv-grid-fr-checkbox"
256
+ checked={Boolean(val)}
257
+ onchange={(e) =>
258
+ ctrl.setFullRowDraft(column.id, e.currentTarget.checked)}
259
+ onkeydown={fullRowKeydown}
260
+ onpointerdown={(e) => e.stopPropagation()}
261
+ onclick={(e) => e.stopPropagation()}
262
+ />
263
+ {:else if et === "list" || et === "select" || et === "rich-select"}
264
+ {@const opts = getColumnEditorOptions(column, row)}
265
+ <select
266
+ class="sv-grid-cell-editor sv-grid-fr-editor"
267
+ value={String(val ?? "")}
268
+ onchange={(e) => ctrl.setFullRowDraft(column.id, e.currentTarget.value)}
269
+ onkeydown={fullRowKeydown}
270
+ onpointerdown={(e) => e.stopPropagation()}
271
+ onclick={(e) => e.stopPropagation()}
272
+ >
273
+ {#each opts as o (optionValueOf(o))}
274
+ <option value={optionValueOf(o)}>{optionLabelOf(o)}</option>
275
+ {/each}
276
+ </select>
277
+ {:else}
278
+ {@const inputType =
279
+ et === "number"
280
+ ? "number"
281
+ : et === "date"
282
+ ? "date"
283
+ : et === "datetime"
284
+ ? "datetime-local"
285
+ : et === "time"
286
+ ? "time"
287
+ : et === "password"
288
+ ? "password"
289
+ : "text"}
290
+ <input
291
+ type={inputType}
292
+ class="sv-grid-cell-editor sv-grid-fr-editor"
293
+ value={String(val ?? "")}
294
+ oninput={(e) => ctrl.setFullRowDraft(column.id, e.currentTarget.value)}
295
+ onkeydown={fullRowKeydown}
296
+ onpointerdown={(e) => e.stopPropagation()}
297
+ onclick={(e) => e.stopPropagation()}
298
+ />
299
+ {/if}
300
+ {:else}
301
+ {#if column.columnDef.cellEditor}
302
+ <!-- Custom editor slot. The columnDef provides a snippet that
303
+ receives the editor context (value + commit + cancel) so the
304
+ consumer fully owns the in-cell UI. -->
305
+ {@const customEditor = column.columnDef
306
+ .cellEditor as unknown as import("svelte").Snippet<
307
+ [EditorContext<TData>]
308
+ >}
309
+ {@render customEditor({
310
+ cell: row.getAllCells().find((c) => c.column.id === column.id)!,
311
+ row,
312
+ column,
313
+ table: grid,
314
+ getValue: () => ctrl.editingCell?.value,
315
+ value: ctrl.editingCell?.value,
316
+ update: (next: unknown) => {
317
+ // Stage the draft without closing. Live-preview controls
318
+ // (sliders, color pickers) call this on every input tick.
319
+ ctrl.editingCell = ctrl.editingCell
320
+ ? { ...ctrl.editingCell, value: next }
321
+ : ctrl.editingCell;
322
+ },
323
+ commit: (next?: unknown) => {
324
+ // Write + close. If the caller passed a value, stage it
325
+ // first; otherwise save whatever update() last wrote.
326
+ if (next !== undefined) {
327
+ ctrl.editingCell = ctrl.editingCell
328
+ ? { ...ctrl.editingCell, value: next }
329
+ : ctrl.editingCell;
330
+ }
331
+ saveEditingCell();
332
+ },
333
+ cancel: () => {
334
+ ctrl.editingCell = null;
335
+ ctrl.gridRootEl?.focus({ preventScroll: true });
336
+ },
337
+ })}
338
+ {:else if ctrl.editingCell?.editorType === "checkbox"}
339
+ <button
340
+ type="button"
341
+ class="sv-grid-checkbox"
342
+ role="checkbox"
343
+ aria-checked={Boolean(ctrl.editingCell.value)}
344
+ aria-label="Edit checkbox value"
345
+ onclick={(event) => {
346
+ event.stopPropagation();
347
+ const nextValue = !ctrl.editingCell?.value;
348
+ ctrl.editingCell = ctrl.editingCell
349
+ ? { ...ctrl.editingCell, value: nextValue }
350
+ : ctrl.editingCell;
351
+ saveEditingCell();
352
+ }}
353
+ onkeydown={(event) =>
354
+ toggleCheckboxWithKeyboard(event, () => {
355
+ event.stopPropagation();
356
+ const nextValue = !ctrl.editingCell?.value;
357
+ ctrl.editingCell = ctrl.editingCell
358
+ ? { ...ctrl.editingCell, value: nextValue }
359
+ : ctrl.editingCell;
360
+ saveEditingCell();
361
+ })}
362
+ onblur={() => saveEditingCell()}
363
+ ></button>
364
+ {:else if ctrl.editingCell?.editorType === "list"}
365
+ {@const opts = getColumnEditorOptions(column, row)}
366
+ {@const optsLoading = areEditorOptionsLoading(column, row)}
367
+ {@const multi = column.columnDef.editorMultiple === true}
368
+ {#if DropdownEditor}
369
+ <DropdownEditor
370
+ options={opts}
371
+ loading={optsLoading}
372
+ value={ctrl.editingCell?.value}
373
+ multiple={multi}
374
+ placeholder="Select…"
375
+ onChange={(next) => {
376
+ ctrl.editingCell = ctrl.editingCell
377
+ ? { ...ctrl.editingCell, value: next }
378
+ : ctrl.editingCell;
379
+ }}
380
+ onCommit={() => saveEditingCell()}
381
+ onCancel={() => {
382
+ ctrl.editingCell = null;
383
+ ctrl.gridRootEl?.focus({ preventScroll: true });
384
+ }}
385
+ />
386
+ {/if}
387
+ {:else if ctrl.editingCell?.editorType === "chips"}
388
+ {@const opts = getColumnEditorOptions(column, row)}
389
+ {@const optsLoading = areEditorOptionsLoading(column, row)}
390
+ {@const multi = column.columnDef.editorMultiple === true}
391
+ {@const selectedArr = toValueArray(ctrl.editingCell?.value)}
392
+ {@render chipsEditor(opts, multi, selectedArr, optsLoading)}
393
+ {:else if ctrl.editingCell?.editorType === "rating"}
394
+ {@const ratingVal = Math.max(
395
+ 0,
396
+ Math.min(5, Math.round(Number(ctrl.editingCell?.value) || 0)),
397
+ )}
398
+ <span class="sv-grid-rating-editor" role="radiogroup" aria-label="Rating">
399
+ {#each [1, 2, 3, 4, 5] as n (n)}
400
+ <button
401
+ type="button"
402
+ role="radio"
403
+ aria-checked={ratingVal >= n}
404
+ aria-label={`${n} ${n === 1 ? "star" : "stars"}`}
405
+ class={`sv-grid-rating-star ${ratingVal >= n ? "sv-grid-rating-star-on" : ""}`}
406
+ onmousedown={(event) => event.preventDefault()}
407
+ onclick={(event) => {
408
+ event.stopPropagation();
409
+ ctrl.editingCell = ctrl.editingCell
410
+ ? { ...ctrl.editingCell, value: n }
411
+ : ctrl.editingCell;
412
+ saveEditingCell();
413
+ }}
414
+ onkeydown={onEditorKeyDown}>★</button
415
+ >
416
+ {/each}
417
+ <button
418
+ type="button"
419
+ aria-label="Clear rating"
420
+ class="sv-grid-rating-clear"
421
+ onmousedown={(event) => event.preventDefault()}
422
+ onclick={(event) => {
423
+ event.stopPropagation();
424
+ ctrl.editingCell = ctrl.editingCell
425
+ ? { ...ctrl.editingCell, value: 0 }
426
+ : ctrl.editingCell;
427
+ saveEditingCell();
428
+ }}>×</button
429
+ >
430
+ </span>
431
+ {:else if ctrl.editingCell?.editorType === "select"}
432
+ <!-- Custom dropdown: opens a themed popover identical in feel to
433
+ the existing 'list' editor (single-select, no typeahead). -->
434
+ {@const selectOpts = getColumnEditorOptions(column, row)}
435
+ {@const optsLoading = areEditorOptionsLoading(column, row)}
436
+ {#if DropdownEditor}
437
+ <DropdownEditor
438
+ options={selectOpts}
439
+ loading={optsLoading}
440
+ value={ctrl.editingCell?.value}
441
+ multiple={false}
442
+ placeholder="Select…"
443
+ onChange={(next) => {
444
+ ctrl.editingCell = ctrl.editingCell
445
+ ? { ...ctrl.editingCell, value: next }
446
+ : ctrl.editingCell;
447
+ }}
448
+ onCommit={() => saveEditingCell()}
449
+ onCancel={() => {
450
+ ctrl.editingCell = null;
451
+ ctrl.gridRootEl?.focus({ preventScroll: true });
452
+ }}
453
+ />
454
+ {/if}
455
+ {:else if ctrl.editingCell?.editorType === "rich-select"}
456
+ <!-- Searchable combobox: same popover as 'select' with a
457
+ typeahead filter input baked in at the top. -->
458
+ {@const richOpts = getColumnEditorOptions(column, row)}
459
+ {@const optsLoading = areEditorOptionsLoading(column, row)}
460
+ {#if DropdownEditor}
461
+ <DropdownEditor
462
+ options={richOpts}
463
+ loading={optsLoading}
464
+ value={ctrl.editingCell?.value}
465
+ multiple={false}
466
+ searchable={true}
467
+ placeholder="Search…"
468
+ onChange={(next) => {
469
+ ctrl.editingCell = ctrl.editingCell
470
+ ? { ...ctrl.editingCell, value: next }
471
+ : ctrl.editingCell;
472
+ }}
473
+ onCommit={() => saveEditingCell()}
474
+ onCancel={() => {
475
+ ctrl.editingCell = null;
476
+ ctrl.gridRootEl?.focus({ preventScroll: true });
477
+ }}
478
+ />
479
+ {/if}
480
+ {:else if ctrl.editingCell?.editorType === "textarea"}
481
+ <!-- Multi-line editor. Commits on Tab, Ctrl/Cmd+Enter, or blur.
482
+ Plain Enter inserts a newline (the whole point of textarea).
483
+ Esc cancels. -->
484
+ <textarea
485
+ use:focusOnMount
486
+ class="sv-grid-cell-editor sv-grid-cell-editor-textarea"
487
+ rows="4"
488
+ value={String(ctrl.editingCell?.value ?? "")}
489
+ onpointerdown={(event) => event.stopPropagation()}
490
+ oninput={(event) =>
491
+ updateEditingCellValue(
492
+ (event.currentTarget as HTMLTextAreaElement).value,
493
+ )}
494
+ onkeydown={(event) => {
495
+ event.stopPropagation();
496
+ if (event.key === "Escape") {
497
+ event.preventDefault();
498
+ ctrl.editingCell = null;
499
+ ctrl.gridRootEl?.focus({ preventScroll: true });
500
+ return;
501
+ }
502
+ // Tab and Ctrl/Cmd+Enter both commit. Plain Enter inserts a newline.
503
+ // Tab goes through the shared helper so it advances the active cell
504
+ // like every other editor does (#48).
505
+ if (event.key === "Tab") {
506
+ event.preventDefault();
507
+ ctrl.commitAndMoveByTab(event.shiftKey);
508
+ return;
509
+ }
510
+ if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
511
+ event.preventDefault();
512
+ saveEditingCell();
513
+ ctrl.gridRootEl?.focus({ preventScroll: true });
514
+ }
515
+ }}
516
+ onblur={() => saveEditingCell()}
517
+ ></textarea>
518
+ {:else if ctrl.editingCell?.editorType === "autocomplete"}
519
+ <!-- Free-text autocomplete: a text input with a live-filtered
520
+ suggestion list. Typing edits the value freely; clicking a
521
+ suggestion (or blur) commits. Accepts values not in the list. -->
522
+ {@const acOpts = getColumnEditorOptions(column, row)}
523
+ {@const acText = String(ctrl.editingCell?.value ?? "")}
524
+ {@const acFiltered = acText.trim()
525
+ ? acOpts.filter((o) =>
526
+ String(o.label).toLowerCase().includes(acText.toLowerCase()),
527
+ )
528
+ : acOpts}
529
+ <div class="sv-grid-autocomplete">
530
+ <input
531
+ use:focusOnMount
532
+ class="sv-grid-cell-editor sv-grid-cell-editor-autocomplete"
533
+ type="text"
534
+ value={acText}
535
+ onpointerdown={(event) => event.stopPropagation()}
536
+ oninput={(event) =>
537
+ updateEditingCellValue(
538
+ (event.currentTarget as HTMLInputElement).value,
539
+ )}
540
+ onblur={() => saveEditingCell()}
541
+ onkeydown={onEditorKeyDown}
542
+ />
543
+ {#if acFiltered.length > 0}
544
+ <div class="sv-grid-autocomplete-list" role="listbox">
545
+ {#each acFiltered.slice(0, 50) as opt (opt.value)}
546
+ <button
547
+ type="button"
548
+ class="sv-grid-autocomplete-option"
549
+ role="option"
550
+ aria-selected={String(opt.value) === acText}
551
+ onmousedown={(event) => {
552
+ event.preventDefault();
553
+ ctrl.editingCell = ctrl.editingCell
554
+ ? { ...ctrl.editingCell, value: opt.value }
555
+ : ctrl.editingCell;
556
+ saveEditingCell();
557
+ }}>{opt.label}</button
558
+ >
559
+ {/each}
560
+ </div>
561
+ {/if}
562
+ </div>
563
+ {:else if ctrl.editingCell?.editorType === "date"}
564
+ <!-- Rich date editor: SvCalendar popover over a formatted input. Opts
565
+ out to the native <input type="date"> via editorType 'date-native'. -->
566
+ {#if DateEditor}
567
+ <DateEditor
568
+ value={ctrl.editingCell?.value as string | number | Date | null}
569
+ formatString="yyyy-MM-dd"
570
+ dropDownDisplayMode="calendar"
571
+ autoOpen
572
+ block
573
+ onChange={(d) => updateEditingCellValue(d)}
574
+ onCommit={() => saveEditingCell()}
575
+ onCancel={() => {
576
+ ctrl.editingCell = null;
577
+ ctrl.gridRootEl?.focus({ preventScroll: true });
578
+ }}
579
+ />
580
+ {/if}
581
+ {:else if ctrl.editingCell?.editorType === "datetime"}
582
+ {#if DateEditor}
583
+ <DateEditor
584
+ value={ctrl.editingCell?.value as string | number | Date | null}
585
+ formatString="yyyy-MM-dd HH:mm"
586
+ dropDownDisplayMode="both"
587
+ autoOpen
588
+ block
589
+ onChange={(d) => updateEditingCellValue(d)}
590
+ onCommit={() => saveEditingCell()}
591
+ onCancel={() => {
592
+ ctrl.editingCell = null;
593
+ ctrl.gridRootEl?.focus({ preventScroll: true });
594
+ }}
595
+ />
596
+ {/if}
597
+ {:else if ctrl.editingCell?.editorType === "time"}
598
+ <!-- Rich time editor: SvTimePicker dial. Stores the 'HH:MM' string the
599
+ `time` parser expects; opts out via editorType 'time-native'. -->
600
+ {#if DateEditor}
601
+ <DateEditor
602
+ value={timeStringToDate(ctrl.editingCell?.value)}
603
+ formatString="HH:mm"
604
+ dropDownDisplayMode="time"
605
+ autoOpen
606
+ block
607
+ onChange={(d) => updateEditingCellValue(dateToTimeString(d))}
608
+ onCommit={() => saveEditingCell()}
609
+ onCancel={() => {
610
+ ctrl.editingCell = null;
611
+ ctrl.gridRootEl?.focus({ preventScroll: true });
612
+ }}
613
+ />
614
+ {/if}
615
+ {:else if ctrl.editingCell?.editorType === "color"}
616
+ <!-- Native <input type="color"> opens its picker in a separate OS
617
+ overlay; once the picker closes, focus stays on the input so
618
+ `blur` never fires on its own. Commit on `change` (which fires
619
+ exactly once when the picker is dismissed) so the chosen color
620
+ is saved without needing the user to click elsewhere. -->
621
+ <input
622
+ use:focusOnMount
623
+ class={getEditorClass("color")}
624
+ type="color"
625
+ value={getEditableInputValue("color", ctrl.editingCell?.value)}
626
+ oninput={(event) =>
627
+ updateEditingCellValue(
628
+ (event.currentTarget as HTMLInputElement).value,
629
+ )}
630
+ onchange={(event) => {
631
+ updateEditingCellValue(
632
+ (event.currentTarget as HTMLInputElement).value,
633
+ );
634
+ saveEditingCell();
635
+ }}
636
+ onblur={() => saveEditingCell()}
637
+ onkeydown={onEditorKeyDown}
638
+ />
639
+ {:else if hasCellEditor(String(ctrl.editingCell?.editorType ?? ""))}
640
+ <!-- Custom editor registered via `registerCellEditor(type, Component)`:
641
+ mount it and hand it the uniform change / commit / cancel context. -->
642
+ {@const _reg = getCellEditor(String(ctrl.editingCell?.editorType))!}
643
+ {@const CustomCellEditor = _reg.component}
644
+ <CustomCellEditor {...resolveEditorProps(_reg, buildRegisteredEditorContext())} />
645
+ {:else}
646
+ <input
647
+ use:focusOnMount
648
+ class={getEditorClass(ctrl.editingCell?.editorType ?? "text")}
649
+ type={getEditorInputType(ctrl.editingCell?.editorType ?? "text")}
650
+ value={getEditableInputValue(
651
+ ctrl.editingCell?.editorType ?? "text",
652
+ ctrl.editingCell?.value,
653
+ )}
654
+ oninput={(event) =>
655
+ updateEditingCellValue(
656
+ (event.currentTarget as HTMLInputElement).value,
657
+ )}
658
+ onblur={() => saveEditingCell()}
659
+ onkeydown={onEditorKeyDown}
660
+ />
661
+ {/if}
662
+ {/if}