@katlux/toolkit 0.1.1-alpha.146 → 0.1.1-alpha.147

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 (231) hide show
  1. package/README.md +32 -22
  2. package/bin/ai-init.mjs +71 -13
  3. package/bin/ai-tokens/adapters/antigravityAdapter.mjs +22 -0
  4. package/bin/ai-tokens/adapters/claudeCodeAdapter.mjs +192 -0
  5. package/bin/ai-tokens/adapters/codexAdapter.mjs +176 -0
  6. package/bin/ai-tokens/adapters/cursorAdapter.mjs +202 -0
  7. package/bin/ai-tokens/adapters/index.mjs +30 -0
  8. package/bin/ai-tokens/cliViews.mjs +301 -0
  9. package/bin/ai-tokens/formatAndDates.mjs +89 -0
  10. package/bin/ai-tokens/reportGenerator.mjs +232 -0
  11. package/bin/ai-tokens/transcriptParser.mjs +299 -0
  12. package/bin/ai-tokens.mjs +38 -1030
  13. package/bin/cli.mjs +14 -10
  14. package/bin/preset-contracts.json +66 -10
  15. package/dist/compiled/composables/locales/asianAndPacific.mjs +296 -0
  16. package/dist/compiled/composables/locales/northernAndEasternEuropean.mjs +342 -0
  17. package/dist/compiled/composables/locales/westernEuropean.mjs +268 -0
  18. package/dist/compiled/composables/locales.mjs +28 -895
  19. package/dist/compiled/composables/useDataProvider.mjs +3 -1
  20. package/dist/compiled/composables/useKatluxForm.mjs +7 -7
  21. package/dist/compiled/composables/usePresetComponent.mjs +2 -0
  22. package/dist/compiled/composables/useRequestQueue.mjs +3 -1
  23. package/dist/compiled/composables/useVirtualDataset.mjs +322 -354
  24. package/dist/compiled/composables/useVirtualScroll.mjs +69 -62
  25. package/dist/compiled/composables/virtualDataset/cacheStateHelpers.mjs +76 -0
  26. package/dist/compiled/composables/virtualDataset/keyboardNavHelpers.mjs +60 -0
  27. package/dist/compiled/composables/virtualDataset/treeSelectionHelpers.mjs +103 -0
  28. package/dist/compiled/composables/virtualDataset/types.mjs +0 -0
  29. package/dist/compiled/utils/deprecation.mjs +44 -0
  30. package/dist/compiled/utils/dom.mjs +124 -0
  31. package/dist/module.cjs +0 -5
  32. package/dist/module.json +1 -1
  33. package/dist/module.mjs +1 -6
  34. package/dist/runtime/app.config.d.ts +3 -0
  35. package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +1 -1
  36. package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +1 -1
  37. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +8 -0
  38. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -55
  39. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +2 -2
  40. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +2 -2
  41. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  42. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +4 -4
  43. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +4 -4
  44. package/dist/runtime/components/KCalendar/KCalendar.logic.js +8 -4
  45. package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +4 -0
  46. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +2 -0
  47. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +41 -26
  48. package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
  49. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  50. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  51. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +17 -2
  52. package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
  53. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +17 -2
  54. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +10 -2
  55. package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
  56. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +7 -7
  57. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +7 -7
  58. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  59. package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +3 -3
  60. package/dist/runtime/components/KContextMenu/KContextMenu.global.vue +4 -1
  61. package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +3 -3
  62. package/dist/runtime/components/KContextMenu/KContextMenu.logic.d.ts +24 -4
  63. package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +43 -27
  64. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +25 -2
  65. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +19 -7
  66. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +25 -2
  67. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +20 -0
  68. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +54 -14
  69. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +1 -1
  70. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +1 -1
  71. package/dist/runtime/components/KDatatable/KDatatable.logic.js +6 -5
  72. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +5 -3
  73. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +45 -26
  74. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +5 -3
  75. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -0
  76. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +66 -20
  77. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
  78. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
  79. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +4 -4
  80. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +4 -4
  81. package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +3 -2
  82. package/dist/runtime/components/KDropdown/KDropdown.logic.js +14 -13
  83. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +3 -1
  84. package/dist/runtime/components/KGantt/KGantt.global.vue +7 -1
  85. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +3 -1
  86. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
  87. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
  88. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
  89. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
  90. package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
  91. package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
  92. package/dist/runtime/components/KLayout/KLayout.global.d.vue.ts +4 -1
  93. package/dist/runtime/components/KLayout/KLayout.global.vue +4 -1
  94. package/dist/runtime/components/KLayout/KLayout.global.vue.d.ts +4 -1
  95. package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +9 -0
  96. package/dist/runtime/components/KLoader/KLoader.global.vue +1 -0
  97. package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +9 -0
  98. package/dist/runtime/components/KLoader/KLoader.logic.d.ts +5 -0
  99. package/dist/runtime/components/KLoader/KLoader.logic.js +4 -0
  100. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
  101. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
  102. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +30 -7
  103. package/dist/runtime/components/KMultiTabs/KMultiTabs.logic.d.ts +1 -0
  104. package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +6 -4
  105. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -1
  106. package/dist/runtime/components/KPagination/KPagination.logic.js +17 -9
  107. package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
  108. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
  109. package/dist/runtime/components/KTabs/KTabs.logic.js +33 -11
  110. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +2 -2
  111. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
  112. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +14 -3
  113. package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
  114. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +14 -3
  115. package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +5 -0
  116. package/dist/runtime/components/KTextbox/KTextbox.logic.js +4 -0
  117. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  118. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  119. package/dist/runtime/components/KTooltip/KTooltip.logic.d.ts +11 -2
  120. package/dist/runtime/components/KTooltip/KTooltip.logic.js +7 -5
  121. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  122. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  123. package/dist/runtime/components/KTree/KTree.logic.js +21 -1
  124. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +8 -4
  125. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -2
  126. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +8 -4
  127. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -2
  128. package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +10 -1
  129. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
  130. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
  131. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +1 -1
  132. package/dist/runtime/components/KTreeView/KTreeView.logic.js +36 -12
  133. package/dist/runtime/composables/locales/asianAndPacific.d.ts +11 -0
  134. package/dist/runtime/composables/locales/asianAndPacific.js +296 -0
  135. package/dist/runtime/composables/locales/northernAndEasternEuropean.d.ts +12 -0
  136. package/dist/runtime/composables/locales/northernAndEasternEuropean.js +342 -0
  137. package/dist/runtime/composables/locales/westernEuropean.d.ts +10 -0
  138. package/dist/runtime/composables/locales/westernEuropean.js +268 -0
  139. package/dist/runtime/composables/locales.d.ts +4 -24
  140. package/dist/runtime/composables/locales.js +28 -895
  141. package/dist/runtime/composables/useDataProvider.js +3 -1
  142. package/dist/runtime/composables/useKatluxForm.js +7 -7
  143. package/dist/runtime/composables/usePresetComponent.js +2 -0
  144. package/dist/runtime/composables/useRequestQueue.d.ts +2 -0
  145. package/dist/runtime/composables/useRequestQueue.js +3 -1
  146. package/dist/runtime/composables/useVirtualDataset.d.ts +6 -118
  147. package/dist/runtime/composables/useVirtualDataset.js +322 -354
  148. package/dist/runtime/composables/useVirtualScroll.d.ts +9 -9
  149. package/dist/runtime/composables/useVirtualScroll.js +69 -62
  150. package/dist/runtime/composables/virtualDataset/cacheStateHelpers.d.ts +49 -0
  151. package/dist/runtime/composables/virtualDataset/cacheStateHelpers.js +76 -0
  152. package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.d.ts +26 -0
  153. package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.js +60 -0
  154. package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.d.ts +24 -0
  155. package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.js +103 -0
  156. package/dist/runtime/composables/virtualDataset/types.d.ts +113 -0
  157. package/dist/runtime/composables/virtualDataset/types.js +0 -0
  158. package/dist/runtime/directives/clickOutside.d.ts +1 -1
  159. package/dist/runtime/directives/clickOutside.js +41 -13
  160. package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -1
  161. package/dist/runtime/plugins/nuxtCompatPlugin.js +7 -0
  162. package/dist/runtime/plugins/toastPlugin.client.js +2 -2
  163. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +2 -0
  164. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +24 -0
  165. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +2 -0
  166. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +6 -5
  167. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
  168. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +27 -17
  169. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
  170. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -1
  171. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +10 -10
  172. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -1
  173. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.d.vue.ts +2 -0
  174. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +60 -21
  175. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
  176. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
  177. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +109 -15
  178. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
  179. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +1 -1
  180. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +14 -0
  181. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +1 -1
  182. package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +5 -2
  183. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +15 -12
  184. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +5 -2
  185. package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +10 -0
  186. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +23 -69
  187. package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +10 -0
  188. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
  189. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +22 -8
  190. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue.d.ts +6 -2
  191. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +2 -2
  192. package/dist/runtime/presets/default/components/KLoader/KLoader.d.vue.ts +1 -0
  193. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +13 -2
  194. package/dist/runtime/presets/default/components/KLoader/KLoader.vue.d.ts +1 -0
  195. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -94
  196. package/dist/runtime/presets/default/components/KMultiTabs/KMultiTabs.vue +69 -4
  197. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +18 -46
  198. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +11 -23
  199. package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +4 -1
  200. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +24 -8
  201. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +4 -1
  202. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +1 -1
  203. package/dist/runtime/presets/default/components/KTree/KTree.vue +51 -80
  204. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
  205. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +1 -0
  206. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +12 -2
  207. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +1 -0
  208. package/dist/runtime/server/middleware/session.js +7 -0
  209. package/dist/runtime/utils/deprecation.d.ts +14 -0
  210. package/dist/runtime/utils/deprecation.js +44 -0
  211. package/dist/runtime/utils/dom.d.ts +31 -0
  212. package/dist/runtime/utils/dom.js +124 -0
  213. package/dist/skills/KATLUX_INDEX.md +15 -19
  214. package/dist/skills/katlux-components/components/KBulkActions.md +1 -1
  215. package/dist/skills/katlux-components/components/KDataIterator.md +5 -0
  216. package/dist/skills/katlux-components/components/KLayout.md +4 -0
  217. package/dist/skills/katlux-components/components/KLoader.md +3 -0
  218. package/dist/skills/katlux-components/components/KTextbox.md +1 -0
  219. package/dist/skills/katlux-config/SKILL.md +15 -7
  220. package/dist/skills/katlux-presets/SKILL.md +42 -2
  221. package/dist/skills/katlux-providers/SKILL.md +12 -0
  222. package/dist/skills/katlux-providers/providers/ADataProvider.md +1 -0
  223. package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
  224. package/dist/skills/katlux-providers/providers/RequestProvider.md +2 -2
  225. package/dist/skills/katlux-providers/providers/encryption-field-level.md +5 -2
  226. package/dist/skills/katlux-providers/providers/encryption-key-management.md +5 -2
  227. package/dist/skills/katlux-providers/providers/encryption-searchable.md +150 -27
  228. package/dist/skills/katlux-providers/providers/encryption-symmetric.md +4 -1
  229. package/dist/skills/katlux-providers/providers/encryption-threat-model.md +12 -6
  230. package/dist/skills/katlux-providers/providers/encryption.md +1 -1
  231. package/package.json +3 -3
