@katlux/toolkit 0.1.1-alpha.146 → 0.1.1-alpha.148
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 +71 -13
- 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 -1030
- package/bin/cli.mjs +14 -10
- package/bin/preset-contracts.json +66 -10
- 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 +28 -895
- package/dist/compiled/composables/useDataProvider.mjs +3 -1
- package/dist/compiled/composables/useKatluxForm.mjs +7 -7
- package/dist/compiled/composables/usePresetComponent.mjs +2 -0
- package/dist/compiled/composables/useRequestQueue.mjs +3 -1
- package/dist/compiled/composables/useVirtualDataset.mjs +322 -354
- package/dist/compiled/composables/useVirtualScroll.mjs +69 -62
- 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 +0 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -6
- package/dist/runtime/app.config.d.ts +3 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +8 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -55
- 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 +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +8 -4
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +4 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +2 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +41 -26
- package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +10 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +1 -1
- 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 -27
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +19 -7
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +20 -0
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +54 -14
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +6 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +45 -26
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +66 -20
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +3 -3
- 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 +3 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue +7 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +3 -1
- 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 +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- 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 +1 -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.logic.js +30 -7
- package/dist/runtime/components/KMultiTabs/KMultiTabs.logic.d.ts +1 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +6 -4
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +17 -9
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.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 +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +12 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +12 -1
- 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.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
- 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 +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.logic.js +21 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +8 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +8 -4
- 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 +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +36 -12
- 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 +28 -895
- package/dist/runtime/composables/useDataProvider.js +3 -1
- package/dist/runtime/composables/useKatluxForm.js +7 -7
- 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/useVirtualDataset.d.ts +6 -118
- package/dist/runtime/composables/useVirtualDataset.js +322 -354
- package/dist/runtime/composables/useVirtualScroll.d.ts +9 -9
- package/dist/runtime/composables/useVirtualScroll.js +69 -62
- 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 +7 -0
- package/dist/runtime/plugins/toastPlugin.client.js +2 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +24 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +2 -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 +60 -21
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +109 -15
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +14 -0
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +1 -1
- 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 +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +23 -69
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +22 -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 +1 -1
- package/dist/runtime/presets/default/components/KTree/KTree.vue +51 -80
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
- 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/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 +15 -19
- package/dist/skills/katlux-components/components/KBulkActions.md +1 -1
- package/dist/skills/katlux-components/components/KDataIterator.md +5 -0
- package/dist/skills/katlux-components/components/KLayout.md +4 -0
- package/dist/skills/katlux-components/components/KLoader.md +3 -0
- package/dist/skills/katlux-components/components/KTextbox.md +1 -0
- package/dist/skills/katlux-config/SKILL.md +15 -7
- package/dist/skills/katlux-presets/SKILL.md +42 -2
- package/dist/skills/katlux-providers/SKILL.md +12 -0
- package/dist/skills/katlux-providers/providers/ADataProvider.md +1 -0
- package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
- package/dist/skills/katlux-providers/providers/RequestProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +150 -27
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +4 -1
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +12 -6
- package/dist/skills/katlux-providers/providers/encryption.md +1 -1
- package/package.json +3 -3
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { ref, computed, unref, watch, getCurrentScope, onScopeDispose } from "vue";
|
|
1
|
+
import { ref, computed, unref, toValue, watch, getCurrentScope, onScopeDispose } from "vue";
|
|
2
|
+
import { resolveElement } from "../utils/dom";
|
|
2
3
|
export function useVirtualScroll(options) {
|
|
3
4
|
const containerRef = ref(null);
|
|
4
5
|
const scrollTop = ref(0);
|
|
5
6
|
const resolveItems = () => {
|
|
6
|
-
|
|
7
|
-
return options.items();
|
|
8
|
-
}
|
|
9
|
-
return unref(options.items) || [];
|
|
7
|
+
return toValue(options.items) || [];
|
|
10
8
|
};
|
|
11
9
|
const allItems = computed(() => resolveItems());
|
|
12
10
|
const resolveTotalCount = () => {
|
|
13
11
|
if (options.totalCount !== void 0) {
|
|
14
|
-
|
|
15
|
-
const val = unref(options.totalCount);
|
|
12
|
+
const val = toValue(options.totalCount);
|
|
16
13
|
return typeof val === "number" && val >= 0 ? val : 0;
|
|
17
14
|
}
|
|
18
15
|
return allItems.value.length;
|
|
@@ -20,34 +17,39 @@ export function useVirtualScroll(options) {
|
|
|
20
17
|
const totalCount = computed(() => resolveTotalCount());
|
|
21
18
|
const isVirtual = computed(() => {
|
|
22
19
|
if (options.virtualScroll === void 0) return false;
|
|
23
|
-
return
|
|
20
|
+
return toValue(options.virtualScroll) === true;
|
|
24
21
|
});
|
|
25
22
|
const colCount = computed(() => {
|
|
26
|
-
const c =
|
|
23
|
+
const c = toValue(options.columns);
|
|
27
24
|
return typeof c === "number" && c > 1 ? c : 1;
|
|
28
25
|
});
|
|
29
26
|
const buf = computed(() => {
|
|
30
|
-
const b =
|
|
31
|
-
return typeof b === "number" ? b : 5;
|
|
27
|
+
const b = toValue(options.buffer);
|
|
28
|
+
return typeof b === "number" && Number.isFinite(b) && b >= 0 ? b : 5;
|
|
32
29
|
});
|
|
33
30
|
const defaultHeight = 40;
|
|
34
|
-
const
|
|
31
|
+
const resolveItemHeightOption = () => {
|
|
35
32
|
const raw = unref(options.itemHeight);
|
|
33
|
+
if (typeof raw === "function" && raw.length === 0) {
|
|
34
|
+
return raw();
|
|
35
|
+
}
|
|
36
|
+
return raw;
|
|
37
|
+
};
|
|
38
|
+
const getItemHeight = (item, index) => {
|
|
39
|
+
const raw = resolveItemHeightOption();
|
|
36
40
|
if (typeof raw === "function") {
|
|
37
|
-
|
|
41
|
+
const h = raw(item, index);
|
|
42
|
+
return typeof h === "number" && Number.isFinite(h) && h > 0 ? h : defaultHeight;
|
|
38
43
|
}
|
|
39
44
|
return typeof raw === "number" && raw > 0 ? raw : defaultHeight;
|
|
40
45
|
};
|
|
41
46
|
const baseItemHeight = computed(() => {
|
|
42
|
-
const h =
|
|
47
|
+
const h = resolveItemHeightOption();
|
|
43
48
|
if (typeof h === "number" && h > 0) return h;
|
|
44
49
|
return defaultHeight;
|
|
45
50
|
});
|
|
46
51
|
const resolveContainerHeight = () => {
|
|
47
|
-
|
|
48
|
-
return options.containerHeight() || 400;
|
|
49
|
-
}
|
|
50
|
-
const val = unref(options.containerHeight);
|
|
52
|
+
const val = toValue(options.containerHeight);
|
|
51
53
|
return typeof val === "number" && val > 0 ? val : 400;
|
|
52
54
|
};
|
|
53
55
|
const configuredContainerHeight = computed(() => resolveContainerHeight());
|
|
@@ -62,32 +64,37 @@ export function useVirtualScroll(options) {
|
|
|
62
64
|
);
|
|
63
65
|
watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
|
|
64
66
|
if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
const prevEl = resolveElement(oldEl) ?? oldEl;
|
|
68
|
+
if (prevEl && prevEl.__vsObserver) {
|
|
69
|
+
;
|
|
70
|
+
prevEl.__vsObserver.disconnect();
|
|
71
|
+
delete prevEl.__vsObserver;
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
const targetEl = resolveElement(el) ?? el;
|
|
74
|
+
if (targetEl && virtual && typeof Element !== "undefined" && targetEl instanceof Element) {
|
|
70
75
|
const ro = new ResizeObserver((entries) => {
|
|
71
76
|
for (const entry of entries) {
|
|
72
|
-
const h = Math.round(entry.contentRect.height ||
|
|
77
|
+
const h = Math.round(entry.contentRect.height || targetEl.clientHeight);
|
|
73
78
|
if (h > 0 && h !== viewportHeight.value) {
|
|
74
79
|
viewportHeight.value = h;
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
});
|
|
78
|
-
ro.observe(
|
|
79
|
-
|
|
83
|
+
ro.observe(targetEl);
|
|
84
|
+
targetEl.__vsObserver = ro;
|
|
80
85
|
}
|
|
81
86
|
});
|
|
82
87
|
if (getCurrentScope()) {
|
|
83
88
|
onScopeDispose(() => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
const targetEl = resolveElement(containerRef.value) ?? containerRef.value;
|
|
90
|
+
if (targetEl && targetEl.__vsObserver) {
|
|
91
|
+
;
|
|
92
|
+
targetEl.__vsObserver.disconnect();
|
|
93
|
+
delete targetEl.__vsObserver;
|
|
87
94
|
}
|
|
88
95
|
});
|
|
89
96
|
}
|
|
90
|
-
const isDynamicHeight = computed(() => typeof
|
|
97
|
+
const isDynamicHeight = computed(() => typeof resolveItemHeightOption() === "function");
|
|
91
98
|
const rowOffsets = computed(() => {
|
|
92
99
|
if (!isDynamicHeight.value || colCount.value > 1) return [];
|
|
93
100
|
const count = totalCount.value;
|
|
@@ -208,14 +215,22 @@ export function useVirtualScroll(options) {
|
|
|
208
215
|
}
|
|
209
216
|
}
|
|
210
217
|
});
|
|
211
|
-
const containerCssVars = computed(() =>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
const containerCssVars = computed(() => {
|
|
219
|
+
const vars = {
|
|
220
|
+
"--virtual-spacer-top": `${topSpacerHeight.value}px`,
|
|
221
|
+
"--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
|
|
222
|
+
"--virtual-total-height": `${totalHeight.value}px`,
|
|
223
|
+
"--virtual-container-height": `${configuredContainerHeight.value}px`
|
|
224
|
+
};
|
|
225
|
+
if (!isDynamicHeight.value) {
|
|
226
|
+
vars["--virtual-item-height"] = `${baseItemHeight.value}px`;
|
|
227
|
+
}
|
|
228
|
+
return vars;
|
|
229
|
+
});
|
|
230
|
+
const scrollThreshold = computed(() => {
|
|
231
|
+
const val = toValue(options.scrollThreshold);
|
|
232
|
+
return typeof val === "number" && Number.isFinite(val) && val >= 0 ? val : 100;
|
|
233
|
+
});
|
|
219
234
|
const onScroll = (e) => {
|
|
220
235
|
const target = e.target;
|
|
221
236
|
if (!target) return;
|
|
@@ -224,43 +239,35 @@ export function useVirtualScroll(options) {
|
|
|
224
239
|
viewportHeight.value = target.clientHeight;
|
|
225
240
|
}
|
|
226
241
|
const distanceToBottom = target.scrollHeight - (target.scrollTop + target.clientHeight);
|
|
227
|
-
if (distanceToBottom <= scrollThreshold && typeof options.onThresholdReach === "function") {
|
|
242
|
+
if (distanceToBottom <= scrollThreshold.value && typeof options.onThresholdReach === "function") {
|
|
228
243
|
options.onThresholdReach();
|
|
229
244
|
}
|
|
230
245
|
};
|
|
246
|
+
const applyScrollTop = (targetScrollTop, behavior) => {
|
|
247
|
+
const el = resolveElement(containerRef.value) ?? containerRef.value;
|
|
248
|
+
if (!el) return;
|
|
249
|
+
el.scrollTop = targetScrollTop;
|
|
250
|
+
if (typeof el.scrollTo === "function") {
|
|
251
|
+
try {
|
|
252
|
+
el.scrollTo({
|
|
253
|
+
top: targetScrollTop,
|
|
254
|
+
behavior
|
|
255
|
+
});
|
|
256
|
+
} catch {
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
231
260
|
const scrollToIndex = (index, behavior = "auto", offset = 0) => {
|
|
232
261
|
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
233
262
|
const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
|
|
234
263
|
scrollTop.value = targetScrollTop2;
|
|
235
|
-
|
|
236
|
-
containerRef.value.scrollTop = targetScrollTop2;
|
|
237
|
-
if (typeof containerRef.value.scrollTo === "function") {
|
|
238
|
-
try {
|
|
239
|
-
containerRef.value.scrollTo({
|
|
240
|
-
top: targetScrollTop2,
|
|
241
|
-
behavior
|
|
242
|
-
});
|
|
243
|
-
} catch {
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
264
|
+
applyScrollTop(targetScrollTop2, behavior);
|
|
247
265
|
return;
|
|
248
266
|
}
|
|
249
267
|
const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
|
|
250
268
|
const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
|
|
251
269
|
scrollTop.value = targetScrollTop;
|
|
252
|
-
|
|
253
|
-
containerRef.value.scrollTop = targetScrollTop;
|
|
254
|
-
if (typeof containerRef.value.scrollTo === "function") {
|
|
255
|
-
try {
|
|
256
|
-
containerRef.value.scrollTo({
|
|
257
|
-
top: targetScrollTop,
|
|
258
|
-
behavior
|
|
259
|
-
});
|
|
260
|
-
} catch {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
270
|
+
applyScrollTop(targetScrollTop, behavior);
|
|
264
271
|
};
|
|
265
272
|
return {
|
|
266
273
|
startIndex,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { isRef, unref } from "vue";
|
|
2
|
+
export function isUseDataProviderReturn(val) {
|
|
3
|
+
return val !== null && typeof val === "object" && "pageData" in val && isRef(val.pageData) && "stateVersion" in val && isRef(val.stateVersion);
|
|
4
|
+
}
|
|
5
|
+
export function resolveProviderAllDataRef(dp) {
|
|
6
|
+
if (!dp) return void 0;
|
|
7
|
+
return dp.allData?.value ?? dp.allData ?? dp.rowMap?.value ?? dp.rowMap ?? dp.data;
|
|
8
|
+
}
|
|
9
|
+
export function resolveVirtualItemsArray(dp, fallbackPageRows, isVirtual) {
|
|
10
|
+
if (isVirtual && dp) {
|
|
11
|
+
const candidates = [
|
|
12
|
+
dp.rowMap,
|
|
13
|
+
dp.rowMap?.value,
|
|
14
|
+
dp.allVisibleRows,
|
|
15
|
+
dp.allVisibleRows?.value,
|
|
16
|
+
dp.allVisibleNodes,
|
|
17
|
+
dp.allVisibleNodes?.value,
|
|
18
|
+
dp.visibleRows,
|
|
19
|
+
dp.visibleRows?.value,
|
|
20
|
+
dp.filteredData?.value,
|
|
21
|
+
dp.filteredData,
|
|
22
|
+
dp.allData?.value,
|
|
23
|
+
dp.allData,
|
|
24
|
+
dp.data
|
|
25
|
+
];
|
|
26
|
+
for (const candidate of candidates) {
|
|
27
|
+
if (Array.isArray(candidate)) return candidate;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return fallbackPageRows;
|
|
31
|
+
}
|
|
32
|
+
export function resolveVirtualTotalCount(dp, bridgeRowCount, datasetItems, pageRowsLength, isVirtual) {
|
|
33
|
+
if (!isVirtual) return pageRowsLength;
|
|
34
|
+
if (dp?.paginateBy === "root" && Array.isArray(dp.allVisibleRows)) {
|
|
35
|
+
return dp.allVisibleRows.length;
|
|
36
|
+
}
|
|
37
|
+
const rc = bridgeRowCount ?? dp?.rowCount;
|
|
38
|
+
const count = typeof rc === "number" ? rc : unref(rc);
|
|
39
|
+
if (typeof count === "number" && (count > 0 || datasetItems.length === 0)) return count;
|
|
40
|
+
if (Array.isArray(dp?.rowMap)) {
|
|
41
|
+
return dp.rowMap.length;
|
|
42
|
+
}
|
|
43
|
+
return datasetItems.length;
|
|
44
|
+
}
|
|
45
|
+
export function classifyVirtualStateChange(params) {
|
|
46
|
+
const { dp, snapshot } = params;
|
|
47
|
+
if (dp !== snapshot.provider) {
|
|
48
|
+
return "invalidate";
|
|
49
|
+
}
|
|
50
|
+
const stateChanged = params.dpBridgeStateVersion !== snapshot.stateVersion;
|
|
51
|
+
const pageChanged = params.pageRowsRef !== snapshot.pageRowsRef;
|
|
52
|
+
const allDataChanged = resolveProviderAllDataRef(dp) !== snapshot.allDataRef;
|
|
53
|
+
const customChanged = params.customChangeCount !== snapshot.customChangeCount;
|
|
54
|
+
if (!stateChanged && !pageChanged && !allDataChanged && !customChanged) {
|
|
55
|
+
return "none";
|
|
56
|
+
}
|
|
57
|
+
const batchGenNow = dp?._batchGeneration;
|
|
58
|
+
const loadedBatchesSizeNow = dp?.loadedBatches instanceof Set ? dp.loadedBatches.size : 0;
|
|
59
|
+
const isIncrementalBatchAppend = Boolean(
|
|
60
|
+
dp && dp.batchLoad === "onDemand" && dp.loadedBatches instanceof Set && batchGenNow === snapshot.batchGeneration && loadedBatchesSizeNow > snapshot.loadedBatchesSize
|
|
61
|
+
);
|
|
62
|
+
if (isIncrementalBatchAppend && !customChanged) {
|
|
63
|
+
return "skip";
|
|
64
|
+
}
|
|
65
|
+
if (params.currentPage !== snapshot.currentPage && !allDataChanged && !customChanged) {
|
|
66
|
+
return "pageSwitch";
|
|
67
|
+
}
|
|
68
|
+
if (pageChanged || allDataChanged || customChanged) {
|
|
69
|
+
return "invalidate";
|
|
70
|
+
}
|
|
71
|
+
const loadingChanged = params.loading !== snapshot.loading || params.initialLoad !== snapshot.initialLoad || params.error !== snapshot.error || dp?.batchProgress !== snapshot.batchProgress || Boolean(dp?.isBatchLoading) !== snapshot.isBatchLoading;
|
|
72
|
+
if (loadingChanged || params.isFetchingPage) {
|
|
73
|
+
return "skip";
|
|
74
|
+
}
|
|
75
|
+
return "invalidate";
|
|
76
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function resolveDomTheadOffset(container, fallbackOffset) {
|
|
2
|
+
if (container) {
|
|
3
|
+
const thead = container.querySelector("thead");
|
|
4
|
+
if (thead && thead.offsetHeight > 0) {
|
|
5
|
+
return thead.offsetHeight;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return fallbackOffset;
|
|
9
|
+
}
|
|
10
|
+
export function resolveDomItemHeight(container, optionHeight) {
|
|
11
|
+
if (container) {
|
|
12
|
+
const rowEl = container.querySelector('tbody tr, [role="row"]');
|
|
13
|
+
if (rowEl && rowEl.offsetHeight > 0) {
|
|
14
|
+
return rowEl.offsetHeight;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (typeof optionHeight === "function") return 40;
|
|
18
|
+
return typeof optionHeight === "number" && optionHeight > 0 ? optionHeight : 40;
|
|
19
|
+
}
|
|
20
|
+
export function resolveDomViewportHeight(container, measuredHeight, optionHeight) {
|
|
21
|
+
if (container && container.clientHeight > 0) {
|
|
22
|
+
return container.clientHeight;
|
|
23
|
+
}
|
|
24
|
+
if (measuredHeight > 0) {
|
|
25
|
+
return measuredHeight;
|
|
26
|
+
}
|
|
27
|
+
return typeof optionHeight === "number" && optionHeight > 0 ? optionHeight : 500;
|
|
28
|
+
}
|
|
29
|
+
export function computeNextKeyboardFocusIndex(params) {
|
|
30
|
+
const { key, currentFocus, total, firstInView, lastInView, pageStep } = params;
|
|
31
|
+
const outOfView = currentFocus < firstInView || currentFocus > lastInView;
|
|
32
|
+
switch (key) {
|
|
33
|
+
case "ArrowDown":
|
|
34
|
+
return {
|
|
35
|
+
nextIndex: outOfView ? Math.min(total - 1, firstInView) : Math.min(total - 1, currentFocus + 1),
|
|
36
|
+
scrollMode: "ensureVisible"
|
|
37
|
+
};
|
|
38
|
+
case "ArrowUp":
|
|
39
|
+
return {
|
|
40
|
+
nextIndex: outOfView ? Math.max(0, lastInView) : Math.max(0, currentFocus - 1),
|
|
41
|
+
scrollMode: "ensureVisible"
|
|
42
|
+
};
|
|
43
|
+
case "PageDown":
|
|
44
|
+
return {
|
|
45
|
+
nextIndex: outOfView ? Math.min(total - 1, firstInView + pageStep) : Math.min(total - 1, currentFocus + pageStep),
|
|
46
|
+
scrollMode: "ensureVisible"
|
|
47
|
+
};
|
|
48
|
+
case "PageUp":
|
|
49
|
+
return {
|
|
50
|
+
nextIndex: outOfView ? Math.max(0, lastInView - pageStep) : Math.max(0, currentFocus - pageStep),
|
|
51
|
+
scrollMode: "ensureVisible"
|
|
52
|
+
};
|
|
53
|
+
case "Home":
|
|
54
|
+
return { nextIndex: 0, scrollMode: "home" };
|
|
55
|
+
case "End":
|
|
56
|
+
return { nextIndex: total - 1, scrollMode: "end" };
|
|
57
|
+
default:
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { unref } from "vue";
|
|
2
|
+
import { isEncrypted } from "@katlux/providers";
|
|
3
|
+
export function extractVirtualRowId(row, idKey) {
|
|
4
|
+
return row?.[idKey] ?? row?.id ?? row?._id ?? row?.__treeNode?.id;
|
|
5
|
+
}
|
|
6
|
+
export function getTreeBranchRows(row, dp, fallbackRows, idKey) {
|
|
7
|
+
if (!dp || !("parentKey" in dp) && typeof dp.toggleNode !== "function") {
|
|
8
|
+
return [row];
|
|
9
|
+
}
|
|
10
|
+
const parentKey = dp.parentKey || "parentId";
|
|
11
|
+
const sourceRows = unref(dp.allData) || fallbackRows || [];
|
|
12
|
+
const rootId = extractVirtualRowId(row, idKey);
|
|
13
|
+
if (rootId === null || rootId === void 0) return [row];
|
|
14
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
15
|
+
for (const r of sourceRows) {
|
|
16
|
+
const pId = r?.__treeNode?.parentId ?? r?.[parentKey];
|
|
17
|
+
if (pId === null || pId === void 0) continue;
|
|
18
|
+
let list = childrenByParent.get(pId);
|
|
19
|
+
if (!list) {
|
|
20
|
+
list = [];
|
|
21
|
+
childrenByParent.set(pId, list);
|
|
22
|
+
}
|
|
23
|
+
list.push(r);
|
|
24
|
+
}
|
|
25
|
+
const result = [row];
|
|
26
|
+
const visited = /* @__PURE__ */ new Set([rootId]);
|
|
27
|
+
const queue = [rootId];
|
|
28
|
+
while (queue.length > 0) {
|
|
29
|
+
const curr = queue.shift();
|
|
30
|
+
for (const child of childrenByParent.get(curr) || []) {
|
|
31
|
+
const cId = extractVirtualRowId(child, idKey);
|
|
32
|
+
if (cId !== null && cId !== void 0 && !visited.has(cId)) {
|
|
33
|
+
visited.add(cId);
|
|
34
|
+
result.push(child);
|
|
35
|
+
queue.push(cId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
export function getTreeAncestorIds(row, dp, fallbackRows, idKey) {
|
|
42
|
+
if (!dp || !("parentKey" in dp) && typeof dp.toggleNode !== "function") return [];
|
|
43
|
+
const parentKey = dp.parentKey || "parentId";
|
|
44
|
+
const sourceRows = unref(dp.allData) || fallbackRows || [];
|
|
45
|
+
const parentById = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const r of sourceRows) {
|
|
47
|
+
const id = extractVirtualRowId(r, idKey);
|
|
48
|
+
if (id !== null && id !== void 0) parentById.set(id, r?.__treeNode?.parentId ?? r?.[parentKey] ?? null);
|
|
49
|
+
}
|
|
50
|
+
const ancestors = [];
|
|
51
|
+
const startId = extractVirtualRowId(row, idKey);
|
|
52
|
+
const visited = /* @__PURE__ */ new Set([startId]);
|
|
53
|
+
let currParent = row?.__treeNode?.parentId ?? row?.[parentKey] ?? parentById.get(startId) ?? null;
|
|
54
|
+
while (currParent !== null && currParent !== void 0 && !visited.has(currParent)) {
|
|
55
|
+
visited.add(currParent);
|
|
56
|
+
ancestors.push(currParent);
|
|
57
|
+
currParent = parentById.get(currParent) ?? null;
|
|
58
|
+
}
|
|
59
|
+
return ancestors;
|
|
60
|
+
}
|
|
61
|
+
export function buildSelectionIdSet(rows, idKey) {
|
|
62
|
+
const set = /* @__PURE__ */ new Set();
|
|
63
|
+
for (const r of rows || []) {
|
|
64
|
+
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
65
|
+
set.add(id);
|
|
66
|
+
set.add(r);
|
|
67
|
+
}
|
|
68
|
+
return set;
|
|
69
|
+
}
|
|
70
|
+
export function detectEncryptedCellValue(val, rawProvider) {
|
|
71
|
+
if (!val || typeof val !== "object") return false;
|
|
72
|
+
if (val.__encrypted === true) return true;
|
|
73
|
+
const cipher = rawProvider?.cipherProvider;
|
|
74
|
+
if (cipher && typeof cipher.isEncrypted === "function") {
|
|
75
|
+
return cipher.isEncrypted(val);
|
|
76
|
+
}
|
|
77
|
+
return typeof isEncrypted === "function" ? isEncrypted(val) : false;
|
|
78
|
+
}
|
|
79
|
+
export function computePageScopedSelectAllRows(datasetItems, currentSelected, selectedRowIds, dp, idKey, allSelected) {
|
|
80
|
+
if (allSelected) {
|
|
81
|
+
const pageIdSet = new Set(
|
|
82
|
+
datasetItems.flatMap(
|
|
83
|
+
(r) => getTreeBranchRows(r, dp, datasetItems, idKey).map((b) => b?.[idKey] ?? b?.id ?? b?._id ?? b)
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
return currentSelected.filter((r) => {
|
|
87
|
+
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
88
|
+
return !pageIdSet.has(id) && !pageIdSet.has(r);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const existingIds = new Set(selectedRowIds);
|
|
92
|
+
const toAdd = [];
|
|
93
|
+
for (const r of datasetItems) {
|
|
94
|
+
for (const item of getTreeBranchRows(r, dp, datasetItems, idKey)) {
|
|
95
|
+
const id = item?.[idKey] ?? item?.id ?? item?._id ?? item;
|
|
96
|
+
if (!existingIds.has(id) && !existingIds.has(item)) {
|
|
97
|
+
existingIds.add(id);
|
|
98
|
+
toAdd.push(item);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return [...currentSelected, ...toAdd];
|
|
103
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getCurrentInstance } from "vue";
|
|
2
|
+
const warnedDeprecations = /* @__PURE__ */ new Set();
|
|
3
|
+
function isProductionEnv() {
|
|
4
|
+
return typeof process !== "undefined" && process.env?.NODE_ENV === "production";
|
|
5
|
+
}
|
|
6
|
+
function toCamelCase(eventName) {
|
|
7
|
+
return eventName.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
function capitalize(str) {
|
|
10
|
+
return str ? str.charAt(0).toUpperCase() + str.slice(1) : "";
|
|
11
|
+
}
|
|
12
|
+
function hasLegacyListener(vnodeProps, eventName) {
|
|
13
|
+
if (!vnodeProps) return false;
|
|
14
|
+
const exactKey = `on${capitalize(eventName)}`;
|
|
15
|
+
const camelKey = `on${capitalize(toCamelCase(eventName))}`;
|
|
16
|
+
return typeof vnodeProps[exactKey] === "function" || typeof vnodeProps[camelKey] === "function";
|
|
17
|
+
}
|
|
18
|
+
export function warnDeprecatedOnce(key, message) {
|
|
19
|
+
if (isProductionEnv() || warnedDeprecations.has(key)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
warnedDeprecations.add(key);
|
|
23
|
+
console.warn(`[Katlux Toolkit]: ${message}`);
|
|
24
|
+
}
|
|
25
|
+
export function clearDeprecationWarnings() {
|
|
26
|
+
warnedDeprecations.clear();
|
|
27
|
+
}
|
|
28
|
+
export function createLegacyEventEmitter(componentName, emit) {
|
|
29
|
+
const instance = getCurrentInstance();
|
|
30
|
+
return (canonicalEvent, legacyEvents, payload) => {
|
|
31
|
+
if (!emit) return;
|
|
32
|
+
emit(canonicalEvent, payload);
|
|
33
|
+
const vnodeProps = instance?.vnode?.props;
|
|
34
|
+
for (const legacyEvent of legacyEvents) {
|
|
35
|
+
if (!instance || hasLegacyListener(vnodeProps, legacyEvent)) {
|
|
36
|
+
warnDeprecatedOnce(
|
|
37
|
+
`${componentName}:${legacyEvent}`,
|
|
38
|
+
`<${componentName}> event "@${legacyEvent}" is deprecated and will be removed in a future release. Use "@${canonicalEvent}" instead.`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
emit(legacyEvent, payload);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { unref } from "vue";
|
|
2
|
+
function collectVNodeElements(vnode, out) {
|
|
3
|
+
if (!vnode) return;
|
|
4
|
+
if (vnode.el && vnode.anchor && vnode.el.parentNode && vnode.el.parentNode === vnode.anchor.parentNode) {
|
|
5
|
+
let cur = vnode.el;
|
|
6
|
+
while (cur) {
|
|
7
|
+
if (cur.nodeType === 1) {
|
|
8
|
+
out.push(cur);
|
|
9
|
+
}
|
|
10
|
+
if (cur === vnode.anchor) break;
|
|
11
|
+
cur = cur.nextSibling;
|
|
12
|
+
}
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (vnode.el && vnode.el.nodeType === 1) {
|
|
16
|
+
out.push(vnode.el);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (vnode.component?.subTree) {
|
|
20
|
+
collectVNodeElements(vnode.component.subTree, out);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(vnode.children)) {
|
|
24
|
+
for (const child of vnode.children) {
|
|
25
|
+
if (child && typeof child === "object") {
|
|
26
|
+
collectVNodeElements(child, out);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function resolveElements(target) {
|
|
32
|
+
const raw = unref(target);
|
|
33
|
+
if (!raw) return [];
|
|
34
|
+
if (Array.isArray(raw)) {
|
|
35
|
+
const collected = [];
|
|
36
|
+
for (const item of raw) {
|
|
37
|
+
collected.push(...resolveElements(item));
|
|
38
|
+
}
|
|
39
|
+
return collected;
|
|
40
|
+
}
|
|
41
|
+
if (typeof Element !== "undefined" && raw instanceof Element) {
|
|
42
|
+
return [raw];
|
|
43
|
+
}
|
|
44
|
+
if (typeof Node !== "undefined" && raw instanceof Node) {
|
|
45
|
+
return raw.nodeType === 1 ? [raw] : [];
|
|
46
|
+
}
|
|
47
|
+
if (typeof raw === "object") {
|
|
48
|
+
const obj = raw;
|
|
49
|
+
if (obj.$el) {
|
|
50
|
+
if (obj.$el.nodeType === 1) {
|
|
51
|
+
return [obj.$el];
|
|
52
|
+
}
|
|
53
|
+
if (obj.$?.subTree) {
|
|
54
|
+
const out = [];
|
|
55
|
+
collectVNodeElements(obj.$.subTree, out);
|
|
56
|
+
if (out.length > 0) return out;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (obj.$?.subTree) {
|
|
60
|
+
const out = [];
|
|
61
|
+
collectVNodeElements(obj.$.subTree, out);
|
|
62
|
+
if (out.length > 0) return out;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
export function resolveElement(target) {
|
|
68
|
+
const raw = unref(target);
|
|
69
|
+
if (!raw) return null;
|
|
70
|
+
if (typeof raw === "object" && typeof raw.getBoundingClientRect === "function" && !("$el" in raw)) {
|
|
71
|
+
return raw;
|
|
72
|
+
}
|
|
73
|
+
const elements = resolveElements(raw);
|
|
74
|
+
if (elements.length > 0) {
|
|
75
|
+
return elements[0];
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
export function focusTarget(target) {
|
|
80
|
+
const raw = unref(target);
|
|
81
|
+
if (!raw) return false;
|
|
82
|
+
const isDomNode = typeof Node !== "undefined" && raw instanceof Node;
|
|
83
|
+
if (!isDomNode && typeof raw.focus === "function") {
|
|
84
|
+
;
|
|
85
|
+
raw.focus();
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const elements = resolveElements(raw);
|
|
89
|
+
for (const el of elements) {
|
|
90
|
+
const focusableEl = el;
|
|
91
|
+
if (typeof focusableEl.focus === "function" && (focusableEl.matches?.('input, select, textarea, button, a[href], [tabindex]:not([tabindex="-1"])') || typeof focusableEl.tabIndex === "number" && focusableEl.tabIndex >= 0)) {
|
|
92
|
+
focusableEl.focus();
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
const nested = el.querySelector?.(
|
|
96
|
+
'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])'
|
|
97
|
+
);
|
|
98
|
+
if (nested && typeof nested.focus === "function") {
|
|
99
|
+
nested.focus();
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (elements.length > 0 && typeof elements[0].focus === "function") {
|
|
104
|
+
;
|
|
105
|
+
elements[0].focus?.();
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
export function resolveModalTeleportTarget(explicitTeleportTo, modalPortalId) {
|
|
111
|
+
if (explicitTeleportTo) return explicitTeleportTo;
|
|
112
|
+
const resolvedId = unref(modalPortalId);
|
|
113
|
+
if (typeof resolvedId === "string" && resolvedId.length > 0) {
|
|
114
|
+
if (typeof document !== "undefined") {
|
|
115
|
+
if (document.getElementById(resolvedId)) {
|
|
116
|
+
const escapedId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(resolvedId) : resolvedId;
|
|
117
|
+
return `#${escapedId}`;
|
|
118
|
+
}
|
|
119
|
+
return "body";
|
|
120
|
+
}
|
|
121
|
+
return "body";
|
|
122
|
+
}
|
|
123
|
+
return "body";
|
|
124
|
+
}
|
package/dist/module.cjs
CHANGED
|
@@ -45,11 +45,6 @@ const module$1 = kit.defineNuxtModule({
|
|
|
45
45
|
extensions: ["vue"],
|
|
46
46
|
global: true
|
|
47
47
|
});
|
|
48
|
-
kit.addComponent({
|
|
49
|
-
name: "MultiTabs",
|
|
50
|
-
filePath: resolve("./runtime/components/KMultiTabs/MultiTabs.global.vue"),
|
|
51
|
-
global: true
|
|
52
|
-
});
|
|
53
48
|
kit.addImportsDir(resolve("./runtime/composables"));
|
|
54
49
|
const providerRuntimeExports = [
|
|
55
50
|
// Data Providers
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addComponentsDir,
|
|
1
|
+
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, resolvePath, resolveModule, addImports, addServerImports, addTypeTemplate, addPlugin, addServerHandler, addPluginTemplate } from '@nuxt/kit';
|
|
2
2
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
@@ -40,11 +40,6 @@ const module$1 = defineNuxtModule({
|
|
|
40
40
|
extensions: ["vue"],
|
|
41
41
|
global: true
|
|
42
42
|
});
|
|
43
|
-
addComponent({
|
|
44
|
-
name: "MultiTabs",
|
|
45
|
-
filePath: resolve("./runtime/components/KMultiTabs/MultiTabs.global.vue"),
|
|
46
|
-
global: true
|
|
47
|
-
});
|
|
48
43
|
addImportsDir(resolve("./runtime/composables"));
|
|
49
44
|
const providerRuntimeExports = [
|
|
50
45
|
// Data Providers
|