feat: visible date range

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-29 21:41:27 -04:00
parent 18a96f5dab
commit 51bf195664
10 changed files with 214 additions and 68 deletions
+6 -14
View File
@@ -107,6 +107,7 @@ import {
getTimedEventsForDate,
type MultiDaySegment,
} from '@/utils/calendarHelpers';
import { shiftLocalDays } from '@/utils/dateRanges';
import { DAYS_VIEW_SPANS, spanToDays, type DaysViewSpan } from '@/types/spans';
import type { EntityObject } from '@ChronoManager/models/entity';
import type { CollectionObject } from '@ChronoManager/models/collection';
@@ -126,7 +127,6 @@ const props = defineProps<{
const selectedSpan = ref<DaysViewSpan>(props.initialSpan ?? '7d');
const daysCount = computed(() => spanToDays(selectedSpan.value));
const localDate = ref(new Date(props.currentDate));
const emit = defineEmits<{
'event-click': [event: CalendarEntity];
@@ -134,13 +134,9 @@ const emit = defineEmits<{
'event-hover-end': [];
'date-click': [date: Date];
'update:span': [span: DaysViewSpan];
'update:current-date': [date: Date];
}>();
// Watch for external date changes (e.g., from mini calendar)
watch(() => props.currentDate, (newDate) => {
localDate.value = new Date(newDate);
});
watch(() => props.initialSpan, (newSpan) => {
if (newSpan && newSpan !== selectedSpan.value) {
selectedSpan.value = newSpan;
@@ -153,19 +149,15 @@ function setSpan(span: DaysViewSpan) {
}
function previousPeriod() {
const date = new Date(localDate.value);
date.setDate(date.getDate() - daysCount.value);
localDate.value = date;
emit('update:current-date', shiftLocalDays(props.currentDate, -daysCount.value));
}
function nextPeriod() {
const date = new Date(localDate.value);
date.setDate(date.getDate() + daysCount.value);
localDate.value = date;
emit('update:current-date', shiftLocalDays(props.currentDate, daysCount.value));
}
function goToToday() {
localDate.value = new Date();
emit('update:current-date', new Date());
}
const dateRangeLabel = computed(() => {
@@ -189,7 +181,7 @@ const dateRangeLabel = computed(() => {
const visibleDates = computed(() => {
const dates: Date[] = [];
const start = new Date(localDate.value);
const start = new Date(props.currentDate);
for (let i = 0; i < daysCount.value; i++) {
dates.push(new Date(start));