@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,1378 @@
1
+ import { useElementSize } from "@vueuse/core";
2
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
3
+ import { usePropWithDefault } from "../../config/_internal/index.js";
4
+ import { useNuGridKeyboardNavigation } from "./useNuGridKeyboardNavigation.js";
5
+ import { useNuGridScroll } from "./useNuGridScroll.js";
6
+ export function useNuGridFocus(props, tableApi, rows, navigableRows, tableRef, rootRef, virtualizedStickyHeight, virtualizer, editingCell, interactionRouter, eventEmitter, focusedRowIdModel) {
7
+ const focusMode = usePropWithDefault(props, "focus", "mode");
8
+ const retainFocus = usePropWithDefault(props, "focus", "retain");
9
+ const cmdArrows = usePropWithDefault(props, "focus", "cmdArrows");
10
+ const alignOnModel = usePropWithDefault(props, "focus", "alignOnModel");
11
+ const enableEditing = usePropWithDefault(props, "editing", "enabled");
12
+ const rowSelectionMode = computed(() => props.selection ?? false);
13
+ const focusedCell = ref(null);
14
+ const gridHasFocus = ref(false);
15
+ let pointerDownInsideGrid = false;
16
+ let isUpdatingFromModel = false;
17
+ let isUpdatingToModel = false;
18
+ const resolvedRows = computed(() => navigableRows?.value ?? rows.value);
19
+ function setFocusedCell(newValue, options) {
20
+ const oldValue = focusedCell.value;
21
+ focusedCell.value = newValue;
22
+ if (focusedRowIdModel && !isUpdatingFromModel) {
23
+ const currentRows = resolvedRows.value;
24
+ const newRowIndex2 = newValue?.rowIndex ?? null;
25
+ const row = newRowIndex2 !== null && newRowIndex2 >= 0 ? currentRows[newRowIndex2] ?? null : null;
26
+ const newRowId = row?.id ?? null;
27
+ if (focusedRowIdModel.value !== newRowId) {
28
+ isUpdatingToModel = true;
29
+ focusedRowIdModel.value = newRowId;
30
+ nextTick(() => {
31
+ isUpdatingToModel = false;
32
+ });
33
+ }
34
+ }
35
+ if (options?.suppressEvents) return;
36
+ const oldRowIndex = oldValue?.rowIndex ?? null;
37
+ const newRowIndex = newValue?.rowIndex ?? null;
38
+ const oldColumnIndex = oldValue?.columnIndex ?? null;
39
+ const newColumnIndex = newValue?.columnIndex ?? null;
40
+ if (eventEmitter?.focusedCellChanged && (oldRowIndex !== newRowIndex || oldColumnIndex !== newColumnIndex)) {
41
+ const currentRows = resolvedRows.value;
42
+ const columns = tableApi.getAllLeafColumns();
43
+ const row = newRowIndex !== null && newRowIndex >= 0 ? currentRows[newRowIndex] ?? null : null;
44
+ const column = newColumnIndex !== null && newColumnIndex >= 0 ? columns[newColumnIndex] ?? null : null;
45
+ eventEmitter.focusedCellChanged({
46
+ rowId: row?.id ?? null,
47
+ columnId: column?.id ?? null,
48
+ rowIndex: newRowIndex ?? -1,
49
+ columnIndex: newColumnIndex ?? -1,
50
+ row,
51
+ column,
52
+ previousRowIndex: oldRowIndex,
53
+ previousColumnIndex: oldColumnIndex
54
+ });
55
+ }
56
+ if (eventEmitter?.focusedRowChanged && oldRowIndex !== newRowIndex) {
57
+ const currentRows = resolvedRows.value;
58
+ const row = newRowIndex !== null && newRowIndex >= 0 ? currentRows[newRowIndex] ?? null : null;
59
+ const previousRow = oldRowIndex !== null && oldRowIndex >= 0 ? currentRows[oldRowIndex] ?? null : null;
60
+ eventEmitter.focusedRowChanged({
61
+ rowId: row?.id ?? null,
62
+ rowIndex: newRowIndex ?? -1,
63
+ row,
64
+ previousRowIndex: oldRowIndex,
65
+ previousRow
66
+ });
67
+ }
68
+ }
69
+ const cellSelector = '[data-row-id="$ID"] [data-cell-index="$COL"]';
70
+ const rowSelector = '[data-row-id="$ID"]';
71
+ const rowHeightEstimate = ref(80);
72
+ const containerHeight = ref(0);
73
+ let unregisterInteraction = null;
74
+ let unregisterRetainFocus = null;
75
+ const rowElementCache = /* @__PURE__ */ new Map();
76
+ const cellElementCache = /* @__PURE__ */ new Map();
77
+ let processingTimer = null;
78
+ function clearElementCaches() {
79
+ rowElementCache.clear();
80
+ cellElementCache.clear();
81
+ }
82
+ const rootElement = computed(() => {
83
+ if (!rootRef?.value) {
84
+ return null;
85
+ }
86
+ return rootRef.value.$el ?? null;
87
+ });
88
+ const {
89
+ scrollManager,
90
+ visibleColumns,
91
+ verticalScrollContainer,
92
+ horizontalScrollContainer,
93
+ updateScrollContainerCache
94
+ } = useNuGridScroll(tableApi, rootRef);
95
+ const { height: observedHeight } = useElementSize(rootElement, void 0, { box: "border-box" });
96
+ watch(observedHeight, (height) => {
97
+ if (typeof height === "number" && !Number.isNaN(height)) {
98
+ containerHeight.value = height;
99
+ updateScrollContainerCache();
100
+ }
101
+ });
102
+ const resolveStickyHeight = (tableElement) => {
103
+ const virtualHeight = virtualizedStickyHeight?.value;
104
+ if (typeof virtualHeight === "number" && virtualHeight > 0) {
105
+ return virtualHeight;
106
+ }
107
+ const targetTable = tableElement ?? tableRef.value;
108
+ if (!targetTable) {
109
+ return 0;
110
+ }
111
+ return scrollManager.getStickyHeaderHeight(targetTable);
112
+ };
113
+ const viewportRowsPerPage = computed(() => {
114
+ const estimatedHeight = Math.max(rowHeightEstimate.value, 1);
115
+ const stickyHeight = resolveStickyHeight();
116
+ const vScrollContainer = verticalScrollContainer.value;
117
+ const effectiveHeight = vScrollContainer?.clientHeight ?? containerHeight.value;
118
+ if (effectiveHeight > 0) {
119
+ const visibleHeight = Math.max(0, effectiveHeight - stickyHeight);
120
+ return Math.max(1, Math.round(visibleHeight / estimatedHeight));
121
+ }
122
+ return Math.max(1, Math.round(600 / estimatedHeight));
123
+ });
124
+ if (virtualizer) {
125
+ watch(
126
+ () => virtualizer.value?.props.value.estimateSize,
127
+ (estimate) => {
128
+ if (typeof estimate === "number" && estimate > 0) {
129
+ rowHeightEstimate.value = estimate;
130
+ }
131
+ },
132
+ { immediate: true }
133
+ );
134
+ }
135
+ const allRows = computed(() => rows.value);
136
+ function startProcessingLock(duration = 200) {
137
+ scrollManager.setProcessing(true);
138
+ if (processingTimer) clearTimeout(processingTimer);
139
+ processingTimer = setTimeout(() => {
140
+ scrollManager.setProcessing(false);
141
+ processingTimer = null;
142
+ }, duration);
143
+ }
144
+ function stopProcessingLock() {
145
+ if (processingTimer) {
146
+ clearTimeout(processingTimer);
147
+ processingTimer = null;
148
+ }
149
+ scrollManager.setProcessing(false);
150
+ }
151
+ const keyboardNav = useNuGridKeyboardNavigation(props, tableApi);
152
+ const {
153
+ multiRowEnabled,
154
+ multiRowCount,
155
+ getVisualRowForColumn,
156
+ getColumnsInVisualRow,
157
+ findColumnInVisualRow
158
+ } = keyboardNav;
159
+ function isWithinAriaHidden(element) {
160
+ return Boolean(element.closest('[aria-hidden="true"]'));
161
+ }
162
+ let ariaHiddenObserver = null;
163
+ onMounted(() => {
164
+ const nuxtEl = document.getElementById("__nuxt");
165
+ if (nuxtEl && typeof MutationObserver !== "undefined") {
166
+ ariaHiddenObserver = new MutationObserver((mutations) => {
167
+ for (const mutation of mutations) {
168
+ if (mutation.type === "attributes" && mutation.attributeName === "aria-hidden") {
169
+ const isHidden = nuxtEl.getAttribute("aria-hidden") === "true";
170
+ if (isHidden && document.activeElement) {
171
+ const activeEl = document.activeElement;
172
+ if (activeEl && typeof activeEl.blur === "function") {
173
+ activeEl.blur();
174
+ }
175
+ }
176
+ }
177
+ }
178
+ });
179
+ ariaHiddenObserver.observe(nuxtEl, {
180
+ attributes: true,
181
+ attributeFilter: ["aria-hidden"]
182
+ });
183
+ }
184
+ });
185
+ onUnmounted(() => {
186
+ if (ariaHiddenObserver) {
187
+ ariaHiddenObserver.disconnect();
188
+ ariaHiddenObserver = null;
189
+ }
190
+ if (unregisterRetainFocus) {
191
+ unregisterRetainFocus();
192
+ unregisterRetainFocus = null;
193
+ }
194
+ if (unregisterInteraction) {
195
+ unregisterInteraction();
196
+ unregisterInteraction = null;
197
+ }
198
+ gridHasFocus.value = false;
199
+ clearElementCaches();
200
+ });
201
+ watch(
202
+ () => tableRef.value,
203
+ () => {
204
+ clearElementCaches();
205
+ }
206
+ );
207
+ function getRootElement() {
208
+ return rootElement.value;
209
+ }
210
+ function handleRootFocusIn(event) {
211
+ if (pointerDownInsideGrid) {
212
+ return;
213
+ }
214
+ const target = event.target;
215
+ if (isGridCellOrRow(target)) {
216
+ gridHasFocus.value = true;
217
+ }
218
+ }
219
+ function isGridCellOrRow(element) {
220
+ if (!element) return false;
221
+ if (element.closest("[data-cell-index]") !== null) {
222
+ return true;
223
+ }
224
+ if (element.closest("[data-row-id]") !== null) {
225
+ return true;
226
+ }
227
+ return false;
228
+ }
229
+ function handleRootFocusOut(event) {
230
+ if (retainFocus.value) {
231
+ return;
232
+ }
233
+ if (pointerDownInsideGrid) {
234
+ return;
235
+ }
236
+ const rootEl = getRootElement();
237
+ if (!rootEl) {
238
+ gridHasFocus.value = false;
239
+ return;
240
+ }
241
+ const nextTarget = event.relatedTarget;
242
+ if (!nextTarget || !rootEl.contains(nextTarget)) {
243
+ requestAnimationFrame(() => {
244
+ if (!pointerDownInsideGrid && !rootEl.contains(document.activeElement)) {
245
+ gridHasFocus.value = false;
246
+ }
247
+ });
248
+ return;
249
+ }
250
+ if (!isGridCellOrRow(nextTarget)) {
251
+ gridHasFocus.value = false;
252
+ }
253
+ }
254
+ function handlePointerDownInside() {
255
+ pointerDownInsideGrid = true;
256
+ }
257
+ function handlePointerUpOutside() {
258
+ pointerDownInsideGrid = false;
259
+ }
260
+ function handleClickOutside(event) {
261
+ if (!retainFocus.value || focusMode.value === "none") {
262
+ return;
263
+ }
264
+ const rootEl = getRootElement();
265
+ if (!rootEl) {
266
+ return;
267
+ }
268
+ const target = event.target;
269
+ if (target && !rootEl.contains(target)) {
270
+ const isInteractive = target instanceof HTMLElement && (target.closest("input") || target.closest("textarea") || target.closest("select") || target.closest("button") || target.closest("a") || target.isContentEditable);
271
+ if (isInteractive) {
272
+ return;
273
+ }
274
+ const rowsList = resolvedRows.value;
275
+ if (rowsList.length === 0) {
276
+ return;
277
+ }
278
+ if (focusedCell.value) {
279
+ const row = rowsList[focusedCell.value.rowIndex];
280
+ if (row) {
281
+ nextTick(() => {
282
+ focusCell(row, focusedCell.value.rowIndex, focusedCell.value.columnIndex);
283
+ });
284
+ }
285
+ } else {
286
+ const firstRow = rowsList[0];
287
+ if (firstRow) {
288
+ const firstFocusableColumn = findFirstFocusableColumn(firstRow);
289
+ nextTick(() => {
290
+ setFocusedCell({ rowIndex: 0, columnIndex: firstFocusableColumn });
291
+ focusCell(firstRow, 0, firstFocusableColumn);
292
+ });
293
+ }
294
+ }
295
+ }
296
+ }
297
+ watch(
298
+ () => rootRef?.value,
299
+ (primitive, _, onCleanup) => {
300
+ const rootEl = primitive?.$el;
301
+ if (!rootEl) {
302
+ gridHasFocus.value = false;
303
+ return;
304
+ }
305
+ rootEl.addEventListener("focusin", handleRootFocusIn);
306
+ rootEl.addEventListener("focusout", handleRootFocusOut);
307
+ rootEl.addEventListener("pointerdown", handlePointerDownInside, true);
308
+ if (typeof window !== "undefined") {
309
+ window.addEventListener("pointerup", handlePointerUpOutside);
310
+ window.addEventListener("pointercancel", handlePointerUpOutside);
311
+ }
312
+ onCleanup(() => {
313
+ rootEl.removeEventListener("focusin", handleRootFocusIn);
314
+ rootEl.removeEventListener("focusout", handleRootFocusOut);
315
+ rootEl.removeEventListener("pointerdown", handlePointerDownInside, true);
316
+ if (typeof window !== "undefined") {
317
+ window.removeEventListener("pointerup", handlePointerUpOutside);
318
+ window.removeEventListener("pointercancel", handlePointerUpOutside);
319
+ }
320
+ });
321
+ },
322
+ { immediate: true }
323
+ );
324
+ watch(
325
+ () => retainFocus.value,
326
+ (enabled) => {
327
+ if (unregisterRetainFocus) {
328
+ unregisterRetainFocus();
329
+ unregisterRetainFocus = null;
330
+ }
331
+ if (enabled && interactionRouter) {
332
+ unregisterRetainFocus = interactionRouter.registerGlobalPointerHandler({
333
+ id: "focus-retain",
334
+ priority: 5,
335
+ handle: ({ event }) => {
336
+ handleClickOutside(event);
337
+ return { handled: false };
338
+ }
339
+ });
340
+ }
341
+ if (enabled && !interactionRouter && typeof document !== "undefined") {
342
+ document.addEventListener("click", handleClickOutside, true);
343
+ unregisterRetainFocus = () => {
344
+ document.removeEventListener("click", handleClickOutside, true);
345
+ };
346
+ }
347
+ },
348
+ { immediate: true }
349
+ );
350
+ const rowIdToIndexMap = ref(/* @__PURE__ */ new Map());
351
+ watch(
352
+ [resolvedRows, allRows],
353
+ ([currentRows, fullRows]) => {
354
+ const map = rowIdToIndexMap.value;
355
+ map.clear();
356
+ const isGroupedGrid = currentRows !== fullRows;
357
+ const sourceRows = isGroupedGrid ? currentRows : fullRows?.length ? fullRows : currentRows;
358
+ sourceRows?.forEach((row, arrayIndex) => {
359
+ if (row.getIsGrouped?.()) {
360
+ return;
361
+ }
362
+ map.set(row.id, arrayIndex);
363
+ });
364
+ for (const rowId of [...rowElementCache.keys()]) {
365
+ if (!map.has(rowId)) {
366
+ rowElementCache.delete(rowId);
367
+ }
368
+ }
369
+ for (const rowId of [...cellElementCache.keys()]) {
370
+ if (!map.has(rowId)) {
371
+ cellElementCache.delete(rowId);
372
+ }
373
+ }
374
+ },
375
+ { immediate: true }
376
+ );
377
+ function getRowIndex(row) {
378
+ const index = rowIdToIndexMap.value.get(row.id);
379
+ return index !== void 0 ? index : -1;
380
+ }
381
+ function getRowIndexById(rowId) {
382
+ if (!rowId) return -1;
383
+ const index = rowIdToIndexMap.value.get(rowId);
384
+ return index !== void 0 ? index : -1;
385
+ }
386
+ function cacheRowElement(rowId, element) {
387
+ if (!element || !element.isConnected) {
388
+ rowElementCache.delete(rowId);
389
+ return;
390
+ }
391
+ rowElementCache.set(rowId, element);
392
+ }
393
+ function cacheCellElement(rowId, columnIndex, element) {
394
+ if (!element || !element.isConnected) {
395
+ const rowMap2 = cellElementCache.get(rowId);
396
+ if (rowMap2) {
397
+ rowMap2.delete(columnIndex);
398
+ if (rowMap2.size === 0) {
399
+ cellElementCache.delete(rowId);
400
+ }
401
+ }
402
+ return;
403
+ }
404
+ let rowMap = cellElementCache.get(rowId);
405
+ if (!rowMap) {
406
+ rowMap = /* @__PURE__ */ new Map();
407
+ cellElementCache.set(rowId, rowMap);
408
+ }
409
+ rowMap.set(columnIndex, element);
410
+ }
411
+ function resolveCellSelector(rowId, columnIndex) {
412
+ return cellSelector.replace("$COL", String(columnIndex)).replace("$ID", rowId);
413
+ }
414
+ function resolveRowSelector(rowId) {
415
+ return rowSelector.replace("$ID", rowId);
416
+ }
417
+ function getRowElement(rowId) {
418
+ const cached = rowElementCache.get(rowId);
419
+ if (cached?.isConnected) {
420
+ return cached;
421
+ }
422
+ const element = tableRef.value?.querySelector(resolveRowSelector(rowId));
423
+ cacheRowElement(rowId, element);
424
+ return element;
425
+ }
426
+ function getCellElement(rowId, columnIndex) {
427
+ const rowMap = cellElementCache.get(rowId);
428
+ const cached = rowMap?.get(columnIndex);
429
+ if (cached?.isConnected) {
430
+ return cached;
431
+ }
432
+ const rowElement = getRowElement(rowId);
433
+ if (rowElement) {
434
+ const cellElement = rowElement.querySelector(
435
+ `[data-cell-index="${columnIndex}"]`
436
+ );
437
+ cacheCellElement(rowId, columnIndex, cellElement);
438
+ return cellElement;
439
+ }
440
+ const element = tableRef.value?.querySelector(
441
+ resolveCellSelector(rowId, columnIndex)
442
+ );
443
+ cacheCellElement(rowId, columnIndex, element);
444
+ return element;
445
+ }
446
+ function ensureFootersVisible(scrollContainer, useDoubleRAF = false) {
447
+ const footerGroups = tableApi.getFooterGroups();
448
+ const tableElement = tableRef.value;
449
+ if (footerGroups.length === 0 || !tableElement) return;
450
+ const checkFooters = () => {
451
+ const footerElements = tableElement.querySelectorAll('[class*="tfoot"]');
452
+ if (footerElements.length === 0) {
453
+ const absoluteMaxScroll = scrollContainer.scrollHeight - scrollContainer.clientHeight;
454
+ if (scrollContainer.scrollTop < absoluteMaxScroll - 1) {
455
+ scrollContainer.scrollTop = absoluteMaxScroll;
456
+ }
457
+ return;
458
+ }
459
+ const lastFooter = Array.from(footerElements).reduce(
460
+ (latest, footer) => {
461
+ const latestRect = latest?.getBoundingClientRect();
462
+ const footerRect = footer.getBoundingClientRect();
463
+ return !latestRect || footerRect.bottom > latestRect.bottom ? footer : latest;
464
+ },
465
+ null
466
+ );
467
+ if (lastFooter) {
468
+ const containerRect = scrollContainer.getBoundingClientRect();
469
+ const footerRect = lastFooter.getBoundingClientRect();
470
+ const containerBottom = containerRect.bottom;
471
+ const footerBottom = footerRect.bottom;
472
+ const padding = 15;
473
+ if (footerBottom > containerBottom - padding) {
474
+ const adjustment = footerBottom - containerBottom + padding;
475
+ scrollContainer.scrollTop += adjustment;
476
+ }
477
+ }
478
+ };
479
+ if (useDoubleRAF) {
480
+ requestAnimationFrame(() => {
481
+ requestAnimationFrame(checkFooters);
482
+ });
483
+ } else {
484
+ requestAnimationFrame(checkFooters);
485
+ }
486
+ }
487
+ function scrollToCellAndFocus(options) {
488
+ const {
489
+ cellElement,
490
+ rowId,
491
+ rowIndex,
492
+ columnIndex,
493
+ behavior = "instant",
494
+ skipHorizontalScroll = false,
495
+ verticalOnly = false,
496
+ isFirstFocusableColumn = false,
497
+ isLastFocusableColumn = false,
498
+ onComplete
499
+ } = options;
500
+ const effectiveScrollContainer = verticalScrollContainer.value;
501
+ const effectiveHScrollContainer = horizontalScrollContainer.value;
502
+ const tableElement = tableRef.value;
503
+ if (!effectiveScrollContainer || !tableElement) {
504
+ onComplete?.();
505
+ return;
506
+ }
507
+ const resolvedRows2 = navigableRows?.value ?? rows.value;
508
+ const isLastRow = resolvedRows2.length > 0 && rowId === resolvedRows2[resolvedRows2.length - 1]?.id;
509
+ cellElement.focus({ preventScroll: true });
510
+ scrollManager.scrollToCell({
511
+ cellElement,
512
+ scrollContainer: effectiveScrollContainer,
513
+ horizontalScrollContainer: effectiveHScrollContainer ?? void 0,
514
+ tableElement,
515
+ rowIndex,
516
+ columnIndex,
517
+ virtualizedStickyHeight: resolveStickyHeight(tableElement),
518
+ behavior,
519
+ verticalPadding: 15,
520
+ includeHeadersAbove: false,
521
+ skipHorizontalScroll,
522
+ verticalOnly
523
+ }).then(() => {
524
+ if (isLastRow) {
525
+ ensureFootersVisible(effectiveScrollContainer);
526
+ }
527
+ if (isFirstFocusableColumn && effectiveHScrollContainer) {
528
+ scrollManager.scrollToHorizontalEdge(effectiveHScrollContainer, "start");
529
+ }
530
+ if (isLastFocusableColumn && effectiveHScrollContainer) {
531
+ scrollManager.scrollToHorizontalEdge(effectiveHScrollContainer, "end");
532
+ }
533
+ }).finally(() => {
534
+ onComplete?.();
535
+ });
536
+ }
537
+ function isColumnFocusable(columnIndex, row) {
538
+ const cols = visibleColumns.value;
539
+ if (columnIndex < 0 || columnIndex >= cols.length) return false;
540
+ const column = cols[columnIndex];
541
+ if (!column) return false;
542
+ const columnDef = column.columnDef;
543
+ if (columnDef.enableFocusing === void 0) return true;
544
+ if (typeof columnDef.enableFocusing === "function") {
545
+ return columnDef.enableFocusing(row);
546
+ }
547
+ return columnDef.enableFocusing;
548
+ }
549
+ function findNextFocusableColumn(startIndex, row) {
550
+ const cols = visibleColumns.value;
551
+ for (let i = startIndex + 1; i < cols.length; i++) {
552
+ if (isColumnFocusable(i, row)) return i;
553
+ }
554
+ return startIndex;
555
+ }
556
+ function findPreviousFocusableColumn(startIndex, row) {
557
+ for (let i = startIndex - 1; i >= 0; i--) {
558
+ if (isColumnFocusable(i, row)) return i;
559
+ }
560
+ return startIndex;
561
+ }
562
+ function findFirstFocusableColumn(row) {
563
+ const cols = visibleColumns.value;
564
+ for (let i = 0; i < cols.length; i++) {
565
+ if (isColumnFocusable(i, row)) return i;
566
+ }
567
+ return 0;
568
+ }
569
+ function findLastFocusableColumn(row) {
570
+ const cols = visibleColumns.value;
571
+ for (let i = cols.length - 1; i >= 0; i--) {
572
+ if (isColumnFocusable(i, row)) return i;
573
+ }
574
+ return cols.length - 1;
575
+ }
576
+ function findFirstFocusableColumnInVisualRow(visualRow, row) {
577
+ return keyboardNav.findFirstInVisualRow(visualRow, row, isColumnFocusable) ?? getColumnsInVisualRow(visualRow)[0] ?? 0;
578
+ }
579
+ function findLastFocusableColumnInVisualRow(visualRow, row) {
580
+ const cols = getColumnsInVisualRow(visualRow);
581
+ return keyboardNav.findLastInVisualRow(visualRow, row, isColumnFocusable) ?? cols[cols.length - 1] ?? 0;
582
+ }
583
+ function findNextFocusableColumnInVisualRow(startIndex, visualRow, row) {
584
+ return keyboardNav.findNextInVisualRow(startIndex, visualRow, row, isColumnFocusable);
585
+ }
586
+ function findPreviousFocusableColumnInVisualRow(startIndex, visualRow, row) {
587
+ return keyboardNav.findPreviousInVisualRow(startIndex, visualRow, row, isColumnFocusable);
588
+ }
589
+ function onCellClick(e, row, columnIndex) {
590
+ const target = e.target;
591
+ if (isWithinAriaHidden(target)) {
592
+ return;
593
+ }
594
+ const isInteractive = target.closest("button") || target.closest("a") || target.closest("input") || target.closest("select");
595
+ if (isInteractive) {
596
+ return;
597
+ }
598
+ if (!isColumnFocusable(columnIndex, row)) {
599
+ return;
600
+ }
601
+ const rowIndex = getRowIndex(row);
602
+ if (rowIndex === -1) {
603
+ return;
604
+ }
605
+ gridHasFocus.value = true;
606
+ pointerDownInsideGrid = false;
607
+ const currentSuppressOutline = focusedCell.value?.suppressOutline;
608
+ focusCell(row, rowIndex, columnIndex);
609
+ if (focusMode.value === "cell") {
610
+ setFocusedCell({
611
+ rowIndex,
612
+ columnIndex,
613
+ ...currentSuppressOutline && { suppressOutline: true }
614
+ });
615
+ } else if (focusMode.value === "row") {
616
+ setFocusedCell({
617
+ rowIndex,
618
+ columnIndex: 0,
619
+ ...currentSuppressOutline && { suppressOutline: true }
620
+ });
621
+ }
622
+ }
623
+ if (interactionRouter) {
624
+ unregisterInteraction = interactionRouter.registerCellClickHandler({
625
+ id: "focus",
626
+ priority: 10,
627
+ handle: ({ event, row, cellIndex }) => {
628
+ if (typeof cellIndex !== "number") return;
629
+ if (event.__addRowFinalizing) {
630
+ return { handled: true, stop: true };
631
+ }
632
+ if (event.__addRowUneditableClick) {
633
+ return { handled: true, stop: true };
634
+ }
635
+ onCellClick(event, row, cellIndex);
636
+ return { handled: event.defaultPrevented || event.cancelBubble };
637
+ }
638
+ });
639
+ }
640
+ function onCellKeyDown(e) {
641
+ if (focusMode.value === "none") {
642
+ if ([
643
+ "ArrowUp",
644
+ "ArrowDown",
645
+ "ArrowLeft",
646
+ "ArrowRight",
647
+ "Home",
648
+ "End",
649
+ "PageUp",
650
+ "PageDown"
651
+ ].includes(e.key)) {
652
+ e.preventDefault();
653
+ }
654
+ return;
655
+ }
656
+ if (!focusedCell.value) return;
657
+ if (scrollManager.isProcessingScroll && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown"].includes(e.key)) {
658
+ e.preventDefault();
659
+ return;
660
+ }
661
+ const { rowIndex, columnIndex } = focusedCell.value;
662
+ const visibleRows = resolvedRows.value;
663
+ const pageJump = viewportRowsPerPage.value;
664
+ let newRowIndex = rowIndex;
665
+ let newColumnIndex = columnIndex;
666
+ let isPageScroll = false;
667
+ let skipFinalFocus = false;
668
+ let isVerticalOnly = false;
669
+ switch (e.key) {
670
+ case "ArrowUp":
671
+ e.preventDefault();
672
+ if (e.metaKey || e.ctrlKey) {
673
+ if (cmdArrows.value === "paging") {
674
+ newRowIndex = Math.max(0, rowIndex - pageJump);
675
+ isPageScroll = true;
676
+ } else {
677
+ newRowIndex = 0;
678
+ }
679
+ } else if (focusMode.value === "cell" && multiRowEnabled.value && multiRowCount.value > 1) {
680
+ const currentVisualRow = getVisualRowForColumn(columnIndex);
681
+ const currentRow = visibleRows[rowIndex];
682
+ if (currentVisualRow > 0 && currentRow) {
683
+ newColumnIndex = findColumnInVisualRow(columnIndex, currentVisualRow - 1, currentRow);
684
+ } else {
685
+ newRowIndex = Math.max(0, rowIndex - 1);
686
+ const targetRow = visibleRows[newRowIndex];
687
+ if (targetRow && newRowIndex !== rowIndex) {
688
+ const lastVisualRow = multiRowCount.value - 1;
689
+ newColumnIndex = findColumnInVisualRow(columnIndex, lastVisualRow, targetRow);
690
+ }
691
+ }
692
+ } else {
693
+ newRowIndex = Math.max(0, rowIndex - 1);
694
+ isVerticalOnly = true;
695
+ }
696
+ break;
697
+ case "ArrowDown":
698
+ e.preventDefault();
699
+ if (e.metaKey || e.ctrlKey) {
700
+ if (cmdArrows.value === "paging") {
701
+ newRowIndex = Math.min(visibleRows.length - 1, rowIndex + pageJump);
702
+ isPageScroll = true;
703
+ } else {
704
+ newRowIndex = visibleRows.length - 1;
705
+ }
706
+ } else if (focusMode.value === "cell" && multiRowEnabled.value && multiRowCount.value > 1) {
707
+ const currentVisualRow = getVisualRowForColumn(columnIndex);
708
+ const lastVisualRow = multiRowCount.value - 1;
709
+ const currentRow = visibleRows[rowIndex];
710
+ if (currentVisualRow < lastVisualRow && currentRow) {
711
+ newColumnIndex = findColumnInVisualRow(columnIndex, currentVisualRow + 1, currentRow);
712
+ } else {
713
+ newRowIndex = Math.min(visibleRows.length - 1, rowIndex + 1);
714
+ const targetRow = visibleRows[newRowIndex];
715
+ if (targetRow && newRowIndex !== rowIndex) {
716
+ newColumnIndex = findColumnInVisualRow(columnIndex, 0, targetRow);
717
+ }
718
+ }
719
+ } else {
720
+ newRowIndex = Math.min(visibleRows.length - 1, rowIndex + 1);
721
+ isVerticalOnly = true;
722
+ }
723
+ break;
724
+ case "PageUp":
725
+ e.preventDefault();
726
+ newRowIndex = Math.max(0, rowIndex - pageJump);
727
+ isPageScroll = true;
728
+ break;
729
+ case "PageDown":
730
+ e.preventDefault();
731
+ newRowIndex = Math.min(visibleRows.length - 1, rowIndex + pageJump);
732
+ isPageScroll = true;
733
+ break;
734
+ case "ArrowLeft":
735
+ e.preventDefault();
736
+ if (focusMode.value === "cell") {
737
+ const targetRow = visibleRows[rowIndex];
738
+ if (targetRow) {
739
+ if (e.metaKey || e.ctrlKey) {
740
+ newColumnIndex = findFirstFocusableColumn(targetRow);
741
+ } else if (multiRowEnabled.value && multiRowCount.value > 1) {
742
+ const currentVisualRow = getVisualRowForColumn(columnIndex);
743
+ const prevCol = findPreviousFocusableColumnInVisualRow(
744
+ columnIndex,
745
+ currentVisualRow,
746
+ targetRow
747
+ );
748
+ if (prevCol !== null) {
749
+ newColumnIndex = prevCol;
750
+ } else if (currentVisualRow > 0) {
751
+ newColumnIndex = findLastFocusableColumnInVisualRow(currentVisualRow - 1, targetRow);
752
+ } else {
753
+ if (rowIndex > 0) {
754
+ newRowIndex = rowIndex - 1;
755
+ const prevDataRow = visibleRows[newRowIndex];
756
+ if (prevDataRow) {
757
+ const lastVisualRow = multiRowCount.value - 1;
758
+ newColumnIndex = findLastFocusableColumnInVisualRow(lastVisualRow, prevDataRow);
759
+ }
760
+ }
761
+ }
762
+ } else {
763
+ newColumnIndex = findPreviousFocusableColumn(columnIndex, targetRow);
764
+ }
765
+ }
766
+ }
767
+ break;
768
+ case "ArrowRight":
769
+ e.preventDefault();
770
+ if (focusMode.value === "cell") {
771
+ const targetRow = visibleRows[rowIndex];
772
+ if (targetRow) {
773
+ if (e.metaKey || e.ctrlKey) {
774
+ newColumnIndex = findLastFocusableColumn(targetRow);
775
+ } else if (multiRowEnabled.value && multiRowCount.value > 1) {
776
+ const currentVisualRow = getVisualRowForColumn(columnIndex);
777
+ const nextCol = findNextFocusableColumnInVisualRow(
778
+ columnIndex,
779
+ currentVisualRow,
780
+ targetRow
781
+ );
782
+ if (nextCol !== null) {
783
+ newColumnIndex = nextCol;
784
+ } else if (currentVisualRow < multiRowCount.value - 1) {
785
+ newColumnIndex = findFirstFocusableColumnInVisualRow(
786
+ currentVisualRow + 1,
787
+ targetRow
788
+ );
789
+ } else {
790
+ if (rowIndex < visibleRows.length - 1) {
791
+ newRowIndex = rowIndex + 1;
792
+ const nextDataRow = visibleRows[newRowIndex];
793
+ if (nextDataRow) {
794
+ newColumnIndex = findFirstFocusableColumnInVisualRow(0, nextDataRow);
795
+ }
796
+ }
797
+ }
798
+ } else {
799
+ newColumnIndex = findNextFocusableColumn(columnIndex, targetRow);
800
+ }
801
+ }
802
+ }
803
+ break;
804
+ case "Tab":
805
+ if (focusMode.value === "cell") {
806
+ const direction = e.shiftKey ? "previous" : "next";
807
+ const target = keyboardNav.navigateTab(
808
+ direction,
809
+ rowIndex,
810
+ columnIndex,
811
+ visibleRows,
812
+ isColumnFocusable
813
+ );
814
+ if (target) {
815
+ e.preventDefault();
816
+ newRowIndex = target.rowIndex;
817
+ newColumnIndex = target.columnIndex;
818
+ } else {
819
+ skipFinalFocus = true;
820
+ }
821
+ }
822
+ break;
823
+ case "Home":
824
+ e.preventDefault();
825
+ if (focusMode.value === "cell") {
826
+ const targetRow = visibleRows[rowIndex];
827
+ if (targetRow) {
828
+ newColumnIndex = findFirstFocusableColumn(targetRow);
829
+ }
830
+ }
831
+ break;
832
+ case "End":
833
+ e.preventDefault();
834
+ if (focusMode.value === "cell") {
835
+ const targetRow = visibleRows[rowIndex];
836
+ if (targetRow) {
837
+ newColumnIndex = findLastFocusableColumn(targetRow);
838
+ }
839
+ }
840
+ break;
841
+ case " ":
842
+ {
843
+ const target = e.target;
844
+ const isInteractive = target.closest("input") || target.closest("button") || target.closest("select") || target.closest("textarea");
845
+ if (isInteractive) {
846
+ return;
847
+ }
848
+ e.preventDefault();
849
+ const isRowSelectionEnabled = rowSelectionMode.value !== void 0 && rowSelectionMode.value !== false;
850
+ const isInEditMode = editingCell?.value !== null && editingCell?.value !== void 0;
851
+ const isEditingDisabled = enableEditing.value === false;
852
+ const row = visibleRows[rowIndex];
853
+ const isOnSelectionColumn = focusMode.value === "cell" && row && columnIndex >= 0 && row.getVisibleCells()[columnIndex]?.column.id === "__selection";
854
+ const canRowBeSelected = (() => {
855
+ if (!row) return false;
856
+ const mode = rowSelectionMode.value;
857
+ if (typeof mode === "object" && mode !== null) {
858
+ const options = mode;
859
+ if (options.enabled === false) {
860
+ return false;
861
+ }
862
+ if (options.rowSelectionEnabled) {
863
+ return options.rowSelectionEnabled(row);
864
+ }
865
+ }
866
+ return true;
867
+ })();
868
+ if (isRowSelectionEnabled && (!isInEditMode || isEditingDisabled) && !isOnSelectionColumn && row && canRowBeSelected) {
869
+ row.toggleSelected(!row.getIsSelected());
870
+ return;
871
+ }
872
+ if (props.onSelect && (focusMode.value === "cell" || focusMode.value === "row")) {
873
+ if (row) {
874
+ props.onSelect(e, row);
875
+ }
876
+ }
877
+ }
878
+ return;
879
+ default:
880
+ return;
881
+ }
882
+ const isJumpToFirstColumn = focusMode.value === "cell" && (e.key === "Home" || e.key === "ArrowLeft" && (e.metaKey || e.ctrlKey)) && newColumnIndex !== columnIndex;
883
+ if (isJumpToFirstColumn) {
884
+ const hScrollContainer = horizontalScrollContainer.value;
885
+ if (!hScrollContainer) return;
886
+ const targetRow = visibleRows[newRowIndex];
887
+ if (!targetRow) return;
888
+ setFocusedCell({ rowIndex: newRowIndex, columnIndex: newColumnIndex });
889
+ scrollManager.scrollToHorizontalEdge(hScrollContainer, "start").then(() => {
890
+ requestAnimationFrame(() => {
891
+ requestAnimationFrame(() => {
892
+ const targetElement = getCellElement(targetRow.id, newColumnIndex);
893
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
894
+ targetElement.focus({ preventScroll: true });
895
+ }
896
+ });
897
+ });
898
+ });
899
+ return;
900
+ }
901
+ const isJumpToLastColumn = focusMode.value === "cell" && (e.key === "End" || e.key === "ArrowRight" && (e.metaKey || e.ctrlKey)) && newColumnIndex !== columnIndex;
902
+ if (isJumpToLastColumn) {
903
+ const hScrollContainer = horizontalScrollContainer.value;
904
+ if (!hScrollContainer) return;
905
+ const targetRow = visibleRows[newRowIndex];
906
+ if (!targetRow) return;
907
+ setFocusedCell({ rowIndex: newRowIndex, columnIndex: newColumnIndex });
908
+ scrollManager.scrollToHorizontalEdge(hScrollContainer, "end").then(() => {
909
+ requestAnimationFrame(() => {
910
+ requestAnimationFrame(() => {
911
+ const targetElement = getCellElement(targetRow.id, newColumnIndex);
912
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
913
+ targetElement.focus({ preventScroll: true });
914
+ }
915
+ });
916
+ });
917
+ });
918
+ return;
919
+ }
920
+ const isJumpToFirstOrLast = (e.key === "ArrowUp" || e.key === "ArrowDown") && (e.metaKey || e.ctrlKey) && cmdArrows.value === "firstlast";
921
+ if (isJumpToFirstOrLast) {
922
+ const effectiveScrollContainer = verticalScrollContainer.value;
923
+ if (!effectiveScrollContainer) return;
924
+ const targetRowIndex = newRowIndex;
925
+ const targetRow = visibleRows[targetRowIndex];
926
+ if (!targetRow) return;
927
+ const edgeDirection = e.key === "ArrowUp" ? "start" : "end";
928
+ scrollManager.scrollToVerticalEdge(effectiveScrollContainer, edgeDirection).then(() => {
929
+ requestAnimationFrame(() => {
930
+ requestAnimationFrame(
931
+ () => focusTargetRowAfterEdgeScroll(targetRow, newColumnIndex, e.key)
932
+ );
933
+ });
934
+ });
935
+ setFocusedCell({ rowIndex: targetRowIndex, columnIndex: newColumnIndex });
936
+ } else if (isPageScroll) {
937
+ if (scrollManager.isProcessingScroll) {
938
+ e.preventDefault();
939
+ return;
940
+ }
941
+ startProcessingLock();
942
+ const effectiveScrollContainer = verticalScrollContainer.value;
943
+ const tableElement = tableRef.value;
944
+ if (!effectiveScrollContainer || !tableElement) {
945
+ stopProcessingLock();
946
+ return;
947
+ }
948
+ const lastRowIndex = visibleRows.length - 1;
949
+ if (newRowIndex === rowIndex) {
950
+ stopProcessingLock();
951
+ return;
952
+ }
953
+ const scrollDirection = newRowIndex > rowIndex ? 1 : -1;
954
+ const currentScrollTop = effectiveScrollContainer.scrollTop;
955
+ const maxScrollTop = effectiveScrollContainer.scrollHeight - effectiveScrollContainer.clientHeight;
956
+ if (scrollDirection < 0 && rowIndex === 0) {
957
+ if (currentScrollTop > 0) {
958
+ effectiveScrollContainer.scrollTop = 0;
959
+ }
960
+ stopProcessingLock();
961
+ return;
962
+ }
963
+ const oneRowHeight = rowHeightEstimate.value;
964
+ if (scrollDirection < 0 && currentScrollTop > 0 && currentScrollTop <= oneRowHeight) {
965
+ effectiveScrollContainer.scrollTop = 0;
966
+ const viewportHeightForCheck = effectiveScrollContainer.clientHeight;
967
+ const visibleRowCount = Math.floor(viewportHeightForCheck / oneRowHeight);
968
+ if (rowIndex < visibleRowCount) {
969
+ const firstRow = visibleRows[0];
970
+ if (firstRow) {
971
+ setFocusedCell({ rowIndex: 0, columnIndex: newColumnIndex });
972
+ const targetElement = focusMode.value === "cell" ? getCellElement(firstRow.id, newColumnIndex) : getRowElement(firstRow.id);
973
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
974
+ targetElement.focus({ preventScroll: true });
975
+ }
976
+ }
977
+ }
978
+ stopProcessingLock();
979
+ return;
980
+ }
981
+ if (scrollDirection < 0 && currentScrollTop === 0 && rowIndex > 0) {
982
+ const firstRow = visibleRows[0];
983
+ if (firstRow) {
984
+ setFocusedCell({ rowIndex: 0, columnIndex: newColumnIndex });
985
+ const targetElement = focusMode.value === "cell" ? getCellElement(firstRow.id, newColumnIndex) : getRowElement(firstRow.id);
986
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
987
+ targetElement.focus({ preventScroll: true });
988
+ }
989
+ }
990
+ stopProcessingLock();
991
+ return;
992
+ }
993
+ if (scrollDirection > 0 && rowIndex >= lastRowIndex) {
994
+ stopProcessingLock();
995
+ return;
996
+ }
997
+ if (scrollDirection > 0 && currentScrollTop >= maxScrollTop - 10) {
998
+ if (lastRowIndex >= 0 && rowIndex < lastRowIndex) {
999
+ const lastRow = visibleRows[lastRowIndex];
1000
+ if (lastRow) {
1001
+ setFocusedCell({ rowIndex: lastRowIndex, columnIndex: newColumnIndex });
1002
+ const targetElement = focusMode.value === "cell" ? getCellElement(lastRow.id, newColumnIndex) : getRowElement(lastRow.id);
1003
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
1004
+ targetElement.focus({ preventScroll: true });
1005
+ }
1006
+ }
1007
+ }
1008
+ stopProcessingLock();
1009
+ return;
1010
+ }
1011
+ const currentRow = visibleRows[rowIndex];
1012
+ let currentFocusedElement = null;
1013
+ if (currentRow) {
1014
+ if (focusMode.value === "cell") {
1015
+ currentFocusedElement = getCellElement(currentRow.id, columnIndex);
1016
+ } else {
1017
+ currentFocusedElement = getRowElement(currentRow.id);
1018
+ }
1019
+ }
1020
+ const stickyHeaderHeight = Math.round(resolveStickyHeight(tableElement));
1021
+ const containerRectTop = effectiveScrollContainer.getBoundingClientRect().top;
1022
+ const visibleTop = Math.round(containerRectTop + stickyHeaderHeight);
1023
+ const currentFocusedTop = currentFocusedElement?.getBoundingClientRect().top ?? 0;
1024
+ const targetVisualTop = currentFocusedElement ? Math.round(currentFocusedTop - visibleTop) : 0;
1025
+ const viewportHeight = Math.round(effectiveScrollContainer.clientHeight - stickyHeaderHeight);
1026
+ const overlap = Math.round(Math.max(1, rowHeightEstimate.value) * 0.3);
1027
+ const effectiveScrollAmount = Math.max(1, viewportHeight - overlap);
1028
+ const scrollAmount = scrollDirection * effectiveScrollAmount;
1029
+ const newScrollTop = Math.max(0, Math.min(maxScrollTop, currentScrollTop + scrollAmount));
1030
+ effectiveScrollContainer.scrollTop = newScrollTop;
1031
+ const targetScreenY = Math.round(visibleTop + targetVisualTop);
1032
+ requestAnimationFrame(() => {
1033
+ const currentScrollAfter = effectiveScrollContainer.scrollTop;
1034
+ const maxScrollAfter = effectiveScrollContainer.scrollHeight - effectiveScrollContainer.clientHeight;
1035
+ if (scrollDirection > 0 && currentScrollAfter >= maxScrollAfter - 10) {
1036
+ const lastRowIndex2 = visibleRows.length - 1;
1037
+ if (lastRowIndex2 >= 0) {
1038
+ const lastRow = visibleRows[lastRowIndex2];
1039
+ if (lastRow) {
1040
+ setFocusedCell({ rowIndex: lastRowIndex2, columnIndex: newColumnIndex });
1041
+ const targetElement = focusMode.value === "cell" ? getCellElement(lastRow.id, newColumnIndex) : getRowElement(lastRow.id);
1042
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
1043
+ targetElement.focus({ preventScroll: true });
1044
+ }
1045
+ }
1046
+ }
1047
+ ensureFootersVisible(effectiveScrollContainer, true);
1048
+ stopProcessingLock();
1049
+ return;
1050
+ }
1051
+ let closestRow = null;
1052
+ let closestRowIndex = -1;
1053
+ let closestDistance = Infinity;
1054
+ const rowElements = tableElement.querySelectorAll("[data-row-id]");
1055
+ for (const rowElement of rowElements) {
1056
+ const rowId = rowElement.getAttribute("data-row-id");
1057
+ if (rowId) {
1058
+ cacheRowElement(rowId, rowElement);
1059
+ }
1060
+ const rowIdx = getRowIndexById(rowId);
1061
+ if (rowIdx === -1) {
1062
+ continue;
1063
+ }
1064
+ const row = visibleRows[rowIdx];
1065
+ if (!row) {
1066
+ continue;
1067
+ }
1068
+ const rowRect = rowElement.getBoundingClientRect();
1069
+ const distance = Math.abs(Math.round(rowRect.top) - targetScreenY);
1070
+ if (distance < closestDistance) {
1071
+ closestDistance = distance;
1072
+ closestRow = row;
1073
+ closestRowIndex = rowIdx;
1074
+ }
1075
+ }
1076
+ if (closestRow && closestRowIndex !== -1) {
1077
+ setFocusedCell({ rowIndex: closestRowIndex, columnIndex: newColumnIndex });
1078
+ const targetElement = focusMode.value === "cell" ? getCellElement(closestRow.id, newColumnIndex) : getRowElement(closestRow.id);
1079
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
1080
+ targetElement.focus({ preventScroll: true });
1081
+ const actualVisualTop = targetElement.getBoundingClientRect().top - visibleTop;
1082
+ const adjustment = actualVisualTop - targetVisualTop;
1083
+ if (Math.abs(adjustment) > 0.5) {
1084
+ effectiveScrollContainer.scrollTop += adjustment;
1085
+ }
1086
+ if (closestRowIndex === 0 && effectiveScrollContainer.scrollTop > 0) {
1087
+ effectiveScrollContainer.scrollTop = 0;
1088
+ }
1089
+ }
1090
+ }
1091
+ stopProcessingLock();
1092
+ });
1093
+ } else if (!skipFinalFocus) {
1094
+ setFocusedCell({ rowIndex: newRowIndex, columnIndex: newColumnIndex });
1095
+ const targetRow = visibleRows[newRowIndex];
1096
+ if (!targetRow) return;
1097
+ focusCell(targetRow, newRowIndex, newColumnIndex, isVerticalOnly);
1098
+ }
1099
+ }
1100
+ function onCellKeyUp(e) {
1101
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown"].includes(e.key)) {
1102
+ scrollManager.invalidateDimensionCache();
1103
+ }
1104
+ }
1105
+ function focusCell(targetRow, newRowIndex, newColumnIndex, verticalOnly = false, onScrollComplete) {
1106
+ startProcessingLock();
1107
+ const finalize = () => {
1108
+ stopProcessingLock();
1109
+ onScrollComplete?.();
1110
+ };
1111
+ if (focusMode.value === "cell") {
1112
+ const cellElement = getCellElement(targetRow.id, newColumnIndex);
1113
+ if (cellElement) {
1114
+ if (isWithinAriaHidden(cellElement)) {
1115
+ finalize();
1116
+ return;
1117
+ }
1118
+ const firstFocusableCol = findFirstFocusableColumn(targetRow);
1119
+ const lastFocusableCol = findLastFocusableColumn(targetRow);
1120
+ const isFirstFocusableColumn = newColumnIndex === firstFocusableCol && firstFocusableCol > 0;
1121
+ const isLastFocusableColumn = newColumnIndex === lastFocusableCol && lastFocusableCol < visibleColumns.value.length - 1;
1122
+ scrollToCellAndFocus({
1123
+ cellElement,
1124
+ rowId: targetRow.id,
1125
+ rowIndex: newRowIndex,
1126
+ columnIndex: newColumnIndex,
1127
+ behavior: "instant",
1128
+ verticalOnly,
1129
+ isFirstFocusableColumn,
1130
+ isLastFocusableColumn,
1131
+ onComplete: finalize
1132
+ });
1133
+ } else {
1134
+ finalize();
1135
+ }
1136
+ } else if (focusMode.value === "row") {
1137
+ const rowElement = getRowElement(targetRow.id);
1138
+ if (rowElement) {
1139
+ if (isWithinAriaHidden(rowElement)) {
1140
+ finalize();
1141
+ return;
1142
+ }
1143
+ scrollToCellAndFocus({
1144
+ cellElement: rowElement,
1145
+ rowId: targetRow.id,
1146
+ rowIndex: newRowIndex,
1147
+ columnIndex: 0,
1148
+ behavior: "instant",
1149
+ skipHorizontalScroll: true,
1150
+ verticalOnly,
1151
+ onComplete: finalize
1152
+ });
1153
+ } else {
1154
+ finalize();
1155
+ }
1156
+ } else {
1157
+ finalize();
1158
+ }
1159
+ }
1160
+ function focusTargetRowAfterEdgeScroll(row, columnIndex, directionKey) {
1161
+ const effectiveScrollContainer = verticalScrollContainer.value;
1162
+ if (!effectiveScrollContainer) return;
1163
+ const targetElement = focusMode.value === "cell" ? getCellElement(row.id, columnIndex) : getRowElement(row.id);
1164
+ if (targetElement && !isWithinAriaHidden(targetElement)) {
1165
+ targetElement.focus({ preventScroll: true });
1166
+ if (directionKey === "ArrowDown") {
1167
+ const containerRect = effectiveScrollContainer.getBoundingClientRect();
1168
+ const elementRect = targetElement.getBoundingClientRect();
1169
+ const containerBottom = containerRect.bottom;
1170
+ const elementBottom = elementRect.bottom;
1171
+ const padding = 15;
1172
+ if (elementBottom > containerBottom - padding) {
1173
+ const adjustment = elementBottom - containerBottom + padding;
1174
+ effectiveScrollContainer.scrollTop += adjustment;
1175
+ }
1176
+ const resolvedRows2 = navigableRows?.value ?? rows.value;
1177
+ const isLastRow = resolvedRows2.length > 0 && row.id === resolvedRows2[resolvedRows2.length - 1]?.id;
1178
+ if (isLastRow) {
1179
+ ensureFootersVisible(effectiveScrollContainer);
1180
+ }
1181
+ }
1182
+ }
1183
+ }
1184
+ function getRowTabIndex(row) {
1185
+ if (focusMode.value === "row") {
1186
+ const rowIndex = getRowIndex(row);
1187
+ if (rowIndex !== -1 && focusedCell.value?.rowIndex === rowIndex) {
1188
+ return 0;
1189
+ }
1190
+ }
1191
+ if (props.onSelect && focusMode.value === "none") {
1192
+ return 0;
1193
+ }
1194
+ return -1;
1195
+ }
1196
+ function shouldRowHandleKeydown(row) {
1197
+ if (focusMode.value === "none" && props.onSelect) {
1198
+ return true;
1199
+ }
1200
+ if (focusMode.value === "row") {
1201
+ const rowIndex = getRowIndex(row);
1202
+ return rowIndex !== -1 && focusedCell.value?.rowIndex === rowIndex;
1203
+ }
1204
+ return false;
1205
+ }
1206
+ function getCellTabIndex(row, cellIndex) {
1207
+ if (focusMode.value === "cell") {
1208
+ const rowIndex = getRowIndex(row);
1209
+ if (rowIndex !== -1 && focusedCell.value?.rowIndex === rowIndex && focusedCell.value?.columnIndex === cellIndex) {
1210
+ return 0;
1211
+ }
1212
+ }
1213
+ return -1;
1214
+ }
1215
+ function shouldCellHandleKeydown(row, cellIndex) {
1216
+ if (focusMode.value === "none" && props.onSelect) {
1217
+ return true;
1218
+ }
1219
+ if (focusMode.value === "cell") {
1220
+ const rowIndex = getRowIndex(row);
1221
+ return rowIndex !== -1 && focusedCell.value?.rowIndex === rowIndex && focusedCell.value?.columnIndex === cellIndex;
1222
+ }
1223
+ return false;
1224
+ }
1225
+ function isActiveRow(row) {
1226
+ if (focusMode.value === "none" || !focusedCell.value) return false;
1227
+ const rowIndex = getRowIndex(row);
1228
+ return rowIndex !== -1 && focusedCell.value.rowIndex === rowIndex;
1229
+ }
1230
+ function isFocusedRow(row) {
1231
+ if (focusMode.value !== "row" || !focusedCell.value) return false;
1232
+ const rowIndex = getRowIndex(row);
1233
+ return rowIndex !== -1 && focusedCell.value.rowIndex === rowIndex;
1234
+ }
1235
+ function isFocusedCell(row, cellIndex) {
1236
+ if (focusMode.value !== "cell" || !focusedCell.value) return false;
1237
+ const rowIndex = getRowIndex(row);
1238
+ if (rowIndex !== -1 && focusedCell.value.rowIndex === rowIndex && focusedCell.value.columnIndex === cellIndex) {
1239
+ return !focusedCell.value.suppressOutline;
1240
+ }
1241
+ return false;
1242
+ }
1243
+ function rowFocusProps(row) {
1244
+ return {
1245
+ "data-active-row": isActiveRow(row),
1246
+ "data-focused-row": isFocusedRow(row),
1247
+ "tabindex": getRowTabIndex(row)
1248
+ };
1249
+ }
1250
+ function cellFocusProps(row, cellIndex) {
1251
+ const isFocused = isFocusedCell(row, cellIndex);
1252
+ return {
1253
+ "data-focused": isFocused,
1254
+ "tabindex": getCellTabIndex(row, cellIndex),
1255
+ "class": isFocused ? "focused-cell" : "",
1256
+ "onClick": (e) => onCellClick(e, row, cellIndex)
1257
+ };
1258
+ }
1259
+ function focusRowById(rowId, options) {
1260
+ if (rowId === null) {
1261
+ setFocusedCell(null);
1262
+ return true;
1263
+ }
1264
+ const rowIndex = rowIdToIndexMap.value.get(rowId);
1265
+ if (rowIndex === void 0) {
1266
+ console.warn(`[NuGrid] focusRowById: Row ID "${rowId}" not found in grid`);
1267
+ return false;
1268
+ }
1269
+ const currentRows = resolvedRows.value;
1270
+ const targetRow = currentRows[rowIndex];
1271
+ if (!targetRow) {
1272
+ return false;
1273
+ }
1274
+ const columnIndex = options?.columnIndex ?? findFirstFocusableColumn(targetRow);
1275
+ const align = options?.align ?? alignOnModel.value ?? "nearest";
1276
+ isUpdatingFromModel = true;
1277
+ setFocusedCell({ rowIndex, columnIndex });
1278
+ isUpdatingFromModel = false;
1279
+ focusCell(targetRow, rowIndex, columnIndex, false, () => {
1280
+ const scrollContainer = verticalScrollContainer.value;
1281
+ const rowElement = getRowElement(targetRow.id);
1282
+ const tableElement = tableRef.value;
1283
+ if (scrollContainer && rowElement) {
1284
+ const containerRect = scrollContainer.getBoundingClientRect();
1285
+ const rowRect = rowElement.getBoundingClientRect();
1286
+ const stickyHeight = resolveStickyHeight(tableElement);
1287
+ const visibleTop = containerRect.top + stickyHeight;
1288
+ const visibleHeight = containerRect.height - stickyHeight;
1289
+ const visibleBottom = visibleTop + visibleHeight;
1290
+ if (align === "top") {
1291
+ const targetScrollTop = scrollContainer.scrollTop + (rowRect.top - visibleTop);
1292
+ scrollContainer.scrollTop = Math.max(0, targetScrollTop);
1293
+ } else if (align === "center") {
1294
+ const rowCenter = rowRect.top + rowRect.height / 2;
1295
+ const visibleCenter = visibleTop + visibleHeight / 2;
1296
+ const offset = rowCenter - visibleCenter;
1297
+ scrollContainer.scrollTop = Math.max(0, scrollContainer.scrollTop + offset);
1298
+ } else if (align === "nearest") {
1299
+ const minVisiblePadding = 10;
1300
+ if (rowRect.top < visibleTop + minVisiblePadding) {
1301
+ const adjustment = rowRect.top - visibleTop - minVisiblePadding;
1302
+ scrollContainer.scrollTop = Math.max(0, scrollContainer.scrollTop + adjustment);
1303
+ } else if (rowRect.bottom > visibleBottom - minVisiblePadding) {
1304
+ const adjustment = rowRect.bottom - visibleBottom + minVisiblePadding;
1305
+ const maxScroll = scrollContainer.scrollHeight - scrollContainer.clientHeight;
1306
+ scrollContainer.scrollTop = Math.min(maxScroll, scrollContainer.scrollTop + adjustment);
1307
+ }
1308
+ }
1309
+ }
1310
+ });
1311
+ return true;
1312
+ }
1313
+ if (focusedRowIdModel) {
1314
+ watch(
1315
+ focusedRowIdModel,
1316
+ (newRowId, oldRowId) => {
1317
+ if (isUpdatingToModel) return;
1318
+ if (newRowId === oldRowId) return;
1319
+ if (newRowId === null) {
1320
+ isUpdatingFromModel = true;
1321
+ setFocusedCell(null);
1322
+ isUpdatingFromModel = false;
1323
+ return;
1324
+ }
1325
+ const success = focusRowById(newRowId);
1326
+ if (!success && oldRowId !== void 0) {
1327
+ isUpdatingToModel = true;
1328
+ focusedRowIdModel.value = oldRowId;
1329
+ isUpdatingToModel = false;
1330
+ }
1331
+ },
1332
+ { immediate: false }
1333
+ // Don't run on mount - let normal focus init happen
1334
+ );
1335
+ }
1336
+ return {
1337
+ focusedCell,
1338
+ gridHasFocus,
1339
+ onCellClick,
1340
+ onCellKeyDown,
1341
+ onCellKeyUp,
1342
+ getRowTabIndex,
1343
+ shouldRowHandleKeydown,
1344
+ getCellTabIndex,
1345
+ shouldCellHandleKeydown,
1346
+ isActiveRow,
1347
+ isFocusedRow,
1348
+ isFocusedCell,
1349
+ rowFocusProps,
1350
+ cellFocusProps,
1351
+ focusCell,
1352
+ findFirstFocusableColumn,
1353
+ getCellElement,
1354
+ ensureFootersVisible,
1355
+ scrollToCellAndFocus,
1356
+ setFocusedCell,
1357
+ focusRowById
1358
+ };
1359
+ }
1360
+ export function useNuGridFocusInit(props, focusFns, rows) {
1361
+ const focusMode = usePropWithDefault(props, "focus", "mode");
1362
+ watch(
1363
+ [focusMode, rows],
1364
+ ([mode, rowList]) => {
1365
+ if (mode === "cell" && rowList && rowList.length > 0 && !focusFns.focusedCell.value) {
1366
+ nextTick(() => {
1367
+ const firstRow = rowList[0];
1368
+ if (firstRow) {
1369
+ const firstFocusableColumn = focusFns.findFirstFocusableColumn(firstRow);
1370
+ focusFns.setFocusedCell({ rowIndex: 0, columnIndex: firstFocusableColumn });
1371
+ focusFns.focusCell(firstRow, 0, firstFocusableColumn);
1372
+ }
1373
+ });
1374
+ }
1375
+ },
1376
+ { immediate: true }
1377
+ );
1378
+ }