@open-webapp/calendar 0.11.1 → 0.13.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 CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Multi-account Google Calendar read-only sync (controller) plus React UI (`CalendarPane`, `CalendarSelector`). Storage and encryption are host-supplied adapters.
4
4
 
5
- > **0.8.0 is BREAKING.** See [0.8.0](#080-breaking-pre-10-minor) for independent Unaccepted toggling.
5
+ > **0.13.0 is BREAKING.** Clicking an event title now opens an in-pane event details overlay instead of a popup window. See [0.13.0](#0130-breaking-pre-10-minor).
6
+ >
7
+ > **0.12.0 is BREAKING.** See [0.12.0](#0120-breaking-pre-10-minor) for exclusive Unaccepted filtering and new RSVP defaults.
6
8
  >
7
9
  > **0.10.0 is BREAKING.** See [0.10.0](#0100-breaking-pre-10-minor) for the approved CalendarPane selector-popup geometry correction.
8
10
 
@@ -150,7 +152,7 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
150
152
  | `sources` | `Source[]` | shown accounts; 2+ enables multi-source UI (per-source color and email) |
151
153
  | `controller` | `CalendarController` | |
152
154
  | `theme?` | `'system' \| 'light' \| 'dark'` | defaults to `'system'`, including when `undefined`; applies to every pane state and all internal selectors |
153
- | `selectedRsvpStatuses` | `Set<RsvpStatus>` | host-controlled filter; `DEFAULT_RSVP_STATUSES` = accepted, tentative, needsAction (O pressed) |
155
+ | `selectedRsvpStatuses` | `Set<RsvpStatus>` | host-controlled filter; `DEFAULT_RSVP_STATUSES` = accepted, tentative (O unpressed) |
154
156
  | `onRsvpStatusesChange` | `(next) => void` | |
155
157
  | `renderEventAction?` | `(event) => ReactNode` | per-event slot |
156
158
  | `connected?` | `boolean` | defaults to `sources.length > 0` (back-compat). `false` shows the not-connected block |
@@ -160,13 +162,24 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
160
162
  | `emptyState?` | `ReactNode` | replaces the built-in not-connected block |
161
163
  | `sourceNotice?` | `(source) => ReactNode` | per-source slot, rendered for `needs-scope` sources (e.g. re-consent button); without it the built-in reauth block is shown |
162
164
  | `onClose?` | `() => void` | |
163
- | `popupName?` | `string` | `window.open` name for the event popup (default `notesdiary-cal-event`) |
165
+ | `popupName?` | `string` | `window.open` name for the event popup window (default `notesdiary-cal-event`). The popup now opens only from the overlay's "Open in Google Calendar" link |
166
+
167
+ #### Event details overlay
168
+
169
+ A plain left click on an event title opens a bottom-sheet overlay inside the pane (`role="dialog"`, `aria-modal="true"`). It shows the time, calendar, organizer, Join and RSVP controls, location, a plain-text description, and attendees (the first 10, then "+N more"). It also has an "Open in Google Calendar" link.
170
+
171
+ - Close with Escape, the close (X) button, or a click on the backdrop. Focus is trapped inside the sheet while it is open and returns to the title that opened it when it closes.
172
+ - Modified clicks (ctrl, cmd, shift, alt, or middle click) keep the native new-tab behavior of the title link.
173
+ - Events without an `htmlLink` still open the overlay. The "Open in Google Calendar" link is hidden for them.
174
+ - There is no prop to opt out. Hosts that relied on the title click opening a popup window must use the overlay's link or handle the click themselves.
175
+
176
+ `CalendarEvent` gains optional fields used by the overlay: `location?: string`, `description?: string` (HTML is converted to plain text for display), and `attendees?: CalendarEventAttendee[]`, where `CalendarEventAttendee` is `{ email: string; displayName?: string; responseStatus: RsvpStatus; self?: boolean; organizer?: boolean }`. Missing fields are simply not shown.
164
177
 
165
178
  #### RSVP chips
166
179
 
167
- The chips appear in order: Accepted, Maybe, Declined, Unaccepted (O). All four independently toggle current supplied membership. Defaults remain accepted, tentative, needsAction, so O is pressed by default.
180
+ The chips appear in order: Accepted, Maybe, Declined, Unaccepted (O). Accepted, Maybe and Declined independently toggle current supplied membership. Defaults are accepted and tentative, so O is unpressed by default.
168
181
 
169
- O is pressed iff `needsAction` belongs to the selection, including mixed sets. Unanswered events follow that membership within existing calendar/window filters. Clicking O preserves other statuses; no previous RSVP selection is saved/restored. Removing the last status returns `DEFAULT_RSVP_STATUSES`: O-only -> O returns defaults with O still pressed. Explicit empty host selections remain empty; host rerenders do not normalize membership or emit callbacks.
182
+ O is an exclusive shortcut: clicking it saves the current RSVP selection and selects only `needsAction`. Clicking O again restores that saved selection. O is pressed only when `needsAction` is the sole selected status. Unanswered events follow the active membership within existing calendar/window filters. Explicit empty host selections remain empty; host rerenders do not normalize membership or emit callbacks.
170
183
 
171
184
  The Unaccepted badge is always visible, including at zero. It counts `needsAction` events from the controller's selected-calendar, rolling ±30-day snapshot before RSVP filtering. Visible counts cap at `99+`; the chip's `aria-label` and `title` expose the full count.
172
185
 
@@ -231,10 +244,27 @@ Day ribbon styling: each day's ribbon alternates between two tones by day parity
231
244
 
232
245
  The Unaccepted count badge uses `.calendar-rsvp-chip-badge`, with light and dark styling included in `styles.css`.
233
246
 
247
+ Event details overlay (0.13.0): `.calendar-event-details` is the full-pane backdrop (absolutely positioned inside the pane root, dimmed, bottom-aligned) and `.calendar-event-details-sheet` is the bottom sheet (max 80% of the pane height, scrolls internally). Both use the pane's palette tokens, so they follow the pane's `theme`. Inner hooks: `-grabber`, `-header`, `-dot`, `-title`, `-close`, `-body`, `-when`, `-calendar`, and related `calendar-event-details-*` section classes. The overlay is positioned against the nearest positioned ancestor, so the pane root must stay positioned.
248
+
234
249
  The shared `.calendar-selector-trigger` uses border-box inline-flex, centered alignment, an 8px gap, 36px minimum height, 8px 12px padding, 6px radius, a 1px solid control border, inherited font and pointer cursor. `.calendar-selector-trigger-label` bounds long labels with ellipsis; `.calendar-selector-chevron` stays 12px and does not shrink or add a tab stop. Existing scoped surface/text/control-border tokens style the resting trigger, the hover token supplies its hover background, and the focus token supplies a 2px `:focus-visible` outline with 2px offset. The default 64px footer and 6px upward clearance remain unchanged. Only pane dropdowns use the approved trigger-left, pane-inset and available-height exception; standalone selectors retain their existing right-aligned 220px-to-320px geometry and 240px options cap. Import the shipped stylesheet for both footer and standalone use.
235
250
 
236
251
  Done, Select all and Clear use the approved action-only flat styling via `.calendar-selector-actions > button` in standalone and grouped footer dropdowns: transparent resting background, zero border, no shadow, inherited font, `--calendar-selector-text` color and pointer cursor. Hover uses `--calendar-hover`; pointer focus has no decorative outline, while keyboard `:focus-visible` uses a 2px solid `--calendar-focus` outline with 2px offset. Action padding, row flex layout and 8px gap/top/bottom margins, footer/dropdown geometry, trigger/search/option styling, other native controls and all selection, callback and focus-return contracts are preserved.
237
252
 
253
+ ## 0.13.0 (BREAKING pre-1.0 minor)
254
+
255
+ - Plain left click on an event title opens an in-pane event details overlay (bottom sheet, `role="dialog"`, `aria-modal`) instead of the event popup window. It closes with Escape, the X button or the backdrop, traps focus while open and returns focus to the title on close.
256
+ - The overlay shows time, calendar, organizer, Join and RSVP, location, plain-text description, and attendees (max 10, then "+N more"), with an "Open in Google Calendar" link.
257
+ - The `popupName` popup window now opens only from that link. Modified clicks (ctrl/cmd/shift/alt/middle) keep the native new-tab behavior. Events without `htmlLink` open the overlay too.
258
+ - `CalendarEvent` gains optional `location`, `description` and `attendees` (`CalendarEventAttendee[]`). Existing rows without them still read.
259
+ - New host CSS hooks: `.calendar-event-details` and `.calendar-event-details-sheet`.
260
+ - Breaking for hosts relying on the title click opening a popup. There is no opt-out prop. No storage migration is required.
261
+
262
+ ## 0.12.0 (BREAKING pre-1.0 minor)
263
+
264
+ - Unaccepted (O) is again an exclusive `needsAction` shortcut. It saves the current RSVP selection when enabled and restores it when disabled; it is no longer an independent toggle.
265
+ - `DEFAULT_RSVP_STATUSES` now contains only accepted and tentative, so O is unpressed by default.
266
+ - Hosts that persist RSVP selections, including selections containing `needsAction`, must adapt to the exclusive O and new-default behavior.
267
+
238
268
  ## 0.11.1 (patch)
239
269
 
240
270
  - Pin the storage contract harness's injected controller clock near its literal legacy fixtures so adapter checks remain deterministic as the wall clock advances. Regression coverage runs the contract with wall clocks in 2000 and 2100.
@@ -250,8 +280,8 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
250
280
 
251
281
  ## 0.8.0 (BREAKING pre-1.0 minor)
252
282
 
253
- - Unaccepted independently toggles `needsAction`, replacing the exclusive shortcut and local restoration introduced in 0.3.0. Hosts relying on pending-only callbacks or restoration must adapt to callbacks reflecting current membership.
254
- - Defaults and last-deselection fallback remain accepted/tentative/needsAction; O is pressed for defaults and mixed selections containing needsAction.
283
+ - Unaccepted independently toggled `needsAction` at this release. This behavior changed in 0.12.0.
284
+ - Defaults and last-deselection fallback were accepted/tentative/needsAction at this release.
255
285
  - Ribbon labels center in the measured visible intersection, including empty Today, scrolling, resizing and mounted theme changes.
256
286
 
257
287
  ## 0.7.0 (minor, breaking-visual)
@@ -282,7 +312,7 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
282
312
 
283
313
  ## 0.3.0 (minor, additive)
284
314
 
285
- - Added the Unaccepted exclusive shortcut after Accepted, Maybe, and Declined, with local selection restoration and default fallback. This historical behavior is superseded by the independent toggle in 0.8.0.
315
+ - Added the Unaccepted exclusive shortcut after Accepted, Maybe, and Declined, with local selection restoration and default fallback. The exclusive shortcut behavior returns in 0.12.0.
286
316
  - Adds an always-visible Unaccepted count badge, including zero, computed before RSVP filtering from the controller's selected-calendar ±30-day snapshot. Counts above 99 display `99+`, with the full count in the chip's `aria-label` and `title`.
287
317
  - Adds the `.calendar-rsvp-chip-badge` host styling hook. Public props and default RSVP statuses remain compatible.
288
318
 
@@ -63,7 +63,10 @@ interface RawEvent {
63
63
  start?: CalendarEvent['start'];
64
64
  end?: CalendarEvent['end'];
65
65
  attendees?: {
66
+ email?: string;
67
+ displayName?: string;
66
68
  self?: boolean;
69
+ organizer?: boolean;
67
70
  responseStatus?: string;
68
71
  }[];
69
72
  organizer?: {
@@ -1,5 +1,5 @@
1
1
  const MS_PER_DAY = 24 * 60 * 60 * 1000;
2
- export const DEFAULT_RSVP_STATUSES = ['accepted', 'tentative', 'needsAction'];
2
+ export const DEFAULT_RSVP_STATUSES = ['accepted', 'tentative'];
3
3
  /** Keeps stored calendar selections that still exist, defaulting to the primary calendar. */
4
4
  export function reconcileSelectedCalendarIds(storedIds, calendars) {
5
5
  const availableIds = new Set(calendars.map((calendar) => calendar.id));
@@ -212,6 +212,22 @@ export function extractJoinUrl(raw) {
212
212
  const desc = typeof raw.description === 'string' ? raw.description.match(JOIN_URL_REGEX) : null;
213
213
  return desc ? desc[0] : null;
214
214
  }
215
+ function parseAttendees(raw) {
216
+ if (!Array.isArray(raw))
217
+ return undefined;
218
+ return raw
219
+ .filter((a) => a && typeof a === 'object')
220
+ .map((a) => ({
221
+ email: typeof a.email === 'string' ? a.email : '',
222
+ displayName: typeof a.displayName === 'string' ? a.displayName : undefined,
223
+ responseStatus: a.responseStatus === 'accepted' || a.responseStatus === 'tentative' ||
224
+ a.responseStatus === 'declined' || a.responseStatus === 'needsAction'
225
+ ? a.responseStatus
226
+ : 'needsAction',
227
+ self: typeof a.self === 'boolean' ? a.self : undefined,
228
+ organizer: typeof a.organizer === 'boolean' ? a.organizer : undefined,
229
+ }));
230
+ }
215
231
  /** Parses a raw Google Calendar event. Returns null for cancelled/malformed input; never throws. */
216
232
  export function parseEvent(raw, ctx) {
217
233
  try {
@@ -239,6 +255,9 @@ export function parseEvent(raw, ctx) {
239
255
  self: Boolean(raw.organizer?.self),
240
256
  },
241
257
  htmlLink: raw.htmlLink ?? '',
258
+ location: typeof raw.location === 'string' ? raw.location : undefined,
259
+ description: typeof raw.description === 'string' ? raw.description : undefined,
260
+ attendees: parseAttendees(raw.attendees),
242
261
  };
243
262
  }
244
263
  catch {
@@ -29,6 +29,16 @@ export interface CalendarEvent {
29
29
  self: boolean;
30
30
  };
31
31
  htmlLink: string;
32
+ location?: string;
33
+ description?: string;
34
+ attendees?: CalendarEventAttendee[];
35
+ }
36
+ export interface CalendarEventAttendee {
37
+ email: string;
38
+ displayName?: string;
39
+ responseStatus: RsvpStatus;
40
+ self?: boolean;
41
+ organizer?: boolean;
32
42
  }
33
43
  export interface CalendarInfo {
34
44
  id: string;
@@ -21,4 +21,14 @@ export interface CalendarPaneProps {
21
21
  /** Window name used for the event popup. */
22
22
  popupName?: string;
23
23
  }
24
+ export declare const RSVP_CHIPS: {
25
+ status: RsvpStatus;
26
+ label: string;
27
+ path: string;
28
+ }[];
29
+ export declare function RsvpGlyph({ path, size, strokeWidth }: {
30
+ path: string;
31
+ size?: number;
32
+ strokeWidth?: number;
33
+ }): import("react").JSX.Element;
24
34
  export declare function CalendarPane(props: CalendarPaneProps): import("react").JSX.Element;
@@ -2,7 +2,20 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
3
3
  import { filterByRsvp, groupByDay, getOrganizerLabel, formatDayHeader, formatRibbonLabel, isEventCurrent, findNextUpcomingEvent, getCalendarEventKey, DEFAULT_RSVP_STATUSES, } from '../core/events.js';
4
4
  import { GroupedCalendarSelector } from './CalendarSelector.js';
5
- function toggleRsvpStatus(selection, status) {
5
+ import { EventDetails } from './EventDetails.js';
6
+ function nextRsvpSelection(selection, status, saved) {
7
+ const isUnacceptedOnly = selection.size === 1 && selection.has('needsAction');
8
+ if (status === 'needsAction') {
9
+ if (isUnacceptedOnly) {
10
+ return { next: new Set(saved ?? DEFAULT_RSVP_STATUSES), saved: null };
11
+ }
12
+ if (!selection.has('needsAction')) {
13
+ return { next: new Set(['needsAction']), saved: new Set(selection) };
14
+ }
15
+ }
16
+ else if (isUnacceptedOnly) {
17
+ return { next: new Set([status]), saved: null };
18
+ }
6
19
  const next = new Set(selection);
7
20
  if (next.has(status)) {
8
21
  next.delete(status);
@@ -10,19 +23,10 @@ function toggleRsvpStatus(selection, status) {
10
23
  else {
11
24
  next.add(status);
12
25
  }
13
- return next.size === 0 ? new Set(DEFAULT_RSVP_STATUSES) : next;
14
- }
15
- function useWindowWidth() {
16
- const [width, setWidth] = useState(typeof window !== 'undefined' ? window.innerWidth : 1024);
17
- useEffect(() => {
18
- const handler = () => setWidth(window.innerWidth);
19
- window.addEventListener('resize', handler);
20
- return () => window.removeEventListener('resize', handler);
21
- }, []);
22
- return width;
26
+ return { next: next.size === 0 ? new Set(DEFAULT_RSVP_STATUSES) : next, saved: null };
23
27
  }
24
28
  const SOURCE_COLORS = ['#4285f4', '#ea4335', '#34a853', '#fbbc04', '#a142f4', '#00acc1', '#ff7043', '#8d6e63'];
25
- const RSVP_CHIPS = [
29
+ export const RSVP_CHIPS = [
26
30
  {
27
31
  status: 'accepted',
28
32
  label: 'Accepted',
@@ -44,7 +48,7 @@ const RSVP_CHIPS = [
44
48
  path: 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z',
45
49
  },
46
50
  ];
47
- function RsvpGlyph({ path, size = 16, strokeWidth = 2.2 }) {
51
+ export function RsvpGlyph({ path, size = 16, strokeWidth = 2.2 }) {
48
52
  return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: path, stroke: "currentColor", strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" }) }));
49
53
  }
50
54
  function RsvpStatusIcon({ status }) {
@@ -111,7 +115,6 @@ function usableUrl(url) {
111
115
  return trimmed === '' ? null : trimmed;
112
116
  }
113
117
  export function CalendarPane(props) {
114
- const isDesktop = useWindowWidth() >= 960;
115
118
  const { sources, controller, selectedRsvpStatuses, theme = 'system' } = props;
116
119
  const popupName = props.popupName ?? DEFAULT_POPUP_NAME;
117
120
  const [version, setVersion] = useState(0);
@@ -146,7 +149,56 @@ export function CalendarPane(props) {
146
149
  const popupRef = useRef(null);
147
150
  const anchorSnapshotRef = useRef(null);
148
151
  const didMountRsvpRef = useRef(false);
152
+ const savedRsvpRef = useRef(null);
149
153
  const [now, setNow] = useState(() => new Date());
154
+ const [detail, setDetail] = useState(null);
155
+ const detailKey = detail ? getCalendarEventKey(detail.snapshot) : null;
156
+ function closeDetail(returnFocus) {
157
+ const trigger = detail?.trigger;
158
+ setDetail(null);
159
+ if (returnFocus && trigger)
160
+ trigger.focus();
161
+ }
162
+ // Refresh with the same key updates the snapshot; a vanished key keeps the last snapshot.
163
+ useEffect(() => {
164
+ if (detailKey === null)
165
+ return;
166
+ const fresh = events.find((e) => getCalendarEventKey(e) === detailKey);
167
+ if (fresh)
168
+ setDetail((d) => (d && d.snapshot !== fresh ? { ...d, snapshot: fresh } : d));
169
+ }, [events, detailKey]);
170
+ const selectionSignature = sources
171
+ .map((s) => `${s.id}:${[...controller.getSelectedIds(s.id)].sort().join(',')}`)
172
+ .join('|');
173
+ const rsvpSignature = [...selectedRsvpStatuses].sort().join(',');
174
+ const didMountFilterRef = useRef(false);
175
+ useEffect(() => {
176
+ if (!didMountFilterRef.current) {
177
+ didMountFilterRef.current = true;
178
+ return;
179
+ }
180
+ setDetail(null);
181
+ }, [selectionSignature, rsvpSignature]);
182
+ function renderTitle(event) {
183
+ const titleSpan = _jsx("span", { className: "calendar-event-title", children: event.summary });
184
+ if (usableUrl(event.htmlLink) !== null) {
185
+ return (_jsx("a", { className: "calendar-event-title-link", href: event.htmlLink, target: "_blank", rel: "noopener noreferrer", onClick: (e) => {
186
+ if (e.button === 0 && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey) {
187
+ e.preventDefault();
188
+ openDetail(e, event);
189
+ }
190
+ }, children: titleSpan }));
191
+ }
192
+ return (_jsx("button", { type: "button", className: "calendar-event-title-link", onClick: (e) => openDetail(e, event), children: titleSpan }));
193
+ }
194
+ function openDetail(e, event) {
195
+ setDetail({ snapshot: event, trigger: e.currentTarget });
196
+ }
197
+ useEffect(() => {
198
+ if (selectedRsvpStatuses.size !== 1 || !selectedRsvpStatuses.has('needsAction')) {
199
+ savedRsvpRef.current = null;
200
+ }
201
+ }, [selectedRsvpStatuses]);
150
202
  const unacceptedCount = useMemo(() => events.filter((event) => event.selfResponseStatus === 'needsAction').length, [events]);
151
203
  const filteredEvents = useMemo(() => filterByRsvp(events, selectedRsvpStatuses), [events, selectedRsvpStatuses]);
152
204
  const calendarsByKey = useMemo(() => {
@@ -217,7 +269,9 @@ export function CalendarPane(props) {
217
269
  // eslint-disable-next-line react-hooks/exhaustive-deps
218
270
  }, [selectedRsvpStatuses]);
219
271
  function handleToggle(status) {
220
- props.onRsvpStatusesChange(toggleRsvpStatus(selectedRsvpStatuses, status));
272
+ const selection = nextRsvpSelection(selectedRsvpStatuses, status, savedRsvpRef.current);
273
+ savedRsvpRef.current = selection.saved;
274
+ props.onRsvpStatusesChange(selection.next);
221
275
  }
222
276
  const dayGroups = groupByDay(filteredEvents, todayIso);
223
277
  function scrollToToday(behavior = 'auto') {
@@ -396,9 +450,8 @@ export function CalendarPane(props) {
396
450
  ? event.selfResponseStatus
397
451
  : 'needsAction';
398
452
  if (event.isAllDay) {
399
- return (_jsxs("div", { className: `calendar-event-allday calendar-event-row--rsvp-${rsvpStatus}`, children: [_jsxs("div", { className: "calendar-event-header", children: [_jsx("span", { className: "calendar-event-time", children: "All day" }), _jsx(RsvpStatusIcon, { status: event.selfResponseStatus })] }), _jsxs("span", { className: "calendar-event-title-wrap", children: [_jsx("span", { className: "calendar-event-title", children: event.summary }), props.renderEventAction?.(event)] }), showCalendarLabel && (_jsxs("span", { className: "calendar-event-calendar", children: [_jsx("span", { className: "calendar-event-calendar-dot", style: { backgroundColor: calendar.backgroundColor } }), calendar.summary] })), showOrganizerLabel && (_jsxs("span", { className: "calendar-event-organizer", children: [multi && (_jsx("span", { className: "calendar-event-source-dot", style: { backgroundColor: sourceColor(event.sourceId) } })), organizerText] }))] }, eventKey));
453
+ return (_jsxs("div", { className: `calendar-event-allday calendar-event-row--rsvp-${rsvpStatus}`, children: [_jsxs("div", { className: "calendar-event-header", children: [_jsx("span", { className: "calendar-event-time", children: "All day" }), _jsx(RsvpStatusIcon, { status: event.selfResponseStatus })] }), _jsxs("span", { className: "calendar-event-title-wrap", children: [renderTitle(event), props.renderEventAction?.(event)] }), showCalendarLabel && (_jsxs("span", { className: "calendar-event-calendar", children: [_jsx("span", { className: "calendar-event-calendar-dot", style: { backgroundColor: calendar.backgroundColor } }), calendar.summary] })), showOrganizerLabel && (_jsxs("span", { className: "calendar-event-organizer", children: [multi && (_jsx("span", { className: "calendar-event-source-dot", style: { backgroundColor: sourceColor(event.sourceId) } })), organizerText] }))] }, eventKey));
400
454
  }
401
- const hasLink = usableUrl(event.htmlLink) !== null;
402
455
  return (_jsxs("div", { className: `calendar-event-row${currentEventKeys.has(eventKey) ? ' calendar-event-row--current' : ''}${selectedEventKey === eventKey ? ' calendar-event-row--selected' : ''} calendar-event-row--rsvp-${rsvpStatus}`, ref: (el) => {
403
456
  if (el) {
404
457
  timedEventRefs.current.set(eventKey, el);
@@ -406,17 +459,7 @@ export function CalendarPane(props) {
406
459
  else {
407
460
  timedEventRefs.current.delete(eventKey);
408
461
  }
409
- }, children: [_jsxs("div", { className: "calendar-event-header", children: [_jsx("span", { className: "calendar-event-time", children: formatTimeRange(event) }), _jsxs("div", { className: "calendar-event-actions", children: [event.joinUrl && (_jsx("a", { className: "calendar-event-join", href: event.joinUrl, target: "_blank", rel: "noopener noreferrer", onClick: (e) => e.stopPropagation(), children: "Join" })), _jsx(RsvpStatusIcon, { status: event.selfResponseStatus })] })] }), _jsxs("div", { className: "calendar-event-title-wrap", children: [hasLink ? (_jsx("a", { className: "calendar-event-title-link", href: event.htmlLink, target: "_blank", rel: "noopener noreferrer", onClick: (e) => {
410
- if (isDesktop &&
411
- e.button === 0 &&
412
- !e.ctrlKey &&
413
- !e.metaKey &&
414
- !e.shiftKey &&
415
- !e.altKey) {
416
- e.preventDefault();
417
- openEventPopup(event.htmlLink, popupRef, popupName);
418
- }
419
- }, children: _jsx("span", { className: "calendar-event-title", children: event.summary }) })) : (_jsx("span", { className: "calendar-event-title", children: event.summary })), props.renderEventAction?.(event)] }), showCalendarLabel && (_jsxs("span", { className: "calendar-event-calendar", children: [_jsx("span", { className: "calendar-event-calendar-dot", style: { backgroundColor: calendar.backgroundColor } }), calendar.summary] })), showOrganizerLabel && (_jsxs("span", { className: "calendar-event-organizer", children: [multi && (_jsx("span", { className: "calendar-event-source-dot", style: { backgroundColor: sourceColor(event.sourceId) } })), organizerText] }))] }, eventKey));
462
+ }, children: [_jsxs("div", { className: "calendar-event-header", children: [_jsx("span", { className: "calendar-event-time", children: formatTimeRange(event) }), _jsxs("div", { className: "calendar-event-actions", children: [event.joinUrl && (_jsx("a", { className: "calendar-event-join", href: event.joinUrl, target: "_blank", rel: "noopener noreferrer", onClick: (e) => e.stopPropagation(), children: "Join" })), _jsx(RsvpStatusIcon, { status: event.selfResponseStatus })] })] }), _jsxs("div", { className: "calendar-event-title-wrap", children: [renderTitle(event), props.renderEventAction?.(event)] }), showCalendarLabel && (_jsxs("span", { className: "calendar-event-calendar", children: [_jsx("span", { className: "calendar-event-calendar-dot", style: { backgroundColor: calendar.backgroundColor } }), calendar.summary] })), showOrganizerLabel && (_jsxs("span", { className: "calendar-event-organizer", children: [multi && (_jsx("span", { className: "calendar-event-source-dot", style: { backgroundColor: sourceColor(event.sourceId) } })), organizerText] }))] }, eventKey));
420
463
  }) })] }))] }, group.dateKey))), loading && _jsx("p", { className: "calendar-empty-state-text", children: "Loading calendar\u2026" }), filteredEvents.length === 0 && !loading && !error && needsScopeSources.length === 0 && _jsx("p", { className: "calendar-empty-state-text", children: emptyStateText })] }))] }), showCalendarSelector && (_jsx("footer", { className: "calendar-pane-footer", children: _jsx(GroupedCalendarSelector, { theme: theme, groups: calendarSources.map((s) => ({
421
464
  id: s.id,
422
465
  calendars: controller.getCalendars(s.id),
@@ -425,5 +468,5 @@ export function CalendarPane(props) {
425
468
  void controller.setSelectedIds(s.id, ids);
426
469
  },
427
470
  heading: multi ? s.email : undefined,
428
- })) }) }))] }));
471
+ })) }) })), detail && (_jsx(EventDetails, { event: detail.snapshot, calendar: calendarsByKey.get(`${detail.snapshot.sourceId}\u0000${detail.snapshot.calendarId}`), sourceLabel: multi ? sourceEmail(detail.snapshot.sourceId) : '', onClose: () => closeDetail(true), onOpenLink: (url) => openEventPopup(url, popupRef, popupName) }))] }));
429
472
  }
