@katlux/toolkit 0.1.0-beta.43 → 0.1.0-beta.45
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/module.json +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +41 -2
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +10 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +41 -2
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +15 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +79 -4
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +39 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +9 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +39 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +15 -0
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +113 -13
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +21 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue +24 -11
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +21 -1
- 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/KTextbox/KTextbox.global.d.vue.ts +3 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +2 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +3 -2
- package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +4 -4
- package/dist/runtime/components/KTextbox/KTextbox.logic.js +4 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +3 -1
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +23 -13
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +6 -2
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +6 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +2 -2
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, onMounted, computed } from "vue";
|
|
1
|
+
import { ref, watch, onMounted, computed } from "vue";
|
|
2
2
|
export const KDateTimePickerDefaultProps = {
|
|
3
3
|
format: {
|
|
4
4
|
type: String,
|
|
@@ -12,6 +12,18 @@ export const KDateTimePickerDefaultProps = {
|
|
|
12
12
|
type: [Date, String],
|
|
13
13
|
default: void 0
|
|
14
14
|
},
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: [Date, String],
|
|
17
|
+
default: void 0
|
|
18
|
+
},
|
|
19
|
+
isOpen: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
showClear: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
15
27
|
timeStep: {
|
|
16
28
|
type: Number,
|
|
17
29
|
default: 30
|
|
@@ -30,22 +42,84 @@ export function useKDateTimePickerLogic(props) {
|
|
|
30
42
|
const _time = ref("");
|
|
31
43
|
const maskedModel = ref("");
|
|
32
44
|
const calendarShow = ref(false);
|
|
45
|
+
watch(maskedModel, (newVal) => {
|
|
46
|
+
if (newVal === "") {
|
|
47
|
+
_date.value = "";
|
|
48
|
+
_time.value = "";
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const format = props.format || "MM-DD-YYYY HH:mm";
|
|
52
|
+
let day = "", month = "", year = "", hours = "", minutes = "";
|
|
53
|
+
let rawIdx = 0;
|
|
54
|
+
for (let i = 0; i < format.length; i++) {
|
|
55
|
+
const char = format[i];
|
|
56
|
+
if (char === "M") {
|
|
57
|
+
month += newVal[rawIdx] || "";
|
|
58
|
+
rawIdx++;
|
|
59
|
+
} else if (char === "D") {
|
|
60
|
+
day += newVal[rawIdx] || "";
|
|
61
|
+
rawIdx++;
|
|
62
|
+
} else if (char === "Y") {
|
|
63
|
+
year += newVal[rawIdx] || "";
|
|
64
|
+
rawIdx++;
|
|
65
|
+
} else if (char === "H") {
|
|
66
|
+
hours += newVal[rawIdx] || "";
|
|
67
|
+
rawIdx++;
|
|
68
|
+
} else if (char === "m") {
|
|
69
|
+
minutes += newVal[rawIdx] || "";
|
|
70
|
+
rawIdx++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (month.length === 2 && day.length === 2 && year.length === 4) {
|
|
74
|
+
const d = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
|
|
75
|
+
if (hours.length === 2 && minutes.length === 2) {
|
|
76
|
+
d.setHours(parseInt(hours));
|
|
77
|
+
d.setMinutes(parseInt(minutes));
|
|
78
|
+
_time.value = `${hours}:${minutes}`;
|
|
79
|
+
}
|
|
80
|
+
if (!isNaN(d.getTime())) {
|
|
81
|
+
_date.value = d;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
33
85
|
const textboxClicked = () => {
|
|
34
86
|
calendarShow.value = true;
|
|
35
87
|
};
|
|
36
88
|
const dateSelected = (date) => {
|
|
37
|
-
|
|
89
|
+
const newDate = new Date(date);
|
|
90
|
+
if (_time.value) {
|
|
91
|
+
const [h, m] = _time.value.split(":").map(Number);
|
|
92
|
+
newDate.setHours(h);
|
|
93
|
+
newDate.setMinutes(m);
|
|
94
|
+
} else {
|
|
95
|
+
_time.value = "00:00";
|
|
96
|
+
newDate.setHours(0);
|
|
97
|
+
newDate.setMinutes(0);
|
|
98
|
+
}
|
|
99
|
+
_date.value = newDate;
|
|
38
100
|
updateMaskedModel();
|
|
39
101
|
};
|
|
40
102
|
const timeSelected = (time) => {
|
|
41
103
|
_time.value = time;
|
|
104
|
+
if (_date.value) {
|
|
105
|
+
const current = _date.value instanceof Date ? _date.value : new Date(_date.value);
|
|
106
|
+
const newDate = new Date(current);
|
|
107
|
+
const [h, m] = time.split(":").map(Number);
|
|
108
|
+
newDate.setHours(h);
|
|
109
|
+
newDate.setMinutes(m);
|
|
110
|
+
_date.value = newDate;
|
|
111
|
+
}
|
|
42
112
|
updateMaskedModel();
|
|
43
113
|
calendarShow.value = false;
|
|
44
114
|
};
|
|
45
115
|
const updateMaskedModel = () => {
|
|
46
|
-
if (_date.value
|
|
47
|
-
const
|
|
48
|
-
|
|
116
|
+
if (_date.value) {
|
|
117
|
+
const d = _date.value instanceof Date ? _date.value : new Date(_date.value);
|
|
118
|
+
if (!isNaN(d.getTime())) {
|
|
119
|
+
const dateStr = formatDate(d);
|
|
120
|
+
const timeStr = _time.value || "00:00";
|
|
121
|
+
maskedModel.value = `${dateStr} ${timeStr}`;
|
|
122
|
+
}
|
|
49
123
|
}
|
|
50
124
|
};
|
|
51
125
|
const formatDate = (date) => {
|
|
@@ -60,20 +134,46 @@ export function useKDateTimePickerLogic(props) {
|
|
|
60
134
|
return formattedDate;
|
|
61
135
|
};
|
|
62
136
|
const calendarDay = computed(() => {
|
|
63
|
-
|
|
64
|
-
|
|
137
|
+
const val = props.modelValue || props.day;
|
|
138
|
+
if (val) {
|
|
139
|
+
return val;
|
|
65
140
|
}
|
|
66
141
|
return /* @__PURE__ */ new Date();
|
|
67
142
|
});
|
|
68
143
|
onMounted(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
144
|
+
syncValue(props.modelValue || props.day);
|
|
145
|
+
if (props.isOpen) {
|
|
146
|
+
calendarShow.value = props.isOpen;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const syncValue = (val) => {
|
|
150
|
+
if (!val) return;
|
|
151
|
+
if (val instanceof Date) {
|
|
152
|
+
_date.value = val;
|
|
153
|
+
const h = val.getHours().toString().padStart(2, "0");
|
|
154
|
+
const m = val.getMinutes().toString().padStart(2, "0");
|
|
155
|
+
_time.value = `${h}:${m}`;
|
|
156
|
+
} else if (typeof val === "string") {
|
|
157
|
+
if (val.includes(" ")) {
|
|
158
|
+
const parts = val.split(" ");
|
|
159
|
+
_date.value = parts[0];
|
|
160
|
+
_time.value = parts[1];
|
|
161
|
+
} else if (val.includes(":")) {
|
|
162
|
+
_time.value = val;
|
|
163
|
+
} else {
|
|
164
|
+
_date.value = val;
|
|
74
165
|
}
|
|
75
|
-
updateMaskedModel();
|
|
76
166
|
}
|
|
167
|
+
updateMaskedModel();
|
|
168
|
+
};
|
|
169
|
+
watch(() => props.modelValue, (newVal) => {
|
|
170
|
+
syncValue(newVal);
|
|
171
|
+
});
|
|
172
|
+
watch(() => props.day, (newDay) => {
|
|
173
|
+
syncValue(newDay);
|
|
174
|
+
});
|
|
175
|
+
watch(() => props.isOpen, (newVal) => {
|
|
176
|
+
calendarShow.value = !!newVal;
|
|
77
177
|
});
|
|
78
178
|
return {
|
|
79
179
|
_date,
|
|
@@ -27,8 +27,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
27
27
|
type: BooleanConstructor;
|
|
28
28
|
default: boolean;
|
|
29
29
|
};
|
|
30
|
+
isOpen: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
showClear: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
30
38
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
31
39
|
"update:modelValue": (value: string) => any;
|
|
40
|
+
"update:isOpen": (value: boolean) => any;
|
|
32
41
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
42
|
step: {
|
|
34
43
|
type: NumberConstructor;
|
|
@@ -58,13 +67,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
58
67
|
type: BooleanConstructor;
|
|
59
68
|
default: boolean;
|
|
60
69
|
};
|
|
70
|
+
isOpen: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
showClear: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: boolean;
|
|
77
|
+
};
|
|
61
78
|
}>> & Readonly<{
|
|
62
79
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
80
|
+
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
63
81
|
}>, {
|
|
82
|
+
isOpen: boolean;
|
|
64
83
|
disabled: boolean;
|
|
65
84
|
modelValue: string;
|
|
66
|
-
format: string;
|
|
67
85
|
placeholder: string;
|
|
86
|
+
format: string;
|
|
87
|
+
showClear: boolean;
|
|
68
88
|
step: number;
|
|
69
89
|
startHour: string;
|
|
70
90
|
endHour: string;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "vue";
|
|
2
|
+
import { computed, watch } from "vue";
|
|
3
3
|
import { useKHourPickerLogic, KHourPickerDefaultProps } from "./KHourPicker.logic";
|
|
4
4
|
import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
5
5
|
import KHourPickerDefault from "../../presets/default/components/KHourPicker/KHourPicker.vue";
|
|
6
6
|
const props = defineProps(KHourPickerDefaultProps);
|
|
7
|
-
const emit = defineEmits(["update:modelValue"]);
|
|
7
|
+
const emit = defineEmits(["update:modelValue", "update:isOpen"]);
|
|
8
8
|
const {
|
|
9
9
|
isOpen,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
maskedModel,
|
|
11
|
+
textboxClicked,
|
|
12
12
|
closeDropdown,
|
|
13
|
-
onTimeSelect
|
|
14
|
-
|
|
13
|
+
onTimeSelect,
|
|
14
|
+
clear
|
|
15
|
+
} = useKHourPickerLogic(props);
|
|
15
16
|
const presetComponent = usePresetComponent("KHourPicker", KHourPickerDefault);
|
|
16
17
|
const templateProps = computed(() => ({
|
|
17
|
-
|
|
18
|
+
maskedModel: maskedModel.value,
|
|
18
19
|
isOpen: isOpen.value,
|
|
19
20
|
step: props.step,
|
|
20
21
|
format: props.format,
|
|
@@ -22,19 +23,31 @@ const templateProps = computed(() => ({
|
|
|
22
23
|
endHour: props.endHour,
|
|
23
24
|
placeholder: props.placeholder,
|
|
24
25
|
disabled: props.disabled,
|
|
25
|
-
|
|
26
|
+
showClear: props.showClear,
|
|
27
|
+
textboxClicked,
|
|
26
28
|
closeDropdown,
|
|
27
|
-
onTimeSelect
|
|
29
|
+
onTimeSelect,
|
|
30
|
+
clear
|
|
28
31
|
}));
|
|
29
|
-
const
|
|
32
|
+
const updateIsOpen = (val) => {
|
|
30
33
|
isOpen.value = val;
|
|
31
34
|
};
|
|
35
|
+
const updateMaskedModel = (val) => {
|
|
36
|
+
maskedModel.value = val;
|
|
37
|
+
};
|
|
38
|
+
watch(maskedModel, (newVal) => {
|
|
39
|
+
emit("update:modelValue", newVal);
|
|
40
|
+
});
|
|
41
|
+
watch(isOpen, (newVal) => {
|
|
42
|
+
emit("update:isOpen", newVal);
|
|
43
|
+
});
|
|
32
44
|
</script>
|
|
33
45
|
|
|
34
46
|
<template lang="pug">
|
|
35
47
|
component(
|
|
36
48
|
:is="presetComponent"
|
|
37
49
|
v-bind="{...templateProps, ...$attrs}"
|
|
38
|
-
@update:isOpen="
|
|
50
|
+
@update:isOpen="updateIsOpen"
|
|
51
|
+
@update:maskedModel="updateMaskedModel"
|
|
39
52
|
)
|
|
40
53
|
</template>
|
|
@@ -27,8 +27,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
27
27
|
type: BooleanConstructor;
|
|
28
28
|
default: boolean;
|
|
29
29
|
};
|
|
30
|
+
isOpen: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
showClear: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
30
38
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
31
39
|
"update:modelValue": (value: string) => any;
|
|
40
|
+
"update:isOpen": (value: boolean) => any;
|
|
32
41
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
42
|
step: {
|
|
34
43
|
type: NumberConstructor;
|
|
@@ -58,13 +67,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
58
67
|
type: BooleanConstructor;
|
|
59
68
|
default: boolean;
|
|
60
69
|
};
|
|
70
|
+
isOpen: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
showClear: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: boolean;
|
|
77
|
+
};
|
|
61
78
|
}>> & Readonly<{
|
|
62
79
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
80
|
+
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
63
81
|
}>, {
|
|
82
|
+
isOpen: boolean;
|
|
64
83
|
disabled: boolean;
|
|
65
84
|
modelValue: string;
|
|
66
|
-
format: string;
|
|
67
85
|
placeholder: string;
|
|
86
|
+
format: string;
|
|
87
|
+
showClear: boolean;
|
|
68
88
|
step: number;
|
|
69
89
|
startHour: string;
|
|
70
90
|
endHour: string;
|
|
@@ -6,6 +6,8 @@ export interface KHourPickerProps {
|
|
|
6
6
|
modelValue?: string;
|
|
7
7
|
placeholder?: string;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
isOpen?: boolean;
|
|
10
|
+
showClear?: boolean;
|
|
9
11
|
}
|
|
10
12
|
export declare const KHourPickerDefaultProps: {
|
|
11
13
|
step: {
|
|
@@ -36,11 +38,20 @@ export declare const KHourPickerDefaultProps: {
|
|
|
36
38
|
type: BooleanConstructor;
|
|
37
39
|
default: boolean;
|
|
38
40
|
};
|
|
41
|
+
isOpen: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
45
|
+
showClear: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
39
49
|
};
|
|
40
|
-
export declare function useKHourPickerLogic(props: KHourPickerProps
|
|
50
|
+
export declare function useKHourPickerLogic(props: KHourPickerProps): {
|
|
41
51
|
isOpen: import("vue").Ref<boolean, boolean>;
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
maskedModel: import("vue").Ref<string, string>;
|
|
53
|
+
textboxClicked: () => void;
|
|
44
54
|
closeDropdown: () => void;
|
|
45
55
|
onTimeSelect: (time: string) => void;
|
|
56
|
+
clear: () => void;
|
|
46
57
|
};
|
|
@@ -28,12 +28,20 @@ export const KHourPickerDefaultProps = {
|
|
|
28
28
|
disabled: {
|
|
29
29
|
type: Boolean,
|
|
30
30
|
default: false
|
|
31
|
+
},
|
|
32
|
+
isOpen: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
showClear: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
31
39
|
}
|
|
32
40
|
};
|
|
33
|
-
export function useKHourPickerLogic(props
|
|
34
|
-
const isOpen = ref(false);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
41
|
+
export function useKHourPickerLogic(props) {
|
|
42
|
+
const isOpen = ref(props.isOpen || false);
|
|
43
|
+
const maskedModel = ref(props.modelValue || "");
|
|
44
|
+
const textboxClicked = () => {
|
|
37
45
|
if (props.disabled) return;
|
|
38
46
|
isOpen.value = !isOpen.value;
|
|
39
47
|
};
|
|
@@ -41,18 +49,25 @@ export function useKHourPickerLogic(props, emit) {
|
|
|
41
49
|
isOpen.value = false;
|
|
42
50
|
};
|
|
43
51
|
const onTimeSelect = (time) => {
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
maskedModel.value = time;
|
|
53
|
+
closeDropdown();
|
|
54
|
+
};
|
|
55
|
+
const clear = () => {
|
|
56
|
+
maskedModel.value = "";
|
|
46
57
|
closeDropdown();
|
|
47
58
|
};
|
|
48
59
|
watch(() => props.modelValue, (val) => {
|
|
49
|
-
|
|
60
|
+
maskedModel.value = val || "";
|
|
61
|
+
});
|
|
62
|
+
watch(() => props.isOpen, (val) => {
|
|
63
|
+
isOpen.value = !!val;
|
|
50
64
|
});
|
|
51
65
|
return {
|
|
52
66
|
isOpen,
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
maskedModel,
|
|
68
|
+
textboxClicked,
|
|
55
69
|
closeDropdown,
|
|
56
|
-
onTimeSelect
|
|
70
|
+
onTimeSelect,
|
|
71
|
+
clear
|
|
57
72
|
};
|
|
58
73
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, computed } from "vue";
|
|
1
|
+
import { ref, computed, watch } from "vue";
|
|
2
2
|
export const KHourSelectDefaultProps = {
|
|
3
3
|
step: {
|
|
4
4
|
type: Number,
|
|
@@ -61,6 +61,9 @@ export function useKHourSelectLogic(props) {
|
|
|
61
61
|
const selectTime = (time) => {
|
|
62
62
|
selectedTime.value = time;
|
|
63
63
|
};
|
|
64
|
+
watch(() => props.modelValue, (val) => {
|
|
65
|
+
selectedTime.value = val || "";
|
|
66
|
+
});
|
|
64
67
|
return {
|
|
65
68
|
timeSlots,
|
|
66
69
|
selectedTime,
|
|
@@ -2,7 +2,7 @@ import { type KTextboxProps } from './KTextbox.logic.js';
|
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
3
|
modelValue: {
|
|
4
4
|
type: StringConstructor;
|
|
5
|
-
|
|
5
|
+
default: string;
|
|
6
6
|
};
|
|
7
7
|
placeholder: {
|
|
8
8
|
type: StringConstructor;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
23
23
|
modelValue: {
|
|
24
24
|
type: StringConstructor;
|
|
25
|
-
|
|
25
|
+
default: string;
|
|
26
26
|
};
|
|
27
27
|
placeholder: {
|
|
28
28
|
type: StringConstructor;
|
|
@@ -41,6 +41,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
41
41
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
42
42
|
}>, {
|
|
43
43
|
type: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
|
|
44
|
+
modelValue: string;
|
|
44
45
|
placeholder: string;
|
|
45
46
|
showClear: boolean;
|
|
46
47
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -5,11 +5,11 @@ import { computed } from "vue";
|
|
|
5
5
|
import KTextboxDefault from "../../presets/default/components/KTextbox/KTextbox.vue";
|
|
6
6
|
const props = defineProps(KTextboxDefaultProps);
|
|
7
7
|
const emit = defineEmits(["update:modelValue"]);
|
|
8
|
-
const { text,
|
|
8
|
+
const { text, showClear, clear } = useKTextboxLogic(props, emit);
|
|
9
9
|
const presetComponent = usePresetComponent("KTextbox", KTextboxDefault);
|
|
10
10
|
const templateProps = computed(() => ({
|
|
11
11
|
text: text.value,
|
|
12
|
-
|
|
12
|
+
showClear: showClear.value,
|
|
13
13
|
clear,
|
|
14
14
|
placeholder: props.placeholder,
|
|
15
15
|
type: props.type
|
|
@@ -2,7 +2,7 @@ import { type KTextboxProps } from './KTextbox.logic.js';
|
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
3
|
modelValue: {
|
|
4
4
|
type: StringConstructor;
|
|
5
|
-
|
|
5
|
+
default: string;
|
|
6
6
|
};
|
|
7
7
|
placeholder: {
|
|
8
8
|
type: StringConstructor;
|
|
@@ -22,7 +22,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
23
23
|
modelValue: {
|
|
24
24
|
type: StringConstructor;
|
|
25
|
-
|
|
25
|
+
default: string;
|
|
26
26
|
};
|
|
27
27
|
placeholder: {
|
|
28
28
|
type: StringConstructor;
|
|
@@ -41,6 +41,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
41
41
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
42
42
|
}>, {
|
|
43
43
|
type: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
|
|
44
|
+
modelValue: string;
|
|
44
45
|
placeholder: string;
|
|
45
46
|
showClear: boolean;
|
|
46
47
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface KTextboxProps {
|
|
2
|
-
modelValue
|
|
3
|
-
placeholder
|
|
2
|
+
modelValue?: string;
|
|
3
|
+
placeholder?: string;
|
|
4
4
|
showClear?: boolean;
|
|
5
5
|
type?: 'text' | 'password' | 'email' | 'url' | 'tel' | 'search' | 'number';
|
|
6
6
|
}
|
|
@@ -12,7 +12,7 @@ export interface KTextboxEmits {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function useKTextboxLogic(props: KTextboxProps, emit: KTextboxEmits): {
|
|
14
14
|
text: import("vue").WritableComputedRef<string, string>;
|
|
15
|
-
|
|
15
|
+
showClear: import("vue").ComputedRef<boolean | undefined>;
|
|
16
16
|
clear: () => void;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
@@ -21,7 +21,7 @@ export declare function useKTextboxLogic(props: KTextboxProps, emit: KTextboxEmi
|
|
|
21
21
|
export declare const KTextboxDefaultProps: {
|
|
22
22
|
modelValue: {
|
|
23
23
|
type: StringConstructor;
|
|
24
|
-
|
|
24
|
+
default: string;
|
|
25
25
|
};
|
|
26
26
|
placeholder: {
|
|
27
27
|
type: StringConstructor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
export function useKTextboxLogic(props, emit) {
|
|
3
3
|
const text = computed({
|
|
4
|
-
get: () => props.modelValue,
|
|
4
|
+
get: () => props.modelValue ?? "",
|
|
5
5
|
set: (value) => emit("update:modelValue", value)
|
|
6
6
|
});
|
|
7
|
-
const
|
|
7
|
+
const showClear = computed(() => {
|
|
8
8
|
return props.showClear && text.value !== "";
|
|
9
9
|
});
|
|
10
10
|
const clear = () => {
|
|
@@ -12,14 +12,14 @@ export function useKTextboxLogic(props, emit) {
|
|
|
12
12
|
};
|
|
13
13
|
return {
|
|
14
14
|
text,
|
|
15
|
-
|
|
15
|
+
showClear,
|
|
16
16
|
clear
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export const KTextboxDefaultProps = {
|
|
20
20
|
modelValue: {
|
|
21
21
|
type: String,
|
|
22
|
-
|
|
22
|
+
default: ""
|
|
23
23
|
},
|
|
24
24
|
placeholder: {
|
|
25
25
|
type: String,
|
|
@@ -108,9 +108,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
disabled: boolean;
|
|
109
109
|
loading: boolean;
|
|
110
110
|
modelValue: any;
|
|
111
|
-
dataProvider: any;
|
|
112
111
|
searchbox: boolean;
|
|
113
112
|
placeholder: string;
|
|
113
|
+
dataProvider: any;
|
|
114
114
|
closeOnSelect: boolean;
|
|
115
115
|
multiSelect: boolean;
|
|
116
116
|
iconField: string;
|
|
@@ -108,9 +108,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
disabled: boolean;
|
|
109
109
|
loading: boolean;
|
|
110
110
|
modelValue: any;
|
|
111
|
-
dataProvider: any;
|
|
112
111
|
searchbox: boolean;
|
|
113
112
|
placeholder: string;
|
|
113
|
+
dataProvider: any;
|
|
114
114
|
closeOnSelect: boolean;
|
|
115
115
|
multiSelect: boolean;
|
|
116
116
|
iconField: string;
|
|
@@ -5,9 +5,11 @@ type __VLS_Props = {
|
|
|
5
5
|
_date: any;
|
|
6
6
|
calendarDay: Date | string;
|
|
7
7
|
format: string;
|
|
8
|
+
showClear: boolean;
|
|
8
9
|
calendarDefinedDays: IDefinedDay[];
|
|
9
10
|
calendarMarkedDays: IMarkedDay[];
|
|
10
11
|
textboxClicked: () => void;
|
|
12
|
+
onClear: () => void;
|
|
11
13
|
dateSelected: (date: Date) => void;
|
|
12
14
|
};
|
|
13
15
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KDatePicker(ref="activatorRef")
|
|
3
|
-
KMaskTextbox(v-model="maskedModel" :key="maskedModel" :mask="format" :placeholder="format" @click.stop="textboxClicked" showClear)
|
|
3
|
+
KMaskTextbox(v-model="maskedModel" :key="maskedModel" :mask="format" :placeholder="format" @click.stop="textboxClicked" :showClear="showClear" @clear="onClear")
|
|
4
4
|
KDropdown(v-model:isOpen="calendarShow" :anchorEl="activatorRef")
|
|
5
5
|
KCalendar(view="month" :viewCount="1" :day="calendarDay" :selectedDay="_date" @dayClicked="dateSelected" :definedDays="calendarDefinedDays" :markedDays="calendarMarkedDays")
|
|
6
6
|
</template>
|
|
@@ -19,9 +19,11 @@ const props = defineProps<{
|
|
|
19
19
|
_date: any
|
|
20
20
|
calendarDay: Date | string
|
|
21
21
|
format: string
|
|
22
|
+
showClear: boolean
|
|
22
23
|
calendarDefinedDays: IDefinedDay[]
|
|
23
24
|
calendarMarkedDays: IMarkedDay[]
|
|
24
25
|
textboxClicked: () => void
|
|
26
|
+
onClear: () => void
|
|
25
27
|
dateSelected: (date: Date) => void
|
|
26
28
|
}>()
|
|
27
29
|
|
|
@@ -5,9 +5,11 @@ type __VLS_Props = {
|
|
|
5
5
|
_date: any;
|
|
6
6
|
calendarDay: Date | string;
|
|
7
7
|
format: string;
|
|
8
|
+
showClear: boolean;
|
|
8
9
|
calendarDefinedDays: IDefinedDay[];
|
|
9
10
|
calendarMarkedDays: IMarkedDay[];
|
|
10
11
|
textboxClicked: () => void;
|
|
12
|
+
onClear: () => void;
|
|
11
13
|
dateSelected: (date: Date) => void;
|
|
12
14
|
};
|
|
13
15
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
@@ -10,7 +10,9 @@ type __VLS_Props = {
|
|
|
10
10
|
timeStep: number;
|
|
11
11
|
calendarDefinedDays: IDefinedDay[];
|
|
12
12
|
calendarMarkedDays: IMarkedDay[];
|
|
13
|
+
showClear: boolean;
|
|
13
14
|
textboxClicked: () => void;
|
|
15
|
+
onClear: () => void;
|
|
14
16
|
dateSelected: (date: Date) => void;
|
|
15
17
|
timeSelected: (time: string) => void;
|
|
16
18
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KDateTimePicker(ref="activatorRef" @click.stop="textboxClicked")
|
|
3
|
-
KMaskTextbox(v-model="maskedModel" :key="maskedModel" :mask="format" :placeholder="format" showClear)
|
|
3
|
+
KMaskTextbox(v-model="maskedModel" :key="maskedModel" :mask="format" :placeholder="format" :showClear="showClear" @clear="onClear")
|
|
4
4
|
KDropdown(v-model:isOpen="calendarShow" :anchorEl="activatorRef")
|
|
5
5
|
KGrid(direction="row" align="start" :noGap="false" wrap="nowrap").datetime-picker-grid
|
|
6
6
|
.calendar-section
|
|
@@ -28,7 +28,9 @@ const props = defineProps<{
|
|
|
28
28
|
timeStep: number
|
|
29
29
|
calendarDefinedDays: IDefinedDay[]
|
|
30
30
|
calendarMarkedDays: IMarkedDay[]
|
|
31
|
+
showClear: boolean
|
|
31
32
|
textboxClicked: () => void
|
|
33
|
+
onClear: () => void
|
|
32
34
|
dateSelected: (date: Date) => void
|
|
33
35
|
timeSelected: (time: string) => void
|
|
34
36
|
}>()
|
|
@@ -10,7 +10,9 @@ type __VLS_Props = {
|
|
|
10
10
|
timeStep: number;
|
|
11
11
|
calendarDefinedDays: IDefinedDay[];
|
|
12
12
|
calendarMarkedDays: IMarkedDay[];
|
|
13
|
+
showClear: boolean;
|
|
13
14
|
textboxClicked: () => void;
|
|
15
|
+
onClear: () => void;
|
|
14
16
|
dateSelected: (date: Date) => void;
|
|
15
17
|
timeSelected: (time: string) => void;
|
|
16
18
|
};
|