@nomideusz/svelte-calendar 0.3.0 → 0.4.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.
Files changed (36) hide show
  1. package/README.md +568 -517
  2. package/dist/adapters/memory.d.ts +7 -2
  3. package/dist/adapters/memory.js +9 -6
  4. package/dist/adapters/recurring.d.ts +7 -2
  5. package/dist/adapters/recurring.js +9 -6
  6. package/dist/calendar/Calendar.svelte +21 -1
  7. package/dist/calendar/Calendar.svelte.d.ts +1 -0
  8. package/dist/calendar/Toolbar.svelte +5 -2
  9. package/dist/calendar/Toolbar.svelte.d.ts +2 -0
  10. package/dist/core/index.d.ts +1 -0
  11. package/dist/core/index.js +2 -0
  12. package/dist/core/palette.d.ts +23 -0
  13. package/dist/core/palette.js +109 -0
  14. package/dist/engine/view-state.svelte.d.ts +1 -0
  15. package/dist/engine/view-state.svelte.js +3 -0
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/views/agenda/Agenda.svelte +117 -5
  19. package/dist/views/agenda/Agenda.svelte.d.ts +1 -0
  20. package/dist/views/day/DayGrid.svelte +39 -3
  21. package/dist/views/day/DayGrid.svelte.d.ts +2 -0
  22. package/dist/views/day/DayTimeline.svelte +31 -3
  23. package/dist/views/day/DayTimeline.svelte.d.ts +5 -1
  24. package/dist/views/schedule/WeekSchedule.svelte +4 -0
  25. package/dist/views/schedule/WeekSchedule.svelte.d.ts +2 -0
  26. package/dist/views/settings/Settings.svelte +451 -173
  27. package/dist/views/settings/Settings.svelte.d.ts +22 -6
  28. package/dist/views/week/WeekGrid.svelte +44 -11
  29. package/dist/views/week/WeekGrid.svelte.d.ts +1 -0
  30. package/dist/views/week/WeekHeatmap.svelte +8 -7
  31. package/dist/views/week/WeekHeatmap.svelte.d.ts +1 -0
  32. package/dist/widget/CalendarWidget.svelte +0 -2
  33. package/dist/widget/widget.d.ts +1 -7
  34. package/dist/widget/widget.js +44 -3
  35. package/package.json +65 -67
  36. package/widget/widget.js +260 -260
@@ -35,6 +35,8 @@
35
35
  style?: string;
36
36
  /** The date to centre this view on */
37
37
  focusDate?: Date;
38
+ /** Locale for labels */
39
+ locale?: string;
38
40
  /** Called when the user clicks an event */
39
41
  oneventclick?: (event: TimelineEvent) => void;
40
42
  /** Called when the user clicks an empty time slot */
@@ -58,6 +60,7 @@
58
60
  height = 520,
59
61
  events = [],
60
62
  style = '',
63
+ locale,
61
64
  focusDate,
62
65
  oneventclick,
63
66
  oneventcreate,
@@ -130,7 +133,7 @@
130
133
 
