@katlux/toolkit 0.1.1-alpha.119 → 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/dist/compiled/composables/useDataProvider.mjs +20 -0
- package/dist/compiled/composables/useKatluxForm.mjs +55 -12
- package/dist/compiled/composables/useVirtualScroll.mjs +78 -8
- package/dist/module.json +1 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +13 -7
- 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 +2 -0
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -0
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +17 -2
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +2 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -0
- package/dist/runtime/components/KGantt/KGantt.logic.js +1 -6
- 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 +6 -1
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue +0 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +1 -1
- package/dist/runtime/composables/useDataProvider.d.ts +1 -0
- package/dist/runtime/composables/useDataProvider.js +20 -0
- package/dist/runtime/composables/useKatluxForm.d.ts +2 -0
- package/dist/runtime/composables/useKatluxForm.js +55 -12
- package/dist/runtime/composables/useVirtualScroll.d.ts +1 -1
- package/dist/runtime/composables/useVirtualScroll.js +78 -8
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +7 -0
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +2 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +20 -6
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +29 -12
- 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/KLayout/KLayout.d.vue.ts +6 -1
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue +37 -5
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
- package/dist/runtime/presets/default/components/KToast/KToast.vue +0 -1
- package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +0 -1
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +2 -3
- package/dist/runtime/presets/default/components/KTree/KTree.vue +7 -5
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +2 -3
- package/package.json +2 -2
|
@@ -15,6 +15,22 @@ export function useDataProvider(provider, options) {
|
|
|
15
15
|
const pageData = shallowRef(
|
|
16
16
|
activeProvider ? activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []) : []
|
|
17
17
|
);
|
|
18
|
+
const getFullData = () => {
|
|
19
|
+
if (!activeProvider) return [];
|
|
20
|
+
if (Array.isArray(activeProvider.allVisibleRows) && activeProvider.allVisibleRows.length > 0) return activeProvider.allVisibleRows;
|
|
21
|
+
if (Array.isArray(activeProvider.allVisibleRows?.value) && activeProvider.allVisibleRows.value.length > 0) return activeProvider.allVisibleRows.value;
|
|
22
|
+
if (Array.isArray(activeProvider.rowMap) && activeProvider.rowMap.length > 0) return activeProvider.rowMap;
|
|
23
|
+
if (Array.isArray(activeProvider.rowMap?.value) && activeProvider.rowMap.value.length > 0) return activeProvider.rowMap.value;
|
|
24
|
+
if (Array.isArray(activeProvider.allVisibleNodes) && activeProvider.allVisibleNodes.length > 0) return activeProvider.allVisibleNodes;
|
|
25
|
+
if (Array.isArray(activeProvider.allVisibleNodes?.value) && activeProvider.allVisibleNodes.value.length > 0) return activeProvider.allVisibleNodes.value;
|
|
26
|
+
if (Array.isArray(activeProvider.allData) && activeProvider.allData.length > 0) return activeProvider.allData;
|
|
27
|
+
if (Array.isArray(activeProvider.allData?.value) && activeProvider.allData.value.length > 0) return activeProvider.allData.value;
|
|
28
|
+
if (Array.isArray(activeProvider.data) && activeProvider.data.length > 0) return activeProvider.data;
|
|
29
|
+
if (Array.isArray(activeProvider.rowMap)) return activeProvider.rowMap;
|
|
30
|
+
if (Array.isArray(activeProvider.allVisibleRows)) return activeProvider.allVisibleRows;
|
|
31
|
+
return pageData.value;
|
|
32
|
+
};
|
|
33
|
+
const virtualRows = shallowRef(activeProvider ? getFullData() : []);
|
|
18
34
|
const rowCount = ref(activeProvider ? extractVal(activeProvider.rowCount, 0) : 0);
|
|
19
35
|
const currentPage = options?.currentPage || ref(activeProvider ? extractVal(activeProvider.currentPage, 1) : 1);
|
|
20
36
|
const pageSize = options?.pageSize || ref(activeProvider ? extractVal(activeProvider.pageSize, 10) : 10);
|
|
@@ -30,6 +46,7 @@ export function useDataProvider(provider, options) {
|
|
|
30
46
|
const syncFromProvider = () => {
|
|
31
47
|
if (!activeProvider) {
|
|
32
48
|
pageData.value = [];
|
|
49
|
+
virtualRows.value = [];
|
|
33
50
|
rowCount.value = 0;
|
|
34
51
|
currentPage.value = 1;
|
|
35
52
|
pageSize.value = 10;
|
|
@@ -46,6 +63,7 @@ export function useDataProvider(provider, options) {
|
|
|
46
63
|
try {
|
|
47
64
|
pageData.value = activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []);
|
|
48
65
|
rowCount.value = extractVal(activeProvider.rowCount, 0);
|
|
66
|
+
virtualRows.value = getFullData();
|
|
49
67
|
const newPage = extractVal(activeProvider.currentPage, 1);
|
|
50
68
|
if (currentPage.value !== newPage) {
|
|
51
69
|
currentPage.value = newPage;
|
|
@@ -93,6 +111,7 @@ export function useDataProvider(provider, options) {
|
|
|
93
111
|
}
|
|
94
112
|
};
|
|
95
113
|
attachListener();
|
|
114
|
+
syncFromProvider();
|
|
96
115
|
try {
|
|
97
116
|
onScopeDispose(() => {
|
|
98
117
|
if (unsubscribe) {
|
|
@@ -320,6 +339,7 @@ export function useDataProvider(provider, options) {
|
|
|
320
339
|
return activeProvider;
|
|
321
340
|
},
|
|
322
341
|
pageData,
|
|
342
|
+
virtualRows,
|
|
323
343
|
rowCount,
|
|
324
344
|
currentPage,
|
|
325
345
|
pageSize,
|
|
@@ -45,15 +45,28 @@ export function useKatluxForm(options = {}) {
|
|
|
45
45
|
const submitCount = ref(0);
|
|
46
46
|
const isDirty = computed(() => Object.values(dirtyFields.value).some(Boolean));
|
|
47
47
|
const isValid = computed(() => Object.keys(errors.value).length === 0);
|
|
48
|
+
function registerErrorPaths(errorMap, pathStr, message) {
|
|
49
|
+
if (!pathStr) {
|
|
50
|
+
errorMap[""] = message;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
errorMap[pathStr] = message;
|
|
54
|
+
const bracketPath = pathStr.replace(/\.(\d+)(?=\.|$)/g, "[$1]");
|
|
55
|
+
if (bracketPath !== pathStr && !errorMap[bracketPath]) {
|
|
56
|
+
errorMap[bracketPath] = message;
|
|
57
|
+
}
|
|
58
|
+
const dotPath = pathStr.replace(/\[(\d+)\]/g, ".$1");
|
|
59
|
+
if (dotPath !== pathStr && !errorMap[dotPath]) {
|
|
60
|
+
errorMap[dotPath] = message;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
48
63
|
function parseValidationResult(rawResult, schemaType, dataToValidate) {
|
|
49
64
|
if (schemaType === "standard") {
|
|
50
65
|
if (rawResult.issues && rawResult.issues.length > 0) {
|
|
51
66
|
const errorMap = {};
|
|
52
67
|
for (const issue of rawResult.issues) {
|
|
53
68
|
const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? seg.key : seg).join(".") : "";
|
|
54
|
-
|
|
55
|
-
errorMap[pathStr] = issue.message;
|
|
56
|
-
}
|
|
69
|
+
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
57
70
|
}
|
|
58
71
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
59
72
|
}
|
|
@@ -64,16 +77,18 @@ export function useKatluxForm(options = {}) {
|
|
|
64
77
|
const errorMap = {};
|
|
65
78
|
for (const issue of rawResult.error.issues) {
|
|
66
79
|
const pathStr = issue.path ? issue.path.join(".") : "";
|
|
67
|
-
|
|
68
|
-
errorMap[pathStr] = issue.message;
|
|
69
|
-
}
|
|
80
|
+
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
70
81
|
}
|
|
71
82
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
72
83
|
}
|
|
73
84
|
return { valid: true, output: rawResult.data ?? dataToValidate, errors: {} };
|
|
74
85
|
}
|
|
75
86
|
if (schemaType === "custom") {
|
|
76
|
-
const errorMap =
|
|
87
|
+
const errorMap = {};
|
|
88
|
+
const rawErrors = rawResult || {};
|
|
89
|
+
for (const [key, msg] of Object.entries(rawErrors)) {
|
|
90
|
+
registerErrorPaths(errorMap, key, String(msg));
|
|
91
|
+
}
|
|
77
92
|
const valid = Object.keys(errorMap).length === 0;
|
|
78
93
|
return { valid, output: dataToValidate, errors: errorMap };
|
|
79
94
|
}
|
|
@@ -109,12 +124,17 @@ export function useKatluxForm(options = {}) {
|
|
|
109
124
|
}
|
|
110
125
|
function applyErrors(targetPath, newErrors) {
|
|
111
126
|
if (targetPath) {
|
|
112
|
-
|
|
113
|
-
|
|
127
|
+
const bracketPath = targetPath.replace(/\.(\d+)(?=\.|$)/g, "[$1]");
|
|
128
|
+
const dotPath = targetPath.replace(/\[(\d+)\]/g, ".$1");
|
|
129
|
+
const err = newErrors[targetPath] || newErrors[bracketPath] || newErrors[dotPath];
|
|
130
|
+
if (err) {
|
|
131
|
+
errors.value = { ...errors.value, [targetPath]: err };
|
|
114
132
|
return false;
|
|
115
133
|
} else {
|
|
116
134
|
const nextErrors = { ...errors.value };
|
|
117
135
|
delete nextErrors[targetPath];
|
|
136
|
+
delete nextErrors[bracketPath];
|
|
137
|
+
delete nextErrors[dotPath];
|
|
118
138
|
errors.value = nextErrors;
|
|
119
139
|
return true;
|
|
120
140
|
}
|
|
@@ -123,10 +143,17 @@ export function useKatluxForm(options = {}) {
|
|
|
123
143
|
return Object.keys(newErrors).length === 0;
|
|
124
144
|
}
|
|
125
145
|
}
|
|
146
|
+
let validationSeq = 0;
|
|
126
147
|
function validate(targetPath) {
|
|
148
|
+
const seq = ++validationSeq;
|
|
127
149
|
const result = runValidation(values);
|
|
128
150
|
if (result && typeof result.then === "function") {
|
|
129
|
-
return result.then(({ errors: newErrors }) =>
|
|
151
|
+
return result.then(({ errors: newErrors }) => {
|
|
152
|
+
if (seq !== validationSeq) {
|
|
153
|
+
return Object.keys(errors.value).length === 0;
|
|
154
|
+
}
|
|
155
|
+
return applyErrors(targetPath, newErrors);
|
|
156
|
+
});
|
|
130
157
|
}
|
|
131
158
|
return applyErrors(targetPath, result.errors);
|
|
132
159
|
}
|
|
@@ -176,9 +203,18 @@ export function useKatluxForm(options = {}) {
|
|
|
176
203
|
return getByPath(values, path);
|
|
177
204
|
},
|
|
178
205
|
"onUpdate:modelValue": (newVal) => {
|
|
179
|
-
|
|
206
|
+
let transformed = newVal;
|
|
207
|
+
if (regOptions.transform) {
|
|
208
|
+
if (regOptions.transform === Number) {
|
|
209
|
+
transformed = newVal === "" || newVal === null || newVal === void 0 ? "" : Number(newVal);
|
|
210
|
+
} else {
|
|
211
|
+
transformed = regOptions.transform(newVal);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
180
214
|
setByPath(values, path, transformed);
|
|
181
|
-
|
|
215
|
+
const initialVal = getByPath(initialValues, path);
|
|
216
|
+
const isFieldDirty = JSON.stringify(transformed) !== JSON.stringify(initialVal);
|
|
217
|
+
dirtyFields.value = { ...dirtyFields.value, [path]: isFieldDirty };
|
|
182
218
|
const hasActiveError = !!errors.value[path];
|
|
183
219
|
if (mode === "onChange" || hasActiveError && reValidateMode === "onChange") {
|
|
184
220
|
validate(path);
|
|
@@ -196,6 +232,12 @@ export function useKatluxForm(options = {}) {
|
|
|
196
232
|
}
|
|
197
233
|
return errors.value[path] || "";
|
|
198
234
|
},
|
|
235
|
+
get "aria-invalid"() {
|
|
236
|
+
return !!errors.value[path];
|
|
237
|
+
},
|
|
238
|
+
get "aria-describedby"() {
|
|
239
|
+
return errors.value[path] ? `${path}-error` : void 0;
|
|
240
|
+
},
|
|
199
241
|
onBlur: () => {
|
|
200
242
|
touched.value = { ...touched.value, [path]: true };
|
|
201
243
|
const hasActiveError = !!errors.value[path];
|
|
@@ -221,6 +263,7 @@ export function useKatluxForm(options = {}) {
|
|
|
221
263
|
}
|
|
222
264
|
function handleSubmit(onValid, onInvalid) {
|
|
223
265
|
return async (event) => {
|
|
266
|
+
if (isSubmitting.value) return;
|
|
224
267
|
if (event && typeof event.preventDefault === "function") {
|
|
225
268
|
event.preventDefault();
|
|
226
269
|
}
|
|
@@ -42,6 +42,7 @@ export function useVirtualScroll(options) {
|
|
|
42
42
|
const val = unref(options.containerHeight);
|
|
43
43
|
return typeof val === "number" && val > 0 ? val : 400;
|
|
44
44
|
};
|
|
45
|
+
const configuredContainerHeight = computed(() => resolveContainerHeight());
|
|
45
46
|
const viewportHeight = ref(resolveContainerHeight());
|
|
46
47
|
watch(
|
|
47
48
|
() => resolveContainerHeight(),
|
|
@@ -51,13 +52,13 @@ export function useVirtualScroll(options) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
);
|
|
54
|
-
watch(containerRef, (el, oldEl) => {
|
|
55
|
+
watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
|
|
55
56
|
if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
|
|
56
57
|
if (oldEl && oldEl.__vsObserver) {
|
|
57
58
|
oldEl.__vsObserver.disconnect();
|
|
58
59
|
delete oldEl.__vsObserver;
|
|
59
60
|
}
|
|
60
|
-
if (el) {
|
|
61
|
+
if (el && virtual) {
|
|
61
62
|
const ro = new ResizeObserver((entries) => {
|
|
62
63
|
for (const entry of entries) {
|
|
63
64
|
const h = Math.round(entry.contentRect.height || el.clientHeight);
|
|
@@ -78,12 +79,42 @@ export function useVirtualScroll(options) {
|
|
|
78
79
|
}
|
|
79
80
|
});
|
|
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
|
+
});
|
|
81
95
|
const totalRows = computed(() => {
|
|
82
96
|
if (colCount.value <= 1) return totalCount.value;
|
|
83
97
|
return Math.ceil(totalCount.value / colCount.value);
|
|
84
98
|
});
|
|
85
99
|
const startRowIndex = computed(() => {
|
|
86
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
|
+
}
|
|
87
118
|
const rawRow = Math.floor(scrollTop.value / baseItemHeight.value);
|
|
88
119
|
return Math.max(0, rawRow - buf.value);
|
|
89
120
|
});
|
|
@@ -94,6 +125,23 @@ export function useVirtualScroll(options) {
|
|
|
94
125
|
});
|
|
95
126
|
const endRowIndex = computed(() => {
|
|
96
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
|
+
}
|
|
97
145
|
return Math.min(totalRows.value, startRowIndex.value + visibleRowsCount.value);
|
|
98
146
|
});
|
|
99
147
|
const startIndex = computed(() => {
|
|
@@ -110,16 +158,27 @@ export function useVirtualScroll(options) {
|
|
|
110
158
|
});
|
|
111
159
|
const topSpacerHeight = computed(() => {
|
|
112
160
|
if (!isVirtual.value) return 0;
|
|
161
|
+
if (isDynamicHeight.value && colCount.value <= 1) {
|
|
162
|
+
return rowOffsets.value[startRowIndex.value] || 0;
|
|
163
|
+
}
|
|
113
164
|
return Math.max(0, startRowIndex.value * baseItemHeight.value);
|
|
114
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
|
+
});
|
|
115
173
|
const bottomSpacerHeight = computed(() => {
|
|
116
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
|
+
}
|
|
117
179
|
const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
|
|
118
180
|
return remainingRows * baseItemHeight.value;
|
|
119
181
|
});
|
|
120
|
-
const totalHeight = computed(() => {
|
|
121
|
-
return totalRows.value * baseItemHeight.value;
|
|
122
|
-
});
|
|
123
182
|
watch(totalHeight, (newTotal) => {
|
|
124
183
|
if (scrollTop.value > newTotal) {
|
|
125
184
|
scrollTop.value = Math.max(0, newTotal - viewportHeight.value);
|
|
@@ -133,7 +192,7 @@ export function useVirtualScroll(options) {
|
|
|
133
192
|
"--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
|
|
134
193
|
"--virtual-total-height": `${totalHeight.value}px`,
|
|
135
194
|
"--virtual-item-height": `${baseItemHeight.value}px`,
|
|
136
|
-
"--virtual-container-height": `${
|
|
195
|
+
"--virtual-container-height": `${configuredContainerHeight.value}px`
|
|
137
196
|
}));
|
|
138
197
|
const scrollThreshold = options.scrollThreshold ?? 100;
|
|
139
198
|
const onScroll = (e) => {
|
|
@@ -148,9 +207,20 @@ export function useVirtualScroll(options) {
|
|
|
148
207
|
options.onThresholdReach();
|
|
149
208
|
}
|
|
150
209
|
};
|
|
151
|
-
const scrollToIndex = (index, behavior = "auto") => {
|
|
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
|
+
}
|
|
152
222
|
const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
|
|
153
|
-
const targetScrollTop = targetRow * baseItemHeight.value;
|
|
223
|
+
const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
|
|
154
224
|
scrollTop.value = targetScrollTop;
|
|
155
225
|
if (containerRef.value) {
|
|
156
226
|
containerRef.value.scrollTo({
|
package/dist/module.json
CHANGED
|
@@ -8,7 +8,7 @@ export function getApplicableRows(action, selectedRows, selectAll) {
|
|
|
8
8
|
if (!selectedRows || selectedRows.length === 0) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
-
const isBulkAction = action.isBulk || typeof action.visible === "function" && action.visible.length >= 2;
|
|
11
|
+
const isBulkAction = action.isBulk || action.bulk || typeof action.visible === "function" && action.visible.length >= 2;
|
|
12
12
|
if (isBulkAction) {
|
|
13
13
|
try {
|
|
14
14
|
const isVisible = action.visible(selectedRows, selectAll);
|
|
@@ -18,13 +18,19 @@ export function getApplicableRows(action, selectedRows, selectAll) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
let isPerRowPredicate = false;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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;
|
|
25
33
|
}
|
|
26
|
-
} catch {
|
|
27
|
-
isPerRowPredicate = false;
|
|
28
34
|
}
|
|
29
35
|
if (isPerRowPredicate) {
|
|
30
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
|
};
|
|
@@ -107,6 +107,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
107
107
|
closeDropdown: () => void;
|
|
108
108
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
109
109
|
"update:modelValue": (value: any) => any;
|
|
110
|
+
blur: (event: FocusEvent) => any;
|
|
110
111
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
111
112
|
"update:searchtext": (value: string) => any;
|
|
112
113
|
"scroll-state-change": (state: {
|
|
@@ -211,6 +212,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
211
212
|
};
|
|
212
213
|
}>> & Readonly<{
|
|
213
214
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
215
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
214
216
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
215
217
|
"onUpdate:searchtext"?: ((value: string) => any) | undefined;
|
|
216
218
|
"onScroll-state-change"?: ((state: {
|
|
@@ -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,
|
|
@@ -79,7 +79,7 @@ function updateIsOptionsOpen(val) {
|
|
|
79
79
|
</script>
|
|
80
80
|
|
|
81
81
|
<template lang="pug">
|
|
82
|
-
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)")
|
|
83
83
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
84
84
|
slot(:name="slot" v-bind="scope")
|
|
85
85
|
</template>
|
|
@@ -107,6 +107,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
107
107
|
closeDropdown: () => void;
|
|
108
108
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
109
109
|
"update:modelValue": (value: any) => any;
|
|
110
|
+
blur: (event: FocusEvent) => any;
|
|
110
111
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
111
112
|
"update:searchtext": (value: string) => any;
|
|
112
113
|
"scroll-state-change": (state: {
|
|
@@ -211,6 +212,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
211
212
|
};
|
|
212
213
|
}>> & Readonly<{
|
|
213
214
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
215
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
214
216
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
215
217
|
"onUpdate:searchtext"?: ((value: string) => any) | undefined;
|
|
216
218
|
"onScroll-state-change"?: ((state: {
|
|
@@ -12,6 +12,7 @@ export const KDatatableDefaultProps = {
|
|
|
12
12
|
export function useKDatatableLogic(props, emit) {
|
|
13
13
|
const {
|
|
14
14
|
pageData,
|
|
15
|
+
virtualRows,
|
|
15
16
|
selectedRows: dpSelectedRows,
|
|
16
17
|
selectAll: dpSelectAll,
|
|
17
18
|
currentPage: dpCurrentPage,
|
|
@@ -124,10 +125,24 @@ export function useKDatatableLogic(props, emit) {
|
|
|
124
125
|
emit?.("filter-change", newVal);
|
|
125
126
|
}, { deep: true });
|
|
126
127
|
let lastSyncedSelectAll = Boolean(selectAll.value);
|
|
128
|
+
const getTargetRows = () => {
|
|
129
|
+
if (props.virtualScroll) {
|
|
130
|
+
const dp = props.dataProvider;
|
|
131
|
+
if (Array.isArray(dp?.rowMap)) return dp.rowMap;
|
|
132
|
+
if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value;
|
|
133
|
+
if (Array.isArray(virtualRows?.value) && virtualRows.value.length > 0) return virtualRows.value;
|
|
134
|
+
if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows;
|
|
135
|
+
if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value;
|
|
136
|
+
if (Array.isArray(dp?.allData?.value)) return dp.allData.value;
|
|
137
|
+
if (Array.isArray(dp?.allData)) return dp.allData;
|
|
138
|
+
if (Array.isArray(dp?.data)) return dp.data;
|
|
139
|
+
}
|
|
140
|
+
return pageRows.value;
|
|
141
|
+
};
|
|
127
142
|
watch(() => selectAll.value, (newVal) => {
|
|
128
143
|
if (isInternalUpdating || newVal === lastSyncedSelectAll) return;
|
|
129
144
|
lastSyncedSelectAll = newVal;
|
|
130
|
-
const currentRows =
|
|
145
|
+
const currentRows = getTargetRows();
|
|
131
146
|
if (newVal === false) {
|
|
132
147
|
const pageIds = new Set(currentRows.map(getRowId));
|
|
133
148
|
selectedRows.value = selectedRows.value.filter((r) => !pageIds.has(getRowId(r)));
|
|
@@ -141,7 +156,7 @@ export function useKDatatableLogic(props, emit) {
|
|
|
141
156
|
syncToProvider();
|
|
142
157
|
});
|
|
143
158
|
watch([pageRows, () => selectedRows.value], () => {
|
|
144
|
-
const currentRows =
|
|
159
|
+
const currentRows = getTargetRows();
|
|
145
160
|
if (currentRows.length === 0) {
|
|
146
161
|
if (selectAll.value) {
|
|
147
162
|
lastSyncedSelectAll = false;
|
|
@@ -56,6 +56,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
56
56
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
57
57
|
"update:modelValue": (value: string | Date) => any;
|
|
58
58
|
change: (value: string | Date) => any;
|
|
59
|
+
blur: (event: FocusEvent) => any;
|
|
59
60
|
"update:isOpen": (value: boolean) => any;
|
|
60
61
|
"update:maskedModel": (value: string) => any;
|
|
61
62
|
"update:calendarShow": (value: boolean) => any;
|
|
@@ -117,6 +118,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
117
118
|
}>> & Readonly<{
|
|
118
119
|
"onUpdate:modelValue"?: ((value: string | Date) => any) | undefined;
|
|
119
120
|
onChange?: ((value: string | Date) => any) | undefined;
|
|
121
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
120
122
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
121
123
|
"onUpdate:maskedModel"?: ((value: string) => any) | undefined;
|
|
122
124
|
"onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
|
|
@@ -4,7 +4,7 @@ import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
|
4
4
|
import { computed, watch } from "vue";
|
|
5
5
|
import KDatePickerDefault from "../../presets/default/components/KDatePicker/KDatePicker.vue";
|
|
6
6
|
const props = defineProps(KDatePickerDefaultProps);
|
|
7
|
-
const emit = defineEmits(["update:maskedModel", "update:calendarShow", "update:day", "update:modelValue", "update:isOpen", "change"]);
|
|
7
|
+
const emit = defineEmits(["update:maskedModel", "update:calendarShow", "update:day", "update:modelValue", "update:isOpen", "change", "blur"]);
|
|
8
8
|
const {
|
|
9
9
|
_date,
|
|
10
10
|
maskedModel,
|
|
@@ -70,5 +70,6 @@ component(
|
|
|
70
70
|
v-bind="{ ...templateProps, ...$attrs }"
|
|
71
71
|
@update:maskedModel="updateMaskedModel"
|
|
72
72
|
@update:calendarShow="updateCalendarShow"
|
|
73
|
+
@blur="emit('blur', $event)"
|
|
73
74
|
)
|
|
74
75
|
</template>
|