@@ -0,0 +1,9 @@
1
+ import type { CalendarEvent, CalendarInfo } from '../core/types.js';
2
+ export interface EventDetailsProps {
3
+ event: CalendarEvent;
4
+ calendar?: CalendarInfo;
5
+ sourceLabel: string;
6
+ onClose: () => void;
7
+ onOpenLink: (url: string) => void;
8
+ }
9
+ export declare function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink }: EventDetailsProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from 'react';
3
+ import { getOrganizerLabel } from '../core/events.js';
4
+ import { RSVP_CHIPS, RsvpGlyph } from './CalendarPane.js';
5
+ import { formatEventWhen, htmlToPlainText, linkifyText } from './detailsText.js';
6
+ const MAX_ATTENDEES = 10;
7
+ const FOCUSABLE = 'a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"])';
8
+ function rsvpOf(status) {
9
+ return RSVP_CHIPS.find((c) => c.status === status) ?? RSVP_CHIPS[3];
10
+ }
11
+ function Status({ status }) {
12
+ const g = rsvpOf(status);
13
+ return (_jsxs("span", { className: `calendar-event-rsvp calendar-event-rsvp--${g.status}`, children: [_jsx(RsvpGlyph, { path: g.path, size: 14, strokeWidth: 2.4 }), " ", g.label] }));
14
+ }
15
+ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink }) {
16
+ const sheetRef = useRef(null);
17
+ useEffect(() => {
18
+ sheetRef.current?.focus();
19
+ }, []);
20
+ const when = formatEventWhen(event.start.dateTime ?? event.start.date, event.end.dateTime ?? event.end.date, event.isAllDay);
21
+ const organizer = getOrganizerLabel(event);
22
+ const description = htmlToPlainText(event.description);
23
+ const attendees = event.attendees ?? [];
24
+ function onKeyDown(e) {
25
+ if (e.key === 'Escape') {
26
+ e.stopPropagation();
27
+ onClose();
28
+ return;
29
+ }
30
+ if (e.key !== 'Tab')
31
+ return;
32
+ const items = Array.from(sheetRef.current?.querySelectorAll(FOCUSABLE) ?? []);
33
+ if (items.length === 0)
34
+ return;
35
+ const first = items[0];
36
+ const last = items[items.length - 1];
37
+ const active = document.activeElement;
38
+ if (e.shiftKey && (active === first || active === sheetRef.current)) {
39
+ e.preventDefault();
40
+ last.focus();
41
+ }
42
+ else if (!e.shiftKey && active === last) {
43
+ e.preventDefault();
44
+ first.focus();
45
+ }
46
+ }
47
+ return (_jsx("div", { className: "calendar-event-details", onClick: onClose, onKeyDown: onKeyDown, children: _jsxs("div", { ref: sheetRef, className: "calendar-event-details-sheet", role: "dialog", "aria-modal": "true", "aria-label": event.summary, tabIndex: -1, onClick: (e) => e.stopPropagation(), children: [_jsx("div", { className: "calendar-event-details-grabber", "aria-hidden": "true" }), _jsxs("div", { className: "calendar-event-details-header", children: [_jsx("span", { className: "calendar-event-details-dot", "aria-hidden": "true", style: { background: calendar?.backgroundColor } }), _jsx("h2", { className: "calendar-event-details-title", children: event.summary }), _jsx("button", { type: "button", className: "calendar-event-details-close", "aria-label": "Close", onClick: onClose, children: "\u00D7" })] }), _jsxs("div", { className: "calendar-event-details-body", children: [when.date && (_jsxs("section", { className: "calendar-event-details-when", children: [_jsx("span", { children: when.date }), when.time && _jsxs("span", { children: [" ", when.time] })] })), (calendar || sourceLabel) && (_jsxs("section", { className: "calendar-event-details-calendar", children: [calendar?.summary && _jsx("span", { children: calendar.summary }), sourceLabel && _jsxs("span", { children: [" ", sourceLabel] })] })), organizer && _jsx("section", { className: "calendar-event-details-organizer", children: organizer }), _jsxs("section", { className: "calendar-event-details-actions", children: [event.joinUrl && (_jsx("a", { href: event.joinUrl, target: "_blank", rel: "noopener noreferrer", children: "Join" })), _jsx(Status, { status: event.selfResponseStatus })] }), event.location && _jsx("section", { className: "calendar-event-details-location", children: event.location }), description && (_jsx("section", { className: "calendar-event-details-description", style: { whiteSpace: 'pre-wrap' }, children: linkifyText(description).map((t, i) => t.type === 'link' ? (_jsx("a", { href: t.href, target: "_blank", rel: "noopener noreferrer", children: t.text }, i)) : (_jsx("span", { children: t.text }, i))) })), attendees.length > 0 && (_jsxs("section", { className: "calendar-event-details-attendees", children: [_jsx("ul", { children: attendees.slice(0, MAX_ATTENDEES).map((a, i) => (_jsxs("li", { children: [_jsx("span", { children: a.displayName || a.email }), " ", _jsx(Status, { status: a.responseStatus })] }, `${a.email}-${i}`))) }), attendees.length > MAX_ATTENDEES && _jsxs("div", { children: ["+", attendees.length - MAX_ATTENDEES, " more"] })] })), event.htmlLink && (_jsx("section", { className: "calendar-event-details-open", children: _jsx("a", { href: event.htmlLink, target: "_blank", rel: "noopener noreferrer", onClick: (e) => {
48
+ e.preventDefault();
49
+ onOpenLink(event.htmlLink);
50
+ }, children: "Open in Google Calendar" }) }))] })] }) }));
51
+ }
@@ -0,0 +1,14 @@
1
+ export type Token = {
2
+ type: 'text';
3
+ text: string;
4
+ } | {
5
+ type: 'link';
6
+ text: string;
7
+ href: string;
8
+ };
9
+ export declare function htmlToPlainText(html?: string): string;
10
+ export declare function linkifyText(text: string): Token[];
11
+ export declare function formatEventWhen(start?: string, end?: string, allDay?: boolean): {
12
+ date: string;
13
+ time: string;
14
+ };
@@ -0,0 +1,44 @@
1
+ const BLOCK = 'p,div,li,tr,h1,h2,h3,h4,h5,h6,ul,ol,blockquote';
2
+ export function htmlToPlainText(html) {
3
+ if (!html)
4
+ return '';
5
+ const doc = new DOMParser().parseFromString(html, 'text/html');
6
+ doc.querySelectorAll('script,style').forEach((n) => n.remove());
7
+ doc.querySelectorAll('br').forEach((n) => n.replaceWith('\n'));
8
+ doc.querySelectorAll(BLOCK).forEach((n) => n.append('\n'));
9
+ return (doc.body.textContent ?? '').replace(/\n{3,}/g, '\n\n').trim();
10
+ }
11
+ export function linkifyText(text) {
12
+ const tokens = [];
13
+ const re = /https?:\/\/[^\s<>"]+/g;
14
+ let last = 0;
15
+ let m;
16
+ while ((m = re.exec(text))) {
17
+ const url = m[0].replace(/[.,;:!?)\]}'"]+$/, '');
18
+ if (m.index > last)
19
+ tokens.push({ type: 'text', text: text.slice(last, m.index) });
20
+ tokens.push({ type: 'link', text: url, href: url });
21
+ last = m.index + url.length;
22
+ re.lastIndex = last;
23
+ }
24
+ if (last < text.length)
25
+ tokens.push({ type: 'text', text: text.slice(last) });
26
+ return tokens;
27
+ }
28
+ function timeOfDay(dateTime) {
29
+ return new Date(dateTime).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });
30
+ }
31
+ function parseLocalDate(s) {
32
+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
33
+ return m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(s);
34
+ }
35
+ export function formatEventWhen(start, end, allDay) {
36
+ if (!start)
37
+ return { date: '', time: '' };
38
+ const d = allDay ? parseLocalDate(start) : new Date(start);
39
+ const date = d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
40
+ if (allDay)
41
+ return { date, time: '' };
42
+ const s = timeOfDay(start);
43
+ return { date, time: end ? `${s} – ${timeOfDay(end)}` : s };
44
+ }
package/dist/styles.css CHANGED
@@ -86,6 +86,7 @@
86
86
  }