@@ -1,23 +1,23 @@
1
- import { type Ref, type ComputedRef } from 'vue';
1
+ import { type Ref, type ComputedRef, type MaybeRefOrGetter } from 'vue';
2
2
  export interface IUseVirtualScrollOptions<T> {
3
3
  /** Reactive array, computed ref, or getter function for items (optional if totalCount is provided) */
4
- items?: Ref<T[]> | ComputedRef<T[]> | (() => T[]);
4
+ items?: MaybeRefOrGetter<T[]>;
5
5
  /** Total count of items for virtualization (takes precedence over items.length if provided) */
6
- totalCount?: number | Ref<number> | ComputedRef<number> | (() => number);
6
+ totalCount?: MaybeRefOrGetter<number | undefined>;
7
7
  /** Optional on-demand item resolver callback for index */
8
8
  getItem?: (index: number) => T;
9
9
  /** Height of each item in px (default: 40) or dynamic calculation function */
10
- itemHeight?: number | ((item: T, index: number) => number) | Ref<number | ((item: T, index: number) => number)> | ComputedRef<number | ((item: T, index: number) => number)>;
10
+ itemHeight?: MaybeRefOrGetter<number | ((item: T, index: number) => number) | undefined>;
11
11
  /** Viewport height of the scroll container in px (default: 400) */
12
- containerHeight?: number | Ref<number> | ComputedRef<number> | (() => number);
12
+ containerHeight?: MaybeRefOrGetter<number | undefined>;
13
13
  /** Number of buffer items above and below the visible window (default: 5) */
14
- buffer?: number | Ref<number>;
14
+ buffer?: MaybeRefOrGetter<number | undefined>;
15
15
  /** Parametric opt-in flag. When false, returns all items with 0 spacers (default: false) */
16
- virtualScroll?: boolean | Ref<boolean>;
16
+ virtualScroll?: MaybeRefOrGetter<boolean | undefined>;
17
17
  /** Number of columns for grid virtualization (default: 1) */
18
- columns?: number | Ref<number>;
18
+ columns?: MaybeRefOrGetter<number | undefined>;
19
19
  /** Distance from bottom in px to trigger infinite/streaming load (default: 100) */
20
- scrollThreshold?: number;
20
+ scrollThreshold?: MaybeRefOrGetter<number | undefined>;
21
21
  /** Callback fired when user scrolls near the bottom */
22
22
  onThresholdReach?: () => void;
23
23
  }
