@rokoyfa/calendar 1.2.0 → 1.3.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 (144) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/DEVELOPER_GUIDE.md +1045 -0
  3. package/README.md +41 -190
  4. package/api/openapi.yaml +395 -4
  5. package/demo/calendar.config.jsonc +183 -0
  6. package/demo/calendar.config.yaml +180 -0
  7. package/dist-lib/cdn/browser-BSbYkIQu.js +130 -0
  8. package/dist-lib/cdn/browser-BSbYkIQu.js.map +1 -0
  9. package/dist-lib/cdn/calendar-widget.js +14 -11
  10. package/dist-lib/cdn/calendar-widget.js.map +1 -1
  11. package/dist-lib/cdn/de-Dqga3QZG.js +2 -0
  12. package/dist-lib/cdn/de-Dqga3QZG.js.map +1 -0
  13. package/dist-lib/cdn/es-BWSfTMjh.js +2 -0
  14. package/dist-lib/cdn/es-BWSfTMjh.js.map +1 -0
  15. package/dist-lib/cdn/fr-N9gwLjVq.js +2 -0
  16. package/dist-lib/cdn/fr-N9gwLjVq.js.map +1 -0
  17. package/dist-lib/cdn/it-B5Ib2xLn.js +2 -0
  18. package/dist-lib/cdn/it-B5Ib2xLn.js.map +1 -0
  19. package/dist-lib/cdn/nl-CjI7Uc8l.js +2 -0
  20. package/dist-lib/cdn/nl-CjI7Uc8l.js.map +1 -0
  21. package/dist-lib/cdn/pl-FRu3yQhc.js +2 -0
  22. package/dist-lib/cdn/pl-FRu3yQhc.js.map +1 -0
  23. package/dist-lib/cdn/pt-DBKJ-3Is.js +2 -0
  24. package/dist-lib/cdn/pt-DBKJ-3Is.js.map +1 -0
  25. package/dist-lib/npm/{de-Cuz-uz3s.js → de-DhWrY8Ae.js} +111 -3
  26. package/dist-lib/npm/de-DhWrY8Ae.js.map +1 -0
  27. package/dist-lib/npm/{es-BnRzdU90.js → es-Bj8leuD5.js} +111 -3
  28. package/dist-lib/npm/es-Bj8leuD5.js.map +1 -0
  29. package/dist-lib/npm/{fr-B-nmvStg.js → fr-DzAFZ0jh.js} +111 -3
  30. package/dist-lib/npm/fr-DzAFZ0jh.js.map +1 -0
  31. package/dist-lib/npm/index.js +3876 -1400
  32. package/dist-lib/npm/index.js.map +1 -1
  33. package/dist-lib/npm/{it-DMTpE4GO.js → it-lEmGP5yo.js} +111 -3
  34. package/dist-lib/npm/it-lEmGP5yo.js.map +1 -0
  35. package/dist-lib/npm/{nl-DQkyEt9Z.js → nl-d1h63dvm.js} +111 -3
  36. package/dist-lib/npm/nl-d1h63dvm.js.map +1 -0
  37. package/dist-lib/npm/{pl-CcjU41yx.js → pl-DynFKadb.js} +111 -3
  38. package/dist-lib/npm/pl-DynFKadb.js.map +1 -0
  39. package/dist-lib/npm/{pt-Dulais2f.js → pt-foL7jDsE.js} +111 -3
  40. package/dist-lib/npm/pt-foL7jDsE.js.map +1 -0
  41. package/dist-lib/npm/types/components/Icons.d.ts +2 -0
  42. package/dist-lib/npm/types/config/routes.d.ts +1 -0
  43. package/dist-lib/npm/types/context/HostBridge.d.ts +38 -0
  44. package/dist-lib/npm/types/context/HostContext.d.ts +39 -2
  45. package/dist-lib/npm/types/data/restDataSource.d.ts +3 -1
  46. package/dist-lib/npm/types/data/tenantDataSource.d.ts +3 -1
  47. package/dist-lib/npm/types/data/types.d.ts +4 -1
  48. package/dist-lib/npm/types/features/attachments/components/AttachmentsField.d.ts +8 -0
  49. package/dist-lib/npm/types/features/attachments/hooks/useAttachments.d.ts +11 -0
  50. package/dist-lib/npm/types/features/attachments/index.d.ts +2 -0
  51. package/dist-lib/npm/types/features/authorization/components/account/DataExportSection.d.ts +1 -0
  52. package/dist-lib/npm/types/features/authorization/hooks/useAuth.d.ts +1 -0
  53. package/dist-lib/npm/types/features/authorization/index.d.ts +1 -0
  54. package/dist-lib/npm/types/features/authorization/repositories/HostTokenAuthRepository.d.ts +1 -0
  55. package/dist-lib/npm/types/features/authorization/repositories/RemoteAuthRepository.d.ts +1 -0
  56. package/dist-lib/npm/types/features/authorization/types/auth.d.ts +2 -0
  57. package/dist-lib/npm/types/features/calendar/components/Calendar.d.ts +7 -1
  58. package/dist-lib/npm/types/features/calendar/components/CalendarHeader.d.ts +3 -1
  59. package/dist-lib/npm/types/features/calendar/constants/views.d.ts +2 -2
  60. package/dist-lib/npm/types/features/calendar/hooks/useEventNavigation.d.ts +4 -0
  61. package/dist-lib/npm/types/features/calendar/hooks/useHostController.d.ts +2 -0
  62. package/dist-lib/npm/types/features/calendar/hooks/useLiveEvents.d.ts +11 -0
  63. package/dist-lib/npm/types/features/calendar/hooks/useSegmentAttributes.d.ts +2 -0
  64. package/dist-lib/npm/types/features/calendar/utils/eventLabels.d.ts +4 -0
  65. package/dist-lib/npm/types/features/calendars/components/settings/ShareSection.d.ts +4 -0
  66. package/dist-lib/npm/types/features/calendars/components/settings/TrashSection.d.ts +4 -0
  67. package/dist-lib/npm/types/features/calendars/index.d.ts +1 -1
  68. package/dist-lib/npm/types/features/calendars/repositories/RemoteCalendarRepository.d.ts +3 -0
  69. package/dist-lib/npm/types/features/calendars/types/calendar.d.ts +3 -0
  70. package/dist-lib/npm/types/features/calendars/utils/permissions.d.ts +4 -0
  71. package/dist-lib/npm/types/features/categories/components/CategoriesSection.d.ts +6 -0
  72. package/dist-lib/npm/types/features/categories/components/CategoryField.d.ts +9 -0
  73. package/dist-lib/npm/types/features/categories/components/CategoryFilterModal.d.ts +10 -0
  74. package/dist-lib/npm/types/features/categories/hooks/useCategories.d.ts +9 -0
  75. package/dist-lib/npm/types/features/categories/index.d.ts +4 -0
  76. package/dist-lib/npm/types/features/events/components/DeleteEventModal.d.ts +2 -1
  77. package/dist-lib/npm/types/features/events/components/EventModal.d.ts +11 -3
  78. package/dist-lib/npm/types/features/events/hooks/useEvents.d.ts +4 -1
  79. package/dist-lib/npm/types/features/events/index.d.ts +2 -2
  80. package/dist-lib/npm/types/features/events/utils/icalExchange.d.ts +4 -1
  81. package/dist-lib/npm/types/features/storage/index.d.ts +6 -1
  82. package/dist-lib/npm/types/features/storage/repositories/LocalCategoryRepository.d.ts +14 -0
  83. package/dist-lib/npm/types/features/storage/repositories/LocalEventRepository.d.ts +8 -2
  84. package/dist-lib/npm/types/features/storage/repositories/RemoteAttachmentRepository.d.ts +11 -0
  85. package/dist-lib/npm/types/features/storage/repositories/RemoteCategoryRepository.d.ts +10 -0
  86. package/dist-lib/npm/types/features/storage/repositories/RemoteChatRepository.d.ts +2 -1
  87. package/dist-lib/npm/types/features/storage/repositories/RemoteEventRepository.d.ts +9 -3
  88. package/dist-lib/npm/types/features/storage/repositories/RemoteSharedCalendarRepository.d.ts +9 -0
  89. package/dist-lib/npm/types/features/storage/types/storage.d.ts +30 -2
  90. package/dist-lib/npm/types/features/storage/utils/liveSocket.d.ts +10 -0
  91. package/dist-lib/npm/types/i18n/messages/en/calendar.d.ts +9 -0
  92. package/dist-lib/npm/types/i18n/messages/en/calendars.d.ts +44 -0
  93. package/dist-lib/npm/types/i18n/messages/en/core.d.ts +1 -0
  94. package/dist-lib/npm/types/i18n/messages/en/events.d.ts +37 -0
  95. package/dist-lib/npm/types/i18n/messages/en/index.d.ts +99 -1
  96. package/dist-lib/npm/types/i18n/messages/en/settings.d.ts +7 -0
  97. package/dist-lib/npm/types/i18n/messages/index.d.ts +99 -1
  98. package/dist-lib/npm/types/lib/CalendarWidget.d.ts +1 -1
  99. package/dist-lib/npm/types/lib/IsolatedRoot.d.ts +3 -1
  100. package/dist-lib/npm/types/lib/appearance.d.ts +3 -0
  101. package/dist-lib/npm/types/lib/config.d.ts +16 -27
  102. package/dist-lib/npm/types/lib/configFile.d.ts +6 -0
  103. package/dist-lib/npm/types/lib/defaults.d.ts +29 -1
  104. package/dist-lib/npm/types/lib/element.d.ts +15 -1
  105. package/dist-lib/npm/types/lib/handle.d.ts +15 -0
  106. package/dist-lib/npm/types/lib/index.d.ts +6 -2
  107. package/dist-lib/npm/types/lib/options.d.ts +47 -0
  108. package/dist-lib/npm/types/lib/useCalendarOptions.d.ts +11 -0
  109. package/dist-lib/npm/types/pages/SharedCalendarPage.d.ts +1 -0
  110. package/dist-lib/npm/types/utils/api.d.ts +1 -0
  111. package/dist-lib/npm/types/utils/appError.d.ts +1 -1
  112. package/dist-lib/npm/types/utils/attachment.d.ts +31 -0
  113. package/dist-lib/npm/types/utils/calendarView.d.ts +1 -0
  114. package/dist-lib/npm/types/utils/category.d.ts +18 -0
  115. package/dist-lib/npm/types/utils/conflict.d.ts +1 -0
  116. package/dist-lib/npm/types/utils/dataExport.d.ts +13 -0
  117. package/dist-lib/npm/types/utils/event.d.ts +6 -1
  118. package/dist-lib/npm/types/utils/eventChange.d.ts +13 -0
  119. package/dist-lib/npm/types/utils/ical.d.ts +6 -1
  120. package/dist-lib/npm/types/utils/sharedCalendar.d.ts +13 -0
  121. package/dist-lib/npm/types/utils/trash.d.ts +14 -0
  122. package/package.json +8 -2
  123. package/schema/calendar-config.schema.json +297 -0
  124. package/dist-lib/cdn/de-BjzK4Pgn.js +0 -2
  125. package/dist-lib/cdn/de-BjzK4Pgn.js.map +0 -1
  126. package/dist-lib/cdn/es-TA5DvEsw.js +0 -2
  127. package/dist-lib/cdn/es-TA5DvEsw.js.map +0 -1
  128. package/dist-lib/cdn/fr-Dx-nmhQ7.js +0 -2
  129. package/dist-lib/cdn/fr-Dx-nmhQ7.js.map +0 -1
  130. package/dist-lib/cdn/it-D_2eA3dT.js +0 -2
  131. package/dist-lib/cdn/it-D_2eA3dT.js.map +0 -1
  132. package/dist-lib/cdn/nl-dC1zae2Z.js +0 -2
  133. package/dist-lib/cdn/nl-dC1zae2Z.js.map +0 -1
  134. package/dist-lib/cdn/pl-9TYRPoy1.js +0 -2
  135. package/dist-lib/cdn/pl-9TYRPoy1.js.map +0 -1
  136. package/dist-lib/cdn/pt-CvBN-qx1.js +0 -2
  137. package/dist-lib/cdn/pt-CvBN-qx1.js.map +0 -1
  138. package/dist-lib/npm/de-Cuz-uz3s.js.map +0 -1
  139. package/dist-lib/npm/es-BnRzdU90.js.map +0 -1
  140. package/dist-lib/npm/fr-B-nmvStg.js.map +0 -1
  141. package/dist-lib/npm/it-DMTpE4GO.js.map +0 -1
  142. package/dist-lib/npm/nl-DQkyEt9Z.js.map +0 -1
  143. package/dist-lib/npm/pl-CcjU41yx.js.map +0 -1
  144. package/dist-lib/npm/pt-Dulais2f.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,19 @@