131
134
  layouts.push({
132
135
  ms,
133
- name: fmtDay(ms, clock.today, { short: true }),
136
+ name: fmtDay(ms, clock.today, { short: true }, locale),
134
137
  today: isToday,
135
138
  past: isPast,
136
139
  dayX: x,
@@ -579,7 +582,7 @@
579
582
  {@const hour = NIGHT_END + h}
580
583
  {@const x = h * hourWidth}
581
584
  <div class="fs-tick" style:left="{x}px">
582
- <span class="fs-tick-lb">{fmtH(hour)}</span>
585
+ <span class="fs-tick-lb">{fmtH(hour, locale)}</span>
583
586
  </div>
584
587
  <div class="fs-tick fs-tick--half" style:left="{x + hourWidth * 0.5}px"></div>
585
588
  {/each}
@@ -605,7 +608,7 @@
605
608
  {@const hour = (NIGHT_START + h) % 24}
606
609
  {@const x = h * hourWidth}
607
610
  <div class="fs-tick fs-tick--night" style:left="{x}px">
608
- <span class="fs-tick-lb">{fmtH(hour)}</span>
611
+ <span class="fs-tick-lb">{fmtH(hour, locale)}</span>
609
612
  </div>
610
613
  {/each}
611
614
  <button class="fs-night-toggle" onclick={(e) => { e.stopPropagation(); toggleNight(i); }}>
@@ -656,6 +659,16 @@
656
659
  </span>
657
660
  {/if}
658
661
  <span class="fs-ev-title">{p.ev.title}</span>
662
+ {#if p.ev.subtitle && p.heightPx > 48}
663
+ <span class="fs-ev-sub">{p.ev.subtitle}</span>
664
+ {/if}
665
+ {#if p.ev.tags?.length && p.heightPx > 72}
666
+ <span class="fs-ev-tags">
667
+ {#each p.ev.tags as tag}
668
+ <span class="fs-ev-tag">{tag}</span>
669
+ {/each}
670
+ </span>
671
+ {/if}
659
672
  </div>
660
673
  </div>
661
674
  {/each}
@@ -1055,6 +1068,29 @@
1055
1068
  white-space: nowrap;
1056
1069
  }
1057
1070
 
1071
+ .fs-ev-sub {
1072
+ font: 400 11px / 1 var(--dt-sans);
1073
+ color: var(--dt-text-2);
1074
+ opacity: 0.6;
1075
+ white-space: nowrap;
1076
+ overflow: hidden;
1077
+ text-overflow: ellipsis;
1078
+ }
1079
+
1080
+ .fs-ev-tags {
1081
+ display: flex;
1082
+ gap: 4px;
1083
+ }
1084
+
1085
+ .fs-ev-tag {
1086
+ font: 500 8px / 1 var(--dt-sans);
1087
+ color: var(--ev-color, var(--dt-accent));
1088
+ background: color-mix(in srgb, var(--ev-color, var(--dt-accent)) 18%, transparent);
1089
+ padding: 1px 4px;
1090
+ border-radius: 3px;
1091
+ white-space: nowrap;
1092
+ }
1093
+
1058
1094
  /* ─── Focus-visible (accessibility) ──────────── */
1059
1095
  .fs-event:focus-visible,
1060
1096
  .fs-night:focus-visible {
@@ -16,6 +16,8 @@ interface Props {
16
16
  style?: string;
17
17
  /** The date to centre this view on */
18
18
  focusDate?: Date;
19
+ /** Locale for labels */
20
+ locale?: string;
19
21
  /** Called when the user clicks an event */
20
22
  oneventclick?: (event: TimelineEvent) => void;
21
23
  /** Called when the user clicks an empty time slot */
@@ -14,10 +14,11 @@
14
14
  nowPosition = 0.25,
15
15
  events = [],
16
16
  style = '',
17
+ locale,
17
18
  focusDate,
18
19
  oneventclick,
19
20
  selectedEventId = null,
20
- }: DayTimelineProps = $props();
21
+ }: DayTimelineProps & { locale?: string; [key: string]: unknown } = $props();
21
22
 
22
23
  // ── Drag support (available when inside Calendar) ──
23
24
  const drag = getContext<DragState>('calendar:drag') as DragState | undefined;
@@ -48,7 +49,7 @@
48
49
  out.push({
49
50
  ms,
50
51
  x: i * dayW,
51
- name: fmtDay(ms, clock.today),
52
+ name: fmtDay(ms, clock.today, undefined, locale),
52
53
  today: ms === clock.today
53
54
  });
54
55
  }
@@ -242,7 +243,7 @@
242
243
  {#each HOURS as h}
243
244
  {@const x = d.x + h * hourWidth}
244
245
  <div class="dt-tick" style:left="{x}px">
245
- <span class="dt-tick-lb">{fmtH(h)}</span>
246
+ <span class="dt-tick-lb">{fmtH(h, locale)}</span>
246
247
  </div>
247
248
  <div class="dt-tick dt-tick--h" style:left="{x + hourWidth * 0.5}px"></div>
248
249
  {/each}
@@ -269,6 +270,14 @@
269
270
  onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); oneventclick?.(p.ev); } }}
