@nu-grid/nuxt 0.1.1

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 (348) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +261 -0
  3. package/dist/module.d.mts +13 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +52 -0
  6. package/dist/runtime/cell-types/action-menu/ActionMenuRenderer.d.vue.ts +12 -0
  7. package/dist/runtime/cell-types/action-menu/ActionMenuRenderer.vue +123 -0
  8. package/dist/runtime/cell-types/action-menu/ActionMenuRenderer.vue.d.ts +12 -0
  9. package/dist/runtime/cell-types/action-menu/index.d.ts +8 -0
  10. package/dist/runtime/cell-types/action-menu/index.js +28 -0
  11. package/dist/runtime/cell-types/boolean/BooleanEditor.d.vue.ts +15 -0
  12. package/dist/runtime/cell-types/boolean/BooleanEditor.vue +32 -0
  13. package/dist/runtime/cell-types/boolean/BooleanEditor.vue.d.ts +15 -0
  14. package/dist/runtime/cell-types/boolean/BooleanFilter.d.vue.ts +7 -0
  15. package/dist/runtime/cell-types/boolean/BooleanFilter.vue +42 -0
  16. package/dist/runtime/cell-types/boolean/BooleanFilter.vue.d.ts +7 -0
  17. package/dist/runtime/cell-types/boolean/BooleanRenderer.d.vue.ts +13 -0
  18. package/dist/runtime/cell-types/boolean/BooleanRenderer.vue +23 -0
  19. package/dist/runtime/cell-types/boolean/BooleanRenderer.vue.d.ts +13 -0
  20. package/dist/runtime/cell-types/boolean/index.d.ts +8 -0
  21. package/dist/runtime/cell-types/boolean/index.js +31 -0
  22. package/dist/runtime/cell-types/currency/CurrencyEditor.d.vue.ts +15 -0
  23. package/dist/runtime/cell-types/currency/CurrencyEditor.vue +40 -0
  24. package/dist/runtime/cell-types/currency/CurrencyEditor.vue.d.ts +15 -0
  25. package/dist/runtime/cell-types/currency/CurrencyFilter.d.vue.ts +7 -0
  26. package/dist/runtime/cell-types/currency/CurrencyFilter.vue +76 -0
  27. package/dist/runtime/cell-types/currency/CurrencyFilter.vue.d.ts +7 -0
  28. package/dist/runtime/cell-types/currency/index.d.ts +6 -0
  29. package/dist/runtime/cell-types/currency/index.js +42 -0
  30. package/dist/runtime/cell-types/date/DateEditor.d.vue.ts +15 -0
  31. package/dist/runtime/cell-types/date/DateEditor.vue +42 -0
  32. package/dist/runtime/cell-types/date/DateEditor.vue.d.ts +15 -0
  33. package/dist/runtime/cell-types/date/DateFilter.d.vue.ts +7 -0
  34. package/dist/runtime/cell-types/date/DateFilter.vue +58 -0
  35. package/dist/runtime/cell-types/date/DateFilter.vue.d.ts +7 -0
  36. package/dist/runtime/cell-types/date/index.d.ts +6 -0
  37. package/dist/runtime/cell-types/date/index.js +13 -0
  38. package/dist/runtime/cell-types/index.d.ts +17 -0
  39. package/dist/runtime/cell-types/index.js +34 -0
  40. package/dist/runtime/cell-types/lookup/LookupEditor.d.vue.ts +15 -0
  41. package/dist/runtime/cell-types/lookup/LookupEditor.vue +291 -0
  42. package/dist/runtime/cell-types/lookup/LookupEditor.vue.d.ts +15 -0
  43. package/dist/runtime/cell-types/lookup/LookupRenderer.d.vue.ts +8 -0
  44. package/dist/runtime/cell-types/lookup/LookupRenderer.vue +43 -0
  45. package/dist/runtime/cell-types/lookup/LookupRenderer.vue.d.ts +8 -0
  46. package/dist/runtime/cell-types/lookup/index.d.ts +36 -0
  47. package/dist/runtime/cell-types/lookup/index.js +50 -0
  48. package/dist/runtime/cell-types/number/NumberEditor.d.vue.ts +15 -0
  49. package/dist/runtime/cell-types/number/NumberEditor.vue +34 -0
  50. package/dist/runtime/cell-types/number/NumberEditor.vue.d.ts +15 -0
  51. package/dist/runtime/cell-types/number/NumberFilter.d.vue.ts +7 -0
  52. package/dist/runtime/cell-types/number/NumberFilter.vue +66 -0
  53. package/dist/runtime/cell-types/number/NumberFilter.vue.d.ts +7 -0
  54. package/dist/runtime/cell-types/number/index.d.ts +6 -0
  55. package/dist/runtime/cell-types/number/index.js +13 -0
  56. package/dist/runtime/cell-types/rating/RatingEditor.d.vue.ts +15 -0
  57. package/dist/runtime/cell-types/rating/RatingEditor.vue +219 -0
  58. package/dist/runtime/cell-types/rating/RatingEditor.vue.d.ts +15 -0
  59. package/dist/runtime/cell-types/rating/RatingFilter.d.vue.ts +7 -0
  60. package/dist/runtime/cell-types/rating/RatingFilter.vue +74 -0
  61. package/dist/runtime/cell-types/rating/RatingFilter.vue.d.ts +7 -0
  62. package/dist/runtime/cell-types/rating/RatingRenderer.d.vue.ts +10 -0
  63. package/dist/runtime/cell-types/rating/RatingRenderer.vue +75 -0
  64. package/dist/runtime/cell-types/rating/RatingRenderer.vue.d.ts +10 -0
  65. package/dist/runtime/cell-types/rating/index.d.ts +6 -0
  66. package/dist/runtime/cell-types/rating/index.js +67 -0
  67. package/dist/runtime/cell-types/selection/SelectionEditor.d.vue.ts +15 -0
  68. package/dist/runtime/cell-types/selection/SelectionEditor.vue +42 -0
  69. package/dist/runtime/cell-types/selection/SelectionEditor.vue.d.ts +15 -0
  70. package/dist/runtime/cell-types/selection/SelectionRenderer.d.vue.ts +14 -0
  71. package/dist/runtime/cell-types/selection/SelectionRenderer.vue +25 -0
  72. package/dist/runtime/cell-types/selection/SelectionRenderer.vue.d.ts +14 -0
  73. package/dist/runtime/cell-types/selection/index.d.ts +8 -0
  74. package/dist/runtime/cell-types/selection/index.js +36 -0
  75. package/dist/runtime/cell-types/text/TextEditor.d.vue.ts +15 -0
  76. package/dist/runtime/cell-types/text/TextEditor.vue +70 -0
  77. package/dist/runtime/cell-types/text/TextEditor.vue.d.ts +15 -0
  78. package/dist/runtime/cell-types/text/TextFilter.d.vue.ts +7 -0
  79. package/dist/runtime/cell-types/text/TextFilter.vue +50 -0
  80. package/dist/runtime/cell-types/text/TextFilter.vue.d.ts +7 -0
  81. package/dist/runtime/cell-types/text/TextareaEditor.d.vue.ts +15 -0
  82. package/dist/runtime/cell-types/text/TextareaEditor.vue +100 -0
  83. package/dist/runtime/cell-types/text/TextareaEditor.vue.d.ts +15 -0
  84. package/dist/runtime/cell-types/text/index.d.ts +10 -0
  85. package/dist/runtime/cell-types/text/index.js +16 -0
  86. package/dist/runtime/cell-types/text/textarea.d.ts +13 -0
  87. package/dist/runtime/cell-types/text/textarea.js +13 -0
  88. package/dist/runtime/components/NuGrid.d.vue.ts +96 -0
  89. package/dist/runtime/components/NuGrid.vue +651 -0
  90. package/dist/runtime/components/NuGrid.vue.d.ts +96 -0
  91. package/dist/runtime/components/NuGridCellCheckbox.d.vue.ts +24 -0
  92. package/dist/runtime/components/NuGridCellCheckbox.vue +105 -0
  93. package/dist/runtime/components/NuGridCellCheckbox.vue.d.ts +24 -0
  94. package/dist/runtime/components/NuGridGroup.d.vue.ts +20 -0
  95. package/dist/runtime/components/NuGridGroup.vue +650 -0
  96. package/dist/runtime/components/NuGridGroup.vue.d.ts +20 -0
  97. package/dist/runtime/components/NuGridLazyCell.d.vue.ts +62 -0
  98. package/dist/runtime/components/NuGridLazyCell.vue +133 -0
  99. package/dist/runtime/components/NuGridLazyCell.vue.d.ts +62 -0
  100. package/dist/runtime/components/_internal/NuGridAddRow.d.vue.ts +36 -0
  101. package/dist/runtime/components/_internal/NuGridAddRow.vue +144 -0
  102. package/dist/runtime/components/_internal/NuGridAddRow.vue.d.ts +36 -0
  103. package/dist/runtime/components/_internal/NuGridBase.d.vue.ts +20 -0
  104. package/dist/runtime/components/_internal/NuGridBase.vue +1172 -0
  105. package/dist/runtime/components/_internal/NuGridBase.vue.d.ts +20 -0
  106. package/dist/runtime/components/_internal/NuGridCellContent.d.vue.ts +9 -0
  107. package/dist/runtime/components/_internal/NuGridCellContent.vue +202 -0
  108. package/dist/runtime/components/_internal/NuGridCellContent.vue.d.ts +9 -0
  109. package/dist/runtime/components/_internal/NuGridColumnMenu.d.vue.ts +25 -0
  110. package/dist/runtime/components/_internal/NuGridColumnMenu.vue +391 -0
  111. package/dist/runtime/components/_internal/NuGridColumnMenu.vue.d.ts +25 -0
  112. package/dist/runtime/components/_internal/NuGridGroup.d.vue.ts +20 -0
  113. package/dist/runtime/components/_internal/NuGridGroup.vue +650 -0
  114. package/dist/runtime/components/_internal/NuGridGroup.vue.d.ts +20 -0
  115. package/dist/runtime/components/_internal/NuGridGroupCheckbox.d.vue.ts +22 -0
  116. package/dist/runtime/components/_internal/NuGridGroupCheckbox.vue +132 -0
  117. package/dist/runtime/components/_internal/NuGridGroupCheckbox.vue.d.ts +22 -0
  118. package/dist/runtime/components/_internal/NuGridHeaderSortButton.d.vue.ts +31 -0
  119. package/dist/runtime/components/_internal/NuGridHeaderSortButton.vue +61 -0
  120. package/dist/runtime/components/_internal/NuGridHeaderSortButton.vue.d.ts +31 -0
  121. package/dist/runtime/components/_internal/NuGridPaging.d.vue.ts +3 -0
  122. package/dist/runtime/components/_internal/NuGridPaging.vue +65 -0
  123. package/dist/runtime/components/_internal/NuGridPaging.vue.d.ts +3 -0
  124. package/dist/runtime/components/_internal/NuGridRow.d.vue.ts +40 -0
  125. package/dist/runtime/components/_internal/NuGridRow.vue +645 -0
  126. package/dist/runtime/components/_internal/NuGridRow.vue.d.ts +40 -0
  127. package/dist/runtime/components/_internal/NuGridSplitGroup.d.vue.ts +20 -0
  128. package/dist/runtime/components/_internal/NuGridSplitGroup.vue +735 -0
  129. package/dist/runtime/components/_internal/NuGridSplitGroup.vue.d.ts +20 -0
  130. package/dist/runtime/components/_internal/NuGridTooltip.d.vue.ts +3 -0
  131. package/dist/runtime/components/_internal/NuGridTooltip.vue +36 -0
  132. package/dist/runtime/components/_internal/NuGridTooltip.vue.d.ts +3 -0
  133. package/dist/runtime/composables/_internal/index.d.ts +31 -0
  134. package/dist/runtime/composables/_internal/index.js +28 -0
  135. package/dist/runtime/composables/_internal/keyboard-handlers/index.d.ts +5 -0
  136. package/dist/runtime/composables/_internal/keyboard-handlers/index.js +9 -0
  137. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardCellTypeDispatch.d.ts +18 -0
  138. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardCellTypeDispatch.js +53 -0
  139. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardEditingTriggers.d.ts +12 -0
  140. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardEditingTriggers.js +53 -0
  141. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardNavigation.d.ts +9 -0
  142. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardNavigation.js +35 -0
  143. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardSetup.d.ts +33 -0
  144. package/dist/runtime/composables/_internal/keyboard-handlers/useKeyboardSetup.js +111 -0
  145. package/dist/runtime/composables/_internal/keyboard-handlers/usePagingKeyboard.d.ts +11 -0
  146. package/dist/runtime/composables/_internal/keyboard-handlers/usePagingKeyboard.js +67 -0
  147. package/dist/runtime/composables/_internal/useNuGridActionMenu.d.ts +15 -0
  148. package/dist/runtime/composables/_internal/useNuGridActionMenu.js +137 -0
  149. package/dist/runtime/composables/_internal/useNuGridAddRow.d.ts +39 -0
  150. package/dist/runtime/composables/_internal/useNuGridAddRow.js +735 -0
  151. package/dist/runtime/composables/_internal/useNuGridAnimation.d.ts +33 -0
  152. package/dist/runtime/composables/_internal/useNuGridAnimation.js +178 -0
  153. package/dist/runtime/composables/_internal/useNuGridAutosize.d.ts +14 -0
  154. package/dist/runtime/composables/_internal/useNuGridAutosize.js +161 -0
  155. package/dist/runtime/composables/_internal/useNuGridCellEditing.d.ts +15 -0
  156. package/dist/runtime/composables/_internal/useNuGridCellEditing.js +1243 -0
  157. package/dist/runtime/composables/_internal/useNuGridColumnDragDrop.d.ts +8 -0
  158. package/dist/runtime/composables/_internal/useNuGridColumnDragDrop.js +148 -0
  159. package/dist/runtime/composables/_internal/useNuGridColumnPinning.d.ts +15 -0
  160. package/dist/runtime/composables/_internal/useNuGridColumnPinning.js +44 -0
  161. package/dist/runtime/composables/_internal/useNuGridColumnResize.d.ts +22 -0
  162. package/dist/runtime/composables/_internal/useNuGridColumnResize.js +427 -0
  163. package/dist/runtime/composables/_internal/useNuGridCore.d.ts +62 -0
  164. package/dist/runtime/composables/_internal/useNuGridCore.js +359 -0
  165. package/dist/runtime/composables/_internal/useNuGridExcel.d.ts +60 -0
  166. package/dist/runtime/composables/_internal/useNuGridExcel.js +35 -0
  167. package/dist/runtime/composables/_internal/useNuGridFocus.d.ts +15 -0
  168. package/dist/runtime/composables/_internal/useNuGridFocus.js +1378 -0
  169. package/dist/runtime/composables/_internal/useNuGridGroupSelection.d.ts +13 -0
  170. package/dist/runtime/composables/_internal/useNuGridGroupSelection.js +38 -0
  171. package/dist/runtime/composables/_internal/useNuGridGrouping.d.ts +28 -0
  172. package/dist/runtime/composables/_internal/useNuGridGrouping.js +211 -0
  173. package/dist/runtime/composables/_internal/useNuGridInteractionRouter.d.ts +9 -0
  174. package/dist/runtime/composables/_internal/useNuGridInteractionRouter.js +441 -0
  175. package/dist/runtime/composables/_internal/useNuGridInteractions.d.ts +10 -0
  176. package/dist/runtime/composables/_internal/useNuGridInteractions.js +36 -0
  177. package/dist/runtime/composables/_internal/useNuGridKeyboardNavigation.d.ts +54 -0
  178. package/dist/runtime/composables/_internal/useNuGridKeyboardNavigation.js +407 -0
  179. package/dist/runtime/composables/_internal/useNuGridPaging.d.ts +76 -0
  180. package/dist/runtime/composables/_internal/useNuGridPaging.js +147 -0
  181. package/dist/runtime/composables/_internal/useNuGridRowDragDrop.d.ts +68 -0
  182. package/dist/runtime/composables/_internal/useNuGridRowDragDrop.js +295 -0
  183. package/dist/runtime/composables/_internal/useNuGridRowSelection.d.ts +14 -0
  184. package/dist/runtime/composables/_internal/useNuGridRowSelection.js +214 -0
  185. package/dist/runtime/composables/_internal/useNuGridScroll.d.ts +110 -0
  186. package/dist/runtime/composables/_internal/useNuGridScroll.js +463 -0
  187. package/dist/runtime/composables/_internal/useNuGridScrollState.d.ts +32 -0
  188. package/dist/runtime/composables/_internal/useNuGridScrollState.js +60 -0
  189. package/dist/runtime/composables/_internal/useNuGridScrollbars.d.ts +24 -0
  190. package/dist/runtime/composables/_internal/useNuGridScrollbars.js +69 -0
  191. package/dist/runtime/composables/_internal/useNuGridStatePersistence.d.ts +27 -0
  192. package/dist/runtime/composables/_internal/useNuGridStatePersistence.js +243 -0
  193. package/dist/runtime/composables/_internal/useNuGridTooltip.d.ts +41 -0
  194. package/dist/runtime/composables/_internal/useNuGridTooltip.js +304 -0
  195. package/dist/runtime/composables/_internal/useNuGridUI.d.ts +3283 -0
  196. package/dist/runtime/composables/_internal/useNuGridUI.js +58 -0
  197. package/dist/runtime/composables/_internal/useNuGridVirtualization.d.ts +75 -0
  198. package/dist/runtime/composables/_internal/useNuGridVirtualization.js +534 -0
  199. package/dist/runtime/composables/_internal/useNuGridWheelSmoothing.d.ts +25 -0
  200. package/dist/runtime/composables/_internal/useNuGridWheelSmoothing.js +157 -0
  201. package/dist/runtime/composables/index.d.ts +3 -0
  202. package/dist/runtime/composables/index.js +2 -0
  203. package/dist/runtime/composables/useNuGridCellEditor.d.ts +91 -0
  204. package/dist/runtime/composables/useNuGridCellEditor.js +82 -0
  205. package/dist/runtime/composables/useNuGridCellTypeRegistry.d.ts +85 -0
  206. package/dist/runtime/composables/useNuGridCellTypeRegistry.js +202 -0
  207. package/dist/runtime/config/_internal/index.d.ts +5 -0
  208. package/dist/runtime/config/_internal/index.js +2 -0
  209. package/dist/runtime/config/_internal/options-defaults.d.ts +121 -0
  210. package/dist/runtime/config/_internal/options-defaults.js +121 -0
  211. package/dist/runtime/config/_internal/prop-utils.d.ts +54 -0
  212. package/dist/runtime/config/_internal/prop-utils.js +21 -0
  213. package/dist/runtime/config/config.d.ts +44 -0
  214. package/dist/runtime/config/config.js +18 -0
  215. package/dist/runtime/config/index.d.ts +2 -0
  216. package/dist/runtime/config/index.js +2 -0
  217. package/dist/runtime/config/presets.d.ts +15 -0
  218. package/dist/runtime/config/presets.js +58 -0
  219. package/dist/runtime/index.css +1 -0
  220. package/dist/runtime/index.d.ts +1 -0
  221. package/dist/runtime/index.js +1 -0
  222. package/dist/runtime/plugin.d.ts +5 -0
  223. package/dist/runtime/plugin.js +10 -0
  224. package/dist/runtime/themes/index.d.ts +56 -0
  225. package/dist/runtime/themes/index.js +68 -0
  226. package/dist/runtime/themes/nuGridTheme.d.ts +329 -0
  227. package/dist/runtime/themes/nuGridTheme.js +236 -0
  228. package/dist/runtime/themes/nuGridThemeCompact.d.ts +331 -0
  229. package/dist/runtime/themes/nuGridThemeCompact.js +236 -0
  230. package/dist/runtime/types/_internal/action-menu.d.ts +55 -0
  231. package/dist/runtime/types/_internal/action-menu.js +0 -0
  232. package/dist/runtime/types/_internal/cell-editing.d.ts +75 -0
  233. package/dist/runtime/types/_internal/cell-editing.js +0 -0
  234. package/dist/runtime/types/_internal/composable-returns.d.ts +52 -0
  235. package/dist/runtime/types/_internal/composable-returns.js +0 -0
  236. package/dist/runtime/types/_internal/config.d.ts +16 -0
  237. package/dist/runtime/types/_internal/config.js +0 -0
  238. package/dist/runtime/types/_internal/contexts/add-row.d.ts +25 -0
  239. package/dist/runtime/types/_internal/contexts/add-row.js +0 -0
  240. package/dist/runtime/types/_internal/contexts/animation.d.ts +24 -0
  241. package/dist/runtime/types/_internal/contexts/animation.js +0 -0
  242. package/dist/runtime/types/_internal/contexts/core.d.ts +24 -0
  243. package/dist/runtime/types/_internal/contexts/core.js +0 -0
  244. package/dist/runtime/types/_internal/contexts/drag.d.ts +13 -0
  245. package/dist/runtime/types/_internal/contexts/drag.js +0 -0
  246. package/dist/runtime/types/_internal/contexts/focus.d.ts +11 -0
  247. package/dist/runtime/types/_internal/contexts/focus.js +0 -0
  248. package/dist/runtime/types/_internal/contexts/grouping.d.ts +9 -0
  249. package/dist/runtime/types/_internal/contexts/grouping.js +0 -0
  250. package/dist/runtime/types/_internal/contexts/index.d.ts +15 -0
  251. package/dist/runtime/types/_internal/contexts/index.js +0 -0
  252. package/dist/runtime/types/_internal/contexts/interaction-router.d.ts +5 -0
  253. package/dist/runtime/types/_internal/contexts/interaction-router.js +0 -0
  254. package/dist/runtime/types/_internal/contexts/multi-row.d.ts +40 -0
  255. package/dist/runtime/types/_internal/contexts/multi-row.js +0 -0
  256. package/dist/runtime/types/_internal/contexts/paging.d.ts +39 -0
  257. package/dist/runtime/types/_internal/contexts/paging.js +0 -0
  258. package/dist/runtime/types/_internal/contexts/performance.d.ts +15 -0
  259. package/dist/runtime/types/_internal/contexts/performance.js +0 -0
  260. package/dist/runtime/types/_internal/contexts/resize.d.ts +12 -0
  261. package/dist/runtime/types/_internal/contexts/resize.js +0 -0
  262. package/dist/runtime/types/_internal/contexts/row-interactions.d.ts +12 -0
  263. package/dist/runtime/types/_internal/contexts/row-interactions.js +0 -0
  264. package/dist/runtime/types/_internal/contexts/scroll-state.d.ts +21 -0
  265. package/dist/runtime/types/_internal/contexts/scroll-state.js +0 -0
  266. package/dist/runtime/types/_internal/contexts/ui-config.d.ts +21 -0
  267. package/dist/runtime/types/_internal/contexts/ui-config.js +0 -0
  268. package/dist/runtime/types/_internal/contexts/virtualization.d.ts +16 -0
  269. package/dist/runtime/types/_internal/contexts/virtualization.js +0 -0
  270. package/dist/runtime/types/_internal/drag-drop.d.ts +48 -0
  271. package/dist/runtime/types/_internal/drag-drop.js +0 -0
  272. package/dist/runtime/types/_internal/focus.d.ts +68 -0
  273. package/dist/runtime/types/_internal/focus.js +0 -0
  274. package/dist/runtime/types/_internal/grouping.d.ts +48 -0
  275. package/dist/runtime/types/_internal/grouping.js +0 -0
  276. package/dist/runtime/types/_internal/index.d.ts +37 -0
  277. package/dist/runtime/types/_internal/index.js +2 -0
  278. package/dist/runtime/types/_internal/interaction-router.d.ts +176 -0
  279. package/dist/runtime/types/_internal/interaction-router.js +39 -0
  280. package/dist/runtime/types/_internal/props.d.ts +28 -0
  281. package/dist/runtime/types/_internal/props.js +0 -0
  282. package/dist/runtime/types/_internal/resize.d.ts +37 -0
  283. package/dist/runtime/types/_internal/resize.js +0 -0
  284. package/dist/runtime/types/_internal/row-interactions.d.ts +15 -0
  285. package/dist/runtime/types/_internal/row-interactions.js +0 -0
  286. package/dist/runtime/types/_internal/row-selection.d.ts +27 -0
  287. package/dist/runtime/types/_internal/row-selection.js +0 -0
  288. package/dist/runtime/types/_internal/states.d.ts +24 -0
  289. package/dist/runtime/types/_internal/states.js +0 -0
  290. package/dist/runtime/types/_internal/sticky-headers.d.ts +10 -0
  291. package/dist/runtime/types/_internal/sticky-headers.js +0 -0
  292. package/dist/runtime/types/_internal/validation.d.ts +54 -0
  293. package/dist/runtime/types/_internal/validation.js +0 -0
  294. package/dist/runtime/types/_internal/virtualization.d.ts +114 -0
  295. package/dist/runtime/types/_internal/virtualization.js +0 -0
  296. package/dist/runtime/types/action-menu.d.ts +62 -0
  297. package/dist/runtime/types/action-menu.js +0 -0
  298. package/dist/runtime/types/autosize.d.ts +8 -0
  299. package/dist/runtime/types/autosize.js +0 -0
  300. package/dist/runtime/types/cells.d.ts +292 -0
  301. package/dist/runtime/types/cells.js +5 -0
  302. package/dist/runtime/types/column.d.ts +248 -0
  303. package/dist/runtime/types/column.js +0 -0
  304. package/dist/runtime/types/config.d.ts +35 -0
  305. package/dist/runtime/types/config.js +0 -0
  306. package/dist/runtime/types/drag-drop.d.ts +92 -0
  307. package/dist/runtime/types/drag-drop.js +0 -0
  308. package/dist/runtime/types/events.d.ts +164 -0
  309. package/dist/runtime/types/events.js +1 -0
  310. package/dist/runtime/types/focus.d.ts +50 -0
  311. package/dist/runtime/types/focus.js +0 -0
  312. package/dist/runtime/types/grouping.d.ts +7 -0
  313. package/dist/runtime/types/grouping.js +0 -0
  314. package/dist/runtime/types/index.d.ts +15 -0
  315. package/dist/runtime/types/index.js +0 -0
  316. package/dist/runtime/types/option-groups.d.ts +624 -0
  317. package/dist/runtime/types/option-groups.js +0 -0
  318. package/dist/runtime/types/props.d.ts +418 -0
  319. package/dist/runtime/types/props.js +0 -0
  320. package/dist/runtime/types/resize.d.ts +14 -0
  321. package/dist/runtime/types/resize.js +0 -0
  322. package/dist/runtime/types/row-interactions.d.ts +11 -0
  323. package/dist/runtime/types/row-interactions.js +0 -0
  324. package/dist/runtime/types/row-selection.d.ts +48 -0
  325. package/dist/runtime/types/row-selection.js +0 -0
  326. package/dist/runtime/types/row.d.ts +7 -0
  327. package/dist/runtime/types/row.js +0 -0
  328. package/dist/runtime/types/sort-icon.d.ts +35 -0
  329. package/dist/runtime/types/sort-icon.js +0 -0
  330. package/dist/runtime/types/states.d.ts +17 -0
  331. package/dist/runtime/types/states.js +0 -0
  332. package/dist/runtime/types/sticky-headers.d.ts +6 -0
  333. package/dist/runtime/types/sticky-headers.js +0 -0
  334. package/dist/runtime/types/tanstack-table.d.ts +126 -0
  335. package/dist/runtime/types/theme.d.ts +22 -0
  336. package/dist/runtime/types/theme.js +0 -0
  337. package/dist/runtime/types/validation.d.ts +94 -0
  338. package/dist/runtime/types/validation.js +0 -0
  339. package/dist/runtime/utils/columnHelper.d.ts +208 -0
  340. package/dist/runtime/utils/columnHelper.js +23 -0
  341. package/dist/runtime/utils/excelExport.d.ts +63 -0
  342. package/dist/runtime/utils/excelExport.js +297 -0
  343. package/dist/runtime/utils/index.d.ts +2 -0
  344. package/dist/runtime/utils/index.js +2 -0
  345. package/dist/runtime/utils/standardSchema.d.ts +77 -0
  346. package/dist/runtime/utils/standardSchema.js +141 -0
  347. package/dist/types.d.mts +3 -0
  348. package/package.json +117 -0
