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

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 (207) hide show
  1. package/bin/ai-init.mjs +517 -0
  2. package/bin/ai-tokens.mjs +1043 -0
  3. package/bin/cli.mjs +80 -43
  4. package/bin/create-preset.mjs +1 -0
  5. package/bin/preset-contracts.json +2941 -0
  6. package/dist/compiled/composables/locales.mjs +204 -25
  7. package/dist/compiled/composables/useDataProvider.mjs +36 -25
  8. package/dist/compiled/composables/useFilterLogic.mjs +10 -2
  9. package/dist/compiled/composables/useKatluxForm.mjs +6 -4
  10. package/dist/compiled/composables/useVirtualDataset.mjs +689 -0
  11. package/dist/compiled/composables/useVirtualScroll.mjs +29 -9
  12. package/dist/module.cjs +63 -77
  13. package/dist/module.d.cts +5 -0
  14. package/dist/module.d.mts +4 -1
  15. package/dist/module.json +1 -1
  16. package/dist/module.mjs +60 -78
  17. package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +2 -2
  18. package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +2 -2
  19. package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +1 -1
  20. package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +1 -1
  21. package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +7 -3
  22. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +4 -1
  23. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +7 -3
  24. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +4 -2
  25. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +70 -37
  26. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +2 -2
  27. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +2 -2
  28. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  29. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +19 -10
  30. package/dist/runtime/components/KCalendar/KCalendar.global.vue +7 -2
  31. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +19 -10
  32. package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +14 -201
  33. package/dist/runtime/components/KCalendar/KCalendar.logic.js +60 -11
  34. package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +25 -5
  35. package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +11 -1
  36. package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +25 -5
  37. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +19 -3
  38. package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +115 -1
  39. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +2 -2
  40. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +2 -2
  41. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +9 -9
  42. package/dist/runtime/components/KCombobox/KCombobox.global.vue +1 -1
  43. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +9 -9
  44. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +7 -1
  45. package/dist/runtime/components/KCombobox/KCombobox.logic.js +1 -1
  46. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +14 -14
  47. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +14 -14
  48. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  49. package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +5 -0
  50. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +22 -18
  51. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +23 -16
  52. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +22 -18
  53. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +13 -10
  54. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +25 -20
  55. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +9 -13
  56. package/dist/runtime/components/KDatatable/KDatatable.global.vue +6 -5
  57. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +9 -13
  58. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -6
  59. package/dist/runtime/components/KDatatable/KDatatable.logic.js +26 -19
  60. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +31 -15
  61. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +38 -13
  62. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +31 -15
  63. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +28 -6
  64. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +197 -53
  65. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +3 -3
  66. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +3 -3
  67. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +2 -0
  68. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
  69. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
  70. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +55 -6
  71. package/dist/runtime/components/KGantt/KGantt.global.vue +12 -3
  72. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +55 -6
  73. package/dist/runtime/components/KGantt/KGantt.logic.d.ts +33 -5
  74. package/dist/runtime/components/KGantt/KGantt.logic.js +39 -6
  75. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
  76. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
  77. package/dist/runtime/components/KHourSelect/KHourSelect.global.d.vue.ts +1 -1
  78. package/dist/runtime/components/KHourSelect/KHourSelect.global.vue.d.ts +1 -1
  79. package/dist/runtime/components/KLoader/KLoader.global.vue +2 -0
  80. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +2 -2
  81. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
  82. package/dist/runtime/components/KMultiTabs/MultiTabs.global.d.vue.ts +23 -0
  83. package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +22 -0
  84. package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue.d.ts +23 -0
  85. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +4 -2
  86. package/dist/runtime/components/KPagination/KPagination.global.vue +2 -1
  87. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +4 -2
  88. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  89. package/dist/runtime/components/KPagination/KPagination.logic.js +57 -5
  90. package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
  91. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
  92. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
  93. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
  94. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  95. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  96. package/dist/runtime/components/KTabs/KTabs.global.d.vue.ts +2 -2
  97. package/dist/runtime/components/KTabs/KTabs.global.vue.d.ts +2 -2
  98. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +2 -2
  99. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
  100. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +3 -3
  101. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +3 -3
  102. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +3 -3
  103. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +3 -3
  104. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  105. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  106. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +7 -7
  107. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +7 -7
  108. package/dist/runtime/components/KTree/KTree.logic.d.ts +2 -2
  109. package/dist/runtime/components/KTree/KTree.logic.js +16 -12
  110. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +7 -9
  111. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +1 -5
  112. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +7 -9
  113. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +39 -5
  114. package/dist/runtime/components/KTreeView/KTreeView.global.vue +19 -1
  115. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +39 -5
  116. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +23 -3
  117. package/dist/runtime/components/KTreeView/KTreeView.logic.js +76 -6
  118. package/dist/runtime/composables/locales.js +204 -25
  119. package/dist/runtime/composables/useDataProvider.d.ts +5 -3
  120. package/dist/runtime/composables/useDataProvider.js +36 -25
  121. package/dist/runtime/composables/useFilterLogic.d.ts +16 -4
  122. package/dist/runtime/composables/useFilterLogic.js +10 -2
  123. package/dist/runtime/composables/useKatluxForm.d.ts +4 -4
  124. package/dist/runtime/composables/useKatluxForm.js +6 -4
  125. package/dist/runtime/composables/useSortLogic.d.ts +1 -1
  126. package/dist/runtime/composables/useVirtualDataset.d.ts +121 -0
  127. package/dist/runtime/composables/useVirtualDataset.js +689 -0
  128. package/dist/runtime/composables/useVirtualScroll.d.ts +8 -4
  129. package/dist/runtime/composables/useVirtualScroll.js +29 -9
  130. package/dist/runtime/plugins/nuxtCompatPlugin.js +9 -1
  131. package/dist/runtime/presets/default/assets/scss/css-variables.css +3 -0
  132. package/dist/runtime/presets/default/assets/scss/css-variables.scss +6 -1
  133. package/dist/runtime/presets/default/assets/scss/index.css +3 -0
  134. package/dist/runtime/presets/default/assets/svg/katlux-logo.svg +7 -0
  135. package/dist/runtime/presets/default/assets/svg/katlux.svg +6 -0
  136. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.d.vue.ts +3 -2
  137. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +31 -3
  138. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +3 -2
  139. package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +3 -0
  140. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +6 -0
  141. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +3 -0
  142. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +5 -0
  143. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +33 -2
  144. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +5 -0
  145. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +2 -2
  146. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +2 -2
  147. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +7 -1
  148. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +30 -8
  149. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +80 -164
  150. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +30 -8
  151. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +16 -9
  152. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +99 -394
  153. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +16 -9
  154. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +6 -0
  155. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +71 -4
  156. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +6 -0
  157. package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +11 -12
  158. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +77 -14
  159. package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +11 -12
  160. package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +1 -0
  161. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +2 -2
  162. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +2 -2
  163. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +4 -4
  164. package/dist/runtime/presets/default/components/KTree/KTree.vue +48 -14
  165. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +4 -4
  166. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +11 -2
  167. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +14 -2
  168. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +11 -2
  169. package/dist/skills/KATLUX_INDEX.md +9 -6
  170. package/dist/skills/katlux-components/SKILL.md +2 -0
  171. package/dist/skills/katlux-components/components/KBulkActions.md +25 -1
  172. package/dist/skills/katlux-components/components/KCombobox.md +2 -2
  173. package/dist/skills/katlux-components/components/KDataIterator.md +12 -4
  174. package/dist/skills/katlux-components/components/KDatatable.md +38 -0
  175. package/dist/skills/katlux-components/components/KDatePicker.md +3 -1
  176. package/dist/skills/katlux-components/components/KGantt.md +9 -0
  177. package/dist/skills/katlux-components/components/KIcon.md +1 -1
  178. package/dist/skills/katlux-components/components/KLineChart.md +3 -0
  179. package/dist/skills/katlux-components/components/KProductList.md +0 -1
  180. package/dist/skills/katlux-components/components/KScatterChart.md +3 -0
  181. package/dist/skills/katlux-components/components/KTreePicker.md +2 -1
  182. package/dist/skills/katlux-components/components/KTreeView.md +12 -0
  183. package/dist/skills/katlux-config/SKILL.md +19 -8
  184. package/dist/skills/katlux-presets/SKILL.md +121 -1
  185. package/dist/skills/katlux-presets/creating-a-preset.md +67 -0
  186. package/dist/skills/katlux-providers/SKILL.md +7 -5
  187. package/dist/skills/katlux-providers/providers/ADataProvider.md +16 -9
  188. package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +27 -3
  189. package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +11 -1
  190. package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +19 -4
  191. package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +4 -2
  192. package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
  193. package/dist/skills/katlux-providers/providers/RequestProvider.md +10 -0
  194. package/dist/skills/katlux-providers/providers/encryption-field-level.md +63 -19
  195. package/dist/skills/katlux-providers/providers/encryption-key-management.md +20 -2
  196. package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +25 -11
  197. package/dist/skills/katlux-providers/providers/encryption-searchable.md +218 -0
  198. package/dist/skills/katlux-providers/providers/encryption-symmetric.md +25 -1
  199. package/dist/skills/katlux-providers/providers/encryption-threat-model.md +63 -0
  200. package/dist/skills/katlux-providers/providers/encryption.md +26 -1
  201. package/dist/skills/katlux-providers/providers/types.md +3 -1
  202. package/dist/skills/katlux-providers/providers/useDataProvider.md +2 -1
  203. package/dist/skills/katlux-providers/providers/useVirtualDataset.md +154 -0
  204. package/dist/skills/katlux-tokens/SKILL.md +2 -1
  205. package/dist/types.d.mts +1 -1
  206. package/package.json +9 -3
  207. package/bin/add-ai-reference.mjs +0 -259