@@ -1,18 +1,15 @@
1
- import { ref, computed, unref, watch, getCurrentScope, onScopeDispose } from "vue";
1
+ import { ref, computed, unref, toValue, watch, getCurrentScope, onScopeDispose } from "vue";
2
+ import { resolveElement } from "../utils/dom.js";
2
3
  export function useVirtualScroll(options) {
3
4
  const containerRef = ref(null);
4
5
  const scrollTop = ref(0);
5
6
  const resolveItems = () => {
6
- if (typeof options.items === "function") {
7
- return options.items();
8
- }
9
- return unref(options.items) || [];
7
+ return toValue(options.items) || [];
10
8
  };
11
9
  const allItems = computed(() => resolveItems());
12
10
  const resolveTotalCount = () => {
13
11
  if (options.totalCount !== void 0) {
14
- if (typeof options.totalCount === "function") return options.totalCount();
15
- const val = unref(options.totalCount);
12
+ const val = toValue(options.totalCount);
16
13
  return typeof val === "number" && val >= 0 ? val : 0;
17
14
  }
18
15
  return allItems.value.length;
@@ -20,34 +17,39 @@ export function useVirtualScroll(options) {
20
17
  const totalCount = computed(() => resolveTotalCount());
21
18
  const isVirtual = computed(() => {
22
19
  if (options.virtualScroll === void 0) return false;
23
- return unref(options.virtualScroll) === true;
20
+ return toValue(options.virtualScroll) === true;
24
21
  });
25
22
  const colCount = computed(() => {
26
- const c = unref(options.columns);
23
+ const c = toValue(options.columns);
27
24
  return typeof c === "number" && c > 1 ? c : 1;
28
25
  });
29
26
  const buf = computed(() => {
30
- const b = unref(options.buffer);
31
- return typeof b === "number" ? b : 5;
27
+ const b = toValue(options.buffer);
28
+ return typeof b === "number" && Number.isFinite(b) && b >= 0 ? b : 5;
32
29
  });
33
30
  const defaultHeight = 40;
34
- const getItemHeight = (item, index) => {
31
+ const resolveItemHeightOption = () => {
35
32
  const raw = unref(options.itemHeight);
33
+ if (typeof raw === "function" && raw.length === 0) {
34
+ return raw();
35
+ }
36
+ return raw;
37
+ };
38
+ const getItemHeight = (item, index) => {
39
+ const raw = resolveItemHeightOption();
36
40
  if (typeof raw === "function") {
37
- return raw(item, index);
41
+ const h = raw(item, index);
42
+ return typeof h === "number" && Number.isFinite(h) && h > 0 ? h : defaultHeight;
38
43
  }
39
44
  return typeof raw === "number" && raw > 0 ? raw : defaultHeight;
40
45
  };
41
46
  const baseItemHeight = computed(() => {
42
- const h = unref(options.itemHeight);
47
+ const h = resolveItemHeightOption();
43
48
  if (typeof h === "number" && h > 0) return h;
44
49
  return defaultHeight;
45
50
  });
46
51
  const resolveContainerHeight = () => {
47
- if (typeof options.containerHeight === "function") {
48
- return options.containerHeight() || 400;
49
- }
50
- const val = unref(options.containerHeight);
52
+ const val = toValue(options.containerHeight);
51
53
  return typeof val === "number" && val > 0 ? val : 400;
52
54
  };
53
55
  const configuredContainerHeight = computed(() => resolveContainerHeight());
@@ -62,32 +64,37 @@ export function useVirtualScroll(options) {
62
64
  );
63
65
  watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
64
66
  if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
65
- if (oldEl && oldEl.__vsObserver) {
66
- oldEl.__vsObserver.disconnect();
67
- delete oldEl.__vsObserver;
67
+ const prevEl = resolveElement(oldEl) ?? oldEl;
68
+ if (prevEl && prevEl.__vsObserver) {
69
+ ;
70
+ prevEl.__vsObserver.disconnect();
71
+ delete prevEl.__vsObserver;
68
72
  }
69
- if (el && virtual) {
73
+ const targetEl = resolveElement(el) ?? el;
74
+ if (targetEl && virtual && typeof Element !== "undefined" && targetEl instanceof Element) {
70
75
  const ro = new ResizeObserver((entries) => {
71
76
  for (const entry of entries) {
72
- const h = Math.round(entry.contentRect.height || el.clientHeight);
77
+ const h = Math.round(entry.contentRect.height || targetEl.clientHeight);
73
78
  if (h > 0 && h !== viewportHeight.value) {
74
79
  viewportHeight.value = h;
75
80
  }
76
81
  }
77
82
  });
78
- ro.observe(el);
79
- el.__vsObserver = ro;
83
+ ro.observe(targetEl);
84
+ targetEl.__vsObserver = ro;
80
85
  }
81
86
  });
82
87
  if (getCurrentScope()) {
83
88
  onScopeDispose(() => {
84
- if (containerRef.value && containerRef.value.__vsObserver) {
85
- containerRef.value.__vsObserver.disconnect();
86
- delete containerRef.value.__vsObserver;
89
+ const targetEl = resolveElement(containerRef.value) ?? containerRef.value;
90
+ if (targetEl && targetEl.__vsObserver) {
91
+ ;
92
+ targetEl.__vsObserver.disconnect();
93
+ delete targetEl.__vsObserver;
87
94
  }
88
95
  });
89
96
  }
90
- const isDynamicHeight = computed(() => typeof unref(options.itemHeight) === "function");
97
+ const isDynamicHeight = computed(() => typeof resolveItemHeightOption() === "function");
91
98
  const rowOffsets = computed(() => {
92
99
  if (!isDynamicHeight.value || colCount.value > 1) return [];
93
100
  const count = totalCount.value;
@@ -208,14 +215,22 @@ export function useVirtualScroll(options) {
208
215
  }
209
216
  }
210
217
  });
211
- const containerCssVars = computed(() => ({
212
- "--virtual-spacer-top": `${topSpacerHeight.value}px`,
213
- "--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
214
- "--virtual-total-height": `${totalHeight.value}px`,
215
- "--virtual-item-height": `${baseItemHeight.value}px`,
216
- "--virtual-container-height": `${configuredContainerHeight.value}px`
217
- }));
218
- const scrollThreshold = options.scrollThreshold ?? 100;
218
+ const containerCssVars = computed(() => {
219
+ const vars = {
220
+ "--virtual-spacer-top": `${topSpacerHeight.value}px`,
221
+ "--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
222
+ "--virtual-total-height": `${totalHeight.value}px`,
223
+ "--virtual-container-height": `${configuredContainerHeight.value}px`
224
+ };
225
+ if (!isDynamicHeight.value) {
226
+ vars["--virtual-item-height"] = `${baseItemHeight.value}px`;
227
+ }
228
+ return vars;
229
+ });
230
+ const scrollThreshold = computed(() => {
231
+ const val = toValue(options.scrollThreshold);
232
+ return typeof val === "number" && Number.isFinite(val) && val >= 0 ? val : 100;
233
+ });
219
234
  const onScroll = (e) => {
220
235
  const target = e.target;
221
236
  if (!target) return;
@@ -224,43 +239,35 @@ export function useVirtualScroll(options) {
224
239
  viewportHeight.value = target.clientHeight;
225
240
  }
226
241
  const distanceToBottom = target.scrollHeight - (target.scrollTop + target.clientHeight);
227
- if (distanceToBottom <= scrollThreshold && typeof options.onThresholdReach === "function") {
242
+ if (distanceToBottom <= scrollThreshold.value && typeof options.onThresholdReach === "function") {
228
243
  options.onThresholdReach();
229
244
  }
230
245
  };
246
+ const applyScrollTop = (targetScrollTop, behavior) => {
247
+ const el = resolveElement(containerRef.value) ?? containerRef.value;
248
+ if (!el) return;
249
+ el.scrollTop = targetScrollTop;
250
+ if (typeof el.scrollTo === "function") {
251
+ try {
252
+ el.scrollTo({
253
+ top: targetScrollTop,
254
+ behavior
255
+ });
256
+ } catch {
257
+ }
258
+ }
259
+ };
231
260
  const scrollToIndex = (index, behavior = "auto", offset = 0) => {
232
261
  if (isDynamicHeight.value && colCount.value <= 1) {
233
262
  const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
234
263
  scrollTop.value = targetScrollTop2;
235
- if (containerRef.value) {
236
- containerRef.value.scrollTop = targetScrollTop2;
237
- if (typeof containerRef.value.scrollTo === "function") {
238
- try {
239
- containerRef.value.scrollTo({
240
- top: targetScrollTop2,
241
- behavior
242
- });
243
- } catch {
244
- }
245
- }
246
- }
264
+ applyScrollTop(targetScrollTop2, behavior);
247
265
  return;
248
266
  }
249
267
  const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
250
268
  const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
251
269
  scrollTop.value = targetScrollTop;
252
- if (containerRef.value) {
253
- containerRef.value.scrollTop = targetScrollTop;
254
- if (typeof containerRef.value.scrollTo === "function") {
255
- try {
256
- containerRef.value.scrollTo({
257
- top: targetScrollTop,
258
- behavior
259
- });
260
- } catch {
261
- }
262
- }
263
- }
270
+ applyScrollTop(targetScrollTop, behavior);
264
271
  };
265
272
  return {
266
273
  startIndex,
@@ -0,0 +1,49 @@
1
+ import type { IUseDataProviderReturn } from '../useDataProvider.js';
2
+ export interface IVirtualProviderSnapshot {
3
+ provider: any;
4
+ stateVersion: number;
5
+ pageRowsRef: any[];
6
+ allDataRef: any;
7
+ loading: boolean;
8
+ initialLoad: boolean;
9
+ error: any;
10
+ rowCount: number;
11
+ currentPage: number;
12
+ batchGeneration: any;
13
+ loadedBatchesSize: number;
14
+ batchProgress: any;
15
+ isBatchLoading: boolean;
16
+ customChangeCount: number;
17
+ }
18
+ /**
19
+ * Type guard identifying an initialized `useDataProvider` composable return object.
20
+ */
21
+ export declare function isUseDataProviderReturn<T>(val: any): val is IUseDataProviderReturn<T>;
22
+ /**
23
+ * Resolves the underlying dataset array reference from a client/server/tree DataProvider.
24
+ */
25
+ export declare function resolveProviderAllDataRef(dp: any): any;
26
+ /**
27
+ * Resolves the ordered item source array exposed to the virtual scroll window.
28
+ */
29
+ export declare function resolveVirtualItemsArray<T>(dp: any, fallbackPageRows: T[], isVirtual: boolean): T[];
30
+ /**
31
+ * Resolves total scrollable item count for virtual window calculations.
32
+ */
33
+ export declare function resolveVirtualTotalCount<T>(dp: any, bridgeRowCount: number | undefined, datasetItems: T[], pageRowsLength: number, isVirtual: boolean): number;
34
+ /**
35
+ * Classifies a provider state change so `useVirtualDataset` can distinguish cache-preserving
36
+ * page switches from full dataset invalidations.
37
+ */
38
+ export declare function classifyVirtualStateChange(params: {
39
+ dp: any;
40
+ dpBridgeStateVersion: number;
41
+ pageRowsRef: any[];
42
+ loading: boolean;
43
+ initialLoad: boolean;
44
+ error: any;
45
+ currentPage: number;
46
+ customChangeCount: number;
47
+ isFetchingPage: boolean;
48
+ snapshot: IVirtualProviderSnapshot;
49
+ }): 'none' | 'pageSwitch' | 'skip' | 'invalidate';
@@ -0,0 +1,76 @@
1
+ import { isRef, unref } from "vue";
2
+ export function isUseDataProviderReturn(val) {
3
+ return val !== null && typeof val === "object" && "pageData" in val && isRef(val.pageData) && "stateVersion" in val && isRef(val.stateVersion);
4
+ }
5
+ export function resolveProviderAllDataRef(dp) {
6
+ if (!dp) return void 0;
7
+ return dp.allData?.value ?? dp.allData ?? dp.rowMap?.value ?? dp.rowMap ?? dp.data;
8
+ }
9
+ export function resolveVirtualItemsArray(dp, fallbackPageRows, isVirtual) {
10
+ if (isVirtual && dp) {
11
+ const candidates = [
12
+ dp.rowMap,
13
+ dp.rowMap?.value,
14
+ dp.allVisibleRows,
15
+ dp.allVisibleRows?.value,
16
+ dp.allVisibleNodes,
17
+ dp.allVisibleNodes?.value,
18
+ dp.visibleRows,
19
+ dp.visibleRows?.value,
20
+ dp.filteredData?.value,
21
+ dp.filteredData,
22
+ dp.allData?.value,
23
+ dp.allData,
24
+ dp.data
25
+ ];
26
+ for (const candidate of candidates) {
27
+ if (Array.isArray(candidate)) return candidate;
28
+ }
29
+ }
30
+ return fallbackPageRows;
31
+ }
32
+ export function resolveVirtualTotalCount(dp, bridgeRowCount, datasetItems, pageRowsLength, isVirtual) {
33
+ if (!isVirtual) return pageRowsLength;
34
+ if (dp?.paginateBy === "root" && Array.isArray(dp.allVisibleRows)) {
35
+ return dp.allVisibleRows.length;
36
+ }
37
+ const rc = bridgeRowCount ?? dp?.rowCount;
38
+ const count = typeof rc === "number" ? rc : unref(rc);
39
+ if (typeof count === "number" && (count > 0 || datasetItems.length === 0)) return count;
40
+ if (Array.isArray(dp?.rowMap)) {
41
+ return dp.rowMap.length;
42
+ }
43
+ return datasetItems.length;
44
+ }
45
+ export function classifyVirtualStateChange(params) {
46
+ const { dp, snapshot } = params;
47
+ if (dp !== snapshot.provider) {
48
+ return "invalidate";
49
+ }
50
+ const stateChanged = params.dpBridgeStateVersion !== snapshot.stateVersion;
51
+ const pageChanged = params.pageRowsRef !== snapshot.pageRowsRef;
52
+ const allDataChanged = resolveProviderAllDataRef(dp) !== snapshot.allDataRef;
53
+ const customChanged = params.customChangeCount !== snapshot.customChangeCount;
54
+ if (!stateChanged && !pageChanged && !allDataChanged && !customChanged) {
55
+ return "none";
56
+ }
57
+ const batchGenNow = dp?._batchGeneration;
58
+ const loadedBatchesSizeNow = dp?.loadedBatches instanceof Set ? dp.loadedBatches.size : 0;
59
+ const isIncrementalBatchAppend = Boolean(
60
+ dp && dp.batchLoad === "onDemand" && dp.loadedBatches instanceof Set && batchGenNow === snapshot.batchGeneration && loadedBatchesSizeNow > snapshot.loadedBatchesSize
61
+ );
62
+ if (isIncrementalBatchAppend && !customChanged) {
63
+ return "skip";
64
+ }
65
+ if (params.currentPage !== snapshot.currentPage && !allDataChanged && !customChanged) {
66
+ return "pageSwitch";
67
+ }
68
+ if (pageChanged || allDataChanged || customChanged) {
69
+ return "invalidate";
70
+ }
71
+ const loadingChanged = params.loading !== snapshot.loading || params.initialLoad !== snapshot.initialLoad || params.error !== snapshot.error || dp?.batchProgress !== snapshot.batchProgress || Boolean(dp?.isBatchLoading) !== snapshot.isBatchLoading;
72
+ if (loadingChanged || params.isFetchingPage) {
73
+ return "skip";
74
+ }
75
+ return "invalidate";
76
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Resolves measured `<thead>` height from the scroll container DOM or falls back to configured offset.
3
+ */
4
+ export declare function resolveDomTheadOffset(container: HTMLElement | null, fallbackOffset: number): number;
5
+ /**
6
+ * Resolves rendered row height in pixels from DOM measurement or static numeric option.
7
+ */
8
+ export declare function resolveDomItemHeight(container: HTMLElement | null, optionHeight: number | ((item: any, index: number) => number) | undefined): number;
9
+ /**
10
+ * Resolves effective viewport height in pixels from container DOM measurement, reactive height, or options.
11
+ */
12
+ export declare function resolveDomViewportHeight(container: HTMLElement | null, measuredHeight: number, optionHeight: number | undefined): number;
13
+ /**
14
+ * Computes next focused row index for virtualized Arrow/PageUp/PageDown/Home/End navigation keys.
15
+ */
16
+ export declare function computeNextKeyboardFocusIndex(params: {
17
+ key: string;
18
+ currentFocus: number;
19
+ total: number;
20
+ firstInView: number;
21
+ lastInView: number;
22
+ pageStep: number;
23
+ }): {
24
+ nextIndex: number;
25
+ scrollMode: 'ensureVisible' | 'home' | 'end';
26
+ } | null;
@@ -0,0 +1,60 @@
1
+ export function resolveDomTheadOffset(container, fallbackOffset) {
2
+ if (container) {
3
+ const thead = container.querySelector("thead");
4
+ if (thead && thead.offsetHeight > 0) {
5
+ return thead.offsetHeight;
6
+ }
7
+ }
8
+ return fallbackOffset;
9
+ }
10
+ export function resolveDomItemHeight(container, optionHeight) {
11
+ if (container) {
12
+ const rowEl = container.querySelector('tbody tr, [role="row"]');
13
+ if (rowEl && rowEl.offsetHeight > 0) {
14
+ return rowEl.offsetHeight;
15
+ }
16
+ }
17
+ if (typeof optionHeight === "function") return 40;
18
+ return typeof optionHeight === "number" && optionHeight > 0 ? optionHeight : 40;
19
+ }
20
+ export function resolveDomViewportHeight(container, measuredHeight, optionHeight) {
21
+ if (container && container.clientHeight > 0) {
22
+ return container.clientHeight;
23
+ }
24
+ if (measuredHeight > 0) {
25
+ return measuredHeight;
26
+ }
27
+ return typeof optionHeight === "number" && optionHeight > 0 ? optionHeight : 500;
28
+ }
29
+ export function computeNextKeyboardFocusIndex(params) {
30
+ const { key, currentFocus, total, firstInView, lastInView, pageStep } = params;
31
+ const outOfView = currentFocus < firstInView || currentFocus > lastInView;
32
+ switch (key) {
33
+ case "ArrowDown":
34
+ return {
35
+ nextIndex: outOfView ? Math.min(total - 1, firstInView) : Math.min(total - 1, currentFocus + 1),
36
+ scrollMode: "ensureVisible"
37
+ };
38
+ case "ArrowUp":
39
+ return {
40
+ nextIndex: outOfView ? Math.max(0, lastInView) : Math.max(0, currentFocus - 1),
41
+ scrollMode: "ensureVisible"
42
+ };
43
+ case "PageDown":
44
+ return {
45
+ nextIndex: outOfView ? Math.min(total - 1, firstInView + pageStep) : Math.min(total - 1, currentFocus + pageStep),
46
+ scrollMode: "ensureVisible"
47
+ };
48
+ case "PageUp":
49
+ return {
50
+ nextIndex: outOfView ? Math.max(0, lastInView - pageStep) : Math.max(0, currentFocus - pageStep),
51
+ scrollMode: "ensureVisible"
52
+ };
53
+ case "Home":
54
+ return { nextIndex: 0, scrollMode: "home" };
55
+ case "End":
56
+ return { nextIndex: total - 1, scrollMode: "end" };
57
+ default:
58
+ return null;
59
+ }
60
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Resolves a row's canonical identifier using explicit `idKey` or standard fallbacks (`id`, `_id`, `__treeNode.id`).
3
+ */
4
+ export declare function extractVirtualRowId(row: any, idKey: string): any;
5
+ /**
6
+ * Resolves all descendant rows (including the target root row) in a hierarchical dataset for cascade selection.
7
+ */
8
+ export declare function getTreeBranchRows(row: any, dp: any, fallbackRows: any[], idKey: string): any[];
9
+ /**
10
+ * Walks upward along parent references to collect ancestor node IDs for partial unselection cascades.
11
+ */
12
+ export declare function getTreeAncestorIds(row: any, dp: any, fallbackRows: any[], idKey: string): any[];
13
+ /**
14
+ * Builds a lookup set containing both extracted IDs and raw object references for selection membership checks.
15
+ */
16
+ export declare function buildSelectionIdSet(rows: any[] | undefined, idKey: string): Set<any>;
17
+ /**
18
+ * Detects whether a cell value carries an encrypted payload envelope or provider ciphertext format.
19
+ */
20
+ export declare function detectEncryptedCellValue(val: any, rawProvider: any): boolean;
21
+ /**
22
+ * Computes next `selectedRows` array when toggling select-all in page-scoped mode.
23
+ */
24
+ export declare function computePageScopedSelectAllRows(datasetItems: any[], currentSelected: any[], selectedRowIds: Set<any>, dp: any, idKey: string, allSelected: boolean): any[];
@@ -0,0 +1,103 @@
1
+ import { unref } from "vue";
2
+ import { isEncrypted } from "@katlux/providers";
3
+ export function extractVirtualRowId(row, idKey) {
4
+ return row?.[idKey] ?? row?.id ?? row?._id ?? row?.__treeNode?.id;
5
+ }
6
+ export function getTreeBranchRows(row, dp, fallbackRows, idKey) {
7
+ if (!dp || !("parentKey" in dp) && typeof dp.toggleNode !== "function") {
8
+ return [row];
9
+ }
10
+ const parentKey = dp.parentKey || "parentId";
11
+ const sourceRows = unref(dp.allData) || fallbackRows || [];
12
+ const rootId = extractVirtualRowId(row, idKey);
13
+ if (rootId === null || rootId === void 0) return [row];
14
+ const childrenByParent = /* @__PURE__ */ new Map();
15
+ for (const r of sourceRows) {
16
+ const pId = r?.__treeNode?.parentId ?? r?.[parentKey];
17
+ if (pId === null || pId === void 0) continue;
18
+ let list = childrenByParent.get(pId);
19
+ if (!list) {
20
+ list = [];
21
+ childrenByParent.set(pId, list);
22
+ }
23
+ list.push(r);
24
+ }
25
+ const result = [row];
26
+ const visited = /* @__PURE__ */ new Set([rootId]);
27
+ const queue = [rootId];
28
+ while (queue.length > 0) {
29
+ const curr = queue.shift();
30
+ for (const child of childrenByParent.get(curr) || []) {
31
+ const cId = extractVirtualRowId(child, idKey);
32
+ if (cId !== null && cId !== void 0 && !visited.has(cId)) {
33
+ visited.add(cId);
34
+ result.push(child);
35
+ queue.push(cId);
36
+ }
37
+ }
38
+ }
39
+ return result;
40
+ }
41
+ export function getTreeAncestorIds(row, dp, fallbackRows, idKey) {
42
+ if (!dp || !("parentKey" in dp) && typeof dp.toggleNode !== "function") return [];
43
+ const parentKey = dp.parentKey || "parentId";
44
+ const sourceRows = unref(dp.allData) || fallbackRows || [];
45
+ const parentById = /* @__PURE__ */ new Map();
46
+ for (const r of sourceRows) {
47
+ const id = extractVirtualRowId(r, idKey);
48
+ if (id !== null && id !== void 0) parentById.set(id, r?.__treeNode?.parentId ?? r?.[parentKey] ?? null);
49
+ }
50
+ const ancestors = [];
51
+ const startId = extractVirtualRowId(row, idKey);
52
+ const visited = /* @__PURE__ */ new Set([startId]);
53
+ let currParent = row?.__treeNode?.parentId ?? row?.[parentKey] ?? parentById.get(startId) ?? null;
54
+ while (currParent !== null && currParent !== void 0 && !visited.has(currParent)) {
55
+ visited.add(currParent);
56
+ ancestors.push(currParent);
57
+ currParent = parentById.get(currParent) ?? null;
58
+ }
59
+ return ancestors;
60
+ }
61
+ export function buildSelectionIdSet(rows, idKey) {
62
+ const set = /* @__PURE__ */ new Set();
63
+ for (const r of rows || []) {
64
+ const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
65
+ set.add(id);
66
+ set.add(r);
67
+ }
68
+ return set;
69
+ }
70
+ export function detectEncryptedCellValue(val, rawProvider) {
71
+ if (!val || typeof val !== "object") return false;
72
+ if (val.__encrypted === true) return true;
73
+ const cipher = rawProvider?.cipherProvider;
74
+ if (cipher && typeof cipher.isEncrypted === "function") {
75
+ return cipher.isEncrypted(val);
76
+ }
77
+ return typeof isEncrypted === "function" ? isEncrypted(val) : false;
78
+ }
79
+ export function computePageScopedSelectAllRows(datasetItems, currentSelected, selectedRowIds, dp, idKey, allSelected) {
80
+ if (allSelected) {
81
+ const pageIdSet = new Set(
82
+ datasetItems.flatMap(
83
+ (r) => getTreeBranchRows(r, dp, datasetItems, idKey).map((b) => b?.[idKey] ?? b?.id ?? b?._id ?? b)
84
+ )
85
+ );
86
+ return currentSelected.filter((r) => {
87
+ const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
88
+ return !pageIdSet.has(id) && !pageIdSet.has(r);
89
+ });
90
+ }
91
+ const existingIds = new Set(selectedRowIds);
92
+ const toAdd = [];
93
+ for (const r of datasetItems) {
94
+ for (const item of getTreeBranchRows(r, dp, datasetItems, idKey)) {
95
+ const id = item?.[idKey] ?? item?.id ?? item?._id ?? item;
96
+ if (!existingIds.has(id) && !existingIds.has(item)) {
97
+ existingIds.add(id);
98
+ toAdd.push(item);
99
+ }
100
+ }
101
+ }
102
+ return [...currentSelected, ...toAdd];
103
+ }