@katlux/toolkit 0.1.0-beta.5 → 0.1.0-beta.50
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/usePresetComponent.mjs +21 -16
- package/dist/module.cjs +52 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +52 -0
- package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +11 -12
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +11 -12
- package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +1 -0
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +25 -10
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +18 -10
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +6 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +18 -10
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +78 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +8 -3
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +149 -0
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue +65 -0
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +149 -0
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +116 -0
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.js +149 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +56 -8
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +23 -3
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +56 -8
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +22 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +89 -7
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +54 -8
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +23 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +54 -8
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +22 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +148 -7
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +18 -0
- package/dist/runtime/components/KDropdown/KDropdown.global.vue +13 -4
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +18 -0
- package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +28 -1
- package/dist/runtime/components/KDropdown/KDropdown.logic.js +85 -4
- package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +7 -56
- package/dist/runtime/components/KGrid/KGrid.global.vue +9 -2
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +7 -56
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +20 -0
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue +25 -12
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +20 -0
- package/dist/runtime/components/KHourPicker/KHourPicker.logic.d.ts +14 -3
- package/dist/runtime/components/KHourPicker/KHourPicker.logic.js +25 -10
- package/dist/runtime/components/KHourSelect/KHourSelect.logic.js +4 -1
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.logic.d.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.logic.js +13 -8
- package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +3 -3
- package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +3 -3
- package/dist/runtime/components/KLoader/KLoader.logic.d.ts +8 -1
- package/dist/runtime/components/KLoader/KLoader.logic.js +1 -0
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue +1 -1
- package/dist/runtime/components/KModal/KModal.global.vue +4 -1
- package/dist/runtime/components/KModal/KModal.logic.d.ts +3 -1
- package/dist/runtime/components/KModal/KModal.logic.js +6 -2
- package/dist/runtime/components/KPanel/KPanel.global.d.vue.ts +5 -28
- package/dist/runtime/components/KPanel/KPanel.global.vue +12 -4
- package/dist/runtime/components/KPanel/KPanel.global.vue.d.ts +5 -28
- package/dist/runtime/components/KPanel/KPanel.logic.d.ts +10 -0
- package/dist/runtime/components/KPanel/KPanel.logic.js +8 -0
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +15 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +5 -4
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +15 -2
- package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +10 -4
- package/dist/runtime/components/KTextbox/KTextbox.logic.js +12 -5
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +77 -0
- package/dist/runtime/composables/usePresetComponent.d.ts +16 -0
- package/dist/runtime/composables/usePresetComponent.js +21 -16
- package/dist/runtime/presets/default/assets/scss/css-variables.css +64 -13
- package/dist/runtime/presets/default/assets/scss/css-variables.scss +286 -0
- package/dist/runtime/presets/default/assets/scss/docs.scss +52 -0
- package/dist/runtime/presets/default/assets/scss/index.css +72 -13
- package/dist/runtime/presets/default/assets/scss/index.scss +12 -0
- package/dist/runtime/presets/default/assets/scss/mixins.scss +94 -0
- package/dist/runtime/presets/default/assets/scss/reset.scss +16 -0
- package/dist/runtime/presets/default/components/KAccordion/KAccordion.vue +5 -2
- package/dist/runtime/presets/default/components/KAccordion/KAccordionItem.vue +40 -37
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +29 -22
- package/dist/runtime/presets/default/components/KButton/KButton.vue +147 -428
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +57 -53
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +189 -161
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +46 -36
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +90 -70
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +78 -60
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +27 -0
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +190 -0
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +27 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +40 -31
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +110 -92
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +44 -25
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +68 -52
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +8 -0
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +46 -25
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +8 -0
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +337 -241
- package/dist/runtime/presets/default/components/KGantt/KGanttRuler.vue +40 -35
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +170 -140
- package/dist/runtime/presets/default/components/KGrid/KGrid.vue +62 -60
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +44 -28
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +6 -2
- package/dist/runtime/presets/default/components/KHourSelect/KHourSelect.vue +34 -28
- package/dist/runtime/presets/default/components/KIcon/KIcon.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KIcon/KIcon.vue +31 -22
- package/dist/runtime/presets/default/components/KIcon/KIcon.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +53 -47
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +113 -84
- package/dist/runtime/presets/default/components/KModal/KModal.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KModal/KModal.vue +64 -35
- package/dist/runtime/presets/default/components/KModal/KModal.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KPagination/KPagination.vue +42 -40
- package/dist/runtime/presets/default/components/KPanel/KPanel.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KPanel/KPanel.vue +95 -34
- package/dist/runtime/presets/default/components/KPanel/KPanel.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +30 -29
- package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +158 -125
- package/dist/runtime/presets/default/components/KSlider/KSlider.vue +123 -100
- package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +40 -37
- package/dist/runtime/presets/default/components/KTabs/KTabs.vue +9 -6
- package/dist/runtime/presets/default/components/KTextarea/KTextarea.vue +23 -20
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +2 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +49 -36
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +2 -1
- package/dist/runtime/presets/default/components/KTree/KTree.vue +102 -80
- package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +55 -34
- package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +31 -30
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +34 -27
- package/package.json +5 -5
|
@@ -42,6 +42,10 @@ export const KComboboxDefaultProps = {
|
|
|
42
42
|
modelValue: {
|
|
43
43
|
type: [Object, Array],
|
|
44
44
|
default: null
|
|
45
|
+
},
|
|
46
|
+
teleportTo: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: void 0
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
51
|
export function useKComboboxLogic(props, emit) {
|
|
@@ -102,6 +106,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
102
106
|
watch(
|
|
103
107
|
() => searchtext.value,
|
|
104
108
|
(newText) => {
|
|
109
|
+
if (!props.dataProvider?.filter) return;
|
|
105
110
|
const filter = {
|
|
106
111
|
operator: EDataFilterOperator.In,
|
|
107
112
|
field: { [props.labelField]: newText.trim().toLowerCase() },
|
|
@@ -111,11 +116,11 @@ export function useKComboboxLogic(props, emit) {
|
|
|
111
116
|
}
|
|
112
117
|
);
|
|
113
118
|
const filteredOptions = computed(() => {
|
|
114
|
-
return props.dataProvider
|
|
119
|
+
return props.dataProvider?.pageData.value || [];
|
|
115
120
|
});
|
|
116
121
|
onMounted(() => {
|
|
117
122
|
selectedItems.value = Array.isArray(props.modelValue) ? props.modelValue : props.modelValue ? [props.modelValue] : null;
|
|
118
|
-
if (props.searchbox) {
|
|
123
|
+
if (props.searchbox && props.dataProvider?.filter) {
|
|
119
124
|
props.dataProvider.filter.value = null;
|
|
120
125
|
}
|
|
121
126
|
});
|
|
@@ -135,6 +140,6 @@ export function useKComboboxLogic(props, emit) {
|
|
|
135
140
|
toggleDropdown,
|
|
136
141
|
closeDropdown,
|
|
137
142
|
filteredOptions,
|
|
138
|
-
loading: props.dataProvider.
|
|
143
|
+
loading: computed(() => props.dataProvider?.loading.value ?? false)
|
|
139
144
|
};
|
|
140
145
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type KCompositeInputProps } from './KCompositeInput.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
selectionValue: {
|
|
4
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
5
|
+
default: null;
|
|
6
|
+
};
|
|
7
|
+
inputValue: {
|
|
8
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").ICompositeItem[]>;
|
|
13
|
+
default: () => never[];
|
|
14
|
+
};
|
|
15
|
+
items: {
|
|
16
|
+
type: import("vue").PropType<any[] | import("@katlux/providers").ADataProvider>;
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
type: {
|
|
20
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").CompositeInputType>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
selectionSide: {
|
|
24
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").SelectionSide>;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
inputType: {
|
|
28
|
+
type: import("vue").PropType<KCompositeInputProps["inputType"]>;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
mask: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
labelField: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
valueField: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
placeholder: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
inputPlaceholder: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
searchbox: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
showClear: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
teleportTo: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
64
|
+
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
65
|
+
"update:selectionValue": (value: any) => any;
|
|
66
|
+
"update:inputValue": (value: any) => any;
|
|
67
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
68
|
+
selectionValue: {
|
|
69
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
70
|
+
default: null;
|
|
71
|
+
};
|
|
72
|
+
inputValue: {
|
|
73
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
74
|
+
default: string;
|
|
75
|
+
};
|
|
76
|
+
modelValue: {
|
|
77
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").ICompositeItem[]>;
|
|
78
|
+
default: () => never[];
|
|
79
|
+
};
|
|
80
|
+
items: {
|
|
81
|
+
type: import("vue").PropType<any[] | import("@katlux/providers").ADataProvider>;
|
|
82
|
+
required: boolean;
|
|
83
|
+
};
|
|
84
|
+
type: {
|
|
85
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").CompositeInputType>;
|
|
86
|
+
default: string;
|
|
87
|
+
};
|
|
88
|
+
selectionSide: {
|
|
89
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").SelectionSide>;
|
|
90
|
+
default: string;
|
|
91
|
+
};
|
|
92
|
+
inputType: {
|
|
93
|
+
type: import("vue").PropType<KCompositeInputProps["inputType"]>;
|
|
94
|
+
default: string;
|
|
95
|
+
};
|
|
96
|
+
mask: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
labelField: {
|
|
101
|
+
type: StringConstructor;
|
|
102
|
+
default: string;
|
|
103
|
+
};
|
|
104
|
+
valueField: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
placeholder: {
|
|
109
|
+
type: StringConstructor;
|
|
110
|
+
default: string;
|
|
111
|
+
};
|
|
112
|
+
inputPlaceholder: {
|
|
113
|
+
type: StringConstructor;
|
|
114
|
+
default: string;
|
|
115
|
+
};
|
|
116
|
+
searchbox: {
|
|
117
|
+
type: BooleanConstructor;
|
|
118
|
+
default: boolean;
|
|
119
|
+
};
|
|
120
|
+
showClear: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: boolean;
|
|
123
|
+
};
|
|
124
|
+
teleportTo: {
|
|
125
|
+
type: StringConstructor;
|
|
126
|
+
default: undefined;
|
|
127
|
+
};
|
|
128
|
+
}>> & Readonly<{
|
|
129
|
+
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
130
|
+
"onUpdate:selectionValue"?: ((value: any) => any) | undefined;
|
|
131
|
+
"onUpdate:inputValue"?: ((value: any) => any) | undefined;
|
|
132
|
+
}>, {
|
|
133
|
+
type: import("./KCompositeInput.logic.js").CompositeInputType;
|
|
134
|
+
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
135
|
+
inputType: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
|
|
136
|
+
selectionValue: string | number | Record<string, any> | unknown[];
|
|
137
|
+
inputValue: string | number | Record<string, any> | unknown[];
|
|
138
|
+
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
139
|
+
mask: string;
|
|
140
|
+
labelField: string;
|
|
141
|
+
valueField: string;
|
|
142
|
+
placeholder: string;
|
|
143
|
+
inputPlaceholder: string;
|
|
144
|
+
searchbox: boolean;
|
|
145
|
+
showClear: boolean;
|
|
146
|
+
teleportTo: string;
|
|
147
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
148
|
+
declare const _default: typeof __VLS_export;
|
|
149
|
+
export default _default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, watch, shallowRef, ref, onMounted } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
useKCompositeInputLogic,
|
|
5
|
+
KCompositeInputDefaultProps
|
|
6
|
+
} from "./KCompositeInput.logic";
|
|
7
|
+
import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
8
|
+
import KCompositeInputDefault from "../../presets/default/components/KCompositeInput/KCompositeInput.vue";
|
|
9
|
+
import { CFlatClientDataProvider } from "@katlux/providers";
|
|
10
|
+
const props = defineProps(KCompositeInputDefaultProps);
|
|
11
|
+
const emit = defineEmits(["update:selectionValue", "update:inputValue", "update:modelValue"]);
|
|
12
|
+
const internalDataProvider = shallowRef(null);
|
|
13
|
+
function updateDataProvider(items) {
|
|
14
|
+
if (Array.isArray(items)) {
|
|
15
|
+
const provider = new CFlatClientDataProvider();
|
|
16
|
+
provider.setData(items.map((item) => {
|
|
17
|
+
if (typeof item === "string") {
|
|
18
|
+
return { [props.labelField || "label"]: item, [props.valueField || "value"]: item };
|
|
19
|
+
}
|
|
20
|
+
return item;
|
|
21
|
+
}));
|
|
22
|
+
internalDataProvider.value = provider;
|
|
23
|
+
} else {
|
|
24
|
+
internalDataProvider.value = items;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
watch(() => props.items, (newItems) => {
|
|
28
|
+
updateDataProvider(newItems);
|
|
29
|
+
}, { immediate: true });
|
|
30
|
+
const {
|
|
31
|
+
internalSelectionValue,
|
|
32
|
+
internalInputValue,
|
|
33
|
+
selectionProps,
|
|
34
|
+
inputProps
|
|
35
|
+
} = useKCompositeInputLogic(props, emit);
|
|
36
|
+
const presetComponent = usePresetComponent("KCompositeInput", KCompositeInputDefault);
|
|
37
|
+
const templateProps = computed(() => ({
|
|
38
|
+
...props,
|
|
39
|
+
dataProvider: internalDataProvider.value,
|
|
40
|
+
selectionValue: internalSelectionValue.value,
|
|
41
|
+
inputValue: internalInputValue.value,
|
|
42
|
+
modelValue: props.modelValue,
|
|
43
|
+
// Determine if searchbox is needed (> 10 items)
|
|
44
|
+
searchbox: Array.isArray(props.items) ? props.items.length > 10 : true
|
|
45
|
+
}));
|
|
46
|
+
function updateSelection(val) {
|
|
47
|
+
internalSelectionValue.value = val;
|
|
48
|
+
}
|
|
49
|
+
function updateInput(val) {
|
|
50
|
+
internalInputValue.value = val;
|
|
51
|
+
}
|
|
52
|
+
function updateModelValue(val) {
|
|
53
|
+
emit("update:modelValue", val);
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template lang="pug">
|
|
58
|
+
component(
|
|
59
|
+
:is="presetComponent"
|
|
60
|
+
v-bind="{...templateProps, ...$attrs}"
|
|
61
|
+
@update:selectionValue="updateSelection"
|
|
62
|
+
@update:inputValue="updateInput"
|
|
63
|
+
@update:modelValue="updateModelValue"
|
|
64
|
+
)
|
|
65
|
+
</template>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type KCompositeInputProps } from './KCompositeInput.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
selectionValue: {
|
|
4
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
5
|
+
default: null;
|
|
6
|
+
};
|
|
7
|
+
inputValue: {
|
|
8
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").ICompositeItem[]>;
|
|
13
|
+
default: () => never[];
|
|
14
|
+
};
|
|
15
|
+
items: {
|
|
16
|
+
type: import("vue").PropType<any[] | import("@katlux/providers").ADataProvider>;
|
|
17
|
+
required: boolean;
|
|
18
|
+
};
|
|
19
|
+
type: {
|
|
20
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").CompositeInputType>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
selectionSide: {
|
|
24
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").SelectionSide>;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
inputType: {
|
|
28
|
+
type: import("vue").PropType<KCompositeInputProps["inputType"]>;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
mask: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
labelField: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
valueField: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
placeholder: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
inputPlaceholder: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
searchbox: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
showClear: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
teleportTo: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
64
|
+
"update:modelValue": (value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any;
|
|
65
|
+
"update:selectionValue": (value: any) => any;
|
|
66
|
+
"update:inputValue": (value: any) => any;
|
|
67
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
68
|
+
selectionValue: {
|
|
69
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
70
|
+
default: null;
|
|
71
|
+
};
|
|
72
|
+
inputValue: {
|
|
73
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
74
|
+
default: string;
|
|
75
|
+
};
|
|
76
|
+
modelValue: {
|
|
77
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").ICompositeItem[]>;
|
|
78
|
+
default: () => never[];
|
|
79
|
+
};
|
|
80
|
+
items: {
|
|
81
|
+
type: import("vue").PropType<any[] | import("@katlux/providers").ADataProvider>;
|
|
82
|
+
required: boolean;
|
|
83
|
+
};
|
|
84
|
+
type: {
|
|
85
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").CompositeInputType>;
|
|
86
|
+
default: string;
|
|
87
|
+
};
|
|
88
|
+
selectionSide: {
|
|
89
|
+
type: import("vue").PropType<import("./KCompositeInput.logic.js").SelectionSide>;
|
|
90
|
+
default: string;
|
|
91
|
+
};
|
|
92
|
+
inputType: {
|
|
93
|
+
type: import("vue").PropType<KCompositeInputProps["inputType"]>;
|
|
94
|
+
default: string;
|
|
95
|
+
};
|
|
96
|
+
mask: {
|
|
97
|
+
type: StringConstructor;
|
|
98
|
+
default: string;
|
|
99
|
+
};
|
|
100
|
+
labelField: {
|
|
101
|
+
type: StringConstructor;
|
|
102
|
+
default: string;
|
|
103
|
+
};
|
|
104
|
+
valueField: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: string;
|
|
107
|
+
};
|
|
108
|
+
placeholder: {
|
|
109
|
+
type: StringConstructor;
|
|
110
|
+
default: string;
|
|
111
|
+
};
|
|
112
|
+
inputPlaceholder: {
|
|
113
|
+
type: StringConstructor;
|
|
114
|
+
default: string;
|
|
115
|
+
};
|
|
116
|
+
searchbox: {
|
|
117
|
+
type: BooleanConstructor;
|
|
118
|
+
default: boolean;
|
|
119
|
+
};
|
|
120
|
+
showClear: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: boolean;
|
|
123
|
+
};
|
|
124
|
+
teleportTo: {
|
|
125
|
+
type: StringConstructor;
|
|
126
|
+
default: undefined;
|
|
127
|
+
};
|
|
128
|
+
}>> & Readonly<{
|
|
129
|
+
"onUpdate:modelValue"?: ((value: import("./KCompositeInput.logic.js").ICompositeItem[]) => any) | undefined;
|
|
130
|
+
"onUpdate:selectionValue"?: ((value: any) => any) | undefined;
|
|
131
|
+
"onUpdate:inputValue"?: ((value: any) => any) | undefined;
|
|
132
|
+
}>, {
|
|
133
|
+
type: import("./KCompositeInput.logic.js").CompositeInputType;
|
|
134
|
+
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
135
|
+
inputType: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
|
|
136
|
+
selectionValue: string | number | Record<string, any> | unknown[];
|
|
137
|
+
inputValue: string | number | Record<string, any> | unknown[];
|
|
138
|
+
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
139
|
+
mask: string;
|
|
140
|
+
labelField: string;
|
|
141
|
+
valueField: string;
|
|
142
|
+
placeholder: string;
|
|
143
|
+
inputPlaceholder: string;
|
|
144
|
+
searchbox: boolean;
|
|
145
|
+
showClear: boolean;
|
|
146
|
+
teleportTo: string;
|
|
147
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
148
|
+
declare const _default: typeof __VLS_export;
|
|
149
|
+
export default _default;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import type { ADataProvider } from '@katlux/providers';
|
|
3
|
+
export type CompositeInputType = 'textbox' | 'textarea' | 'maskedtextbox' | 'combobox' | 'datepicker' | 'datetimepicker' | 'hourpicker';
|
|
4
|
+
export type SelectionSide = 'left' | 'right';
|
|
5
|
+
export interface ICompositeItem {
|
|
6
|
+
selection: any;
|
|
7
|
+
value: any;
|
|
8
|
+
}
|
|
9
|
+
export interface KCompositeInputProps {
|
|
10
|
+
selectionValue: any;
|
|
11
|
+
inputValue: any;
|
|
12
|
+
modelValue?: ICompositeItem[];
|
|
13
|
+
items: any[] | ADataProvider;
|
|
14
|
+
type?: CompositeInputType;
|
|
15
|
+
selectionSide?: SelectionSide;
|
|
16
|
+
inputType?: 'text' | 'password' | 'email' | 'url' | 'tel' | 'search' | 'number';
|
|
17
|
+
mask?: string;
|
|
18
|
+
labelField?: string;
|
|
19
|
+
valueField?: string;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
inputPlaceholder?: string;
|
|
22
|
+
searchbox?: boolean;
|
|
23
|
+
showClear?: boolean;
|
|
24
|
+
teleportTo?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface KCompositeInputEmits {
|
|
27
|
+
(e: 'update:selectionValue', value: any): void;
|
|
28
|
+
(e: 'update:inputValue', value: any): void;
|
|
29
|
+
(e: 'update:modelValue', value: ICompositeItem[]): void;
|
|
30
|
+
}
|
|
31
|
+
export declare const KCompositeInputDefaultProps: {
|
|
32
|
+
selectionValue: {
|
|
33
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
34
|
+
default: null;
|
|
35
|
+
};
|
|
36
|
+
inputValue: {
|
|
37
|
+
type: (ObjectConstructor | ArrayConstructor | NumberConstructor | StringConstructor)[];
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
modelValue: {
|
|
41
|
+
type: PropType<ICompositeItem[]>;
|
|
42
|
+
default: () => never[];
|
|
43
|
+
};
|
|
44
|
+
items: {
|
|
45
|
+
type: PropType<any[] | ADataProvider>;
|
|
46
|
+
required: boolean;
|
|
47
|
+
};
|
|
48
|
+
type: {
|
|
49
|
+
type: PropType<CompositeInputType>;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
selectionSide: {
|
|
53
|
+
type: PropType<SelectionSide>;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
inputType: {
|
|
57
|
+
type: PropType<KCompositeInputProps["inputType"]>;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
mask: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: string;
|
|
63
|
+
};
|
|
64
|
+
labelField: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: string;
|
|
67
|
+
};
|
|
68
|
+
valueField: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
placeholder: {
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
default: string;
|
|
75
|
+
};
|
|
76
|
+
inputPlaceholder: {
|
|
77
|
+
type: StringConstructor;
|
|
78
|
+
default: string;
|
|
79
|
+
};
|
|
80
|
+
searchbox: {
|
|
81
|
+
type: BooleanConstructor;
|
|
82
|
+
default: boolean;
|
|
83
|
+
};
|
|
84
|
+
showClear: {
|
|
85
|
+
type: BooleanConstructor;
|
|
86
|
+
default: boolean;
|
|
87
|
+
};
|
|
88
|
+
teleportTo: {
|
|
89
|
+
type: StringConstructor;
|
|
90
|
+
default: undefined;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export declare function useKCompositeInputLogic(props: KCompositeInputProps, emit: KCompositeInputEmits): {
|
|
94
|
+
internalSelectionValue: import("vue").WritableComputedRef<any, any>;
|
|
95
|
+
internalInputValue: import("vue").WritableComputedRef<any, any>;
|
|
96
|
+
selectionProps: import("vue").ComputedRef<{
|
|
97
|
+
modelValue: any;
|
|
98
|
+
'onUpdate:modelValue': (val: any) => any;
|
|
99
|
+
items: any[] | ADataProvider;
|
|
100
|
+
labelField: string | undefined;
|
|
101
|
+
valueField: string | undefined;
|
|
102
|
+
placeholder: string | undefined;
|
|
103
|
+
searchbox: boolean | undefined;
|
|
104
|
+
closeOnSelect: boolean;
|
|
105
|
+
teleportTo: string | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
inputProps: import("vue").ComputedRef<{
|
|
108
|
+
modelValue: any;
|
|
109
|
+
'onUpdate:modelValue': (val: any) => any;
|
|
110
|
+
placeholder: string;
|
|
111
|
+
type: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
|
|
112
|
+
mask: string | undefined;
|
|
113
|
+
showClear: boolean | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
resolvedSelectionItem: import("vue").ComputedRef<any>;
|
|
116
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { computed, watch } from "vue";
|
|
2
|
+
export const KCompositeInputDefaultProps = {
|
|
3
|
+
selectionValue: {
|
|
4
|
+
type: [String, Number, Object, Array],
|
|
5
|
+
default: null
|
|
6
|
+
},
|
|
7
|
+
inputValue: {
|
|
8
|
+
type: [String, Number, Object, Array],
|
|
9
|
+
default: ""
|
|
10
|
+
},
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: Array,
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
items: {
|
|
16
|
+
type: [Array, Object],
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
type: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "textbox"
|
|
22
|
+
},
|
|
23
|
+
selectionSide: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "left"
|
|
26
|
+
},
|
|
27
|
+
inputType: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "text"
|
|
30
|
+
},
|
|
31
|
+
mask: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: ""
|
|
34
|
+
},
|
|
35
|
+
labelField: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "label"
|
|
38
|
+
},
|
|
39
|
+
valueField: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: "value"
|
|
42
|
+
},
|
|
43
|
+
placeholder: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "Select..."
|
|
46
|
+
},
|
|
47
|
+
inputPlaceholder: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: ""
|
|
50
|
+
},
|
|
51
|
+
searchbox: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
showClear: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
teleportTo: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: void 0
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export function useKCompositeInputLogic(props, emit) {
|
|
65
|
+
const getSelectionKey = (selection) => {
|
|
66
|
+
if (selection && typeof selection === "object" && props.valueField) {
|
|
67
|
+
return selection[props.valueField];
|
|
68
|
+
}
|
|
69
|
+
return selection;
|
|
70
|
+
};
|
|
71
|
+
const resolvedSelectionItem = computed(() => {
|
|
72
|
+
if (props.selectionValue === null || props.selectionValue === void 0) return null;
|
|
73
|
+
if (typeof props.selectionValue === "object") return props.selectionValue;
|
|
74
|
+
if (Array.isArray(props.items)) {
|
|
75
|
+
return props.items.find((item) => getSelectionKey(item) === props.selectionValue) || props.selectionValue;
|
|
76
|
+
}
|
|
77
|
+
return props.selectionValue;
|
|
78
|
+
});
|
|
79
|
+
const internalSelectionValue = computed({
|
|
80
|
+
get: () => resolvedSelectionItem.value,
|
|
81
|
+
set: (val) => {
|
|
82
|
+
const key = getSelectionKey(val);
|
|
83
|
+
emit("update:selectionValue", key);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const internalInputValue = computed({
|
|
87
|
+
get: () => props.inputValue,
|
|
88
|
+
set: (val) => {
|
|
89
|
+
emit("update:inputValue", val);
|
|
90
|
+
updateModelValue(props.selectionValue, val);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
watch(() => props.selectionValue, (newSelection) => {
|
|
94
|
+
const newKey = getSelectionKey(newSelection);
|
|
95
|
+
if (newKey !== void 0 && newKey !== null) {
|
|
96
|
+
const existingItem = props.modelValue?.find((item) => {
|
|
97
|
+
const itemKey = getSelectionKey(item.selection);
|
|
98
|
+
return JSON.stringify(itemKey) === JSON.stringify(newKey) || itemKey === newKey;
|
|
99
|
+
});
|
|
100
|
+
if (existingItem) {
|
|
101
|
+
emit("update:inputValue", existingItem.value);
|
|
102
|
+
} else {
|
|
103
|
+
const defaultValue = props.type?.includes("picker") ? null : "";
|
|
104
|
+
emit("update:inputValue", defaultValue);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
function updateModelValue(selection, value) {
|
|
109
|
+
const selectionKey = getSelectionKey(selection);
|
|
110
|
+
if (selectionKey === void 0 || selectionKey === null) return;
|
|
111
|
+
const currentModel = [...props.modelValue || []];
|
|
112
|
+
const index = currentModel.findIndex((item) => {
|
|
113
|
+
const itemKey = getSelectionKey(item.selection);
|
|
114
|
+
return JSON.stringify(itemKey) === JSON.stringify(selectionKey) || itemKey === selectionKey;
|
|
115
|
+
});
|
|
116
|
+
if (index !== -1) {
|
|
117
|
+
currentModel[index] = { ...currentModel[index], value };
|
|
118
|
+
} else {
|
|
119
|
+
currentModel.push({ selection, value });
|
|
120
|
+
}
|
|
121
|
+
emit("update:modelValue", currentModel);
|
|
122
|
+
}
|
|
123
|
+
const selectionProps = computed(() => ({
|
|
124
|
+
modelValue: internalSelectionValue.value,
|
|
125
|
+
"onUpdate:modelValue": (val) => internalSelectionValue.value = val,
|
|
126
|
+
items: props.items,
|
|
127
|
+
labelField: props.labelField,
|
|
128
|
+
valueField: props.valueField,
|
|
129
|
+
placeholder: props.placeholder,
|
|
130
|
+
searchbox: props.searchbox,
|
|
131
|
+
closeOnSelect: true,
|
|
132
|
+
teleportTo: props.teleportTo
|
|
133
|
+
}));
|
|
134
|
+
const inputProps = computed(() => ({
|
|
135
|
+
modelValue: props.inputValue,
|
|
136
|
+
"onUpdate:modelValue": (val) => internalInputValue.value = val,
|
|
137
|
+
placeholder: props.inputPlaceholder || "",
|
|
138
|
+
type: props.inputType,
|
|
139
|
+
mask: props.mask,
|
|
140
|
+
showClear: props.showClear
|
|
141
|
+
}));
|
|
142
|
+
return {
|
|
143
|
+
internalSelectionValue,
|
|
144
|
+
internalInputValue,
|
|
145
|
+
selectionProps,
|
|
146
|
+
inputProps,
|
|
147
|
+
resolvedSelectionItem
|
|
148
|
+
};
|
|
149
|
+
}
|