@@ -0,0 +1,1243 @@
1
+ import { FlexRender } from "@tanstack/vue-table";
2
+ import { computed, h, nextTick, onMounted, onUnmounted, ref, resolveComponent } from "vue";
3
+ import { textCellType } from "../../cell-types/index.js";
4
+ import { getDefaults, usePropWithDefault } from "../../config/_internal/index.js";
5
+ import { splitPath, validateFieldValue } from "../../utils/standardSchema.js";
6
+ import { useNuGridCellTypeRegistry } from "../useNuGridCellTypeRegistry.js";
7
+ import { useNuGridKeyboardNavigation } from "./useNuGridKeyboardNavigation.js";
8
+ import { useNuGridScroll } from "./useNuGridScroll.js";
9
+ const validationDefaults = getDefaults("validation");
10
+ export const defaultValidationIcon = validationDefaults.icon;
11
+ function resolveValidationConfig(validation) {
12
+ if (!validation) return null;
13
+ return {
14
+ schema: validation.schema ?? null,
15
+ rowRules: validation.rowRules ?? [],
16
+ validateOn: validation.validateOn ?? validationDefaults.validateOn,
17
+ showErrors: validation.showErrors ?? validationDefaults.showErrors,
18
+ icon: validation.icon ?? validationDefaults.icon,
19
+ onInvalid: validation.onInvalid ?? validationDefaults.onInvalid,
20
+ validateOnAddRow: validation.validateOnAddRow ?? validationDefaults.validateOnAddRow
21
+ };
22
+ }
23
+ export function useNuGridCellEditing(props, tableApi, data, rows, tableRef, rootRef, focusFns, interactionRouter, emit, navigableRows, externalEditingCell, addRowContext, eventEmitter) {
24
+ const editingCell = externalEditingCell ?? ref(null);
25
+ const editingValue = ref(null);
26
+ const isNavigating = ref(false);
27
+ const shouldFocusEditor = ref(false);
28
+ const cellSelector = '[data-row-id="$ID"] [data-cell-index="$COL"]';
29
+ const validationError = ref(null);
30
+ const validationPending = ref(false);
31
+ let validationRunId = 0;
32
+ const hasBeenPunished = ref(false);
33
+ const hasAttemptedClickAway = ref(false);
34
+ const isRowLevelValidationError = ref(false);
35
+ let unregisterInteraction = null;
36
+ let unregisterDoubleClick = null;
37
+ let unregisterOutsidePointer = null;
38
+ const typeRegistry = useNuGridCellTypeRegistry(
39
+ props.cellTypes ? computed(() => props.cellTypes) : void 0
40
+ );
41
+ const { scrollManager } = useNuGridScroll(tableApi);
42
+ const editingEnabled = usePropWithDefault(props, "editing", "enabled");
43
+ const startClicks = usePropWithDefault(props, "editing", "startClicks");
44
+ const startKeys = usePropWithDefault(props, "editing", "startKeys");
45
+ const validationConfig = computed(() => resolveValidationConfig(props.validation));
46
+ const showValidationErrors = computed(
47
+ () => validationConfig.value?.showErrors ?? validationDefaults.showErrors
48
+ );
49
+ const validationIcon = computed(() => validationConfig.value?.icon ?? defaultValidationIcon);
50
+ const pathCache = /* @__PURE__ */ new Map();
51
+ const keyboardNav = useNuGridKeyboardNavigation(props, tableApi);
52
+ const { multiRowEnabled, multiRowCount, getVisualRowForColumn, findColumnInVisualRow } = keyboardNav;
53
+ const rowValidationErrors = ref(
54
+ /* @__PURE__ */ new Map()
55
+ );
56
+ function runRowValidation(rowData, candidateField, candidateValue) {
57
+ const config = validationConfig.value;
58
+ if (!config || config.rowRules.length === 0) {
59
+ return { valid: true };
60
+ }
61
+ const candidateRow = candidateField ? { ...rowData, [candidateField]: candidateValue } : rowData;
62
+ for (const rule of config.rowRules) {
63
+ const result = rule(candidateRow);
64
+ if (!result.valid) {
65
+ return result;
66
+ }
67
+ }
68
+ return { valid: true };
69
+ }
70
+ function hasRowValidationError(rowId) {
71
+ return rowValidationErrors.value.has(rowId);
72
+ }
73
+ function hasCellValidationError(rowId, columnId) {
74
+ const rowError = rowValidationErrors.value.get(rowId);
75
+ if (!rowError) return false;
76
+ if (!rowError.failedFields || rowError.failedFields.length === 0) return true;
77
+ return rowError.failedFields.includes(columnId);
78
+ }
79
+ function getRowValidationError(rowId) {
80
+ return rowValidationErrors.value.get(rowId)?.message ?? null;
81
+ }
82
+ function clearRowValidationError(rowId) {
83
+ if (rowValidationErrors.value.has(rowId)) {
84
+ const newMap = new Map(rowValidationErrors.value);
85
+ newMap.delete(rowId);
86
+ rowValidationErrors.value = newMap;
87
+ }
88
+ }
89
+ function setRowValidationError(rowId, message, failedFields) {
90
+ const newMap = new Map(rowValidationErrors.value);
91
+ newMap.set(rowId, { message, failedFields });
92
+ rowValidationErrors.value = newMap;
93
+ }
94
+ function runSchemaValidation(row, cell, value) {
95
+ const config = validationConfig.value;
96
+ if (!config || !config.schema) return true;
97
+ const accessorKey = "accessorKey" in cell.column.columnDef && cell.column.columnDef.accessorKey ? cell.column.columnDef.accessorKey : cell.column.id;
98
+ const fieldPath = (() => {
99
+ const cached = pathCache.get(accessorKey);
100
+ if (cached) return cached;
101
+ const resolved = splitPath(accessorKey);
102
+ pathCache.set(accessorKey, resolved);
103
+ return resolved;
104
+ })();
105
+ const schemaResult = validateFieldValue(
106
+ config.schema,
107
+ fieldPath,
108
+ value,
109
+ row.original
110
+ );
111
+ const handleSchemaResult = (result) => {
112
+ if (!result.valid) {
113
+ validationError.value = result.message || "Validation failed";
114
+ return false;
115
+ }
116
+ validationError.value = null;
117
+ return true;
118
+ };
119
+ if (schemaResult instanceof Promise) {
120
+ const runId = ++validationRunId;
121
+ validationPending.value = true;
122
+ schemaResult.then((result) => {
123
+ if (runId !== validationRunId) return;
124
+ validationPending.value = false;
125
+ handleSchemaResult(result);
126
+ }).catch(() => {
127
+ if (runId !== validationRunId) return;
128
+ validationPending.value = false;
129
+ validationError.value = "Validation failed";
130
+ });
131
+ return true;
132
+ }
133
+ validationPending.value = false;
134
+ return handleSchemaResult(schemaResult);
135
+ }
136
+ function renderEditor(editorConfig, context, additionalProps) {
137
+ const getCurrentEditingContext2 = () => {
138
+ if (!editingCell.value) return null;
139
+ const rowsList = navigableRows?.value ?? rows.value;
140
+ const currentRow = rowsList.find((r) => r.id === editingCell.value.rowId);
141
+ if (!currentRow) return null;
142
+ const currentCell = currentRow.getAllCells().find((c) => c.column.id === editingCell.value.columnId);
143
+ if (!currentCell) return null;
144
+ return { row: currentRow, cell: currentCell };
145
+ };
146
+ if (typeof editorConfig === "function") {
147
+ return editorConfig(context);
148
+ }
149
+ let componentToRender;
150
+ let componentProps = {};
151
+ if (typeof editorConfig === "string") {
152
+ componentToRender = resolveComponent(editorConfig);
153
+ } else if (typeof editorConfig === "object" && "component" in editorConfig) {
154
+ componentToRender = typeof editorConfig.component === "string" ? resolveComponent(editorConfig.component) : editorConfig.component;
155
+ componentProps = editorConfig.props || {};
156
+ } else {
157
+ componentToRender = editorConfig;
158
+ }
159
+ const shouldShowPopover = showValidationErrors.value;
160
+ return h(componentToRender, {
161
+ "modelValue": context.getValue(),
162
+ "cell": context.cell,
163
+ "row": context.row,
164
+ "isNavigating": isNavigating.value,
165
+ "shouldFocus": shouldFocusEditor.value,
166
+ "validationError": validationError.value,
167
+ "showValidationErrors": shouldShowPopover,
168
+ "interactionRouter": interactionRouter,
169
+ ...componentProps,
170
+ ...additionalProps,
171
+ "onUpdate:modelValue": (value) => {
172
+ context.setValue(value);
173
+ const config = validationConfig.value;
174
+ if (!config) return;
175
+ const validateOn = config.validateOn;
176
+ if (validateOn === "change") {
177
+ runSchemaValidation(context.row, context.cell, value);
178
+ } else if (validateOn === "reward" && hasBeenPunished.value) {
179
+ const isValid = runSchemaValidation(context.row, context.cell, value);
180
+ if (isValid) {
181
+ validationError.value = null;
182
+ }
183
+ }
184
+ },
185
+ "onUpdate:isNavigating": (value) => {
186
+ isNavigating.value = value;
187
+ },
188
+ "onStopEditing": (direction) => {
189
+ if (direction && scrollManager.isProcessingScroll) {
190
+ isNavigating.value = false;
191
+ return;
192
+ }
193
+ context.stopEditing(direction);
194
+ },
195
+ "onCancelEditing": () => {
196
+ const ctx = getCurrentEditingContext2();
197
+ const hadError = !!validationError.value;
198
+ if (ctx && eventEmitter?.cellEditingCancelled) {
199
+ eventEmitter.cellEditingCancelled({
200
+ row: ctx.row,
201
+ column: ctx.cell.column,
202
+ value: editingValue.value
203
+ });
204
+ }
205
+ validationRunId++;
206
+ validationPending.value = false;
207
+ editingCell.value = null;
208
+ editingValue.value = null;
209
+ validationError.value = null;
210
+ hasBeenPunished.value = false;
211
+ hasAttemptedClickAway.value = false;
212
+ if (ctx) {
213
+ if (hadError) {
214
+ nextTick(() => restoreFocus(ctx.row, ctx.cell));
215
+ setTimeout(() => restoreFocus(ctx.row, ctx.cell), 0);
216
+ } else {
217
+ restoreFocus(ctx.row, ctx.cell);
218
+ }
219
+ }
220
+ }
221
+ });
222
+ }
223
+ function isCellEditable(row, cell) {
224
+ if (editingEnabled.value === false) {
225
+ return false;
226
+ }
227
+ const columnDef = cell.column.columnDef;
228
+ const isAddRow = addRowContext?.isAddRowRow(row) ?? false;
229
+ if (isAddRow && columnDef.showNew === false) {
230
+ return false;
231
+ }
232
+ if (isAddRow) {
233
+ const groupingState = tableApi.getState().grouping || [];
234
+ if (groupingState.includes(cell.column.id)) {
235
+ return false;
236
+ }
237
+ }
238
+ if (columnDef.enableEditing !== void 0) {
239
+ if (typeof columnDef.enableEditing === "function") {
240
+ return columnDef.enableEditing(row);
241
+ }
242
+ return columnDef.enableEditing;
243
+ }
244
+ return true;
245
+ }
246
+ function startEditing(row, cell, initialValue, options) {
247
+ const wasNavigating = isNavigating.value;
248
+ if (wasNavigating && scrollManager.isProcessingScroll) {
249
+ isNavigating.value = false;
250
+ return;
251
+ }
252
+ if (editingCell.value?.rowId === row.id && editingCell.value?.columnId === cell.column.id && initialValue === void 0) {
253
+ return;
254
+ }
255
+ if (!isCellEditable(row, cell)) {
256
+ return;
257
+ }
258
+ shouldFocusEditor.value = false;
259
+ editingCell.value = {
260
+ rowId: row.id,
261
+ columnId: cell.column.id
262
+ };
263
+ editingValue.value = initialValue !== void 0 ? initialValue : cell.getValue();
264
+ if (eventEmitter?.cellEditingStarted) {
265
+ eventEmitter.cellEditingStarted({
266
+ row,
267
+ column: cell.column,
268
+ value: editingValue.value
269
+ });
270
+ }
271
+ const rowError = rowValidationErrors.value.get(row.id);
272
+ if (rowError && isRowLevelValidationError.value) {
273
+ const accessorKey = "accessorKey" in cell.column.columnDef && cell.column.columnDef.accessorKey ? cell.column.columnDef.accessorKey : cell.column.id;
274
+ const isFailedField = rowError.failedFields.length === 0 || rowError.failedFields.includes(accessorKey);
275
+ if (isFailedField) {
276
+ validationError.value = rowError.message;
277
+ hasBeenPunished.value = true;
278
+ } else {
279
+ validationError.value = null;
280
+ hasBeenPunished.value = false;
281
+ }
282
+ } else {
283
+ validationError.value = null;
284
+ hasBeenPunished.value = false;
285
+ }
286
+ hasAttemptedClickAway.value = false;
287
+ if (wasNavigating) {
288
+ if (scrollManager.isProcessingScroll) {
289
+ isNavigating.value = false;
290
+ return;
291
+ }
292
+ scrollManager.setProcessing(true);
293
+ }
294
+ const rowsList = navigableRows?.value ?? rows.value;
295
+ const rowIndex = options?.rowIndex !== void 0 ? options.rowIndex : rowsList.findIndex((r) => r.id === row.id);
296
+ const cellIndex = options?.cellIndex !== void 0 ? options.cellIndex : row.getVisibleCells().findIndex((c) => c.id === cell.id);
297
+ if (rowIndex !== -1 && cellIndex !== -1) {
298
+ const currentSuppressOutline = focusFns.focusedCell.value?.suppressOutline;
299
+ focusFns.focusedCell.value = {
300
+ rowIndex,
301
+ columnIndex: cellIndex,
302
+ ...currentSuppressOutline && { suppressOutline: true }
303
+ };
304
+ }
305
+ if (rowIndex !== -1 && cellIndex !== -1 && tableRef.value) {
306
+ const cellElement = focusFns.getCellElement(row.id, cellIndex);
307
+ const rootElement = rootRef.value && "$el" in rootRef.value ? rootRef.value.$el : rootRef.value;
308
+ if (cellElement && rootElement) {
309
+ focusFns.scrollToCellAndFocus({
310
+ cellElement,
311
+ rowId: row.id,
312
+ rowIndex,
313
+ columnIndex: cellIndex,
314
+ behavior: wasNavigating ? "instant" : "smooth",
315
+ onComplete: () => {
316
+ shouldFocusEditor.value = true;
317
+ if (wasNavigating) {
318
+ scrollManager.setProcessing(false);
319
+ }
320
+ }
321
+ });
322
+ } else {
323
+ shouldFocusEditor.value = true;
324
+ if (wasNavigating) {
325
+ scrollManager.setProcessing(false);
326
+ }
327
+ }
328
+ } else {
329
+ shouldFocusEditor.value = true;
330
+ if (wasNavigating) {
331
+ scrollManager.setProcessing(false);
332
+ }
333
+ }
334
+ }
335
+ function isEditingCell(row, columnId) {
336
+ return editingCell.value?.rowId === row.id && editingCell.value?.columnId === columnId;
337
+ }
338
+ function stopEditing(row, cell, newValue, moveDirection, options) {
339
+ const shouldRestoreFocus = options?.restoreFocus !== false;
340
+ const isClickAway = options?.isClickAway === true;
341
+ const config = validationConfig.value;
342
+ const onInvalid = config?.onInvalid ?? validationDefaults.onInvalid;
343
+ if (onInvalid === "block" && hasAttemptedClickAway.value && !isClickAway) {
344
+ return;
345
+ }
346
+ const navDirection = moveDirection;
347
+ const oldValue = cell.getValue();
348
+ let valueToSave = newValue;
349
+ const isAddRow = addRowContext?.isAddRowRow(row);
350
+ const isCurrentValueEmpty = newValue === void 0 || newValue === null || newValue === "";
351
+ const isVerticalNav = navDirection === "up" || navDirection === "down";
352
+ if (isAddRow && isCurrentValueEmpty && isVerticalNav) {
353
+ const rowsList = navigableRows?.value ?? rows.value;
354
+ const currentRowIndex = rowsList.findIndex((r) => r.id === row.id);
355
+ editingCell.value = null;
356
+ editingValue.value = null;
357
+ validationError.value = null;
358
+ hasBeenPunished.value = false;
359
+ hasAttemptedClickAway.value = false;
360
+ addRowContext.resetAddRow(row);
361
+ if (navDirection === "up" || navDirection === "down") {
362
+ isNavigating.value = true;
363
+ const targetRowIndex = navDirection === "up" ? currentRowIndex - 1 : currentRowIndex + 1;
364
+ const freshRowsList = navigableRows?.value ?? rows.value;
365
+ if (targetRowIndex >= 0 && targetRowIndex < freshRowsList.length) {
366
+ const targetRow = freshRowsList[targetRowIndex];
367
+ if (targetRow) {
368
+ const targetCells = targetRow.getVisibleCells();
369
+ const targetCellIdx = targetCells.findIndex((c) => c.column.id === cell.column.id);
370
+ const targetCell = targetCellIdx !== -1 ? targetCells[targetCellIdx] : null;
371
+ if (targetCell && isCellEditable(targetRow, targetCell)) {
372
+ nextTick(() => {
373
+ startEditing(targetRow, targetCell, void 0, {
374
+ rowIndex: targetRowIndex,
375
+ cellIndex: targetCellIdx
376
+ });
377
+ isNavigating.value = false;
378
+ });
379
+ return;
380
+ }
381
+ }
382
+ }
383
+ isNavigating.value = false;
384
+ }
385
+ return;
386
+ }
387
+ const visibleCells = row.getVisibleCells();
388
+ const editableCellIndices = visibleCells.map((c, idx) => ({ c, idx })).filter(({ c }) => isCellEditable(row, c));
389
+ const lastEditableIndex = editableCellIndices[editableCellIndices.length - 1]?.idx ?? visibleCells.length - 1;
390
+ const currentCellIndex = visibleCells.findIndex((c) => c.id === cell.id);
391
+ const columnDef = cell.column.columnDef;
392
+ const cellDataType = columnDef.cellDataType || "text";
393
+ const plugin = typeRegistry.getCellType(cellDataType);
394
+ if (plugin?.validation) {
395
+ const pluginContext = {
396
+ cell,
397
+ row,
398
+ columnDef,
399
+ column: cell.column,
400
+ getValue: () => newValue,
401
+ isFocused: false,
402
+ canEdit: true,
403
+ data: data.value,
404
+ tableApi,
405
+ startEditing: (initialValue) => startEditing(row, cell, initialValue),
406
+ stopEditing: (value, dir) => stopEditing(row, cell, value, dir),
407
+ emitChange: (oldVal, newVal) => {
408
+ emit({ row, column: cell.column, oldValue: oldVal, newValue: newVal });
409
+ }
410
+ };
411
+ const validationResult = plugin.validation(newValue, pluginContext);
412
+ if (!validationResult.valid) {
413
+ if (onInvalid === "revert") {
414
+ valueToSave = oldValue;
415
+ } else {
416
+ validationError.value = validationResult.message || "Invalid value";
417
+ return;
418
+ }
419
+ }
420
+ }
421
+ if (config && config.validateOn !== "change") {
422
+ const isValid = runSchemaValidation(row, cell, valueToSave);
423
+ if (!isValid) {
424
+ if (onInvalid === "revert") {
425
+ valueToSave = oldValue;
426
+ validationError.value = null;
427
+ } else {
428
+ isRowLevelValidationError.value = false;
429
+ if (handleValidationFailure(config, isClickAway)) return;
430
+ }
431
+ }
432
+ }
433
+ const accessorKey = "accessorKey" in cell.column.columnDef && cell.column.columnDef.accessorKey ? cell.column.columnDef.accessorKey : cell.column.id;
434
+ const rowValidationResult = runRowValidation(row.original, accessorKey, valueToSave);
435
+ if (!rowValidationResult.valid) {
436
+ if (onInvalid === "revert") {
437
+ valueToSave = oldValue;
438
+ validationError.value = null;
439
+ } else {
440
+ setRowValidationError(
441
+ row.id,
442
+ rowValidationResult.message || "Row validation failed",
443
+ rowValidationResult.failedFields || [accessorKey]
444
+ );
445
+ validationError.value = rowValidationResult.message || "Row validation failed";
446
+ isRowLevelValidationError.value = true;
447
+ const isHorizontalNavigation = navDirection === "next" || navDirection === "previous";
448
+ if (isHorizontalNavigation) {
449
+ const cells = row.getVisibleCells();
450
+ let hasEditableCellInDirection = false;
451
+ if (navDirection === "next") {
452
+ for (let i = currentCellIndex + 1; i < cells.length; i++) {
453
+ const candidateCell = cells[i];
454
+ if (candidateCell && isCellEditable(row, candidateCell)) {
455
+ hasEditableCellInDirection = true;
456
+ break;
457
+ }
458
+ }
459
+ } else {
460
+ for (let i = currentCellIndex - 1; i >= 0; i--) {
461
+ const candidateCell = cells[i];
462
+ if (candidateCell && isCellEditable(row, candidateCell)) {
463
+ hasEditableCellInDirection = true;
464
+ break;
465
+ }
466
+ }
467
+ }
468
+ if (hasEditableCellInDirection) {
469
+ if (config?.validateOn === "reward") {
470
+ hasBeenPunished.value = true;
471
+ }
472
+ } else {
473
+ if (config && handleValidationFailure(config, isClickAway))
474
+ return;
475
+ }
476
+ } else {
477
+ if (config && handleValidationFailure(config, isClickAway))
478
+ return;
479
+ }
480
+ }
481
+ } else {
482
+ clearRowValidationError(row.id);
483
+ isRowLevelValidationError.value = false;
484
+ validationError.value = null;
485
+ }
486
+ const coerceToOriginalType = (original, value) => {
487
+ if (value === null || value === void 0) return value;
488
+ if (original === null || original === void 0) return value;
489
+ const originalType = typeof original;
490
+ const valueType = typeof value;
491
+ if (originalType === valueType) return value;
492
+ if (originalType === "number" && valueType === "string") {
493
+ const num = Number(value);
494
+ return Number.isNaN(num) ? value : num;
495
+ }
496
+ if (originalType === "boolean" && valueType === "string") {
497
+ if (value === "true") return true;
498
+ if (value === "false") return false;
499
+ return value;
500
+ }
501
+ return value;
502
+ };
503
+ const coercedValue = coerceToOriginalType(oldValue, valueToSave);
504
+ if (oldValue !== coercedValue && cell.column.columnDef.cellDataType !== "selection") {
505
+ if (plugin?.onValueChanged) {
506
+ const pluginContext = {
507
+ cell,
508
+ row,
509
+ columnDef,
510
+ column: cell.column,
511
+ getValue: () => coercedValue,
512
+ isFocused: false,
513
+ canEdit: true,
514
+ data: data.value,
515
+ tableApi,
516
+ startEditing: (initialValue) => startEditing(row, cell, initialValue),
517
+ stopEditing: (value, dir) => stopEditing(row, cell, value, dir),
518
+ emitChange: (oldVal, newVal) => {
519
+ emit({ row, column: cell.column, oldValue: oldVal, newValue: newVal });
520
+ }
521
+ };
522
+ plugin.onValueChanged(oldValue, coercedValue, pluginContext);
523
+ }
524
+ emit({
525
+ row,
526
+ column: cell.column,
527
+ oldValue,
528
+ newValue: coercedValue
529
+ });
530
+ const rowIndex = data.value.findIndex((r, index) => {
531
+ return tableApi.options.getRowId?.(r, index) === row.id || r === row.original;
532
+ });
533
+ const accessorKey2 = "accessorKey" in cell.column.columnDef && cell.column.columnDef.accessorKey ? cell.column.columnDef.accessorKey : void 0;
534
+ const fallbackKey = !accessorKey2 ? cell.column.id : void 0;
535
+ const assignValue = (target) => {
536
+ if (accessorKey2) {
537
+ target[accessorKey2] = coercedValue;
538
+ } else if (fallbackKey) {
539
+ target[fallbackKey] = coercedValue;
540
+ }
541
+ };
542
+ if (rowIndex !== -1) {
543
+ assignValue(data.value[rowIndex]);
544
+ } else if (addRowContext?.isAddRowRow(row)) {
545
+ assignValue(row.original);
546
+ }
547
+ const valuesCache = row._valuesCache;
548
+ if (valuesCache) {
549
+ if (typeof valuesCache.clear === "function") {
550
+ valuesCache.clear();
551
+ } else if (typeof valuesCache === "object") {
552
+ delete valuesCache[cell.column.id];
553
+ }
554
+ }
555
+ data.value = [...data.value];
556
+ }
557
+ let shouldFocusNewAddRowAfterFinalize = false;
558
+ let groupIdToFocus = null;
559
+ if (isAddRow && addRowContext) {
560
+ const currentIndex = visibleCells.findIndex((c) => c.id === cell.id);
561
+ const isLastEditable = currentIndex === lastEditableIndex;
562
+ const shouldFinalizeAfterNav = navDirection === "down" || navDirection === "next" && isLastEditable || navDirection === void 0 && isLastEditable;
563
+ if (shouldFinalizeAfterNav) {
564
+ const parentId = row.parentId;
565
+ groupIdToFocus = parentId || null;
566
+ const result = addRowContext.finalizeAddRow(row);
567
+ if (!result.success) {
568
+ validationError.value = result.messages?.[0] || "Invalid value";
569
+ if (!navDirection) {
570
+ return;
571
+ }
572
+ } else {
573
+ if ((navDirection === "next" || navDirection === void 0) && isLastEditable) {
574
+ shouldFocusNewAddRowAfterFinalize = true;
575
+ }
576
+ }
577
+ }
578
+ }
579
+ const findEditableInRow = (targetRow, startIndex, direction) => {
580
+ const cells = targetRow.getVisibleCells();
581
+ if (direction === "next") {
582
+ for (let i = startIndex + 1; i < cells.length; i++) {
583
+ const candidate = cells[i];
584
+ if (candidate && isCellEditable(targetRow, candidate))
585
+ return { cell: candidate, index: i };
586
+ }
587
+ } else {
588
+ for (let i = startIndex - 1; i >= 0; i--) {
589
+ const candidate = cells[i];
590
+ if (candidate && isCellEditable(targetRow, candidate))
591
+ return { cell: candidate, index: i };
592
+ }
593
+ }
594
+ return null;
595
+ };
596
+ if (navDirection) {
597
+ isNavigating.value = true;
598
+ const rowsList = navigableRows?.value ?? rows.value;
599
+ const currentRowIndex = rowsList.findIndex((r) => r.id === row.id);
600
+ if (shouldFocusNewAddRowAfterFinalize) {
601
+ nextTick(() => {
602
+ const nextRowsList = navigableRows?.value ?? rows.value;
603
+ const newAddRow = groupIdToFocus ? nextRowsList.find(
604
+ (r) => addRowContext?.isAddRowRow(r) && r.parentId === groupIdToFocus
605
+ ) : nextRowsList.find((r) => addRowContext?.isAddRowRow(r));
606
+ if (newAddRow) {
607
+ const firstEditableCell = newAddRow.getVisibleCells().find((c) => isCellEditable(newAddRow, c));
608
+ if (firstEditableCell) {
609
+ startEditing(newAddRow, firstEditableCell);
610
+ isNavigating.value = false;
611
+ return;
612
+ }
613
+ }
614
+ editingCell.value = null;
615
+ editingValue.value = null;
616
+ isNavigating.value = false;
617
+ hasAttemptedClickAway.value = false;
618
+ if (shouldRestoreFocus) {
619
+ restoreFocus(row, cell);
620
+ }
621
+ });
622
+ return;
623
+ }
624
+ if (navDirection === "up" || navDirection === "down") {
625
+ const visibleCells2 = row.getVisibleCells();
626
+ const currentCellIdx = visibleCells2.findIndex((c) => c.id === cell.id);
627
+ if (multiRowEnabled.value && multiRowCount.value > 1) {
628
+ const currentVisualRow = getVisualRowForColumn(currentCellIdx);
629
+ const lastVisualRow = multiRowCount.value - 1;
630
+ if (navDirection === "up") {
631
+ if (currentVisualRow > 0) {
632
+ const targetColIdx = findColumnInVisualRow(currentCellIdx, currentVisualRow - 1, row);
633
+ const targetCell = visibleCells2[targetColIdx];
634
+ if (targetCell && isCellEditable(row, targetCell)) {
635
+ nextTick(() => {
636
+ startEditing(row, targetCell, void 0, {
637
+ rowIndex: currentRowIndex,
638
+ cellIndex: targetColIdx
639
+ });
640
+ isNavigating.value = false;
641
+ });
642
+ return;
643
+ }
644
+ } else {
645
+ const targetRowIndex = currentRowIndex - 1;
646
+ if (targetRowIndex >= 0) {
647
+ const targetRow = rowsList[targetRowIndex];
648
+ if (targetRow) {
649
+ let targetColIdx = findColumnInVisualRow(currentCellIdx, lastVisualRow, targetRow);
650
+ const targetCells = targetRow.getVisibleCells();
651
+ const targetCell = targetCells[targetColIdx];
652
+ let effectiveTargetCell = targetCell ?? null;
653
+ if (effectiveTargetCell && !isCellEditable(targetRow, effectiveTargetCell)) {
654
+ const fallback = findEditableInRow(targetRow, targetColIdx, "previous");
655
+ effectiveTargetCell = fallback?.cell ?? null;
656
+ if (fallback) {
657
+ targetColIdx = fallback.index;
658
+ }
659
+ }
660
+ if (effectiveTargetCell) {
661
+ nextTick(() => {
662
+ startEditing(targetRow, effectiveTargetCell, void 0, {
663
+ rowIndex: targetRowIndex,
664
+ cellIndex: targetColIdx
665
+ });
666
+ isNavigating.value = false;
667
+ });
668
+ return;
669
+ }
670
+ }
671
+ }
672
+ }
673
+ } else {
674
+ if (currentVisualRow < lastVisualRow) {
675
+ const targetColIdx = findColumnInVisualRow(currentCellIdx, currentVisualRow + 1, row);
676
+ const targetCell = visibleCells2[targetColIdx];
677
+ if (targetCell && isCellEditable(row, targetCell)) {
678
+ nextTick(() => {
679
+ startEditing(row, targetCell, void 0, {
680
+ rowIndex: currentRowIndex,
681
+ cellIndex: targetColIdx
682
+ });
683
+ isNavigating.value = false;
684
+ });
685
+ return;
686
+ }
687
+ } else {
688
+ const targetRowIndex = currentRowIndex + 1;
689
+ if (targetRowIndex < rowsList.length) {
690
+ const targetRow = rowsList[targetRowIndex];
691
+ if (targetRow) {
692
+ let targetColIdx = findColumnInVisualRow(currentCellIdx, 0, targetRow);
693
+ const targetCells = targetRow.getVisibleCells();
694
+ const targetCell = targetCells[targetColIdx];
695
+ let effectiveTargetCell = targetCell ?? null;
696
+ if (effectiveTargetCell && !isCellEditable(targetRow, effectiveTargetCell)) {
697
+ const fallback = findEditableInRow(targetRow, targetColIdx, "previous");
698
+ effectiveTargetCell = fallback?.cell ?? null;
699
+ if (fallback) {
700
+ targetColIdx = fallback.index;
701
+ }
702
+ }
703
+ if (effectiveTargetCell) {
704
+ nextTick(() => {
705
+ startEditing(targetRow, effectiveTargetCell, void 0, {
706
+ rowIndex: targetRowIndex,
707
+ cellIndex: targetColIdx
708
+ });
709
+ isNavigating.value = false;
710
+ });
711
+ return;
712
+ }
713
+ }
714
+ }
715
+ }
716
+ }
717
+ } else {
718
+ const targetRowIndex = navDirection === "up" ? currentRowIndex - 1 : currentRowIndex + 1;
719
+ if (targetRowIndex >= 0 && targetRowIndex < rowsList.length) {
720
+ const targetRow = rowsList[targetRowIndex];
721
+ if (targetRow) {
722
+ const targetCells = targetRow.getVisibleCells();
723
+ const targetCellIdx = targetCells.findIndex((c) => c.column.id === cell.column.id);
724
+ let effectiveTargetCell = targetCellIdx !== -1 ? targetCells[targetCellIdx] ?? null : null;
725
+ let resolvedCellIdx = targetCellIdx;
726
+ if (effectiveTargetCell && !isCellEditable(targetRow, effectiveTargetCell)) {
727
+ const fallback = findEditableInRow(targetRow, targetCellIdx, "previous");
728
+ effectiveTargetCell = fallback?.cell ?? null;
729
+ resolvedCellIdx = fallback?.index ?? targetCellIdx;
730
+ }
731
+ if (effectiveTargetCell) {
732
+ nextTick(() => {
733
+ startEditing(targetRow, effectiveTargetCell, void 0, {
734
+ rowIndex: targetRowIndex,
735
+ cellIndex: resolvedCellIdx
736
+ });
737
+ isNavigating.value = false;
738
+ });
739
+ return;
740
+ }
741
+ }
742
+ }
743
+ }
744
+ editingCell.value = null;
745
+ editingValue.value = null;
746
+ isNavigating.value = false;
747
+ hasAttemptedClickAway.value = false;
748
+ if (shouldRestoreFocus) {
749
+ restoreFocus(row, cell);
750
+ }
751
+ return;
752
+ } else if (navDirection === "next" || navDirection === "previous") {
753
+ let targetCellInfo = null;
754
+ let targetRow = row;
755
+ let targetRowIndex = currentRowIndex;
756
+ if (navDirection === "next") {
757
+ targetCellInfo = findEditableInRow(row, currentCellIndex, "next");
758
+ if (!targetCellInfo && currentRowIndex < rowsList.length - 1) {
759
+ for (let r = currentRowIndex + 1; r < rowsList.length; r++) {
760
+ const candidateRow = rowsList[r];
761
+ if (!candidateRow) continue;
762
+ const candidateCellInfo = findEditableInRow(candidateRow, -1, "next");
763
+ if (candidateCellInfo) {
764
+ targetRow = candidateRow;
765
+ targetRowIndex = r;
766
+ targetCellInfo = candidateCellInfo;
767
+ break;
768
+ }
769
+ }
770
+ }
771
+ } else {
772
+ targetCellInfo = findEditableInRow(row, currentCellIndex, "previous");
773
+ if (!targetCellInfo && currentRowIndex > 0) {
774
+ for (let r = currentRowIndex - 1; r >= 0; r--) {
775
+ const candidateRow = rowsList[r];
776
+ if (!candidateRow) continue;
777
+ const cells = candidateRow.getVisibleCells();
778
+ const candidateCellInfo = findEditableInRow(candidateRow, cells.length, "previous");
779
+ if (candidateCellInfo) {
780
+ targetRow = candidateRow;
781
+ targetRowIndex = r;
782
+ targetCellInfo = candidateCellInfo;
783
+ break;
784
+ }
785
+ }
786
+ }
787
+ }
788
+ if (targetCellInfo) {
789
+ nextTick(() => {
790
+ startEditing(targetRow, targetCellInfo.cell, void 0, {
791
+ rowIndex: targetRowIndex,
792
+ cellIndex: targetCellInfo.index
793
+ });
794
+ isNavigating.value = false;
795
+ });
796
+ return;
797
+ }
798
+ editingCell.value = null;
799
+ editingValue.value = null;
800
+ isNavigating.value = false;
801
+ hasAttemptedClickAway.value = false;
802
+ if (shouldRestoreFocus) {
803
+ restoreFocus(row, cell);
804
+ }
805
+ return;
806
+ }
807
+ }
808
+ if (shouldFocusNewAddRowAfterFinalize && !navDirection) {
809
+ nextTick(() => {
810
+ const nextRowsList = navigableRows?.value ?? rows.value;
811
+ const newAddRow = groupIdToFocus ? nextRowsList.find(
812
+ (r) => addRowContext?.isAddRowRow(r) && r.parentId === groupIdToFocus
813
+ ) : nextRowsList.find((r) => addRowContext?.isAddRowRow(r));
814
+ if (newAddRow) {
815
+ const firstEditableCell = newAddRow.getVisibleCells().find((c) => isCellEditable(newAddRow, c));
816
+ if (firstEditableCell) {
817
+ startEditing(newAddRow, firstEditableCell);
818
+ return;
819
+ }
820
+ }
821
+ editingCell.value = null;
822
+ editingValue.value = null;
823
+ hasAttemptedClickAway.value = false;
824
+ if (shouldRestoreFocus) {
825
+ restoreFocus(row, cell);
826
+ }
827
+ });
828
+ return;
829
+ }
830
+ editingCell.value = null;
831
+ editingValue.value = null;
832
+ hasAttemptedClickAway.value = false;
833
+ if (shouldRestoreFocus) {
834
+ restoreFocus(row, cell);
835
+ }
836
+ }
837
+ function restoreFocus(row, cell) {
838
+ nextTick(() => {
839
+ const rowsList = navigableRows?.value ?? rows.value;
840
+ const rowIndex = rowsList.findIndex((r) => r.id === row.id);
841
+ const cellIndex = row.getVisibleCells().findIndex((c) => c.id === cell.id);
842
+ if (rowIndex === -1) {
843
+ return;
844
+ }
845
+ if (rowIndex !== -1 && cellIndex !== -1) {
846
+ const currentSuppressOutline = focusFns.focusedCell.value?.suppressOutline;
847
+ focusFns.focusedCell.value = {
848
+ rowIndex,
849
+ columnIndex: cellIndex,
850
+ ...currentSuppressOutline && { suppressOutline: true }
851
+ };
852
+ focusFns.focusCell(row, rowIndex, cellIndex);
853
+ }
854
+ });
855
+ }
856
+ const getCurrentEditingContext = () => {
857
+ if (!editingCell.value) return null;
858
+ const rowsList = navigableRows?.value ?? rows.value;
859
+ const currentRow = rowsList.find((r) => r.id === editingCell.value.rowId);
860
+ if (!currentRow) return null;
861
+ const currentCell = currentRow.getAllCells().find((c) => c.column.id === editingCell.value.columnId);
862
+ if (!currentCell) return null;
863
+ return { row: currentRow, cell: currentCell };
864
+ };
865
+ function createEditorContext(cell, row) {
866
+ return {
867
+ cell,
868
+ row,
869
+ getValue: () => editingValue.value,
870
+ setValue: (value) => {
871
+ editingValue.value = value;
872
+ },
873
+ stopEditing: (moveDirection) => {
874
+ const ctx = getCurrentEditingContext();
875
+ if (ctx) {
876
+ stopEditing(ctx.row, ctx.cell, editingValue.value, moveDirection);
877
+ }
878
+ },
879
+ table: tableApi,
880
+ column: cell.column
881
+ };
882
+ }
883
+ function createDefaultEditor(cell, row) {
884
+ const columnDef = cell.column.columnDef;
885
+ const defined = columnDef.cellDataType;
886
+ let cellDataType = defined || "text";
887
+ if (!defined || defined === "text") {
888
+ if (columnDef.wrapText === true) {
889
+ cellDataType = "textarea";
890
+ } else {
891
+ const value = cell.getValue();
892
+ if (typeof value === "string" && value.includes("\n")) {
893
+ cellDataType = "textarea";
894
+ }
895
+ }
896
+ }
897
+ if (props.editing?.defaultEditors?.[cellDataType]) {
898
+ const customEditor = props.editing.defaultEditors[cellDataType];
899
+ if (customEditor) {
900
+ const context2 = createEditorContext(cell, row);
901
+ return renderEditor(customEditor, context2);
902
+ }
903
+ }
904
+ const cellTypeEditor = typeRegistry.getDefaultEditor(cellDataType);
905
+ const EditorComponent = cellTypeEditor ?? textCellType.editor;
906
+ if (!EditorComponent) {
907
+ console.warn(
908
+ `[NuGrid] No editor registered for cellDataType "${cellDataType}". Rendering skipped.`
909
+ );
910
+ return null;
911
+ }
912
+ const context = createEditorContext(cell, row);
913
+ return renderEditor(EditorComponent, context);
914
+ }
915
+ function renderCellContent(cell, row) {
916
+ const columnDef = cell.column.columnDef;
917
+ const isEditing = isEditingCell(row, cell.column.id);
918
+ if (isEditing) {
919
+ if (columnDef.editor) {
920
+ const context = {
921
+ cell,
922
+ row,
923
+ getValue: () => editingValue.value,
924
+ setValue: (value) => {
925
+ editingValue.value = value;
926
+ },
927
+ stopEditing: (moveDirection) => {
928
+ if (!editingCell.value) return;
929
+ const rowsList = navigableRows?.value ?? rows.value;
930
+ const currentRow = rowsList.find((r) => r.id === editingCell.value.rowId);
931
+ if (!currentRow) return;
932
+ const currentCell = currentRow.getAllCells().find((c) => c.column.id === editingCell.value.columnId);
933
+ if (!currentCell) return;
934
+ if (moveDirection) {
935
+ stopEditing(currentRow, currentCell, editingValue.value, moveDirection);
936
+ } else {
937
+ stopEditing(currentRow, currentCell, editingValue.value);
938
+ }
939
+ },
940
+ table: tableApi,
941
+ column: cell.column
942
+ };
943
+ return renderEditor(columnDef.editor, context);
944
+ }
945
+ return createDefaultEditor(cell, row);
946
+ }
947
+ return h(FlexRender, {
948
+ render: cell.column.columnDef.cell,
949
+ props: cell.getContext()
950
+ });
951
+ }
952
+ function handleValidationFailure(config, isClickAway) {
953
+ if (isRowLevelValidationError.value && isClickAway) {
954
+ if (config.validateOn === "reward") {
955
+ hasBeenPunished.value = true;
956
+ }
957
+ editingCell.value = null;
958
+ editingValue.value = null;
959
+ return true;
960
+ }
961
+ if (isClickAway) {
962
+ if (!hasAttemptedClickAway.value) {
963
+ hasAttemptedClickAway.value = true;
964
+ if (config.validateOn === "reward") {
965
+ hasBeenPunished.value = true;
966
+ }
967
+ shouldFocusEditor.value = false;
968
+ nextTick(() => {
969
+ shouldFocusEditor.value = true;
970
+ });
971
+ return true;
972
+ }
973
+ editingCell.value = null;
974
+ editingValue.value = null;
975
+ validationError.value = null;
976
+ hasBeenPunished.value = false;
977
+ hasAttemptedClickAway.value = false;
978
+ return true;
979
+ }
980
+ if (config.validateOn === "reward") {
981
+ hasBeenPunished.value = true;
982
+ }
983
+ shouldFocusEditor.value = true;
984
+ return true;
985
+ }
986
+ function onCellClick(event, row, cell) {
987
+ if (hasAttemptedClickAway.value) {
988
+ return;
989
+ }
990
+ if (startClicks.value === "single") {
991
+ event.stopPropagation();
992
+ startEditing(row, cell);
993
+ }
994
+ }
995
+ function onCellDoubleClick(event, row, cell) {
996
+ if (hasAttemptedClickAway.value) {
997
+ return;
998
+ }
999
+ if (startClicks.value === "double") {
1000
+ event.stopPropagation();
1001
+ startEditing(row, cell);
1002
+ }
1003
+ }
1004
+ if (interactionRouter) {
1005
+ unregisterInteraction = interactionRouter.registerCellClickHandler({
1006
+ id: "cell-editing",
1007
+ priority: 20,
1008
+ handle: ({ event, row, cell }) => {
1009
+ if (event.__addRowCellTransition) {
1010
+ if (focusFns.focusedCell.value) {
1011
+ focusFns.focusedCell.value = {
1012
+ ...focusFns.focusedCell.value,
1013
+ suppressOutline: true
1014
+ };
1015
+ }
1016
+ const ctx = getCurrentEditingContext();
1017
+ if (ctx) {
1018
+ stopEditing(ctx.row, ctx.cell, editingValue.value, void 0, {
1019
+ restoreFocus: false
1020
+ });
1021
+ }
1022
+ startEditing(row, cell);
1023
+ return { handled: false };
1024
+ }
1025
+ onCellClick(event, row, cell);
1026
+ return { handled: event.defaultPrevented || event.cancelBubble };
1027
+ }
1028
+ });
1029
+ unregisterDoubleClick = interactionRouter.registerCellDoubleClickHandler({
1030
+ id: "cell-editing-dblclick",
1031
+ priority: 20,
1032
+ handle: ({ event, row, cell }) => {
1033
+ onCellDoubleClick(event, row, cell);
1034
+ return { handled: event.defaultPrevented || event.cancelBubble };
1035
+ }
1036
+ });
1037
+ }
1038
+ function onCellKeyDown(event, row, cell, cellIndex) {
1039
+ const isEditing = isEditingCell(row, cell.column.id);
1040
+ const columnDef = cell.column.columnDef;
1041
+ const cellDataType = columnDef.cellDataType || "text";
1042
+ const isFocused = focusFns.shouldCellHandleKeydown(row, cellIndex);
1043
+ const canEdit = isCellEditable(row, cell);
1044
+ if (!isEditing) {
1045
+ const keyboardHandler = typeRegistry.getKeyboardHandler(cellDataType);
1046
+ if (keyboardHandler) {
1047
+ const pluginContext = {
1048
+ cell,
1049
+ row,
1050
+ columnDef,
1051
+ column: cell.column,
1052
+ getValue: () => cell.getValue(),
1053
+ isFocused,
1054
+ canEdit,
1055
+ data: data.value,
1056
+ tableApi,
1057
+ startEditing: (initialValue) => startEditing(row, cell, initialValue),
1058
+ stopEditing: (newValue, moveDirection) => {
1059
+ stopEditing(row, cell, newValue, moveDirection);
1060
+ },
1061
+ emitChange: (oldValue, newValue) => {
1062
+ emit({
1063
+ row,
1064
+ column: cell.column,
1065
+ oldValue,
1066
+ newValue
1067
+ });
1068
+ }
1069
+ };
1070
+ const result = keyboardHandler(event, pluginContext);
1071
+ if (result.handled) {
1072
+ if (result.preventDefault) {
1073
+ event.preventDefault();
1074
+ }
1075
+ if (result.stopPropagation) {
1076
+ event.stopPropagation();
1077
+ }
1078
+ return;
1079
+ }
1080
+ }
1081
+ }
1082
+ if (isEditing) {
1083
+ event.stopPropagation();
1084
+ return;
1085
+ }
1086
+ const enabledKeys = startKeys.value === "all" ? ["enter", "f2", "bs", "alpha", "numeric"] : startKeys.value === "minimal" ? ["enter", "f2"] : startKeys.value === "none" ? [] : startKeys.value;
1087
+ const noKeysEnabled = enabledKeys.length === 0;
1088
+ if (!isEditing && isFocused && canEdit && !noKeysEnabled) {
1089
+ if (event.key === "F2" && enabledKeys.includes("f2")) {
1090
+ event.preventDefault();
1091
+ event.stopPropagation();
1092
+ startEditing(row, cell);
1093
+ return;
1094
+ }
1095
+ if ((event.key === "Backspace" || event.key === "Delete") && enabledKeys.includes("bs")) {
1096
+ event.preventDefault();
1097
+ event.stopPropagation();
1098
+ startEditing(row, cell, "");
1099
+ return;
1100
+ }
1101
+ if (event.key === "Enter" && enabledKeys.includes("enter")) {
1102
+ event.preventDefault();
1103
+ event.stopPropagation();
1104
+ startEditing(row, cell);
1105
+ return;
1106
+ }
1107
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && event.key !== " ") {
1108
+ const isAlpha = /[a-z]/i.test(event.key);
1109
+ const isNumeric = /\d/.test(event.key);
1110
+ if (isAlpha && enabledKeys.includes("alpha") || isNumeric && enabledKeys.includes("numeric")) {
1111
+ event.preventDefault();
1112
+ event.stopPropagation();
1113
+ startEditing(row, cell, event.key);
1114
+ return;
1115
+ }
1116
+ }
1117
+ }
1118
+ if (isFocused) {
1119
+ focusFns.onCellKeyDown(event);
1120
+ }
1121
+ }
1122
+ const handleClickOutside = (event) => {
1123
+ if (!editingCell.value) return;
1124
+ if (event.__addRowCellTransition) {
1125
+ return;
1126
+ }
1127
+ if (event.__addRowFinalizing) {
1128
+ return;
1129
+ }
1130
+ const target = event.target;
1131
+ const isInsideUIOverlay = target.closest(
1132
+ '[role="menu"], [role="listbox"], [role="dialog"], .headlessui-portal-root, [data-headlessui-portal]'
1133
+ );
1134
+ if (isInsideUIOverlay) {
1135
+ return;
1136
+ }
1137
+ const isClickInsideGrid = Boolean(tableRef.value && tableRef.value.contains(target));
1138
+ if (tableRef.value && editingCell.value) {
1139
+ const rowsList = navigableRows?.value ?? rows.value;
1140
+ const currentRow = rowsList.find((r) => r.id === editingCell.value.rowId);
1141
+ if (!currentRow) return;
1142
+ const cellIndex = currentRow.getVisibleCells().findIndex((c) => c.column.id === editingCell.value.columnId);
1143
+ if (cellIndex === -1) return;
1144
+ const selector = cellSelector.replace("$COL", String(cellIndex)).replace("$ID", currentRow.id);
1145
+ const editingCellElement = tableRef.value.querySelector(selector);
1146
+ if (editingCellElement && !editingCellElement.contains(target)) {
1147
+ const currentCell = currentRow.getAllCells().find((c) => c.column.id === editingCell.value.columnId);
1148
+ if (currentCell) {
1149
+ const isAddRow = addRowContext?.isAddRowRow(currentRow);
1150
+ if (isAddRow && addRowContext) {
1151
+ addRowContext.resetAddRow(currentRow);
1152
+ editingCell.value = null;
1153
+ editingValue.value = null;
1154
+ validationError.value = null;
1155
+ hasBeenPunished.value = false;
1156
+ hasAttemptedClickAway.value = false;
1157
+ if (isClickInsideGrid) {
1158
+ focusFns.gridHasFocus.value = true;
1159
+ if (focusFns.focusedCell.value) {
1160
+ focusFns.focusedCell.value = {
1161
+ ...focusFns.focusedCell.value,
1162
+ columnIndex: -1
1163
+ };
1164
+ }
1165
+ } else {
1166
+ focusFns.focusedCell.value = null;
1167
+ }
1168
+ return;
1169
+ }
1170
+ if (isClickInsideGrid) {
1171
+ focusFns.gridHasFocus.value = true;
1172
+ if (focusFns.focusedCell.value) {
1173
+ focusFns.focusedCell.value = {
1174
+ ...focusFns.focusedCell.value,
1175
+ columnIndex: -1
1176
+ };
1177
+ }
1178
+ }
1179
+ stopEditing(currentRow, currentCell, editingValue.value, void 0, {
1180
+ restoreFocus: !isClickInsideGrid,
1181
+ isClickAway: isClickInsideGrid
1182
+ // Signal this is a click-away attempt
1183
+ });
1184
+ }
1185
+ }
1186
+ }
1187
+ };
1188
+ if (interactionRouter) {
1189
+ unregisterOutsidePointer = interactionRouter.registerGlobalPointerHandler({
1190
+ id: "cell-editing-outside",
1191
+ priority: 25,
1192
+ handle: ({ event }) => {
1193
+ handleClickOutside(event);
1194
+ return { handled: false };
1195
+ }
1196
+ });
1197
+ } else if (typeof document !== "undefined") {
1198
+ const listener = (event) => handleClickOutside(event);
1199
+ onMounted(() => document.addEventListener("mousedown", listener));
1200
+ unregisterOutsidePointer = () => {
1201
+ document.removeEventListener("mousedown", listener);
1202
+ };
1203
+ }
1204
+ onUnmounted(() => {
1205
+ if (unregisterInteraction) {
1206
+ unregisterInteraction();
1207
+ unregisterInteraction = null;
1208
+ }
1209
+ if (unregisterDoubleClick) {
1210
+ unregisterDoubleClick();
1211
+ unregisterDoubleClick = null;
1212
+ }
1213
+ if (unregisterOutsidePointer) {
1214
+ unregisterOutsidePointer();
1215
+ unregisterOutsidePointer = null;
1216
+ }
1217
+ });
1218
+ return {
1219
+ editingCell,
1220
+ editingValue,
1221
+ isNavigating,
1222
+ shouldFocusEditor,
1223
+ validationError,
1224
+ showValidationErrors,
1225
+ validationIcon,
1226
+ startClicks,
1227
+ // Row validation
1228
+ rowValidationErrors,
1229
+ hasRowValidationError,
1230
+ hasCellValidationError,
1231
+ getRowValidationError,
1232
+ // Cell editing functions
1233
+ isEditingCell,
1234
+ isCellEditable,
1235
+ startEditing,
1236
+ stopEditing,
1237
+ createDefaultEditor,
1238
+ renderCellContent,
1239
+ onCellClick,
1240
+ onCellDoubleClick,
1241
+ onCellKeyDown
1242
+ };
1243
+ }