@katlux/toolkit 0.1.1-alpha.110 → 0.1.1-alpha.111
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 +26 -10
- package/dist/compiled/composables/useRequestQueue.mjs +35 -0
- package/dist/module.json +1 -1
- 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 +31 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +12 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +31 -4
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +22 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +115 -10
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +10 -10
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +10 -10
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +6 -5
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +37 -15
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -3
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +25 -10
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +4 -4
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -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/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +9 -5
- 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/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 +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
- package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.logic.js +7 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +7 -0
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +4 -1
- package/dist/runtime/composables/useDataProvider.js +26 -10
- package/dist/runtime/composables/useRequestQueue.d.ts +25 -0
- package/dist/runtime/composables/useRequestQueue.js +35 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +15 -1
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +23 -2
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +15 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +15 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +170 -7
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +15 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ export function useDataProvider(provider) {
|
|
|
37
37
|
return prop;
|
|
38
38
|
};
|
|
39
39
|
const pageData = shallowRef(
|
|
40
|
-
Array.isArray(provider.pageData) ?
|
|
40
|
+
provider.pageData?.value !== void 0 ? provider.pageData.value : Array.isArray(provider.pageData) ? provider.pageData : extractVal(provider.pageData, [])
|
|
41
41
|
);
|
|
42
42
|
const rowCount = ref(extractVal(provider.rowCount, 0));
|
|
43
43
|
const currentPage = ref(extractVal(provider.currentPage, 1));
|
|
@@ -50,7 +50,7 @@ export function useDataProvider(provider) {
|
|
|
50
50
|
const selectedRows = ref(extractVal(provider.selectedRows, []));
|
|
51
51
|
const selectAll = ref(extractVal(provider.selectAll, false));
|
|
52
52
|
const syncFromProvider = () => {
|
|
53
|
-
pageData.value = Array.isArray(provider.pageData) ?
|
|
53
|
+
pageData.value = provider.pageData?.value !== void 0 ? provider.pageData.value : Array.isArray(provider.pageData) ? provider.pageData : extractVal(provider.pageData, []);
|
|
54
54
|
rowCount.value = extractVal(provider.rowCount, 0);
|
|
55
55
|
currentPage.value = extractVal(provider.currentPage, 1);
|
|
56
56
|
pageSize.value = extractVal(provider.pageSize, 10);
|
|
@@ -74,32 +74,48 @@ export function useDataProvider(provider) {
|
|
|
74
74
|
const setCurrentPage = (page) => {
|
|
75
75
|
if (typeof provider.setCurrentPage === "function") {
|
|
76
76
|
provider.setCurrentPage(page);
|
|
77
|
-
} else if (provider
|
|
78
|
-
provider.currentPage.value
|
|
77
|
+
} else if ("currentPage" in provider) {
|
|
78
|
+
if (isRef(provider.currentPage) || typeof provider.currentPage === "object" && provider.currentPage !== null && "value" in provider.currentPage) {
|
|
79
|
+
provider.currentPage.value = page;
|
|
80
|
+
} else {
|
|
81
|
+
provider.currentPage = page;
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
currentPage.value = page;
|
|
81
85
|
};
|
|
82
86
|
const setPageSize = (size) => {
|
|
83
87
|
if (typeof provider.setPageSize === "function") {
|
|
84
88
|
provider.setPageSize(size);
|
|
85
|
-
} else if (provider
|
|
86
|
-
provider.pageSize.value
|
|
89
|
+
} else if ("pageSize" in provider) {
|
|
90
|
+
if (isRef(provider.pageSize) || typeof provider.pageSize === "object" && provider.pageSize !== null && "value" in provider.pageSize) {
|
|
91
|
+
provider.pageSize.value = size;
|
|
92
|
+
} else {
|
|
93
|
+
provider.pageSize = size;
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
pageSize.value = size;
|
|
89
97
|
};
|
|
90
98
|
const setFilter = (f) => {
|
|
91
99
|
if (typeof provider.setFilter === "function") {
|
|
92
100
|
provider.setFilter(f);
|
|
93
|
-
} else if (provider
|
|
94
|
-
provider.filter.value
|
|
101
|
+
} else if ("filter" in provider) {
|
|
102
|
+
if (isRef(provider.filter) || typeof provider.filter === "object" && provider.filter !== null && "value" in provider.filter) {
|
|
103
|
+
provider.filter.value = f;
|
|
104
|
+
} else {
|
|
105
|
+
provider.filter = f;
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
filter.value = f;
|
|
97
109
|
};
|
|
98
110
|
const setSortList = (s) => {
|
|
99
111
|
if (typeof provider.setSortList === "function") {
|
|
100
112
|
provider.setSortList(s);
|
|
101
|
-
} else if (provider
|
|
102
|
-
provider.sortList.value
|
|
113
|
+
} else if ("sortList" in provider) {
|
|
114
|
+
if (isRef(provider.sortList) || typeof provider.sortList === "object" && provider.sortList !== null && "value" in provider.sortList) {
|
|
115
|
+
provider.sortList.value = s;
|
|
116
|
+
} else {
|
|
117
|
+
provider.sortList = s;
|
|
118
|
+
}
|
|
103
119
|
}
|
|
104
120
|
sortList.value = s;
|
|
105
121
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { shallowRef, ref, onScopeDispose } from "vue";
|
|
2
|
+
import { RequestQueue } from "@katlux/providers";
|
|
3
|
+
export function useRequestQueue() {
|
|
4
|
+
const queue = shallowRef([...RequestQueue.queue]);
|
|
5
|
+
const deadLetterQueue = shallowRef([...RequestQueue.deadLetterQueue]);
|
|
6
|
+
const isFlushing = ref(RequestQueue.isFlushing);
|
|
7
|
+
const sync = () => {
|
|
8
|
+
queue.value = [...RequestQueue.queue];
|
|
9
|
+
deadLetterQueue.value = [...RequestQueue.deadLetterQueue];
|
|
10
|
+
isFlushing.value = RequestQueue.isFlushing;
|
|
11
|
+
};
|
|
12
|
+
const unsubscribe = RequestQueue.subscribe(sync);
|
|
13
|
+
try {
|
|
14
|
+
onScopeDispose(unsubscribe);
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
queue,
|
|
19
|
+
deadLetterQueue,
|
|
20
|
+
isFlushing,
|
|
21
|
+
init: RequestQueue.init.bind(RequestQueue),
|
|
22
|
+
setStorageBackend: RequestQueue.setStorageBackend.bind(RequestQueue),
|
|
23
|
+
enqueue: RequestQueue.enqueue.bind(RequestQueue),
|
|
24
|
+
flushAll: RequestQueue.flushAll.bind(RequestQueue),
|
|
25
|
+
flushOne: RequestQueue.flushOne.bind(RequestQueue),
|
|
26
|
+
retryOne: RequestQueue.retryOne.bind(RequestQueue),
|
|
27
|
+
discard: RequestQueue.discard.bind(RequestQueue),
|
|
28
|
+
reorder: RequestQueue.reorder.bind(RequestQueue),
|
|
29
|
+
getQueue: RequestQueue.getQueue.bind(RequestQueue),
|
|
30
|
+
getDeadLetterQueue: RequestQueue.getDeadLetterQueue.bind(RequestQueue),
|
|
31
|
+
onDeadLetter: RequestQueue.onDeadLetter.bind(RequestQueue),
|
|
32
|
+
onFlushComplete: RequestQueue.onFlushComplete.bind(RequestQueue),
|
|
33
|
+
onNetworkError: RequestQueue.onNetworkError.bind(RequestQueue)
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/module.json
CHANGED
|
@@ -54,9 +54,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
}>> & Readonly<{
|
|
55
55
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
56
56
|
}>, {
|
|
57
|
-
value: any;
|
|
58
57
|
label: string;
|
|
59
58
|
disabled: boolean;
|
|
59
|
+
value: any;
|
|
60
60
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
61
61
|
validationText: string;
|
|
62
62
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -54,9 +54,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
}>> & Readonly<{
|
|
55
55
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
56
56
|
}>, {
|
|
57
|
-
value: any;
|
|
58
57
|
label: string;
|
|
59
58
|
disabled: boolean;
|
|
59
|
+
value: any;
|
|
60
60
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
61
61
|
validationText: string;
|
|
62
62
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -73,6 +73,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
73
73
|
type: BooleanConstructor;
|
|
74
74
|
default: boolean;
|
|
75
75
|
};
|
|
76
|
+
virtualScroll: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: boolean;
|
|
79
|
+
};
|
|
80
|
+
itemHeight: {
|
|
81
|
+
type: NumberConstructor;
|
|
82
|
+
default: number;
|
|
83
|
+
};
|
|
84
|
+
buffer: {
|
|
85
|
+
type: NumberConstructor;
|
|
86
|
+
default: number;
|
|
87
|
+
};
|
|
76
88
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
77
89
|
"update:modelValue": (value: any) => any;
|
|
78
90
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
@@ -150,6 +162,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
150
162
|
type: BooleanConstructor;
|
|
151
163
|
default: boolean;
|
|
152
164
|
};
|
|
165
|
+
virtualScroll: {
|
|
166
|
+
type: BooleanConstructor;
|
|
167
|
+
default: boolean;
|
|
168
|
+
};
|
|
169
|
+
itemHeight: {
|
|
170
|
+
type: NumberConstructor;
|
|
171
|
+
default: number;
|
|
172
|
+
};
|
|
173
|
+
buffer: {
|
|
174
|
+
type: NumberConstructor;
|
|
175
|
+
default: number;
|
|
176
|
+
};
|
|
153
177
|
}>> & Readonly<{
|
|
154
178
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
155
179
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
@@ -157,19 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
157
181
|
label: string;
|
|
158
182
|
disabled: boolean;
|
|
159
183
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
160
|
-
validationText: string;
|
|
161
184
|
modelValue: any;
|
|
185
|
+
valueField: string;
|
|
186
|
+
placeholder: string;
|
|
162
187
|
searchbox: boolean;
|
|
188
|
+
teleportTo: string;
|
|
189
|
+
validationText: string;
|
|
163
190
|
searchPlaceholder: string;
|
|
191
|
+
virtualScroll: boolean;
|
|
192
|
+
itemHeight: number;
|
|
193
|
+
buffer: number;
|
|
164
194
|
isOptionsOpen: boolean;
|
|
165
|
-
placeholder: string;
|
|
166
|
-
teleportTo: string;
|
|
167
195
|
fullWidth: boolean;
|
|
168
196
|
closeOnSelect: boolean;
|
|
169
197
|
multiSelect: boolean;
|
|
170
198
|
maxSelectedDisplay: string | number | boolean;
|
|
171
199
|
visibleFields: String[];
|
|
172
|
-
valueField: string;
|
|
173
200
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
174
201
|
declare const _default: typeof __VLS_export;
|
|
175
202
|
export default _default;
|
|
@@ -15,7 +15,11 @@ const {
|
|
|
15
15
|
toggleDropdown,
|
|
16
16
|
closeDropdown,
|
|
17
17
|
filteredOptions,
|
|
18
|
-
loading
|
|
18
|
+
loading,
|
|
19
|
+
loadingMore,
|
|
20
|
+
initialLoading,
|
|
21
|
+
canLoadMore,
|
|
22
|
+
loadMore
|
|
19
23
|
} = useKComboboxLogic(props, emit);
|
|
20
24
|
watch(isOptionsOpen, (newVal) => {
|
|
21
25
|
emit("update:isOptionsOpen", newVal);
|
|
@@ -37,6 +41,13 @@ const templateProps = computed(() => ({
|
|
|
37
41
|
selectItem,
|
|
38
42
|
isSelected,
|
|
39
43
|
loading: loading.value,
|
|
44
|
+
loadingMore: loadingMore.value,
|
|
45
|
+
initialLoading: initialLoading.value,
|
|
46
|
+
canLoadMore: canLoadMore.value,
|
|
47
|
+
loadMore,
|
|
48
|
+
virtualScroll: props.virtualScroll,
|
|
49
|
+
itemHeight: props.itemHeight,
|
|
50
|
+
buffer: props.buffer,
|
|
40
51
|
teleportTo: props.teleportTo,
|
|
41
52
|
valueField: props.valueField,
|
|
42
53
|
validation: props.validation,
|
|
@@ -73,6 +73,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
73
73
|
type: BooleanConstructor;
|
|
74
74
|
default: boolean;
|
|
75
75
|
};
|
|
76
|
+
virtualScroll: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: boolean;
|
|
79
|
+
};
|
|
80
|
+
itemHeight: {
|
|
81
|
+
type: NumberConstructor;
|
|
82
|
+
default: number;
|
|
83
|
+
};
|
|
84
|
+
buffer: {
|
|
85
|
+
type: NumberConstructor;
|
|
86
|
+
default: number;
|
|
87
|
+
};
|
|
76
88
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
77
89
|
"update:modelValue": (value: any) => any;
|
|
78
90
|
"update:isOptionsOpen": (value: boolean) => any;
|
|
@@ -150,6 +162,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
150
162
|
type: BooleanConstructor;
|
|
151
163
|
default: boolean;
|
|
152
164
|
};
|
|
165
|
+
virtualScroll: {
|
|
166
|
+
type: BooleanConstructor;
|
|
167
|
+
default: boolean;
|
|
168
|
+
};
|
|
169
|
+
itemHeight: {
|
|
170
|
+
type: NumberConstructor;
|
|
171
|
+
default: number;
|
|
172
|
+
};
|
|
173
|
+
buffer: {
|
|
174
|
+
type: NumberConstructor;
|
|
175
|
+
default: number;
|
|
176
|
+
};
|
|
153
177
|
}>> & Readonly<{
|
|
154
178
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
155
179
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
@@ -157,19 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
157
181
|
label: string;
|
|
158
182
|
disabled: boolean;
|
|
159
183
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
160
|
-
validationText: string;
|
|
161
184
|
modelValue: any;
|
|
185
|
+
valueField: string;
|
|
186
|
+
placeholder: string;
|
|
162
187
|
searchbox: boolean;
|
|
188
|
+
teleportTo: string;
|
|
189
|
+
validationText: string;
|
|
163
190
|
searchPlaceholder: string;
|
|
191
|
+
virtualScroll: boolean;
|
|
192
|
+
itemHeight: number;
|
|
193
|
+
buffer: number;
|
|
164
194
|
isOptionsOpen: boolean;
|
|
165
|
-
placeholder: string;
|
|
166
|
-
teleportTo: string;
|
|
167
195
|
fullWidth: boolean;
|
|
168
196
|
closeOnSelect: boolean;
|
|
169
197
|
multiSelect: boolean;
|
|
170
198
|
maxSelectedDisplay: string | number | boolean;
|
|
171
199
|
visibleFields: String[];
|
|
172
|
-
valueField: string;
|
|
173
200
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
174
201
|
declare const _default: typeof __VLS_export;
|
|
175
202
|
export default _default;
|
|
@@ -21,6 +21,9 @@ export interface KComboboxProps {
|
|
|
21
21
|
fullWidth?: boolean;
|
|
22
22
|
validation?: 'success' | 'warning' | 'error' | null;
|
|
23
23
|
validationText?: string;
|
|
24
|
+
virtualScroll?: boolean;
|
|
25
|
+
itemHeight?: number;
|
|
26
|
+
buffer?: number;
|
|
24
27
|
}
|
|
25
28
|
export interface KComboboxEmits {
|
|
26
29
|
(e: 'update:modelValue', value: any): void;
|
|
@@ -100,6 +103,18 @@ export declare const KComboboxDefaultProps: {
|
|
|
100
103
|
type: BooleanConstructor;
|
|
101
104
|
default: boolean;
|
|
102
105
|
};
|
|
106
|
+
virtualScroll: {
|
|
107
|
+
type: BooleanConstructor;
|
|
108
|
+
default: boolean;
|
|
109
|
+
};
|
|
110
|
+
itemHeight: {
|
|
111
|
+
type: NumberConstructor;
|
|
112
|
+
default: number;
|
|
113
|
+
};
|
|
114
|
+
buffer: {
|
|
115
|
+
type: NumberConstructor;
|
|
116
|
+
default: number;
|
|
117
|
+
};
|
|
103
118
|
};
|
|
104
119
|
export declare function useKComboboxLogic(props: KComboboxProps, emit: KComboboxEmits): {
|
|
105
120
|
selectedItems: import("vue").Ref<TDataRow[] | null, TDataRow[] | null>;
|
|
@@ -112,4 +127,11 @@ export declare function useKComboboxLogic(props: KComboboxProps, emit: KCombobox
|
|
|
112
127
|
closeDropdown: () => void;
|
|
113
128
|
filteredOptions: import("vue").ComputedRef<TDataRow[]>;
|
|
114
129
|
loading: import("vue").Ref<boolean, boolean>;
|
|
130
|
+
loadingMore: import("vue").ComputedRef<boolean>;
|
|
131
|
+
initialLoading: import("vue").ComputedRef<boolean>;
|
|
132
|
+
canLoadMore: import("vue").ComputedRef<boolean>;
|
|
133
|
+
loadMore: () => void;
|
|
134
|
+
virtualScroll: boolean;
|
|
135
|
+
itemHeight: number;
|
|
136
|
+
buffer: number;
|
|
115
137
|
};
|
|
@@ -76,13 +76,82 @@ export const KComboboxDefaultProps = {
|
|
|
76
76
|
fullWidth: {
|
|
77
77
|
type: Boolean,
|
|
78
78
|
default: true
|
|
79
|
+
},
|
|
80
|
+
virtualScroll: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
},
|
|
84
|
+
itemHeight: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 40
|
|
87
|
+
},
|
|
88
|
+
buffer: {
|
|
89
|
+
type: Number,
|
|
90
|
+
default: 5
|
|
79
91
|
}
|
|
80
92
|
};
|
|
81
93
|
export function useKComboboxLogic(props, emit) {
|
|
82
|
-
const {
|
|
94
|
+
const {
|
|
95
|
+
pageData: dpPageData,
|
|
96
|
+
loading: dpLoading,
|
|
97
|
+
currentPage: dpCurrentPage,
|
|
98
|
+
pageSize: dpPageSize,
|
|
99
|
+
rowCount: dpRowCount,
|
|
100
|
+
setCurrentPage: dpSetCurrentPage
|
|
101
|
+
} = useDataProvider(props.dataProvider);
|
|
83
102
|
const selectedItems = ref(null);
|
|
84
103
|
const isOptionsOpen = ref(false);
|
|
85
104
|
const searchtext = ref("");
|
|
105
|
+
const loadedOptions = ref([]);
|
|
106
|
+
const lastAppendedPage = ref(1);
|
|
107
|
+
const hasMorePages = ref(true);
|
|
108
|
+
function getItemKey(item, index) {
|
|
109
|
+
if (!item) return index;
|
|
110
|
+
if (props.valueField && item[props.valueField] !== void 0) return item[props.valueField];
|
|
111
|
+
const idKey = props.dataProvider?.idKey || "id";
|
|
112
|
+
if (item[idKey] !== void 0) return item[idKey];
|
|
113
|
+
if (props.labelField && item[props.labelField] !== void 0) return item[props.labelField];
|
|
114
|
+
return index;
|
|
115
|
+
}
|
|
116
|
+
function syncLoadedOptions() {
|
|
117
|
+
const currentData = dpPageData.value || [];
|
|
118
|
+
const currentPageNum = dpCurrentPage.value ?? 1;
|
|
119
|
+
const currentSize = dpPageSize.value ?? 10;
|
|
120
|
+
if (currentSize <= 0) {
|
|
121
|
+
loadedOptions.value = [...currentData];
|
|
122
|
+
hasMorePages.value = false;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (currentPageNum === 1) {
|
|
126
|
+
loadedOptions.value = [...currentData];
|
|
127
|
+
lastAppendedPage.value = 1;
|
|
128
|
+
hasMorePages.value = currentData.length >= currentSize;
|
|
129
|
+
} else {
|
|
130
|
+
const existingKeys = new Set(loadedOptions.value.map((item, idx) => getItemKey(item, idx)));
|
|
131
|
+
const newItems = currentData.filter((item, idx) => !existingKeys.has(getItemKey(item, idx)));
|
|
132
|
+
if (newItems.length > 0) {
|
|
133
|
+
loadedOptions.value = [...loadedOptions.value, ...newItems];
|
|
134
|
+
lastAppendedPage.value = currentPageNum;
|
|
135
|
+
}
|
|
136
|
+
hasMorePages.value = currentData.length >= currentSize;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
syncLoadedOptions();
|
|
140
|
+
watch(
|
|
141
|
+
() => dpPageData.value,
|
|
142
|
+
() => {
|
|
143
|
+
syncLoadedOptions();
|
|
144
|
+
},
|
|
145
|
+
{ deep: true }
|
|
146
|
+
);
|
|
147
|
+
watch(
|
|
148
|
+
() => dpCurrentPage.value,
|
|
149
|
+
(newPage) => {
|
|
150
|
+
if (newPage === 1) {
|
|
151
|
+
syncLoadedOptions();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
);
|
|
86
155
|
watch(() => props.isOptionsOpen, (newVal) => {
|
|
87
156
|
if (newVal !== void 0 && newVal !== isOptionsOpen.value) {
|
|
88
157
|
isOptionsOpen.value = newVal;
|
|
@@ -147,17 +216,46 @@ export function useKComboboxLogic(props, emit) {
|
|
|
147
216
|
watch(
|
|
148
217
|
() => searchtext.value,
|
|
149
218
|
(newText) => {
|
|
150
|
-
if (!props.dataProvider
|
|
219
|
+
if (!props.dataProvider) return;
|
|
151
220
|
const filter = {
|
|
152
221
|
operator: EDataFilterOperator.In,
|
|
153
222
|
field: { [props.labelField]: newText.trim().toLowerCase() },
|
|
154
|
-
active: newText.trim().toLowerCase()
|
|
223
|
+
active: newText.trim().toLowerCase() !== ""
|
|
155
224
|
};
|
|
156
|
-
props.dataProvider.setFilter
|
|
225
|
+
if (typeof props.dataProvider.setFilter === "function") {
|
|
226
|
+
props.dataProvider.setFilter(filter);
|
|
227
|
+
} else if (props.dataProvider.filter && typeof props.dataProvider.filter === "object" && "value" in props.dataProvider.filter) {
|
|
228
|
+
props.dataProvider.filter.value = filter;
|
|
229
|
+
} else {
|
|
230
|
+
props.dataProvider.filter = filter;
|
|
231
|
+
}
|
|
157
232
|
}
|
|
158
233
|
);
|
|
234
|
+
const canLoadMore = computed(() => {
|
|
235
|
+
if (dpLoading.value) return false;
|
|
236
|
+
const currentSize = dpPageSize.value ?? 10;
|
|
237
|
+
if (currentSize <= 0) return false;
|
|
238
|
+
const totalCount = dpRowCount.value ?? 0;
|
|
239
|
+
if (totalCount > 0) {
|
|
240
|
+
return loadedOptions.value.length < totalCount;
|
|
241
|
+
}
|
|
242
|
+
return hasMorePages.value && (dpPageData.value?.length || 0) >= currentSize;
|
|
243
|
+
});
|
|
244
|
+
const loadingMore = computed(() => {
|
|
245
|
+
return dpLoading.value && loadedOptions.value.length > 0;
|
|
246
|
+
});
|
|
247
|
+
const initialLoading = computed(() => {
|
|
248
|
+
return dpLoading.value && loadedOptions.value.length === 0;
|
|
249
|
+
});
|
|
250
|
+
function loadMore() {
|
|
251
|
+
if (!canLoadMore.value || dpLoading.value) return;
|
|
252
|
+
const nextPage = (dpCurrentPage.value ?? 1) + 1;
|
|
253
|
+
if (typeof dpSetCurrentPage === "function") {
|
|
254
|
+
dpSetCurrentPage(nextPage);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
159
257
|
const filteredOptions = computed(() => {
|
|
160
|
-
return
|
|
258
|
+
return loadedOptions.value;
|
|
161
259
|
});
|
|
162
260
|
function resolveSelectedFromValue() {
|
|
163
261
|
if (!props.modelValue) {
|
|
@@ -169,7 +267,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
169
267
|
return;
|
|
170
268
|
}
|
|
171
269
|
const provider = props.dataProvider;
|
|
172
|
-
const data = unref(provider?.allData) || dpPageData.value || [];
|
|
270
|
+
const data = unref(provider?.allData) || loadedOptions.value || dpPageData.value || [];
|
|
173
271
|
if (data.length === 0) return;
|
|
174
272
|
const values = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
|
|
175
273
|
const matchedItems = data.filter((item) => values.includes(item[props.valueField]));
|
|
@@ -187,9 +285,9 @@ export function useKComboboxLogic(props, emit) {
|
|
|
187
285
|
}
|
|
188
286
|
);
|
|
189
287
|
watch(
|
|
190
|
-
() => unref(props.dataProvider?.allData)
|
|
191
|
-
(
|
|
192
|
-
if (
|
|
288
|
+
() => [unref(props.dataProvider?.allData), unref(props.dataProvider?.pageData), loadedOptions.value.length],
|
|
289
|
+
() => {
|
|
290
|
+
if (props.modelValue && (!selectedItems.value || selectedItems.value.length === 0 || !selectedItems.value[0]?.[props.labelField])) {
|
|
193
291
|
resolveSelectedFromValue();
|
|
194
292
|
}
|
|
195
293
|
}
|
|
@@ -204,6 +302,13 @@ export function useKComboboxLogic(props, emit) {
|
|
|
204
302
|
toggleDropdown,
|
|
205
303
|
closeDropdown,
|
|
206
304
|
filteredOptions,
|
|
207
|
-
loading: dpLoading
|
|
305
|
+
loading: dpLoading,
|
|
306
|
+
loadingMore,
|
|
307
|
+
initialLoading,
|
|
308
|
+
canLoadMore,
|
|
309
|
+
loadMore,
|
|
310
|
+
virtualScroll: props.virtualScroll ?? true,
|
|
311
|
+
itemHeight: props.itemHeight ?? 40,
|
|
312
|
+
buffer: props.buffer ?? 5
|
|
208
313
|
};
|
|
209
314
|
}
|
|
@@ -90,9 +90,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
90
90
|
default: boolean;
|
|
91
91
|
};
|
|
92
92
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
93
|
-
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
94
93
|
"update:selectionValue": (value: any) => any;
|
|
95
94
|
"update:inputValue": (value: any) => any;
|
|
95
|
+
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
96
96
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
97
97
|
label: {
|
|
98
98
|
type: StringConstructor;
|
|
@@ -184,27 +184,27 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
184
184
|
default: boolean;
|
|
185
185
|
};
|
|
186
186
|
}>> & Readonly<{
|
|
187
|
-
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
188
187
|
"onUpdate:selectionValue"?: ((value: any) => any) | undefined;
|
|
189
188
|
"onUpdate:inputValue"?: ((value: any) => any) | undefined;
|
|
189
|
+
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
190
190
|
}>, {
|
|
191
191
|
type: import("./KCompositeInput.logic.js").CompositeInputType;
|
|
192
192
|
label: string;
|
|
193
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
194
|
-
validationText: string;
|
|
195
|
-
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
196
|
-
searchbox: boolean;
|
|
197
|
-
labelField: string;
|
|
198
|
-
placeholder: string;
|
|
199
|
-
teleportTo: string;
|
|
200
|
-
valueField: string;
|
|
201
193
|
inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
|
|
194
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
202
195
|
selectionValue: string | number | Record<string, any> | unknown[];
|
|
203
196
|
inputValue: string | number | Record<string, any> | unknown[];
|
|
197
|
+
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
204
198
|
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
205
199
|
mask: string;
|
|
200
|
+
labelField: string;
|
|
201
|
+
valueField: string;
|
|
202
|
+
placeholder: string;
|
|
206
203
|
inputPlaceholder: string;
|
|
204
|
+
searchbox: boolean;
|
|
207
205
|
showClear: boolean;
|
|
206
|
+
teleportTo: string;
|
|
207
|
+
validationText: string;
|
|
208
208
|
inputConfigField: string;
|
|
209
209
|
validateAll: boolean;
|
|
210
210
|
inputFormat: string;
|
|
@@ -90,9 +90,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
90
90
|
default: boolean;
|
|
91
91
|
};
|
|
92
92
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
93
|
-
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
94
93
|
"update:selectionValue": (value: any) => any;
|
|
95
94
|
"update:inputValue": (value: any) => any;
|
|
95
|
+
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
96
96
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
97
97
|
label: {
|
|
98
98
|
type: StringConstructor;
|
|
@@ -184,27 +184,27 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
184
184
|
default: boolean;
|
|
185
185
|
};
|
|
186
186
|
}>> & Readonly<{
|
|
187
|
-
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
188
187
|
"onUpdate:selectionValue"?: ((value: any) => any) | undefined;
|
|
189
188
|
"onUpdate:inputValue"?: ((value: any) => any) | undefined;
|
|
189
|
+
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
190
190
|
}>, {
|
|
191
191
|
type: import("./KCompositeInput.logic.js").CompositeInputType;
|
|
192
192
|
label: string;
|
|
193
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
194
|
-
validationText: string;
|
|
195
|
-
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
196
|
-
searchbox: boolean;
|
|
197
|
-
labelField: string;
|
|
198
|
-
placeholder: string;
|
|
199
|
-
teleportTo: string;
|
|
200
|
-
valueField: string;
|
|
201
193
|
inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
|
|
194
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
202
195
|
selectionValue: string | number | Record<string, any> | unknown[];
|
|
203
196
|
inputValue: string | number | Record<string, any> | unknown[];
|
|
197
|
+
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
204
198
|
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
205
199
|
mask: string;
|
|
200
|
+
labelField: string;
|
|
201
|
+
valueField: string;
|
|
202
|
+
placeholder: string;
|
|
206
203
|
inputPlaceholder: string;
|
|
204
|
+
searchbox: boolean;
|
|
207
205
|
showClear: boolean;
|
|
206
|
+
teleportTo: string;
|
|
207
|
+
validationText: string;
|
|
208
208
|
inputConfigField: string;
|
|
209
209
|
validateAll: boolean;
|
|
210
210
|
inputFormat: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
1
2
|
import { ADataProvider } from '@katlux/providers';
|
|
2
3
|
export interface KDataIteratorProps {
|
|
3
4
|
dataProvider: ADataProvider;
|
|
@@ -15,9 +16,9 @@ export declare const KDataIteratorDefaultProps: {
|
|
|
15
16
|
page: number;
|
|
16
17
|
};
|
|
17
18
|
export declare function useKDataIteratorLogic(props: KDataIteratorProps): {
|
|
18
|
-
selectedRows:
|
|
19
|
-
selectAll:
|
|
20
|
-
pageData:
|
|
21
|
-
loading:
|
|
22
|
-
initialLoad:
|
|
19
|
+
selectedRows: Ref<any[], any[]>;
|
|
20
|
+
selectAll: Ref<boolean, boolean>;
|
|
21
|
+
pageData: Ref<import("@katlux/providers").TDataRow[], import("@katlux/providers").TDataRow[]>;
|
|
22
|
+
loading: Ref<boolean, boolean>;
|
|
23
|
+
initialLoad: Ref<boolean, boolean>;
|
|
23
24
|
};
|