@nomideusz/svelte-calendar 0.6.0 → 0.6.4
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/README.md +183 -5
- package/dist/adapters/composite.d.ts +15 -0
- package/dist/adapters/composite.js +65 -0
- package/dist/adapters/index.d.ts +5 -1
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/mapped.d.ts +170 -0
- package/dist/adapters/mapped.js +343 -0
- package/dist/adapters/recurring.d.ts +11 -0
- package/dist/adapters/recurring.js +9 -13
- package/dist/adapters/types.d.ts +11 -2
- package/dist/calendar/Calendar.svelte +847 -767
- package/dist/calendar/Calendar.svelte.d.ts +14 -2
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.js +2 -0
- package/dist/core/measure.d.ts +104 -0
- package/dist/core/measure.js +195 -0
- package/dist/core/time.js +2 -2
- package/dist/core/types.d.ts +32 -0
- package/dist/engine/event-store.svelte.js +22 -7
- package/dist/headless/create-agenda.svelte.d.ts +67 -0
- package/dist/headless/create-agenda.svelte.js +139 -0
- package/dist/headless/create-calendar.svelte.d.ts +2 -0
- package/dist/headless/create-calendar.svelte.js +380 -0
- package/dist/headless/index.d.ts +4 -0
- package/dist/headless/index.js +2 -0
- package/dist/headless/types.d.ts +219 -0
- package/dist/headless/types.js +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4 -2
- package/dist/primitives/DayHeader.svelte +103 -103
- package/dist/primitives/EmptySlot.svelte +105 -105
- package/dist/primitives/EventBlock.svelte +397 -312
- package/dist/primitives/NowIndicator.svelte +178 -178
- package/dist/primitives/TimeGutter.svelte +104 -104
- package/dist/theme/presets.js +36 -36
- package/dist/views/agenda/AgendaDay.svelte +1167 -1055
- package/dist/views/agenda/AgendaWeek.svelte +987 -924
- package/dist/views/mobile/Mobile.svelte +17 -17
- package/dist/views/mobile/MobileDay.svelte +729 -665
- package/dist/views/mobile/MobileWeek.svelte +476 -456
- package/dist/views/planner/PlannerDay.svelte +1184 -1091
- package/dist/views/planner/PlannerWeek.svelte +924 -945
- package/dist/views/shared/context.svelte.d.ts +47 -0
- package/dist/views/shared/context.svelte.js +47 -0
- package/dist/views/shared/format.d.ts +19 -0
- package/dist/views/shared/format.js +46 -0
- package/dist/views/shared/index.d.ts +4 -0
- package/dist/views/shared/index.js +2 -0
- package/dist/widget/CalendarWidget.svelte +142 -142
- package/package.json +76 -71
|
@@ -1,456 +1,476 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
MobileWeek — touch-first 7-day overview.
|
|
3
|
-
|
|
4
|
-
Compact week grid with day columns. Each day shows a condensed
|
|
5
|
-
list of events. Tap a day to drill into MobileDay. Swipe
|
|
6
|
-
left/right to navigate weeks.
|
|
7
|
-
-->
|
|
8
|
-
<script lang="ts">
|
|
9
|
-
import {
|
|
10
|
-
import { createClock } from '../../core/clock.svelte.js';
|
|
11
|
-
import type { TimelineEvent } from '../../core/types.js';
|
|
12
|
-
import type { ViewState } from '../../engine/view-state.svelte.js';
|
|
13
|
-
import { DAY_MS, sod, isAllDay, isMultiDay } from '../../core/time.js';
|
|
14
|
-
import { startOfWeek as sowFn } from '../../core/time.js';
|
|
15
|
-
import { fmtTime as _fmtTime, weekdayShort, getLabels } from '../../core/locale.js';
|
|
16
|
-
|
|
17
|
-
const L = $derived(getLabels());
|
|
18
|
-
|
|
19
|
-
interface Props {
|
|
20
|
-
mondayStart?: boolean;
|
|
21
|
-
locale?: string;
|
|
22
|
-
height?: number | null;
|
|
23
|
-
events?: TimelineEvent[];
|
|
24
|
-
style?: string;
|
|
25
|
-
focusDate?: Date;
|
|
26
|
-
oneventclick?: (event: TimelineEvent) => void;
|
|
27
|
-
oneventcreate?: (range: { start: Date; end: Date }) => void;
|
|
28
|
-
selectedEventId?: string | null;
|
|
29
|
-
readOnly?: boolean;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let {
|
|
34
|
-
mondayStart = true,
|
|
35
|
-
locale,
|
|
36
|
-
height = null,
|
|
37
|
-
events = [],
|
|
38
|
-
style = '',
|
|
39
|
-
focusDate,
|
|
40
|
-
oneventclick,
|
|
41
|
-
oneventcreate,
|
|
42
|
-
selectedEventId = null,
|
|
43
|
-
readOnly = false,
|
|
44
|
-
}: Props = $props();
|
|
45
|
-
|
|
46
|
-
// ── Context ────────────────────────────────────────
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
// ──
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
swipeOffset =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
viewState.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
class
|
|
210
|
-
class:mw-row--
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
class
|
|
233
|
-
class:mw-ev--
|
|
234
|
-
class:mw-ev--
|
|
235
|
-
class:mw-ev--
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
</div>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
.mw-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
.mw-row:
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
.mw-row
|
|
312
|
-
background: color-mix(in srgb, var(--dt-accent, #2563eb)
|
|
313
|
-
}
|
|
314
|
-
.mw-row--
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
.mw-row--
|
|
318
|
-
opacity: 0.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
flex-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
color: var(--dt-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
flex
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
.mw-ev
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
.mw-ev--
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
.mw-ev--
|
|
398
|
-
background: color-mix(in srgb, var(--ev-color)
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
.mw-ev
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
.mw-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
1
|
+
<!--
|
|
2
|
+
MobileWeek — touch-first 7-day overview.
|
|
3
|
+
|
|
4
|
+
Compact week grid with day columns. Each day shows a condensed
|
|
5
|
+
list of events. Tap a day to drill into MobileDay. Swipe
|
|
6
|
+
left/right to navigate weeks.
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { useCalendarContext } from '../shared/context.svelte.js';
|
|
10
|
+
import { createClock } from '../../core/clock.svelte.js';
|
|
11
|
+
import type { TimelineEvent } from '../../core/types.js';
|
|
12
|
+
import type { ViewState } from '../../engine/view-state.svelte.js';
|
|
13
|
+
import { DAY_MS, sod, isAllDay, isMultiDay } from '../../core/time.js';
|
|
14
|
+
import { startOfWeek as sowFn } from '../../core/time.js';
|
|
15
|
+
import { fmtTime as _fmtTime, weekdayShort, getLabels } from '../../core/locale.js';
|
|
16
|
+
|
|
17
|
+
const L = $derived(getLabels());
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
mondayStart?: boolean;
|
|
21
|
+
locale?: string;
|
|
22
|
+
height?: number | null;
|
|
23
|
+
events?: TimelineEvent[];
|
|
24
|
+
style?: string;
|
|
25
|
+
focusDate?: Date;
|
|
26
|
+
oneventclick?: (event: TimelineEvent) => void;
|
|
27
|
+
oneventcreate?: (range: { start: Date; end: Date }) => void;
|
|
28
|
+
selectedEventId?: string | null;
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
mondayStart = true,
|
|
35
|
+
locale,
|
|
36
|
+
height = null,
|
|
37
|
+
events = [],
|
|
38
|
+
style = '',
|
|
39
|
+
focusDate,
|
|
40
|
+
oneventclick,
|
|
41
|
+
oneventcreate,
|
|
42
|
+
selectedEventId = null,
|
|
43
|
+
readOnly = false,
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
// ── Context ────────────────────────────────────────
|
|
47
|
+
const ctx = useCalendarContext();
|
|
48
|
+
const viewState = $derived(ctx.viewState);
|
|
49
|
+
const equalDays = $derived(ctx.equalDays);
|
|
50
|
+
const showDates = $derived(ctx.showDates);
|
|
51
|
+
const hideDays = $derived(ctx.hideDays);
|
|
52
|
+
const autoHeight = $derived(ctx.autoHeight);
|
|
53
|
+
const oneventhover = $derived(ctx.oneventhover);
|
|
54
|
+
const disabledSet = $derived(ctx.disabledSet);
|
|
55
|
+
const loadRangeCtx = $derived(ctx.loadRange);
|
|
56
|
+
const minDuration = $derived(ctx.minDuration);
|
|
57
|
+
|
|
58
|
+
const clock = createClock();
|
|
59
|
+
|
|
60
|
+
// ── Config ─────────────────────────────────────────
|
|
61
|
+
const MAX_EVENTS = 3;
|
|
62
|
+
const customDays = $derived(viewState?.dayCount ?? 7);
|
|
63
|
+
|
|
64
|
+
// ── Derived week data ──────────────────────────────
|
|
65
|
+
const todayMs = $derived(clock.today);
|
|
66
|
+
const focusMs = $derived(focusDate ? sod(focusDate.getTime()) : todayMs);
|
|
67
|
+
|
|
68
|
+
const weekStart = $derived(
|
|
69
|
+
customDays === 7
|
|
70
|
+
? sowFn(focusMs, mondayStart)
|
|
71
|
+
: sod(focusMs)
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// ── Load range ─────────────────────────────────────
|
|
75
|
+
$effect(() => {
|
|
76
|
+
if (!loadRangeCtx) return;
|
|
77
|
+
const rangeStart = new Date(weekStart - 7 * DAY_MS);
|
|
78
|
+
const rangeEnd = new Date(weekStart + (customDays + 7) * DAY_MS);
|
|
79
|
+
loadRangeCtx.set({ start: rangeStart, end: rangeEnd });
|
|
80
|
+
return () => loadRangeCtx.set(null);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// ── Day cells ──────────────────────────────────────
|
|
84
|
+
interface DayCell {
|
|
85
|
+
ms: number;
|
|
86
|
+
dayNum: number;
|
|
87
|
+
dayName: string;
|
|
88
|
+
isToday: boolean;
|
|
89
|
+
isPast: boolean;
|
|
90
|
+
isDisabled: boolean;
|
|
91
|
+
isWeekend: boolean;
|
|
92
|
+
events: TimelineEvent[];
|
|
93
|
+
allDayCount: number;
|
|
94
|
+
totalCount: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const dayCells = $derived.by(() => {
|
|
98
|
+
const result: DayCell[] = [];
|
|
99
|
+
const hideSet = new Set(hideDays ?? []);
|
|
100
|
+
|
|
101
|
+
for (let i = 0; i < customDays; i++) {
|
|
102
|
+
const ms = weekStart + i * DAY_MS;
|
|
103
|
+
const d = new Date(ms);
|
|
104
|
+
const jsDay = d.getDay();
|
|
105
|
+
const isoDay = jsDay === 0 ? 7 : jsDay;
|
|
106
|
+
|
|
107
|
+
if (hideSet.has(isoDay)) continue;
|
|
108
|
+
|
|
109
|
+
const isToday = ms === todayMs;
|
|
110
|
+
const isPast = equalDays ? false : ms < todayMs;
|
|
111
|
+
const isWeekend = jsDay === 0 || jsDay === 6;
|
|
112
|
+
const isDisabled = disabledSet.has(ms);
|
|
113
|
+
const dayEnd = ms + DAY_MS;
|
|
114
|
+
|
|
115
|
+
const dayEvents = events
|
|
116
|
+
.filter(ev => ev.start.getTime() < dayEnd && ev.end.getTime() > ms)
|
|
117
|
+
.sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
118
|
+
|
|
119
|
+
const allDayCount = dayEvents.filter(ev => isAllDay(ev) || isMultiDay(ev)).length;
|
|
120
|
+
|
|
121
|
+
result.push({
|
|
122
|
+
ms,
|
|
123
|
+
dayNum: d.getDate(),
|
|
124
|
+
dayName: weekdayShort(ms, locale),
|
|
125
|
+
isToday,
|
|
126
|
+
isPast,
|
|
127
|
+
isDisabled,
|
|
128
|
+
isWeekend,
|
|
129
|
+
events: dayEvents,
|
|
130
|
+
allDayCount,
|
|
131
|
+
totalCount: dayEvents.length,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// ── Format helpers ─────────────────────────────────
|
|
138
|
+
function fmtTime(d: Date): string {
|
|
139
|
+
return _fmtTime(d, locale);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ── Touch swipe ────────────────────────────────────
|
|
143
|
+
let touchStartX = 0;
|
|
144
|
+
let touchStartY = 0;
|
|
145
|
+
let swiping = false;
|
|
146
|
+
let swipeOffset = $state(0);
|
|
147
|
+
const SWIPE_THRESHOLD = 60;
|
|
148
|
+
|
|
149
|
+
function onTouchStart(e: TouchEvent) {
|
|
150
|
+
const t = e.touches[0];
|
|
151
|
+
touchStartX = t.clientX;
|
|
152
|
+
touchStartY = t.clientY;
|
|
153
|
+
swiping = true;
|
|
154
|
+
swipeOffset = 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function onTouchMove(e: TouchEvent) {
|
|
158
|
+
if (!swiping) return;
|
|
159
|
+
const t = e.touches[0];
|
|
160
|
+
const dx = t.clientX - touchStartX;
|
|
161
|
+
const dy = t.clientY - touchStartY;
|
|
162
|
+
if (Math.abs(dy) > Math.abs(dx) * 0.8) { swiping = false; return; }
|
|
163
|
+
swipeOffset = dx;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function onTouchEnd() {
|
|
167
|
+
if (!swiping) { swipeOffset = 0; return; }
|
|
168
|
+
if (Math.abs(swipeOffset) > SWIPE_THRESHOLD) {
|
|
169
|
+
if (swipeOffset > 0) {
|
|
170
|
+
viewState?.prev();
|
|
171
|
+
} else {
|
|
172
|
+
viewState?.next();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
swipeOffset = 0;
|
|
176
|
+
swiping = false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ── Day tap → switch to day mode ───────────────────
|
|
180
|
+
function handleDayTap(dayMs: number) {
|
|
181
|
+
if (viewState) {
|
|
182
|
+
viewState.setFocusDate(new Date(dayMs));
|
|
183
|
+
// Switch to day-mobile view if available
|
|
184
|
+
const currentView = viewState.view;
|
|
185
|
+
const dayView = currentView.replace('week', 'day');
|
|
186
|
+
viewState.setView(dayView);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<div
|
|
192
|
+
class="mw"
|
|
193
|
+
class:mw--auto={autoHeight}
|
|
194
|
+
style={style || undefined}
|
|
195
|
+
style:height={autoHeight ? undefined : (height ? `${height}px` : '100%')}
|
|
196
|
+
role="region"
|
|
197
|
+
aria-label={L.weekAhead}
|
|
198
|
+
ontouchstart={onTouchStart}
|
|
199
|
+
ontouchmove={onTouchMove}
|
|
200
|
+
ontouchend={onTouchEnd}
|
|
201
|
+
>
|
|
202
|
+
<!-- Vertical day list -->
|
|
203
|
+
<div class="mw-list" role="list">
|
|
204
|
+
{#each dayCells as cell (cell.ms)}
|
|
205
|
+
<button
|
|
206
|
+
class="mw-row"
|
|
207
|
+
class:mw-row--today={cell.isToday}
|
|
208
|
+
class:mw-row--past={cell.isPast}
|
|
209
|
+
class:mw-row--weekend={cell.isWeekend}
|
|
210
|
+
class:mw-row--disabled={cell.isDisabled}
|
|
211
|
+
onclick={() => handleDayTap(cell.ms)}
|
|
212
|
+
aria-label="{cell.dayName} {cell.dayNum}"
|
|
213
|
+
>
|
|
214
|
+
<!-- Date column -->
|
|
215
|
+
<div class="mw-date">
|
|
216
|
+
<span class="mw-day-name" class:mw-day-name--today={cell.isToday}>{cell.dayName}</span>
|
|
217
|
+
{#if showDates}
|
|
218
|
+
<span class="mw-day-num" class:mw-day-num--today={cell.isToday}>{cell.dayNum}</span>
|
|
219
|
+
{/if}
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<!-- Events column -->
|
|
223
|
+
<div class="mw-events">
|
|
224
|
+
{#if cell.events.length === 0}
|
|
225
|
+
<span class="mw-empty">{L.noEvents}</span>
|
|
226
|
+
{:else}
|
|
227
|
+
{#each cell.events.slice(0, MAX_EVENTS) as ev (ev.id)}
|
|
228
|
+
<div
|
|
229
|
+
class="mw-ev"
|
|
230
|
+
class:mw-ev--selected={selectedEventId === ev.id}
|
|
231
|
+
class:mw-ev--allday={isAllDay(ev) || isMultiDay(ev)}
|
|
232
|
+
class:mw-ev--current={!isAllDay(ev) && !isMultiDay(ev) && ev.start.getTime() <= clock.tick && ev.end.getTime() > clock.tick}
|
|
233
|
+
class:mw-ev--cancelled={ev.status === 'cancelled'}
|
|
234
|
+
class:mw-ev--tentative={ev.status === 'tentative'}
|
|
235
|
+
class:mw-ev--full={ev.status === 'full'}
|
|
236
|
+
class:mw-ev--limited={ev.status === 'limited'}
|
|
237
|
+
style:--ev-color={ev.color ?? 'var(--dt-accent)'}
|
|
238
|
+
role="button"
|
|
239
|
+
tabindex="0"
|
|
240
|
+
onclick={(e) => { e.stopPropagation(); oneventclick?.(ev); }}
|
|
241
|
+
onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); e.stopPropagation(); oneventclick?.(ev); } }}
|
|
242
|
+
onpointerenter={() => oneventhover?.(ev)}
|
|
243
|
+
>
|
|
244
|
+
<span class="mw-ev-stripe"></span>
|
|
245
|
+
<div class="mw-ev-body">
|
|
246
|
+
<span class="mw-ev-title">{ev.title}</span>
|
|
247
|
+
{#if isAllDay(ev) || isMultiDay(ev)}
|
|
248
|
+
<span class="mw-ev-time">{L.allDay}</span>
|
|
249
|
+
{:else}
|
|
250
|
+
<span class="mw-ev-time">{fmtTime(ev.start)}</span>
|
|
251
|
+
{/if}
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
{/each}
|
|
255
|
+
{#if cell.totalCount > MAX_EVENTS}
|
|
256
|
+
<span class="mw-ev-more">{L.nMore(cell.totalCount - MAX_EVENTS)}</span>
|
|
257
|
+
{/if}
|
|
258
|
+
{/if}
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
<!-- Chevron -->
|
|
262
|
+
<svg class="mw-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="14" height="14" aria-hidden="true"><path d="M6 3l5 5-5 5"/></svg>
|
|
263
|
+
</button>
|
|
264
|
+
{/each}
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<style>
|
|
269
|
+
/* ─── Container ──────────────────────────────────── */
|
|
270
|
+
.mw {
|
|
271
|
+
position: relative;
|
|
272
|
+
display: flex;
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
user-select: none;
|
|
275
|
+
font-variant-numeric: tabular-nums;
|
|
276
|
+
overflow: hidden;
|
|
277
|
+
background: var(--dt-bg, #fff);
|
|
278
|
+
-webkit-tap-highlight-color: transparent;
|
|
279
|
+
}
|
|
280
|
+
.mw--auto { overflow: visible; }
|
|
281
|
+
|
|
282
|
+
/* ─── Scrollable day list ────────────────────────── */
|
|
283
|
+
.mw-list {
|
|
284
|
+
flex: 1;
|
|
285
|
+
overflow-y: auto;
|
|
286
|
+
-webkit-overflow-scrolling: touch;
|
|
287
|
+
scrollbar-width: thin;
|
|
288
|
+
scrollbar-color: var(--dt-scrollbar, rgba(0, 0, 0, 0.08)) transparent;
|
|
289
|
+
}
|
|
290
|
+
.mw--auto .mw-list { overflow-y: visible; }
|
|
291
|
+
|
|
292
|
+
/* ─── Day row ────────────────────────────────────── */
|
|
293
|
+
.mw-row {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: 12px;
|
|
297
|
+
padding: 10px 12px;
|
|
298
|
+
border: none;
|
|
299
|
+
background: transparent;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
transition: background 120ms;
|
|
302
|
+
text-align: left;
|
|
303
|
+
width: 100%;
|
|
304
|
+
-webkit-tap-highlight-color: transparent;
|
|
305
|
+
border-bottom: 1px solid var(--dt-border, rgba(0, 0, 0, 0.06));
|
|
306
|
+
min-height: 56px;
|
|
307
|
+
}
|
|
308
|
+
.mw-row:last-child {
|
|
309
|
+
border-bottom: none;
|
|
310
|
+
}
|
|
311
|
+
.mw-row:active {
|
|
312
|
+
background: color-mix(in srgb, var(--dt-accent, #2563eb) 6%, transparent);
|
|
313
|
+
}
|
|
314
|
+
.mw-row--today {
|
|
315
|
+
background: color-mix(in srgb, var(--dt-accent, #2563eb) 4%, transparent);
|
|
316
|
+
}
|
|
317
|
+
.mw-row--past {
|
|
318
|
+
opacity: 0.5;
|
|
319
|
+
}
|
|
320
|
+
.mw-row--disabled {
|
|
321
|
+
opacity: 0.3;
|
|
322
|
+
pointer-events: none;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* ─── Date column ────────────────────────────────── */
|
|
326
|
+
.mw-date {
|
|
327
|
+
display: flex;
|
|
328
|
+
flex-direction: column;
|
|
329
|
+
align-items: center;
|
|
330
|
+
width: 40px;
|
|
331
|
+
flex-shrink: 0;
|
|
332
|
+
gap: 2px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.mw-day-name {
|
|
336
|
+
font: 600 10px/1 var(--dt-sans, system-ui, sans-serif);
|
|
337
|
+
letter-spacing: 0.06em;
|
|
338
|
+
text-transform: uppercase;
|
|
339
|
+
color: var(--dt-text-3, rgba(0, 0, 0, 0.38));
|
|
340
|
+
}
|
|
341
|
+
.mw-day-name--today {
|
|
342
|
+
color: var(--dt-accent, #2563eb);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.mw-day-num {
|
|
346
|
+
font: 700 18px/1 var(--dt-sans, system-ui, sans-serif);
|
|
347
|
+
color: var(--dt-text, rgba(0, 0, 0, 0.87));
|
|
348
|
+
}
|
|
349
|
+
.mw-day-num--today {
|
|
350
|
+
background: var(--dt-accent, #2563eb);
|
|
351
|
+
color: var(--dt-btn-text, #fff);
|
|
352
|
+
width: 30px;
|
|
353
|
+
height: 30px;
|
|
354
|
+
display: inline-flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
justify-content: center;
|
|
357
|
+
border-radius: 50%;
|
|
358
|
+
font-size: 15px;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* ─── Events column ──────────────────────────────── */
|
|
362
|
+
.mw-events {
|
|
363
|
+
flex: 1;
|
|
364
|
+
min-width: 0;
|
|
365
|
+
display: flex;
|
|
366
|
+
flex-direction: column;
|
|
367
|
+
gap: 4px;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.mw-empty {
|
|
371
|
+
font: 400 12px/1 var(--dt-sans, system-ui, sans-serif);
|
|
372
|
+
color: var(--dt-text-3, rgba(0, 0, 0, 0.25));
|
|
373
|
+
font-style: italic;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* ─── Event chip ─────────────────────────────────── */
|
|
377
|
+
.mw-ev {
|
|
378
|
+
display: flex;
|
|
379
|
+
align-items: center;
|
|
380
|
+
gap: 0;
|
|
381
|
+
border-radius: 6px;
|
|
382
|
+
background: color-mix(in srgb, var(--ev-color) 10%, var(--dt-surface, #f9fafb));
|
|
383
|
+
overflow: hidden;
|
|
384
|
+
cursor: pointer;
|
|
385
|
+
transition: background 120ms;
|
|
386
|
+
-webkit-tap-highlight-color: transparent;
|
|
387
|
+
border: none;
|
|
388
|
+
text-align: left;
|
|
389
|
+
padding: 0;
|
|
390
|
+
}
|
|
391
|
+
.mw-ev:active {
|
|
392
|
+
background: color-mix(in srgb, var(--ev-color) 20%, var(--dt-surface, #f9fafb));
|
|
393
|
+
}
|
|
394
|
+
.mw-ev--selected {
|
|
395
|
+
box-shadow: 0 0 0 1.5px var(--ev-color);
|
|
396
|
+
}
|
|
397
|
+
.mw-ev--current {
|
|
398
|
+
background: color-mix(in srgb, var(--ev-color) 16%, var(--dt-surface, #f9fafb));
|
|
399
|
+
}
|
|
400
|
+
.mw-ev--allday {
|
|
401
|
+
background: color-mix(in srgb, var(--ev-color) 14%, var(--dt-surface, #f9fafb));
|
|
402
|
+
}
|
|
403
|
+
.mw-ev--cancelled {
|
|
404
|
+
opacity: 0.5;
|
|
405
|
+
}
|
|
406
|
+
.mw-ev--cancelled .mw-ev-title {
|
|
407
|
+
text-decoration: line-through;
|
|
408
|
+
}
|
|
409
|
+
.mw-ev--tentative {
|
|
410
|
+
opacity: 0.65;
|
|
411
|
+
border: 1px dashed color-mix(in srgb, var(--ev-color) 35%, transparent);
|
|
412
|
+
}
|
|
413
|
+
.mw-ev--full {
|
|
414
|
+
opacity: 0.55;
|
|
415
|
+
}
|
|
416
|
+
.mw-ev--limited {
|
|
417
|
+
opacity: 0.65;
|
|
418
|
+
border: 1px dashed color-mix(in srgb, var(--ev-color) 35%, transparent);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.mw-ev-stripe {
|
|
422
|
+
width: 3px;
|
|
423
|
+
align-self: stretch;
|
|
424
|
+
background: var(--ev-color, var(--dt-accent));
|
|
425
|
+
flex-shrink: 0;
|
|
426
|
+
border-radius: 6px 0 0 6px;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.mw-ev-body {
|
|
430
|
+
flex: 1;
|
|
431
|
+
min-width: 0;
|
|
432
|
+
padding: 5px 8px;
|
|
433
|
+
display: flex;
|
|
434
|
+
align-items: baseline;
|
|
435
|
+
gap: 6px;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.mw-ev-title {
|
|
439
|
+
font: 500 12px/1.2 var(--dt-sans, system-ui, sans-serif);
|
|
440
|
+
color: var(--dt-text, rgba(0, 0, 0, 0.87));
|
|
441
|
+
white-space: nowrap;
|
|
442
|
+
overflow: hidden;
|
|
443
|
+
text-overflow: ellipsis;
|
|
444
|
+
flex: 1;
|
|
445
|
+
min-width: 0;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.mw-ev-time {
|
|
449
|
+
font: 400 11px/1 var(--dt-mono, ui-monospace, monospace);
|
|
450
|
+
color: var(--dt-text-3, rgba(0, 0, 0, 0.38));
|
|
451
|
+
white-space: nowrap;
|
|
452
|
+
flex-shrink: 0;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.mw-ev-more {
|
|
456
|
+
font: 400 11px/1 var(--dt-sans, system-ui, sans-serif);
|
|
457
|
+
color: var(--dt-text-3, rgba(0, 0, 0, 0.38));
|
|
458
|
+
padding: 2px 0;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/* ─── Chevron ────────────────────────────────────── */
|
|
462
|
+
.mw-chevron {
|
|
463
|
+
flex-shrink: 0;
|
|
464
|
+
color: var(--dt-text-3, rgba(0, 0, 0, 0.2));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* ─── Focus ──────────────────────────────────────── */
|
|
468
|
+
.mw-row:focus-visible {
|
|
469
|
+
outline: 2px solid var(--dt-accent, #2563eb);
|
|
470
|
+
outline-offset: -2px;
|
|
471
|
+
}
|
|
472
|
+
.mw-ev:focus-visible {
|
|
473
|
+
outline: 2px solid var(--ev-color, var(--dt-accent));
|
|
474
|
+
outline-offset: 1px;
|
|
475
|
+
}
|
|
476
|
+
</style>
|