1
1
  # @rokoyfa/calendar
2
2
 
3
- An embeddable calendar for React apps and any other website. Day, week, month and year views, recurring events, team calendars with roles and invitations. English, German, French, Spanish, Italian, Dutch, Polish and Portuguese built in, more through your own texts. Runs without a backend (data stays in the browser) or against your own REST backend. Styles are isolated in a Shadow DOM, so the host page and the calendar never affect each other.
3
+ An embeddable calendar for React apps and any other website. It runs without a backend, with data kept in the browser, or against your own REST backend.
4
4
 
5
- ## Setup
5
+ - Day, week, month and year views with drag and drop
6
+ - Recurring and all-day events, time zones, reminders, locations and links
7
+ - Team calendars with roles, invitations, attendees and a chat per event
8
+ - Public holidays for over 200 countries, search, undo, keyboard shortcuts
9
+ - iCalendar import, export and subscription links for other calendar apps
10
+ - English, German, French, Spanish, Italian, Dutch, Polish and Portuguese built in, more through your own texts
11
+ - Styles isolated in a Shadow DOM, so your page and the calendar never affect each other
12
+ - Categories with a filter, a read-only mode and public read-only links
13
+ - Your page can steer it (`goToDate()`, `setView()`, `openEvent()`) and match it to your design with CSS variables
14
+ - Every optional feature can be switched off
15
+
16
+ ## Quick start
6
17
 
