@katlux/toolkit 0.1.1-alpha.90 → 0.1.1-alpha.92
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 +8 -4
- package/dist/module.json +1 -1
- package/dist/runtime/app.config.d.ts +2 -1
- package/dist/runtime/components/KAccordion/KAccordion.logic.d.ts +5 -1
- package/dist/runtime/components/KAccordion/KAccordion.logic.js +11 -4
- package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +10 -1
- package/dist/runtime/components/KAlert/KAlert.global.vue +9 -1
- package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +10 -1
- package/dist/runtime/components/KAlert/KAlert.logic.d.ts +10 -2
- package/dist/runtime/components/KAlert/KAlert.logic.js +18 -3
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCalendar/KCalendar.global.vue +5 -0
- package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +3 -1
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +37 -10
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +2 -2
- package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +1 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KModal/KModal.logic.js +4 -1
- package/dist/runtime/components/KTabs/KTabs.logic.js +12 -5
- package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
- package/dist/runtime/composables/usePresetComponent.d.ts +3 -2
- package/dist/runtime/composables/usePresetComponent.js +8 -4
- package/dist/runtime/plugins/PresetPlugin.d.ts +2 -3
- package/dist/runtime/plugins/PresetPlugin.js +3 -6
- package/dist/runtime/presets/default/components/KAccordion/KAccordionItem.vue +18 -1
- package/dist/runtime/presets/default/components/KAlert/KAlert.d.vue.ts +6 -1
- package/dist/runtime/presets/default/components/KAlert/KAlert.vue +113 -3
- package/dist/runtime/presets/default/components/KAlert/KAlert.vue.d.ts +6 -1
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +6 -3
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +17 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +3 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.d.vue.ts +8 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +302 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue.d.ts +8 -1
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +15 -3
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +7 -4
- package/dist/runtime/presets/default/components/KModal/KModal.vue +4 -1
- package/dist/runtime/presets/default/components/KPagination/KPagination.vue +16 -6
- package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +15 -3
- package/dist/runtime/presets/default/components/KTabs/KTabs.vue +9 -3
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +4 -1
- package/dist/runtime/presets/default/components/KTree/KTree.vue +13 -1
- package/package.json +1 -1
- package/dist/runtime/components/KSearchTree/KSearchTree.global.d.vue.ts +0 -3
- package/dist/runtime/components/KSearchTree/KSearchTree.global.vue +0 -9
- package/dist/runtime/components/KSearchTree/KSearchTree.global.vue.d.ts +0 -3
- package/dist/runtime/components/KSearchTree/KSearchTree.logic.d.ts +0 -10
- package/dist/runtime/components/KSearchTree/KSearchTree.logic.js +0 -9
- package/dist/runtime/components/KSearchTreeDropdown/KSearchTreeDropdown.global.d.vue.ts +0 -3
- package/dist/runtime/components/KSearchTreeDropdown/KSearchTreeDropdown.global.vue +0 -9
- package/dist/runtime/components/KSearchTreeDropdown/KSearchTreeDropdown.global.vue.d.ts +0 -3
- package/dist/runtime/components/KSearchTreeDropdown/KSearchTreeDropdown.logic.d.ts +0 -10
- package/dist/runtime/components/KSearchTreeDropdown/KSearchTreeDropdown.logic.js +0 -9
- package/dist/runtime/presets/default/components/KSearchTree/KSearchTree.d.vue.ts +0 -6
- package/dist/runtime/presets/default/components/KSearchTree/KSearchTree.vue +0 -13
- package/dist/runtime/presets/default/components/KSearchTree/KSearchTree.vue.d.ts +0 -6
- package/dist/runtime/presets/default/components/KSearchTreeDropdown/KSearchTreeDropdown.d.vue.ts +0 -6
- package/dist/runtime/presets/default/components/KSearchTreeDropdown/KSearchTreeDropdown.vue +0 -13
- package/dist/runtime/presets/default/components/KSearchTreeDropdown/KSearchTreeDropdown.vue.d.ts +0 -6
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { computed, defineAsyncComponent } from "vue";
|
|
2
|
-
import { useAppConfig } from "#app";
|
|
3
|
-
export
|
|
2
|
+
import { useAppConfig, useState } from "#app";
|
|
3
|
+
export function usePresetLoadersRegistry() {
|
|
4
|
+
return useState("katlux-preset-loaders-registry", () => ({}));
|
|
5
|
+
}
|
|
4
6
|
export function registerPresetComponents(presetName, loaders) {
|
|
5
|
-
|
|
7
|
+
const registry = usePresetLoadersRegistry();
|
|
8
|
+
registry.value[presetName] = loaders;
|
|
6
9
|
}
|
|
7
10
|
export function usePresetComponent(componentBaseName, defaultComponent) {
|
|
8
11
|
const appConfig = useAppConfig();
|
|
12
|
+
const registry = usePresetLoadersRegistry();
|
|
9
13
|
const presetStack = computed(() => {
|
|
10
14
|
const raw = appConfig.katluxToolkit?.activePreset;
|
|
11
15
|
const list = Array.isArray(raw) ? raw : raw ? [raw] : [];
|
|
@@ -15,7 +19,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
|
|
|
15
19
|
let loader;
|
|
16
20
|
for (const presetName of presetStack.value) {
|
|
17
21
|
if (presetName === "default") break;
|
|
18
|
-
const externalLoaders =
|
|
22
|
+
const externalLoaders = registry.value[presetName];
|
|
19
23
|
if (externalLoaders) {
|
|
20
24
|
const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
|
|
21
25
|
loader = externalLoaders[key];
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Katlux Preset Plugin
|
|
3
3
|
*
|
|
4
4
|
* This plugin initializes the preset system on app startup:
|
|
5
|
-
* - Creates the PresetResolver singleton
|
|
5
|
+
* - Creates the PresetResolver singleton per-request
|
|
6
6
|
* - Discovers available presets
|
|
7
|
-
* -
|
|
8
|
-
* - Provides global preset utilities
|
|
7
|
+
* - Provides global preset utilities with SSR request isolation
|
|
9
8
|
*/
|
|
10
9
|
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
11
10
|
export default _default;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useHead,
|
|
1
|
+
import { defineNuxtPlugin, useHead, useState } from "#app";
|
|
2
2
|
import { watch } from "vue";
|
|
3
3
|
import { PresetResolver } from "../utils/PresetResolver.js";
|
|
4
4
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
5
|
const resolver = new PresetResolver();
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
if (activePreset && appConfig.katluxToolkit) {
|
|
9
|
-
appConfig.katluxToolkit.activePreset = activePreset;
|
|
10
|
-
}
|
|
6
|
+
const activePresetState = useState("katlux-active-preset-state", () => resolver.getActivePreset());
|
|
7
|
+
const activePreset = activePresetState.value;
|
|
11
8
|
const updateRootAttribute = (preset) => {
|
|
12
9
|
useHead({
|
|
13
10
|
htmlAttrs: {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.accordion-item(:class="{'isOpen': isOpen}")
|
|
3
|
-
KGrid.accordion-item__header(
|
|
3
|
+
KGrid.accordion-item__header(
|
|
4
|
+
align="center"
|
|
5
|
+
justify="space-between"
|
|
6
|
+
noGap
|
|
7
|
+
@click="toggleAccordion"
|
|
8
|
+
@keydown.enter.prevent="toggleAccordion"
|
|
9
|
+
@keydown.space.prevent="toggleAccordion"
|
|
10
|
+
role="button"
|
|
11
|
+
:aria-expanded="isOpen"
|
|
12
|
+
tabindex="0"
|
|
13
|
+
)
|
|
4
14
|
.accordion-item__title {{title}}
|
|
5
15
|
KIcon.accordion-item__chevron(iconname="chevron", :class="{'open': isOpen}")
|
|
6
16
|
.accordion-item__content(:class="{'open': isOpen}")
|
|
@@ -17,6 +27,10 @@ const props = defineProps<{
|
|
|
17
27
|
|
|
18
28
|
<style lang="scss" scoped>
|
|
19
29
|
.accordion-item {
|
|
30
|
+
width: 100%;
|
|
31
|
+
min-width: 0;
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
overflow: hidden;
|
|
20
34
|
&__header {
|
|
21
35
|
padding: var(--component-gap);
|
|
22
36
|
background-color: var(--background-color-medium);
|
|
@@ -42,6 +56,9 @@ const props = defineProps<{
|
|
|
42
56
|
display: none;
|
|
43
57
|
padding-top: var(--box-padding);
|
|
44
58
|
padding-bottom: var(--box-padding);
|
|
59
|
+
width: 100%;
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
overflow: hidden;
|
|
45
62
|
&.open {
|
|
46
63
|
border-bottom: var(--box-border);
|
|
47
64
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { KAlertProps } from '../../../../components/KAlert/KAlert.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
dismiss: () => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
|
|
5
|
+
onDismiss?: (() => any) | undefined;
|
|
6
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
7
|
declare const _default: typeof __VLS_export;
|
|
3
8
|
export default _default;
|
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Transition(name="k-alert-fade")
|
|
3
|
+
.KAlert(v-if="visible" :class="[props.type]" role="alert")
|
|
4
|
+
.alert-icon {{ icon }}
|
|
5
|
+
.alert-body
|
|
6
|
+
.alert-title(v-if="props.title") {{ props.title }}
|
|
7
|
+
.alert-content
|
|
8
|
+
slot
|
|
9
|
+
button.alert-dismiss(v-if="props.dismissible" @click="dismiss" :aria-label="t('Dismiss')")
|
|
10
|
+
| ×
|
|
4
11
|
</template>
|
|
5
|
-
|
|
12
|
+
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
import type { KAlertProps } from '../../../../components/KAlert/KAlert.logic'
|
|
15
|
+
import { useKAlertLogic } from '../../../../components/KAlert/KAlert.logic'
|
|
16
|
+
|
|
17
|
+
const props = defineProps<KAlertProps>()
|
|
18
|
+
const emit = defineEmits<{ dismiss: [] }>()
|
|
19
|
+
const { visible, dismiss, icon } = useKAlertLogic(props, () => emit('dismiss'))
|
|
20
|
+
|
|
21
|
+
const nuxtApp = useNuxtApp?.()
|
|
22
|
+
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<style lang="scss" scoped>
|
|
26
|
+
.KAlert {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: flex-start;
|
|
29
|
+
gap: 0.75rem;
|
|
30
|
+
padding: 0.875rem 1.125rem;
|
|
31
|
+
border-radius: var(--border-radius-md, 8px);
|
|
32
|
+
border: 1px solid transparent;
|
|
33
|
+
font-size: var(--font-size-md, 14px);
|
|
34
|
+
line-height: 1.5;
|
|
35
|
+
margin-bottom: 0.75rem;
|
|
36
|
+
|
|
37
|
+
// Type variants
|
|
38
|
+
&.info {
|
|
39
|
+
background-color: var(--info-color-light, #cffafe);
|
|
40
|
+
border-color: var(--info-color, #06b6d4);
|
|
41
|
+
color: var(--cyan-900, #164e63);
|
|
42
|
+
}
|
|
43
|
+
&.success {
|
|
44
|
+
background-color: var(--success-color-light, #dcfce7);
|
|
45
|
+
border-color: var(--success-color, #4caf50);
|
|
46
|
+
color: var(--green-900, #14532d);
|
|
47
|
+
}
|
|
48
|
+
&.warning {
|
|
49
|
+
background-color: var(--warning-color-light, #fef9c3);
|
|
50
|
+
border-color: var(--warning-color, #eab308);
|
|
51
|
+
color: var(--yellow-900, #713f12);
|
|
52
|
+
}
|
|
53
|
+
&.danger {
|
|
54
|
+
background-color: var(--error-color-light, #fee2e2);
|
|
55
|
+
border-color: var(--error-color, #ef4444);
|
|
56
|
+
color: var(--red-900, #7f1d1d);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.alert-icon {
|
|
60
|
+
font-size: 1.1rem;
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
margin-top: 1px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.alert-body {
|
|
66
|
+
flex: 1;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.alert-title {
|
|
71
|
+
font-weight: var(--font-weight-semibold, 600);
|
|
72
|
+
margin-bottom: 0.25rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.alert-content {
|
|
76
|
+
font-size: var(--font-size-md, 14px);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.alert-dismiss {
|
|
80
|
+
background: none;
|
|
81
|
+
border: none;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
font-size: 1.25rem;
|
|
84
|
+
line-height: 1;
|
|
85
|
+
opacity: 0.6;
|
|
86
|
+
color: inherit;
|
|
87
|
+
padding: 0;
|
|
88
|
+
flex-shrink: 0;
|
|
89
|
+
transition: opacity var(--transition-fast, 0.15s ease);
|
|
90
|
+
|
|
91
|
+
&:hover {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.k-alert-fade-enter-active,
|
|
98
|
+
.k-alert-fade-leave-active {
|
|
99
|
+
transition: all var(--transition-normal, 0.3s ease);
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
}
|
|
102
|
+
.k-alert-fade-enter-from,
|
|
103
|
+
.k-alert-fade-leave-to {
|
|
104
|
+
opacity: 0;
|
|
105
|
+
max-height: 0;
|
|
106
|
+
padding-top: 0;
|
|
107
|
+
padding-bottom: 0;
|
|
108
|
+
margin-bottom: 0;
|
|
109
|
+
}
|
|
110
|
+
.k-alert-fade-enter-to,
|
|
111
|
+
.k-alert-fade-leave-from {
|
|
112
|
+
opacity: 1;
|
|
113
|
+
max-height: 200px;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { KAlertProps } from '../../../../components/KAlert/KAlert.logic.js';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
dismiss: () => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
|
|
5
|
+
onDismiss?: (() => any) | undefined;
|
|
6
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
7
|
declare const _default: typeof __VLS_export;
|
|
3
8
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.k-bulk-actions
|
|
3
3
|
template(v-if="props.bulkActions.length>3")
|
|
4
|
-
KCombobox(:dataProvider="dp" v-model="internalSelected" labelField="label" closeOnSelect :disabled="props.selectedRows.length === 0" placeholder="Select an action")
|
|
5
|
-
KButton(@click="doAction(internalSelected)" size="small" :disabled="props.selectedRows.length === 0 || internalSelected == undefined")
|
|
4
|
+
KCombobox(:dataProvider="dp" v-model="internalSelected" labelField="label" closeOnSelect :disabled="props.selectedRows.length === 0" :placeholder="t('Select an action')")
|
|
5
|
+
KButton(@click="doAction(internalSelected)" size="small" :disabled="props.selectedRows.length === 0 || internalSelected == undefined") {{ t('Apply') }}
|
|
6
6
|
template(v-else-if="props.bulkActions.length<=3" v-for="(action, index) in props.bulkActions")
|
|
7
7
|
KTooltip(
|
|
8
8
|
:text="action.label"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
template(#icon v-if="action.icon")
|
|
19
19
|
KIcon(:iconname="action.icon" :width="16" :height="16")
|
|
20
20
|
template(#default v-if="!action.iconOnly && !action.icon") {{action.label}}
|
|
21
|
-
.info Selected {{props.selectedRows.length}}
|
|
21
|
+
.info {{ t('Selected {count} items').replace('{count}', props.selectedRows.length.toString()) }}
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script setup lang="ts">
|
|
@@ -26,6 +26,9 @@ import { computed } from 'vue'
|
|
|
26
26
|
import { CFlatClientDataProvider } from '@katlux/providers'
|
|
27
27
|
import type { IKDatatableAction } from '@katlux/providers'
|
|
28
28
|
|
|
29
|
+
const nuxtApp = useNuxtApp?.()
|
|
30
|
+
const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
|
|
31
|
+
|
|
29
32
|
const props = defineProps<{
|
|
30
33
|
bulkActions: IKDatatableAction[]
|
|
31
34
|
selectedRows: any[]
|
|
@@ -3,7 +3,10 @@ type __VLS_Props = {
|
|
|
3
3
|
view: string;
|
|
4
4
|
viewCount: number;
|
|
5
5
|
actualYear: any;
|
|
6
|
+
actualMonth: any;
|
|
7
|
+
activeDate: Date;
|
|
6
8
|
monthSelectedDay: any;
|
|
9
|
+
rawMarkedDays?: IMarkedDay[];
|
|
7
10
|
goToPrev: () => void;
|
|
8
11
|
goToNext: () => void;
|
|
9
12
|
getMonthName: (i: number) => string;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KCalendar
|
|
3
|
-
.
|
|
3
|
+
.week-view(v-if="view=='week'")
|
|
4
|
+
.view-header
|
|
5
|
+
.prev(@click="goToPrev")
|
|
6
|
+
KIcon(iconname="chevron" width=10 height=10 rotate="180")
|
|
7
|
+
.year {{ getMonthName(1) }} {{ actualYear }}
|
|
8
|
+
.next(@click="goToNext")
|
|
9
|
+
KIcon(iconname="chevron" width=10 height=10)
|
|
10
|
+
KCalendarWeek(
|
|
11
|
+
:currentDate="activeDate"
|
|
12
|
+
:selectedDay="monthSelectedDay"
|
|
13
|
+
:markedDays="rawMarkedDays && rawMarkedDays.length > 0 ? rawMarkedDays : getExpandedMarkedDays(1)"
|
|
14
|
+
:dayClicked="dayClicked"
|
|
15
|
+
)
|
|
16
|
+
.month-view(v-else)
|
|
4
17
|
.view-header
|
|
5
18
|
.prev(@click="goToPrev")
|
|
6
19
|
KIcon(iconname="chevron" width=10 height=10 rotate="180")
|
|
@@ -27,7 +40,10 @@ const props = defineProps<{
|
|
|
27
40
|
view: string
|
|
28
41
|
viewCount: number
|
|
29
42
|
actualYear: any
|
|
43
|
+
actualMonth: any
|
|
44
|
+
activeDate: Date
|
|
30
45
|
monthSelectedDay: any
|
|
46
|
+
rawMarkedDays?: IMarkedDay[]
|
|
31
47
|
goToPrev: () => void
|
|
32
48
|
goToNext: () => void
|
|
33
49
|
getMonthName: (i: number) => string
|
|
@@ -3,7 +3,10 @@ type __VLS_Props = {
|
|
|
3
3
|
view: string;
|
|
4
4
|
viewCount: number;
|
|
5
5
|
actualYear: any;
|
|
6
|
+
actualMonth: any;
|
|
7
|
+
activeDate: Date;
|
|
6
8
|
monthSelectedDay: any;
|
|
9
|
+
rawMarkedDays?: IMarkedDay[];
|
|
7
10
|
goToPrev: () => void;
|
|
8
11
|
goToNext: () => void;
|
|
9
12
|
getMonthName: (i: number) => string;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IMarkedDay } from '../../../../components/KCalendar/types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
currentDate?: Date | string;
|
|
4
|
+
selectedDay?: Date | string;
|
|
5
|
+
markedDays?: IMarkedDay[];
|
|
6
|
+
dayClicked: (date: Date) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
9
|
declare const _default: typeof __VLS_export;
|
|
3
10
|
export default _default;
|
|
@@ -1,5 +1,305 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
.KCalendarWeek
|
|
3
|
-
//
|
|
3
|
+
// Left fixed time column
|
|
4
|
+
.time-column-wrapper
|
|
5
|
+
.time-header-space
|
|
6
|
+
.time-slots-container(ref="timeContainerRef")
|
|
7
|
+
.time-slot(v-for="hour in 24" :key="hour")
|
|
8
|
+
span {{ formatHour(hour - 1) }}
|
|
9
|
+
|
|
10
|
+
// Right days schedule column
|
|
11
|
+
.days-scroll-body(@scroll="handleScroll")
|
|
12
|
+
.week-headers
|
|
13
|
+
.day-header(v-for="(dayName, i) in weekDays" :key="i")
|
|
14
|
+
.day-name {{ dayName }}
|
|
15
|
+
.day-date(
|
|
16
|
+
:class="{ today: isToday(weekDates[i]), selected: isSelected(weekDates[i]) }"
|
|
17
|
+
@click="dayClicked(weekDates[i])"
|
|
18
|
+
) {{ weekDates[i].getDate() }}
|
|
19
|
+
|
|
20
|
+
.days-grid
|
|
21
|
+
.day-column(v-for="(date, dayIdx) in weekDates" :key="dayIdx")
|
|
22
|
+
.hour-cell(
|
|
23
|
+
v-for="hour in 24"
|
|
24
|
+
:key="hour"
|
|
25
|
+
@click="cellClicked(date, hour - 1)"
|
|
26
|
+
)
|
|
27
|
+
// Render events for this day & hour
|
|
28
|
+
.event-tag(
|
|
29
|
+
v-for="(evt, evtIdx) in getEventsForSlot(date, hour - 1)"
|
|
30
|
+
:key="evtIdx"
|
|
31
|
+
:class="evt.type || 'info'"
|
|
32
|
+
:title="evt.description || evt.label"
|
|
33
|
+
) {{ evt.label }}
|
|
4
34
|
</template>
|
|
5
|
-
|
|
35
|
+
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import { computed, ref } from 'vue'
|
|
38
|
+
import type { IMarkedDay } from '../../../../components/KCalendar/types'
|
|
39
|
+
|
|
40
|
+
const timeContainerRef = ref<HTMLElement | null>(null)
|
|
41
|
+
|
|
42
|
+
function handleScroll(e: Event) {
|
|
43
|
+
const target = e.target as HTMLElement
|
|
44
|
+
if (timeContainerRef.value && target) {
|
|
45
|
+
timeContainerRef.value.scrollTop = target.scrollTop
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const props = defineProps<{
|
|
50
|
+
currentDate?: Date | string
|
|
51
|
+
selectedDay?: Date | string
|
|
52
|
+
markedDays?: IMarkedDay[]
|
|
53
|
+
dayClicked: (date: Date) => void
|
|
54
|
+
}>()
|
|
55
|
+
|
|
56
|
+
const weekDays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
57
|
+
|
|
58
|
+
const baseDate = computed(() => {
|
|
59
|
+
if (!props.currentDate) return new Date()
|
|
60
|
+
return typeof props.currentDate === 'string' ? new Date(props.currentDate) : props.currentDate
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const weekDates = computed(() => {
|
|
64
|
+
const curr = new Date(baseDate.value)
|
|
65
|
+
const dayOfWeek = curr.getDay()
|
|
66
|
+
const distanceToMon = (dayOfWeek + 6) % 7
|
|
67
|
+
const monday = new Date(curr)
|
|
68
|
+
monday.setDate(curr.getDate() - distanceToMon)
|
|
69
|
+
|
|
70
|
+
const dates: Date[] = []
|
|
71
|
+
for (let i = 0; i < 7; i++) {
|
|
72
|
+
const d = new Date(monday)
|
|
73
|
+
d.setDate(monday.getDate() + i)
|
|
74
|
+
dates.push(d)
|
|
75
|
+
}
|
|
76
|
+
return dates
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
function formatHour(h: number) {
|
|
80
|
+
return `${h.toString().padStart(2, '0')}:00`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isToday(date: Date) {
|
|
84
|
+
const today = new Date()
|
|
85
|
+
return (
|
|
86
|
+
date.getDate() === today.getDate() &&
|
|
87
|
+
date.getMonth() === today.getMonth() &&
|
|
88
|
+
date.getFullYear() === today.getFullYear()
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isSelected(date: Date) {
|
|
93
|
+
if (!props.selectedDay) return false
|
|
94
|
+
const sel = typeof props.selectedDay === 'string' ? new Date(props.selectedDay) : props.selectedDay
|
|
95
|
+
return (
|
|
96
|
+
date.getDate() === sel.getDate() &&
|
|
97
|
+
date.getMonth() === sel.getMonth() &&
|
|
98
|
+
date.getFullYear() === sel.getFullYear()
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function cellClicked(date: Date, hour: number) {
|
|
103
|
+
const slotDate = new Date(date)
|
|
104
|
+
slotDate.setHours(hour, 0, 0, 0)
|
|
105
|
+
props.dayClicked(slotDate)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function getEventsForSlot(date: Date, hour: number): IMarkedDay[] {
|
|
109
|
+
if (!props.markedDays) return []
|
|
110
|
+
return props.markedDays.filter(evt => {
|
|
111
|
+
if (!evt.date) return false
|
|
112
|
+
let evtDate: Date | null = null
|
|
113
|
+
|
|
114
|
+
// 1. Direct JS Date or Date string / ISO
|
|
115
|
+
if (evt.date instanceof Date) {
|
|
116
|
+
evtDate = evt.date
|
|
117
|
+
} else if (typeof evt.date === 'string') {
|
|
118
|
+
evtDate = new Date(evt.date)
|
|
119
|
+
} else if ((evt.date as any).startDate) {
|
|
120
|
+
evtDate = new Date((evt.date as any).startDate)
|
|
121
|
+
} else if ((evt.date as any).recurringRules) {
|
|
122
|
+
// Recurring rule support: check if recurring rule lands on this date
|
|
123
|
+
const rules = (evt.date as any).recurringRules
|
|
124
|
+
for (const r of rules) {
|
|
125
|
+
if (r.daysOfYear) {
|
|
126
|
+
for (const doy of r.daysOfYear) {
|
|
127
|
+
if (doy.month === (date.getMonth() + 1) && doy.day === date.getDate()) {
|
|
128
|
+
evtDate = date
|
|
129
|
+
break
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} else if (r.daysOfWeek) {
|
|
133
|
+
const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
134
|
+
if (r.daysOfWeek.includes(dayNames[date.getDay()])) {
|
|
135
|
+
evtDate = date
|
|
136
|
+
break
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!evtDate || isNaN(evtDate.getTime())) return false
|
|
143
|
+
|
|
144
|
+
const sameDay =
|
|
145
|
+
evtDate.getDate() === date.getDate() &&
|
|
146
|
+
evtDate.getMonth() === date.getMonth() &&
|
|
147
|
+
evtDate.getFullYear() === date.getFullYear()
|
|
148
|
+
|
|
149
|
+
if (!sameDay) return false
|
|
150
|
+
|
|
151
|
+
// Default to 9 AM slot if no specific hour was assigned to the event
|
|
152
|
+
const evtHour = (evt as any).hour ?? (evtDate.getHours() !== 0 ? evtDate.getHours() : 9)
|
|
153
|
+
return evtHour === hour
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<style lang="scss" scoped>
|
|
159
|
+
.KCalendarWeek {
|
|
160
|
+
width: 540px;
|
|
161
|
+
border: 1px solid var(--border-color-light, #e5e7eb);
|
|
162
|
+
border-radius: var(--border-radius-md, 8px);
|
|
163
|
+
background: var(--panel-bg-default, #ffffff);
|
|
164
|
+
overflow: hidden;
|
|
165
|
+
box-sizing: border-box;
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: row;
|
|
168
|
+
|
|
169
|
+
.time-column-wrapper {
|
|
170
|
+
width: 50px;
|
|
171
|
+
flex-shrink: 0;
|
|
172
|
+
border-right: 1px solid var(--border-color-light, #e5e7eb);
|
|
173
|
+
background: var(--neutral-50, #f9fafb);
|
|
174
|
+
|
|
175
|
+
.time-header-space {
|
|
176
|
+
height: 52px;
|
|
177
|
+
border-bottom: 1px solid var(--border-color-light, #e5e7eb);
|
|
178
|
+
box-sizing: border-box;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.time-slots-container {
|
|
182
|
+
height: 340px;
|
|
183
|
+
overflow: hidden;
|
|
184
|
+
|
|
185
|
+
.time-slot {
|
|
186
|
+
height: 36px;
|
|
187
|
+
display: flex;
|
|
188
|
+
align-items: flex-start;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
padding-top: 2px;
|
|
191
|
+
font-size: 10px;
|
|
192
|
+
color: var(--font-color-secondary, #6b7280);
|
|
193
|
+
border-bottom: 1px solid var(--border-color-light, #e5e7eb);
|
|
194
|
+
box-sizing: border-box;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.days-scroll-body {
|
|
200
|
+
flex: 1;
|
|
201
|
+
height: 392px;
|
|
202
|
+
overflow-y: scroll;
|
|
203
|
+
min-width: 0;
|
|
204
|
+
|
|
205
|
+
&::-webkit-scrollbar {
|
|
206
|
+
width: 6px;
|
|
207
|
+
}
|
|
208
|
+
&::-webkit-scrollbar-track {
|
|
209
|
+
background: var(--neutral-50, #f9fafb);
|
|
210
|
+
}
|
|
211
|
+
&::-webkit-scrollbar-thumb {
|
|
212
|
+
background: var(--neutral-300, #d1d5db);
|
|
213
|
+
border-radius: 3px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.week-headers {
|
|
217
|
+
position: sticky;
|
|
218
|
+
top: 0;
|
|
219
|
+
z-index: 10;
|
|
220
|
+
display: grid;
|
|
221
|
+
grid-template-columns: repeat(7, 1fr);
|
|
222
|
+
border-bottom: 1px solid var(--border-color-light, #e5e7eb);
|
|
223
|
+
background: var(--neutral-50, #f9fafb);
|
|
224
|
+
height: 52px;
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
|
|
227
|
+
.day-header {
|
|
228
|
+
text-align: center;
|
|
229
|
+
padding: 6px 2px;
|
|
230
|
+
border-right: 1px solid var(--border-color-light, #e5e7eb);
|
|
231
|
+
box-sizing: border-box;
|
|
232
|
+
&:last-child { border-right: none; }
|
|
233
|
+
|
|
234
|
+
.day-name {
|
|
235
|
+
font-size: 11px;
|
|
236
|
+
color: var(--font-color-secondary, #6b7280);
|
|
237
|
+
font-weight: 500;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.day-date {
|
|
241
|
+
width: 24px;
|
|
242
|
+
height: 24px;
|
|
243
|
+
margin: 2px auto 0 auto;
|
|
244
|
+
display: flex;
|
|
245
|
+
align-items: center;
|
|
246
|
+
justify-content: center;
|
|
247
|
+
border-radius: 50%;
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
font-size: 12px;
|
|
250
|
+
font-weight: 600;
|
|
251
|
+
|
|
252
|
+
&.today { border: 2px solid var(--primary-500, #3b82f6); }
|
|
253
|
+
&.selected { background: var(--primary-500, #3b82f6); color: #fff; }
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.days-grid {
|
|
259
|
+
display: grid;
|
|
260
|
+
grid-template-columns: repeat(7, 1fr);
|
|
261
|
+
|
|
262
|
+
.day-column {
|
|
263
|
+
border-right: 1px solid var(--border-color-light, #e5e7eb);
|
|
264
|
+
box-sizing: border-box;
|
|
265
|
+
&:last-child { border-right: none; }
|
|
266
|
+
|
|
267
|
+
.hour-cell {
|
|
268
|
+
height: 36px;
|
|
269
|
+
border-bottom: 1px solid var(--border-color-light, #f3f4f6);
|
|
270
|
+
box-sizing: border-box;
|
|
271
|
+
padding: 1px;
|
|
272
|
+
cursor: pointer;
|
|
273
|
+
position: relative;
|
|
274
|
+
transition: background 0.15s ease;
|
|
275
|
+
|
|
276
|
+
&:hover {
|
|
277
|
+
background: var(--neutral-100, #f3f4f6);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.event-tag {
|
|
281
|
+
font-size: 9px;
|
|
282
|
+
line-height: 1.1;
|
|
283
|
+
padding: 2px 3px;
|
|
284
|
+
border-radius: 3px;
|
|
285
|
+
white-space: nowrap;
|
|
286
|
+
overflow: hidden;
|
|
287
|
+
text-overflow: ellipsis;
|
|
288
|
+
color: #fff;
|
|
289
|
+
background: var(--primary-500, #3b82f6);
|
|
290
|
+
position: absolute;
|
|
291
|
+
inset: 1px;
|
|
292
|
+
z-index: 2;
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
|
|
296
|
+
&.warning { background: var(--warning-color, #eab308); color: #000; }
|
|
297
|
+
&.error { background: var(--error-color, #ef4444); }
|
|
298
|
+
&.success { background: var(--success-color, #22c55e); }
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
</style>
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { IMarkedDay } from '../../../../components/KCalendar/types.js';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
currentDate?: Date | string;
|
|
4
|
+
selectedDay?: Date | string;
|
|
5
|
+
markedDays?: IMarkedDay[];
|
|
6
|
+
dayClicked: (date: Date) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
2
9
|
declare const _default: typeof __VLS_export;
|
|
3
10
|
export default _default;
|