@nomideusz/svelte-calendar 0.10.0 → 0.12.0
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 +2 -16
- package/dist/calendar/Calendar.svelte +43 -5
- package/dist/calendar/Calendar.svelte.d.ts +8 -0
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -2
- package/dist/engine/view-state.svelte.d.ts +5 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/theme/auto.js +56 -21
- package/dist/theme/presets.d.ts +6 -5
- package/dist/theme/presets.js +2 -3
- package/dist/views/agenda/AgendaDay.svelte +69 -32
- package/dist/views/agenda/AgendaWeek.svelte +220 -83
- package/dist/views/mobile/MobileDay.svelte +11 -3
- package/dist/views/mobile/MobileWeek.svelte +6 -0
- package/dist/views/mobile/swipe.d.ts +1 -0
- package/dist/views/mobile/swipe.js +9 -0
- package/dist/views/month/MonthGrid.svelte +35 -2
- package/dist/views/planner/Planner.svelte +3 -7
- package/dist/views/planner/PlannerWeek.svelte +16 -7
- package/dist/views/planner/PlannerWeek.svelte.d.ts +2 -0
- package/dist/views/shared/context.svelte.d.ts +1 -0
- package/dist/views/shared/context.svelte.js +1 -0
- package/package.json +1 -8
- package/widget/widget.js +1381 -2428
- package/dist/core/measure.d.ts +0 -104
- package/dist/core/measure.js +0 -195
- package/dist/views/planner/PlannerDay.svelte +0 -1279
- package/dist/views/planner/PlannerDay.svelte.d.ts +0 -30
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Planner
|
|
2
|
+
Planner time grid — vertical, Google-Calendar-style. Renders both planner
|
|
3
|
+
modes: week (N columns from viewState.dayCount) and day (a single column),
|
|
4
|
+
so the two share one geometry, one drag mapping, and one overlap engine.
|
|
3
5
|
|
|
4
6
|
• Left time gutter with localized hour labels; N day columns (viewState.dayCount).
|
|
5
7
|
• Sticky day-header row + sticky all-day strip; the grid scrolls vertically.
|
|
@@ -17,8 +19,9 @@ import EventContent from "../shared/EventContent.svelte";
|
|
|
17
19
|
import { createClock } from "../../core/clock.svelte.js";
|
|
18
20
|
import { DAY_MS, HOUR_MS, sod, addDaysMs } from "../../core/time.js";
|
|
19
21
|
import { startOfWeek as sowFn, isAllDay, isMultiDay, segmentForDay } from "../../core/time.js";
|
|
20
|
-
import { fmtH, fmtTime, fmtDuration, weekdayShort } from "../../core/locale.js";
|
|
22
|
+
import { fmtH, fmtTime, fmtDuration, weekdayShort, weekdayLong } from "../../core/locale.js";
|
|
21
23
|
let {
|
|
24
|
+
mode = "week",
|
|
22
25
|
mondayStart = true,
|
|
23
26
|
locale,
|
|
24
27
|
height = 520,
|
|
@@ -59,7 +62,9 @@ const gridHeight = $derived(hourCount * HOUR_H);
|
|
|
59
62
|
let scrollEl;
|
|
60
63
|
let colsEl;
|
|
61
64
|
const todayMs = $derived(clock.today);
|
|
62
|
-
const
|
|
65
|
+
const singleDay = $derived(mode === "day" || viewState?.mode === "day");
|
|
66
|
+
const customDays = $derived(singleDay ? 1 : viewState?.dayCount ?? 7);
|
|
67
|
+
const hideDayHead = $derived(singleDay && showDates && !!viewState && !dayHeaderSnippet);
|
|
63
68
|
const weekStartMs = $derived.by(() => {
|
|
64
69
|
const r = viewState?.range;
|
|
65
70
|
if (r) return sod(r.start.getTime());
|
|
@@ -259,8 +264,8 @@ function statusText(ev) {
|
|
|
259
264
|
}
|
|
260
265
|
function ghostForDay(dayMs) {
|
|
261
266
|
if (!drag?.active || !drag.payload) return null;
|
|
262
|
-
const
|
|
263
|
-
if (
|
|
267
|
+
const mode2 = drag.mode;
|
|
268
|
+
if (mode2 !== "move" && mode2 !== "create") return null;
|
|
264
269
|
const s = drag.payload.start.getTime();
|
|
265
270
|
const e = drag.payload.end.getTime();
|
|
266
271
|
const bandS = dayMs + startHour * HOUR_MS;
|
|
@@ -273,7 +278,7 @@ function ghostForDay(dayMs) {
|
|
|
273
278
|
height: Math.max(12, (ce - cs) / HOUR_MS * HOUR_H),
|
|
274
279
|
start: drag.payload.start,
|
|
275
280
|
end: drag.payload.end,
|
|
276
|
-
create:
|
|
281
|
+
create: mode2 === "create",
|
|
277
282
|
// Only the segment containing the start shows the readout
|
|
278
283
|
showTime: cs === Math.max(s, dayMs)
|
|
279
284
|
};
|
|
@@ -570,7 +575,9 @@ function onWindowKeydown(e) {
|
|
|
570
575
|
<div class="tw-scroll" bind:this={scrollEl}>
|
|
571
576
|
<div class="tw-inner" style:min-width="{innerMinWidth}px">
|
|
572
577
|
<!-- Sticky top: day headers + all-day strip -->
|
|
578
|
+
{#if !hideDayHead || hasAllDayRow}
|
|
573
579
|
<div class="tw-top">
|
|
580
|
+
{#if !hideDayHead}
|
|
574
581
|
<div class="tw-head">
|
|
575
582
|
<div class="tw-corner" style:width="{GUTTER_W}px" aria-hidden="true"></div>
|
|
576
583
|
{#each dayCols as day (day.ms)}
|
|
@@ -579,7 +586,7 @@ function onWindowKeydown(e) {
|
|
|
579
586
|
class:tw-hd--today={day.isToday}
|
|
580
587
|
aria-current={day.isToday ? 'date' : undefined}
|
|
581
588
|
>
|
|
582
|
-
<span class="tw-hd-wd">{weekdayShort(day.ms, locale)}</span>
|
|
589
|
+
<span class="tw-hd-wd">{singleDay ? weekdayLong(day.ms, locale) : weekdayShort(day.ms, locale)}</span>
|
|
583
590
|
{#if showDates}
|
|
584
591
|
<span class="tw-hd-num" class:tw-hd-num--today={day.isToday}>{day.dayNum}</span>
|
|
585
592
|
{/if}
|
|
@@ -591,6 +598,7 @@ function onWindowKeydown(e) {
|
|
|
591
598
|
</div>
|
|
592
599
|
{/each}
|
|
593
600
|
</div>
|
|
601
|
+
{/if}
|
|
594
602
|
|
|
595
603
|
{#if hasAllDayRow}
|
|
596
604
|
<div class="tw-allday">
|
|
@@ -618,6 +626,7 @@ function onWindowKeydown(e) {
|
|
|
618
626
|
</div>
|
|
619
627
|
{/if}
|
|
620
628
|
</div>
|
|
629
|
+
{/if}
|
|
621
630
|
|
|
622
631
|
<!-- Grid body -->
|
|
623
632
|
<div class="tw-body" style:height="{gridHeight}px">
|
|
@@ -14,6 +14,7 @@ export interface CalendarContext {
|
|
|
14
14
|
readonly isMobile: boolean;
|
|
15
15
|
readonly autoHeight: boolean;
|
|
16
16
|
readonly compact: boolean;
|
|
17
|
+
readonly columns: boolean;
|
|
17
18
|
readonly readOnly: boolean;
|
|
18
19
|
readonly blockedSlots: BlockedSlot[] | undefined;
|
|
19
20
|
readonly dayHeaderSnippet: Snippet<[{
|
|
@@ -34,6 +34,7 @@ export function useCalendarContext() {
|
|
|
34
34
|
get isMobile() { return raw?.mobile ?? false; },
|
|
35
35
|
get autoHeight() { return raw?.autoHeight ?? false; },
|
|
36
36
|
get compact() { return raw?.compact ?? false; },
|
|
37
|
+
get columns() { return raw?.columns ?? false; },
|
|
37
38
|
get readOnly() { return raw?.readOnly ?? false; },
|
|
38
39
|
get blockedSlots() { return raw?.blockedSlots; },
|
|
39
40
|
get dayHeaderSnippet() { return raw?.dayHeaderSnippet; },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomideusz/svelte-calendar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "A themeable Svelte 5 calendar with Day and Week views — Planner and Agenda.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,16 +35,9 @@
|
|
|
35
35
|
"test:watch": "vitest"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@chenglou/pretext": "^0.0.5",
|
|
39
38
|
"svelte": "^5.0.0"
|
|
40
39
|
},
|
|
41
|
-
"peerDependenciesMeta": {
|
|
42
|
-
"@chenglou/pretext": {
|
|
43
|
-
"optional": true
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
40
|
"devDependencies": {
|
|
47
|
-
"@chenglou/pretext": "^0.0.5",
|
|
48
41
|
"@sveltejs/adapter-auto": "^7.0.1",
|
|
49
42
|
"@sveltejs/kit": "^2.69.1",
|
|
50
43
|
"@sveltejs/package": "^2.5.8",
|