7
18
  **Any website**, React is bundled:
8
19
 
@@ -12,7 +23,7 @@ An embeddable calendar for React apps and any other website. Day, week, month an
12
23
  <calendar-widget style="height: 700px"></calendar-widget>
13
24
  ```
14
25
 
15
- **React 19**:
26
+ **React 19:**
16
27
 
17
28
  ```bash
18
29
  npm install @rokoyfa/calendar
@@ -26,216 +37,56 @@ import { Calendar } from '@rokoyfa/calendar'
26
37
 
27
38
  Give the calendar a height, it fills its box. No CSS import is needed.
28
39
 
29
- ## Examples
40
+ ## Configuring
41
+
42
+ Options are attributes on the web component and props on the React component:
30
43
 
31
44
  ```html
32
- <!-- German, dark, month view -->
33
45
  <calendar-widget locale="de-DE" theme="dark" initial-view="month" style="height: 600px"></calendar-widget>
34
46
 
35
- <!-- Your backend with sign-in -->
36
- <calendar-widget storage-mode="remote" auth api-base-url="https://api.example.com" style="height: 700px"></calendar-widget>
47
+ <calendar-widget storage-mode="remote" feature-auth feature-chat="false" api-base-url="https://api.example.com"></calendar-widget>
37
48
  ```