270
271
  >
271
272
  <span class="dt-ev-title">{p.ev.title}</span>
273
+ {#if p.ev.subtitle}
274
+ <span class="dt-ev-sub">{p.ev.subtitle}</span>
275
+ {/if}
276
+ {#if p.ev.tags?.length}
277
+ {#each p.ev.tags as tag}
278
+ <span class="dt-ev-tag">{tag}</span>
279
+ {/each}
280
+ {/if}
272
281
  </div>
273
282
  {/each}
274
283
  </div>
@@ -476,6 +485,7 @@
476
485
  padding: 0 8px;
477
486
  display: flex;
478
487
  align-items: center;
488
+ gap: 4px;
479
489
  cursor: pointer;
480
490
  background: color-mix(in srgb, var(--ev-color) 22%, transparent);
481
491
  border-left: 3px solid var(--ev-color);
@@ -502,4 +512,22 @@
502
512
  overflow: hidden;
503
513
  text-overflow: ellipsis;
504
514
  }
515
+
516
+ .dt-ev-sub {
517
+ font: 400 9px / 1 var(--dt-sans, 'Outfit', system-ui, sans-serif);
518
+ color: var(--dt-text-2, rgba(148, 163, 184, 0.6));
519
+ white-space: nowrap;
520
+ overflow: hidden;
521
+ text-overflow: ellipsis;
522
+ }
523
+
524
+ .dt-ev-tag {
525
+ font: 500 7px / 1 var(--dt-sans, 'Outfit', system-ui, sans-serif);
526
+ color: var(--ev-color, var(--dt-accent));
527
+ background: color-mix(in srgb, var(--ev-color, var(--dt-accent)) 20%, transparent);
528
+ padding: 1px 3px;
529
+ border-radius: 2px;
530
+ white-space: nowrap;
531
+ flex-shrink: 0;
532
+ }
505
533
  </style>
@@ -1,4 +1,8 @@
1
1
  import type { DayTimelineProps } from '../../core/types.js';
2
- declare const DayTimeline: import("svelte").Component<DayTimelineProps, {}, "">;
2
+ type $$ComponentProps = DayTimelineProps & {
3
+ locale?: string;
4
+ [key: string]: unknown;
5
+ };
6
+ declare const DayTimeline: import("svelte").Component<$$ComponentProps, {}, "">;
3
7
  type DayTimeline = ReturnType<typeof DayTimeline>;
4
8
  export default DayTimeline;
@@ -40,6 +40,8 @@
40
40
  theme?: string;
41
41
  /** BCP 47 locale */
42
42
  locale?: string;
43
+ /** Text direction */
44
+ dir?: 'ltr' | 'rtl' | 'auto';
43
45
  /** Total height */
44
46
  height?: number;
45
47
  /** Start week on Monday */
@@ -67,6 +69,7 @@
67
69
  schedule,
68
70
  theme = '',
69
71
  locale,
72
+ dir,
70
73
  height = 560,
71
74
  mondayStart = true,
72
75
  readOnly = true,
@@ -123,6 +126,7 @@
123
126
  defaultView="week-grid"
124
127
  {theme}
125
128
  {locale}
129
+ {dir}
126
130
  {height}
127
131
  {mondayStart}
128
132
  {readOnly}
@@ -9,6 +9,8 @@ interface Props {
9
9
  theme?: string;
10
10
  /** BCP 47 locale */
11
11
  locale?: string;
12
+ /** Text direction */
13
+ dir?: 'ltr' | 'rtl' | 'auto';
12
14
  /** Total height */
13
15
  height?: number;
14
16
  /** Start week on Monday */