@nomideusz/svelte-calendar 0.7.5 → 0.9.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 +33 -5
- package/dist/calendar/Calendar.svelte +379 -497
- package/dist/calendar/Calendar.svelte.d.ts +13 -2
- package/dist/core/clock.svelte.d.ts +1 -1
- package/dist/core/clock.svelte.js +20 -9
- package/dist/core/locale.d.ts +4 -0
- package/dist/core/locale.js +4 -0
- package/dist/core/timezone.d.ts +12 -0
- package/dist/core/timezone.js +31 -0
- package/dist/engine/view-state.svelte.d.ts +2 -2
- package/dist/engine/view-state.svelte.js +20 -0
- package/dist/headless/create-calendar.svelte.js +29 -7
- package/dist/headless/types.d.ts +8 -6
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/primitives/DayHeader.svelte +9 -25
- package/dist/primitives/EmptySlot.svelte +15 -31
- package/dist/primitives/EventBlock.svelte +33 -61
- package/dist/primitives/NowIndicator.svelte +16 -42
- package/dist/primitives/TimeGutter.svelte +9 -23
- package/dist/views/agenda/Agenda.svelte +3 -10
- package/dist/views/agenda/AgendaDay.svelte +195 -167
- package/dist/views/agenda/AgendaWeek.svelte +141 -195
- package/dist/views/mobile/Mobile.svelte +3 -10
- package/dist/views/mobile/MobileDay.svelte +422 -266
- package/dist/views/mobile/MobileWeek.svelte +131 -186
- package/dist/views/month/MonthGrid.svelte +334 -0
- package/dist/views/month/MonthGrid.svelte.d.ts +15 -0
- package/dist/views/planner/Planner.svelte +3 -10
- package/dist/views/planner/PlannerDay.svelte +636 -546
- package/dist/views/planner/PlannerWeek.svelte +299 -412
- package/dist/views/shared/EventContent.svelte +16 -0
- package/dist/views/shared/EventContent.svelte.d.ts +9 -0
- package/dist/views/shared/context.svelte.d.ts +2 -0
- package/dist/views/shared/context.svelte.js +2 -0
- package/dist/widget/CalendarWidget.svelte +79 -116
- package/package.json +3 -2
- package/widget/svelte-calendar.css +321 -10
- package/widget/widget.js +2508 -1056
package/README.md
CHANGED
|
@@ -31,18 +31,25 @@ That's it — 6 views (Day/Week × Planner, Agenda, Mobile), auto-coloring, drag
|
|
|
31
31
|
|
|
32
32
|
## Views
|
|
33
33
|
|
|
34
|
-
Switch between **Planner** (time grid)
|
|
34
|
+
Switch between **Planner** (time grid), **Agenda** (list) and the **Month** grid:
|
|
35
35
|
|
|
36
36
|
```svelte
|
|
37
37
|
<Calendar {adapter} view="week-planner" /> <!-- default -->
|
|
38
38
|
<Calendar {adapter} view="day-planner" />
|
|
39
39
|
<Calendar {adapter} view="week-agenda" />
|
|
40
40
|
<Calendar {adapter} view="day-agenda" />
|
|
41
|
+
<Calendar {adapter} view="month-grid" />
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
Users can also switch via the built-in Day/Week pills.
|
|
44
|
+
Users can also switch via the built-in Day/Week/Month pills.
|
|
44
45
|
|
|
45
|
-
Planner views are designed for direct manipulation:
|
|
46
|
+
Planner views are designed for direct manipulation:
|
|
47
|
+
|
|
48
|
+
- **Move** — drag an event to another day or time; a ghost previews the target before the move commits.
|
|
49
|
+
- **Resize** — drag an event's edge handles (`day-planner`: left/right, `day-mobile`: top/bottom) to change its duration; `minDuration`/`maxDuration` clamp at commit.
|
|
50
|
+
- **Drag-to-create** — press on empty canvas and sweep to draw a new event; a plain click still creates a default-length slot. Both fire `oneventcreate` with the final range, after blocked-slot and disabled-date validation.
|
|
51
|
+
|
|
52
|
+
The month grid lists events as chips per day with a "+N more" overflow; clicking a day fires `ondayclick(date)` — the natural month → day drill-down.
|
|
46
53
|
|
|
47
54
|
Hide the pills when your app controls the view externally:
|
|
48
55
|
|
|
@@ -100,9 +107,15 @@ Agenda views keep their list-based layout on mobile; navigation stays in the cal
|
|
|
100
107
|
oneventcreate={(range) => console.log('New slot', range.start, range.end)}
|
|
101
108
|
oneventmove={(event, start, end) => console.log('Moved', event.title, start, end)}
|
|
102
109
|
onviewchange={(viewId) => console.log('View', viewId)}
|
|
110
|
+
ondayclick={(date) => console.log('Day', date)}
|
|
111
|
+
onerror={(error) => console.error('Calendar', error)}
|
|
103
112
|
/>
|
|
104
113
|
```
|
|
105
114
|
|
|
115
|
+
`onerror` surfaces adapter load failures and rejected drag commits that would
|
|
116
|
+
otherwise only reach the console. Clicking an event also selects it — the
|
|
117
|
+
active event is highlighted across views.
|
|
118
|
+
|
|
106
119
|
Set `readOnly` to disable drag, resize, and click-to-create:
|
|
107
120
|
|
|
108
121
|
```svelte
|
|
@@ -392,7 +405,9 @@ const events = [
|
|
|
392
405
|
|
|
393
406
|
### Custom Event Rendering
|
|
394
407
|
|
|
395
|
-
Use the `event` snippet to
|
|
408
|
+
Use the `event` snippet to replace the event *content* in every view (the
|
|
409
|
+
interactive shell — click, keyboard, drag, selection — stays intact). The
|
|
410
|
+
`empty` snippet replaces the day-agenda empty state:
|
|
396
411
|
|
|
397
412
|
```svelte
|
|
398
413
|
<Calendar {adapter}>
|
|
@@ -691,7 +706,20 @@ Call `resetLabels()` to restore English defaults (`defaultLabels` exports them;
|
|
|
691
706
|
|
|
692
707
|
## Timezone Support
|
|
693
708
|
|
|
694
|
-
|
|
709
|
+
Render the whole calendar in any IANA timezone — events, the now-indicator
|
|
710
|
+
and day boundaries all shift; ranges passed to `oneventcreate`/`oneventmove`
|
|
711
|
+
convert back to real instants:
|
|
712
|
+
|
|
713
|
+
```svelte
|
|
714
|
+
<Calendar {adapter} timezone="Europe/Warsaw" />
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
Under the hood the adapter is wrapped with `wrapAdapterWithTimezone` (also
|
|
718
|
+
exported) so views do plain local-time math on a zoned wall-clock plane.
|
|
719
|
+
Known limit shared by every wall-clock calendar: the repeated hour of a DST
|
|
720
|
+
fall-back is ambiguous, writes inside it resolve to one of the two instants.
|
|
721
|
+
|
|
722
|
+
Convert events manually with the built-in helpers:
|
|
695
723
|
|
|
696
724
|
```ts
|
|
697
725
|
import { toZonedTime, fromZonedTime, nowInZone } from '@nomideusz/svelte-calendar';
|