38
49
 
39
50
  ```tsx
40
51
  <Calendar
41
52
  storageMode="remote"
42
53
  apiBaseUrl="https://api.example.com"
43
- features={{ auth: true, teams: false }}
54
+ features={{ auth: true, chat: false }}
55
+ views={['week', 'month']}
44
56
  onEventCreate={(event) => console.log('created', event)}
45
57
  />
46
58
  ```
47
59
 
48
- ```js
49
- document.querySelector('calendar-widget').addEventListener('event-create', (e) => console.log(e.detail))
50
- ```
60
+ Or keep them in a JSON or YAML file:
51
61
 
52
- | Prop | Attribute | Default | |
53
- | --- | --- | --- | --- |
54
- | `locale` | `locale` | browser | `en-US`, `de-DE`, `fr-FR`, `pt-BR`, … Formats follow the region |
55
- | `messages` | property | – | Own texts per language, see below |
56
- | `theme` | `theme` | system | `light`, `dark` |
57
- | `initialView` | `initial-view` | user setting | `day`, `week`, `month`, `year` |
58
- | `timeZone` | `time-zone` | browser | IANA zone the calendar is shown in, e.g. `Europe/Berlin`. New events start in it. A zone the user picks in the settings takes precedence |
59
- | `holidays` | `holidays` | from `locale` | Public holidays to show: country or region code such as `DE`, `DE-NW`, `AT`, `US-CA`, or `off`. Users can override it in the settings |
60
- | `mapUrl` | `map-url` | Google Maps | Map service for locations, with `{query}` for the place, e.g. `https://www.openstreetmap.org/search?query={query}` or `https://maps.apple.com/?q={query}` |
61
- | `holidaySource` | `holiday-source` | `library` | `library` computes holidays in the browser, `backend` asks your backend (`GET /holidays`) and falls back to the library |
62
- | `storageMode` | `storage-mode` | `local` | `local` or `remote` |
63
- | `apiBaseUrl` | `api-base-url` | `/api` | Base URL of your backend |
64
- | `features` | `auth`, `teams` | auth off, teams on | `teams="false"` turns team features off |
65
- | `tenant`, `getUserToken` | `tenant`, property | – | Multi-tenant backend, sign-in through your own page |
66
- | `dataSource` | property | – | Custom data adapter instead of REST |
67
- | `onEventCreate` / `Update` / `Delete` | `event-create` / `-update` / `-delete` | – | After every stored change |
68
-
69
- **Own texts and languages.** Override single texts or add a language. Missing texts fall back to the built-in language, or to English for a new one. The full list of keys is the `Messages` type.
70
-
71
- ```js
72
- document.querySelector('calendar-widget').messages = {
73
- de: { calendar: { newEvent: 'Neuer Eintrag' } },
74
- sv: { calendar: { today: 'Idag', newEvent: 'Ny händelse' }, views: { weekNumber: (week) => `V. ${week}` } },
75
- }
62
+ ```html
63
+ <calendar-widget config="/calendar.config.yaml" style="height: 700px"></calendar-widget>
76
64
  ```
77
65
 
78
- The CDN build loads languages other than English on demand from files next to `calendar-widget.js`. When hosting it yourself, copy the whole `dist-lib/cdn` folder.
79
-
80
- **Demo:** [`demo/cdn.html`](demo/cdn.html) shows local mode with an event log, a dark German month view and a compact widget. Download it and open it in a browser, it loads the published package from jsDelivr.
81
-
82
- ## Calendar subscriptions
83
-
84
- With a backend that serves `/calendars/:id/feed` and `/feeds/:token.ics`, every signed-in user can subscribe to a calendar in another calendar app and see its events there, for example on the phone. Users get the link in the calendar settings: **Import & export** tab for team calendars, on the settings page for the personal calendar → **Subscribe** → **Create subscription link**. They can copy the link or open it in their calendar app.
85
-
86
- - The subscription is **read-only**. Changes made in the other app do not come back.
87
- - The link is **personal and secret**: it contains the user's own reminders, and anyone who has it can see all events of the calendar. **Create new link** turns the old one off, **End subscription** removes it.
88
- - It stops working when the user leaves the calendar.
89
-
90
- ### Adding the link in calendar apps
91
-
92
- | App | Steps |
93
- | --- | --- |
94
- | **Apple Calendar on Mac** | **Open in calendar app** in the settings, or *File → New Calendar Subscription…*, paste the link, **Subscribe**. Set *Auto-refresh* and choose *iCloud* as location so the calendar also appears on iPhone and iPad. |
95
- | **Apple Calendar on iPhone / iPad** | **Open in calendar app** in the settings, or *Settings → Apps → Calendar → Calendar Accounts → Add Account → Other → Add Subscribed Calendar* (older iOS: *Settings → Calendar → Accounts*), paste the link as server, **Next**, **Save**. |
96
- | **Google Calendar** | Only in the browser at calendar.google.com: next to *Other calendars* click **+** → **From URL**, paste the link, **Add calendar**. It then also shows in the Google Calendar apps on Android and iPhone. |
97
- | **Outlook.com / Outlook on the web / new Outlook** | *Calendar → Add calendar → Subscribe from web*, paste the link, give it a name, **Import**. |
98
- | **Classic Outlook for Windows** | *Home → Add Calendar → From Internet…* (in some versions *Open Calendar → From Internet*), paste the link, **OK**, confirm with **Yes**. |
99
- | **Thunderbird** | *New Calendar → On the Network*, paste the link, choose the iCalendar (ICS) format. |
100
-
101
- Menu names change between app versions. If a path does not match, look for “subscribe”, “from URL” or “from internet”.
102
-
103
- ### How quickly changes show up
104
-
105
- A subscription is not live: the app downloads the whole calendar again at intervals that the app decides. Changes made in this calendar therefore appear with a delay:
106
-
107
- | App | Refresh |
108
- | --- | --- |
109
- | Apple Calendar on Mac | Adjustable per subscription, from every 5 minutes to weekly (right-click the calendar → *Get Info* → *Auto-refresh*). *View → Refresh Calendars* (⌘R) refreshes right away. |
110
- | Apple Calendar on iPhone / iPad | Follows *Fetch New Data* (*Settings → Apps → Calendar → Calendar Accounts → Fetch New Data*). Choose *Every 15 Minutes* or *Hourly*. Subscriptions have no push. A subscription added on the Mac with location *iCloud* is refreshed by iCloud. |
111
- | Google Calendar | Google's own schedule, usually several hours, sometimes up to a day. Cannot be changed. |
112
- | Outlook.com / web / new Outlook | Microsoft's own schedule, roughly every 3 hours, sometimes more than 24 hours. Cannot be changed. |
113
- | Classic Outlook for Windows | Follows the update limit in the feed (one hour here) and Outlook's send/receive settings. |
114
-
115
- The feed asks clients to reload every hour (`REFRESH-INTERVAL` and `X-PUBLISHED-TTL`), but most apps follow their own settings. For changes that must show up immediately, users should open this calendar directly. Two-way sync with near-instant updates would need a CalDAV server, which this component does not cover.
116
-
117
- ## Event chat
118
-
119
- Events in team calendars have a **Chat** tab: every member can read and write, edit and delete their own messages, and owners, admins and managers (`manage_calendars`) can delete any message. Recurring events have one chat per occurrence. A detached occurrence keeps the chat of its original date. The calendar shows unread messages as a red badge on the event and in the tab title, and attendees can get an email about new messages (`emailChat`, on by default, at most one email per chat every few minutes).
120
-
121
- Messages go over REST (see the OpenAPI file, tag *Chat*). New, edited and deleted messages arrive live over a WebSocket:
122
-
123
- - **Address:** `{apiBaseUrl}/chat/socket` with `ws://` or `wss://`, derived from `apiBaseUrl` (relative addresses use the page's host). With `tenant` the tenant is added as `?tenant=…`, because browsers cannot set headers on WebSockets. Custom data sources can pass `chatSocketUrl` to `restDataSource`.
124
- - **Sign-in:** the session cookie is sent with the handshake. Check the `Origin` header against the allowed origins and answer `401` without a session.
125
- - **Server → client** (JSON text frames): `{ "type": "message.created" | "message.updated", "message": ChatMessage }` and `{ "type": "message.deleted", "id", "calendarId", "eventId", "occurrenceDate" }`, sent to every connected member of the calendar's team.
126
- - **Client → server:** only `{ "type": "ping" }` every 25 seconds, answer with `{ "type": "pong" }` or ignore it.
127
- - The component reconnects with growing pauses (1 to 30 seconds) and reloads the open chat and the unread counts after reconnecting, so a lost connection only delays messages.
128
-
129
- Emails link to the host page with `?calendar=…&event=…&date=…&tab=chat`, which opens the event with the chat.
130
-
131
- ## Building your own backend
132
-
133
- The full contract is [`api/openapi.yaml`](api/openapi.yaml) (OpenAPI 3.1, also shipped as `@rokoyfa/calendar/openapi.yaml`). The essentials:
134
-
135
- ### Data types
136
-
137
- ```ts
138
- type CalendarEvent = EventInput & {
139
- id: string
140
- calendarId: string
141
- createdAt: string // ISO date-time
142
- updatedAt: string
143
- }
144
-
145
- type EventInput = {
146
- uid: string // stable id for iCalendar, shared by a series and its detached events
147
- title: string // 1–100 chars
148
- location: string // max 200 chars, '' if none
149
- links: EventLink[] // up to 10 http(s) links
150
- startDate: string // 'YYYY-MM-DD'
151
- start: string // 'HH:mm' in timeZone
152
- endDate: string // inclusive for all-day events
153
- end: string
154
- allDay: boolean // start and end are '00:00'
155
- timeZone: string | null // IANA zone, null = same local time everywhere (always null for all-day)
156
- description: string // max 2000 chars
157
- color: 'blue' | 'red' | 'green' | 'yellow' | `#${string}`
158
- recurrence: Recurrence | null
159
- excludedDates: string[] // occurrences removed from a series
160
- seriesId: string | null // set on an occurrence detached from a series
161
- originalDate: string | null // its original date in that series
162
- reminders: number[] // minutes before the start, per user (see below)
163
- attendees: Attendee[]
164
- }
165
-
166
- type Attendee = { email: string; name: string; status: 'needsAction' | 'accepted' | 'tentative' | 'declined' }
167
-
168
- type EventLink = { url: string; label: string } // url max 2000 chars, label max 100 chars, '' if none
169
-
170
- type Recurrence = {
171
- frequency: 'daily' | 'weekly' | 'monthly' | 'yearly'
172
- interval: number // 1–99
173
- weekdays: number[] // 0 = Monday … 6 = Sunday
174
- monthlyMode: 'dayOfMonth' | 'weekdayOfMonth' | 'lastWeekdayOfMonth'
175
- until: string | null // either until or count, or neither
176
- count: number | null
177
- }
178
-
179
- type CalendarSummary = {
180
- id: string; teamId: string; name: string; color: string
181
- kind: 'personal' | 'team'; teamName: string | null; description: string
182
- role: 'owner' | 'admin' | 'manager' | 'editor' | 'member' | 'contributor' | 'viewer'
183
- showInPersonal: boolean; permissions: string[]
184
- }
185
-
186
- type User = { id: string; email: string; name: string; emailVerified: boolean }
187
- type Preferences = {
188
- theme: 'system' | 'light' | 'dark'; defaultView: View; mobileDefaultView: View; locale: string
189
- timeZone: string // 'auto' or IANA zone
190
- holidays: string // 'auto', 'off' or a region such as 'DE-NW'
191
- }
192
- type PublicHoliday = { date: string; name: string } // GET /holidays, only with holiday-source="backend"
193
- // Preferences also carry emailInvites, emailChanges, emailReminders, emailChat: booleans for the emails below
194
- type Problem = { code: string; message: string } // every error response
66
+ ```yaml
67
+ storageMode: remote
68
+ apiBaseUrl: https://api.example.com
69
+ locale: de-DE
70
+ views: [week, month]
71
+ features:
72
+ auth: true
73
+ chat: false
195
74
  ```
