@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
|
@@ -4,38 +4,52 @@ import {
|
|
|
4
4
|
computed,
|
|
5
5
|
unref,
|
|
6
6
|
isRef,
|
|
7
|
+
toValue,
|
|
7
8
|
watch,
|
|
8
9
|
onScopeDispose
|
|
9
10
|
} from "vue";
|
|
10
|
-
import { isEncrypted } from "@katlux/providers";
|
|
11
11
|
import { useVirtualScroll } from "./useVirtualScroll.js";
|
|
12
12
|
import { useDataProvider } from "./useDataProvider.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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";
|
|
16
35
|
export function useVirtualDataset(options) {
|
|
17
36
|
const resolveRawProvider = () => {
|
|
18
37
|
if (isUseDataProviderReturn(options.dataProvider)) {
|
|
19
38
|
return options.dataProvider.rawProvider;
|
|
20
39
|
}
|
|
21
|
-
|
|
22
|
-
return options.dataProvider();
|
|
23
|
-
}
|
|
24
|
-
return isRef(options.dataProvider) ? options.dataProvider.value : options.dataProvider;
|
|
40
|
+
return toValue(options.dataProvider);
|
|
25
41
|
};
|
|
26
42
|
const rawProvider = resolveRawProvider();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
watch(() => unref(options.pageSize), (newVal) => {
|
|
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) => {
|
|
31
46
|
if (newVal !== void 0 && newVal !== datasetPageSize.value) {
|
|
32
47
|
datasetPageSize.value = newVal;
|
|
33
48
|
}
|
|
34
49
|
});
|
|
35
50
|
}
|
|
36
|
-
const dpBridge = isUseDataProviderReturn(options.dataProvider) ? options.dataProvider : useDataProvider(() => resolveRawProvider(), {
|
|
37
|
-
|
|
38
|
-
});
|
|
51
|
+
const dpBridge = isUseDataProviderReturn(options.dataProvider) ? options.dataProvider : useDataProvider(() => resolveRawProvider(), { pageSize: datasetPageSize });
|
|
52
|
+
let customChangeCount = 0;
|
|
39
53
|
let customUnsub = null;
|
|
40
54
|
const attachCustomProviderListener = (dp) => {
|
|
41
55
|
if (customUnsub) {
|
|
@@ -48,6 +62,7 @@ export function useVirtualDataset(options) {
|
|
|
48
62
|
if (dp && typeof dp.on === "function") {
|
|
49
63
|
try {
|
|
50
64
|
const off = dp.on("change", () => {
|
|
65
|
+
customChangeCount++;
|
|
51
66
|
dpBridge.stateVersion.value++;
|
|
52
67
|
});
|
|
53
68
|
customUnsub = () => {
|
|
@@ -72,21 +87,15 @@ export function useVirtualDataset(options) {
|
|
|
72
87
|
} catch {
|
|
73
88
|
}
|
|
74
89
|
if (isRef(options.dataProvider) || typeof options.dataProvider === "function") {
|
|
75
|
-
watch(resolveRawProvider, (newDp) =>
|
|
76
|
-
attachCustomProviderListener(newDp);
|
|
77
|
-
});
|
|
90
|
+
watch(resolveRawProvider, (newDp) => attachCustomProviderListener(newDp));
|
|
78
91
|
}
|
|
79
92
|
const pageRows = computed(() => dpBridge.pageData.value || []);
|
|
80
|
-
const activeFilter = computed(() =>
|
|
81
|
-
return dpBridge.filter.value || dpBridge.rawProvider?.filter || null;
|
|
82
|
-
});
|
|
93
|
+
const activeFilter = computed(() => dpBridge.filter.value || dpBridge.rawProvider?.filter || null);
|
|
83
94
|
const effectivePageSize = computed(() => {
|
|
84
|
-
const ps =
|
|
95
|
+
const ps = toValue(options.pageSize) ?? dpBridge.pageSize.value ?? dpBridge.rawProvider?.pageSize;
|
|
85
96
|
return typeof ps === "number" && ps > 0 ? ps : 10;
|
|
86
97
|
});
|
|
87
|
-
const isLoading = computed(() =>
|
|
88
|
-
return dpBridge.loading.value || dpBridge.initialLoad.value || false;
|
|
89
|
-
});
|
|
98
|
+
const isLoading = computed(() => dpBridge.loading.value || dpBridge.initialLoad.value || false);
|
|
90
99
|
const dpFields = computed(() => {
|
|
91
100
|
const _ver = dpBridge.stateVersion.value;
|
|
92
101
|
const bridgeFields = dpBridge.fields?.value;
|
|
@@ -98,62 +107,41 @@ export function useVirtualDataset(options) {
|
|
|
98
107
|
}
|
|
99
108
|
return [];
|
|
100
109
|
});
|
|
101
|
-
const rowIdKey = computed(() =>
|
|
102
|
-
|
|
103
|
-
|
|
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
|
+
};
|
|
104
118
|
const datasetItems = computed(() => {
|
|
105
119
|
const _ver = dpBridge.stateVersion.value;
|
|
106
|
-
|
|
107
|
-
const dp = dpBridge.rawProvider;
|
|
108
|
-
const isVirtual = unref(options.virtualScroll);
|
|
109
|
-
if (isVirtual && dp) {
|
|
110
|
-
if (Array.isArray(dp.rowMap)) return dp.rowMap;
|
|
111
|
-
if (Array.isArray(dp.rowMap?.value)) return dp.rowMap.value;
|
|
112
|
-
if (Array.isArray(dp.allVisibleRows)) return dp.allVisibleRows;
|
|
113
|
-
if (Array.isArray(dp.allVisibleRows?.value)) return dp.allVisibleRows.value;
|
|
114
|
-
if (Array.isArray(dp.allVisibleNodes)) return dp.allVisibleNodes;
|
|
115
|
-
if (Array.isArray(dp.allVisibleNodes?.value)) return dp.allVisibleNodes.value;
|
|
116
|
-
if (Array.isArray(dp.filteredData?.value)) return dp.filteredData.value;
|
|
117
|
-
if (Array.isArray(dp.filteredData)) return dp.filteredData;
|
|
118
|
-
if (Array.isArray(dp.allData?.value)) return dp.allData.value;
|
|
119
|
-
if (Array.isArray(dp.allData)) return dp.allData;
|
|
120
|
-
if (Array.isArray(dp.data)) return dp.data;
|
|
121
|
-
}
|
|
122
|
-
return currentRows;
|
|
120
|
+
return resolveVirtualItemsArray(dpBridge.rawProvider, pageRows.value, Boolean(toValue(options.virtualScroll)));
|
|
123
121
|
});
|
|
124
122
|
const virtualScrollReturn = useVirtualScroll({
|
|
125
123
|
totalCount: computed(() => {
|
|
126
124
|
const _ver = dpBridge.stateVersion.value;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return pageRows.value.length;
|
|
125
|
+
return resolveVirtualTotalCount(
|
|
126
|
+
dpBridge.rawProvider,
|
|
127
|
+
dpBridge.rowCount.value,
|
|
128
|
+
datasetItems.value,
|
|
129
|
+
pageRows.value.length,
|
|
130
|
+
Boolean(toValue(options.virtualScroll))
|
|
131
|
+
);
|
|
137
132
|
}),
|
|
138
133
|
items: datasetItems,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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)),
|
|
143
139
|
columns: options.columns,
|
|
144
140
|
scrollThreshold: options.scrollThreshold,
|
|
145
141
|
onThresholdReach: () => {
|
|
146
142
|
const dp = dpBridge.rawProvider;
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
dp.loadMore();
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
if (typeof dp?.loadMore === "function") {
|
|
153
|
-
dp.loadMore();
|
|
154
|
-
} else if (typeof dp?.nextPage === "function" && dp.hasMore) {
|
|
155
|
-
dp.nextPage();
|
|
156
|
-
}
|
|
143
|
+
if (!toValue(options.virtualScroll) && typeof dp?.nextPage === "function" && dp.hasMore) {
|
|
144
|
+
dp.nextPage();
|
|
157
145
|
}
|
|
158
146
|
options.onThresholdReach?.();
|
|
159
147
|
}
|
|
@@ -173,32 +161,83 @@ export function useVirtualDataset(options) {
|
|
|
173
161
|
containerCssVars
|
|
174
162
|
} = virtualScrollReturn;
|
|
175
163
|
const deliveredRowsCache = shallowRef(/* @__PURE__ */ new Map());
|
|
164
|
+
const deliveredIndexCache = shallowRef(/* @__PURE__ */ new Map());
|
|
165
|
+
const deliveredRowVersions = /* @__PURE__ */ new Map();
|
|
176
166
|
const requestedPages = /* @__PURE__ */ new Set();
|
|
177
167
|
let isFetchingPage = false;
|
|
178
168
|
const pageQueue = [];
|
|
179
169
|
let cacheGeneration = 0;
|
|
180
|
-
|
|
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);
|
|
181
192
|
if (Array.isArray(rows) && rows.length > 0) {
|
|
182
193
|
const idKey = rowIdKey.value;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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);
|
|
186
198
|
if (id !== void 0 && id !== null) {
|
|
187
199
|
nextCache.set(id, r);
|
|
200
|
+
deliveredRowVersions.set(id, dataVersion);
|
|
188
201
|
}
|
|
189
202
|
}
|
|
190
|
-
deliveredRowsCache.value = nextCache;
|
|
191
|
-
const curPage = dpBridge.currentPage.value || dpBridge.rawProvider?.currentPage || 1;
|
|
192
|
-
requestedPages.add(curPage);
|
|
193
203
|
}
|
|
194
|
-
|
|
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);
|
|
195
227
|
const processPageQueue = async () => {
|
|
196
228
|
if (isFetchingPage || pageQueue.length === 0) return;
|
|
197
229
|
const nextPage = pageQueue.shift();
|
|
198
230
|
const dp = dpBridge.rawProvider;
|
|
199
|
-
if (!dp)
|
|
231
|
+
if (!dp) {
|
|
232
|
+
requestedPages.delete(nextPage);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
200
235
|
const currentGen = cacheGeneration;
|
|
236
|
+
const versionBefore = dpBridge.stateVersion.value;
|
|
237
|
+
const pageBefore = pageRows.value;
|
|
238
|
+
const allBefore = resolveProviderAllDataRef(dp);
|
|
201
239
|
isFetchingPage = true;
|
|
240
|
+
let resolved = false;
|
|
202
241
|
try {
|
|
203
242
|
const ps = effectivePageSize.value;
|
|
204
243
|
const pageStart = (nextPage - 1) * ps;
|
|
@@ -210,31 +249,23 @@ export function useVirtualDataset(options) {
|
|
|
210
249
|
resolvedRows = await dp.getWindowRows(pageStart, pageEnd);
|
|
211
250
|
} else if (typeof dp.loadRange === "function") {
|
|
212
251
|
await dp.loadRange(pageStart, pageEnd);
|
|
213
|
-
if (Array.isArray(dp.rowMap))
|
|
214
|
-
resolvedRows = dp.rowMap.slice(pageStart, pageEnd);
|
|
215
|
-
}
|
|
252
|
+
if (Array.isArray(dp.rowMap)) resolvedRows = dp.rowMap.slice(pageStart, pageEnd);
|
|
216
253
|
}
|
|
217
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
|
+
}
|
|
218
259
|
if (Array.isArray(resolvedRows) && resolvedRows.length > 0) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
for (const r of resolvedRows) {
|
|
222
|
-
const id = r?.[idKey] ?? r?.id ?? r?._id;
|
|
223
|
-
if (id !== void 0 && id !== null) {
|
|
224
|
-
nextCache.set(id, r);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
deliveredRowsCache.value = nextCache;
|
|
228
|
-
} else {
|
|
229
|
-
requestedPages.delete(nextPage);
|
|
260
|
+
writeRowsToCache(resolvedRows, pageStart, false);
|
|
261
|
+
resolved = true;
|
|
230
262
|
}
|
|
231
263
|
} catch (err) {
|
|
232
264
|
console.warn("[useVirtualDataset] processPageQueue error:", err);
|
|
233
265
|
} finally {
|
|
266
|
+
if (!resolved && currentGen === cacheGeneration) requestedPages.delete(nextPage);
|
|
234
267
|
isFetchingPage = false;
|
|
235
|
-
if (pageQueue.length > 0)
|
|
236
|
-
processPageQueue();
|
|
237
|
-
}
|
|
268
|
+
if (pageQueue.length > 0) processPageQueue();
|
|
238
269
|
}
|
|
239
270
|
};
|
|
240
271
|
const queuePage = (page) => {
|
|
@@ -245,146 +276,120 @@ export function useVirtualDataset(options) {
|
|
|
245
276
|
}
|
|
246
277
|
};
|
|
247
278
|
const ensureVisiblePagesLoaded = () => {
|
|
248
|
-
if (!
|
|
279
|
+
if (typeof window === "undefined" || !toValue(options.virtualScroll)) return;
|
|
249
280
|
const start = startIndex.value;
|
|
250
281
|
const end = endIndex.value;
|
|
251
282
|
const dp = dpBridge.rawProvider;
|
|
252
|
-
if (dp && typeof dp.ensureRangeLoaded === "function")
|
|
253
|
-
dp.ensureRangeLoaded(start, end);
|
|
254
|
-
}
|
|
255
|
-
const vHeight = typeof viewportHeight.value === "number" && viewportHeight.value > 0 ? viewportHeight.value : 500;
|
|
256
|
-
const rawH = unref(options.itemHeight);
|
|
257
|
-
const iHeight = typeof rawH === "number" && rawH > 0 ? rawH : 40;
|
|
258
|
-
const visibleEnd = Math.ceil((scrollTop.value + vHeight) / iHeight);
|
|
259
|
-
const needsMore = scrollTop.value > 0 && end > datasetItems.value.length || visibleEnd > datasetItems.value.length;
|
|
260
|
-
if (dp && typeof dp.loadMore === "function" && dp.batchLoad !== "onDemand" && dp.hasMore && !dp.loading && !dp._inFlightLoadMore && needsMore) {
|
|
261
|
-
const res = dp.loadMore();
|
|
262
|
-
if (res instanceof Promise) {
|
|
263
|
-
res.catch((err) => {
|
|
264
|
-
console.warn("[useVirtualDataset] loadMore error:", err);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
283
|
+
if (dp && typeof dp.ensureRangeLoaded === "function") dp.ensureRangeLoaded(start, end);
|
|
268
284
|
const ps = effectivePageSize.value;
|
|
269
285
|
if (!ps || ps <= 0) return;
|
|
270
286
|
const startPage = Math.floor(start / ps) + 1;
|
|
271
287
|
const endPage = Math.floor(Math.max(0, end - 1) / ps) + 1;
|
|
272
|
-
for (let p = startPage; p <= endPage; p++)
|
|
273
|
-
queuePage(p);
|
|
274
|
-
}
|
|
288
|
+
for (let p = startPage; p <= endPage; p++) queuePage(p);
|
|
275
289
|
};
|
|
276
|
-
watch([startIndex, endIndex, () => datasetItems.value.length, dpBridge.stateVersion, () =>
|
|
277
|
-
ensureVisiblePagesLoaded();
|
|
290
|
+
watch([startIndex, endIndex, () => datasetItems.value.length, dpBridge.stateVersion, () => !!toValue(options.virtualScroll)], () => {
|
|
291
|
+
if (typeof window !== "undefined") ensureVisiblePagesLoaded();
|
|
278
292
|
}, { immediate: true });
|
|
279
293
|
const invalidateCache = () => {
|
|
280
294
|
cacheGeneration++;
|
|
281
|
-
|
|
295
|
+
dataVersion++;
|
|
282
296
|
requestedPages.clear();
|
|
283
297
|
pageQueue.length = 0;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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;
|
|
296
312
|
}
|
|
297
|
-
if (
|
|
298
|
-
|
|
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
|
+
}
|
|
299
322
|
}
|
|
300
|
-
|
|
301
|
-
watch([dpBridge.filter, dpBridge.sortList, dpBridge.filterSortVersion], () => {
|
|
302
|
-
invalidateCache();
|
|
303
|
-
});
|
|
304
|
-
watch(() => dpBridge.rawProvider, () => {
|
|
305
|
-
invalidateCache();
|
|
323
|
+
snapshot = buildSnapshot(dp);
|
|
306
324
|
});
|
|
325
|
+
watch([dpBridge.filter, dpBridge.sortList, dpBridge.filterSortVersion], () => invalidateCache());
|
|
326
|
+
watch(() => dpBridge.rawProvider, () => invalidateCache());
|
|
307
327
|
const displayRows = computed(() => {
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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;
|
|
323
357
|
}
|
|
324
|
-
|
|
325
|
-
|
|
358
|
+
}
|
|
359
|
+
result[i] = item;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (indexCache !== null && indexCache.has(absIdx)) {
|
|
363
|
+
result[i] = indexCache.get(absIdx);
|
|
364
|
+
continue;
|
|
326
365
|
}
|
|
327
|
-
|
|
366
|
+
result[i] = { __encrypted: true, __skeleton: true };
|
|
328
367
|
}
|
|
329
|
-
return
|
|
368
|
+
return result;
|
|
330
369
|
});
|
|
331
|
-
const isCellEncrypted = (val) =>
|
|
332
|
-
if (!val || typeof val !== "object") return false;
|
|
333
|
-
if (val.__encrypted === true) return true;
|
|
334
|
-
const cipher = dpBridge.rawProvider?.cipherProvider;
|
|
335
|
-
if (cipher && typeof cipher.isEncrypted === "function") {
|
|
336
|
-
return cipher.isEncrypted(val);
|
|
337
|
-
}
|
|
338
|
-
return typeof isEncrypted === "function" ? isEncrypted(val) : false;
|
|
339
|
-
};
|
|
370
|
+
const isCellEncrypted = (val) => detectEncryptedCellValue(val, dpBridge.rawProvider);
|
|
340
371
|
const selectedRows = options.selectedRows ?? ref([]);
|
|
341
372
|
const selectAll = options.selectAll ?? ref(false);
|
|
342
373
|
const unselectedRows = options.unselectedRows ?? ref([]);
|
|
343
374
|
const selectAllFilter = ref(null);
|
|
344
375
|
const effectiveSelectAllScope = computed(() => {
|
|
345
|
-
if (
|
|
346
|
-
if (
|
|
347
|
-
console.warn(
|
|
348
|
-
'[useVirtualDataset] virtualScroll is enabled with selectAllScope="page". Overriding selectAllScope to "dataset" because page-scoped selection is incompatible with virtual scrolling.'
|
|
349
|
-
);
|
|
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.');
|
|
350
379
|
}
|
|
351
380
|
return "dataset";
|
|
352
381
|
}
|
|
353
|
-
return
|
|
382
|
+
return toValue(options.selectAllScope) || "page";
|
|
354
383
|
});
|
|
355
384
|
const getRowKey = (row, index) => {
|
|
356
385
|
const idKey = rowIdKey.value;
|
|
357
|
-
if (row && row[idKey] !== void 0 && row[idKey] !== null)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
return row.id;
|
|
362
|
-
}
|
|
363
|
-
if (row && row._id !== void 0 && row._id !== null) {
|
|
364
|
-
return row._id;
|
|
365
|
-
}
|
|
366
|
-
return unref(options.virtualScroll) ? startIndex.value + index : index;
|
|
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;
|
|
367
390
|
};
|
|
368
|
-
const selectedRowIds = computed(() =>
|
|
369
|
-
|
|
370
|
-
const set = /* @__PURE__ */ new Set();
|
|
371
|
-
for (const r of selectedRows.value || []) {
|
|
372
|
-
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
373
|
-
set.add(id);
|
|
374
|
-
set.add(r);
|
|
375
|
-
}
|
|
376
|
-
return set;
|
|
377
|
-
});
|
|
378
|
-
const unselectedRowIds = computed(() => {
|
|
379
|
-
const idKey = rowIdKey.value;
|
|
380
|
-
const set = /* @__PURE__ */ new Set();
|
|
381
|
-
for (const r of unselectedRows.value || []) {
|
|
382
|
-
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
383
|
-
set.add(id);
|
|
384
|
-
set.add(r);
|
|
385
|
-
}
|
|
386
|
-
return set;
|
|
387
|
-
});
|
|
391
|
+
const selectedRowIds = computed(() => buildSelectionIdSet(selectedRows.value, rowIdKey.value));
|
|
392
|
+
const unselectedRowIds = computed(() => buildSelectionIdSet(unselectedRows.value, rowIdKey.value));
|
|
388
393
|
const isRowSelected = (row) => {
|
|
389
394
|
const idKey = rowIdKey.value;
|
|
390
395
|
const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row;
|
|
@@ -411,203 +416,170 @@ export function useVirtualDataset(options) {
|
|
|
411
416
|
const isAllSelected = computed(() => {
|
|
412
417
|
const total = datasetItems.value.length;
|
|
413
418
|
if (total === 0) return false;
|
|
414
|
-
if (effectiveSelectAllScope.value === "dataset") {
|
|
415
|
-
if (
|
|
416
|
-
|
|
417
|
-
return pageSelectedCount.value === total;
|
|
418
|
-
}
|
|
419
|
-
return unselectedRows.value.length === 0;
|
|
419
|
+
if (effectiveSelectAllScope.value === "dataset" && selectAll.value === true) {
|
|
420
|
+
if (selectAllFilter.value !== null && selectAllFilter.value !== JSON.stringify(activeFilter.value)) {
|
|
421
|
+
return pageSelectedCount.value === total;
|
|
420
422
|
}
|
|
421
|
-
return
|
|
423
|
+
return unselectedRows.value.length === 0;
|
|
422
424
|
}
|
|
423
425
|
return pageSelectedCount.value === total;
|
|
424
426
|
});
|
|
425
427
|
const isIndeterminate = computed(() => {
|
|
426
428
|
const total = datasetItems.value.length;
|
|
427
|
-
if (total === 0) return false;
|
|
428
|
-
if (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (selectAllFilter.value !== null && selectAllFilter.value !== JSON.stringify(activeFilter.value)) {
|
|
432
|
-
return pageSelectedCount.value > 0;
|
|
433
|
-
}
|
|
434
|
-
return unselectedRows.value.length > 0;
|
|
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;
|
|
435
433
|
}
|
|
436
|
-
return
|
|
434
|
+
return unselectedRows.value.length > 0;
|
|
437
435
|
}
|
|
438
436
|
return pageSelectedCount.value > 0 && pageSelectedCount.value < total;
|
|
439
437
|
});
|
|
440
438
|
const handleSelectAll = () => {
|
|
441
|
-
|
|
442
|
-
if (total === 0) return;
|
|
439
|
+
if (datasetItems.value.length === 0) return;
|
|
443
440
|
if (effectiveSelectAllScope.value === "dataset") {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
unselectedRows.value = [];
|
|
448
|
-
selectedRows.value = [];
|
|
449
|
-
} else {
|
|
450
|
-
selectAll.value = true;
|
|
451
|
-
selectAllFilter.value = JSON.stringify(activeFilter.value);
|
|
452
|
-
unselectedRows.value = [];
|
|
453
|
-
selectedRows.value = [];
|
|
454
|
-
}
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
const idKey = rowIdKey.value;
|
|
458
|
-
if (isAllSelected.value) {
|
|
459
|
-
const pageIdSet = new Set(
|
|
460
|
-
datasetItems.value.map((r) => r?.[idKey] ?? r?.id ?? r?._id ?? r)
|
|
461
|
-
);
|
|
462
|
-
selectedRows.value = (selectedRows.value || []).filter((r) => {
|
|
463
|
-
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
464
|
-
return !pageIdSet.has(id) && !pageIdSet.has(r);
|
|
465
|
-
});
|
|
466
|
-
unselectedRows.value = [];
|
|
467
|
-
selectAll.value = false;
|
|
468
|
-
} else {
|
|
469
|
-
const existingIds = selectedRowIds.value;
|
|
470
|
-
const toAdd = datasetItems.value.filter((r) => {
|
|
471
|
-
const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
472
|
-
return !existingIds.has(id) && !existingIds.has(r);
|
|
473
|
-
});
|
|
474
|
-
selectedRows.value = [...selectedRows.value || [], ...toAdd];
|
|
441
|
+
const nextAll = !isAllSelected.value;
|
|
442
|
+
selectAll.value = nextAll;
|
|
443
|
+
selectAllFilter.value = nextAll ? JSON.stringify(activeFilter.value) : null;
|
|
475
444
|
unselectedRows.value = [];
|
|
476
|
-
|
|
445
|
+
selectedRows.value = [];
|
|
446
|
+
return;
|
|
477
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;
|
|
478
458
|
};
|
|
479
459
|
const toggleRow = (row) => {
|
|
480
460
|
const idKey = rowIdKey.value;
|
|
481
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)]);
|
|
482
464
|
if (effectiveSelectAllScope.value === "dataset" && selectAll.value) {
|
|
483
|
-
|
|
484
|
-
if (isCurrentlyExcluded) {
|
|
465
|
+
if (unselectedRowIds.value.has(rowId) || unselectedRowIds.value.has(row)) {
|
|
485
466
|
unselectedRows.value = (unselectedRows.value || []).filter((r) => {
|
|
486
467
|
const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
487
|
-
return rId
|
|
468
|
+
return !branchIdSet.has(rId) && !branchIdSet.has(r);
|
|
488
469
|
});
|
|
489
470
|
} else {
|
|
490
|
-
|
|
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];
|
|
491
477
|
}
|
|
492
478
|
return;
|
|
493
479
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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) => {
|
|
497
483
|
const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
|
|
498
|
-
return rId
|
|
484
|
+
return !branchIdSet.has(rId) && !branchIdSet.has(r);
|
|
499
485
|
});
|
|
500
|
-
selectedRows.value = next;
|
|
501
486
|
} else {
|
|
502
|
-
|
|
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];
|
|
503
497
|
}
|
|
504
498
|
};
|
|
505
499
|
const focusedIndex = ref(-1);
|
|
506
500
|
const theadStickyOffset = options.theadStickyOffset ?? 40;
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return
|
|
515
|
-
};
|
|
516
|
-
const resolveItemH = () => {
|
|
517
|
-
if (containerRef.value) {
|
|
518
|
-
const rowEl = containerRef.value.querySelector('tbody tr, [role="row"]');
|
|
519
|
-
if (rowEl && rowEl.offsetHeight > 0) {
|
|
520
|
-
return rowEl.offsetHeight;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
const raw = unref(options.itemHeight);
|
|
524
|
-
if (typeof raw === "function") return 40;
|
|
525
|
-
return typeof raw === "number" && raw > 0 ? raw : 40;
|
|
526
|
-
};
|
|
527
|
-
const resolveVpH = () => {
|
|
528
|
-
if (containerRef.value && containerRef.value.clientHeight > 0) {
|
|
529
|
-
return containerRef.value.clientHeight;
|
|
530
|
-
}
|
|
531
|
-
if (viewportHeight.value > 0) {
|
|
532
|
-
return viewportHeight.value;
|
|
533
|
-
}
|
|
534
|
-
const v = options.viewportHeight ?? options.containerHeight;
|
|
535
|
-
if (typeof v === "function") return v() || 500;
|
|
536
|
-
const num = unref(v);
|
|
537
|
-
return typeof num === "number" && num > 0 ? num : 500;
|
|
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) };
|
|
538
509
|
};
|
|
539
510
|
const ensureVisible = (index) => {
|
|
540
511
|
const total = datasetItems.value.length;
|
|
541
512
|
if (total === 0) return;
|
|
542
|
-
const
|
|
543
|
-
const vpH =
|
|
544
|
-
|
|
545
|
-
|
|
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
|
+
}
|
|
546
526
|
if (rowTop < scrollTop.value) {
|
|
547
|
-
|
|
548
|
-
scrollToIndex(index, "auto", index > 0 ? offset : 0);
|
|
527
|
+
scrollToIndex(index, "auto", index > 0 ? resolveDomTheadOffset(containerRef.value, theadStickyOffset) : 0);
|
|
549
528
|
} else if (rowBottom > scrollTop.value + vpH) {
|
|
550
529
|
const targetScroll = Math.max(0, rowBottom - vpH);
|
|
551
530
|
scrollTop.value = targetScroll;
|
|
552
|
-
if (containerRef.value)
|
|
553
|
-
containerRef.value.scrollTop = targetScroll;
|
|
554
|
-
}
|
|
531
|
+
if (containerRef.value) containerRef.value.scrollTop = targetScroll;
|
|
555
532
|
}
|
|
556
533
|
};
|
|
557
534
|
const handleKeyDown = (e) => {
|
|
558
|
-
if (!
|
|
535
|
+
if (!toValue(options.virtualScroll)) return;
|
|
559
536
|
const total = datasetItems.value.length;
|
|
560
537
|
if (total === 0) return;
|
|
561
|
-
const
|
|
562
|
-
const vpH =
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
e.preventDefault();
|
|
583
|
-
const step = Math.max(1, Math.floor(vpH / itemH));
|
|
584
|
-
if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
|
|
585
|
-
focusedIndex.value = Math.min(total - 1, firstInView + step);
|
|
586
|
-
} else {
|
|
587
|
-
focusedIndex.value = Math.min(total - 1, focusedIndex.value + step);
|
|
588
|
-
}
|
|
589
|
-
ensureVisible(focusedIndex.value);
|
|
590
|
-
} else if (e.key === "PageUp") {
|
|
591
|
-
e.preventDefault();
|
|
592
|
-
const step = Math.max(1, Math.floor(vpH / itemH));
|
|
593
|
-
if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
|
|
594
|
-
focusedIndex.value = Math.max(0, lastInView - step);
|
|
595
|
-
} else {
|
|
596
|
-
focusedIndex.value = Math.max(0, focusedIndex.value - step);
|
|
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;
|
|
597
559
|
}
|
|
598
|
-
|
|
599
|
-
} else
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
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);
|
|
608
581
|
};
|
|
609
582
|
return {
|
|
610
|
-
// Virtual Scroll & Projection
|
|
611
583
|
datasetItems,
|
|
612
584
|
datatableItems: datasetItems,
|
|
613
585
|
displayRows,
|
|
@@ -623,12 +595,10 @@ export function useVirtualDataset(options) {
|
|
|
623
595
|
onScroll,
|
|
624
596
|
scrollToIndex,
|
|
625
597
|
containerCssVars,
|
|
626
|
-
// Delivered Rows Cache & Decryption
|
|
627
598
|
deliveredRowsCache,
|
|
628
599
|
invalidateCache,
|
|
629
600
|
ensureVisiblePagesLoaded,
|
|
630
601
|
isCellEncrypted,
|
|
631
|
-
// Selection Bridge
|
|
632
602
|
rowIdKey,
|
|
633
603
|
getRowKey,
|
|
634
604
|
selectedRows,
|
|
@@ -643,11 +613,9 @@ export function useVirtualDataset(options) {
|
|
|
643
613
|
isIndeterminate,
|
|
644
614
|
handleSelectAll,
|
|
645
615
|
toggleRow,
|
|
646
|
-
// Keyboard Navigation Bridge
|
|
647
616
|
focusedIndex,
|
|
648
617
|
handleKeyDown,
|
|
649
618
|
ensureVisible,
|
|
650
|
-
// Provider State Bridge (from useDataProvider)
|
|
651
619
|
get rawProvider() {
|
|
652
620
|
return dpBridge.rawProvider;
|
|
653
621
|
},
|