@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
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import type { IMarkedDay, IDefinedDay } from '../KCalendar/types.js';
|
|
2
3
|
export interface KDateTimePickerProps {
|
|
3
4
|
format?: string;
|
|
4
5
|
timeFormat?: string;
|
|
5
6
|
day?: Date | string;
|
|
7
|
+
modelValue?: Date | string;
|
|
8
|
+
isOpen?: boolean;
|
|
9
|
+
showClear?: boolean;
|
|
6
10
|
timeStep?: number;
|
|
7
11
|
calendarDefinedDays?: IDefinedDay[];
|
|
8
12
|
calendarMarkedDays?: IMarkedDay[];
|
|
13
|
+
teleportTo?: string;
|
|
9
14
|
}
|
|
10
15
|
export declare const KDateTimePickerDefaultProps: {
|
|
11
16
|
format: {
|
|
@@ -20,6 +25,18 @@ export declare const KDateTimePickerDefaultProps: {
|
|
|
20
25
|
type: (DateConstructor | StringConstructor)[];
|
|
21
26
|
default: undefined;
|
|
22
27
|
};
|
|
28
|
+
modelValue: {
|
|
29
|
+
type: (DateConstructor | StringConstructor)[];
|
|
30
|
+
default: undefined;
|
|
31
|
+
};
|
|
32
|
+
isOpen: {
|
|
33
|
+
type: BooleanConstructor;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
showClear: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
23
40
|
timeStep: {
|
|
24
41
|
type: NumberConstructor;
|
|
25
42
|
default: number;
|
|
@@ -32,6 +49,10 @@ export declare const KDateTimePickerDefaultProps: {
|
|
|
32
49
|
type: PropType<IMarkedDay[]>;
|
|
33
50
|
default: () => never[];
|
|
34
51
|
};
|
|
52
|
+
teleportTo: {
|
|
53
|
+
type: PropType<string>;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
35
56
|
};
|
|
36
57
|
export declare function useKDateTimePickerLogic(props: KDateTimePickerProps): {
|
|
37
58
|
_date: import("vue").Ref<string | Date, string | Date>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, 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
|
|
@@ -23,6 +35,10 @@ export const KDateTimePickerDefaultProps = {
|
|
|
23
35
|
calendarMarkedDays: {
|
|
24
36
|
type: Array,
|
|
25
37
|
default: () => []
|
|
38
|
+
},
|
|
39
|
+
teleportTo: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: void 0
|
|
26
42
|
}
|
|
27
43
|
};
|
|
28
44
|
export function useKDateTimePickerLogic(props) {
|
|
@@ -30,21 +46,93 @@ export function useKDateTimePickerLogic(props) {
|
|
|
30
46
|
const _time = ref("");
|
|
31
47
|
const maskedModel = ref("");
|
|
32
48
|
const calendarShow = ref(false);
|
|
49
|
+
watch(maskedModel, (newVal) => {
|
|
50
|
+
if (newVal === "") {
|
|
51
|
+
if (_date.value !== "") {
|
|
52
|
+
_date.value = "";
|
|
53
|
+
_time.value = "";
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const format = props.format || "MM-DD-YYYY HH:mm";
|
|
58
|
+
let day = "", month = "", year = "", hours = "", minutes = "";
|
|
59
|
+
let rawIdx = 0;
|
|
60
|
+
for (let i = 0; i < format.length; i++) {
|
|
61
|
+
const char = format[i];
|
|
62
|
+
if (char === "M") {
|
|
63
|
+
month += newVal[rawIdx] || "";
|
|
64
|
+
rawIdx++;
|
|
65
|
+
} else if (char === "D") {
|
|
66
|
+
day += newVal[rawIdx] || "";
|
|
67
|
+
rawIdx++;
|
|
68
|
+
} else if (char === "Y") {
|
|
69
|
+
year += newVal[rawIdx] || "";
|
|
70
|
+
rawIdx++;
|
|
71
|
+
} else if (char === "H") {
|
|
72
|
+
hours += newVal[rawIdx] || "";
|
|
73
|
+
rawIdx++;
|
|
74
|
+
} else if (char === "m") {
|
|
75
|
+
minutes += newVal[rawIdx] || "";
|
|
76
|
+
rawIdx++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (month.length === 2 && day.length === 2 && year.length === 4) {
|
|
80
|
+
const d = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
|
|
81
|
+
if (hours.length === 2 && minutes.length === 2) {
|
|
82
|
+
d.setHours(parseInt(hours));
|
|
83
|
+
d.setMinutes(parseInt(minutes));
|
|
84
|
+
}
|
|
85
|
+
if (!isNaN(d.getTime())) {
|
|
86
|
+
const oldTime = _date.value instanceof Date ? _date.value.getTime() : new Date(_date.value).getTime();
|
|
87
|
+
if (d.getTime() !== oldTime) {
|
|
88
|
+
_date.value = d;
|
|
89
|
+
if (hours.length === 2 && minutes.length === 2) {
|
|
90
|
+
_time.value = `${hours}:${minutes}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
33
96
|
const textboxClicked = () => {
|
|
34
97
|
calendarShow.value = true;
|
|
35
98
|
};
|
|
36
99
|
const dateSelected = (date) => {
|
|
37
|
-
|
|
100
|
+
const newDate = new Date(date);
|
|
101
|
+
if (_time.value) {
|
|
102
|
+
const [h, m] = _time.value.split(":").map(Number);
|
|
103
|
+
newDate.setHours(h);
|
|
104
|
+
newDate.setMinutes(m);
|
|
105
|
+
} else {
|
|
106
|
+
_time.value = "00:00";
|
|
107
|
+
newDate.setHours(0);
|
|
108
|
+
newDate.setMinutes(0);
|
|
109
|
+
}
|
|
110
|
+
_date.value = newDate;
|
|
38
111
|
updateMaskedModel();
|
|
39
112
|
};
|
|
40
113
|
const timeSelected = (time) => {
|
|
41
114
|
_time.value = time;
|
|
115
|
+
if (_date.value) {
|
|
116
|
+
const current = _date.value instanceof Date ? _date.value : new Date(_date.value);
|
|
117
|
+
const newDate = new Date(current);
|
|
118
|
+
const [h, m] = time.split(":").map(Number);
|
|
119
|
+
newDate.setHours(h);
|
|
120
|
+
newDate.setMinutes(m);
|
|
121
|
+
_date.value = newDate;
|
|
122
|
+
}
|
|
42
123
|
updateMaskedModel();
|
|
124
|
+
calendarShow.value = false;
|
|
43
125
|
};
|
|
44
126
|
const updateMaskedModel = () => {
|
|
45
|
-
if (_date.value
|
|
46
|
-
const
|
|
47
|
-
|
|
127
|
+
if (_date.value) {
|
|
128
|
+
const d = _date.value instanceof Date ? _date.value : new Date(_date.value);
|
|
129
|
+
if (!isNaN(d.getTime())) {
|
|
130
|
+
const dateStr = formatDate(d);
|
|
131
|
+
const timeStr = _time.value || "00:00";
|
|
132
|
+
maskedModel.value = `${dateStr} ${timeStr}`;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
maskedModel.value = "";
|
|
48
136
|
}
|
|
49
137
|
};
|
|
50
138
|
const formatDate = (date) => {
|
|
@@ -59,11 +147,64 @@ export function useKDateTimePickerLogic(props) {
|
|
|
59
147
|
return formattedDate;
|
|
60
148
|
};
|
|
61
149
|
const calendarDay = computed(() => {
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
const val = props.modelValue || props.day;
|
|
151
|
+
if (val) {
|
|
152
|
+
return val;
|
|
64
153
|
}
|
|
65
154
|
return /* @__PURE__ */ new Date();
|
|
66
155
|
});
|
|
156
|
+
onMounted(() => {
|
|
157
|
+
syncValue(props.modelValue || props.day);
|
|
158
|
+
if (props.isOpen) {
|
|
159
|
+
calendarShow.value = props.isOpen;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
const syncValue = (val) => {
|
|
163
|
+
if (val === void 0 || val === null || val === "") {
|
|
164
|
+
_date.value = "";
|
|
165
|
+
_time.value = "";
|
|
166
|
+
maskedModel.value = "";
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (val instanceof Date) {
|
|
170
|
+
_date.value = val;
|
|
171
|
+
const h = val.getHours().toString().padStart(2, "0");
|
|
172
|
+
const m = val.getMinutes().toString().padStart(2, "0");
|
|
173
|
+
_time.value = `${h}:${m}`;
|
|
174
|
+
} else if (typeof val === "string") {
|
|
175
|
+
if (val.includes(" ")) {
|
|
176
|
+
const parts = val.split(" ");
|
|
177
|
+
_date.value = parts[0];
|
|
178
|
+
_time.value = parts[1];
|
|
179
|
+
} else if (val.includes(":")) {
|
|
180
|
+
_time.value = val;
|
|
181
|
+
} else {
|
|
182
|
+
_date.value = val;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
updateMaskedModel();
|
|
186
|
+
};
|
|
187
|
+
watch(() => props.modelValue, (newVal) => {
|
|
188
|
+
if (newVal !== void 0) {
|
|
189
|
+
const d1 = newVal && (newVal instanceof Date || typeof newVal === "string") ? newVal instanceof Date ? newVal.getTime() : new Date(newVal).getTime() : 0;
|
|
190
|
+
const d2 = _date.value instanceof Date ? _date.value.getTime() : new Date(_date.value || "").getTime();
|
|
191
|
+
if (d1 !== d2 || !newVal && _date.value) {
|
|
192
|
+
syncValue(newVal);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
watch(() => props.day, (newDay) => {
|
|
197
|
+
if (newDay !== void 0) {
|
|
198
|
+
const d1 = newDay && (newDay instanceof Date || typeof newDay === "string") ? newDay instanceof Date ? newDay.getTime() : new Date(newDay).getTime() : 0;
|
|
199
|
+
const d2 = _date.value instanceof Date ? _date.value.getTime() : new Date(_date.value || "").getTime();
|
|
200
|
+
if (d1 !== d2 || !newDay && _date.value) {
|
|
201
|
+
syncValue(newDay);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
watch(() => props.isOpen, (newVal) => {
|
|
206
|
+
calendarShow.value = !!newVal;
|
|
207
|
+
});
|
|
67
208
|
return {
|
|
68
209
|
_date,
|
|
69
210
|
_time,
|
|
@@ -7,6 +7,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
7
7
|
type: BooleanConstructor;
|
|
8
8
|
default: boolean;
|
|
9
9
|
};
|
|
10
|
+
anchorEl: {
|
|
11
|
+
type: import("vue").PropType<HTMLElement>;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
teleportTo: {
|
|
15
|
+
type: import("vue").PropType<string>;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
10
18
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
19
|
"update:isOpen": (value: boolean) => any;
|
|
12
20
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -18,11 +26,21 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
18
26
|
type: BooleanConstructor;
|
|
19
27
|
default: boolean;
|
|
20
28
|
};
|
|
29
|
+
anchorEl: {
|
|
30
|
+
type: import("vue").PropType<HTMLElement>;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
teleportTo: {
|
|
34
|
+
type: import("vue").PropType<string>;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
21
37
|
}>> & Readonly<{
|
|
22
38
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
23
39
|
}>, {
|
|
24
40
|
isOpen: boolean;
|
|
41
|
+
teleportTo: string;
|
|
25
42
|
fullWidth: boolean;
|
|
43
|
+
anchorEl: HTMLElement;
|
|
26
44
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
45
|
declare const _default: typeof __VLS_export;
|
|
28
46
|
export default _default;
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useKDropdownLogic, KDropdownDefaultProps } from "./KDropdown.logic";
|
|
3
3
|
import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
4
|
-
import { computed } from "vue";
|
|
4
|
+
import { computed, watch } from "vue";
|
|
5
5
|
import KDropdownDefault from "../../presets/default/components/KDropdown/KDropdown.vue";
|
|
6
6
|
const props = defineProps(KDropdownDefaultProps);
|
|
7
7
|
const emit = defineEmits(["update:isOpen"]);
|
|
8
|
-
const { open, clickoutside } = useKDropdownLogic(props, emit);
|
|
8
|
+
const { open, dropdownRect, clickoutside, teleportTarget, isInModal, updatePosition } = useKDropdownLogic(props, emit);
|
|
9
9
|
const presetComponent = usePresetComponent("KDropdown", KDropdownDefault);
|
|
10
|
+
watch(presetComponent, () => {
|
|
11
|
+
if (open.value) {
|
|
12
|
+
updatePosition();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
10
15
|
const templateProps = computed(() => ({
|
|
11
16
|
open: open.value,
|
|
12
17
|
fullWidth: props.fullWidth,
|
|
13
|
-
|
|
18
|
+
anchorEl: props.anchorEl,
|
|
19
|
+
dropdownRect: dropdownRect.value,
|
|
20
|
+
clickoutside,
|
|
21
|
+
teleportTarget: teleportTarget.value,
|
|
22
|
+
isInModal: isInModal.value
|
|
14
23
|
}));
|
|
15
24
|
</script>
|
|
16
25
|
|
|
17
26
|
<template lang="pug">
|
|
18
|
-
component(:is="presetComponent" v-bind="templateProps")
|
|
27
|
+
component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" @update:isOpen="emit('update:isOpen', $event)")
|
|
19
28
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
20
29
|
slot(:name="slot" v-bind="scope")
|
|
21
30
|
</template>
|
|
@@ -7,6 +7,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
7
7
|
type: BooleanConstructor;
|
|
8
8
|
default: boolean;
|
|
9
9
|
};
|
|
10
|
+
anchorEl: {
|
|
11
|
+
type: import("vue").PropType<HTMLElement>;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
teleportTo: {
|
|
15
|
+
type: import("vue").PropType<string>;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
10
18
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
11
19
|
"update:isOpen": (value: boolean) => any;
|
|
12
20
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -18,11 +26,21 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
18
26
|
type: BooleanConstructor;
|
|
19
27
|
default: boolean;
|
|
20
28
|
};
|
|
29
|
+
anchorEl: {
|
|
30
|
+
type: import("vue").PropType<HTMLElement>;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
teleportTo: {
|
|
34
|
+
type: import("vue").PropType<string>;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
21
37
|
}>> & Readonly<{
|
|
22
38
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
23
39
|
}>, {
|
|
24
40
|
isOpen: boolean;
|
|
41
|
+
teleportTo: string;
|
|
25
42
|
fullWidth: boolean;
|
|
43
|
+
anchorEl: HTMLElement;
|
|
26
44
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
45
|
declare const _default: typeof __VLS_export;
|
|
28
46
|
export default _default;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { type PropType, type Ref } from 'vue';
|
|
1
2
|
export interface KDropdownProps {
|
|
2
3
|
isOpen: boolean;
|
|
3
4
|
fullWidth: boolean;
|
|
5
|
+
anchorEl?: HTMLElement;
|
|
6
|
+
teleportTo?: string;
|
|
4
7
|
}
|
|
5
8
|
export interface KDropdownEmits {
|
|
6
9
|
(e: 'update:isOpen', value: boolean): void;
|
|
@@ -14,8 +17,32 @@ export declare const KDropdownDefaultProps: {
|
|
|
14
17
|
type: BooleanConstructor;
|
|
15
18
|
default: boolean;
|
|
16
19
|
};
|
|
20
|
+
anchorEl: {
|
|
21
|
+
type: PropType<HTMLElement>;
|
|
22
|
+
default: undefined;
|
|
23
|
+
};
|
|
24
|
+
teleportTo: {
|
|
25
|
+
type: PropType<string>;
|
|
26
|
+
default: undefined;
|
|
27
|
+
};
|
|
17
28
|
};
|
|
18
29
|
export declare function useKDropdownLogic(props: KDropdownProps, emit: KDropdownEmits): {
|
|
19
|
-
open:
|
|
30
|
+
open: Ref<boolean, boolean>;
|
|
31
|
+
dropdownRect: Ref<{
|
|
32
|
+
top: number;
|
|
33
|
+
left: number;
|
|
34
|
+
width: number;
|
|
35
|
+
}, {
|
|
36
|
+
top: number;
|
|
37
|
+
left: number;
|
|
38
|
+
width: number;
|
|
39
|
+
} | {
|
|
40
|
+
top: number;
|
|
41
|
+
left: number;
|
|
42
|
+
width: number;
|
|
43
|
+
}>;
|
|
20
44
|
clickoutside: () => void;
|
|
45
|
+
teleportTarget: import("vue").ComputedRef<string>;
|
|
46
|
+
isInModal: import("vue").ComputedRef<boolean>;
|
|
47
|
+
updatePosition: () => void;
|
|
21
48
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ref, watch, onMounted } from "vue";
|
|
1
|
+
import { ref, watch, onMounted, onUnmounted, nextTick, inject, computed } from "vue";
|
|
2
|
+
import { KMODAL_PORTAL_ID_KEY } from "../KModal/KModal.logic.js";
|
|
2
3
|
export const KDropdownDefaultProps = {
|
|
3
4
|
isOpen: {
|
|
4
5
|
type: Boolean,
|
|
@@ -7,25 +8,105 @@ export const KDropdownDefaultProps = {
|
|
|
7
8
|
fullWidth: {
|
|
8
9
|
type: Boolean,
|
|
9
10
|
default: false
|
|
11
|
+
},
|
|
12
|
+
anchorEl: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: void 0
|
|
15
|
+
},
|
|
16
|
+
teleportTo: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: void 0
|
|
10
19
|
}
|
|
11
20
|
};
|
|
12
21
|
export function useKDropdownLogic(props, emit) {
|
|
22
|
+
const modalPortalId = inject(KMODAL_PORTAL_ID_KEY, null);
|
|
23
|
+
const isInModal = computed(() => !!modalPortalId?.value);
|
|
24
|
+
const teleportTarget = computed(() => {
|
|
25
|
+
if (props.teleportTo) return props.teleportTo;
|
|
26
|
+
if (isInModal.value && modalPortalId?.value) {
|
|
27
|
+
const targetId = `#${modalPortalId.value}`;
|
|
28
|
+
if (typeof document !== "undefined" && !document.querySelector(targetId)) {
|
|
29
|
+
const activePortal = document.querySelector(".modal-portal");
|
|
30
|
+
if (activePortal && activePortal.id) return `#${activePortal.id}`;
|
|
31
|
+
}
|
|
32
|
+
return targetId;
|
|
33
|
+
}
|
|
34
|
+
return "body";
|
|
35
|
+
});
|
|
13
36
|
const open = ref(false);
|
|
37
|
+
const dropdownRect = ref({ top: 0, left: 0, width: 0 });
|
|
14
38
|
const clickoutside = () => {
|
|
15
39
|
open.value = false;
|
|
16
40
|
emit("update:isOpen", open.value);
|
|
17
41
|
};
|
|
42
|
+
const updatePosition = () => {
|
|
43
|
+
try {
|
|
44
|
+
if (props.anchorEl) {
|
|
45
|
+
const el = props.anchorEl.$el || props.anchorEl;
|
|
46
|
+
if (el && typeof el.getBoundingClientRect === "function") {
|
|
47
|
+
const rect = el.getBoundingClientRect();
|
|
48
|
+
if (teleportTarget.value === "body" || teleportTarget.value === void 0) {
|
|
49
|
+
dropdownRect.value = {
|
|
50
|
+
top: rect.bottom + window.scrollY,
|
|
51
|
+
left: rect.left + window.scrollX,
|
|
52
|
+
width: rect.width
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
const portalEl = document.querySelector(teleportTarget.value);
|
|
56
|
+
const portalRect = portalEl ? portalEl.getBoundingClientRect() : { top: 0, left: 0 };
|
|
57
|
+
dropdownRect.value = {
|
|
58
|
+
top: rect.bottom - portalRect.top,
|
|
59
|
+
left: rect.left - portalRect.left,
|
|
60
|
+
width: rect.width
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error("[KDropdown] Failed to update position", e);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const onScrollResize = () => {
|
|
70
|
+
if (open.value) {
|
|
71
|
+
updatePosition();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
18
74
|
watch(
|
|
19
75
|
() => props.isOpen,
|
|
20
76
|
(newValue) => {
|
|
21
|
-
|
|
77
|
+
if (newValue) {
|
|
78
|
+
updatePosition();
|
|
79
|
+
nextTick(() => {
|
|
80
|
+
open.value = true;
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
open.value = false;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{ immediate: true }
|
|
87
|
+
);
|
|
88
|
+
watch(
|
|
89
|
+
() => props.anchorEl,
|
|
90
|
+
() => {
|
|
91
|
+
if (open.value) {
|
|
92
|
+
updatePosition();
|
|
93
|
+
}
|
|
22
94
|
}
|
|
23
95
|
);
|
|
24
96
|
onMounted(() => {
|
|
25
|
-
|
|
97
|
+
window.addEventListener("scroll", onScrollResize, true);
|
|
98
|
+
window.addEventListener("resize", onScrollResize);
|
|
99
|
+
});
|
|
100
|
+
onUnmounted(() => {
|
|
101
|
+
window.removeEventListener("scroll", onScrollResize, true);
|
|
102
|
+
window.removeEventListener("resize", onScrollResize);
|
|
26
103
|
});
|
|
27
104
|
return {
|
|
28
105
|
open,
|
|
29
|
-
|
|
106
|
+
dropdownRect,
|
|
107
|
+
clickoutside,
|
|
108
|
+
teleportTarget,
|
|
109
|
+
isInModal,
|
|
110
|
+
updatePosition
|
|
30
111
|
};
|
|
31
112
|
}
|
|
@@ -1,60 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
wrap: {
|
|
7
|
-
type: PropType<"wrap" | "nowrap">;
|
|
8
|
-
default: string;
|
|
9
|
-
};
|
|
10
|
-
flexChild: {
|
|
11
|
-
type: BooleanConstructor;
|
|
12
|
-
default: boolean;
|
|
13
|
-
};
|
|
14
|
-
align: {
|
|
15
|
-
type: PropType<"start" | "center" | "end" | "stretch" | "baseline">;
|
|
16
|
-
default: string;
|
|
17
|
-
};
|
|
18
|
-
justify: {
|
|
19
|
-
type: PropType<"start" | "center" | "end" | "space-between" | "around" | "evenly">;
|
|
20
|
-
default: string;
|
|
21
|
-
};
|
|
22
|
-
noGap: {
|
|
23
|
-
type: BooleanConstructor;
|
|
24
|
-
default: boolean;
|
|
25
|
-
};
|
|
26
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
-
direction: {
|
|
28
|
-
type: PropType<"row" | "column">;
|
|
29
|
-
default: string;
|
|
30
|
-
};
|
|
31
|
-
wrap: {
|
|
32
|
-
type: PropType<"wrap" | "nowrap">;
|
|
33
|
-
default: string;
|
|
34
|
-
};
|
|
35
|
-
flexChild: {
|
|
36
|
-
type: BooleanConstructor;
|
|
37
|
-
default: boolean;
|
|
38
|
-
};
|
|
39
|
-
align: {
|
|
40
|
-
type: PropType<"start" | "center" | "end" | "stretch" | "baseline">;
|
|
41
|
-
default: string;
|
|
42
|
-
};
|
|
43
|
-
justify: {
|
|
44
|
-
type: PropType<"start" | "center" | "end" | "space-between" | "around" | "evenly">;
|
|
45
|
-
default: string;
|
|
46
|
-
};
|
|
47
|
-
noGap: {
|
|
48
|
-
type: BooleanConstructor;
|
|
49
|
-
default: boolean;
|
|
50
|
-
};
|
|
51
|
-
}>> & Readonly<{}>, {
|
|
52
|
-
wrap: any;
|
|
53
|
-
direction: any;
|
|
1
|
+
import { type KGridProps } from './KGrid.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KGridProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<KGridProps> & Readonly<{}>, {
|
|
3
|
+
wrap: "wrap" | "nowrap";
|
|
4
|
+
direction: "row" | "column";
|
|
54
5
|
flexChild: boolean;
|
|
55
|
-
align:
|
|
56
|
-
justify:
|
|
6
|
+
align: "start" | "center" | "end" | "stretch" | "baseline";
|
|
7
|
+
justify: "start" | "center" | "end" | "space-between" | "around" | "evenly";
|
|
57
8
|
noGap: boolean;
|
|
58
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions,
|
|
9
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
59
10
|
declare const _default: typeof __VLS_export;
|
|
60
11
|
export default _default;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { useKGridLogic
|
|
2
|
+
import { useKGridLogic } from "./KGrid.logic";
|
|
3
3
|
import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
4
4
|
import { computed } from "vue";
|
|
5
5
|
import KGridDefault from "../../presets/default/components/KGrid/KGrid.vue";
|
|
6
|
-
const props = defineProps(
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
direction: { type: String, required: false, default: "row" },
|
|
8
|
+
wrap: { type: String, required: false, default: "wrap" },
|
|
9
|
+
flexChild: { type: Boolean, required: false, default: false },
|
|
10
|
+
align: { type: String, required: false, default: "start" },
|
|
11
|
+
justify: { type: String, required: false, default: "start" },
|
|
12
|
+
noGap: { type: Boolean, required: false, default: false }
|
|
13
|
+
});
|
|
7
14
|
const { classes } = useKGridLogic(props);
|
|
8
15
|
const presetComponent = usePresetComponent("KGrid", KGridDefault);
|
|
9
16
|
const templateProps = computed(() => ({
|
|
@@ -1,60 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
wrap: {
|
|
7
|
-
type: PropType<"wrap" | "nowrap">;
|
|
8
|
-
default: string;
|
|
9
|
-
};
|
|
10
|
-
flexChild: {
|
|
11
|
-
type: BooleanConstructor;
|
|
12
|
-
default: boolean;
|
|
13
|
-
};
|
|
14
|
-
align: {
|
|
15
|
-
type: PropType<"start" | "center" | "end" | "stretch" | "baseline">;
|
|
16
|
-
default: string;
|
|
17
|
-
};
|
|
18
|
-
justify: {
|
|
19
|
-
type: PropType<"start" | "center" | "end" | "space-between" | "around" | "evenly">;
|
|
20
|
-
default: string;
|
|
21
|
-
};
|
|
22
|
-
noGap: {
|
|
23
|
-
type: BooleanConstructor;
|
|
24
|
-
default: boolean;
|
|
25
|
-
};
|
|
26
|
-
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
-
direction: {
|
|
28
|
-
type: PropType<"row" | "column">;
|
|
29
|
-
default: string;
|
|
30
|
-
};
|
|
31
|
-
wrap: {
|
|
32
|
-
type: PropType<"wrap" | "nowrap">;
|
|
33
|
-
default: string;
|
|
34
|
-
};
|
|
35
|
-
flexChild: {
|
|
36
|
-
type: BooleanConstructor;
|
|
37
|
-
default: boolean;
|
|
38
|
-
};
|
|
39
|
-
align: {
|
|
40
|
-
type: PropType<"start" | "center" | "end" | "stretch" | "baseline">;
|
|
41
|
-
default: string;
|
|
42
|
-
};
|
|
43
|
-
justify: {
|
|
44
|
-
type: PropType<"start" | "center" | "end" | "space-between" | "around" | "evenly">;
|
|
45
|
-
default: string;
|
|
46
|
-
};
|
|
47
|
-
noGap: {
|
|
48
|
-
type: BooleanConstructor;
|
|
49
|
-
default: boolean;
|
|
50
|
-
};
|
|
51
|
-
}>> & Readonly<{}>, {
|
|
52
|
-
wrap: any;
|
|
53
|
-
direction: any;
|
|
1
|
+
import { type KGridProps } from './KGrid.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KGridProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<KGridProps> & Readonly<{}>, {
|
|
3
|
+
wrap: "wrap" | "nowrap";
|
|
4
|
+
direction: "row" | "column";
|
|
54
5
|
flexChild: boolean;
|
|
55
|
-
align:
|
|
56
|
-
justify:
|
|
6
|
+
align: "start" | "center" | "end" | "stretch" | "baseline";
|
|
7
|
+
justify: "start" | "center" | "end" | "space-between" | "around" | "evenly";
|
|
57
8
|
noGap: boolean;
|
|
58
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions,
|
|
9
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
59
10
|
declare const _default: typeof __VLS_export;
|
|
60
11
|
export default _default;
|