@katlux/toolkit 0.1.1-alpha.145 → 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.
- package/README.md +32 -22
- package/bin/ai-init.mjs +575 -0
- package/bin/ai-tokens/adapters/antigravityAdapter.mjs +22 -0
- package/bin/ai-tokens/adapters/claudeCodeAdapter.mjs +192 -0
- package/bin/ai-tokens/adapters/codexAdapter.mjs +176 -0
- package/bin/ai-tokens/adapters/cursorAdapter.mjs +202 -0
- package/bin/ai-tokens/adapters/index.mjs +30 -0
- package/bin/ai-tokens/cliViews.mjs +301 -0
- package/bin/ai-tokens/formatAndDates.mjs +89 -0
- package/bin/ai-tokens/reportGenerator.mjs +232 -0
- package/bin/ai-tokens/transcriptParser.mjs +299 -0
- package/bin/ai-tokens.mjs +38 -872
- package/bin/cli.mjs +81 -48
- package/bin/create-preset.mjs +1 -0
- package/bin/preset-contracts.json +2997 -0
- package/dist/compiled/composables/locales/asianAndPacific.mjs +296 -0
- package/dist/compiled/composables/locales/northernAndEasternEuropean.mjs +342 -0
- package/dist/compiled/composables/locales/westernEuropean.mjs +268 -0
- package/dist/compiled/composables/locales.mjs +32 -720
- package/dist/compiled/composables/useDataProvider.mjs +39 -26
- package/dist/compiled/composables/useFilterLogic.mjs +10 -2
- package/dist/compiled/composables/useKatluxForm.mjs +13 -11
- package/dist/compiled/composables/usePresetComponent.mjs +2 -0
- package/dist/compiled/composables/useRequestQueue.mjs +3 -1
- package/dist/compiled/composables/useVirtualDataset.mjs +657 -0
- package/dist/compiled/composables/useVirtualScroll.mjs +93 -66
- package/dist/compiled/composables/virtualDataset/cacheStateHelpers.mjs +76 -0
- package/dist/compiled/composables/virtualDataset/keyboardNavHelpers.mjs +60 -0
- package/dist/compiled/composables/virtualDataset/treeSelectionHelpers.mjs +103 -0
- package/dist/compiled/composables/virtualDataset/types.mjs +0 -0
- package/dist/compiled/utils/deprecation.mjs +44 -0
- package/dist/compiled/utils/dom.mjs +124 -0
- package/dist/module.cjs +58 -77
- package/dist/module.d.cts +5 -0
- package/dist/module.d.mts +4 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +54 -77
- package/dist/runtime/app.config.d.ts +3 -0
- package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +1 -1
- package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +1 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +7 -3
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +4 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +7 -3
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +12 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +40 -41
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +19 -10
- package/dist/runtime/components/KCalendar/KCalendar.global.vue +7 -2
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +19 -10
- package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +14 -201
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +67 -14
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +15 -1
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +25 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +21 -3
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +136 -7
- package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +18 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +18 -3
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +16 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +8 -8
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +8 -8
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue +4 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.d.ts +24 -4
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +43 -22
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +38 -11
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +39 -20
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +38 -11
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +31 -8
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +69 -24
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +10 -14
- package/dist/runtime/components/KDatatable/KDatatable.global.vue +6 -5
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +10 -14
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -6
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +32 -24
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +33 -15
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +60 -16
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +33 -15
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +30 -6
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +249 -59
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +2 -0
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +3 -2
- package/dist/runtime/components/KDropdown/KDropdown.logic.js +14 -13
- package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +55 -4
- package/dist/runtime/components/KGantt/KGantt.global.vue +18 -3
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +55 -4
- package/dist/runtime/components/KGantt/KGantt.logic.d.ts +33 -5
- package/dist/runtime/components/KGantt/KGantt.logic.js +39 -6
- package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
- package/dist/runtime/components/KLayout/KLayout.global.d.vue.ts +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue.d.ts +4 -1
- package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue +3 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.logic.d.ts +5 -0
- package/dist/runtime/components/KLoader/KLoader.logic.js +4 -0
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +30 -7
- package/dist/runtime/components/KMultiTabs/KMultiTabs.logic.d.ts +1 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.d.vue.ts +23 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +24 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue.d.ts +23 -0
- package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +3 -1
- package/dist/runtime/components/KPagination/KPagination.global.vue +2 -1
- package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +3 -1
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +74 -14
- package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTabs/KTabs.logic.js +33 -11
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +2 -2
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +15 -4
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +15 -4
- package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +5 -0
- package/dist/runtime/components/KTextbox/KTextbox.logic.js +4 -0
- package/dist/runtime/components/KTooltip/KTooltip.logic.d.ts +11 -2
- package/dist/runtime/components/KTooltip/KTooltip.logic.js +7 -5
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +4 -4
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +4 -4
- package/dist/runtime/components/KTree/KTree.logic.d.ts +2 -2
- package/dist/runtime/components/KTree/KTree.logic.js +37 -13
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +7 -5
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -6
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +7 -5
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +10 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +40 -6
- package/dist/runtime/components/KTreeView/KTreeView.global.vue +19 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +40 -6
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +24 -4
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +105 -11
- package/dist/runtime/composables/locales/asianAndPacific.d.ts +11 -0
- package/dist/runtime/composables/locales/asianAndPacific.js +296 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.d.ts +12 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.js +342 -0
- package/dist/runtime/composables/locales/westernEuropean.d.ts +10 -0
- package/dist/runtime/composables/locales/westernEuropean.js +268 -0
- package/dist/runtime/composables/locales.d.ts +4 -24
- package/dist/runtime/composables/locales.js +32 -720
- package/dist/runtime/composables/useDataProvider.d.ts +5 -3
- package/dist/runtime/composables/useDataProvider.js +39 -26
- package/dist/runtime/composables/useFilterLogic.d.ts +16 -4
- package/dist/runtime/composables/useFilterLogic.js +10 -2
- package/dist/runtime/composables/useKatluxForm.d.ts +4 -4
- package/dist/runtime/composables/useKatluxForm.js +13 -11
- package/dist/runtime/composables/usePresetComponent.js +2 -0
- package/dist/runtime/composables/useRequestQueue.d.ts +2 -0
- package/dist/runtime/composables/useRequestQueue.js +3 -1
- package/dist/runtime/composables/useSortLogic.d.ts +1 -1
- package/dist/runtime/composables/useVirtualDataset.d.ts +9 -0
- package/dist/runtime/composables/useVirtualDataset.js +657 -0
- package/dist/runtime/composables/useVirtualScroll.d.ts +14 -10
- package/dist/runtime/composables/useVirtualScroll.js +93 -66
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.d.ts +49 -0
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.js +76 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.d.ts +26 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.js +60 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.d.ts +24 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.js +103 -0
- package/dist/runtime/composables/virtualDataset/types.d.ts +113 -0
- package/dist/runtime/composables/virtualDataset/types.js +0 -0
- package/dist/runtime/directives/clickOutside.d.ts +1 -1
- package/dist/runtime/directives/clickOutside.js +41 -13
- package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -1
- package/dist/runtime/plugins/nuxtCompatPlugin.js +16 -1
- package/dist/runtime/plugins/toastPlugin.client.js +2 -2
- package/dist/runtime/presets/default/assets/scss/css-variables.css +3 -0
- package/dist/runtime/presets/default/assets/scss/css-variables.scss +6 -1
- package/dist/runtime/presets/default/assets/scss/index.css +3 -0
- package/dist/runtime/presets/default/assets/svg/katlux-logo.svg +7 -0
- package/dist/runtime/presets/default/assets/svg/katlux.svg +6 -0
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.d.vue.ts +3 -2
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +31 -3
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +3 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +6 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +7 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +57 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +7 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +6 -5
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +27 -17
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +10 -10
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +67 -22
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +41 -8
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +184 -174
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +41 -8
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +17 -10
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +113 -394
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +17 -10
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +6 -0
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +71 -4
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +6 -0
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +5 -2
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +15 -12
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +5 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +11 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +46 -29
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +11 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +23 -8
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue.d.ts +6 -2
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue +2 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +13 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -94
- package/dist/runtime/presets/default/components/KMultiTabs/KMultiTabs.vue +69 -4
- package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +18 -46
- package/dist/runtime/presets/default/components/KSlider/KSlider.vue +11 -23
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +24 -8
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +3 -3
- package/dist/runtime/presets/default/components/KTree/KTree.vue +61 -56
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +3 -3
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +12 -2
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +11 -2
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +14 -2
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +11 -2
- package/dist/runtime/server/middleware/session.js +7 -0
- package/dist/runtime/utils/deprecation.d.ts +14 -0
- package/dist/runtime/utils/deprecation.js +44 -0
- package/dist/runtime/utils/dom.d.ts +31 -0
- package/dist/runtime/utils/dom.js +124 -0
- package/dist/skills/KATLUX_INDEX.md +18 -19
- package/dist/skills/katlux-components/SKILL.md +2 -0
- package/dist/skills/katlux-components/components/KBulkActions.md +26 -2
- package/dist/skills/katlux-components/components/KCombobox.md +2 -2
- package/dist/skills/katlux-components/components/KDataIterator.md +17 -4
- package/dist/skills/katlux-components/components/KDatatable.md +38 -0
- package/dist/skills/katlux-components/components/KDatePicker.md +3 -1
- package/dist/skills/katlux-components/components/KGantt.md +9 -0
- package/dist/skills/katlux-components/components/KIcon.md +1 -1
- package/dist/skills/katlux-components/components/KLayout.md +4 -0
- package/dist/skills/katlux-components/components/KLineChart.md +3 -0
- package/dist/skills/katlux-components/components/KLoader.md +3 -0
- package/dist/skills/katlux-components/components/KProductList.md +0 -1
- package/dist/skills/katlux-components/components/KScatterChart.md +3 -0
- package/dist/skills/katlux-components/components/KTextbox.md +1 -0
- package/dist/skills/katlux-components/components/KTreePicker.md +2 -1
- package/dist/skills/katlux-components/components/KTreeView.md +12 -0
- package/dist/skills/katlux-config/SKILL.md +27 -8
- package/dist/skills/katlux-presets/SKILL.md +163 -3
- package/dist/skills/katlux-presets/creating-a-preset.md +67 -0
- package/dist/skills/katlux-providers/SKILL.md +19 -5
- package/dist/skills/katlux-providers/providers/ADataProvider.md +17 -9
- package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +27 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +11 -1
- package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
- package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +19 -4
- package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +4 -2
- package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/RequestProvider.md +10 -0
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +67 -20
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +23 -2
- package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +25 -11
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +341 -0
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +29 -2
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +70 -1
- package/dist/skills/katlux-providers/providers/encryption.md +26 -1
- package/dist/skills/katlux-providers/providers/types.md +3 -1
- package/dist/skills/katlux-providers/providers/useDataProvider.md +2 -1
- package/dist/skills/katlux-providers/providers/useVirtualDataset.md +154 -0
- package/dist/skills/katlux-tokens/SKILL.md +2 -1
- package/dist/types.d.mts +1 -1
- package/package.json +7 -3
- package/bin/add-ai-reference.mjs +0 -259
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
shallowRef,
|
|
4
|
+
computed,
|
|
5
|
+
unref,
|
|
6
|
+
isRef,
|
|
7
|
+
toValue,
|
|
8
|
+
watch,
|
|
9
|
+
onScopeDispose
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { useVirtualScroll } from "./useVirtualScroll.js";
|
|
12
|
+
import { useDataProvider } from "./useDataProvider.js";
|
|
13
|
+
import {
|
|
14
|
+
buildSelectionIdSet,
|
|
15
|
+
computePageScopedSelectAllRows,
|
|
16
|
+
detectEncryptedCellValue,
|
|
17
|
+
extractVirtualRowId,
|
|
18
|
+
getTreeAncestorIds,
|
|
19
|
+
getTreeBranchRows
|
|
20
|
+
} from "./virtualDataset/treeSelectionHelpers.js";
|
|
21
|
+
import {
|
|
22
|
+
classifyVirtualStateChange,
|
|
23
|
+
isUseDataProviderReturn,
|
|
24
|
+
resolveProviderAllDataRef,
|
|
25
|
+
resolveVirtualItemsArray,
|
|
26
|
+
resolveVirtualTotalCount
|
|
27
|
+
} from "./virtualDataset/cacheStateHelpers.js";
|
|
28
|
+
import {
|
|
29
|
+
computeNextKeyboardFocusIndex,
|
|
30
|
+
resolveDomItemHeight,
|
|
31
|
+
resolveDomTheadOffset,
|
|
32
|
+
resolveDomViewportHeight
|
|
33
|
+
} from "./virtualDataset/keyboardNavHelpers.js";
|
|
34
|
+
export { getTreeBranchRows, getTreeAncestorIds } from "./virtualDataset/treeSelectionHelpers.js";
|
|
35
|
+
export function useVirtualDataset(options) {
|
|
36
|
+
const resolveRawProvider = () => {
|
|
37
|
+
if (isUseDataProviderReturn(options.dataProvider)) {
|
|
38
|
+
return options.dataProvider.rawProvider;
|
|
39
|
+
}
|
|
40
|
+
return toValue(options.dataProvider);
|
|
41
|
+
};
|
|
42
|
+
const rawProvider = resolveRawProvider();
|
|
43
|
+
const datasetPageSize = ref(toValue(options.pageSize) ?? rawProvider?.pageSize ?? 10);
|
|
44
|
+
if (options.pageSize !== void 0 && (isRef(options.pageSize) || typeof options.pageSize === "function")) {
|
|
45
|
+
watch(() => toValue(options.pageSize), (newVal) => {
|
|
46
|
+
if (newVal !== void 0 && newVal !== datasetPageSize.value) {
|
|
47
|
+
datasetPageSize.value = newVal;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const dpBridge = isUseDataProviderReturn(options.dataProvider) ? options.dataProvider : useDataProvider(() => resolveRawProvider(), { pageSize: datasetPageSize });
|
|
52
|
+
let customChangeCount = 0;
|
|
53
|
+
let customUnsub = null;
|
|
54
|
+
const attachCustomProviderListener = (dp) => {
|
|
55
|
+
if (customUnsub) {
|
|
56
|
+
try {
|
|
57
|
+
customUnsub();
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
customUnsub = null;
|
|
61
|
+
}
|
|
62
|
+
if (dp && typeof dp.on === "function") {
|
|
63
|
+
try {
|
|
64
|
+
const off = dp.on("change", () => {
|
|
65
|
+
customChangeCount++;
|
|
66
|
+
dpBridge.stateVersion.value++;
|
|
67
|
+
});
|
|
68
|
+
customUnsub = () => {
|
|
69
|
+
if (typeof off === "function") off();
|
|
70
|
+
else if (typeof dp.off === "function") dp.off("change");
|
|
71
|
+
};
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
attachCustomProviderListener(resolveRawProvider());
|
|
77
|
+
try {
|
|
78
|
+
onScopeDispose(() => {
|
|
79
|
+
if (customUnsub) {
|
|
80
|
+
try {
|
|
81
|
+
customUnsub();
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
customUnsub = null;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
if (isRef(options.dataProvider) || typeof options.dataProvider === "function") {
|
|
90
|
+
watch(resolveRawProvider, (newDp) => attachCustomProviderListener(newDp));
|
|
91
|
+
}
|
|
92
|
+
const pageRows = computed(() => dpBridge.pageData.value || []);
|
|
93
|
+
const activeFilter = computed(() => dpBridge.filter.value || dpBridge.rawProvider?.filter || null);
|
|
94
|
+
const effectivePageSize = computed(() => {
|
|
95
|
+
const ps = toValue(options.pageSize) ?? dpBridge.pageSize.value ?? dpBridge.rawProvider?.pageSize;
|
|
96
|
+
return typeof ps === "number" && ps > 0 ? ps : 10;
|
|
97
|
+
});
|
|
98
|
+
const isLoading = computed(() => dpBridge.loading.value || dpBridge.initialLoad.value || false);
|
|
99
|
+
const dpFields = computed(() => {
|
|
100
|
+
const _ver = dpBridge.stateVersion.value;
|
|
101
|
+
const bridgeFields = dpBridge.fields?.value;
|
|
102
|
+
if (Array.isArray(bridgeFields) && bridgeFields.length > 0) return bridgeFields;
|
|
103
|
+
const rawFields = dpBridge.rawProvider?.fields;
|
|
104
|
+
if (Array.isArray(rawFields) && rawFields.length > 0) return rawFields;
|
|
105
|
+
if (pageRows.value.length > 0 && pageRows.value[0]) {
|
|
106
|
+
return Object.keys(pageRows.value[0]).filter((k) => !k.startsWith("__"));
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
});
|
|
110
|
+
const rowIdKey = computed(() => toValue(options.idKey) || dpBridge.rawProvider?.idKey || "id");
|
|
111
|
+
const resolveItemHeightOption = () => {
|
|
112
|
+
const raw = unref(options.itemHeight);
|
|
113
|
+
if (typeof raw === "function" && raw.length === 0) {
|
|
114
|
+
return raw();
|
|
115
|
+
}
|
|
116
|
+
return raw;
|
|
117
|
+
};
|
|
118
|
+
const datasetItems = computed(() => {
|
|
119
|
+
const _ver = dpBridge.stateVersion.value;
|
|
120
|
+
return resolveVirtualItemsArray(dpBridge.rawProvider, pageRows.value, Boolean(toValue(options.virtualScroll)));
|
|
121
|
+
});
|
|
122
|
+
const virtualScrollReturn = useVirtualScroll({
|
|
123
|
+
totalCount: computed(() => {
|
|
124
|
+
const _ver = dpBridge.stateVersion.value;
|
|
125
|
+
return resolveVirtualTotalCount(
|
|
126
|
+
dpBridge.rawProvider,
|
|
127
|
+
dpBridge.rowCount.value,
|
|
128
|
+
datasetItems.value,
|
|
129
|
+
pageRows.value.length,
|
|
130
|
+
Boolean(toValue(options.virtualScroll))
|
|
131
|
+
);
|
|
132
|
+
}),
|
|
133
|
+
items: datasetItems,
|
|
134
|
+
getItem: (index) => deliveredIndexCache.value.get(index),
|
|
135
|
+
itemHeight: computed(() => resolveItemHeightOption() ?? 40),
|
|
136
|
+
containerHeight: computed(() => toValue(options.viewportHeight) ?? toValue(options.containerHeight) ?? 500),
|
|
137
|
+
buffer: computed(() => toValue(options.buffer) ?? 5),
|
|
138
|
+
virtualScroll: computed(() => !!toValue(options.virtualScroll)),
|
|
139
|
+
columns: options.columns,
|
|
140
|
+
scrollThreshold: options.scrollThreshold,
|
|
141
|
+
onThresholdReach: () => {
|
|
142
|
+
const dp = dpBridge.rawProvider;
|
|
143
|
+
if (!toValue(options.virtualScroll) && typeof dp?.nextPage === "function" && dp.hasMore) {
|
|
144
|
+
dp.nextPage();
|
|
145
|
+
}
|
|
146
|
+
options.onThresholdReach?.();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const {
|
|
150
|
+
visibleItems,
|
|
151
|
+
startIndex,
|
|
152
|
+
endIndex,
|
|
153
|
+
topSpacerHeight,
|
|
154
|
+
bottomSpacerHeight,
|
|
155
|
+
totalHeight,
|
|
156
|
+
scrollTop,
|
|
157
|
+
viewportHeight,
|
|
158
|
+
containerRef,
|
|
159
|
+
onScroll,
|
|
160
|
+
scrollToIndex,
|
|
161
|
+
containerCssVars
|
|
162
|
+
} = virtualScrollReturn;
|
|
163
|
+
const deliveredRowsCache = shallowRef(/* @__PURE__ */ new Map());
|
|
164
|
+
const deliveredIndexCache = shallowRef(/* @__PURE__ */ new Map());
|
|
165
|
+
const deliveredRowVersions = /* @__PURE__ */ new Map();
|
|
166
|
+
const requestedPages = /* @__PURE__ */ new Set();
|
|
167
|
+
let isFetchingPage = false;
|
|
168
|
+
const pageQueue = [];
|
|
169
|
+
let cacheGeneration = 0;
|
|
170
|
+
let dataVersion = 0;
|
|
171
|
+
const buildSnapshot = (dp) => ({
|
|
172
|
+
provider: dp,
|
|
173
|
+
stateVersion: dpBridge.stateVersion.value,
|
|
174
|
+
pageRowsRef: pageRows.value,
|
|
175
|
+
allDataRef: resolveProviderAllDataRef(dp),
|
|
176
|
+
loading: Boolean(dpBridge.loading.value),
|
|
177
|
+
initialLoad: Boolean(dpBridge.initialLoad.value),
|
|
178
|
+
error: dpBridge.error.value,
|
|
179
|
+
rowCount: dpBridge.rowCount.value,
|
|
180
|
+
currentPage: dpBridge.currentPage.value,
|
|
181
|
+
batchGeneration: dp?._batchGeneration,
|
|
182
|
+
loadedBatchesSize: dp?.loadedBatches instanceof Set ? dp.loadedBatches.size : 0,
|
|
183
|
+
batchProgress: dp?.batchProgress,
|
|
184
|
+
isBatchLoading: Boolean(dp?.isBatchLoading),
|
|
185
|
+
customChangeCount
|
|
186
|
+
});
|
|
187
|
+
let snapshot = buildSnapshot(dpBridge.rawProvider);
|
|
188
|
+
const writeRowsToCache = (rows, startIdx, reset) => {
|
|
189
|
+
if (reset) deliveredRowVersions.clear();
|
|
190
|
+
const nextCache = reset ? /* @__PURE__ */ new Map() : new Map(deliveredRowsCache.value);
|
|
191
|
+
const nextIndexCache = reset ? /* @__PURE__ */ new Map() : new Map(deliveredIndexCache.value);
|
|
192
|
+
if (Array.isArray(rows) && rows.length > 0) {
|
|
193
|
+
const idKey = rowIdKey.value;
|
|
194
|
+
for (let i = 0; i < rows.length; i++) {
|
|
195
|
+
const r = rows[i];
|
|
196
|
+
nextIndexCache.set(startIdx + i, r);
|
|
197
|
+
const id = extractVirtualRowId(r, idKey);
|
|
198
|
+
if (id !== void 0 && id !== null) {
|
|
199
|
+
nextCache.set(id, r);
|
|
200
|
+
deliveredRowVersions.set(id, dataVersion);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
deliveredRowsCache.value = nextCache;
|
|
205
|
+
deliveredIndexCache.value = nextIndexCache;
|
|
206
|
+
};
|
|
207
|
+
const getStateClassification = (dp) => classifyVirtualStateChange({
|
|
208
|
+
dp,
|
|
209
|
+
dpBridgeStateVersion: dpBridge.stateVersion.value,
|
|
210
|
+
pageRowsRef: pageRows.value,
|
|
211
|
+
loading: Boolean(dpBridge.loading.value),
|
|
212
|
+
initialLoad: Boolean(dpBridge.initialLoad.value),
|
|
213
|
+
error: dpBridge.error.value,
|
|
214
|
+
currentPage: dpBridge.currentPage.value,
|
|
215
|
+
customChangeCount,
|
|
216
|
+
isFetchingPage,
|
|
217
|
+
snapshot
|
|
218
|
+
});
|
|
219
|
+
if (Array.isArray(pageRows.value) && pageRows.value.length > 0) {
|
|
220
|
+
const dp = dpBridge.rawProvider;
|
|
221
|
+
const curPage = dpBridge.currentPage.value || dp?.currentPage || 1;
|
|
222
|
+
const ps = effectivePageSize.value;
|
|
223
|
+
writeRowsToCache(pageRows.value, curPage > 1 && ps > 0 ? (curPage - 1) * ps : 0, true);
|
|
224
|
+
requestedPages.add(curPage);
|
|
225
|
+
}
|
|
226
|
+
snapshot = buildSnapshot(dpBridge.rawProvider);
|
|
227
|
+
const processPageQueue = async () => {
|
|
228
|
+
if (isFetchingPage || pageQueue.length === 0) return;
|
|
229
|
+
const nextPage = pageQueue.shift();
|
|
230
|
+
const dp = dpBridge.rawProvider;
|
|
231
|
+
if (!dp) {
|
|
232
|
+
requestedPages.delete(nextPage);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const currentGen = cacheGeneration;
|
|
236
|
+
const versionBefore = dpBridge.stateVersion.value;
|
|
237
|
+
const pageBefore = pageRows.value;
|
|
238
|
+
const allBefore = resolveProviderAllDataRef(dp);
|
|
239
|
+
isFetchingPage = true;
|
|
240
|
+
let resolved = false;
|
|
241
|
+
try {
|
|
242
|
+
const ps = effectivePageSize.value;
|
|
243
|
+
const pageStart = (nextPage - 1) * ps;
|
|
244
|
+
const pageEnd = pageStart + ps;
|
|
245
|
+
let resolvedRows;
|
|
246
|
+
if (typeof dp.resolveRangeRows === "function") {
|
|
247
|
+
resolvedRows = await dp.resolveRangeRows(pageStart, pageEnd);
|
|
248
|
+
} else if (typeof dp.getWindowRows === "function") {
|
|
249
|
+
resolvedRows = await dp.getWindowRows(pageStart, pageEnd);
|
|
250
|
+
} else if (typeof dp.loadRange === "function") {
|
|
251
|
+
await dp.loadRange(pageStart, pageEnd);
|
|
252
|
+
if (Array.isArray(dp.rowMap)) resolvedRows = dp.rowMap.slice(pageStart, pageEnd);
|
|
253
|
+
}
|
|
254
|
+
if (currentGen !== cacheGeneration) return;
|
|
255
|
+
if (dpBridge.stateVersion.value !== versionBefore && pageRows.value === pageBefore && resolveProviderAllDataRef(dp) === allBefore && dpBridge.currentPage.value === snapshot.currentPage) {
|
|
256
|
+
snapshot.stateVersion = dpBridge.stateVersion.value;
|
|
257
|
+
snapshot.rowCount = dpBridge.rowCount.value;
|
|
258
|
+
}
|
|
259
|
+
if (Array.isArray(resolvedRows) && resolvedRows.length > 0) {
|
|
260
|
+
writeRowsToCache(resolvedRows, pageStart, false);
|
|
261
|
+
resolved = true;
|
|
262
|
+
}
|
|
263
|
+
} catch (err) {
|
|
264
|
+
console.warn("[useVirtualDataset] processPageQueue error:", err);
|
|
265
|
+
} finally {
|
|
266
|
+
if (!resolved && currentGen === cacheGeneration) requestedPages.delete(nextPage);
|
|
267
|
+
isFetchingPage = false;
|
|
268
|
+
if (pageQueue.length > 0) processPageQueue();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const queuePage = (page) => {
|
|
272
|
+
if (!requestedPages.has(page)) {
|
|
273
|
+
requestedPages.add(page);
|
|
274
|
+
pageQueue.push(page);
|
|
275
|
+
processPageQueue();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const ensureVisiblePagesLoaded = () => {
|
|
279
|
+
if (typeof window === "undefined" || !toValue(options.virtualScroll)) return;
|
|
280
|
+
const start = startIndex.value;
|
|
281
|
+
const end = endIndex.value;
|
|
282
|
+
const dp = dpBridge.rawProvider;
|
|
283
|
+
if (dp && typeof dp.ensureRangeLoaded === "function") dp.ensureRangeLoaded(start, end);
|
|
284
|
+
const ps = effectivePageSize.value;
|
|
285
|
+
if (!ps || ps <= 0) return;
|
|
286
|
+
const startPage = Math.floor(start / ps) + 1;
|
|
287
|
+
const endPage = Math.floor(Math.max(0, end - 1) / ps) + 1;
|
|
288
|
+
for (let p = startPage; p <= endPage; p++) queuePage(p);
|
|
289
|
+
};
|
|
290
|
+
watch([startIndex, endIndex, () => datasetItems.value.length, dpBridge.stateVersion, () => !!toValue(options.virtualScroll)], () => {
|
|
291
|
+
if (typeof window !== "undefined") ensureVisiblePagesLoaded();
|
|
292
|
+
}, { immediate: true });
|
|
293
|
+
const invalidateCache = () => {
|
|
294
|
+
cacheGeneration++;
|
|
295
|
+
dataVersion++;
|
|
296
|
+
requestedPages.clear();
|
|
297
|
+
pageQueue.length = 0;
|
|
298
|
+
const dp = dpBridge.rawProvider;
|
|
299
|
+
const curPage = dpBridge.currentPage.value || dp?.currentPage || 1;
|
|
300
|
+
const ps = effectivePageSize.value;
|
|
301
|
+
writeRowsToCache(pageRows.value, curPage > 1 && ps > 0 ? (curPage - 1) * ps : 0, true);
|
|
302
|
+
if (Array.isArray(pageRows.value) && pageRows.value.length > 0) requestedPages.add(curPage);
|
|
303
|
+
snapshot = buildSnapshot(dp);
|
|
304
|
+
if (typeof window !== "undefined" && toValue(options.virtualScroll)) ensureVisiblePagesLoaded();
|
|
305
|
+
};
|
|
306
|
+
watch([dpBridge.stateVersion, pageRows], () => {
|
|
307
|
+
const dp = dpBridge.rawProvider;
|
|
308
|
+
const action = getStateClassification(dp);
|
|
309
|
+
if (action === "invalidate") {
|
|
310
|
+
invalidateCache();
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (action === "pageSwitch") {
|
|
314
|
+
deliveredIndexCache.value = /* @__PURE__ */ new Map();
|
|
315
|
+
requestedPages.clear();
|
|
316
|
+
if (Array.isArray(pageRows.value) && pageRows.value.length > 0) {
|
|
317
|
+
const curPage = dpBridge.currentPage.value || dp?.currentPage || 1;
|
|
318
|
+
const ps = effectivePageSize.value;
|
|
319
|
+
writeRowsToCache(pageRows.value, curPage > 1 && ps > 0 ? (curPage - 1) * ps : 0, false);
|
|
320
|
+
requestedPages.add(curPage);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
snapshot = buildSnapshot(dp);
|
|
324
|
+
});
|
|
325
|
+
watch([dpBridge.filter, dpBridge.sortList, dpBridge.filterSortVersion], () => invalidateCache());
|
|
326
|
+
watch(() => dpBridge.rawProvider, () => invalidateCache());
|
|
327
|
+
const displayRows = computed(() => {
|
|
328
|
+
if (!toValue(options.virtualScroll)) return pageRows.value;
|
|
329
|
+
const _ver = dpBridge.stateVersion.value;
|
|
330
|
+
const start = startIndex.value;
|
|
331
|
+
const end = endIndex.value;
|
|
332
|
+
const count = Math.max(0, end - start);
|
|
333
|
+
if (count === 0) return [];
|
|
334
|
+
const rawAll = datasetItems.value;
|
|
335
|
+
const items = visibleItems.value;
|
|
336
|
+
const dp = dpBridge.rawProvider;
|
|
337
|
+
const staleState = getStateClassification(dp) === "invalidate";
|
|
338
|
+
const cache = staleState ? null : deliveredRowsCache.value;
|
|
339
|
+
const indexCache = staleState ? null : deliveredIndexCache.value;
|
|
340
|
+
const hasRefDecrypt = dp && typeof dp.getDecryptedRow === "function";
|
|
341
|
+
const idKey = rowIdKey.value;
|
|
342
|
+
const result = new Array(count);
|
|
343
|
+
for (let i = 0; i < count; i++) {
|
|
344
|
+
const absIdx = start + i;
|
|
345
|
+
const item = absIdx < rawAll.length ? rawAll[absIdx] : i < items.length ? items[i] : void 0;
|
|
346
|
+
if (item !== void 0 && item !== null) {
|
|
347
|
+
const id = extractVirtualRowId(item, idKey);
|
|
348
|
+
if (cache !== null && id !== void 0 && id !== null && cache.has(id) && deliveredRowVersions.get(id) === dataVersion) {
|
|
349
|
+
result[i] = cache.get(id);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (hasRefDecrypt && typeof item === "object") {
|
|
353
|
+
const decrypted = dp.getDecryptedRow(item);
|
|
354
|
+
if (decrypted) {
|
|
355
|
+
result[i] = decrypted;
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
result[i] = item;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (indexCache !== null && indexCache.has(absIdx)) {
|
|
363
|
+
result[i] = indexCache.get(absIdx);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
result[i] = { __encrypted: true, __skeleton: true };
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
});
|
|
370
|
+
const isCellEncrypted = (val) => detectEncryptedCellValue(val, dpBridge.rawProvider);
|
|
371
|
+
const selectedRows = options.selectedRows ?? ref([]);
|
|
372
|
+
const selectAll = options.selectAll ?? ref(false);
|
|
373
|
+
const unselectedRows = options.unselectedRows ?? ref([]);
|
|
374
|
+
const selectAllFilter = ref(null);
|
|
375
|
+
const effectiveSelectAllScope = computed(() => {
|
|
376
|
+
if (toValue(options.virtualScroll)) {
|
|
377
|
+
if (toValue(options.selectAllScope) === "page") {
|
|
378
|
+
console.warn('[useVirtualDataset] virtualScroll is enabled with selectAllScope="page". Overriding selectAllScope to "dataset" because page-scoped selection is incompatible with virtual scrolling.');
|
|
379
|
+
}
|
|
380
|
+
return "dataset";
|
|
381
|
+
}
|
|
382
|
+
return toValue(options.selectAllScope) || "page";
|
|
383
|
+
});
|
|
384
|
+
const getRowKey = (row, index) => {
|
|
385
|
+
const idKey = rowIdKey.value;
|
|
386
|
+
if (row && row[idKey] !== void 0 && row[idKey] !== null) return row[idKey];
|
|
387
|
+
if (row && row.id !== void 0 && row.id !== null) return row.id;
|
|
388
|
+
if (row && row._id !== void 0 && row._id !== null) return row._id;
|
|
389
|
+
return toValue(options.virtualScroll) ? startIndex.value + index : index;
|
|
390
|
+
};
|
|
391
|
+
const selectedRowIds = computed(() => buildSelectionIdSet(selectedRows.value, rowIdKey.value));
|
|
392
|
+
const unselectedRowIds = computed(() => buildSelectionIdSet(unselectedRows.value, rowIdKey.value));
|
|
393
|
+
const isRowSelected = (row) => {
|
|
394
|
+
const idKey = rowIdKey.value;
|
|
395
|
+
const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row;
|
|
396
|
+
if (effectiveSelectAllScope.value === "dataset" && selectAll.value) {
|
|
397
|
+
if (selectAllFilter.value !== null && selectAllFilter.value !== JSON.stringify(activeFilter.value)) {
|
|
398
|
+
if (unselectedRowIds.value.has(rowId) || unselectedRowIds.value.has(row)) return false;
|
|
399
|
+
return selectedRowIds.value.has(rowId) || selectedRowIds.value.has(row);
|
|
400
|
+
}
|
|
401
|
+
return !unselectedRowIds.value.has(rowId) && !unselectedRowIds.value.has(row);
|
|
402
|
+
}
|
|
403
|
+
return selectedRowIds.value.has(rowId) || selectedRowIds.value.has(row);
|
|
404
|
+
};
|
|
405
|
+
const pageSelectedCount = computed(() => {
|
|
406
|
+
if (!datasetItems.value || datasetItems.value.length === 0) return 0;
|
|
407
|
+
let count = 0;
|
|
408
|
+
const ids = selectedRowIds.value;
|
|
409
|
+
const idKey = rowIdKey.value;
|
|
410
|
+
for (const r of datasetItems.value) {
|
|
411
|
+
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
412
|
+
if (ids.has(id) || ids.has(r)) count++;
|
|
413
|
+
}
|
|
414
|
+
return count;
|
|
415
|
+
});
|
|
416
|
+
const isAllSelected = computed(() => {
|
|
417
|
+
const total = datasetItems.value.length;
|
|
418
|
+
if (total === 0) return false;
|
|
419
|
+
if (effectiveSelectAllScope.value === "dataset" && selectAll.value === true) {
|
|
420
|
+
if (selectAllFilter.value !== null && selectAllFilter.value !== JSON.stringify(activeFilter.value)) {
|
|
421
|
+
return pageSelectedCount.value === total;
|
|
422
|
+
}
|
|
423
|
+
return unselectedRows.value.length === 0;
|
|
424
|
+
}
|
|
425
|
+
return pageSelectedCount.value === total;
|
|
426
|
+
});
|
|
427
|
+
const isIndeterminate = computed(() => {
|
|
428
|
+
const total = datasetItems.value.length;
|
|
429
|
+
if (total === 0 || isAllSelected.value) return false;
|
|
430
|
+
if (effectiveSelectAllScope.value === "dataset" && selectAll.value === true) {
|
|
431
|
+
if (selectAllFilter.value !== null && selectAllFilter.value !== JSON.stringify(activeFilter.value)) {
|
|
432
|
+
return pageSelectedCount.value > 0;
|
|
433
|
+
}
|
|
434
|
+
return unselectedRows.value.length > 0;
|
|
435
|
+
}
|
|
436
|
+
return pageSelectedCount.value > 0 && pageSelectedCount.value < total;
|
|
437
|
+
});
|
|
438
|
+
const handleSelectAll = () => {
|
|
439
|
+
if (datasetItems.value.length === 0) return;
|
|
440
|
+
if (effectiveSelectAllScope.value === "dataset") {
|
|
441
|
+
const nextAll = !isAllSelected.value;
|
|
442
|
+
selectAll.value = nextAll;
|
|
443
|
+
selectAllFilter.value = nextAll ? JSON.stringify(activeFilter.value) : null;
|
|
444
|
+
unselectedRows.value = [];
|
|
445
|
+
selectedRows.value = [];
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
selectedRows.value = computePageScopedSelectAllRows(
|
|
449
|
+
datasetItems.value,
|
|
450
|
+
selectedRows.value || [],
|
|
451
|
+
selectedRowIds.value,
|
|
452
|
+
dpBridge.rawProvider,
|
|
453
|
+
rowIdKey.value,
|
|
454
|
+
isAllSelected.value
|
|
455
|
+
);
|
|
456
|
+
unselectedRows.value = [];
|
|
457
|
+
selectAll.value = false;
|
|
458
|
+
};
|
|
459
|
+
const toggleRow = (row) => {
|
|
460
|
+
const idKey = rowIdKey.value;
|
|
461
|
+
const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row;
|
|
462
|
+
const branchRows = getTreeBranchRows(row, dpBridge.rawProvider, datasetItems.value, idKey);
|
|
463
|
+
const branchIdSet = /* @__PURE__ */ new Set([row, rowId, ...branchRows.map((b) => b?.[idKey] ?? b?.id ?? b?._id ?? b)]);
|
|
464
|
+
if (effectiveSelectAllScope.value === "dataset" && selectAll.value) {
|
|
465
|
+
if (unselectedRowIds.value.has(rowId) || unselectedRowIds.value.has(row)) {
|
|
466
|
+
unselectedRows.value = (unselectedRows.value || []).filter((r) => {
|
|
467
|
+
const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
468
|
+
return !branchIdSet.has(rId) && !branchIdSet.has(r);
|
|
469
|
+
});
|
|
470
|
+
} else {
|
|
471
|
+
const existing = unselectedRowIds.value;
|
|
472
|
+
const toAdd = branchRows.filter((b) => {
|
|
473
|
+
const bId = b?.[idKey] ?? b?.id ?? b?._id ?? b;
|
|
474
|
+
return !existing.has(bId) && !existing.has(b);
|
|
475
|
+
});
|
|
476
|
+
unselectedRows.value = [...unselectedRows.value || [], ...toAdd];
|
|
477
|
+
}
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (isRowSelected(row)) {
|
|
481
|
+
for (const ancId of getTreeAncestorIds(row, dpBridge.rawProvider, datasetItems.value, idKey)) branchIdSet.add(ancId);
|
|
482
|
+
selectedRows.value = (selectedRows.value || []).filter((r) => {
|
|
483
|
+
const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
484
|
+
return !branchIdSet.has(rId) && !branchIdSet.has(r);
|
|
485
|
+
});
|
|
486
|
+
} else {
|
|
487
|
+
const existing = new Set(selectedRowIds.value);
|
|
488
|
+
const toAdd = [];
|
|
489
|
+
for (const b of branchRows) {
|
|
490
|
+
const bId = b?.[idKey] ?? b?.id ?? b?._id ?? b;
|
|
491
|
+
if (!existing.has(bId) && !existing.has(b)) {
|
|
492
|
+
existing.add(bId);
|
|
493
|
+
toAdd.push(b);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
selectedRows.value = [...selectedRows.value || [], ...toAdd];
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const focusedIndex = ref(-1);
|
|
500
|
+
const theadStickyOffset = options.theadStickyOffset ?? 40;
|
|
501
|
+
const getDynamicRowOffsetAndHeight = (index, fn) => {
|
|
502
|
+
let top = 0;
|
|
503
|
+
for (let i = 0; i < index; i++) {
|
|
504
|
+
const item = deliveredIndexCache.value.get(i) ?? datasetItems.value[i];
|
|
505
|
+
top += fn(item, i);
|
|
506
|
+
}
|
|
507
|
+
const targetItem = deliveredIndexCache.value.get(index) ?? datasetItems.value[index];
|
|
508
|
+
return { top, height: fn(targetItem, index) };
|
|
509
|
+
};
|
|
510
|
+
const ensureVisible = (index) => {
|
|
511
|
+
const total = datasetItems.value.length;
|
|
512
|
+
if (total === 0) return;
|
|
513
|
+
const itemHeightOpt = resolveItemHeightOption();
|
|
514
|
+
const vpH = resolveDomViewportHeight(containerRef.value, viewportHeight.value, toValue(options.viewportHeight) ?? toValue(options.containerHeight));
|
|
515
|
+
let rowTop;
|
|
516
|
+
let rowBottom;
|
|
517
|
+
if (typeof itemHeightOpt === "function") {
|
|
518
|
+
const { top, height } = getDynamicRowOffsetAndHeight(index, itemHeightOpt);
|
|
519
|
+
rowTop = top;
|
|
520
|
+
rowBottom = top + height;
|
|
521
|
+
} else {
|
|
522
|
+
const itemH = resolveDomItemHeight(containerRef.value, itemHeightOpt);
|
|
523
|
+
rowTop = index * itemH;
|
|
524
|
+
rowBottom = rowTop + itemH;
|
|
525
|
+
}
|
|
526
|
+
if (rowTop < scrollTop.value) {
|
|
527
|
+
scrollToIndex(index, "auto", index > 0 ? resolveDomTheadOffset(containerRef.value, theadStickyOffset) : 0);
|
|
528
|
+
} else if (rowBottom > scrollTop.value + vpH) {
|
|
529
|
+
const targetScroll = Math.max(0, rowBottom - vpH);
|
|
530
|
+
scrollTop.value = targetScroll;
|
|
531
|
+
if (containerRef.value) containerRef.value.scrollTop = targetScroll;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const handleKeyDown = (e) => {
|
|
535
|
+
if (!toValue(options.virtualScroll)) return;
|
|
536
|
+
const total = datasetItems.value.length;
|
|
537
|
+
if (total === 0) return;
|
|
538
|
+
const itemHeightOpt = resolveItemHeightOption();
|
|
539
|
+
const vpH = resolveDomViewportHeight(containerRef.value, viewportHeight.value, toValue(options.viewportHeight) ?? toValue(options.containerHeight));
|
|
540
|
+
let firstInView = 0;
|
|
541
|
+
let lastInView = total - 1;
|
|
542
|
+
let pageStep = 1;
|
|
543
|
+
if (typeof itemHeightOpt === "function") {
|
|
544
|
+
let acc = 0;
|
|
545
|
+
let foundFirst = false;
|
|
546
|
+
for (let i = 0; i < total; i++) {
|
|
547
|
+
const item = deliveredIndexCache.value.get(i) ?? datasetItems.value[i];
|
|
548
|
+
const h = itemHeightOpt(item, i);
|
|
549
|
+
if (!foundFirst && acc + h > scrollTop.value) {
|
|
550
|
+
firstInView = i;
|
|
551
|
+
foundFirst = true;
|
|
552
|
+
}
|
|
553
|
+
if (acc + h <= scrollTop.value + vpH) {
|
|
554
|
+
lastInView = i;
|
|
555
|
+
} else if (foundFirst) {
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
acc += h;
|
|
559
|
+
}
|
|
560
|
+
pageStep = Math.max(1, lastInView - firstInView);
|
|
561
|
+
} else {
|
|
562
|
+
const itemH = resolveDomItemHeight(containerRef.value, itemHeightOpt);
|
|
563
|
+
firstInView = Math.floor(scrollTop.value / itemH);
|
|
564
|
+
lastInView = Math.min(total - 1, Math.floor((scrollTop.value + vpH) / itemH) - 1);
|
|
565
|
+
pageStep = Math.max(1, Math.floor(vpH / itemH));
|
|
566
|
+
}
|
|
567
|
+
const next = computeNextKeyboardFocusIndex({
|
|
568
|
+
key: e.key,
|
|
569
|
+
currentFocus: focusedIndex.value,
|
|
570
|
+
total,
|
|
571
|
+
firstInView,
|
|
572
|
+
lastInView,
|
|
573
|
+
pageStep
|
|
574
|
+
});
|
|
575
|
+
if (!next) return;
|
|
576
|
+
e.preventDefault();
|
|
577
|
+
focusedIndex.value = next.nextIndex;
|
|
578
|
+
if (next.scrollMode === "home") scrollToIndex(0, "auto", 0);
|
|
579
|
+
else if (next.scrollMode === "end") scrollToIndex(total - 1, "auto", theadStickyOffset);
|
|
580
|
+
else ensureVisible(next.nextIndex);
|
|
581
|
+
};
|
|
582
|
+
return {
|
|
583
|
+
datasetItems,
|
|
584
|
+
datatableItems: datasetItems,
|
|
585
|
+
displayRows,
|
|
586
|
+
visibleItems,
|
|
587
|
+
startIndex,
|
|
588
|
+
endIndex,
|
|
589
|
+
topSpacerHeight,
|
|
590
|
+
bottomSpacerHeight,
|
|
591
|
+
totalHeight,
|
|
592
|
+
scrollTop,
|
|
593
|
+
viewportHeight,
|
|
594
|
+
containerRef,
|
|
595
|
+
onScroll,
|
|
596
|
+
scrollToIndex,
|
|
597
|
+
containerCssVars,
|
|
598
|
+
deliveredRowsCache,
|
|
599
|
+
invalidateCache,
|
|
600
|
+
ensureVisiblePagesLoaded,
|
|
601
|
+
isCellEncrypted,
|
|
602
|
+
rowIdKey,
|
|
603
|
+
getRowKey,
|
|
604
|
+
selectedRows,
|
|
605
|
+
selectAll,
|
|
606
|
+
unselectedRows,
|
|
607
|
+
effectiveSelectAllScope,
|
|
608
|
+
selectedRowIds,
|
|
609
|
+
unselectedRowIds,
|
|
610
|
+
isRowSelected,
|
|
611
|
+
pageSelectedCount,
|
|
612
|
+
isAllSelected,
|
|
613
|
+
isIndeterminate,
|
|
614
|
+
handleSelectAll,
|
|
615
|
+
toggleRow,
|
|
616
|
+
focusedIndex,
|
|
617
|
+
handleKeyDown,
|
|
618
|
+
ensureVisible,
|
|
619
|
+
get rawProvider() {
|
|
620
|
+
return dpBridge.rawProvider;
|
|
621
|
+
},
|
|
622
|
+
pageData: dpBridge.pageData,
|
|
623
|
+
pageRows,
|
|
624
|
+
rowCount: dpBridge.rowCount,
|
|
625
|
+
dpRowCount: dpBridge.rowCount,
|
|
626
|
+
filter: dpBridge.filter,
|
|
627
|
+
dpFilter: dpBridge.filter,
|
|
628
|
+
activeFilter,
|
|
629
|
+
sortList: dpBridge.sortList,
|
|
630
|
+
dpSortList: dpBridge.sortList,
|
|
631
|
+
loading: dpBridge.loading,
|
|
632
|
+
dpLoading: dpBridge.loading,
|
|
633
|
+
initialLoad: dpBridge.initialLoad,
|
|
634
|
+
dpInitialLoad: dpBridge.initialLoad,
|
|
635
|
+
isLoading,
|
|
636
|
+
error: dpBridge.error,
|
|
637
|
+
dpError: dpBridge.error,
|
|
638
|
+
stateVersion: dpBridge.stateVersion,
|
|
639
|
+
dpStateVersion: dpBridge.stateVersion,
|
|
640
|
+
filterSortVersion: dpBridge.filterSortVersion,
|
|
641
|
+
dpFilterSortVersion: dpBridge.filterSortVersion,
|
|
642
|
+
currentPage: dpBridge.currentPage,
|
|
643
|
+
dpCurrentPage: dpBridge.currentPage,
|
|
644
|
+
pageSize: dpBridge.pageSize,
|
|
645
|
+
dpPageSize: dpBridge.pageSize,
|
|
646
|
+
effectivePageSize,
|
|
647
|
+
dpFields,
|
|
648
|
+
setCurrentPage: dpBridge.setCurrentPage,
|
|
649
|
+
setPageSize: dpBridge.setPageSize,
|
|
650
|
+
setFilter: dpBridge.setFilter,
|
|
651
|
+
setSortList: dpBridge.setSortList,
|
|
652
|
+
refresh: dpBridge.refresh,
|
|
653
|
+
loadPageData: dpBridge.loadPageData,
|
|
654
|
+
getState: dpBridge.getState,
|
|
655
|
+
setState: dpBridge.setState
|
|
656
|
+
};
|
|
657
|
+
}
|
|
@@ -1,19 +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
|
-
/** Reactive array, computed ref, or getter function for items */
|
|
4
|
-
items
|
|
5
|
-
/**
|
|
6
|
-
|
|
3
|
+
/** Reactive array, computed ref, or getter function for items (optional if totalCount is provided) */
|
|
4
|
+
items?: MaybeRefOrGetter<T[]>;
|
|
5
|
+
/** Total count of items for virtualization (takes precedence over items.length if provided) */
|
|
6
|
+
totalCount?: MaybeRefOrGetter<number | undefined>;
|
|
7
|
+
/** Optional on-demand item resolver callback for index */
|
|
8
|
+
getItem?: (index: number) => T;
|
|
9
|
+
/** Height of each item in px (default: 40) or dynamic calculation function */
|
|
10
|
+
itemHeight?: MaybeRefOrGetter<number | ((item: T, index: number) => number) | undefined>;
|
|
7
11
|
/** Viewport height of the scroll container in px (default: 400) */
|
|
8
|
-
containerHeight?:
|
|
12
|
+
containerHeight?: MaybeRefOrGetter<number | undefined>;
|
|
9
13
|
/** Number of buffer items above and below the visible window (default: 5) */
|
|
10
|
-
buffer?: number |
|
|
14
|
+
buffer?: MaybeRefOrGetter<number | undefined>;
|
|
11
15
|
/** Parametric opt-in flag. When false, returns all items with 0 spacers (default: false) */
|
|
12
|
-
virtualScroll?: boolean |
|
|
16
|
+
virtualScroll?: MaybeRefOrGetter<boolean | undefined>;
|
|
13
17
|
/** Number of columns for grid virtualization (default: 1) */
|
|
14
|
-
columns?: number |
|
|
18
|
+
columns?: MaybeRefOrGetter<number | undefined>;
|
|
15
19
|
/** Distance from bottom in px to trigger infinite/streaming load (default: 100) */
|
|
16
|
-
scrollThreshold?: number
|
|
20
|
+
scrollThreshold?: MaybeRefOrGetter<number | undefined>;
|
|
17
21
|
/** Callback fired when user scrolls near the bottom */
|
|
18
22
|
onThresholdReach?: () => void;
|
|
19
23
|
}
|