@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
|
@@ -92,6 +92,10 @@ export const KComboboxDefaultProps = {
|
|
|
92
92
|
buffer: {
|
|
93
93
|
type: Number,
|
|
94
94
|
default: 5
|
|
95
|
+
},
|
|
96
|
+
maxHeight: {
|
|
97
|
+
type: Number,
|
|
98
|
+
default: void 0
|
|
95
99
|
}
|
|
96
100
|
};
|
|
97
101
|
export function useKComboboxLogic(props, emit) {
|
|
@@ -197,7 +201,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
197
201
|
emit("update:modelValue", value);
|
|
198
202
|
} else {
|
|
199
203
|
const value = props.valueField ? selectedItems.value?.[0]?.[props.valueField] : selectedItems.value?.[0];
|
|
200
|
-
emit("update:modelValue", value
|
|
204
|
+
emit("update:modelValue", value !== void 0 ? value : null);
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
function isSelected(option) {
|
|
@@ -290,6 +294,21 @@ export function useKComboboxLogic(props, emit) {
|
|
|
290
294
|
}
|
|
291
295
|
break;
|
|
292
296
|
}
|
|
297
|
+
case " ":
|
|
298
|
+
case "Space": {
|
|
299
|
+
const target = e.target;
|
|
300
|
+
if (target && target.tagName !== "INPUT") {
|
|
301
|
+
e.preventDefault();
|
|
302
|
+
if (isOptionsOpen.value) {
|
|
303
|
+
if (highlightedIndex.value >= 0 && highlightedIndex.value < total) {
|
|
304
|
+
selectItem(filteredOptions.value[highlightedIndex.value]);
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
isOptionsOpen.value = true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
293
312
|
case "Escape": {
|
|
294
313
|
if (isOptionsOpen.value) {
|
|
295
314
|
e.preventDefault();
|
|
@@ -454,7 +473,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
454
473
|
}
|
|
455
474
|
}
|
|
456
475
|
function resolveSelectedFromValue() {
|
|
457
|
-
if (
|
|
476
|
+
if (props.modelValue === void 0 || props.modelValue === null) {
|
|
458
477
|
selectedItems.value = null;
|
|
459
478
|
return;
|
|
460
479
|
}
|
|
@@ -483,7 +502,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
483
502
|
watch(
|
|
484
503
|
() => [unref(props.dataProvider?.allData), unref(props.dataProvider?.pageData), loadedOptions.value.length],
|
|
485
504
|
() => {
|
|
486
|
-
if (props.modelValue && (!selectedItems.value || selectedItems.value.length === 0 || !selectedItems.value[0]?.[props.labelField])) {
|
|
505
|
+
if (props.modelValue !== void 0 && props.modelValue !== null && (!selectedItems.value || selectedItems.value.length === 0 || !selectedItems.value[0]?.[props.labelField])) {
|
|
487
506
|
resolveSelectedFromValue();
|
|
488
507
|
}
|
|
489
508
|
}
|
|
@@ -13,6 +13,10 @@ interface Props {
|
|
|
13
13
|
currentPage?: number;
|
|
14
14
|
selectedRows?: any[];
|
|
15
15
|
selectAll?: boolean;
|
|
16
|
+
virtualScroll?: boolean;
|
|
17
|
+
itemHeight?: number;
|
|
18
|
+
viewportHeight?: number;
|
|
19
|
+
buffer?: number;
|
|
16
20
|
}
|
|
17
21
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
18
22
|
"update:page": (value: number) => any;
|
|
@@ -42,10 +46,14 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
42
46
|
loading: boolean;
|
|
43
47
|
currentPage: number;
|
|
44
48
|
pageSize: number;
|
|
49
|
+
virtualScroll: boolean;
|
|
50
|
+
itemHeight: number;
|
|
51
|
+
buffer: number;
|
|
45
52
|
visibleFields: Array<string> | null;
|
|
46
53
|
rowActions: IKDatatableAction[];
|
|
47
54
|
itemsPerPage: number;
|
|
48
55
|
page: number;
|
|
56
|
+
viewportHeight: number;
|
|
49
57
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
50
58
|
declare const _default: typeof __VLS_export;
|
|
51
59
|
export default _default;
|
|
@@ -16,7 +16,11 @@ const props = defineProps({
|
|
|
16
16
|
page: { type: Number, required: false, default: 1 },
|
|
17
17
|
currentPage: { type: Number, required: false, default: void 0 },
|
|
18
18
|
selectedRows: { type: Array, required: false, default: void 0 },
|
|
19
|
-
selectAll: { type: Boolean, required: false, default: void 0 }
|
|
19
|
+
selectAll: { type: Boolean, required: false, default: void 0 },
|
|
20
|
+
virtualScroll: { type: Boolean, required: false, default: false },
|
|
21
|
+
itemHeight: { type: Number, required: false, default: 60 },
|
|
22
|
+
viewportHeight: { type: Number, required: false, default: 500 },
|
|
23
|
+
buffer: { type: Number, required: false, default: 5 }
|
|
20
24
|
});
|
|
21
25
|
const emit = defineEmits(["update:page", "update:currentPage", "update:itemsPerPage", "update:pageSize", "update:search", "update:selectedRows", "update:selectAll", "page-change", "search-change"]);
|
|
22
26
|
const { selectedRows, selectAll, currentPage, pageSize, setCurrentPage, setPageSize } = useKDataIteratorLogic(props, emit);
|
|
@@ -36,7 +40,11 @@ const templateProps = computed(() => ({
|
|
|
36
40
|
search: props.search,
|
|
37
41
|
itemsPerPage: pageSize.value,
|
|
38
42
|
page: currentPage.value,
|
|
39
|
-
slots: mergedSlots.value
|
|
43
|
+
slots: mergedSlots.value,
|
|
44
|
+
virtualScroll: props.virtualScroll,
|
|
45
|
+
itemHeight: props.itemHeight,
|
|
46
|
+
viewportHeight: props.viewportHeight,
|
|
47
|
+
buffer: props.buffer
|
|
40
48
|
}));
|
|
41
49
|
const updateSelectedRows = (val) => {
|
|
42
50
|
selectedRows.value = val;
|
|
@@ -13,6 +13,10 @@ interface Props {
|
|
|
13
13
|
currentPage?: number;
|
|
14
14
|
selectedRows?: any[];
|
|
15
15
|
selectAll?: boolean;
|
|
16
|
+
virtualScroll?: boolean;
|
|
17
|
+
itemHeight?: number;
|
|
18
|
+
viewportHeight?: number;
|
|
19
|
+
buffer?: number;
|
|
16
20
|
}
|
|
17
21
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
18
22
|
"update:page": (value: number) => any;
|
|
@@ -42,10 +46,14 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
42
46
|
loading: boolean;
|
|
43
47
|
currentPage: number;
|
|
44
48
|
pageSize: number;
|
|
49
|
+
virtualScroll: boolean;
|
|
50
|
+
itemHeight: number;
|
|
51
|
+
buffer: number;
|
|
45
52
|
visibleFields: Array<string> | null;
|
|
46
53
|
rowActions: IKDatatableAction[];
|
|
47
54
|
itemsPerPage: number;
|
|
48
55
|
page: number;
|
|
56
|
+
viewportHeight: number;
|
|
49
57
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
50
58
|
declare const _default: typeof __VLS_export;
|
|
51
59
|
export default _default;
|
|
@@ -11,6 +11,10 @@ export interface KDataIteratorProps {
|
|
|
11
11
|
currentPage?: number;
|
|
12
12
|
selectedRows?: any[];
|
|
13
13
|
selectAll?: boolean;
|
|
14
|
+
virtualScroll?: boolean;
|
|
15
|
+
itemHeight?: number;
|
|
16
|
+
viewportHeight?: number;
|
|
17
|
+
buffer?: number;
|
|
14
18
|
}
|
|
15
19
|
export type KDataIteratorEmits = {
|
|
16
20
|
(e: 'update:page', page: number): void;
|
|
@@ -29,6 +33,10 @@ export declare const KDataIteratorDefaultProps: {
|
|
|
29
33
|
search: string;
|
|
30
34
|
itemsPerPage: number;
|
|
31
35
|
page: number;
|
|
36
|
+
virtualScroll: boolean;
|
|
37
|
+
itemHeight: number;
|
|
38
|
+
viewportHeight: number;
|
|
39
|
+
buffer: number;
|
|
32
40
|
};
|
|
33
41
|
export declare function useKDataIteratorLogic(props: KDataIteratorProps, emit?: KDataIteratorEmits): {
|
|
34
42
|
selectedRows: Ref<any[], any[]>;
|
|
@@ -5,7 +5,11 @@ export const KDataIteratorDefaultProps = {
|
|
|
5
5
|
loading: false,
|
|
6
6
|
search: "",
|
|
7
7
|
itemsPerPage: 10,
|
|
8
|
-
page: 1
|
|
8
|
+
page: 1,
|
|
9
|
+
virtualScroll: false,
|
|
10
|
+
itemHeight: 60,
|
|
11
|
+
viewportHeight: 500,
|
|
12
|
+
buffer: 5
|
|
9
13
|
};
|
|
10
14
|
export function useKDataIteratorLogic(props, emit) {
|
|
11
15
|
const {
|
|
@@ -100,8 +104,10 @@ export function useKDataIteratorLogic(props, emit) {
|
|
|
100
104
|
emit?.("update:itemsPerPage", newVal);
|
|
101
105
|
emit?.("update:pageSize", newVal);
|
|
102
106
|
});
|
|
107
|
+
let lastSyncedSelectAll = Boolean(selectAll.value);
|
|
103
108
|
watch(() => selectAll.value, (newVal) => {
|
|
104
|
-
if (isInternalUpdating) return;
|
|
109
|
+
if (isInternalUpdating || newVal === lastSyncedSelectAll) return;
|
|
110
|
+
lastSyncedSelectAll = newVal;
|
|
105
111
|
const currentRows = pageRows.value;
|
|
106
112
|
if (newVal === false) {
|
|
107
113
|
const pageIds = new Set(currentRows.map(getRowId));
|
|
@@ -119,6 +125,7 @@ export function useKDataIteratorLogic(props, emit) {
|
|
|
119
125
|
const currentRows = pageRows.value;
|
|
120
126
|
if (currentRows.length === 0) {
|
|
121
127
|
if (selectAll.value) {
|
|
128
|
+
lastSyncedSelectAll = false;
|
|
122
129
|
isInternalUpdating = true;
|
|
123
130
|
selectAll.value = false;
|
|
124
131
|
isInternalUpdating = false;
|
|
@@ -130,6 +137,7 @@ export function useKDataIteratorLogic(props, emit) {
|
|
|
130
137
|
const currentSelectedIds = new Set(selectedRows.value.map(getRowId));
|
|
131
138
|
const allSelected = currentRows.every((r) => currentSelectedIds.has(getRowId(r)));
|
|
132
139
|
if (selectAll.value !== allSelected) {
|
|
140
|
+
lastSyncedSelectAll = allSelected;
|
|
133
141
|
isInternalUpdating = true;
|
|
134
142
|
selectAll.value = allSelected;
|
|
135
143
|
isInternalUpdating = false;
|
|
@@ -17,6 +17,10 @@ interface Props {
|
|
|
17
17
|
filter?: IDataFilter | null;
|
|
18
18
|
selectedRows?: any[];
|
|
19
19
|
selectAll?: boolean;
|
|
20
|
+
virtualScroll?: boolean;
|
|
21
|
+
itemHeight?: number;
|
|
22
|
+
viewportHeight?: number;
|
|
23
|
+
buffer?: number;
|
|
20
24
|
}
|
|
21
25
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
22
26
|
"update:currentPage": (value: number) => any;
|
|
@@ -46,8 +50,12 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
46
50
|
currentPage: number;
|
|
47
51
|
pageSize: number;
|
|
48
52
|
sortList: IDataSort[];
|
|
53
|
+
virtualScroll: boolean;
|
|
54
|
+
itemHeight: number;
|
|
55
|
+
buffer: number;
|
|
49
56
|
visibleFields: Array<string> | null;
|
|
50
57
|
rowActions: Array<IKDatatableAction>;
|
|
58
|
+
viewportHeight: number;
|
|
51
59
|
cellSlots: Record<string, any>;
|
|
52
60
|
headerSlots: Record<string, any>;
|
|
53
61
|
columnHeaders: Record<string, string>;
|
|
@@ -11,8 +11,8 @@ const props = defineProps({
|
|
|
11
11
|
bulkActions: { type: Array, required: false, default: () => [] },
|
|
12
12
|
cellSlots: { type: Object, required: false, default: void 0 },
|
|
13
13
|
headerSlots: { type: Object, required: false, default: void 0 },
|
|
14
|
-
columnHeaders: { type: Object, required: false, default:
|
|
15
|
-
columnWidths: { type: Object, required: false, default:
|
|
14
|
+
columnHeaders: { type: Object, required: false, default: () => ({}) },
|
|
15
|
+
columnWidths: { type: Object, required: false, default: () => ({}) },
|
|
16
16
|
emptyStateText: { type: String, required: false, default: "no result" },
|
|
17
17
|
emptyFilterStateText: { type: String, required: false, default: "no result found for filter" },
|
|
18
18
|
currentPage: { type: Number, required: false, default: void 0 },
|
|
@@ -20,7 +20,11 @@ const props = defineProps({
|
|
|
20
20
|
sortList: { type: Array, required: false, default: void 0 },
|
|
21
21
|
filter: { type: [Object, null], required: false, default: void 0 },
|
|
22
22
|
selectedRows: { type: Array, required: false, default: void 0 },
|
|
23
|
-
selectAll: { type: Boolean, required: false, default: void 0 }
|
|
23
|
+
selectAll: { type: Boolean, required: false, default: void 0 },
|
|
24
|
+
virtualScroll: { type: Boolean, required: false, default: false },
|
|
25
|
+
itemHeight: { type: Number, required: false, default: 40 },
|
|
26
|
+
viewportHeight: { type: Number, required: false, default: 500 },
|
|
27
|
+
buffer: { type: Number, required: false, default: 5 }
|
|
24
28
|
});
|
|
25
29
|
const emit = defineEmits(["update:currentPage", "update:pageSize", "update:sortList", "update:filter", "update:selectedRows", "update:selectAll", "page-change", "sort-change", "filter-change"]);
|
|
26
30
|
const {
|
|
@@ -57,7 +61,11 @@ const templateProps = computed(() => ({
|
|
|
57
61
|
columnHeaders: props.columnHeaders,
|
|
58
62
|
columnWidths: props.columnWidths,
|
|
59
63
|
emptyStateText: props.emptyStateText,
|
|
60
|
-
emptyFilterStateText: props.emptyFilterStateText
|
|
64
|
+
emptyFilterStateText: props.emptyFilterStateText,
|
|
65
|
+
virtualScroll: props.virtualScroll,
|
|
66
|
+
itemHeight: props.itemHeight,
|
|
67
|
+
viewportHeight: props.viewportHeight,
|
|
68
|
+
buffer: props.buffer
|
|
61
69
|
}));
|
|
62
70
|
const updateSelectedRows = (val) => {
|
|
63
71
|
selectedRows.value = val;
|
|
@@ -17,6 +17,10 @@ interface Props {
|
|
|
17
17
|
filter?: IDataFilter | null;
|
|
18
18
|
selectedRows?: any[];
|
|
19
19
|
selectAll?: boolean;
|
|
20
|
+
virtualScroll?: boolean;
|
|
21
|
+
itemHeight?: number;
|
|
22
|
+
viewportHeight?: number;
|
|
23
|
+
buffer?: number;
|
|
20
24
|
}
|
|
21
25
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
22
26
|
"update:currentPage": (value: number) => any;
|
|
@@ -46,8 +50,12 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
46
50
|
currentPage: number;
|
|
47
51
|
pageSize: number;
|
|
48
52
|
sortList: IDataSort[];
|
|
53
|
+
virtualScroll: boolean;
|
|
54
|
+
itemHeight: number;
|
|
55
|
+
buffer: number;
|
|
49
56
|
visibleFields: Array<string> | null;
|
|
50
57
|
rowActions: Array<IKDatatableAction>;
|
|
58
|
+
viewportHeight: number;
|
|
51
59
|
cellSlots: Record<string, any>;
|
|
52
60
|
headerSlots: Record<string, any>;
|
|
53
61
|
columnHeaders: Record<string, string>;
|
|
@@ -11,6 +11,10 @@ export interface KDatatableProps {
|
|
|
11
11
|
filter?: IDataFilter | null;
|
|
12
12
|
selectedRows?: any[];
|
|
13
13
|
selectAll?: boolean;
|
|
14
|
+
virtualScroll?: boolean;
|
|
15
|
+
itemHeight?: number;
|
|
16
|
+
viewportHeight?: number;
|
|
17
|
+
buffer?: number;
|
|
14
18
|
}
|
|
15
19
|
export type KDatatableEmits = {
|
|
16
20
|
(e: 'update:currentPage', page: number): void;
|
|
@@ -27,6 +31,10 @@ export declare const KDatatableDefaultProps: {
|
|
|
27
31
|
visibleFields: null;
|
|
28
32
|
emptyStateText: string;
|
|
29
33
|
emptyFilterStateText: string;
|
|
34
|
+
virtualScroll: boolean;
|
|
35
|
+
itemHeight: number;
|
|
36
|
+
viewportHeight: number;
|
|
37
|
+
buffer: number;
|
|
30
38
|
};
|
|
31
39
|
export declare function useKDatatableLogic(props: KDatatableProps, emit?: KDatatableEmits): {
|
|
32
40
|
selectedRows: Ref<any[], any[]>;
|
|
@@ -3,11 +3,16 @@ import { useDataProvider } from "../../composables/useDataProvider.js";
|
|
|
3
3
|
export const KDatatableDefaultProps = {
|
|
4
4
|
visibleFields: null,
|
|
5
5
|
emptyStateText: "no result",
|
|
6
|
-
emptyFilterStateText: "no result found for filter"
|
|
6
|
+
emptyFilterStateText: "no result found for filter",
|
|
7
|
+
virtualScroll: false,
|
|
8
|
+
itemHeight: 40,
|
|
9
|
+
viewportHeight: 500,
|
|
10
|
+
buffer: 5
|
|
7
11
|
};
|
|
8
12
|
export function useKDatatableLogic(props, emit) {
|
|
9
13
|
const {
|
|
10
14
|
pageData,
|
|
15
|
+
virtualRows,
|
|
11
16
|
selectedRows: dpSelectedRows,
|
|
12
17
|
selectAll: dpSelectAll,
|
|
13
18
|
currentPage: dpCurrentPage,
|
|
@@ -119,9 +124,25 @@ export function useKDatatableLogic(props, emit) {
|
|
|
119
124
|
emit?.("update:filter", newVal);
|
|
120
125
|
emit?.("filter-change", newVal);
|
|
121
126
|
}, { deep: true });
|
|
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
|
+
};
|
|
122
142
|
watch(() => selectAll.value, (newVal) => {
|
|
123
|
-
if (isInternalUpdating) return;
|
|
124
|
-
|
|
143
|
+
if (isInternalUpdating || newVal === lastSyncedSelectAll) return;
|
|
144
|
+
lastSyncedSelectAll = newVal;
|
|
145
|
+
const currentRows = getTargetRows();
|
|
125
146
|
if (newVal === false) {
|
|
126
147
|
const pageIds = new Set(currentRows.map(getRowId));
|
|
127
148
|
selectedRows.value = selectedRows.value.filter((r) => !pageIds.has(getRowId(r)));
|
|
@@ -135,9 +156,10 @@ export function useKDatatableLogic(props, emit) {
|
|
|
135
156
|
syncToProvider();
|
|
136
157
|
});
|
|
137
158
|
watch([pageRows, () => selectedRows.value], () => {
|
|
138
|
-
const currentRows =
|
|
159
|
+
const currentRows = getTargetRows();
|
|
139
160
|
if (currentRows.length === 0) {
|
|
140
161
|
if (selectAll.value) {
|
|
162
|
+
lastSyncedSelectAll = false;
|
|
141
163
|
isInternalUpdating = true;
|
|
142
164
|
selectAll.value = false;
|
|
143
165
|
isInternalUpdating = false;
|
|
@@ -149,6 +171,7 @@ export function useKDatatableLogic(props, emit) {
|
|
|
149
171
|
const selectedIds = new Set(selectedRows.value.map(getRowId));
|
|
150
172
|
const allCurrentSelected = currentRows.every((r) => selectedIds.has(getRowId(r)));
|
|
151
173
|
if (selectAll.value !== allCurrentSelected) {
|
|
174
|
+
lastSyncedSelectAll = allCurrentSelected;
|
|
152
175
|
isInternalUpdating = true;
|
|
153
176
|
selectAll.value = allCurrentSelected;
|
|
154
177
|
isInternalUpdating = false;
|
|
@@ -156,7 +179,7 @@ export function useKDatatableLogic(props, emit) {
|
|
|
156
179
|
}
|
|
157
180
|
emit?.("update:selectedRows", selectedRows.value);
|
|
158
181
|
syncToProvider();
|
|
159
|
-
}, { immediate: true
|
|
182
|
+
}, { immediate: true });
|
|
160
183
|
return {
|
|
161
184
|
selectedRows,
|
|
162
185
|
selectAll,
|
|
@@ -55,6 +55,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
55
55
|
};
|
|
56
56
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
57
57
|
"update:modelValue": (value: string | Date) => any;
|
|
58
|
+
change: (value: string | Date) => any;
|
|
59
|
+
blur: (event: FocusEvent) => any;
|
|
58
60
|
"update:isOpen": (value: boolean) => any;
|
|
59
61
|
"update:maskedModel": (value: string) => any;
|
|
60
62
|
"update:calendarShow": (value: boolean) => any;
|
|
@@ -115,6 +117,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
115
117
|
};
|
|
116
118
|
}>> & Readonly<{
|
|
117
119
|
"onUpdate:modelValue"?: ((value: string | Date) => any) | undefined;
|
|
120
|
+
onChange?: ((value: string | Date) => any) | undefined;
|
|
121
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
118
122
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
119
123
|
"onUpdate:maskedModel"?: ((value: string) => any) | undefined;
|
|
120
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"]);
|
|
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,
|
|
@@ -36,6 +36,9 @@ const templateProps = computed(() => ({
|
|
|
36
36
|
const handleClear = () => {
|
|
37
37
|
_date.value = "";
|
|
38
38
|
maskedModel.value = "";
|
|
39
|
+
emit("update:day", "");
|
|
40
|
+
emit("update:modelValue", "");
|
|
41
|
+
emit("change", "");
|
|
39
42
|
};
|
|
40
43
|
const updateMaskedModel = (val) => {
|
|
41
44
|
maskedModel.value = val;
|
|
@@ -53,6 +56,7 @@ watch(_date, (newDate) => {
|
|
|
53
56
|
if (d1 !== d2 && d1 !== d3) {
|
|
54
57
|
emit("update:day", newDate);
|
|
55
58
|
emit("update:modelValue", newDate);
|
|
59
|
+
emit("change", newDate);
|
|
56
60
|
}
|
|
57
61
|
});
|
|
58
62
|
watch(calendarShow, (newVal) => {
|
|
@@ -66,5 +70,6 @@ component(
|
|
|
66
70
|
v-bind="{ ...templateProps, ...$attrs }"
|
|
67
71
|
@update:maskedModel="updateMaskedModel"
|
|
68
72
|
@update:calendarShow="updateCalendarShow"
|
|
73
|
+
@blur="emit('blur', $event)"
|
|
69
74
|
)
|
|
70
75
|
</template>
|
|
@@ -55,6 +55,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
55
55
|
};
|
|
56
56
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
57
57
|
"update:modelValue": (value: string | Date) => any;
|
|
58
|
+
change: (value: string | Date) => any;
|
|
59
|
+
blur: (event: FocusEvent) => any;
|
|
58
60
|
"update:isOpen": (value: boolean) => any;
|
|
59
61
|
"update:maskedModel": (value: string) => any;
|
|
60
62
|
"update:calendarShow": (value: boolean) => any;
|
|
@@ -115,6 +117,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
115
117
|
};
|
|
116
118
|
}>> & Readonly<{
|
|
117
119
|
"onUpdate:modelValue"?: ((value: string | Date) => any) | undefined;
|
|
120
|
+
onChange?: ((value: string | Date) => any) | undefined;
|
|
121
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
118
122
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
119
123
|
"onUpdate:maskedModel"?: ((value: string) => any) | undefined;
|
|
120
124
|
"onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
|
|
@@ -106,12 +106,6 @@ export function useKDatePickerLogic(props) {
|
|
|
106
106
|
formattedDate = formattedDate.replace("YYYY", year.toString());
|
|
107
107
|
return formattedDate;
|
|
108
108
|
};
|
|
109
|
-
onMounted(() => {
|
|
110
|
-
syncValue(props.modelValue || props.day);
|
|
111
|
-
if (props.isOpen) {
|
|
112
|
-
calendarShow.value = props.isOpen;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
109
|
const syncValue = (val) => {
|
|
116
110
|
if (val === void 0 || val === null || val === "") {
|
|
117
111
|
_date.value = "";
|
|
@@ -127,6 +121,13 @@ export function useKDatePickerLogic(props) {
|
|
|
127
121
|
maskedModel.value = "";
|
|
128
122
|
}
|
|
129
123
|
};
|
|
124
|
+
syncValue(props.modelValue || props.day);
|
|
125
|
+
onMounted(() => {
|
|
126
|
+
syncValue(props.modelValue || props.day);
|
|
127
|
+
if (props.isOpen) {
|
|
128
|
+
calendarShow.value = props.isOpen;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
130
131
|
watch(() => props.day, (newDay) => {
|
|
131
132
|
if (newDay !== void 0) {
|
|
132
133
|
const d1 = newDay && (newDay instanceof Date || typeof newDay === "string") ? newDay instanceof Date ? newDay.getTime() : new Date(newDay).getTime() : 0;
|
|
@@ -170,12 +170,6 @@ export function useKDateTimePickerLogic(props) {
|
|
|
170
170
|
}
|
|
171
171
|
return /* @__PURE__ */ new Date();
|
|
172
172
|
});
|
|
173
|
-
onMounted(() => {
|
|
174
|
-
syncValue(props.modelValue || props.day);
|
|
175
|
-
if (props.isOpen) {
|
|
176
|
-
calendarShow.value = props.isOpen;
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
173
|
const syncValue = (val) => {
|
|
180
174
|
if (val === void 0 || val === null || val === "") {
|
|
181
175
|
_date.value = "";
|
|
@@ -201,6 +195,13 @@ export function useKDateTimePickerLogic(props) {
|
|
|
201
195
|
}
|
|
202
196
|
updateMaskedModel();
|
|
203
197
|
};
|
|
198
|
+
syncValue(props.modelValue || props.day);
|
|
199
|
+
onMounted(() => {
|
|
200
|
+
syncValue(props.modelValue || props.day);
|
|
201
|
+
if (props.isOpen) {
|
|
202
|
+
calendarShow.value = props.isOpen;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
204
205
|
watch(() => props.modelValue, (newVal) => {
|
|
205
206
|
if (newVal !== void 0) {
|
|
206
207
|
const d1 = newVal && (newVal instanceof Date || typeof newVal === "string") ? newVal instanceof Date ? newVal.getTime() : new Date(newVal).getTime() : 0;
|
|
@@ -23,6 +23,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
23
23
|
type: import("vue").PropType<import("./KDropdown.logic.js").KDropdownDirection>;
|
|
24
24
|
default: string;
|
|
25
25
|
};
|
|
26
|
+
maxHeight: {
|
|
27
|
+
type: NumberConstructor;
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
26
30
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
27
31
|
"update:isOpen": (value: boolean) => any;
|
|
28
32
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -50,6 +54,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
50
54
|
type: import("vue").PropType<import("./KDropdown.logic.js").KDropdownDirection>;
|
|
51
55
|
default: string;
|
|
52
56
|
};
|
|
57
|
+
maxHeight: {
|
|
58
|
+
type: NumberConstructor;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
53
61
|
}>> & Readonly<{
|
|
54
62
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
55
63
|
}>, {
|
|
@@ -57,6 +65,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
57
65
|
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
58
66
|
teleportTo: string;
|
|
59
67
|
fullWidth: boolean;
|
|
68
|
+
maxHeight: number;
|
|
60
69
|
align: import("./KDropdown.logic.js").KDropdownAlign;
|
|
61
70
|
anchorEl: HTMLElement;
|
|
62
71
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -23,6 +23,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
23
23
|
type: import("vue").PropType<import("./KDropdown.logic.js").KDropdownDirection>;
|
|
24
24
|
default: string;
|
|
25
25
|
};
|
|
26
|
+
maxHeight: {
|
|
27
|
+
type: NumberConstructor;
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
26
30
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
27
31
|
"update:isOpen": (value: boolean) => any;
|
|
28
32
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -50,6 +54,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
50
54
|
type: import("vue").PropType<import("./KDropdown.logic.js").KDropdownDirection>;
|
|
51
55
|
default: string;
|
|
52
56
|
};
|
|
57
|
+
maxHeight: {
|
|
58
|
+
type: NumberConstructor;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
53
61
|
}>> & Readonly<{
|
|
54
62
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
55
63
|
}>, {
|
|
@@ -57,6 +65,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
57
65
|
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
58
66
|
teleportTo: string;
|
|
59
67
|
fullWidth: boolean;
|
|
68
|
+
maxHeight: number;
|
|
60
69
|
align: import("./KDropdown.logic.js").KDropdownAlign;
|
|
61
70
|
anchorEl: HTMLElement;
|
|
62
71
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -8,6 +8,7 @@ export interface KDropdownProps {
|
|
|
8
8
|
teleportTo?: string;
|
|
9
9
|
align?: KDropdownAlign;
|
|
10
10
|
direction?: KDropdownDirection;
|
|
11
|
+
maxHeight?: number;
|
|
11
12
|
}
|
|
12
13
|
export interface KDropdownEmits {
|
|
13
14
|
(e: 'update:isOpen', value: boolean): void;
|
|
@@ -37,6 +38,10 @@ export declare const KDropdownDefaultProps: {
|
|
|
37
38
|
type: PropType<KDropdownDirection>;
|
|
38
39
|
default: string;
|
|
39
40
|
};
|
|
41
|
+
maxHeight: {
|
|
42
|
+
type: NumberConstructor;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
40
45
|
};
|
|
41
46
|
export declare function useKDropdownLogic(props: KDropdownProps, emit: KDropdownEmits): {
|
|
42
47
|
open: Ref<boolean, boolean>;
|
|
@@ -24,6 +24,10 @@ export const KDropdownDefaultProps = {
|
|
|
24
24
|
direction: {
|
|
25
25
|
type: String,
|
|
26
26
|
default: "auto"
|
|
27
|
+
},
|
|
28
|
+
maxHeight: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: void 0
|
|
27
31
|
}
|
|
28
32
|
};
|
|
29
33
|
export function useKDropdownLogic(props, emit) {
|
|
@@ -101,12 +105,8 @@ export function useKDropdownLogic(props, emit) {
|
|
|
101
105
|
const rect = el.getBoundingClientRect();
|
|
102
106
|
const viewportWidth = document.documentElement.clientWidth;
|
|
103
107
|
const viewportHeight = document.documentElement.clientHeight;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
viewportWidth,
|
|
107
|
-
viewportHeight,
|
|
108
|
-
props.direction ?? "auto"
|
|
109
|
-
);
|
|
108
|
+
const existingDir = open.value ? dropdownRect.value.resolvedDirection : void 0;
|
|
109
|
+
const resolvedDir = props.direction && props.direction !== "auto" ? resolveDirection(rect, viewportWidth, viewportHeight, props.direction) : existingDir || resolveDirection(rect, viewportWidth, viewportHeight, "auto");
|
|
110
110
|
const resolvedAl = resolveAlign(
|
|
111
111
|
rect,
|
|
112
112
|
viewportWidth,
|
|
@@ -117,7 +117,8 @@ export function useKDropdownLogic(props, emit) {
|
|
|
117
117
|
const spaceBelow = viewportHeight - rect.bottom;
|
|
118
118
|
const spaceAbove = rect.top;
|
|
119
119
|
const rawSpace = resolvedDir === "top" ? spaceAbove : spaceBelow;
|
|
120
|
-
const
|
|
120
|
+
const requestedMax = props.maxHeight ?? 400;
|
|
121
|
+
const maxHeight = Math.max(100, Math.min(requestedMax, rawSpace - 8));
|
|
121
122
|
dropdownRect.value = {
|
|
122
123
|
top: rect.bottom,
|
|
123
124
|
left: rect.left,
|
|
@@ -164,9 +165,11 @@ export function useKDropdownLogic(props, emit) {
|
|
|
164
165
|
);
|
|
165
166
|
onMounted(() => {
|
|
166
167
|
window.addEventListener("scroll", repositionOnScroll, true);
|
|
168
|
+
window.addEventListener("resize", repositionOnScroll);
|
|
167
169
|
});
|
|
168
170
|
onUnmounted(() => {
|
|
169
171
|
window.removeEventListener("scroll", repositionOnScroll, true);
|
|
172
|
+
window.removeEventListener("resize", repositionOnScroll);
|
|
170
173
|
});
|
|
171
174
|
return {
|
|
172
175
|
open,
|