196
75
 
197
- The backend stores series as one event. The component expands occurrences itself.
198
-
199
- **Reminders are personal.** Store them per user and event, return only the caller's own `reminders`, and keep other members' reminders when someone saves the event. The component shows reminders while it is open (browser notification or a notice in the calendar). Emails or push messages when it is closed are up to your backend.
76
+ Commented example files with every option: [`demo/calendar.config.yaml`](demo/calendar.config.yaml) and [`demo/calendar.config.jsonc`](demo/calendar.config.jsonc).
200
77
 
201
- ### When the component calls your backend
78
+ ## Documentation
202
79
 
203
- | Moment | Requests |
80
+ | | |
204
81
  | --- | --- |
205
- | Widget loads | `GET /auth/me` (only with `auth`), then `GET /preferences`, `GET /colors`, `GET /calendars`, `GET /invitations` |
206
- | Visible range changes | `GET /events?from=…&to=…&calendarId=…` with the calendars shown. The range is two days wider than the view to cover time zone shifts. Return every event in the range **and** every series that can occur in it. |
207
- | Create event | `POST /events` with `EventInput` + `calendarId` |
208
- | Edit event / whole series | `PUT /events/:id` with the full `EventInput` |
209
- | Edit only this occurrence | `PUT` the series with the date added to `excludedDates`, then `POST` a detached event with `seriesId` and `originalDate` |
210
- | Edit this and following | `PUT` the series with `until` set to the day before (and `count: null`), `POST` a new series, `PUT` later detached events to relink them |
211
- | Delete | single: `PUT` with `excludedDates` · following: `PUT` with `until`, `DELETE` its later detached events · all: `DELETE` detached events, then the series · plain: `DELETE /events/:id` |
212
- | Search | `GET /events/search?q=…&calendarId=…` (optional: without it the component searches the last and next year via `GET /events`) |
213
- | Answer as attendee | `POST /events/:id/response` with `{ status }` |
214
- | Change only own reminders | `PUT /events/:id/reminders` with `{ reminders }` (also for members without edit rights) |
215
- | Answer from an email link | `POST /events/respond` with `{ token, status }`, no session needed |
216
- | Event chat | `GET`/`POST /events/:id/chat?date=…`, `POST /events/:id/chat/read`, `PATCH`/`DELETE /chat/messages/:id`, `GET /chat/unread?calendarId=…`, WebSocket `/chat/socket` |
217
- | Subscription link | `GET`, `POST` (new link), `DELETE /calendars/:id/feed`. The link points at your `GET /feeds/:token.ics` |
218
- | Reminders | `GET /events` for the next four weeks of all calendars, every five minutes while the widget is open |
219
- | Import .ics | `GET /events` for the whole calendar, then `PUT` for known `uid`s and `POST` for new ones |
220
- | Settings, colors | `PATCH /preferences`, `POST /colors`, `DELETE /colors/:rrggbb` |
221
- | Holidays (only with `holiday-source="backend"`) | `GET /holidays?from=…&to=…&region=DE-NW&lang=de`, answer `PublicHoliday[]` |
222
- | Sign-in, teams, invitations | `/auth/*`, `/calendars`, `/teams/*`, `/invitations/*`, see the OpenAPI file |
223
-
224
- Before editing "following" or "all" of a series, the component loads its detached events with `GET /events?seriesId=…`.
225
-
226
- ### Rules for the backend
227
-
228
- - **Sessions:** requests use `credentials: 'include'`. Set an `HttpOnly` cookie on sign-in. If the widget runs on another domain: CORS for that origin with `Access-Control-Allow-Credentials: true`, allowed headers `Content-Type`, `Accept`, `Accept-Language`, `Authorization`, `X-Calendar-Tenant`, and the cookie as `SameSite=None; Secure`. Answer `401` when the session is gone.
229
- - **Errors:** always `{ code, message }`. Known codes such as `invalidCredentials`, `emailTaken`, `forbidden`, `lastOwner` are shown translated, others with `message`.
230
- - **Language:** every request carries `Accept-Language`. Use it, or the stored `locale`, for emails.
231
- - **Emails about events** (your backend sends them, the component only stores the user's choice): an invitation with yes / maybe / no links to `/respond?status=accepted&token=…` when someone is added as attendee (`emailInvites`), a notice when title, time, place or repetition change or the event is cancelled (`emailChanges`), and reminders at the user's own reminder times even while the calendar is closed (`emailReminders`, off by default). Only to verified addresses, never to the person who made the change.
232
- - **Subscriptions:** `GET /feeds/:token.ics` answers without a session with the calendar as iCalendar (RFC 5545) and the subscriber's own reminders. Keep one secret token per user and calendar, a new one replaces the old. Stop serving it when the user leaves the calendar.
233
- - **Email links:** point them at the host page with the screen as parameter, e.g. `https://host.example/calendar?calendarPath=%2Freset-password%3Ftoken%3D…`.
234
-
235
- Building, the test backend and all internals are described in German in [DEVELOPMENT.md](DEVELOPMENT.md).
82
+ | [Developer Guide](DEVELOPER_GUIDE.md) | Embedding, all options and features, the configuration file, languages, sign-in, data adapters, exported types, and what your backend has to provide |
83
+ | [`api/openapi.yaml`](api/openapi.yaml) | The REST contract for your own backend (OpenAPI 3.1), also shipped as `@rokoyfa/calendar/openapi.yaml` |
84
+ | [`schema/calendar-config.schema.json`](schema/calendar-config.schema.json) | JSON Schema for configuration files, also shipped as `@rokoyfa/calendar/config.schema.json` |
85
+ | [CHANGELOG.md](CHANGELOG.md) | Changes per version |
86
+ | [DEVELOPMENT.md](DEVELOPMENT.md) | Working on the calendar itself: building, the test backend and internals (in German) |
87
+
88
+ **Demo:** [`demo/cdn.html`](demo/cdn.html) shows local mode with an event log, a dark German month view and a compact widget. Download it and open it in a browser, it loads the published package from jsDelivr.
236
89
 
237
90
  ## License
238
91
 
239
92
  [MIT](LICENSE) © Rokoyfa
240
-
241
- Public holiday data comes from [date-holidays](https://github.com/commenthol/date-holidays) (code ISC, data [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)). It is loaded only when holidays are shown.