@katlux/toolkit 0.1.0-beta.49 → 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.
Files changed (38) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +1 -1
  3. package/dist/runtime/components/KCombobox/KCombobox.global.vue +4 -1
  4. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +1 -1
  5. package/dist/runtime/components/KCombobox/KCombobox.logic.js +2 -2
  6. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +149 -0
  7. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue +65 -0
  8. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +149 -0
  9. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +116 -0
  10. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.js +149 -0
  11. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -2
  12. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +3 -3
  13. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -2
  14. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +26 -32
  15. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
  16. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +4 -10
  17. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
  18. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +16 -9
  19. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
  20. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
  21. package/dist/runtime/components/KIcon/KIcon.logic.js +11 -6
  22. package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +1 -1
  23. package/dist/runtime/components/KTextbox/KTextbox.logic.js +1 -1
  24. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  25. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  26. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
  27. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
  28. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +2 -0
  29. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +11 -3
  30. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +2 -0
  31. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +1 -1
  32. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +27 -0
  33. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +190 -0
  34. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +27 -0
  35. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +0 -1
  36. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -1
  37. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +5 -2
  38. package/package.json +1 -1
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
3
  "configKey": "katluxToolkit",
4
- "version": "0.1.0-beta.49",
4
+ "version": "0.1.0-beta.50",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -95,8 +95,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
95
95
  }>, {
96
96
  disabled: boolean;
97
97
  modelValue: import("@katlux/providers").TDataRow | import("@katlux/providers").TDataRow[] | null;
98
- searchbox: boolean;
99
98
  placeholder: string;
99
+ searchbox: boolean;
100
100
  teleportTo: string;
101
101
  closeOnSelect: boolean;
102
102
  multiSelect: boolean;
@@ -37,8 +37,11 @@ const templateProps = computed(() => ({
37
37
  function updateSearchText(val) {
38
38
  searchtext.value = val;
39
39
  }
40
+ function updateIsOptionsOpen(val) {
41
+ isOptionsOpen.value = val;
42
+ }
40
43
  </script>
41
44
 
42
45
  <template lang="pug">
43
- component(:is="presetComponent" v-bind="{...templateProps, ...$attrs}" @update:searchtext="updateSearchText")
46
+ component(:is="presetComponent" v-bind="{...templateProps, ...$attrs}" @update:searchtext="updateSearchText" @update:isOptionsOpen="updateIsOptionsOpen")
44
47
  </template>
@@ -95,8 +95,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
95
95
  }>, {
96
96
  disabled: boolean;
97
97
  modelValue: import("@katlux/providers").TDataRow | import("@katlux/providers").TDataRow[] | null;
98
- searchbox: boolean;
99
98
  placeholder: string;
99
+ searchbox: boolean;
100
100
  teleportTo: string;
101
101
  closeOnSelect: boolean;
102
102
  multiSelect: boolean;
@@ -106,7 +106,7 @@ export function useKComboboxLogic(props, emit) {
106
106
  watch(
107
107
  () => searchtext.value,
108
108
  (newText) => {
109
- if (!props.dataProvider) return;
109
+ if (!props.dataProvider?.filter) return;
110
110
  const filter = {
111
111
  operator: EDataFilterOperator.In,
112
112
  field: { [props.labelField]: newText.trim().toLowerCase() },
@@ -120,7 +120,7 @@ export function useKComboboxLogic(props, emit) {
120
120
  });
121
121
  onMounted(() => {
122
122
  selectedItems.value = Array.isArray(props.modelValue) ? props.modelValue : props.modelValue ? [props.modelValue] : null;
123
- if (props.searchbox && props.dataProvider) {
123
+ if (props.searchbox && props.dataProvider?.filter) {
124
124
  props.dataProvider.filter.value = null;
125
125
  }
126
126
  });
@@ -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
+ }