mood-ui 0.12.0 → 0.12.1
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/components/data-display/calendar/AgendaView.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.mjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs +7 -5
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs +14 -12
- package/dist/components/data-display/calendar/AgendaView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/data-display/calendar/Calendar.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.mjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs +7 -5
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs +15 -13
- package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs +1 -1
- package/dist/components/data-display/calendar/MonthView.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs +1 -1
- package/dist/components/data-display/calendar/MonthView.mjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs +7 -5
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs +10 -8
- package/dist/components/data-display/calendar/MonthView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.mjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs +7 -5
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs +15 -13
- package/dist/components/data-display/calendar/Scheduler.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.mjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs +7 -5
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.cjs.map +1 -1
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs +15 -13
- package/dist/components/data-display/calendar/WeekView.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/dist/components/data-display/date-picker/DateRangePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs +2 -2
- package/dist/components/data-display/date-picker/DateTimePicker.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs +4 -4
- package/dist/components/feedback/Banner.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs +5 -5
- package/dist/components/feedback/Drawer.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs +5 -5
- package/dist/components/feedback/Modal.vue_vue_type_script_setup_true_lang.mjs.map +1 -1
- package/dist/mood-ui.css +1 -1
- package/dist/types/utils/calendarTooltip.d.ts +13 -0
- package/dist/utils/calendarTooltip.cjs +18 -0
- package/dist/utils/calendarTooltip.cjs.map +1 -0
- package/dist/utils/calendarTooltip.mjs +18 -0
- package/dist/utils/calendarTooltip.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayView.mjs","names":[],"sources":["../../../../src/components/data-display/calendar/DayView.vue"],"sourcesContent":["<template> \n <div \n ref=\"rootRef\" \n tabindex=\"-1\" \n :class=\"['relative flex flex-col bg-card overflow-hidden focus:outline-none', containerRadiusClass, bordered ? 'border border-border' : '']\" \n :style=\"{ maxHeight: toCssLength(maxHeight) }\"\n @keydown=\"handleKeydown\" \n > \n <slot name=\"header\" :label=\"headerLabel\" :goToToday=\"handleToday\" :prev=\"handlePrev\" :next=\"handleNext\" :prevYear=\"handlePrevYear\" :nextYear=\"handleNextYear\"> \n <CalendarHeader \n :label=\"headerLabel\" \n :weekdayLabel=\"weekdayLabel\" \n :showHeader=\"showHeader\" \n :showYearJump=\"showYearJump\" \n :showTodayButton=\"showTodayButton\" \n :showMonthYearSelects=\"showMonthYearSelects\" \n :monthOptions=\"monthOptions\" \n :yearOptions=\"yearOptions\" \n :dayOptions=\"dayOptions\" \n v-model:selectedDay=\"selectedDay\" \n v-model:selectedMonth=\"selectedMonth\" \n v-model:selectedYear=\"selectedYear\" \n :isPrevDisabled=\"isPrevDisabled\" \n :isNextDisabled=\"isNextDisabled\" \n prevLabel=\"Previous day\" \n nextLabel=\"Next day\" \n :color=\"resolvedColor\" \n :focusRingColorClass=\"focusRingColorClass\" \n :todayTextClass=\"todayTextClass\" \n :todayRadiusClass=\"pillRadiusClass\" \n :dayNameCaseClass=\"dayNameCaseClass\" \n @prev=\"handlePrev\" \n @next=\"handleNext\" \n @prevYear=\"handlePrevYear\" \n @nextYear=\"handleNextYear\" \n @today=\"handleToday\" \n /> \n </slot> \n \n <div v-if=\"showAllDayRow && allDayRows > 0\" class=\"flex border-b border-border\" :style=\"{ paddingRight: scrollbarWidth + 'px' }\"> \n <div class=\"w-14 shrink-0 flex items-start justify-end pr-2 pt-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider\"> \n all-day \n </div> \n <div \n class=\"relative flex-1\" \n :style=\"[ \n { height: `${allDayRows * 22 + 4}px` }, \n dayIsDisabled ? disabledStripePattern : undefined, \n ]\" \n @click=\"handleAllDayCellClick($event)\" \n @dblclick=\"handleAllDayCellDblClick($event)\" \n @dragover.prevent=\"onAllDayDragOver($event)\" \n @drop.prevent=\"onAllDayDrop($event)\" \n :class=\"[ \n 'transition-colors', \n dayIsDisabled ? 'cursor-not-allowed' : 'cursor-pointer hover:bg-muted/60', \n allDayDragOver ? 'bg-muted' : '', \n ]\" \n > \n <div \n v-for=\"seg in allDaySegments\" \n :key=\"seg.key\" \n :data-eid=\"seg.event.id\" \n :draggable=\"draggableEvents && isEventInteractive(seg.event)\" \n @dragstart=\"onDragStart(seg.event, $event)\" \n @dragend=\"onDragEnd\" \n @click.stop=\"handleEventClick(seg.event, $event)\" \n @mouseenter=\"onEventEnter(seg.event, true, $event)\" \n @mousemove=\"onEventMove\" \n @mouseleave=\"onEventLeave\" \n :style=\"[ \n { \n left: '2px', \n right: '2px', \n top: `${seg.lane * 22 + 2}px`, \n height: '20px', \n }, \n eventInlineStyle(seg.event), \n ]\" \n :class=\"[ \n 'absolute z-10 truncate text-xs px-1.5 flex items-center cursor-pointer transition-all hover:opacity-80 select-none', \n eventRadiusClass, \n draggableEvents ? 'cursor-grab active:cursor-grabbing' : '', \n seg.event.colorHex ? '' : eventColorClass(seg.event.color, showEventAccent), \n draggingId === seg.event.id ? 'opacity-70 scale-95' : '', \n ]\" \n > \n <slot name=\"event\" :event=\"seg.event\" :allDay=\"true\"> \n <span class=\"truncate font-medium\">{{ seg.event.title }}</span> \n </slot> \n </div> \n </div> \n </div> \n \n <div ref=\"scrollRef\" class=\"flex-1 overflow-y-scroll relative\" style=\"scrollbar-gutter: stable;\"> \n <div class=\"flex\"> \n <div class=\"w-14 shrink-0 relative\" :style=\"{ height: `${totalPixels}px` }\"> \n <div \n v-for=\"h in hourLabels\" \n :key=\"h.offset\" \n class=\"absolute right-0 pr-2 text-[10px] font-medium text-muted-foreground tracking-wide -translate-y-1/2\" \n :style=\"{ top: `${h.offset * 60 * (slotHeight / slotMinutes)}px` }\" \n > \n <span v-if=\"h.offset !== 0 && h.offset !== windowHours\">{{ h.label }}</span> \n </div> \n <span \n v-if=\"showCurrentTime && showCurrentTimeLabel && isTodayInView\" \n :class=\"['absolute right-1 -translate-y-1/2 px-1 py-0.5 text-[10px] font-semibold text-white leading-none z-30 pointer-events-none', eventRadiusClass, currentTimeSolidClass]\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n >{{ currentTimeLabel }}</span> \n <span \n v-else-if=\"showCurrentTime && !showCurrentTimeLabel && isTodayInView\" \n :class=\"['absolute right-0 -translate-y-1/2 w-1.5 h-1.5 rounded-full z-30 pointer-events-none', currentTimeSolidClass]\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n ></span> \n </div> \n \n <div \n ref=\"colRef\" \n class=\"relative flex-1 border-l border-border\" \n @pointerdown=\"onColPointerDown($event)\" \n @click=\"handleSlotClick($event)\" \n @dblclick=\"handleSlotDblClick($event)\" \n @dragover.prevent=\"onDragOver($event)\" \n @drop.prevent=\"onDrop($event)\" \n > \n <div \n v-for=\"(_, idx) in totalSlots\" \n :key=\"idx\" \n :style=\"[ \n { height: `${slotHeight}px` }, \n isSlotDisabled(idx) \n ? disabledStripePattern \n : !isBusinessHourSlot(idx) \n ? { backgroundColor: 'rgba(0,0,0,0.015)' } \n : undefined, \n ]\" \n :class=\"[ \n 'border-t', \n idx === 0 ? 'border-transparent' : idx % slotsPerHour === 0 ? 'border-border' : 'border-dashed border-border/70', \n isSlotDisabled(idx) ? 'cursor-not-allowed' : '', \n ]\" \n ></div> \n \n <div \n v-if=\"dayIsDisabled\" \n class=\"absolute inset-0 pointer-events-none\" \n :style=\"disabledStripePattern\" \n ></div> \n \n <div \n v-for=\"seg in timedSegments\" \n :key=\"seg.key\" \n :data-eid=\"seg.event.id\" \n :draggable=\"draggableEvents && resizingId !== seg.event.id && isEventInteractive(seg.event)\" \n @dragstart.stop=\"onDragStart(seg.event, $event)\" \n @dragend=\"onDragEnd\" \n @click.stop=\"handleEventClick(seg.event, $event)\" \n @pointerdown.stop \n @mouseenter=\"onEventEnter(seg.event, false, $event)\" \n @mousemove=\"onEventMove\" \n @mouseleave=\"onEventLeave\" \n :style=\"[seg.style, eventInlineStyle(seg.event)]\" \n :class=\"[ \n 'absolute z-10 overflow-hidden transition-all hover:opacity-90 select-none flex flex-col', \n eventRadiusClass, \n isEventInteractive(seg.event) ? 'cursor-pointer' : 'cursor-default', \n draggableEvents && isEventInteractive(seg.event) ? 'cursor-grab active:cursor-grabbing' : '', \n seg.event.colorHex ? (showEventAccent ? 'border-l-2' : '') : eventColorClass(seg.event.color, showEventAccent), \n draggingId === seg.event.id ? 'opacity-70 scale-95' : '', \n ]\" \n > \n <slot name=\"event\" :event=\"seg.event\" :allDay=\"false\"> \n <div class=\"px-2 py-1 flex-1 min-h-0\"> \n <div class=\"text-[10px] font-semibold leading-tight opacity-80\">{{ formatEventTime(seg.event.start) }}<template v-if=\"seg.event.end\"> – {{ formatEventTime(seg.event.end) }}</template></div> \n <div class=\"text-xs font-medium truncate leading-tight\">{{ seg.event.title }}</div> \n <div v-if=\"seg.event.description\" class=\"text-[11px] opacity-70 truncate leading-tight mt-0.5\">{{ seg.event.description }}</div> \n </div> \n </slot> \n <div \n v-if=\"resizableEvents && isEventInteractive(seg.event)\" \n draggable=\"false\" \n @mousedown.stop.prevent \n @dragstart.stop.prevent \n @pointerdown.stop=\"onResizeStart(seg.event, $event)\" \n class=\"absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize hover:bg-black/10\" \n ></div> \n </div> \n \n <div \n v-if=\"showCurrentTime && isTodayInView\" \n class=\"absolute left-0 right-0 h-px pointer-events-none z-20\" \n :class=\"currentTimeSolidClass\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n ></div> \n \n <div \n v-if=\"dragOverActive\" \n class=\"absolute inset-0 pointer-events-none z-0 bg-muted/60\" \n ></div> \n \n <div \n v-if=\"rangeSelect\" \n :class=\"['absolute left-1 right-1 pointer-events-none z-20 border border-dashed', eventRadiusClass, rangeSelectClass]\" \n :style=\"{ top: `${rangeSelect.topPx}px`, height: `${rangeSelect.heightPx}px` }\" \n ></div> \n \n <div \n v-if=\"resizingPreview\" \n :class=\"['absolute left-1 right-1 pointer-events-none z-20 border border-dashed border-muted-foreground bg-foreground/5', eventRadiusClass]\" \n :style=\"{ top: `${resizingPreview.topPx}px`, height: `${resizingPreview.heightPx}px` }\" \n ></div> \n </div> \n </div> \n </div> \n \n <button \n v-if=\"showNowPill && isTodayInView\" \n type=\"button\" \n @click=\"scrollToCurrentTime\" \n :class=\"['absolute bottom-4 right-6 z-40 px-3 py-1.5 flex items-center gap-1.5 text-xs font-medium shadow-lg bg-card border border-border hover:bg-muted transition-all cursor-pointer', pillRadiusClass]\" \n > \n <span class=\"w-1.5 h-1.5\" :class=\"[pillRadiusClass, currentTimeSolidClass]\"></span> \n <span class=\"text-foreground/80\">Now</span> \n </button> \n \n <CalendarEventTooltip :state=\"hoverState\" :style=\"tooltipStyle\" :formatTime=\"formatEventTime\"> \n <template #default=\"{ event, allDay }\"> \n <slot name=\"event-tooltip\" :event=\"event\" :allDay=\"allDay\" /> \n </template> \n </CalendarEventTooltip> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { ref, computed, watch, nextTick, onMounted, onUnmounted } from 'vue'; \nimport gsap from 'gsap'; \nimport { isSameDay, startOfDay } from '../../../composables/useCalendar'; \nimport { useCalendarTheme } from '../../../composables/useCalendarTheme'; \nimport { useEventHover } from '../../../composables/useEventHover'; \nimport { useAutoScroll } from '../../../composables/useAutoScroll'; \nimport { useCurrentTimeLine } from '../../../composables/useCurrentTimeLine'; \nimport { useTimeGrid, MS_MIN } from '../../../composables/useTimeGrid'; \nimport { eventColorClass, hexToRgba } from '../../../composables/eventColors'; \nimport CalendarEventTooltip from './CalendarEventTooltip.vue'; \nimport CalendarHeader from './CalendarHeader.vue'; \nimport type { DayView } from '../../../interfaces/data-display/calendar/DayView.interface'; \nimport type { BusinessHours } from '../../../interfaces/data-display/calendar/WeekView.interface'; \nimport type { CalendarEvent } from '../../../interfaces/data-display/calendar/MonthView.interface'; \n \nimport { toCssLength } from '../../../utils/cssLength';\n\nconst props = withDefaults(defineProps<DayView>(), { \n modelValue: () => new Date(), \n events: () => [], \n locale: 'default', \n color: 'default', \n bordered: true, \n dayNameFormat: 'long', \n dayNameCase: 'upper', \n highlightedDates: () => [], \n disabledDates: () => [], \n disabledWeekdays: () => [], \n disabledTimeRanges: () => [], \n showHeader: true, \n showYearJump: false, \n showTodayButton: true, \n showMonthYearSelects: false, \n hourStart: 0, \n hourEnd: 24, \n slotMinutes: 30, \n slotHeight: 28, \n format: '24h', \n showCurrentTime: true, \n showCurrentTimeLabel: true, \n currentTimeColor: 'red', \n currentTimeUpdateInterval: 60000, \n draggableEvents: true, \n resizableEvents: true, \n allowRangeSelection: true, \n allowDropOnDisabled: false, \n allowResizeOverDisabled: false, \n readonly: false, \n preventOverlap: false, \n autoScrollOnDrag: true, \n showAllDayRow: true, \n enableKeyboardNavigation: true, \n showNowPill: true, \n}); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [date: Date]; \n 'event-click': [event: CalendarEvent, nativeEvent: MouseEvent]; \n 'slot-click': [date: Date, nativeEvent: MouseEvent]; \n 'create-event': [date: Date, allDay: boolean, nativeEvent: MouseEvent | KeyboardEvent]; \n 'event-drop': [event: CalendarEvent, newStart: Date, newEnd: Date | undefined]; \n 'event-resize': [event: CalendarEvent, newStart: Date, newEnd: Date]; \n 'select-range': [start: Date, end: Date]; \n}>(); \n \nconst currentDate = ref(startOfDay(new Date(props.modelValue))); \nwatch(() => props.modelValue, (v) => { if (v) currentDate.value = startOfDay(new Date(v)); }); \n \nconst rootRef = ref<HTMLElement | null>(null); \nconst scrollRef = ref<HTMLElement | null>(null); \nconst colRef = ref<HTMLElement | null>(null); \nconst now = ref(new Date()); \nconst scrollbarWidth = ref(0); \nlet tickInterval: ReturnType<typeof setInterval> | null = null; \n \nconst { hoverState, onEventEnter, onEventMove, onEventLeave, tooltipStyle } = useEventHover<CalendarEvent>(); \n \nconst disabledStripePattern = { \n backgroundImage: 'repeating-linear-gradient(-45deg, transparent 0 5px, rgba(0,0,0,0.035) 5px 6px)', \n}; \n \nconst { handleAutoScroll, stopAutoScroll } = useAutoScroll({ \n scrollRef, \n enabled: () => props.autoScrollOnDrag, \n}); \n \n \nonMounted(() => { \n if (props.currentTimeUpdateInterval > 0) { \n tickInterval = setInterval(() => { now.value = new Date(); }, props.currentTimeUpdateInterval); \n } \n if (scrollRef.value) { \n scrollbarWidth.value = scrollRef.value.offsetWidth - scrollRef.value.clientWidth; \n } \n scrollToCurrentTime(); \n nextTick(() => { \n if (!rootRef.value) return; \n const els = rootRef.value.querySelectorAll<HTMLElement>('[data-eid]'); \n if (els.length) { \n gsap.fromTo( \n els, \n { opacity: 0, y: 6, scale: 0.96 }, \n { opacity: 1, y: 0, scale: 1, duration: 0.4, ease: 'power2.out', stagger: { amount: 0.2 } } \n ); \n } \n }); \n}); \nonUnmounted(() => { if (tickInterval) clearInterval(tickInterval); }); \n \nconst headerLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return currentDate.value.toLocaleDateString(locale, { month: 'long', day: 'numeric', year: 'numeric' }); \n}); \nconst weekdayLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return currentDate.value.toLocaleDateString(locale, { weekday: props.dayNameFormat }); \n}); \n \nconst isPrevDisabled = computed(() => { \n if (!props.minDate) return false; \n const prev = new Date(currentDate.value); \n prev.setDate(prev.getDate() - 1); \n return prev < startOfDay(props.minDate); \n}); \nconst isNextDisabled = computed(() => { \n if (!props.maxDate) return false; \n const next = new Date(currentDate.value); \n next.setDate(next.getDate() + 1); \n return next > startOfDay(props.maxDate); \n}); \n \nconst isDisabledDate = (d: Date) => props.disabledDates.some(x => isSameDay(x, d)); \nconst isDisabledWeekday = (d: Date) => props.disabledWeekdays.includes(d.getDay()); \nconst dayIsDisabled = computed(() => { \n const d = currentDate.value; \n if (props.minDate && startOfDay(d) < startOfDay(props.minDate)) return true; \n if (props.maxDate && startOfDay(d) > startOfDay(props.maxDate)) return true; \n return isDisabledDate(d) || isDisabledWeekday(d); \n}); \n \nconst parseHM = (s: string) => { \n const [h, m] = s.split(':').map(Number); \n return h * 60 + (m || 0); \n}; \n \nconst splitDayRange = (absStart: number, absEnd: number) => { \n const parts: { dayOffset: number; startMin: number; endMin: number }[] = []; \n let s = absStart; \n while (s < absEnd) { \n const dayOffset = Math.floor(s / 1440); \n const dayStart = dayOffset * 1440; \n const chunkEnd = Math.min(absEnd, dayStart + 1440); \n parts.push({ dayOffset, startMin: s - dayStart, endMin: chunkEnd - dayStart }); \n s = chunkEnd; \n } \n return parts; \n}; \n \nconst rangeMatchesDisabled = (baseDow: number, absStart: number, absEnd: number) => { \n if (!props.disabledTimeRanges.length) return false; \n const parts = splitDayRange(absStart, absEnd); \n return parts.some(p => { \n const dow = (baseDow + p.dayOffset) % 7; \n return props.disabledTimeRanges.some(r => { \n if (r.daysOfWeek && !r.daysOfWeek.includes(dow)) return false; \n const rs = parseHM(r.start); \n const re = parseHM(r.end); \n return p.startMin < re && p.endMin > rs; \n }); \n }); \n}; \n \nconst isSlotDisabled = (slotIdx: number) => { \n if (dayIsDisabled.value) return true; \n if (!props.disabledTimeRanges.length) return false; \n const slotStartMin = props.hourStart * 60 + slotIdx * props.slotMinutes; \n const slotEndMin = slotStartMin + props.slotMinutes; \n return rangeMatchesDisabled(currentDate.value.getDay(), slotStartMin, slotEndMin); \n}; \n \nconst rangeHitsDisabled = (startMinFromHourStart: number, endMinFromHourStart: number) => { \n if (dayIsDisabled.value) return true; \n if (!props.disabledTimeRanges.length) return false; \n const absStart = props.hourStart * 60 + startMinFromHourStart; \n const absEnd = props.hourStart * 60 + endMinFromHourStart; \n return rangeMatchesDisabled(currentDate.value.getDay(), absStart, absEnd); \n}; \n \nconst rangeOverlapsEvent = (startMs: number, endMs: number, ignoreId: CalendarEvent['id']) => { \n return props.events.some(ev => { \n if (ev.id === ignoreId) return false; \n if (ev.allDay) return false; \n if (!isSameDay(ev.start, currentDate.value)) return false; \n const es = ev.start.getTime(); \n const ee = (ev.end ?? ev.start).getTime(); \n return startMs < ee && endMs > es; \n }); \n}; \n \nconst isEventInteractive = (ev: CalendarEvent) => !props.readonly && !ev.readonly; \n \nconst businessHoursList = computed<BusinessHours[]>(() => { \n if (!props.businessHours) return []; \n return Array.isArray(props.businessHours) ? props.businessHours : [props.businessHours]; \n}); \n \nconst isBusinessHourSlot = (slotIdx: number) => { \n if (!businessHoursList.value.length) return true; \n const slotStartMin = props.hourStart * 60 + slotIdx * props.slotMinutes; \n const slotEndMin = slotStartMin + props.slotMinutes; \n const parts = splitDayRange(slotStartMin, slotEndMin); \n const baseDow = currentDate.value.getDay(); \n return parts.some(p => { \n const dow = (baseDow + p.dayOffset) % 7; \n return businessHoursList.value.some(b => { \n if (b.daysOfWeek && !b.daysOfWeek.includes(dow)) return false; \n return p.startMin >= parseHM(b.start) && p.startMin < parseHM(b.end); \n }); \n }); \n}; \n \nconst { \n slotsPerHour, \n windowHours, \n totalSlots, \n windowMinutes, \n totalPixels, \n hourLabels, \n dayStartMs: getDayStartMs, \n dayEndMs: getDayEndMs, \n} = useTimeGrid({ \n hourStart: () => props.hourStart, \n hourEnd: () => props.hourEnd, \n slotMinutes: () => props.slotMinutes, \n slotHeight: () => props.slotHeight, \n format: () => props.format, \n}); \n \nconst dayStartMs = computed(() => getDayStartMs(currentDate.value)); \nconst dayEndMs = computed(() => getDayEndMs(currentDate.value)); \n \ninterface TimedSeg { key: string; event: CalendarEvent; style: Record<string, string>; } \n \nconst timedSegments = computed<TimedSeg[]>(() => { \n const result: TimedSeg[] = []; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const dStart = dayStartMs.value; \n const dEnd = dayEndMs.value; \n \n const dayEvents = props.events \n .filter(ev => !ev.allDay) \n .filter(ev => { \n const es = ev.start.getTime(); \n const ee = (ev.end ?? ev.start).getTime(); \n return !(ee <= dStart || es >= dEnd); \n }) \n .sort((a, b) => a.start.getTime() - b.start.getTime()); \n \n const clusters: CalendarEvent[][] = []; \n for (const ev of dayEvents) { \n const evStart = Math.max(ev.start.getTime(), dStart); \n let placed = false; \n for (const cluster of clusters) { \n const clusterEnd = Math.max(...cluster.map(e => Math.min((e.end ?? e.start).getTime(), dEnd))); \n if (evStart < clusterEnd) { cluster.push(ev); placed = true; break; } \n } \n if (!placed) clusters.push([ev]); \n } \n \n for (const cluster of clusters) { \n const columns: CalendarEvent[][] = []; \n for (const ev of cluster) { \n const evStart = Math.max(ev.start.getTime(), dStart); \n let placed = false; \n for (const col of columns) { \n const last = col[col.length - 1]; \n const lastEnd = Math.min((last.end ?? last.start).getTime(), dEnd); \n if (lastEnd <= evStart) { col.push(ev); placed = true; break; } \n } \n if (!placed) columns.push([ev]); \n } \n const colCount = columns.length; \n columns.forEach((col, colIdx) => { \n for (const ev of col) { \n const startMs = Math.max(ev.start.getTime(), dStart); \n const endMsRaw = (ev.end ?? new Date(ev.start.getTime() + 30 * MS_MIN)).getTime(); \n const endMs = Math.min(endMsRaw, dEnd); \n const startMin = (startMs - dStart) / MS_MIN; \n const endMin = (endMs - dStart) / MS_MIN; \n const top = startMin * pxPerMin; \n const height = Math.max((endMin - startMin) * pxPerMin - 1, 18); \n const width = 100 / colCount; \n const left = colIdx * width; \n \n result.push({ \n key: String(ev.id), \n event: ev, \n style: { \n top: `${top}px`, \n height: `${height}px`, \n left: `calc(${left}% + 2px)`, \n width: `calc(${width}% - 4px)`, \n }, \n }); \n } \n }); \n } \n return result; \n}); \n \ninterface AllDaySeg { key: string; event: CalendarEvent; lane: number; } \nconst allDayLayout = computed<{ segs: AllDaySeg[]; rows: number }>(() => { \n const segs: AllDaySeg[] = []; \n const target = startOfDay(currentDate.value).getTime(); \n const list = props.events \n .filter(ev => ev.allDay || (ev.end && startOfDay(ev.end).getTime() > startOfDay(ev.start).getTime())) \n .filter(ev => { \n const sd = startOfDay(ev.start).getTime(); \n const ed = startOfDay(ev.end ?? ev.start).getTime(); \n return target >= sd && target <= ed; \n }) \n .sort((a, b) => a.start.getTime() - b.start.getTime()); \n list.forEach((ev, i) => segs.push({ key: `ad-${ev.id}`, event: ev, lane: i })); \n return { segs, rows: segs.length }; \n}); \nconst allDaySegments = computed(() => allDayLayout.value.segs); \nconst allDayRows = computed(() => allDayLayout.value.rows); \n \nconst isTodayInView = computed(() => { \n const nt = now.value.getTime(); \n return nt >= dayStartMs.value && nt < dayEndMs.value; \n}); \n \nconst currentTimeTop = computed(() => { \n if (!isTodayInView.value) return 0; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const min = (now.value.getTime() - dayStartMs.value) / MS_MIN; \n return Math.max(0, Math.min(min, windowMinutes.value)) * pxPerMin; \n}); \n \nconst currentTimeLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return now.value.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: props.format === '12h' }); \n}); \n \nconst formatEventTime = (d: Date) => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return d.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: props.format === '12h' }); \n}; \n \nconst scrollToCurrentTime = () => { \n nextTick(() => { \n if (!scrollRef.value) return; \n let top = 0; \n if (isTodayInView.value) { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const min = (now.value.getTime() - dayStartMs.value) / MS_MIN; \n top = Math.max(0, Math.min(min, windowMinutes.value)) * pxPerMin; \n } \n const target = Math.max(0, top - scrollRef.value.clientHeight / 3); \n gsap.to(scrollRef.value, { scrollTop: target, duration: 0.55, ease: 'power3.inOut' }); \n }); \n}; \n \nconst animate = (dir: 1 | -1) => { \n if (!scrollRef.value) return; \n gsap.fromTo( \n scrollRef.value, \n { opacity: 0, x: 24 * dir }, \n { opacity: 1, x: 0, duration: 0.32, ease: 'power3.out' } \n ); \n nextTick(() => { \n if (!scrollRef.value) return; \n const els = scrollRef.value.querySelectorAll<HTMLElement>('[data-eid]'); \n if (els.length) { \n gsap.fromTo( \n els, \n { opacity: 0, y: 6, scale: 0.96 }, \n { opacity: 1, y: 0, scale: 1, duration: 0.35, ease: 'power2.out', stagger: { amount: 0.18 } } \n ); \n } \n }); \n}; \n \nconst findEventEls = (id: CalendarEvent['id']): HTMLElement[] => { \n if (!rootRef.value) return []; \n return Array.from(rootRef.value.querySelectorAll<HTMLElement>(`[data-eid=\"${id}\"]`)); \n}; \n \nconst dropGrowEvent = (id: CalendarEvent['id']) => { \n nextTick(() => { \n const els = findEventEls(id); \n if (!els.length) return; \n gsap.fromTo( \n els, \n { scale: 0.4, opacity: 0 }, \n { scale: 1, opacity: 1, duration: 0.42, ease: 'back.out(1.7)', transformOrigin: 'center center' } \n ); \n }); \n}; \n \nconst stretchResize = (id: CalendarEvent['id'], oldHeightPx: number) => { \n nextTick(() => { \n const els = findEventEls(id); \n if (!els.length) return; \n els.forEach(el => { \n const newH = el.offsetHeight; \n if (newH <= 0 || oldHeightPx <= 0 || newH === oldHeightPx) return; \n const fromScale = oldHeightPx / newH; \n gsap.fromTo( \n el, \n { scaleY: fromScale }, \n { scaleY: 1, duration: 0.32, ease: 'power3.out', transformOrigin: 'top center', overwrite: 'auto', clearProps: 'transform' } \n ); \n }); \n }); \n}; \n \nconst shiftDay = (days: number) => { \n const d = new Date(currentDate.value); \n d.setDate(d.getDate() + days); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(days > 0 ? 1 : -1)); \n}; \nconst handlePrev = () => shiftDay(-1); \nconst handleNext = () => shiftDay(1); \nconst handlePrevYear = () => { \n const d = new Date(currentDate.value); \n d.setFullYear(d.getFullYear() - 1); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(-1)); \n}; \nconst handleNextYear = () => { \n const d = new Date(currentDate.value); \n d.setFullYear(d.getFullYear() + 1); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(1)); \n}; \nconst handleToday = () => { \n const n = new Date(); \n currentDate.value = startOfDay(n); \n emit('update:modelValue', n); \n nextTick(() => { animate(1); scrollToCurrentTime(); }); \n}; \n \nconst clickTimer = ref<ReturnType<typeof setTimeout> | null>(null); \nconst DOUBLE_CLICK_DELAY = 220; \n \nconst pxToSlotMin = (offsetY: number) => { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const rawMin = offsetY / pxPerMin; \n return Math.floor(rawMin / props.slotMinutes) * props.slotMinutes; \n}; \nconst slotDateFromOffset = (offsetY: number): Date => { \n const snapped = pxToSlotMin(offsetY); \n const base = new Date(currentDate.value); \n base.setHours(props.hourStart, 0, 0, 0); \n base.setMinutes(base.getMinutes() + snapped); \n return base; \n}; \nconst offsetFromEvent = (el: HTMLElement, clientY: number) => { \n const rect = el.getBoundingClientRect(); \n return Math.max(0, clientY - rect.top); \n}; \n \nconst handleSlotClick = (e: MouseEvent) => { \n if (rangeJustSelected.value) { rangeJustSelected.value = false; return; } \n if (dayIsDisabled.value) return; \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const dt = slotDateFromOffset(offsetY); \n const slotIdx = Math.floor(((dt.getHours() - props.hourStart) * 60 + dt.getMinutes()) / props.slotMinutes); \n if (isSlotDisabled(slotIdx)) return; \n if (clickTimer.value) clearTimeout(clickTimer.value); \n clickTimer.value = setTimeout(() => { \n emit('slot-click', dt, e); \n clickTimer.value = null; \n }, DOUBLE_CLICK_DELAY); \n}; \nconst handleSlotDblClick = (e: MouseEvent) => { \n if (props.readonly) return; \n if (dayIsDisabled.value) return; \n if (clickTimer.value) { clearTimeout(clickTimer.value); clickTimer.value = null; } \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const dt = slotDateFromOffset(offsetY); \n const slotIdx = Math.floor(((dt.getHours() - props.hourStart) * 60 + dt.getMinutes()) / props.slotMinutes); \n if (isSlotDisabled(slotIdx)) return; \n emit('create-event', dt, false, e); \n}; \n \nconst handleAllDayCellClick = (_e: MouseEvent) => {}; \nconst handleAllDayCellDblClick = (e: MouseEvent) => { \n if (props.readonly) return; \n if (dayIsDisabled.value) return; \n emit('create-event', startOfDay(currentDate.value), true, e); \n}; \n \nconst resizeJustEnded = ref(false); \nconst handleEventClick = (ev: CalendarEvent, e: MouseEvent) => { \n if (resizeJustEnded.value) { resizeJustEnded.value = false; return; } \n emit('event-click', ev, e); \n}; \n \nconst draggingId = ref<string | number | null>(null); \nconst dragOverActive = ref(false); \nconst allDayDragOver = ref(false); \n \nconst onDragStart = (ev: CalendarEvent, e: DragEvent) => { \n if (!props.draggableEvents || !isEventInteractive(ev)) { e.preventDefault(); return; } \n onEventLeave(); \n draggingId.value = ev.id; \n if (e.dataTransfer) { \n e.dataTransfer.effectAllowed = 'move'; \n e.dataTransfer.setData('text/plain', String(ev.id)); \n const src = e.currentTarget as HTMLElement; \n if (src && typeof e.dataTransfer.setDragImage === 'function') { \n const rect = src.getBoundingClientRect(); \n const w = Math.max(rect.width * 0.7, 90); \n const h = Math.max(rect.height * 0.7, 26); \n const wrap = document.createElement('div'); \n wrap.style.cssText = [ \n 'position:absolute', 'top:-9999px', 'left:-9999px', \n `width:${w}px`, `height:${h}px`, \n 'background:white', 'border-radius:4px', 'overflow:hidden', \n 'box-shadow:0 6px 18px rgba(0,0,0,0.22)', \n 'pointer-events:none', 'margin:0', 'transform:rotate(-1.5deg)', \n ].join(';'); \n const clone = src.cloneNode(true) as HTMLElement; \n clone.style.position = 'static'; \n clone.style.width = '100%'; \n clone.style.height = '100%'; \n clone.style.left = 'auto'; \n clone.style.top = 'auto'; \n clone.style.margin = '0'; \n clone.style.opacity = '1'; \n wrap.appendChild(clone); \n document.body.appendChild(wrap); \n e.dataTransfer.setDragImage(wrap, Math.round(w / 2), 14); \n setTimeout(() => { wrap.parentNode?.removeChild(wrap); }, 0); \n } \n } \n}; \nconst onDragEnd = () => { \n draggingId.value = null; \n dragOverActive.value = false; \n allDayDragOver.value = false; \n stopAutoScroll(); \n}; \nconst onDragOver = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n const ev = props.events.find(x => x.id === draggingId.value); \n let blocked = false; \n if (!props.allowDropOnDisabled) { \n if (dayIsDisabled.value) blocked = true; \n else if (ev && !ev.allDay) { \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const snappedMin = pxToSlotMin(offsetY); \n const duration = ev.end ? ev.end.getTime() - ev.start.getTime() : 30 * MS_MIN; \n const durationMin = duration / MS_MIN; \n if (rangeHitsDisabled(snappedMin, snappedMin + durationMin)) blocked = true; \n } \n } \n if (e.dataTransfer) e.dataTransfer.dropEffect = blocked ? 'none' : 'move'; \n dragOverActive.value = !blocked; \n handleAutoScroll(e.clientY); \n}; \nconst onDrop = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n if (!props.allowDropOnDisabled && dayIsDisabled.value) { onDragEnd(); return; } \n const ev = props.events.find(x => x.id === draggingId.value); \n if (!ev) { onDragEnd(); return; } \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const snappedMin = pxToSlotMin(offsetY); \n const wasAllDay = !!ev.allDay; \n const duration = !wasAllDay && ev.end ? ev.end.getTime() - ev.start.getTime() : 30 * MS_MIN; \n const durationMin = duration / MS_MIN; \n if (!props.allowDropOnDisabled && rangeHitsDisabled(snappedMin, snappedMin + durationMin)) { onDragEnd(); return; } \n const newStart = new Date(currentDate.value); \n newStart.setHours(props.hourStart, 0, 0, 0); \n newStart.setMinutes(newStart.getMinutes() + snappedMin); \n const newEnd = new Date(newStart.getTime() + duration); \n if (props.preventOverlap && rangeOverlapsEvent(newStart.getTime(), newEnd.getTime(), ev.id)) { onDragEnd(); return; } \n const emitEv = wasAllDay ? { ...ev, allDay: false } as CalendarEvent : ev; \n emit('event-drop', emitEv, newStart, newEnd); \n dropGrowEvent(ev.id); \n onDragEnd(); \n}; \n \nconst onAllDayDragOver = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n const blocked = !props.allowDropOnDisabled && dayIsDisabled.value; \n if (e.dataTransfer) e.dataTransfer.dropEffect = blocked ? 'none' : 'move'; \n allDayDragOver.value = !blocked; \n}; \nconst onAllDayDrop = (_e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n if (!props.allowDropOnDisabled && dayIsDisabled.value) { onDragEnd(); return; } \n const ev = props.events.find(x => x.id === draggingId.value); \n if (!ev) { onDragEnd(); return; } \n const wasAllDay = !!ev.allDay; \n const duration = wasAllDay && ev.end ? startOfDay(ev.end).getTime() - startOfDay(ev.start).getTime() : 0; \n const newStart = startOfDay(currentDate.value); \n const newEnd = new Date(newStart.getTime() + duration); \n const emitEv = !wasAllDay ? { ...ev, allDay: true } as CalendarEvent : ev; \n emit('event-drop', emitEv, newStart, wasAllDay ? newEnd : undefined); \n dropGrowEvent(ev.id); \n onDragEnd(); \n}; \n \ninterface RangeSelect { startMin: number; endMin: number; topPx: number; heightPx: number; } \nconst rangeSelect = ref<RangeSelect | null>(null); \nconst rangeJustSelected = ref(false); \nlet rangePointerId: number | null = null; \nlet rangeStartColEl: HTMLElement | null = null; \n \nconst onColPointerDown = (e: PointerEvent) => { \n if (props.readonly) return; \n if (!props.allowRangeSelection) return; \n if (e.button !== 0) return; \n if (dayIsDisabled.value) return; \n rangeStartColEl = e.currentTarget as HTMLElement; \n const offsetY = offsetFromEvent(rangeStartColEl, e.clientY); \n const startMin = pxToSlotMin(offsetY); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n rangeSelect.value = { \n startMin, endMin: startMin + props.slotMinutes, \n topPx: startMin * pxPerMin, \n heightPx: props.slotMinutes * pxPerMin, \n }; \n rangePointerId = e.pointerId; \n rangeStartColEl.setPointerCapture(e.pointerId); \n rangeStartColEl.addEventListener('pointermove', onRangePointerMove); \n rangeStartColEl.addEventListener('pointerup', onRangePointerUp); \n rangeStartColEl.addEventListener('pointercancel', onRangePointerUp); \n}; \nconst onRangePointerMove = (e: PointerEvent) => { \n if (!rangeSelect.value || !rangeStartColEl) return; \n handleAutoScroll(e.clientY); \n const offsetY = offsetFromEvent(rangeStartColEl, e.clientY); \n const curMin = Math.max(0, Math.min(windowMinutes.value, pxToSlotMin(offsetY) + props.slotMinutes)); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const s = Math.min(rangeSelect.value.startMin, curMin - props.slotMinutes); \n const e2 = Math.max(rangeSelect.value.startMin + props.slotMinutes, curMin); \n rangeSelect.value = { ...rangeSelect.value, topPx: s * pxPerMin, heightPx: (e2 - s) * pxPerMin, endMin: e2, startMin: s }; \n}; \nconst onRangePointerUp = (_e: PointerEvent) => { \n if (!rangeSelect.value || !rangeStartColEl) return; \n stopAutoScroll(); \n const { startMin, endMin } = rangeSelect.value; \n rangeStartColEl.removeEventListener('pointermove', onRangePointerMove); \n rangeStartColEl.removeEventListener('pointerup', onRangePointerUp); \n rangeStartColEl.removeEventListener('pointercancel', onRangePointerUp); \n if (rangePointerId !== null) rangeStartColEl.releasePointerCapture?.(rangePointerId); \n rangePointerId = null; \n rangeStartColEl = null; \n \n const durationMin = endMin - startMin; \n if (durationMin > props.slotMinutes) { \n const start = new Date(currentDate.value); \n start.setHours(props.hourStart, 0, 0, 0); \n start.setMinutes(start.getMinutes() + startMin); \n const end = new Date(start.getTime() + durationMin * MS_MIN); \n rangeJustSelected.value = true; \n emit('select-range', start, end); \n } \n rangeSelect.value = null; \n}; \n \ninterface ResizePreview { topPx: number; heightPx: number; } \nconst resizingId = ref<string | number | null>(null); \nconst resizingPreview = ref<ResizePreview | null>(null); \nlet resizeStartState: { event: CalendarEvent; startMin: number; minEndMin: number } | null = null; \n \nconst onResizeStart = (ev: CalendarEvent, e: PointerEvent) => { \n if (!props.resizableEvents || !isEventInteractive(ev)) return; \n const startMin = Math.max(0, (ev.start.getTime() - dayStartMs.value) / MS_MIN); \n const minEndMin = startMin + props.slotMinutes; \n resizingId.value = ev.id; \n resizeStartState = { event: ev, startMin, minEndMin }; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const curEndMin = ev.end ? (ev.end.getTime() - dayStartMs.value) / MS_MIN : minEndMin; \n resizingPreview.value = { \n topPx: startMin * pxPerMin, \n heightPx: Math.max(curEndMin - startMin, props.slotMinutes) * pxPerMin, \n }; \n window.addEventListener('pointermove', onResizeMove); \n window.addEventListener('pointerup', onResizeEnd); \n window.addEventListener('pointercancel', onResizeEnd); \n void e; \n}; \nconst onResizeMove = (e: PointerEvent) => { \n if (!resizeStartState || !resizingPreview.value || !colRef.value) return; \n handleAutoScroll(e.clientY); \n const rect = colRef.value.getBoundingClientRect(); \n const offsetY = Math.max(0, Math.min(totalPixels.value, e.clientY - rect.top)); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const rawMin = offsetY / pxPerMin; \n const snapped = Math.ceil(rawMin / props.slotMinutes) * props.slotMinutes; \n const endMin = Math.max(resizeStartState.minEndMin, Math.min(windowMinutes.value, snapped)); \n resizingPreview.value = { ...resizingPreview.value, heightPx: (endMin - resizeStartState.startMin) * pxPerMin }; \n}; \nconst onResizeEnd = () => { \n window.removeEventListener('pointermove', onResizeMove); \n window.removeEventListener('pointerup', onResizeEnd); \n window.removeEventListener('pointercancel', onResizeEnd); \n stopAutoScroll(); \n if (resizeStartState && resizingPreview.value) { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const endMin = resizeStartState.startMin + resizingPreview.value.heightPx / pxPerMin; \n const newStart = new Date(resizeStartState.event.start); \n const newEnd = new Date(currentDate.value); \n newEnd.setHours(props.hourStart, 0, 0, 0); \n newEnd.setMinutes(newEnd.getMinutes() + endMin); \n const hitsDisabled = !props.allowResizeOverDisabled && rangeHitsDisabled(resizeStartState.startMin, endMin); \n const overlaps = props.preventOverlap && rangeOverlapsEvent(newStart.getTime(), newEnd.getTime(), resizeStartState.event.id); \n if (!hitsDisabled && !overlaps) { \n const ev = resizeStartState.event; \n const oldEndMin = ev.end ? (ev.end.getTime() - dayStartMs.value) / MS_MIN : resizeStartState.minEndMin; \n const oldHeightPx = Math.max((oldEndMin - resizeStartState.startMin) * pxPerMin - 1, 18); \n emit('event-resize', ev, newStart, newEnd); \n stretchResize(ev.id, oldHeightPx); \n } \n resizeJustEnded.value = true; \n setTimeout(() => { resizeJustEnded.value = false; }, 0); \n } \n resizingId.value = null; \n resizingPreview.value = null; \n resizeStartState = null; \n}; \n \nconst handleKeydown = (e: KeyboardEvent) => { \n if (!props.enableKeyboardNavigation) return; \n const target = e.target as HTMLElement; \n if (target.tagName === 'SELECT' || target.tagName === 'INPUT') return; \n if (e.key === 'ArrowLeft' || e.key === 'PageUp') { e.preventDefault(); shiftDay(-1); } \n else if (e.key === 'ArrowRight' || e.key === 'PageDown') { e.preventDefault(); shiftDay(1); } \n else if (e.key.toLowerCase() === 't') { e.preventDefault(); handleToday(); } \n else if (e.key.toLowerCase() === 'c' && !props.readonly) { e.preventDefault(); emit('create-event', startOfDay(currentDate.value), true, e); } \n}; \n \ndefineExpose({ scrollToCurrentTime }); \n \n \nconst eventInlineStyle = (ev: CalendarEvent) => { \n if (!ev.colorHex) return undefined; \n return { backgroundColor: hexToRgba(ev.colorHex, 0.12), borderLeftColor: ev.colorHex, color: ev.colorHex }; \n}; \n \nconst { currentTimeSolidClass } = useCurrentTimeLine(() => props.currentTimeColor); \n \nconst { \n todayTextClass, \n rangeSelectClass, \n focusRingColorClass, \n containerRadiusClass, \n eventRadiusClass, \n showEventAccent, \n pillRadiusClass, \n dayNameCaseClass, \n resolvedColor, \n} = useCalendarTheme({ \n color: () => props.color, \n radius: () => props.radius, \n dayNameCase: () => props.dayNameCase, \n}); \n \nconst localeValue = computed(() => (props.locale === 'default' ? undefined : props.locale)); \n \nconst monthOptions = computed(() => { \n const base = new Date(2024, 0, 1); \n return Array.from({ length: 12 }, (_, i) => { \n const d = new Date(base); \n d.setMonth(i); \n return d.toLocaleString(localeValue.value, { month: 'long' }); \n }); \n}); \n \nconst yearOptions = computed(() => { \n const min = props.minDate?.getFullYear() ?? currentDate.value.getFullYear() - 10; \n const max = props.maxDate?.getFullYear() ?? currentDate.value.getFullYear() + 10; \n const list: number[] = []; \n for (let y = min; y <= max; y++) list.push(y); \n return list; \n}); \n \nconst dayOptions = computed(() => { \n const last = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() + 1, 0).getDate(); \n return Array.from({ length: last }, (_, i) => i + 1); \n}); \n \nconst selectedDay = computed({ \n get: () => currentDate.value.getDate(), \n set: (dd: number) => { \n const dir = dd > currentDate.value.getDate() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setDate(dd); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n \nconst selectedMonth = computed({ \n get: () => currentDate.value.getMonth(), \n set: (mm: number) => { \n const dir = mm > currentDate.value.getMonth() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setDate(1); \n d.setMonth(mm); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n \nconst selectedYear = computed({ \n get: () => currentDate.value.getFullYear(), \n set: (yy: number) => { \n const dir = yy > currentDate.value.getFullYear() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setFullYear(yy); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n</script>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"DayView.mjs","names":[],"sources":["../../../../src/components/data-display/calendar/DayView.vue"],"sourcesContent":["<template> \n <div \n ref=\"rootRef\" \n tabindex=\"-1\" \n :class=\"['relative flex flex-col bg-card overflow-hidden focus:outline-none', containerRadiusClass, bordered ? 'border border-border' : '']\" \n :style=\"{ maxHeight: toCssLength(maxHeight) }\"\n @keydown=\"handleKeydown\" \n > \n <slot name=\"header\" :label=\"headerLabel\" :goToToday=\"handleToday\" :prev=\"handlePrev\" :next=\"handleNext\" :prevYear=\"handlePrevYear\" :nextYear=\"handleNextYear\"> \n <CalendarHeader \n :label=\"headerLabel\" \n :weekdayLabel=\"weekdayLabel\" \n :showHeader=\"showHeader\" \n :showYearJump=\"showYearJump\" \n :showTodayButton=\"showTodayButton\" \n :showMonthYearSelects=\"showMonthYearSelects\" \n :monthOptions=\"monthOptions\" \n :yearOptions=\"yearOptions\" \n :dayOptions=\"dayOptions\" \n v-model:selectedDay=\"selectedDay\" \n v-model:selectedMonth=\"selectedMonth\" \n v-model:selectedYear=\"selectedYear\" \n :isPrevDisabled=\"isPrevDisabled\" \n :isNextDisabled=\"isNextDisabled\" \n prevLabel=\"Previous day\" \n nextLabel=\"Next day\" \n :color=\"resolvedColor\" \n :focusRingColorClass=\"focusRingColorClass\" \n :todayTextClass=\"todayTextClass\" \n :todayRadiusClass=\"pillRadiusClass\" \n :dayNameCaseClass=\"dayNameCaseClass\" \n @prev=\"handlePrev\" \n @next=\"handleNext\" \n @prevYear=\"handlePrevYear\" \n @nextYear=\"handleNextYear\" \n @today=\"handleToday\" \n /> \n </slot> \n \n <div v-if=\"showAllDayRow && allDayRows > 0\" class=\"flex border-b border-border\" :style=\"{ paddingRight: scrollbarWidth + 'px' }\"> \n <div class=\"w-14 shrink-0 flex items-start justify-end pr-2 pt-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider\"> \n all-day \n </div> \n <div \n class=\"relative flex-1\" \n :style=\"[ \n { height: `${allDayRows * 22 + 4}px` }, \n dayIsDisabled ? disabledStripePattern : undefined, \n ]\" \n @click=\"handleAllDayCellClick($event)\" \n @dblclick=\"handleAllDayCellDblClick($event)\" \n @dragover.prevent=\"onAllDayDragOver($event)\" \n @drop.prevent=\"onAllDayDrop($event)\" \n :class=\"[ \n 'transition-colors', \n dayIsDisabled ? 'cursor-not-allowed' : 'cursor-pointer hover:bg-muted/60', \n allDayDragOver ? 'bg-muted' : '', \n ]\" \n > \n <div \n v-for=\"seg in allDaySegments\" \n :key=\"seg.key\" \n :data-eid=\"seg.event.id\" \n :draggable=\"draggableEvents && isEventInteractive(seg.event)\" \n @dragstart=\"onDragStart(seg.event, $event)\" \n @dragend=\"onDragEnd\" \n @click.stop=\"handleEventClick(seg.event, $event)\" \n @mouseenter=\"onEventEnter(seg.event, true, $event)\" \n @mousemove=\"onEventMove\" \n @mouseleave=\"onEventLeave\" \n :style=\"[ \n { \n left: '2px', \n right: '2px', \n top: `${seg.lane * 22 + 2}px`, \n height: '20px', \n }, \n eventInlineStyle(seg.event), \n ]\" \n :class=\"[ \n 'absolute z-10 truncate text-xs px-1.5 flex items-center cursor-pointer transition-all hover:opacity-80 select-none', \n eventRadiusClass, \n draggableEvents ? 'cursor-grab active:cursor-grabbing' : '', \n seg.event.colorHex ? '' : eventColorClass(seg.event.color, showEventAccent), \n draggingId === seg.event.id ? 'opacity-70 scale-95' : '', \n ]\" \n > \n <slot name=\"event\" :event=\"seg.event\" :allDay=\"true\"> \n <span class=\"truncate font-medium\">{{ seg.event.title }}</span> \n </slot> \n </div> \n </div> \n </div> \n \n <div ref=\"scrollRef\" class=\"flex-1 overflow-y-scroll relative\" style=\"scrollbar-gutter: stable;\"> \n <div class=\"flex\"> \n <div class=\"w-14 shrink-0 relative\" :style=\"{ height: `${totalPixels}px` }\"> \n <div \n v-for=\"h in hourLabels\" \n :key=\"h.offset\" \n class=\"absolute right-0 pr-2 text-[10px] font-medium text-muted-foreground tracking-wide -translate-y-1/2\" \n :style=\"{ top: `${h.offset * 60 * (slotHeight / slotMinutes)}px` }\" \n > \n <span v-if=\"h.offset !== 0 && h.offset !== windowHours\">{{ h.label }}</span> \n </div> \n <span \n v-if=\"showCurrentTime && showCurrentTimeLabel && isTodayInView\" \n :class=\"['absolute right-1 -translate-y-1/2 px-1 py-0.5 text-[10px] font-semibold text-white leading-none z-30 pointer-events-none', eventRadiusClass, currentTimeSolidClass]\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n >{{ currentTimeLabel }}</span> \n <span \n v-else-if=\"showCurrentTime && !showCurrentTimeLabel && isTodayInView\" \n :class=\"['absolute right-0 -translate-y-1/2 w-1.5 h-1.5 rounded-full z-30 pointer-events-none', currentTimeSolidClass]\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n ></span> \n </div> \n \n <div \n ref=\"colRef\" \n class=\"relative flex-1 border-l border-border\" \n @pointerdown=\"onColPointerDown($event)\" \n @click=\"handleSlotClick($event)\" \n @dblclick=\"handleSlotDblClick($event)\" \n @dragover.prevent=\"onDragOver($event)\" \n @drop.prevent=\"onDrop($event)\" \n > \n <div \n v-for=\"(_, idx) in totalSlots\" \n :key=\"idx\" \n :style=\"[ \n { height: `${slotHeight}px` }, \n isSlotDisabled(idx) \n ? disabledStripePattern \n : !isBusinessHourSlot(idx) \n ? { backgroundColor: 'rgba(0,0,0,0.015)' } \n : undefined, \n ]\" \n :class=\"[ \n 'border-t', \n idx === 0 ? 'border-transparent' : idx % slotsPerHour === 0 ? 'border-border' : 'border-dashed border-border/70', \n isSlotDisabled(idx) ? 'cursor-not-allowed' : '', \n ]\" \n ></div> \n \n <div \n v-if=\"dayIsDisabled\" \n class=\"absolute inset-0 pointer-events-none\" \n :style=\"disabledStripePattern\" \n ></div> \n \n <div \n v-for=\"seg in timedSegments\" \n :key=\"seg.key\" \n :data-eid=\"seg.event.id\" \n :draggable=\"draggableEvents && resizingId !== seg.event.id && isEventInteractive(seg.event)\" \n @dragstart.stop=\"onDragStart(seg.event, $event)\" \n @dragend=\"onDragEnd\" \n @click.stop=\"handleEventClick(seg.event, $event)\" \n @pointerdown.stop \n @mouseenter=\"onEventEnter(seg.event, false, $event)\" \n @mousemove=\"onEventMove\" \n @mouseleave=\"onEventLeave\" \n :style=\"[seg.style, eventInlineStyle(seg.event)]\" \n :class=\"[ \n 'absolute z-10 overflow-hidden transition-all hover:opacity-90 select-none flex flex-col', \n eventRadiusClass, \n isEventInteractive(seg.event) ? 'cursor-pointer' : 'cursor-default', \n draggableEvents && isEventInteractive(seg.event) ? 'cursor-grab active:cursor-grabbing' : '', \n seg.event.colorHex ? (showEventAccent ? 'border-l-2' : '') : eventColorClass(seg.event.color, showEventAccent), \n draggingId === seg.event.id ? 'opacity-70 scale-95' : '', \n ]\" \n > \n <slot name=\"event\" :event=\"seg.event\" :allDay=\"false\"> \n <div class=\"px-2 py-1 flex-1 min-h-0\"> \n <div class=\"text-[10px] font-semibold leading-tight opacity-80\">{{ formatEventTime(seg.event.start) }}<template v-if=\"seg.event.end\"> – {{ formatEventTime(seg.event.end) }}</template></div> \n <div class=\"text-xs font-medium truncate leading-tight\">{{ seg.event.title }}</div> \n <div v-if=\"seg.event.description\" class=\"text-[11px] opacity-70 truncate leading-tight mt-0.5\">{{ seg.event.description }}</div> \n </div> \n </slot> \n <div \n v-if=\"resizableEvents && isEventInteractive(seg.event)\" \n draggable=\"false\" \n @mousedown.stop.prevent \n @dragstart.stop.prevent \n @pointerdown.stop=\"onResizeStart(seg.event, $event)\" \n class=\"absolute bottom-0 left-0 right-0 h-1.5 cursor-ns-resize hover:bg-black/10\" \n ></div> \n </div> \n \n <div \n v-if=\"showCurrentTime && isTodayInView\" \n class=\"absolute left-0 right-0 h-px pointer-events-none z-20\" \n :class=\"currentTimeSolidClass\" \n :style=\"{ top: `${currentTimeTop}px` }\" \n ></div> \n \n <div \n v-if=\"dragOverActive\" \n class=\"absolute inset-0 pointer-events-none z-0 bg-muted/60\" \n ></div> \n \n <div \n v-if=\"rangeSelect\" \n :class=\"['absolute left-1 right-1 pointer-events-none z-20 border border-dashed', eventRadiusClass, rangeSelectClass]\" \n :style=\"{ top: `${rangeSelect.topPx}px`, height: `${rangeSelect.heightPx}px` }\" \n ></div> \n \n <div \n v-if=\"resizingPreview\" \n :class=\"['absolute left-1 right-1 pointer-events-none z-20 border border-dashed border-muted-foreground bg-foreground/5', eventRadiusClass]\" \n :style=\"{ top: `${resizingPreview.topPx}px`, height: `${resizingPreview.heightPx}px` }\" \n ></div> \n </div> \n </div> \n </div> \n \n <button \n v-if=\"showNowPill && isTodayInView\" \n type=\"button\" \n @click=\"scrollToCurrentTime\" \n :class=\"['absolute bottom-4 right-6 z-40 px-3 py-1.5 flex items-center gap-1.5 text-xs font-medium shadow-lg bg-card border border-border hover:bg-muted transition-all cursor-pointer', pillRadiusClass]\" \n > \n <span class=\"w-1.5 h-1.5\" :class=\"[pillRadiusClass, currentTimeSolidClass]\"></span> \n <span class=\"text-foreground/80\">Now</span> \n </button> \n \n <CalendarEventTooltip :state=\"hoverState\" :style=\"tooltipStyle\" :formatTime=\"formatEventTime\"> \n <!--\n A provided slot replaces the built-in card, so it gets the surface\n here; with no slot the fallback content keeps rendering its own.\n -->\n <template v-if=\"$slots['event-tooltip']\" #default=\"{ event, allDay }\">\n <div :class=\"CALENDAR_TOOLTIP_SURFACE\">\n <slot name=\"event-tooltip\" :event=\"event\" :allDay=\"allDay\" />\n </div>\n </template>\n </CalendarEventTooltip> \n </div> \n</template> \n \n<script setup lang=\"ts\"> \nimport { ref, computed, watch, nextTick, onMounted, onUnmounted } from 'vue'; \nimport gsap from 'gsap'; \nimport { isSameDay, startOfDay } from '../../../composables/useCalendar'; \nimport { useCalendarTheme } from '../../../composables/useCalendarTheme'; \nimport { useEventHover } from '../../../composables/useEventHover'; \nimport { useAutoScroll } from '../../../composables/useAutoScroll'; \nimport { useCurrentTimeLine } from '../../../composables/useCurrentTimeLine'; \nimport { useTimeGrid, MS_MIN } from '../../../composables/useTimeGrid'; \nimport { eventColorClass, hexToRgba } from '../../../composables/eventColors'; \nimport CalendarEventTooltip from './CalendarEventTooltip.vue'; \nimport CalendarHeader from './CalendarHeader.vue'; \nimport type { DayView } from '../../../interfaces/data-display/calendar/DayView.interface'; \nimport type { BusinessHours } from '../../../interfaces/data-display/calendar/WeekView.interface'; \nimport type { CalendarEvent } from '../../../interfaces/data-display/calendar/MonthView.interface'; \n \nimport { toCssLength } from '../../../utils/cssLength';\n\nimport { CALENDAR_TOOLTIP_SURFACE } from '../../../utils/calendarTooltip';\n\nconst props = withDefaults(defineProps<DayView>(), { \n modelValue: () => new Date(), \n events: () => [], \n locale: 'default', \n color: 'default', \n bordered: true, \n dayNameFormat: 'long', \n dayNameCase: 'upper', \n highlightedDates: () => [], \n disabledDates: () => [], \n disabledWeekdays: () => [], \n disabledTimeRanges: () => [], \n showHeader: true, \n showYearJump: false, \n showTodayButton: true, \n showMonthYearSelects: false, \n hourStart: 0, \n hourEnd: 24, \n slotMinutes: 30, \n slotHeight: 28, \n format: '24h', \n showCurrentTime: true, \n showCurrentTimeLabel: true, \n currentTimeColor: 'red', \n currentTimeUpdateInterval: 60000, \n draggableEvents: true, \n resizableEvents: true, \n allowRangeSelection: true, \n allowDropOnDisabled: false, \n allowResizeOverDisabled: false, \n readonly: false, \n preventOverlap: false, \n autoScrollOnDrag: true, \n showAllDayRow: true, \n enableKeyboardNavigation: true, \n showNowPill: true, \n}); \n \nconst emit = defineEmits<{ \n 'update:modelValue': [date: Date]; \n 'event-click': [event: CalendarEvent, nativeEvent: MouseEvent]; \n 'slot-click': [date: Date, nativeEvent: MouseEvent]; \n 'create-event': [date: Date, allDay: boolean, nativeEvent: MouseEvent | KeyboardEvent]; \n 'event-drop': [event: CalendarEvent, newStart: Date, newEnd: Date | undefined]; \n 'event-resize': [event: CalendarEvent, newStart: Date, newEnd: Date]; \n 'select-range': [start: Date, end: Date]; \n}>(); \n \nconst currentDate = ref(startOfDay(new Date(props.modelValue))); \nwatch(() => props.modelValue, (v) => { if (v) currentDate.value = startOfDay(new Date(v)); }); \n \nconst rootRef = ref<HTMLElement | null>(null); \nconst scrollRef = ref<HTMLElement | null>(null); \nconst colRef = ref<HTMLElement | null>(null); \nconst now = ref(new Date()); \nconst scrollbarWidth = ref(0); \nlet tickInterval: ReturnType<typeof setInterval> | null = null; \n \nconst { hoverState, onEventEnter, onEventMove, onEventLeave, tooltipStyle } = useEventHover<CalendarEvent>(); \n \nconst disabledStripePattern = { \n backgroundImage: 'repeating-linear-gradient(-45deg, transparent 0 5px, rgba(0,0,0,0.035) 5px 6px)', \n}; \n \nconst { handleAutoScroll, stopAutoScroll } = useAutoScroll({ \n scrollRef, \n enabled: () => props.autoScrollOnDrag, \n}); \n \n \nonMounted(() => { \n if (props.currentTimeUpdateInterval > 0) { \n tickInterval = setInterval(() => { now.value = new Date(); }, props.currentTimeUpdateInterval); \n } \n if (scrollRef.value) { \n scrollbarWidth.value = scrollRef.value.offsetWidth - scrollRef.value.clientWidth; \n } \n scrollToCurrentTime(); \n nextTick(() => { \n if (!rootRef.value) return; \n const els = rootRef.value.querySelectorAll<HTMLElement>('[data-eid]'); \n if (els.length) { \n gsap.fromTo( \n els, \n { opacity: 0, y: 6, scale: 0.96 }, \n { opacity: 1, y: 0, scale: 1, duration: 0.4, ease: 'power2.out', stagger: { amount: 0.2 } } \n ); \n } \n }); \n}); \nonUnmounted(() => { if (tickInterval) clearInterval(tickInterval); }); \n \nconst headerLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return currentDate.value.toLocaleDateString(locale, { month: 'long', day: 'numeric', year: 'numeric' }); \n}); \nconst weekdayLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return currentDate.value.toLocaleDateString(locale, { weekday: props.dayNameFormat }); \n}); \n \nconst isPrevDisabled = computed(() => { \n if (!props.minDate) return false; \n const prev = new Date(currentDate.value); \n prev.setDate(prev.getDate() - 1); \n return prev < startOfDay(props.minDate); \n}); \nconst isNextDisabled = computed(() => { \n if (!props.maxDate) return false; \n const next = new Date(currentDate.value); \n next.setDate(next.getDate() + 1); \n return next > startOfDay(props.maxDate); \n}); \n \nconst isDisabledDate = (d: Date) => props.disabledDates.some(x => isSameDay(x, d)); \nconst isDisabledWeekday = (d: Date) => props.disabledWeekdays.includes(d.getDay()); \nconst dayIsDisabled = computed(() => { \n const d = currentDate.value; \n if (props.minDate && startOfDay(d) < startOfDay(props.minDate)) return true; \n if (props.maxDate && startOfDay(d) > startOfDay(props.maxDate)) return true; \n return isDisabledDate(d) || isDisabledWeekday(d); \n}); \n \nconst parseHM = (s: string) => { \n const [h, m] = s.split(':').map(Number); \n return h * 60 + (m || 0); \n}; \n \nconst splitDayRange = (absStart: number, absEnd: number) => { \n const parts: { dayOffset: number; startMin: number; endMin: number }[] = []; \n let s = absStart; \n while (s < absEnd) { \n const dayOffset = Math.floor(s / 1440); \n const dayStart = dayOffset * 1440; \n const chunkEnd = Math.min(absEnd, dayStart + 1440); \n parts.push({ dayOffset, startMin: s - dayStart, endMin: chunkEnd - dayStart }); \n s = chunkEnd; \n } \n return parts; \n}; \n \nconst rangeMatchesDisabled = (baseDow: number, absStart: number, absEnd: number) => { \n if (!props.disabledTimeRanges.length) return false; \n const parts = splitDayRange(absStart, absEnd); \n return parts.some(p => { \n const dow = (baseDow + p.dayOffset) % 7; \n return props.disabledTimeRanges.some(r => { \n if (r.daysOfWeek && !r.daysOfWeek.includes(dow)) return false; \n const rs = parseHM(r.start); \n const re = parseHM(r.end); \n return p.startMin < re && p.endMin > rs; \n }); \n }); \n}; \n \nconst isSlotDisabled = (slotIdx: number) => { \n if (dayIsDisabled.value) return true; \n if (!props.disabledTimeRanges.length) return false; \n const slotStartMin = props.hourStart * 60 + slotIdx * props.slotMinutes; \n const slotEndMin = slotStartMin + props.slotMinutes; \n return rangeMatchesDisabled(currentDate.value.getDay(), slotStartMin, slotEndMin); \n}; \n \nconst rangeHitsDisabled = (startMinFromHourStart: number, endMinFromHourStart: number) => { \n if (dayIsDisabled.value) return true; \n if (!props.disabledTimeRanges.length) return false; \n const absStart = props.hourStart * 60 + startMinFromHourStart; \n const absEnd = props.hourStart * 60 + endMinFromHourStart; \n return rangeMatchesDisabled(currentDate.value.getDay(), absStart, absEnd); \n}; \n \nconst rangeOverlapsEvent = (startMs: number, endMs: number, ignoreId: CalendarEvent['id']) => { \n return props.events.some(ev => { \n if (ev.id === ignoreId) return false; \n if (ev.allDay) return false; \n if (!isSameDay(ev.start, currentDate.value)) return false; \n const es = ev.start.getTime(); \n const ee = (ev.end ?? ev.start).getTime(); \n return startMs < ee && endMs > es; \n }); \n}; \n \nconst isEventInteractive = (ev: CalendarEvent) => !props.readonly && !ev.readonly; \n \nconst businessHoursList = computed<BusinessHours[]>(() => { \n if (!props.businessHours) return []; \n return Array.isArray(props.businessHours) ? props.businessHours : [props.businessHours]; \n}); \n \nconst isBusinessHourSlot = (slotIdx: number) => { \n if (!businessHoursList.value.length) return true; \n const slotStartMin = props.hourStart * 60 + slotIdx * props.slotMinutes; \n const slotEndMin = slotStartMin + props.slotMinutes; \n const parts = splitDayRange(slotStartMin, slotEndMin); \n const baseDow = currentDate.value.getDay(); \n return parts.some(p => { \n const dow = (baseDow + p.dayOffset) % 7; \n return businessHoursList.value.some(b => { \n if (b.daysOfWeek && !b.daysOfWeek.includes(dow)) return false; \n return p.startMin >= parseHM(b.start) && p.startMin < parseHM(b.end); \n }); \n }); \n}; \n \nconst { \n slotsPerHour, \n windowHours, \n totalSlots, \n windowMinutes, \n totalPixels, \n hourLabels, \n dayStartMs: getDayStartMs, \n dayEndMs: getDayEndMs, \n} = useTimeGrid({ \n hourStart: () => props.hourStart, \n hourEnd: () => props.hourEnd, \n slotMinutes: () => props.slotMinutes, \n slotHeight: () => props.slotHeight, \n format: () => props.format, \n}); \n \nconst dayStartMs = computed(() => getDayStartMs(currentDate.value)); \nconst dayEndMs = computed(() => getDayEndMs(currentDate.value)); \n \ninterface TimedSeg { key: string; event: CalendarEvent; style: Record<string, string>; } \n \nconst timedSegments = computed<TimedSeg[]>(() => { \n const result: TimedSeg[] = []; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const dStart = dayStartMs.value; \n const dEnd = dayEndMs.value; \n \n const dayEvents = props.events \n .filter(ev => !ev.allDay) \n .filter(ev => { \n const es = ev.start.getTime(); \n const ee = (ev.end ?? ev.start).getTime(); \n return !(ee <= dStart || es >= dEnd); \n }) \n .sort((a, b) => a.start.getTime() - b.start.getTime()); \n \n const clusters: CalendarEvent[][] = []; \n for (const ev of dayEvents) { \n const evStart = Math.max(ev.start.getTime(), dStart); \n let placed = false; \n for (const cluster of clusters) { \n const clusterEnd = Math.max(...cluster.map(e => Math.min((e.end ?? e.start).getTime(), dEnd))); \n if (evStart < clusterEnd) { cluster.push(ev); placed = true; break; } \n } \n if (!placed) clusters.push([ev]); \n } \n \n for (const cluster of clusters) { \n const columns: CalendarEvent[][] = []; \n for (const ev of cluster) { \n const evStart = Math.max(ev.start.getTime(), dStart); \n let placed = false; \n for (const col of columns) { \n const last = col[col.length - 1]; \n const lastEnd = Math.min((last.end ?? last.start).getTime(), dEnd); \n if (lastEnd <= evStart) { col.push(ev); placed = true; break; } \n } \n if (!placed) columns.push([ev]); \n } \n const colCount = columns.length; \n columns.forEach((col, colIdx) => { \n for (const ev of col) { \n const startMs = Math.max(ev.start.getTime(), dStart); \n const endMsRaw = (ev.end ?? new Date(ev.start.getTime() + 30 * MS_MIN)).getTime(); \n const endMs = Math.min(endMsRaw, dEnd); \n const startMin = (startMs - dStart) / MS_MIN; \n const endMin = (endMs - dStart) / MS_MIN; \n const top = startMin * pxPerMin; \n const height = Math.max((endMin - startMin) * pxPerMin - 1, 18); \n const width = 100 / colCount; \n const left = colIdx * width; \n \n result.push({ \n key: String(ev.id), \n event: ev, \n style: { \n top: `${top}px`, \n height: `${height}px`, \n left: `calc(${left}% + 2px)`, \n width: `calc(${width}% - 4px)`, \n }, \n }); \n } \n }); \n } \n return result; \n}); \n \ninterface AllDaySeg { key: string; event: CalendarEvent; lane: number; } \nconst allDayLayout = computed<{ segs: AllDaySeg[]; rows: number }>(() => { \n const segs: AllDaySeg[] = []; \n const target = startOfDay(currentDate.value).getTime(); \n const list = props.events \n .filter(ev => ev.allDay || (ev.end && startOfDay(ev.end).getTime() > startOfDay(ev.start).getTime())) \n .filter(ev => { \n const sd = startOfDay(ev.start).getTime(); \n const ed = startOfDay(ev.end ?? ev.start).getTime(); \n return target >= sd && target <= ed; \n }) \n .sort((a, b) => a.start.getTime() - b.start.getTime()); \n list.forEach((ev, i) => segs.push({ key: `ad-${ev.id}`, event: ev, lane: i })); \n return { segs, rows: segs.length }; \n}); \nconst allDaySegments = computed(() => allDayLayout.value.segs); \nconst allDayRows = computed(() => allDayLayout.value.rows); \n \nconst isTodayInView = computed(() => { \n const nt = now.value.getTime(); \n return nt >= dayStartMs.value && nt < dayEndMs.value; \n}); \n \nconst currentTimeTop = computed(() => { \n if (!isTodayInView.value) return 0; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const min = (now.value.getTime() - dayStartMs.value) / MS_MIN; \n return Math.max(0, Math.min(min, windowMinutes.value)) * pxPerMin; \n}); \n \nconst currentTimeLabel = computed(() => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return now.value.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: props.format === '12h' }); \n}); \n \nconst formatEventTime = (d: Date) => { \n const locale = props.locale === 'default' ? undefined : props.locale; \n return d.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: props.format === '12h' }); \n}; \n \nconst scrollToCurrentTime = () => { \n nextTick(() => { \n if (!scrollRef.value) return; \n let top = 0; \n if (isTodayInView.value) { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const min = (now.value.getTime() - dayStartMs.value) / MS_MIN; \n top = Math.max(0, Math.min(min, windowMinutes.value)) * pxPerMin; \n } \n const target = Math.max(0, top - scrollRef.value.clientHeight / 3); \n gsap.to(scrollRef.value, { scrollTop: target, duration: 0.55, ease: 'power3.inOut' }); \n }); \n}; \n \nconst animate = (dir: 1 | -1) => { \n if (!scrollRef.value) return; \n gsap.fromTo( \n scrollRef.value, \n { opacity: 0, x: 24 * dir }, \n { opacity: 1, x: 0, duration: 0.32, ease: 'power3.out' } \n ); \n nextTick(() => { \n if (!scrollRef.value) return; \n const els = scrollRef.value.querySelectorAll<HTMLElement>('[data-eid]'); \n if (els.length) { \n gsap.fromTo( \n els, \n { opacity: 0, y: 6, scale: 0.96 }, \n { opacity: 1, y: 0, scale: 1, duration: 0.35, ease: 'power2.out', stagger: { amount: 0.18 } } \n ); \n } \n }); \n}; \n \nconst findEventEls = (id: CalendarEvent['id']): HTMLElement[] => { \n if (!rootRef.value) return []; \n return Array.from(rootRef.value.querySelectorAll<HTMLElement>(`[data-eid=\"${id}\"]`)); \n}; \n \nconst dropGrowEvent = (id: CalendarEvent['id']) => { \n nextTick(() => { \n const els = findEventEls(id); \n if (!els.length) return; \n gsap.fromTo( \n els, \n { scale: 0.4, opacity: 0 }, \n { scale: 1, opacity: 1, duration: 0.42, ease: 'back.out(1.7)', transformOrigin: 'center center' } \n ); \n }); \n}; \n \nconst stretchResize = (id: CalendarEvent['id'], oldHeightPx: number) => { \n nextTick(() => { \n const els = findEventEls(id); \n if (!els.length) return; \n els.forEach(el => { \n const newH = el.offsetHeight; \n if (newH <= 0 || oldHeightPx <= 0 || newH === oldHeightPx) return; \n const fromScale = oldHeightPx / newH; \n gsap.fromTo( \n el, \n { scaleY: fromScale }, \n { scaleY: 1, duration: 0.32, ease: 'power3.out', transformOrigin: 'top center', overwrite: 'auto', clearProps: 'transform' } \n ); \n }); \n }); \n}; \n \nconst shiftDay = (days: number) => { \n const d = new Date(currentDate.value); \n d.setDate(d.getDate() + days); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(days > 0 ? 1 : -1)); \n}; \nconst handlePrev = () => shiftDay(-1); \nconst handleNext = () => shiftDay(1); \nconst handlePrevYear = () => { \n const d = new Date(currentDate.value); \n d.setFullYear(d.getFullYear() - 1); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(-1)); \n}; \nconst handleNextYear = () => { \n const d = new Date(currentDate.value); \n d.setFullYear(d.getFullYear() + 1); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(1)); \n}; \nconst handleToday = () => { \n const n = new Date(); \n currentDate.value = startOfDay(n); \n emit('update:modelValue', n); \n nextTick(() => { animate(1); scrollToCurrentTime(); }); \n}; \n \nconst clickTimer = ref<ReturnType<typeof setTimeout> | null>(null); \nconst DOUBLE_CLICK_DELAY = 220; \n \nconst pxToSlotMin = (offsetY: number) => { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const rawMin = offsetY / pxPerMin; \n return Math.floor(rawMin / props.slotMinutes) * props.slotMinutes; \n}; \nconst slotDateFromOffset = (offsetY: number): Date => { \n const snapped = pxToSlotMin(offsetY); \n const base = new Date(currentDate.value); \n base.setHours(props.hourStart, 0, 0, 0); \n base.setMinutes(base.getMinutes() + snapped); \n return base; \n}; \nconst offsetFromEvent = (el: HTMLElement, clientY: number) => { \n const rect = el.getBoundingClientRect(); \n return Math.max(0, clientY - rect.top); \n}; \n \nconst handleSlotClick = (e: MouseEvent) => { \n if (rangeJustSelected.value) { rangeJustSelected.value = false; return; } \n if (dayIsDisabled.value) return; \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const dt = slotDateFromOffset(offsetY); \n const slotIdx = Math.floor(((dt.getHours() - props.hourStart) * 60 + dt.getMinutes()) / props.slotMinutes); \n if (isSlotDisabled(slotIdx)) return; \n if (clickTimer.value) clearTimeout(clickTimer.value); \n clickTimer.value = setTimeout(() => { \n emit('slot-click', dt, e); \n clickTimer.value = null; \n }, DOUBLE_CLICK_DELAY); \n}; \nconst handleSlotDblClick = (e: MouseEvent) => { \n if (props.readonly) return; \n if (dayIsDisabled.value) return; \n if (clickTimer.value) { clearTimeout(clickTimer.value); clickTimer.value = null; } \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const dt = slotDateFromOffset(offsetY); \n const slotIdx = Math.floor(((dt.getHours() - props.hourStart) * 60 + dt.getMinutes()) / props.slotMinutes); \n if (isSlotDisabled(slotIdx)) return; \n emit('create-event', dt, false, e); \n}; \n \nconst handleAllDayCellClick = (_e: MouseEvent) => {}; \nconst handleAllDayCellDblClick = (e: MouseEvent) => { \n if (props.readonly) return; \n if (dayIsDisabled.value) return; \n emit('create-event', startOfDay(currentDate.value), true, e); \n}; \n \nconst resizeJustEnded = ref(false); \nconst handleEventClick = (ev: CalendarEvent, e: MouseEvent) => { \n if (resizeJustEnded.value) { resizeJustEnded.value = false; return; } \n emit('event-click', ev, e); \n}; \n \nconst draggingId = ref<string | number | null>(null); \nconst dragOverActive = ref(false); \nconst allDayDragOver = ref(false); \n \nconst onDragStart = (ev: CalendarEvent, e: DragEvent) => { \n if (!props.draggableEvents || !isEventInteractive(ev)) { e.preventDefault(); return; } \n onEventLeave(); \n draggingId.value = ev.id; \n if (e.dataTransfer) { \n e.dataTransfer.effectAllowed = 'move'; \n e.dataTransfer.setData('text/plain', String(ev.id)); \n const src = e.currentTarget as HTMLElement; \n if (src && typeof e.dataTransfer.setDragImage === 'function') { \n const rect = src.getBoundingClientRect(); \n const w = Math.max(rect.width * 0.7, 90); \n const h = Math.max(rect.height * 0.7, 26); \n const wrap = document.createElement('div'); \n wrap.style.cssText = [ \n 'position:absolute', 'top:-9999px', 'left:-9999px', \n `width:${w}px`, `height:${h}px`, \n 'background:white', 'border-radius:4px', 'overflow:hidden', \n 'box-shadow:0 6px 18px rgba(0,0,0,0.22)', \n 'pointer-events:none', 'margin:0', 'transform:rotate(-1.5deg)', \n ].join(';'); \n const clone = src.cloneNode(true) as HTMLElement; \n clone.style.position = 'static'; \n clone.style.width = '100%'; \n clone.style.height = '100%'; \n clone.style.left = 'auto'; \n clone.style.top = 'auto'; \n clone.style.margin = '0'; \n clone.style.opacity = '1'; \n wrap.appendChild(clone); \n document.body.appendChild(wrap); \n e.dataTransfer.setDragImage(wrap, Math.round(w / 2), 14); \n setTimeout(() => { wrap.parentNode?.removeChild(wrap); }, 0); \n } \n } \n}; \nconst onDragEnd = () => { \n draggingId.value = null; \n dragOverActive.value = false; \n allDayDragOver.value = false; \n stopAutoScroll(); \n}; \nconst onDragOver = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n const ev = props.events.find(x => x.id === draggingId.value); \n let blocked = false; \n if (!props.allowDropOnDisabled) { \n if (dayIsDisabled.value) blocked = true; \n else if (ev && !ev.allDay) { \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const snappedMin = pxToSlotMin(offsetY); \n const duration = ev.end ? ev.end.getTime() - ev.start.getTime() : 30 * MS_MIN; \n const durationMin = duration / MS_MIN; \n if (rangeHitsDisabled(snappedMin, snappedMin + durationMin)) blocked = true; \n } \n } \n if (e.dataTransfer) e.dataTransfer.dropEffect = blocked ? 'none' : 'move'; \n dragOverActive.value = !blocked; \n handleAutoScroll(e.clientY); \n}; \nconst onDrop = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n if (!props.allowDropOnDisabled && dayIsDisabled.value) { onDragEnd(); return; } \n const ev = props.events.find(x => x.id === draggingId.value); \n if (!ev) { onDragEnd(); return; } \n const offsetY = offsetFromEvent(e.currentTarget as HTMLElement, e.clientY); \n const snappedMin = pxToSlotMin(offsetY); \n const wasAllDay = !!ev.allDay; \n const duration = !wasAllDay && ev.end ? ev.end.getTime() - ev.start.getTime() : 30 * MS_MIN; \n const durationMin = duration / MS_MIN; \n if (!props.allowDropOnDisabled && rangeHitsDisabled(snappedMin, snappedMin + durationMin)) { onDragEnd(); return; } \n const newStart = new Date(currentDate.value); \n newStart.setHours(props.hourStart, 0, 0, 0); \n newStart.setMinutes(newStart.getMinutes() + snappedMin); \n const newEnd = new Date(newStart.getTime() + duration); \n if (props.preventOverlap && rangeOverlapsEvent(newStart.getTime(), newEnd.getTime(), ev.id)) { onDragEnd(); return; } \n const emitEv = wasAllDay ? { ...ev, allDay: false } as CalendarEvent : ev; \n emit('event-drop', emitEv, newStart, newEnd); \n dropGrowEvent(ev.id); \n onDragEnd(); \n}; \n \nconst onAllDayDragOver = (e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n const blocked = !props.allowDropOnDisabled && dayIsDisabled.value; \n if (e.dataTransfer) e.dataTransfer.dropEffect = blocked ? 'none' : 'move'; \n allDayDragOver.value = !blocked; \n}; \nconst onAllDayDrop = (_e: DragEvent) => { \n if (!props.draggableEvents || draggingId.value === null) return; \n if (!props.allowDropOnDisabled && dayIsDisabled.value) { onDragEnd(); return; } \n const ev = props.events.find(x => x.id === draggingId.value); \n if (!ev) { onDragEnd(); return; } \n const wasAllDay = !!ev.allDay; \n const duration = wasAllDay && ev.end ? startOfDay(ev.end).getTime() - startOfDay(ev.start).getTime() : 0; \n const newStart = startOfDay(currentDate.value); \n const newEnd = new Date(newStart.getTime() + duration); \n const emitEv = !wasAllDay ? { ...ev, allDay: true } as CalendarEvent : ev; \n emit('event-drop', emitEv, newStart, wasAllDay ? newEnd : undefined); \n dropGrowEvent(ev.id); \n onDragEnd(); \n}; \n \ninterface RangeSelect { startMin: number; endMin: number; topPx: number; heightPx: number; } \nconst rangeSelect = ref<RangeSelect | null>(null); \nconst rangeJustSelected = ref(false); \nlet rangePointerId: number | null = null; \nlet rangeStartColEl: HTMLElement | null = null; \n \nconst onColPointerDown = (e: PointerEvent) => { \n if (props.readonly) return; \n if (!props.allowRangeSelection) return; \n if (e.button !== 0) return; \n if (dayIsDisabled.value) return; \n rangeStartColEl = e.currentTarget as HTMLElement; \n const offsetY = offsetFromEvent(rangeStartColEl, e.clientY); \n const startMin = pxToSlotMin(offsetY); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n rangeSelect.value = { \n startMin, endMin: startMin + props.slotMinutes, \n topPx: startMin * pxPerMin, \n heightPx: props.slotMinutes * pxPerMin, \n }; \n rangePointerId = e.pointerId; \n rangeStartColEl.setPointerCapture(e.pointerId); \n rangeStartColEl.addEventListener('pointermove', onRangePointerMove); \n rangeStartColEl.addEventListener('pointerup', onRangePointerUp); \n rangeStartColEl.addEventListener('pointercancel', onRangePointerUp); \n}; \nconst onRangePointerMove = (e: PointerEvent) => { \n if (!rangeSelect.value || !rangeStartColEl) return; \n handleAutoScroll(e.clientY); \n const offsetY = offsetFromEvent(rangeStartColEl, e.clientY); \n const curMin = Math.max(0, Math.min(windowMinutes.value, pxToSlotMin(offsetY) + props.slotMinutes)); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const s = Math.min(rangeSelect.value.startMin, curMin - props.slotMinutes); \n const e2 = Math.max(rangeSelect.value.startMin + props.slotMinutes, curMin); \n rangeSelect.value = { ...rangeSelect.value, topPx: s * pxPerMin, heightPx: (e2 - s) * pxPerMin, endMin: e2, startMin: s }; \n}; \nconst onRangePointerUp = (_e: PointerEvent) => { \n if (!rangeSelect.value || !rangeStartColEl) return; \n stopAutoScroll(); \n const { startMin, endMin } = rangeSelect.value; \n rangeStartColEl.removeEventListener('pointermove', onRangePointerMove); \n rangeStartColEl.removeEventListener('pointerup', onRangePointerUp); \n rangeStartColEl.removeEventListener('pointercancel', onRangePointerUp); \n if (rangePointerId !== null) rangeStartColEl.releasePointerCapture?.(rangePointerId); \n rangePointerId = null; \n rangeStartColEl = null; \n \n const durationMin = endMin - startMin; \n if (durationMin > props.slotMinutes) { \n const start = new Date(currentDate.value); \n start.setHours(props.hourStart, 0, 0, 0); \n start.setMinutes(start.getMinutes() + startMin); \n const end = new Date(start.getTime() + durationMin * MS_MIN); \n rangeJustSelected.value = true; \n emit('select-range', start, end); \n } \n rangeSelect.value = null; \n}; \n \ninterface ResizePreview { topPx: number; heightPx: number; } \nconst resizingId = ref<string | number | null>(null); \nconst resizingPreview = ref<ResizePreview | null>(null); \nlet resizeStartState: { event: CalendarEvent; startMin: number; minEndMin: number } | null = null; \n \nconst onResizeStart = (ev: CalendarEvent, e: PointerEvent) => { \n if (!props.resizableEvents || !isEventInteractive(ev)) return; \n const startMin = Math.max(0, (ev.start.getTime() - dayStartMs.value) / MS_MIN); \n const minEndMin = startMin + props.slotMinutes; \n resizingId.value = ev.id; \n resizeStartState = { event: ev, startMin, minEndMin }; \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const curEndMin = ev.end ? (ev.end.getTime() - dayStartMs.value) / MS_MIN : minEndMin; \n resizingPreview.value = { \n topPx: startMin * pxPerMin, \n heightPx: Math.max(curEndMin - startMin, props.slotMinutes) * pxPerMin, \n }; \n window.addEventListener('pointermove', onResizeMove); \n window.addEventListener('pointerup', onResizeEnd); \n window.addEventListener('pointercancel', onResizeEnd); \n void e; \n}; \nconst onResizeMove = (e: PointerEvent) => { \n if (!resizeStartState || !resizingPreview.value || !colRef.value) return; \n handleAutoScroll(e.clientY); \n const rect = colRef.value.getBoundingClientRect(); \n const offsetY = Math.max(0, Math.min(totalPixels.value, e.clientY - rect.top)); \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const rawMin = offsetY / pxPerMin; \n const snapped = Math.ceil(rawMin / props.slotMinutes) * props.slotMinutes; \n const endMin = Math.max(resizeStartState.minEndMin, Math.min(windowMinutes.value, snapped)); \n resizingPreview.value = { ...resizingPreview.value, heightPx: (endMin - resizeStartState.startMin) * pxPerMin }; \n}; \nconst onResizeEnd = () => { \n window.removeEventListener('pointermove', onResizeMove); \n window.removeEventListener('pointerup', onResizeEnd); \n window.removeEventListener('pointercancel', onResizeEnd); \n stopAutoScroll(); \n if (resizeStartState && resizingPreview.value) { \n const pxPerMin = props.slotHeight / props.slotMinutes; \n const endMin = resizeStartState.startMin + resizingPreview.value.heightPx / pxPerMin; \n const newStart = new Date(resizeStartState.event.start); \n const newEnd = new Date(currentDate.value); \n newEnd.setHours(props.hourStart, 0, 0, 0); \n newEnd.setMinutes(newEnd.getMinutes() + endMin); \n const hitsDisabled = !props.allowResizeOverDisabled && rangeHitsDisabled(resizeStartState.startMin, endMin); \n const overlaps = props.preventOverlap && rangeOverlapsEvent(newStart.getTime(), newEnd.getTime(), resizeStartState.event.id); \n if (!hitsDisabled && !overlaps) { \n const ev = resizeStartState.event; \n const oldEndMin = ev.end ? (ev.end.getTime() - dayStartMs.value) / MS_MIN : resizeStartState.minEndMin; \n const oldHeightPx = Math.max((oldEndMin - resizeStartState.startMin) * pxPerMin - 1, 18); \n emit('event-resize', ev, newStart, newEnd); \n stretchResize(ev.id, oldHeightPx); \n } \n resizeJustEnded.value = true; \n setTimeout(() => { resizeJustEnded.value = false; }, 0); \n } \n resizingId.value = null; \n resizingPreview.value = null; \n resizeStartState = null; \n}; \n \nconst handleKeydown = (e: KeyboardEvent) => { \n if (!props.enableKeyboardNavigation) return; \n const target = e.target as HTMLElement; \n if (target.tagName === 'SELECT' || target.tagName === 'INPUT') return; \n if (e.key === 'ArrowLeft' || e.key === 'PageUp') { e.preventDefault(); shiftDay(-1); } \n else if (e.key === 'ArrowRight' || e.key === 'PageDown') { e.preventDefault(); shiftDay(1); } \n else if (e.key.toLowerCase() === 't') { e.preventDefault(); handleToday(); } \n else if (e.key.toLowerCase() === 'c' && !props.readonly) { e.preventDefault(); emit('create-event', startOfDay(currentDate.value), true, e); } \n}; \n \ndefineExpose({ scrollToCurrentTime }); \n \n \nconst eventInlineStyle = (ev: CalendarEvent) => { \n if (!ev.colorHex) return undefined; \n return { backgroundColor: hexToRgba(ev.colorHex, 0.12), borderLeftColor: ev.colorHex, color: ev.colorHex }; \n}; \n \nconst { currentTimeSolidClass } = useCurrentTimeLine(() => props.currentTimeColor); \n \nconst { \n todayTextClass, \n rangeSelectClass, \n focusRingColorClass, \n containerRadiusClass, \n eventRadiusClass, \n showEventAccent, \n pillRadiusClass, \n dayNameCaseClass, \n resolvedColor, \n} = useCalendarTheme({ \n color: () => props.color, \n radius: () => props.radius, \n dayNameCase: () => props.dayNameCase, \n}); \n \nconst localeValue = computed(() => (props.locale === 'default' ? undefined : props.locale)); \n \nconst monthOptions = computed(() => { \n const base = new Date(2024, 0, 1); \n return Array.from({ length: 12 }, (_, i) => { \n const d = new Date(base); \n d.setMonth(i); \n return d.toLocaleString(localeValue.value, { month: 'long' }); \n }); \n}); \n \nconst yearOptions = computed(() => { \n const min = props.minDate?.getFullYear() ?? currentDate.value.getFullYear() - 10; \n const max = props.maxDate?.getFullYear() ?? currentDate.value.getFullYear() + 10; \n const list: number[] = []; \n for (let y = min; y <= max; y++) list.push(y); \n return list; \n}); \n \nconst dayOptions = computed(() => { \n const last = new Date(currentDate.value.getFullYear(), currentDate.value.getMonth() + 1, 0).getDate(); \n return Array.from({ length: last }, (_, i) => i + 1); \n}); \n \nconst selectedDay = computed({ \n get: () => currentDate.value.getDate(), \n set: (dd: number) => { \n const dir = dd > currentDate.value.getDate() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setDate(dd); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n \nconst selectedMonth = computed({ \n get: () => currentDate.value.getMonth(), \n set: (mm: number) => { \n const dir = mm > currentDate.value.getMonth() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setDate(1); \n d.setMonth(mm); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n \nconst selectedYear = computed({ \n get: () => currentDate.value.getFullYear(), \n set: (yy: number) => { \n const dir = yy > currentDate.value.getFullYear() ? 1 : -1; \n const d = new Date(currentDate.value); \n d.setFullYear(yy); \n currentDate.value = d; \n emit('update:modelValue', d); \n nextTick(() => animate(dir)); \n }, \n}); \n</script>\n"],"mappings":""}
|
package/dist/components/data-display/calendar/DayView.vue_vue_type_script_setup_true_lang.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_useEventHover = require("../../../composables/useEventHover.cjs");
|
|
|
7
7
|
const require_CalendarEventTooltip = require("./CalendarEventTooltip.cjs");
|
|
8
8
|
const require_CalendarHeader = require("./CalendarHeader.cjs");
|
|
9
9
|
const require_cssLength = require("../../../utils/cssLength.cjs");
|
|
10
|
+
const require_calendarTooltip = require("../../../utils/calendarTooltip.cjs");
|
|
10
11
|
const require_useCurrentTimeLine = require("../../../composables/useCurrentTimeLine.cjs");
|
|
11
12
|
const require_useTimeGrid = require("../../../composables/useTimeGrid.cjs");
|
|
12
13
|
let vue = require("vue");
|
|
@@ -1175,13 +1176,14 @@ var DayView_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vu
|
|
|
1175
1176
|
state: (0, vue.unref)(hoverState),
|
|
1176
1177
|
style: (0, vue.normalizeStyle)((0, vue.unref)(tooltipStyle)),
|
|
1177
1178
|
formatTime: formatEventTime
|
|
1178
|
-
}, {
|
|
1179
|
-
|
|
1179
|
+
}, (0, vue.createSlots)({ _: 2 }, [_ctx.$slots["event-tooltip"] ? {
|
|
1180
|
+
name: "default",
|
|
1181
|
+
fn: (0, vue.withCtx)(({ event, allDay }) => [(0, vue.createElementVNode)("div", { class: (0, vue.normalizeClass)((0, vue.unref)(require_calendarTooltip.CALENDAR_TOOLTIP_SURFACE)) }, [(0, vue.renderSlot)(_ctx.$slots, "event-tooltip", {
|
|
1180
1182
|
event,
|
|
1181
1183
|
allDay
|
|
1182
|
-
})]),
|
|
1183
|
-
|
|
1184
|
-
},
|
|
1184
|
+
})], 2)]),
|
|
1185
|
+
key: "0"
|
|
1186
|
+
} : void 0]), 1032, ["state", "style"])
|
|
1185
1187
|
], 38);
|
|
1186
1188
|
};
|
|
1187
1189
|
}
|