87
87
 
88
88
  .calendar-pane {
89
+ position: relative;
89
90
  --calendar-footer-height: 64px;
90
91
  display: flex;
91
92
  flex-direction: column;
@@ -843,3 +844,78 @@
843
844
  opacity: 0.7;
844
845
  overflow-wrap: anywhere;
845
846
  }
847
+
848
+ /* Event details overlay: confined to the pane, bottom sheet. */
849
+ .calendar-event-details {
850
+ position: absolute;
851
+ inset: 0;
852
+ z-index: 20;
853
+ display: flex;
854
+ flex-direction: column;
855
+ justify-content: flex-end;
856
+ background: rgb(0 0 0 / 45%);
857
+ }
858
+
859
+ .calendar-event-details-sheet {
860
+ box-sizing: border-box;
861
+ max-height: 80%;
862
+ overflow-y: auto;
863
+ padding: 8px 16px 16px;
864
+ background: var(--calendar-surface);
865
+ color: var(--calendar-text);
866
+ border-top: 1px solid var(--calendar-border);
867
+ border-radius: 14px 14px 0 0;
868
+ animation: calendar-event-details-slide 0.2s ease-out;
869
+ }
870
+
871
+ .calendar-event-details-grabber {
872
+ width: 36px;
873
+ height: 4px;
874
+ margin: 0 auto 8px;
875
+ border-radius: 2px;
876
+ background: var(--calendar-border);
877
+ }
878
+
879
+ .calendar-event-details-header {
880
+ display: flex;
881
+ align-items: center;
882
+ gap: 8px;
883
+ }
884
+
885
+ .calendar-event-details-dot {
886
+ flex: none;
887
+ width: 10px;
888
+ height: 10px;
889
+ border-radius: 50%;
890
+ }
891
+
892
+ .calendar-event-details-title {
893
+ flex: 1;
894
+ min-width: 0;
895
+ margin: 0;
896
+ font-size: 1.05em;
897
+ overflow-wrap: anywhere;
898
+ }
899
+
900
+ .calendar-event-details-close {
901
+ flex: none;
902
+ border: 0;
903
+ background: transparent;
904
+ color: inherit;
905
+ font: inherit;
906
+ cursor: pointer;
907
+ }
908
+
909
+ .calendar-event-details-body > section {
910
+ margin-top: 10px;
911
+ overflow-wrap: anywhere;
912
+ }
913
+
914
+ @keyframes calendar-event-details-slide {
915
+ from { transform: translateY(100%); }
916
+ to { transform: translateY(0); }
917
+ }
918
+
919
+ @media (prefers-reduced-motion: reduce) {
920
+ .calendar-event-details-sheet { animation: none; }
921
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-webapp/calendar",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",