@katlux/toolkit 0.1.1-alpha.118 → 0.1.1-alpha.120
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/bin/create-preset.mjs +5 -4
- package/dist/compiled/composables/useDataProvider.mjs +20 -0
- package/dist/compiled/composables/useKatluxContext.mjs +6 -3
- package/dist/compiled/composables/useKatluxForm.mjs +311 -0
- package/dist/compiled/composables/useToast.mjs +164 -0
- package/dist/compiled/composables/useVirtualScroll.mjs +246 -0
- package/dist/module.cjs +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +6 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +3 -3
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +6 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -6
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +12 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -2
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +12 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +11 -0
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +4 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +11 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +6 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +22 -3
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +8 -0
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +10 -2
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +8 -0
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +8 -0
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +10 -2
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +8 -0
- package/dist/runtime/components/KDatatable/KDatatable.global.vue +12 -4
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +8 -0
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +8 -0
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +28 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +4 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +6 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +4 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +7 -6
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +7 -6
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +9 -0
- package/dist/runtime/components/KDropdown/KDropdown.global.vue +2 -1
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +9 -0
- package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +5 -0
- package/dist/runtime/components/KDropdown/KDropdown.logic.js +10 -7
- package/dist/runtime/components/KGantt/KGantt.logic.js +5 -3
- package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +2 -0
- package/dist/runtime/components/KPagination/KPagination.global.vue +1 -1
- package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +2 -0
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
- package/dist/runtime/components/KPagination/KPagination.logic.js +11 -3
- package/dist/runtime/components/KToast/KToast.global.d.vue.ts +24 -1
- package/dist/runtime/components/KToast/KToast.global.vue +12 -2
- package/dist/runtime/components/KToast/KToast.global.vue.d.ts +24 -1
- package/dist/runtime/components/KToast/KToast.logic.d.ts +13 -0
- package/dist/runtime/components/KToast/KToast.logic.js +45 -5
- package/dist/runtime/components/KToastContainer/KToastContainer.global.d.vue.ts +3 -0
- package/dist/runtime/components/KToastContainer/KToastContainer.global.vue +11 -0
- package/dist/runtime/components/KToastContainer/KToastContainer.global.vue.d.ts +3 -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/KTree/KTree.global.d.vue.ts +39 -1
- package/dist/runtime/components/KTree/KTree.global.vue +7 -4
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +39 -1
- package/dist/runtime/components/KTree/KTree.logic.d.ts +21 -0
- package/dist/runtime/components/KTree/KTree.logic.js +17 -0
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +53 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +30 -3
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +53 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +20 -0
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +16 -0
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +37 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue +5 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +37 -1
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +20 -0
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +16 -0
- package/dist/runtime/composables/useDataProvider.d.ts +1 -0
- package/dist/runtime/composables/useDataProvider.js +20 -0
- package/dist/runtime/composables/useKatluxContext.js +6 -3
- package/dist/runtime/composables/useKatluxForm.d.ts +145 -0
- package/dist/runtime/composables/useKatluxForm.js +311 -0
- package/dist/runtime/composables/useToast.d.ts +49 -0
- package/dist/runtime/composables/useToast.js +164 -0
- package/dist/runtime/composables/useVirtualScroll.d.ts +34 -0
- package/dist/runtime/composables/useVirtualScroll.js +246 -0
- package/dist/runtime/plugins/PresetPlugin.js +9 -1
- package/dist/runtime/plugins/nuxtCompatPlugin.js +0 -1
- package/dist/runtime/plugins/toastPlugin.client.d.ts +2 -0
- package/dist/runtime/plugins/toastPlugin.client.js +16 -0
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +1 -0
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +43 -7
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +12 -4
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +7 -2
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +143 -7
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +228 -32
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +12 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -1
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +23 -2
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +6 -1
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue +37 -3
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
- package/dist/runtime/presets/default/components/KModal/KModal.vue +8 -1
- package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +1 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +6 -4
- package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +6 -0
- package/dist/runtime/presets/default/components/KToast/KToast.vue +21 -4
- package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +6 -0
- package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.d.vue.ts +11 -0
- package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +206 -0
- package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue.d.ts +11 -0
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +15 -6
- package/dist/runtime/presets/default/components/KTree/KTree.vue +235 -14
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +15 -6
- package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.d.vue.ts +14 -1
- package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +118 -13
- package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue.d.ts +14 -1
- package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +12 -3
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +4 -0
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +8 -0
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +4 -0
- package/dist/runtime/server/middleware/session.js +1 -1
- package/package.json +3 -4
- package/dist/compiled/composables/useDataProvider.spec.mjs +0 -157
- package/dist/compiled/composables/useKatluxContext.spec.mjs +0 -63
- package/dist/compiled/composables/useKatluxI18n.spec.mjs +0 -10
- package/dist/compiled/composables/usePresetComponent.spec.mjs +0 -106
- package/dist/compiled/composables/useTemplate.spec.mjs +0 -30
- package/dist/compiled/utils/PresetResolver.spec.mjs +0 -68
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { ref, computed, unref, watch, getCurrentScope, onScopeDispose } from "vue";
|
|
2
|
+
export function useVirtualScroll(options) {
|
|
3
|
+
const containerRef = ref(null);
|
|
4
|
+
const scrollTop = ref(0);
|
|
5
|
+
const resolveItems = () => {
|
|
6
|
+
if (typeof options.items === "function") {
|
|
7
|
+
return options.items();
|
|
8
|
+
}
|
|
9
|
+
return unref(options.items) || [];
|
|
10
|
+
};
|
|
11
|
+
const allItems = computed(() => resolveItems());
|
|
12
|
+
const totalCount = computed(() => allItems.value.length);
|
|
13
|
+
const isVirtual = computed(() => {
|
|
14
|
+
if (options.virtualScroll === void 0) return false;
|
|
15
|
+
return unref(options.virtualScroll) === true;
|
|
16
|
+
});
|
|
17
|
+
const colCount = computed(() => {
|
|
18
|
+
const c = unref(options.columns);
|
|
19
|
+
return typeof c === "number" && c > 1 ? c : 1;
|
|
20
|
+
});
|
|
21
|
+
const buf = computed(() => {
|
|
22
|
+
const b = unref(options.buffer);
|
|
23
|
+
return typeof b === "number" ? b : 5;
|
|
24
|
+
});
|
|
25
|
+
const defaultHeight = 40;
|
|
26
|
+
const getItemHeight = (item, index) => {
|
|
27
|
+
if (typeof options.itemHeight === "function") {
|
|
28
|
+
return options.itemHeight(item, index);
|
|
29
|
+
}
|
|
30
|
+
const h = unref(options.itemHeight);
|
|
31
|
+
return typeof h === "number" && h > 0 ? h : defaultHeight;
|
|
32
|
+
};
|
|
33
|
+
const baseItemHeight = computed(() => {
|
|
34
|
+
const h = unref(options.itemHeight);
|
|
35
|
+
if (typeof h === "number" && h > 0) return h;
|
|
36
|
+
return defaultHeight;
|
|
37
|
+
});
|
|
38
|
+
const resolveContainerHeight = () => {
|
|
39
|
+
if (typeof options.containerHeight === "function") {
|
|
40
|
+
return options.containerHeight() || 400;
|
|
41
|
+
}
|
|
42
|
+
const val = unref(options.containerHeight);
|
|
43
|
+
return typeof val === "number" && val > 0 ? val : 400;
|
|
44
|
+
};
|
|
45
|
+
const configuredContainerHeight = computed(() => resolveContainerHeight());
|
|
46
|
+
const viewportHeight = ref(resolveContainerHeight());
|
|
47
|
+
watch(
|
|
48
|
+
() => resolveContainerHeight(),
|
|
49
|
+
(newH) => {
|
|
50
|
+
if (typeof newH === "number" && newH > 0) {
|
|
51
|
+
viewportHeight.value = newH;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
|
|
56
|
+
if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
|
|
57
|
+
if (oldEl && oldEl.__vsObserver) {
|
|
58
|
+
oldEl.__vsObserver.disconnect();
|
|
59
|
+
delete oldEl.__vsObserver;
|
|
60
|
+
}
|
|
61
|
+
if (el && virtual) {
|
|
62
|
+
const ro = new ResizeObserver((entries) => {
|
|
63
|
+
for (const entry of entries) {
|
|
64
|
+
const h = Math.round(entry.contentRect.height || el.clientHeight);
|
|
65
|
+
if (h > 0 && h !== viewportHeight.value) {
|
|
66
|
+
viewportHeight.value = h;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
ro.observe(el);
|
|
71
|
+
el.__vsObserver = ro;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (getCurrentScope()) {
|
|
75
|
+
onScopeDispose(() => {
|
|
76
|
+
if (containerRef.value && containerRef.value.__vsObserver) {
|
|
77
|
+
containerRef.value.__vsObserver.disconnect();
|
|
78
|
+
delete containerRef.value.__vsObserver;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const isDynamicHeight = computed(() => typeof options.itemHeight === "function");
|
|
83
|
+
const rowOffsets = computed(() => {
|
|
84
|
+
if (!isDynamicHeight.value || colCount.value > 1) return [];
|
|
85
|
+
const items = allItems.value;
|
|
86
|
+
const offsets = new Array(items.length + 1);
|
|
87
|
+
offsets[0] = 0;
|
|
88
|
+
let current = 0;
|
|
89
|
+
for (let i = 0; i < items.length; i++) {
|
|
90
|
+
current += getItemHeight(items[i], i);
|
|
91
|
+
offsets[i + 1] = current;
|
|
92
|
+
}
|
|
93
|
+
return offsets;
|
|
94
|
+
});
|
|
95
|
+
const totalRows = computed(() => {
|
|
96
|
+
if (colCount.value <= 1) return totalCount.value;
|
|
97
|
+
return Math.ceil(totalCount.value / colCount.value);
|
|
98
|
+
});
|
|
99
|
+
const startRowIndex = computed(() => {
|
|
100
|
+
if (!isVirtual.value) return 0;
|
|
101
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
102
|
+
const offsets = rowOffsets.value;
|
|
103
|
+
const top = Math.max(0, scrollTop.value);
|
|
104
|
+
let low = 0;
|
|
105
|
+
let high = totalRows.value - 1;
|
|
106
|
+
let idx = 0;
|
|
107
|
+
while (low <= high) {
|
|
108
|
+
const mid = low + high >> 1;
|
|
109
|
+
if (offsets[mid + 1] > top) {
|
|
110
|
+
idx = mid;
|
|
111
|
+
high = mid - 1;
|
|
112
|
+
} else {
|
|
113
|
+
low = mid + 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return Math.max(0, idx - buf.value);
|
|
117
|
+
}
|
|
118
|
+
const rawRow = Math.floor(scrollTop.value / baseItemHeight.value);
|
|
119
|
+
return Math.max(0, rawRow - buf.value);
|
|
120
|
+
});
|
|
121
|
+
const visibleRowsCount = computed(() => {
|
|
122
|
+
if (!isVirtual.value) return totalRows.value;
|
|
123
|
+
const rowsInView = Math.ceil(viewportHeight.value / baseItemHeight.value);
|
|
124
|
+
return rowsInView + 2 * buf.value + 1;
|
|
125
|
+
});
|
|
126
|
+
const endRowIndex = computed(() => {
|
|
127
|
+
if (!isVirtual.value) return totalRows.value;
|
|
128
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
129
|
+
const offsets = rowOffsets.value;
|
|
130
|
+
const bottom = scrollTop.value + viewportHeight.value;
|
|
131
|
+
let low = startRowIndex.value;
|
|
132
|
+
let high = totalRows.value - 1;
|
|
133
|
+
let idx = totalRows.value;
|
|
134
|
+
while (low <= high) {
|
|
135
|
+
const mid = low + high >> 1;
|
|
136
|
+
if (offsets[mid] >= bottom) {
|
|
137
|
+
idx = mid;
|
|
138
|
+
high = mid - 1;
|
|
139
|
+
} else {
|
|
140
|
+
low = mid + 1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return Math.min(totalRows.value, idx + buf.value);
|
|
144
|
+
}
|
|
145
|
+
return Math.min(totalRows.value, startRowIndex.value + visibleRowsCount.value);
|
|
146
|
+
});
|
|
147
|
+
const startIndex = computed(() => {
|
|
148
|
+
if (!isVirtual.value) return 0;
|
|
149
|
+
return Math.max(0, startRowIndex.value * colCount.value);
|
|
150
|
+
});
|
|
151
|
+
const endIndex = computed(() => {
|
|
152
|
+
if (!isVirtual.value) return totalCount.value;
|
|
153
|
+
return Math.min(totalCount.value, endRowIndex.value * colCount.value);
|
|
154
|
+
});
|
|
155
|
+
const visibleItems = computed(() => {
|
|
156
|
+
if (!isVirtual.value) return allItems.value;
|
|
157
|
+
return allItems.value.slice(startIndex.value, endIndex.value);
|
|
158
|
+
});
|
|
159
|
+
const topSpacerHeight = computed(() => {
|
|
160
|
+
if (!isVirtual.value) return 0;
|
|
161
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
162
|
+
return rowOffsets.value[startRowIndex.value] || 0;
|
|
163
|
+
}
|
|
164
|
+
return Math.max(0, startRowIndex.value * baseItemHeight.value);
|
|
165
|
+
});
|
|
166
|
+
const totalHeight = computed(() => {
|
|
167
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
168
|
+
const offsets = rowOffsets.value;
|
|
169
|
+
return offsets.length > 0 ? offsets[offsets.length - 1] : 0;
|
|
170
|
+
}
|
|
171
|
+
return totalRows.value * baseItemHeight.value;
|
|
172
|
+
});
|
|
173
|
+
const bottomSpacerHeight = computed(() => {
|
|
174
|
+
if (!isVirtual.value) return 0;
|
|
175
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
176
|
+
const endOffset = rowOffsets.value[endRowIndex.value] || totalHeight.value;
|
|
177
|
+
return Math.max(0, totalHeight.value - endOffset);
|
|
178
|
+
}
|
|
179
|
+
const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
|
|
180
|
+
return remainingRows * baseItemHeight.value;
|
|
181
|
+
});
|
|
182
|
+
watch(totalHeight, (newTotal) => {
|
|
183
|
+
if (scrollTop.value > newTotal) {
|
|
184
|
+
scrollTop.value = Math.max(0, newTotal - viewportHeight.value);
|
|
185
|
+
if (containerRef.value) {
|
|
186
|
+
containerRef.value.scrollTop = scrollTop.value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const containerCssVars = computed(() => ({
|
|
191
|
+
"--virtual-spacer-top": `${topSpacerHeight.value}px`,
|
|
192
|
+
"--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
|
|
193
|
+
"--virtual-total-height": `${totalHeight.value}px`,
|
|
194
|
+
"--virtual-item-height": `${baseItemHeight.value}px`,
|
|
195
|
+
"--virtual-container-height": `${configuredContainerHeight.value}px`
|
|
196
|
+
}));
|
|
197
|
+
const scrollThreshold = options.scrollThreshold ?? 100;
|
|
198
|
+
const onScroll = (e) => {
|
|
199
|
+
const target = e.target;
|
|
200
|
+
if (!target) return;
|
|
201
|
+
scrollTop.value = target.scrollTop;
|
|
202
|
+
if (target.clientHeight && target.clientHeight !== viewportHeight.value) {
|
|
203
|
+
viewportHeight.value = target.clientHeight;
|
|
204
|
+
}
|
|
205
|
+
const distanceToBottom = target.scrollHeight - (target.scrollTop + target.clientHeight);
|
|
206
|
+
if (distanceToBottom <= scrollThreshold && typeof options.onThresholdReach === "function") {
|
|
207
|
+
options.onThresholdReach();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const scrollToIndex = (index, behavior = "auto", offset = 0) => {
|
|
211
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
212
|
+
const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
|
|
213
|
+
scrollTop.value = targetScrollTop2;
|
|
214
|
+
if (containerRef.value) {
|
|
215
|
+
containerRef.value.scrollTo({
|
|
216
|
+
top: targetScrollTop2,
|
|
217
|
+
behavior
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
|
|
223
|
+
const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
|
|
224
|
+
scrollTop.value = targetScrollTop;
|
|
225
|
+
if (containerRef.value) {
|
|
226
|
+
containerRef.value.scrollTo({
|
|
227
|
+
top: targetScrollTop,
|
|
228
|
+
behavior
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
return {
|
|
233
|
+
startIndex,
|
|
234
|
+
endIndex,
|
|
235
|
+
visibleItems,
|
|
236
|
+
topSpacerHeight,
|
|
237
|
+
bottomSpacerHeight,
|
|
238
|
+
totalHeight,
|
|
239
|
+
scrollTop,
|
|
240
|
+
viewportHeight,
|
|
241
|
+
containerRef,
|
|
242
|
+
onScroll,
|
|
243
|
+
scrollToIndex,
|
|
244
|
+
containerCssVars
|
|
245
|
+
};
|
|
246
|
+
}
|
package/dist/module.cjs
CHANGED
|
@@ -42,6 +42,7 @@ const module$1 = kit.defineNuxtModule({
|
|
|
42
42
|
kit.addPlugin(resolve("./runtime/plugins/registerDirectives"));
|
|
43
43
|
kit.addPlugin(resolve("./runtime/plugins/PresetPlugin"));
|
|
44
44
|
kit.addPlugin(resolve("./runtime/plugins/nuxtCompatPlugin"));
|
|
45
|
+
kit.addPlugin(resolve("./runtime/plugins/toastPlugin.client"));
|
|
45
46
|
kit.addServerHandler({
|
|
46
47
|
handler: resolve("./runtime/server/middleware/session")
|
|
47
48
|
});
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -39,6 +39,7 @@ const module$1 = defineNuxtModule({
|
|
|
39
39
|
addPlugin(resolve("./runtime/plugins/registerDirectives"));
|
|
40
40
|
addPlugin(resolve("./runtime/plugins/PresetPlugin"));
|
|
41
41
|
addPlugin(resolve("./runtime/plugins/nuxtCompatPlugin"));
|
|
42
|
+
addPlugin(resolve("./runtime/plugins/toastPlugin.client"));
|
|
42
43
|
addServerHandler({
|
|
43
44
|
handler: resolve("./runtime/server/middleware/session")
|
|
44
45
|
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { IKDatatableAction, TDataRow } from '@katlux/providers';
|
|
2
2
|
interface Props {
|
|
3
|
+
bulkActions?: IKDatatableAction[];
|
|
4
|
+
selectedRows?: TDataRow[];
|
|
5
|
+
selectAll?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
3
8
|
bulkActions: IKDatatableAction[];
|
|
4
9
|
selectedRows: TDataRow[];
|
|
5
10
|
selectAll: boolean;
|
|
6
|
-
}
|
|
7
|
-
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
12
|
declare const _default: typeof __VLS_export;
|
|
9
13
|
export default _default;
|
|
@@ -4,9 +4,9 @@ import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
|
4
4
|
import { computed } from "vue";
|
|
5
5
|
import KBulkActionsDefault from "../../presets/default/components/KBulkActions/KBulkActions.vue";
|
|
6
6
|
const props = defineProps({
|
|
7
|
-
bulkActions: { type: Array, required:
|
|
8
|
-
selectedRows: { type: Array, required:
|
|
9
|
-
selectAll: { type: Boolean, required:
|
|
7
|
+
bulkActions: { type: Array, required: false, default: () => [] },
|
|
8
|
+
selectedRows: { type: Array, required: false, default: () => [] },
|
|
9
|
+
selectAll: { type: Boolean, required: false, default: false }
|
|
10
10
|
});
|
|
11
11
|
const { selected, dp, doAction, visibleBulkActions } = useKBulkActionsLogic(props);
|
|
12
12
|
const presetComponent = usePresetComponent("KBulkActions", KBulkActionsDefault);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { IKDatatableAction, TDataRow } from '@katlux/providers';
|
|
2
2
|
interface Props {
|
|
3
|
+
bulkActions?: IKDatatableAction[];
|
|
4
|
+
selectedRows?: TDataRow[];
|
|
5
|
+
selectAll?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
3
8
|
bulkActions: IKDatatableAction[];
|
|
4
9
|
selectedRows: TDataRow[];
|
|
5
10
|
selectAll: boolean;
|
|
6
|
-
}
|
|
7
|
-
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
12
|
declare const _default: typeof __VLS_export;
|
|
9
13
|
export default _default;
|
|
@@ -8,14 +8,29 @@ export function getApplicableRows(action, selectedRows, selectAll) {
|
|
|
8
8
|
if (!selectedRows || selectedRows.length === 0) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
+
const isBulkAction = action.isBulk || action.bulk || typeof action.visible === "function" && action.visible.length >= 2;
|
|
12
|
+
if (isBulkAction) {
|
|
13
|
+
try {
|
|
14
|
+
const isVisible = action.visible(selectedRows, selectAll);
|
|
15
|
+
return isVisible ? selectedRows : [];
|
|
16
|
+
} catch {
|
|
17
|
+
return selectedRows;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
let isPerRowPredicate = false;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
if (typeof action.visible === "function") {
|
|
22
|
+
try {
|
|
23
|
+
const arrayResult = action.visible(selectedRows);
|
|
24
|
+
const singleResult = action.visible(selectedRows[0]);
|
|
25
|
+
if (typeof arrayResult === "boolean" && typeof singleResult !== "boolean") {
|
|
26
|
+
return arrayResult ? selectedRows : [];
|
|
27
|
+
}
|
|
28
|
+
if (typeof singleResult === "boolean") {
|
|
29
|
+
isPerRowPredicate = true;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
isPerRowPredicate = false;
|
|
16
33
|
}
|
|
17
|
-
} catch {
|
|
18
|
-
isPerRowPredicate = false;
|
|
19
34
|
}
|
|
20
35
|
if (isPerRowPredicate) {
|
|
21
36
|
return selectedRows.filter((row) => {
|
|
@@ -21,11 +21,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
21
21
|
type: StringConstructor;
|
|
22
22
|
default: string;
|
|
23
23
|
};
|
|
24
|
+
idKey: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: undefined;
|
|
27
|
+
};
|
|
24
28
|
modelValue: {
|
|
25
29
|
type: import("vue").PropType<any>;
|
|
26
30
|
};
|
|
27
31
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
28
32
|
"update:modelValue": (value: any) => any;
|
|
33
|
+
} & {
|
|
34
|
+
blur: (event: FocusEvent) => any;
|
|
29
35
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
30
36
|
disabled: {
|
|
31
37
|
type: BooleanConstructor;
|
|
@@ -48,16 +54,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
48
54
|
type: StringConstructor;
|
|
49
55
|
default: string;
|
|
50
56
|
};
|
|
57
|
+
idKey: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
51
61
|
modelValue: {
|
|
52
62
|
type: import("vue").PropType<any>;
|
|
53
63
|
};
|
|
54
64
|
}>> & Readonly<{
|
|
55
65
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
66
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
56
67
|
}>, {
|
|
57
68
|
label: string;
|
|
58
69
|
disabled: boolean;
|
|
59
70
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
60
71
|
validationText: string;
|
|
72
|
+
idKey: string;
|
|
61
73
|
value: any;
|
|
62
74
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
63
75
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,18 +7,20 @@ const props = defineProps(KCheckboxDefaultProps);
|
|
|
7
7
|
const model = defineModel();
|
|
8
8
|
const { isDisabled, checkboxValue } = useKCheckboxLogic(props, model);
|
|
9
9
|
const presetComponent = usePresetComponent("KCheckbox", KCheckboxDefault);
|
|
10
|
+
defineEmits(["blur"]);
|
|
10
11
|
const templateProps = computed(() => ({
|
|
11
12
|
model: model.value,
|
|
12
13
|
checkboxValue: checkboxValue.value,
|
|
13
14
|
isDisabled: isDisabled.value,
|
|
14
15
|
validation: props.validation,
|
|
15
16
|
validationText: props.validationText,
|
|
16
|
-
label: props.label
|
|
17
|
+
label: props.label,
|
|
18
|
+
idKey: props.idKey
|
|
17
19
|
}));
|
|
18
20
|
</script>
|
|
19
21
|
|
|
20
22
|
<template lang="pug">
|
|
21
|
-
component(:is="presetComponent" v-bind="templateProps" @update:model="model = $event")
|
|
23
|
+
component(:is="presetComponent" v-bind="templateProps" @update:model="model = $event" @blur="$emit('blur', $event)")
|
|
22
24
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
23
25
|
slot(:name="slot" v-bind="scope")
|
|
24
26
|
</template>
|
|
@@ -21,11 +21,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
21
21
|
type: StringConstructor;
|
|
22
22
|
default: string;
|
|
23
23
|
};
|
|
24
|
+
idKey: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: undefined;
|
|
27
|
+
};
|
|
24
28
|
modelValue: {
|
|
25
29
|
type: import("vue").PropType<any>;
|
|
26
30
|
};
|
|
27
31
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
28
32
|
"update:modelValue": (value: any) => any;
|
|
33
|
+
} & {
|
|
34
|
+
blur: (event: FocusEvent) => any;
|
|
29
35
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
30
36
|
disabled: {
|
|
31
37
|
type: BooleanConstructor;
|
|
@@ -48,16 +54,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
48
54
|
type: StringConstructor;
|
|
49
55
|
default: string;
|
|
50
56
|
};
|
|
57
|
+
idKey: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
51
61
|
modelValue: {
|
|
52
62
|
type: import("vue").PropType<any>;
|
|
53
63
|
};
|
|
54
64
|
}>> & Readonly<{
|
|
55
65
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
66
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
56
67
|
}>, {
|
|
57
68
|
label: string;
|
|
58
69
|
disabled: boolean;
|
|
59
70
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
60
71
|
validationText: string;
|
|
72
|
+
idKey: string;
|
|
61
73
|
value: any;
|
|
62
74
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
63
75
|
declare const _default: typeof __VLS_export;
|
|
@@ -5,6 +5,7 @@ export interface KCheckboxProps {
|
|
|
5
5
|
validation?: 'success' | 'warning' | 'error' | null;
|
|
6
6
|
validationText?: string;
|
|
7
7
|
label?: string;
|
|
8
|
+
idKey?: string;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* KCheckbox Logic Composable
|
|
@@ -42,4 +43,8 @@ export declare const KCheckboxDefaultProps: {
|
|
|
42
43
|
type: StringConstructor;
|
|
43
44
|
default: string;
|
|
44
45
|
};
|
|
46
|
+
idKey: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: undefined;
|
|
49
|
+
};
|
|
45
50
|
};
|
|
@@ -89,6 +89,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
89
89
|
type: NumberConstructor;
|
|
90
90
|
default: number;
|
|
91
91
|
};
|
|
92
|
+
maxHeight: {
|
|
93
|
+
type: NumberConstructor;
|
|
94
|
+
default: undefined;
|
|
95
|
+
};
|
|
92
96
|
}>, {
|
|
93
97
|
virtualScrollState: import("vue").ComputedRef<{
|
|
94
98
|
loadedCount: number;
|
|
@@ -103,6 +107,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
103
107
|
closeDropdown: () => void;
|
|
104
108
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
105
109
|
"update:modelValue": (value: any) => any;
|
|
110
|
+
blur: (event: FocusEvent) => any;
|
|
106
111
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
107
112
|
"update:searchtext": (value: string) => any;
|
|
108
113
|
"scroll-state-change": (state: {
|
|
@@ -201,8 +206,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
201
206
|
type: NumberConstructor;
|
|
202
207
|
default: number;
|
|
203
208
|
};
|
|
209
|
+
maxHeight: {
|
|
210
|
+
type: NumberConstructor;
|
|
211
|
+
default: undefined;
|
|
212
|
+
};
|
|
204
213
|
}>> & Readonly<{
|
|
205
214
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
215
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
206
216
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
207
217
|
"onUpdate:searchtext"?: ((value: string) => any) | undefined;
|
|
208
218
|
"onScroll-state-change"?: ((state: {
|
|
@@ -227,6 +237,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
227
237
|
placeholder: string;
|
|
228
238
|
teleportTo: string;
|
|
229
239
|
fullWidth: boolean;
|
|
240
|
+
maxHeight: number;
|
|
230
241
|
closeOnSelect: boolean;
|
|
231
242
|
multiSelect: boolean;
|
|
232
243
|
maxSelectedDisplay: string | number | boolean;
|
|
@@ -4,7 +4,7 @@ import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
|
4
4
|
import { computed, watch } from "vue";
|
|
5
5
|
import KComboboxDefault from "../../presets/default/components/KCombobox/KCombobox.vue";
|
|
6
6
|
const props = defineProps(KComboboxDefaultProps);
|
|
7
|
-
const emit = defineEmits(["update:modelValue", "update:isOptionsOpen", "update:searchtext", "scroll-state-change"]);
|
|
7
|
+
const emit = defineEmits(["update:modelValue", "update:isOptionsOpen", "update:searchtext", "scroll-state-change", "blur"]);
|
|
8
8
|
const {
|
|
9
9
|
selectedItems,
|
|
10
10
|
isOptionsOpen,
|
|
@@ -67,7 +67,8 @@ const templateProps = computed(() => ({
|
|
|
67
67
|
valueField: props.valueField,
|
|
68
68
|
validation: props.validation,
|
|
69
69
|
validationText: props.validationText,
|
|
70
|
-
fullWidth: props.fullWidth
|
|
70
|
+
fullWidth: props.fullWidth,
|
|
71
|
+
maxHeight: props.maxHeight
|
|
71
72
|
}));
|
|
72
73
|
function updateSearchText(val) {
|
|
73
74
|
searchtext.value = val;
|
|
@@ -78,7 +79,7 @@ function updateIsOptionsOpen(val) {
|
|
|
78
79
|
</script>
|
|
79
80
|
|
|
80
81
|
<template lang="pug">
|
|
81
|
-
component(:is="presetComponent" v-bind="{...templateProps, ...$attrs}" @update:searchtext="updateSearchText" @update:isOptionsOpen="updateIsOptionsOpen")
|
|
82
|
+
component(:is="presetComponent" v-bind="{...templateProps, ...$attrs}" @update:searchtext="updateSearchText" @update:isOptionsOpen="updateIsOptionsOpen" @blur="emit('blur', $event)")
|
|
82
83
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
83
84
|
slot(:name="slot" v-bind="scope")
|
|
84
85
|
</template>
|
|
@@ -89,6 +89,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
89
89
|
type: NumberConstructor;
|
|
90
90
|
default: number;
|
|
91
91
|
};
|
|
92
|
+
maxHeight: {
|
|
93
|
+
type: NumberConstructor;
|
|
94
|
+
default: undefined;
|
|
95
|
+
};
|
|
92
96
|
}>, {
|
|
93
97
|
virtualScrollState: import("vue").ComputedRef<{
|
|
94
98
|
loadedCount: number;
|
|
@@ -103,6 +107,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
103
107
|
closeDropdown: () => void;
|
|
104
108
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
105
109
|
"update:modelValue": (value: any) => any;
|
|
110
|
+
blur: (event: FocusEvent) => any;
|
|
106
111
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
107
112
|
"update:searchtext": (value: string) => any;
|
|
108
113
|
"scroll-state-change": (state: {
|
|
@@ -201,8 +206,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
201
206
|
type: NumberConstructor;
|
|
202
207
|
default: number;
|
|
203
208
|
};
|
|
209
|
+
maxHeight: {
|
|
210
|
+
type: NumberConstructor;
|
|
211
|
+
default: undefined;
|
|
212
|
+
};
|
|
204
213
|
}>> & Readonly<{
|
|
205
214
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
215
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
206
216
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
207
217
|
"onUpdate:searchtext"?: ((value: string) => any) | undefined;
|
|
208
218
|
"onScroll-state-change"?: ((state: {
|
|
@@ -227,6 +237,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
227
237
|
placeholder: string;
|
|
228
238
|
teleportTo: string;
|
|
229
239
|
fullWidth: boolean;
|
|
240
|
+
maxHeight: number;
|
|
230
241
|
closeOnSelect: boolean;
|
|
231
242
|
multiSelect: boolean;
|
|
232
243
|
maxSelectedDisplay: string | number | boolean;
|
|
@@ -25,6 +25,7 @@ export interface KComboboxProps {
|
|
|
25
25
|
virtualScroll?: boolean;
|
|
26
26
|
itemHeight?: number;
|
|
27
27
|
buffer?: number;
|
|
28
|
+
maxHeight?: number;
|
|
28
29
|
}
|
|
29
30
|
export interface KComboboxEmits {
|
|
30
31
|
(e: 'update:modelValue', value: any): void;
|
|
@@ -36,6 +37,7 @@ export interface KComboboxEmits {
|
|
|
36
37
|
lastAppendedPage: number;
|
|
37
38
|
totalCount: number;
|
|
38
39
|
}): void;
|
|
40
|
+
(e: 'blur', event: FocusEvent): void;
|
|
39
41
|
}
|
|
40
42
|
export declare const KComboboxDefaultProps: {
|
|
41
43
|
label: {
|
|
@@ -127,6 +129,10 @@ export declare const KComboboxDefaultProps: {
|
|
|
127
129
|
type: NumberConstructor;
|
|
128
130
|
default: number;
|
|
129
131
|
};
|
|
132
|
+
maxHeight: {
|
|
133
|
+
type: NumberConstructor;
|
|
134
|
+
default: undefined;
|
|
135
|
+
};
|
|
130
136
|
};
|
|
131
137
|
export declare function useKComboboxLogic(props: KComboboxProps, emit: KComboboxEmits): {
|
|
132
138
|
selectedItems: import("vue").Ref<TDataRow[] | null, TDataRow[] | null>;
|