@svgrid/grid 2.6.8 → 2.6.10

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 (377) 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.css +2856 -2856
  22. package/dist/SvGrid.svelte +2956 -2956
  23. package/dist/SvGridCellEditor.svelte +662 -662
  24. package/dist/SvGridChart.svelte +1716 -1716
  25. package/dist/SvGridChartPanel.svelte +485 -485
  26. package/dist/SvGridChartView.svelte +70 -70
  27. package/dist/SvGridDropdown.svelte +728 -728
  28. package/dist/SvGridSelect.svelte +266 -266
  29. package/dist/SvGroupCell.svelte +116 -116
  30. package/dist/SvListBox.svelte +326 -326
  31. package/dist/SvMaskedInput.svelte +122 -122
  32. package/dist/SvMenu.svelte +124 -124
  33. package/dist/SvMenuList.svelte +146 -146
  34. package/dist/SvMultiSelect.svelte +289 -289
  35. package/dist/SvNumberInput.svelte +168 -168
  36. package/dist/SvOtpInput.svelte +158 -158
  37. package/dist/SvPasswordInput.svelte +151 -151
  38. package/dist/SvPhoneInput.svelte +133 -133
  39. package/dist/SvPopover.svelte +197 -197
  40. package/dist/SvProgress.svelte +116 -116
  41. package/dist/SvRadioGroup.svelte +107 -107
  42. package/dist/SvRating.svelte +112 -112
  43. package/dist/SvResult.svelte +73 -73
  44. package/dist/SvRichText.svelte +211 -211
  45. package/dist/SvRowGroupPanel.svelte +170 -170
  46. package/dist/SvScrollArea.svelte +61 -61
  47. package/dist/SvSlider.svelte +203 -203
  48. package/dist/SvSwitchButton.svelte +108 -108
  49. package/dist/SvTagsInput.svelte +115 -115
  50. package/dist/SvTextInput.svelte +147 -147
  51. package/dist/SvTimePicker.svelte +245 -245
  52. package/dist/SvToaster.svelte +159 -159
  53. package/dist/SvToggleButton.svelte +85 -85
  54. package/dist/SvTooltip.svelte +161 -161
  55. package/dist/SvTour.svelte +208 -208
  56. package/dist/SvTree.svelte +444 -444
  57. package/dist/SvTreeSelect.svelte +235 -235
  58. package/dist/cdn/{GridMenus-D3JbtKWp.js → GridMenus-BLajq_RP.js} +2 -2
  59. package/dist/cdn/{GridMenus-g9aHrUhs.js → GridMenus-CPdy5dxw.js} +2 -2
  60. package/dist/cdn/{SvDateTimePicker-DSUhIta8.js → SvDateTimePicker-CHnUkWcH.js} +2 -2
  61. package/dist/cdn/{SvDateTimePicker-h9kPyszT.js → SvDateTimePicker-CRQH_U7E.js} +2 -2
  62. package/dist/cdn/{SvGridCellEditor-DkyQO6FV.js → SvGridCellEditor-BGUCzuPB.js} +1 -1
  63. package/dist/cdn/{SvGridCellEditor-JpJSRhDx.js → SvGridCellEditor-G8IMWIws.js} +1 -1
  64. package/dist/cdn/{SvGridChart-CwhFz7GV.js → SvGridChart-BEJmNNx9.js} +1 -1
  65. package/dist/cdn/{SvGridChart-Bs2GIR2Q.js → SvGridChart-BwVos976.js} +1 -1
  66. package/dist/cdn/{SvGridChartPanel-1WXuStzM.js → SvGridChartPanel-BOknOkrP.js} +1 -1
  67. package/dist/cdn/{SvGridChartPanel-e5_nqNP9.js → SvGridChartPanel-D2PjII4O.js} +1 -1
  68. package/dist/cdn/{SvGridChartView-SmPW10dI.js → SvGridChartView-00LPUHL1.js} +1 -1
  69. package/dist/cdn/{SvGridChartView-eSPuJE6g.js → SvGridChartView-BhUEJ5ki.js} +1 -1
  70. package/dist/cdn/{SvGridDropdown-B1ZcLpgs.js → SvGridDropdown-D0VdjeR8.js} +1 -1
  71. package/dist/cdn/{SvGridDropdown-CtdbHcIS.js → SvGridDropdown-D13MtJ2j.js} +1 -1
  72. package/dist/cdn/{src-cKs_0jXV.js → src-CKpl94Cx.js} +26 -26
  73. package/dist/cdn/{src-B76QPix7.js → src-ogpR-lHu.js} +27 -27
  74. package/dist/cdn/svgrid.js +5 -5
  75. package/dist/cdn/svgrid.svelte-external.js +5 -5
  76. package/dist/chart-export.js +8 -8
  77. package/package.json +11 -11
  78. package/src/FlexRender.svelte +96 -96
  79. package/src/GridFooter.svelte +178 -178
  80. package/src/GridMenus.svelte +705 -705
  81. package/src/SvAutoComplete.svelte +165 -165
  82. package/src/SvAvatar.svelte +75 -75
  83. package/src/SvCalendar.svelte +503 -503
  84. package/src/SvCalendar.test.ts +226 -226
  85. package/src/SvCarousel.svelte +141 -141
  86. package/src/SvCheckBox.svelte +102 -102
  87. package/src/SvCircularProgress.svelte +109 -109
  88. package/src/SvColorInput.svelte +181 -181
  89. package/src/SvComboBox.svelte +275 -275
  90. package/src/SvContextMenu.svelte +116 -116
  91. package/src/SvCountryInput.svelte +163 -163
  92. package/src/SvDrawer.svelte +254 -254
  93. package/src/SvDropDownList.svelte +374 -374
  94. package/src/SvDurationInput.svelte +126 -126
  95. package/src/SvField.svelte +293 -293
  96. package/src/SvForm.svelte +437 -437
  97. package/src/SvForm.test.ts +411 -411
  98. package/src/SvGrid.controller.svelte.ts +3898 -3898
  99. package/src/SvGrid.css +2856 -2856
  100. package/src/SvGrid.svelte +2956 -2956
  101. package/src/SvGrid.types.ts +1769 -1769
  102. package/src/SvGridCellEditor.svelte +662 -662
  103. package/src/SvGridChart.svelte +1716 -1716
  104. package/src/SvGridChartPanel.svelte +485 -485
  105. package/src/SvGridChartView.svelte +70 -70
  106. package/src/SvGridDropdown.svelte +728 -728
  107. package/src/SvGridSelect.svelte +266 -266
  108. package/src/SvGroupCell.svelte +116 -116
  109. package/src/SvListBox.svelte +326 -326
  110. package/src/SvMaskedInput.svelte +122 -122
  111. package/src/SvMenu.svelte +124 -124
  112. package/src/SvMenu.test.ts +97 -97
  113. package/src/SvMenuList.svelte +146 -146
  114. package/src/SvMultiSelect.svelte +289 -289
  115. package/src/SvNumberInput.svelte +168 -168
  116. package/src/SvOtpInput.svelte +158 -158
  117. package/src/SvPasswordInput.svelte +151 -151
  118. package/src/SvPhoneInput.svelte +133 -133
  119. package/src/SvPopover.svelte +197 -197
  120. package/src/SvProgress.svelte +116 -116
  121. package/src/SvRadioGroup.svelte +107 -107
  122. package/src/SvRating.svelte +112 -112
  123. package/src/SvResult.svelte +73 -73
  124. package/src/SvRichText.svelte +211 -211
  125. package/src/SvRowGroupPanel.svelte +170 -170
  126. package/src/SvScrollArea.svelte +61 -61
  127. package/src/SvSlider.svelte +203 -203
  128. package/src/SvSwitchButton.svelte +108 -108
  129. package/src/SvTagsInput.svelte +115 -115
  130. package/src/SvTextInput.svelte +147 -147
  131. package/src/SvTimePicker.svelte +245 -245
  132. package/src/SvToaster.svelte +159 -159
  133. package/src/SvToaster.test.ts +95 -95
  134. package/src/SvToggleButton.svelte +85 -85
  135. package/src/SvTooltip.svelte +161 -161
  136. package/src/SvTour.svelte +208 -208
  137. package/src/SvTree.svelte +444 -444
  138. package/src/SvTreeSelect.svelte +235 -235
  139. package/src/a11y/dismissable.test.ts +119 -119
  140. package/src/a11y/dismissable.ts +114 -114
  141. package/src/a11y.contract.test.ts +49 -49
  142. package/src/a11y.test.ts +59 -59
  143. package/src/a11y.ts +61 -61
  144. package/src/ai.test.ts +502 -502
  145. package/src/ai.ts +1391 -1391
  146. package/src/build-api.coverage.test.ts +633 -633
  147. package/src/build-api.ts +846 -846
  148. package/src/builtin-editors.grid.test.ts +83 -83
  149. package/src/cell-formatting.ts +169 -169
  150. package/src/cell-render.test.ts +513 -513
  151. package/src/cell-render.ts +496 -496
  152. package/src/cell-values.ts +118 -118
  153. package/src/chart-export.ts +201 -201
  154. package/src/chart-view.svelte.ts +36 -36
  155. package/src/chart.ts +2295 -2295
  156. package/src/collaboration.test.ts +104 -104
  157. package/src/collaboration.ts +167 -167
  158. package/src/core.performance.test.ts +30 -30
  159. package/src/core.ts +1261 -1261
  160. package/src/createAutocomplete.svelte.ts +132 -132
  161. package/src/createCombobox.svelte.ts +191 -191
  162. package/src/createCountryInput.svelte.ts +157 -157
  163. package/src/createDropdownList.svelte.ts +168 -168
  164. package/src/createForm.svelte.ts +386 -386
  165. package/src/createGrid.svelte.ts +42 -42
  166. package/src/createGrid.test.ts +10 -10
  167. package/src/createGridState.svelte.ts +17 -17
  168. package/src/createListbox.svelte.ts +250 -250
  169. package/src/createMenu.svelte.ts +224 -224
  170. package/src/createPopoverSelect.svelte.ts +213 -213
  171. package/src/createSlider.svelte.ts +191 -191
  172. package/src/createTooltip.svelte.ts +144 -144
  173. package/src/createTree.svelte.ts +319 -319
  174. package/src/editing.test.ts +949 -949
  175. package/src/editing.ts +606 -606
  176. package/src/editor-contract.ts +170 -170
  177. package/src/editor-registry.grid.test.ts +144 -144
  178. package/src/editor-registry.ts +122 -122
  179. package/src/export-data-api.test.ts +126 -126
  180. package/src/export-format.test.ts +107 -107
  181. package/src/export-format.ts +601 -601
  182. package/src/filter-operators.ts +160 -160
  183. package/src/flex-render.ts +3 -3
  184. package/src/form-field.ts +127 -127
  185. package/src/group-display.test.ts +167 -167
  186. package/src/group-display.ts +200 -200
  187. package/src/headless.ts +80 -80
  188. package/src/index.ts +754 -754
  189. package/src/js-scroller.svelte.ts +173 -173
  190. package/src/keyboard-handlers.ts +270 -270
  191. package/src/keyboard.test.ts +59 -59
  192. package/src/keyboard.ts +97 -97
  193. package/src/list-nav.test.ts +49 -49
  194. package/src/list-nav.ts +29 -29
  195. package/src/list-option.test.ts +56 -56
  196. package/src/list-option.ts +172 -172
  197. package/src/menus.ts +567 -567
  198. package/src/merge-objects.ts +48 -48
  199. package/src/overlays.test.ts +90 -90
  200. package/src/render-component.ts +28 -28
  201. package/src/row-drag-touch.ts +211 -211
  202. package/src/row-drag.test.ts +353 -353
  203. package/src/row-drag.ts +415 -415
  204. package/src/row-resize.ts +210 -210
  205. package/src/scheduler-model.test.ts +562 -562
  206. package/src/scheduler-model.ts +872 -872
  207. package/src/selection.test.ts +754 -754
  208. package/src/selection.ts +491 -491
  209. package/src/server-data-source.test.ts +383 -383
  210. package/src/server-data-source.ts +469 -469
  211. package/src/sparkline.test.ts +68 -68
  212. package/src/sparkline.ts +169 -169
  213. package/src/spreadsheet.test.ts +488 -488
  214. package/src/spreadsheet.ts +312 -312
  215. package/src/static-functions.ts +11 -11
  216. package/src/subscribe.ts +38 -38
  217. package/src/svgrid-wrapper.types.ts +558 -558
  218. package/src/svgrid.async-editor-options.test.ts +273 -273
  219. package/src/svgrid.auto-row-height.test.ts +204 -204
  220. package/src/svgrid.behavior.test.ts +705 -705
  221. package/src/svgrid.charting.test.ts +534 -534
  222. package/src/svgrid.comments-autocomplete.test.ts +127 -127
  223. package/src/svgrid.context-menu.test.ts +147 -147
  224. package/src/svgrid.features.test.ts +157 -157
  225. package/src/svgrid.filter-depth.test.ts +163 -163
  226. package/src/svgrid.filter-menu-listbox.svelte.test.ts +331 -331
  227. package/src/svgrid.filter-menu-scroll.test.ts +112 -112
  228. package/src/svgrid.grand-total.test.ts +188 -188
  229. package/src/svgrid.group-display-mode.test.ts +171 -171
  230. package/src/svgrid.group-footers.test.ts +121 -121
  231. package/src/svgrid.group-pagination.test.ts +153 -153
  232. package/src/svgrid.new-features.wrapper.test.ts +251 -251
  233. package/src/svgrid.tree-data.test.ts +186 -186
  234. package/src/svgrid.wrapper.test.ts +63 -63
  235. package/src/svgriddropdown.async-panel.svelte.test.ts +195 -195
  236. package/src/test-setup.ts +62 -62
  237. package/src/themes/index.ts +286 -286
  238. package/src/toast-store.svelte.ts +246 -246
  239. package/src/toast-store.test.ts +147 -147
  240. package/src/tree-row-model.test.ts +168 -168
  241. package/src/ui-buttons.test.ts +144 -144
  242. package/src/ui-inputs.test.ts +118 -118
  243. package/src/ui-localization.test.ts +113 -113
  244. package/src/ui-range.test.ts +70 -70
  245. package/src/ui-selection.test.ts +155 -155
  246. package/src/ui-tier1.test.ts +142 -142
  247. package/src/virtual.test.ts +88 -88
  248. package/src/virtualization/column-virtualizer.test.ts +27 -27
  249. package/src/virtualization/column-virtualizer.ts +30 -30
  250. package/src/virtualization/svelte-virtualizer.svelte.ts +26 -26
  251. package/src/virtualization/types.ts +30 -30
  252. package/src/virtualization/virtualizer.test.ts +47 -47
  253. package/src/virtualization/virtualizer.ts +322 -322
  254. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +0 -1
  255. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +0 -178
  256. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +0 -3843
  257. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +0 -1
  258. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +0 -23
  259. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +0 -1
  260. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +0 -1925
  261. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +0 -1
  262. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +0 -206
  263. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +0 -1
  264. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +0 -20
  265. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +0 -1
  266. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +0 -264
  267. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +0 -1
  268. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +0 -698
  269. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +0 -1
  270. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +0 -3
  271. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +0 -135
  272. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +0 -1
  273. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +0 -57
  274. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +0 -1
  275. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +0 -2
  276. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +0 -46691
  277. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +0 -1
  278. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +0 -239
  279. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +0 -1
  280. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +0 -2
  281. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +0 -6
  282. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +0 -1
  283. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +0 -7
  284. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +0 -6
  285. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +0 -1
  286. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +0 -7
  287. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +0 -1
  288. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +0 -7
  289. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +0 -1
  290. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +0 -7
  291. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +0 -1
  292. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +0 -6
  293. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +0 -85
  294. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +0 -1
  295. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +0 -561
  296. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +0 -1
  297. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +0 -26
  298. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +0 -1
  299. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +0 -124
  300. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +0 -1
  301. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +0 -2
  302. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +0 -91
  303. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +0 -1
  304. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +0 -242
  305. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +0 -1
  306. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +0 -497
  307. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +0 -1
  308. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +0 -4929
  309. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +0 -1
  310. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +0 -192
  311. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +0 -1
  312. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +0 -10
  313. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +0 -1
  314. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +0 -140
  315. package/dist/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js.map +0 -1
  316. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/_svelte_metadata.json +0 -1
  317. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/_metadata.json +0 -178
  318. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js +0 -3843
  319. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/attachments-qzRy9DX4.js.map +0 -1
  320. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js +0 -23
  321. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/constants-RLNOXCpz.js.map +0 -1
  322. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js +0 -1925
  323. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/dev-DPd12uEU.js.map +0 -1
  324. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js +0 -206
  325. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/events-CDC4DKuQ.js.map +0 -1
  326. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js +0 -20
  327. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/flags-BD-lYX7s.js.map +0 -1
  328. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js +0 -264
  329. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/hydration-D3UBU2t8.js.map +0 -1
  330. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js +0 -698
  331. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/legacy-client-B0ZUlbSQ.js.map +0 -1
  332. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/package.json +0 -3
  333. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js +0 -135
  334. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte.js.map +0 -1
  335. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js +0 -57
  336. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_animate.js.map +0 -1
  337. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_attachments.js +0 -2
  338. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js +0 -46691
  339. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_compiler.js.map +0 -1
  340. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js +0 -239
  341. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_easing.js.map +0 -1
  342. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_events.js +0 -2
  343. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js +0 -6
  344. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal.js.map +0 -1
  345. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_client.js +0 -7
  346. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js +0 -6
  347. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_disclose-version.js.map +0 -1
  348. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js +0 -7
  349. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_async.js.map +0 -1
  350. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js +0 -7
  351. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_legacy.js.map +0 -1
  352. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js +0 -7
  353. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_flags_tracing.js.map +0 -1
  354. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_internal_server.js +0 -6
  355. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js +0 -85
  356. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_legacy.js.map +0 -1
  357. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js +0 -561
  358. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_motion.js.map +0 -1
  359. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js +0 -26
  360. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity.js.map +0 -1
  361. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js +0 -124
  362. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_reactivity_window.js.map +0 -1
  363. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_server.js +0 -2
  364. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js +0 -91
  365. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_store.js.map +0 -1
  366. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js +0 -242
  367. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/svelte_transition.js.map +0 -1
  368. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js +0 -497
  369. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-lObbumRX.js.map +0 -1
  370. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js +0 -4929
  371. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/utils-mR9mAWyK.js.map +0 -1
  372. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js +0 -192
  373. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/validate-CezNmRkM.js.map +0 -1
  374. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js +0 -10
  375. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/version-BHHo0WE-.js.map +0 -1
  376. package/src/node_modules/.vite/vitest/67d8ed22ed986c5e2e948f64d892f30be166cc36/deps___vitest__/warnings-yiExAB06.js +0 -140
  377. 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}