@nomideusz/svelte-calendar 0.5.1 → 0.5.2
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.
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import type { TimelineEvent } from '../../core/types.js';
|
|
15
15
|
import type { DragState } from '../../engine/drag.svelte.js';
|
|
16
16
|
import type { ViewState } from '../../engine/view-state.svelte.js';
|
|
17
|
+
import type { EventStore } from '../../engine/event-store.svelte.js';
|
|
17
18
|
import { DAY_MS, HOUR_MS, sod } from '../../core/time.js';
|
|
18
19
|
import { startOfWeek as sowFn, fractionalHour, isAllDay, isMultiDay, segmentForDay } from '../../core/time.js';
|
|
19
20
|
import type { DaySegment } from '../../core/time.js';
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
const drag = getContext<DragState>('calendar:drag') as DragState | undefined;
|
|
53
54
|
const commitDragCtx = getContext<() => void>('calendar:commitDrag') as (() => void) | undefined;
|
|
54
55
|
const viewState = getContext<ViewState>('calendar:viewState') as ViewState | undefined;
|
|
56
|
+
const storeCtx = getContext<{ current: EventStore }>('calendar:store') as { current: EventStore } | undefined;
|
|
55
57
|
|
|
56
58
|
const clock = createClock();
|
|
57
59
|
|
|
@@ -82,6 +84,18 @@
|
|
|
82
84
|
const todayMs = $derived(clock.today);
|
|
83
85
|
const anchorWeekStart = $derived(sowFn(internalFocusMs, mondayStart));
|
|
84
86
|
|
|
87
|
+
// ─── Preload events for entire visible range ────────
|
|
88
|
+
// Calendar only loads a single week by default. The planner shows
|
|
89
|
+
// BUFFER_WEEKS on each side, so we proactively load the full range
|
|
90
|
+
// so events for non-current weeks are visible immediately.
|
|
91
|
+
$effect(() => {
|
|
92
|
+
const store = storeCtx?.current;
|
|
93
|
+
if (!store) return;
|
|
94
|
+
const rangeStart = new Date(anchorWeekStart - BUFFER_WEEKS * 7 * DAY_MS);
|
|
95
|
+
const rangeEnd = new Date(anchorWeekStart + (BUFFER_WEEKS + 1) * 7 * DAY_MS);
|
|
96
|
+
store.load({ start: rangeStart, end: rangeEnd });
|
|
97
|
+
});
|
|
98
|
+
|
|
85
99
|
// ─── Week data ──────────────────────────────────────
|
|
86
100
|
interface WeekRow {
|
|
87
101
|
weekStart: number;
|