@@ -0,0 +1,154 @@
1
+ ## 3.2.2. Vue 3 Integration: `useVirtualDataset` Composable
2
+
3
+ The `useVirtualDataset` composable is the unified high-performance virtualization bridge in `@katlux/toolkit`. It unites headless Katlux data providers (`ADataProvider`), DOM viewport windowing (`useVirtualScroll`), row delivery caching, and off-screen encryption retention into a single compile-safe composable.
4
+
5
+ Preset components (`KDatatable`, `KDataIterator`, or custom list/grid components) consume `useVirtualDataset` to render tens of thousands of records at 60 FPS without duplicating viewport or caching logic.
6
+
7
+ ---
8
+
9
+ ### Import
10
+ ```typescript
11
+ import { useVirtualDataset } from '#toolkit/composables/useVirtualDataset'
12
+ ```
13
+
14
+ ---
15
+
16
+ ### Options Interface (`IUseVirtualDatasetOptions<T>`)
17
+
18
+ | Option | Type | Default | Description |
19
+ | :--- | :--- | :--- | :--- |
20
+ | `provider` | `ADataProvider \| Ref<ADataProvider \| null> \| null` | `undefined` | Standalone Katlux data provider instance |
21
+ | `items` | `T[] \| Ref<T[]> \| null` | `undefined` | Static or local array of items (fallback if no provider is provided) |
22
+ | `itemHeight` | `number \| Ref<number> \| (() => number)` | `40` | Fixed or dynamic item row height in pixels |
23
+ | `viewportHeight` | `number \| Ref<number> \| (() => number)` | `500` | Height of the scroll container viewport in pixels |
24
+ | `buffer` | `number \| Ref<number>` | `5` | Overscan row buffer above and below visible window |
25
+ | `virtualScroll` | `boolean \| Ref<boolean>` | `true` | When `false`, disables windowing and serves regular paginated `pageData` |
26
+ | `scrollContainerRef` | `Ref<HTMLElement \| null>` | `undefined` | DOM container element to monitor scroll events |
27
+ | `pageSize` | `Ref<number> \| number` | `20` | Page size for internal client provider fallback |
28
+ | `currentPage` | `Ref<number> \| number` | `1` | External current page binding |
29
+ | `filter` | `Ref<IDataFilter \| null>` | `undefined` | Two-way reactive filter binding |
30
+ | `sortList` | `Ref<IDataSort[]>` | `undefined` | Two-way reactive sort list binding |
31
+ | `selectedRows` | `Ref<T[]>` | `ref([])` | Two-way bound array of selected row objects |
32
+ | `selectAll` | `Ref<boolean>` | `ref(false)` | Two-way bound select-all boolean state |
33
+ | `unselectedRows` | `Ref<T[]>` | `ref([])` | Two-way bound excluded rows when in dataset scope |
34
+ | `selectAllScope` | `Ref<'page' \| 'dataset'> \| 'page' \| 'dataset'` | `'dataset'` | Select-all scope (defaults to `'dataset'` for virtual scrolling) |
35
+ | `idKey` | `string` | `'id'` | Unique row identifier property name |
36
+
37
+ ---
38
+
39
+ ### Return Interface (`IUseVirtualDatasetReturn<T>`)
40
+
41
+ | Property | Type | Description |
42
+ | :--- | :--- | :--- |
43
+ | `visibleRows` | `ComputedRef<T[]>` | Sliced array of currently visible rows for the viewport |
44
+ | `totalCount` | `ComputedRef<number>` | Total records in dataset (filtered or unfiltered) |
45
+ | `topSpacerHeight` | `ComputedRef<number>` | Height (px) for top spacer element to balance scrollbar |
46
+ | `bottomSpacerHeight` | `ComputedRef<number>` | Height (px) for bottom spacer element to balance scrollbar |
47
+ | `startIndex` | `ComputedRef<number>` | Zero-based index of first row in visible window |
48
+ | `endIndex` | `ComputedRef<number>` | Zero-based index of last row in visible window |
49
+ | `loading` | `Ref<boolean>` | True when provider is fetching data from API/backend |
50
+ | `initialLoad` | `Ref<boolean>` | True during initial load |
51
+ | `error` | `Ref<any>` | Any error returned from the provider |
52
+ | `dpBridge` | `IUseDataProviderReturn<T>` | Underlying `useDataProvider` instance |
53
+ | `activeProvider` | `ComputedRef<ADataProvider \| null>` | The active resolved `ADataProvider` instance |
54
+ | `selectedRows` | `Ref<T[]>` | Selected row objects |
55
+ | `selectAll` | `Ref<boolean>` | Select-all header boolean |
56
+ | `unselectedRows` | `Ref<T[]>` | Deselected rows when `selectAll: true` in dataset mode |
57
+ | `isRowSelected` | `(row: T) => boolean` | Helper function to check if a row is selected |
58
+ | `toggleSelection` | `(row: T) => void` | Toggles selection state of a specific row |
59
+ | `toggleSelectAll` | `() => void` | Toggles header select-all state |
60
+ | `clearSelection` | `() => void` | Clears all selections |
61
+ | `activeRowIndex` | `Ref<number>` | Focused row index for keyboard accessibility |
62
+ | `setActiveRowIndex` | `(idx: number) => void` | Sets keyboard focused row index |
63
+ | `handleKeyNavigation` | `(event: KeyboardEvent) => boolean` | Handles ArrowUp, ArrowDown, PageUp, PageDown |
64
+ | `onScroll` | `(event: Event) => void` | Event handler to bind to the scroll container |
65
+ | `scrollToIndex` | `(index: number) => void` | Scrolls container directly to a specific row index |
66
+ | `invalidateCache` | `() => void` | Evicts the in-memory row delivery cache |
67
+
68
+ ---
69
+
70
+ ### Usage in Custom Preset Component (`KDatatable.vue`)
71
+
72
+ Preset components should use `useVirtualDataset` to handle all viewport windowing, row delivery caching, and selection state with zero boilerplate:
73
+
74
+ ```vue
75
+ <template lang="pug">
76
+ .k-datatable(:ref="containerRef" @scroll="virtual.onScroll" :style="{ maxHeight: `${viewportHeight}px`, overflowY: 'auto' }")
77
+ table
78
+ thead
79
+ tr
80
+ th(v-if="multiSelect")
81
+ KCheckbox(:modelValue="virtual.selectAll.value" @update:modelValue="virtual.toggleSelectAll")
82
+ th(v-for="col in columns" :key="col.field" @click="toggleSort(col.field)")
83
+ | {{ col.title }}
84
+ tbody
85
+ // 1. Top Spacer preserves correct scrollbar height
86
+ tr.spacer-top(v-if="virtualScroll && virtual.topSpacerHeight.value > 0")
87
+ td(:colspan="colSpan" :style="{ height: `${virtual.topSpacerHeight.value}px`, padding: 0 }")
88
+
89
+ // 2. Visible Window Rows
90
+ tr(
91
+ v-for="(row, idx) in virtual.visibleRows.value"
92
+ :key="row[idKey] || (virtual.startIndex.value + idx)"
93
+ :class="{ 'is-selected': virtual.isRowSelected(row), 'is-active': virtual.activeRowIndex.value === (virtual.startIndex.value + idx) }"
94
+ )
95
+ td(v-if="multiSelect")
96
+ KCheckbox(:modelValue="virtual.isRowSelected(row)" @update:modelValue="virtual.toggleSelection(row)")
97
+ td(v-for="col in columns" :key="col.field")
98
+ slot(:name="`cell-${col.field}`" :row="row" :value="row[col.field]")
99
+ | {{ row[col.field] }}
100
+
101
+ // 3. Bottom Spacer preserves correct scrollbar height
102
+ tr.spacer-bottom(v-if="virtualScroll && virtual.bottomSpacerHeight.value > 0")
103
+ td(:colspan="colSpan" :style="{ height: `${virtual.bottomSpacerHeight.value}px`, padding: 0 }")
104
+ </template>
105
+
106
+ <script setup lang="ts">
107
+ import { ref } from 'vue'
108
+ import { useVirtualDataset } from '#toolkit/composables/useVirtualDataset'
109
+
110
+ const props = withDefaults(defineProps<{
111
+ dataProvider?: any
112
+ items?: any[]
113
+ virtualScroll?: boolean
114
+ itemHeight?: number
115
+ viewportHeight?: number
116
+ multiSelect?: boolean
117
+ idKey?: string
118
+ }>(), {
119
+ virtualScroll: true,
120
+ itemHeight: 40,
121
+ viewportHeight: 500,
122
+ multiSelect: false,
123
+ idKey: 'id'
124
+ })
125
+
126
+ const containerRef = ref<HTMLElement | null>(null)
127
+
128
+ // Single composable binds provider, viewport windowing, selection, and caching:
129
+ const virtual = useVirtualDataset({
130
+ provider: () => props.dataProvider,
131
+ items: () => props.items,
132
+ itemHeight: () => props.itemHeight,
133
+ viewportHeight: () => props.viewportHeight,
134
+ virtualScroll: () => props.virtualScroll,
135
+ scrollContainerRef: containerRef,
136
+ idKey: props.idKey
137
+ })
138
+ </script>
139
+ ```
140
+
141
+ ---
142
+
143
+ ### Architectural Invariants
144
+
145
+ 1. **Zero-Proxy Reactivity Overhead (`markRaw`)**:
146
+ `ADataProvider` explicitly sets `__v_skip = true` on internal datasets to prevent Vue reactive proxies on 100,000+ items. `useVirtualDataset` tracks `dpBridge.stateVersion` and `filterSortVersion` tokens, ensuring reactive updates without compromising memory or performance.
147
+ 2. **Transparent Row Delivery Cache**:
148
+ Maintains a rolling `Map<number, T>` of delivered rows to avoid redundant queries when scrolling back and forth.
149
+ 3. **Encryption Retention**:
150
+ Off-screen encrypted items remain ciphertexts until scrolled into the visible window, keeping client RAM secure and lightweight.
151
+ 4. **Side-Channel Window Slicing (`resolveRangeRows`)**:
152
+ `useVirtualDataset` resolves and decrypts visible window slices via `dataProvider.resolveRangeRows(startIndex, endIndex)` without calling `dp.setCurrentPage()` or mutating `dp.currentPage` or `dp.pageData`. This isolates virtual scrolling from external `<KPagination>` components and URL query synchronization.
153
+ 5. **Progressive Virtual Accumulation (`BUG-050`)**:
154
+ When used with paginated API or server providers (`CAPIFlatClientDataProvider`, `CFlatServerDataProvider`, `CAPIFlatServerDataProvider`), `useVirtualDataset` monitors visible window boundaries and triggers `dp.loadMore()` whenever visible rows approach unretrieved pages (`end > datasetItems.length && dp.hasMore`). Providers accumulate incoming pages into `allData` with `idKey` deduplication, preserving earlier pages in the virtual list without rendering blank windows or mutating `dp.currentPage`.
@@ -54,7 +54,8 @@ Katlux Toolkit uses CSS Custom Properties (`var(--variable-name)`) scoped to `[d
54
54
  | **Buttons** | `--button-border-radius`, `--button-font-size-sm`, `--button-font-size-md`, `--button-font-size-lg`, `--button-bg-default`, `--button-text-default`, `--button-hover-bg-default`, `--button-bg-primary`, `--button-text-primary`, `--button-hover-bg-primary`, `--button-bg-success`, `--button-bg-warning`, `--button-bg-danger`, `--button-bg-info`, `--button-bg-light`, `--button-bg-dark` (and corresponding `--button-text-*`, `--button-hover-bg-*`) | Button dimensions, typography, variants, and interactive states |
55
55
  | **Panels & Modals** | `--panel-bg-default`, `--panel-header-bg-default`, `--panel-footer-bg-default`, `--panel-bg-primary`, `--panel-bg-success`, `--panel-bg-warning`, `--panel-bg-danger`, `--panel-bg-info`, `--panel-bg-opacity`, `--panel-blur`, `--component-overlay-bg`, `--table-overlay-bg`, `--modal-overlay-bg`, `--modal-backdrop-blur` | Panel headers/footers, overlays, and modal backdrops |
56
56
  | **Form Inputs** | `--input-bg`, `--input-border-radius`, `--input-border-color`, `--input-border`, `--input-hover-border-color`, `--input-focus-border-color`, `--input-focus-shadow`, `--input-height`, `--input-min-width`, `--input-label-color`, `--input-button-bg`, `--checkbox-bg`, `--checkbox-checked-bg`, `--checkbox-border-color`, `--checkbox-border-radius` | Textboxes, textareas, comboboxes, pickers, and checkboxes |
57
- | **Datatables** | `--table-border-color`, `--table-header-bg`, `--table-header-color`, `--table-row-bg`, `--table-row-alt-bg`, `--table-row-hover-bg`, `--table-row-selected-bg`, `--table-row-text-color` | Datatable headers, rows, alternating row colors, and selections |
57
+ | **Calendar & Pickers** | `--calendar-range-bg`, `--calendar-range-color`, `--calendar-range-hover-bg` | Range track highlight background, text color, and hover state in date picker popups |
58
+ | **Datatables** | `--table-border-color`, `--table-header-bg`, `--table-header-color`, `--table-row-bg`, `--table-row-alt-bg`, `--table-row-hover-bg`, `--table-row-selected-bg`, `--table-row-text-color`, `--k-datatable-row-height` | Datatable headers, rows, alternating row colors, selections, and row height constraints |
58
59
 
59
60
  ---
60
61
 
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export { default } from './module.mjs'
1
+ export { default, type hashContent, type syncAiReference } from './module.mjs'
2
2
 
3
3
  export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.144",
3
+ "version": "0.1.1-alpha.146",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -11,8 +11,10 @@
11
11
  "bin": {
12
12
  "katlux": "./bin/cli.mjs",
13
13
  "katlux-toolkit": "./bin/cli.mjs",
14
+ "toolkit": "./bin/cli.mjs",
14
15
  "create-preset": "./bin/create-preset.mjs",
15
- "katlux-add-ref": "./bin/add-ai-reference.mjs"
16
+ "katlux-ai-init": "./bin/ai-init.mjs",
17
+ "katlux-tokens": "./bin/ai-tokens.mjs"
16
18
  },
17
19
  "scripts": {
18
20
  "build": "nuxt-module-build build && unbuild && node -e \"const fs=require('fs'); fs.mkdirSync('dist/runtime', {recursive:true}); fs.cpSync('src/runtime/presets', 'dist/runtime/presets', {recursive:true}); const clean=(d)=>{if(!fs.existsSync(d))return;for(const f of fs.readdirSync(d,{withFileTypes:true})){const p=d+'/'+f.name;if(f.isDirectory())clean(p);else if(f.name.includes('.spec.'))fs.unlinkSync(p);}};clean('dist'); const sRoot='../../.agents/skills'; if(fs.existsSync(sRoot)){fs.mkdirSync('dist/skills', {recursive:true}); fs.cpSync(sRoot, 'dist/skills', {recursive:true, filter:(s)=>!s.includes('.DS_Store')});}\"",
@@ -49,17 +51,21 @@
49
51
  }
50
52
  },
51
53
  "sideEffects": [
54
+ "**/*.vue",
52
55
  "**/*.css",
53
56
  "**/*.scss",
54
57
  "**/*.sass"
55
58
  ],
56
59
  "dependencies": {
57
- "@katlux/providers": "^0.1.1-alpha.131",
60
+ "@katlux/providers": "^0.1.1-alpha.133",
58
61
  "@nuxt/kit": "^3.12.0",
59
62
  "@nuxtjs/i18n": "^10.4.0",
60
63
  "pug": "^3.0.0",
61
64
  "sass": "^1.80.0"
62
65
  },
66
+ "katlux": {
67
+ "mcpVersion": "0.1.0-alpha.25"
68
+ },
63
69
  "files": [
64
70
  "dist",
65
71
  "bin"
@@ -1,259 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * katlux-add-ref
4
- * Downloads Katlux AI skill files from the official showcase and installs them
5
- * into the current project. Safe to re-run at any time to update to the latest.
6
- *
7
- * What it does:
8
- * 1. Installs .agents/skills/KATLUX_INDEX.md (always overwritten, auto-maintained)
9
- * 2. Installs .agents/skills/katlux-[skill]/SKILL.md and all atomic specs under components/ & providers/
10
- * 3. Scaffolds AGENTS.md (created once, never overwritten)
11
- * 4. Scaffolds .agents/rules/rules.md (created once, never overwritten)
12
- * 5. Auto-configures MCP server for Antigravity, Cursor, and VS Code
13
- *
14
- * Usage:
15
- * npx @katlux/toolkit katlux-add-ref
16
- */
17
-
18
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync } from 'fs'
19
- import { resolve, join, dirname } from 'path'
20
- import { fileURLToPath } from 'url'
21
-
22
- const __dirname = dirname(fileURLToPath(import.meta.url))
23
- const BASE_URL = process.env.KATLUX_REF_URL || 'https://katlux.dev/ai-reference'
24
-
25
- // Local packaged skills directory inside @katlux/toolkit
26
- const packagedSkillsDir = resolve(__dirname, '../dist/skills')
27
- const hasPackagedSkills = existsSync(join(packagedSkillsDir, 'KATLUX_INDEX.md'))
28
-
29
- const RESET = '\x1b[0m'
30
- const GREEN = '\x1b[32m'
31
- const CYAN = '\x1b[36m'
32
- const YELLOW = '\x1b[33m'
33
- const RED = '\x1b[31m'
34
- const BOLD = '\x1b[1m'
35
- const DIM = '\x1b[2m'
36
-
37
- function log(color, prefix, message) {
38
- console.log(`${color}${BOLD}${prefix}${RESET} ${message}`)
39
- }
40
-
41
- async function fetchText(url) {
42
- const response = await fetch(url)
43
- if (!response.ok) throw new Error(`${response.status} ${response.statusText} — ${url}`)
44
- return response.text()
45
- }
46
-
47
- function copyDirRecursive(src, dest) {
48
- if (!existsSync(dest)) mkdirSync(dest, { recursive: true })
49
- const entries = readdirSync(src, { withFileTypes: true })
50
- let count = 0
51
- for (const entry of entries) {
52
- const srcPath = join(src, entry.name)
53
- const destPath = join(dest, entry.name)
54
- if (entry.isDirectory()) {
55
- count += copyDirRecursive(srcPath, destPath)
56
- } else if (entry.name.endsWith('.md')) {
57
- writeFileSync(destPath, readFileSync(srcPath, 'utf-8'), 'utf-8')
58
- count++
59
- }
60
- }
61
- return count
62
- }
63
-
64
- // ── Start ────────────────────────────────────────────────────────────────────
65
- console.log()
66
- log(CYAN, '[katlux-add-ref]', `Installing Katlux AI skill files...`)
67
- console.log()
68
-
69
- const projectRoot = process.cwd()
70
- const agentsDir = resolve(projectRoot, '.agents')
71
- const skillsDir = resolve(agentsDir, 'skills')
72
- const rulesDir = resolve(agentsDir, 'rules')
73
-
74
- // Ensure base directories exist
75
- if (!existsSync(skillsDir)) mkdirSync(skillsDir, { recursive: true })
76
- if (!existsSync(rulesDir)) mkdirSync(rulesDir, { recursive: true })
77
-
78
- let installedFilesCount = 0
79
- let bundleInstalled = false
80
-
81
- // Check if user explicitly asked for remote fetch
82
- const forceRemote = process.argv.includes('--remote') || process.env.KATLUX_FORCE_REMOTE === 'true'
83
-
84
- // ── 1. Priority: Local packaged skills (strictly version-matched to installed @katlux/toolkit, offline, instant) ──
85
- if (hasPackagedSkills && !forceRemote) {
86
- process.stdout.write(` ${DIM}Installing version-matched skills from @katlux/toolkit package...${RESET}`)
87
- installedFilesCount = copyDirRecursive(packagedSkillsDir, skillsDir)
88
- process.stdout.write(` ${GREEN}✔ (${installedFilesCount} files)${RESET}\n`)
89
- bundleInstalled = true
90
- }
91
-
92
- // ── 2. Fallback / Forced Remote: Fetch remote skills bundle from showcase ──
93
- if (!bundleInstalled) {
94
- process.stdout.write(` ${DIM}Fetching skills bundle from ${BASE_URL}/bundle...${RESET}`)
95
- try {
96
- const res = await fetch(`${BASE_URL}/bundle`)
97
- if (res.ok) {
98
- const bundle = await res.json()
99
- if (bundle.files && typeof bundle.files === 'object') {
100
- for (const [relPath, content] of Object.entries(bundle.files)) {
101
- const destPath = join(skillsDir, relPath)
102
- const fileDir = dirname(destPath)
103
- if (!existsSync(fileDir)) mkdirSync(fileDir, { recursive: true })
104
- writeFileSync(destPath, content, 'utf-8')
105
- installedFilesCount++
106
- }
107
- process.stdout.write(` ${GREEN}✔ (${installedFilesCount} files)${RESET}\n`)
108
- bundleInstalled = true
109
- }
110
- } else {
111
- process.stdout.write(` ${YELLOW}HTTP ${res.status}${RESET}\n`)
112
- }
113
- } catch {
114
- process.stdout.write(` ${YELLOW}remote unavailable${RESET}\n`)
115
- }
116
- }
117
-
118
- // ── 3. Fallback: Legacy individual HTTP fetch ────────────────────────────
119
- if (!bundleInstalled) {
120
- log(YELLOW, ' fallback', `Fetching individual skills from ${BASE_URL}...`)
121
- try {
122
- const indexContent = await fetchText(BASE_URL).catch(() => fetchText(`${BASE_URL}/index`))
123
- writeFileSync(join(skillsDir, 'KATLUX_INDEX.md'), indexContent, 'utf-8')
124
- installedFilesCount++
125
- } catch (err) {
126
- log(RED, '[katlux-add-ref] ✖', `Failed to fetch index: ${err.message}`)
127
- process.exit(1)
128
- }
129
-
130
- const SKILLS = ['katlux-config', 'katlux-components', 'katlux-providers', 'katlux-presets', 'katlux-tokens']
131
- for (const skill of SKILLS) {
132
- try {
133
- const content = await fetchText(`${BASE_URL}/${skill}`)
134
- const skillDir = join(skillsDir, skill)
135
- if (!existsSync(skillDir)) mkdirSync(skillDir, { recursive: true })
136
- writeFileSync(join(skillDir, 'SKILL.md'), content, 'utf-8')
137
- installedFilesCount++
138
- } catch (err) {
139
- log(RED, '[katlux-add-ref] ✖', `Failed to fetch ${skill}: ${err.message}`)
140
- }
141
- }
142
- }
143
-
144
- // ── 3. Scaffold AGENTS.md — created once, never overwritten ─────────────────
145
- // Intentionally minimal: just two stable references that never need updating.
146
- // KATLUX_INDEX.md (downloaded above) is what carries the skill routing table.
147
- console.log()
148
- const agentsMdPath = resolve(projectRoot, 'AGENTS.md')
149
- if (!existsSync(agentsMdPath)) {
150
- writeFileSync(agentsMdPath, `# Agent Context and Guidelines
151
-
152
- This file serves as the main entry point for AI agents to understand the workspace structure and guidelines.
153
-
154
- - [Project Rules](.agents/rules/rules.md)
155
- - [Katlux Skills Index](.agents/skills/KATLUX_INDEX.md)
156
- `, 'utf-8')
157
- log(GREEN, ' created', `AGENTS.md ${DIM}(edit this to add project-specific context)${RESET}`)
158
- } else {
159
- log(DIM, ' skipped', `AGENTS.md already exists`)
160
- }
161
-
162
- // ── 4. Scaffold .agents/rules/rules.md — created once, never overwritten ────
163
- // Users add their own project rules here. Katlux standards live in KATLUX_INDEX.md.
164
- const rulesMdPath = join(rulesDir, 'rules.md')
165
- if (!existsSync(rulesMdPath)) {
166
- writeFileSync(rulesMdPath, `# Agent Rules
167
-
168
- ## Project-Specific Rules
169
-
170
- <!-- Add your own project rules here. -->
171
- <!-- Example: always use the "users" Pinia store for auth state. -->
172
-
173
- ## Katlux Code Standards
174
-
175
- 1. **Template**: Always use **Pug** (\`lang="pug"\`). Use **Tabs** for indentation.
176
- 2. **Styling**: Use CSS variables (e.g. \`var(--primary-500)\`, \`var(--border-radius-md)\`). Never hardcode colors or sizes.
177
- 3. **Preset Selectors**: Scope CSS rules under \`[data-preset~="preset-name"]\`. Avoid \`!important\`.
178
- 4. **Imports**: Use workspace aliases (e.g. \`#toolkit/composables/...\`). Avoid deep relative imports.
179
- 5. **i18n**: Use \`t('...')\` for all user-facing strings and ARIA labels.
180
- `, 'utf-8')
181
- log(GREEN, ' created', `.agents/rules/rules.md ${DIM}(add your project-specific rules here)${RESET}`)
182
- } else {
183
- log(DIM, ' skipped', `.agents/rules/rules.md already exists`)
184
- }
185
-
186
- // ── 5. Auto-configure MCP (Model Context Protocol) ───────────────────────────
187
- // Enables surgical on-demand tool access for Cursor, Antigravity, and VS Code
188
- // with zero manual JSON configuration required from the developer.
189
- const localMcpPath = resolve(projectRoot, 'packages/katlux-mcp/bin/katlux-mcp.mjs')
190
- const isMonorepo = existsSync(localMcpPath)
191
-
192
- const KATLUX_MCP_SERVER = isMonorepo
193
- ? { command: 'node', args: ['packages/katlux-mcp/bin/katlux-mcp.mjs'] }
194
- : { command: 'npx', args: ['-y', '@katlux/mcp'] }
195
-
196
- function updateMcpConfigFile(filePath) {
197
- let config = {}
198
- if (existsSync(filePath)) {
199
- try {
200
- config = JSON.parse(readFileSync(filePath, 'utf-8'))
201
- } catch {
202
- config = {}
203
- }
204
- }
205
- if (!config.mcpServers) config.mcpServers = {}
206
- config.mcpServers.katlux = KATLUX_MCP_SERVER
207
- writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8')
208
- }
209
-
210
- // 5a. Antigravity / Agents (.agents/mcp_config.json)
211
- updateMcpConfigFile(join(agentsDir, 'mcp_config.json'))
212
- log(GREEN, ' configured', '.agents/mcp_config.json (Antigravity MCP server enabled)')
213
-
214
- // 5b. Cursor (.cursor/mcp.json)
215
- const cursorDir = resolve(projectRoot, '.cursor')
216
- if (existsSync(cursorDir)) {
217
- updateMcpConfigFile(join(cursorDir, 'mcp.json'))
218
- log(GREEN, ' configured', '.cursor/mcp.json (Cursor MCP server enabled)')
219
- }
220
-
221
- // 5c. VS Code (.vscode/mcp.json)
222
- const vscodeDir = resolve(projectRoot, '.vscode')
223
- if (existsSync(vscodeDir)) {
224
- updateMcpConfigFile(join(vscodeDir, 'mcp.json'))
225
- log(GREEN, ' configured', '.vscode/mcp.json (VS Code MCP server enabled)')
226
- }
227
-
228
- // ── 6. Inject AI-Condensed Typechecker Script (`npm run ai:check`) ─────────────
229
- const pkgJsonPath = resolve(projectRoot, 'package.json')
230
- if (existsSync(pkgJsonPath)) {
231
- try {
232
- const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'))
233
- if (!pkg.scripts) pkg.scripts = {}
234
- if (!pkg.scripts['ai:check']) {
235
- pkg.scripts['ai:check'] = "vue-tsc --noEmit --pretty false | grep -E 'error TS' | head -n 15"
236
- writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8')
237
- log(GREEN, ' injected', 'package.json "ai:check" script (token-efficient typechecker)')
238
- }
239
- } catch {
240
- // Ignore package.json read/parse errors
241
- }
242
- }
243
-
244
- // ── Done ─────────────────────────────────────────────────────────────────────
245
- console.log()
246
- log(GREEN, '[katlux-add-ref] ✔', `Done! ${installedFilesCount} skill files (including atomic components & providers) + index installed and MCP server configured.`)
247
- console.log()
248
- console.log(` ${CYAN}Skills:${RESET} .agents/skills/katlux-*/SKILL.md`)
249
- console.log(` ${CYAN}Components:${RESET} .agents/skills/katlux-components/components/*.md (46 atomic specs)`)
250
- console.log(` ${CYAN}Providers:${RESET} .agents/skills/katlux-providers/providers/*.md (18 atomic specs)`)
251
- console.log(` ${CYAN}Index:${RESET} .agents/skills/KATLUX_INDEX.md ${DIM}(auto-updated each run)${RESET}`)
252
- console.log(` ${CYAN}MCP:${RESET} @katlux/mcp server ready on stdio`)
253
- console.log()
254
- console.log(` ${YELLOW}Next:${RESET} Add your project-specific rules to ${CYAN}.agents/rules/rules.md${RESET}`)
255
- console.log(` ${YELLOW}💡 AI Token Tip:${RESET} When AI pairing, use compact test reporters (e.g. Vitest ${CYAN}--reporter=agent${RESET}, Jest ${CYAN}--reporters=summary${RESET}) or git-changed flags (${CYAN}-o${RESET} / ${CYAN}--changed${RESET}) to prevent log noise and save context tokens.`)
256
- console.log()
257
- console.log(` Re-run any time to update to the latest version:`)
258
- console.log(` ${CYAN}npx @katlux/toolkit katlux-add-ref${RESET}`)
259
- console.log()