@open-webapp/calendar 0.12.0 → 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,6 +2,8 @@
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.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
+ >
5
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.
@@ -160,7 +162,18 @@ 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
 
@@ -231,10 +244,21 @@ 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
+
238
262
  ## 0.12.0 (BREAKING pre-1.0 minor)
239
263
 
240
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.
@@ -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?: {
@@ -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,6 +2,7 @@ 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
+ import { EventDetails } from './EventDetails.js';
5
6
  function nextRsvpSelection(selection, status, saved) {
6
7
  const isUnacceptedOnly = selection.size === 1 && selection.has('needsAction');
7
8
  if (status === 'needsAction') {
@@ -24,17 +25,8 @@ function nextRsvpSelection(selection, status, saved) {
24
25
  }
25
26
  return { next: next.size === 0 ? new Set(DEFAULT_RSVP_STATUSES) : next, saved: null };
26
27
  }
27
- function useWindowWidth() {
28
- const [width, setWidth] = useState(typeof window !== 'undefined' ? window.innerWidth : 1024);
29
- useEffect(() => {
30
- const handler = () => setWidth(window.innerWidth);
31
- window.addEventListener('resize', handler);
32
- return () => window.removeEventListener('resize', handler);
33
- }, []);
34
- return width;
35
- }
36
28
  const SOURCE_COLORS = ['#4285f4', '#ea4335', '#34a853', '#fbbc04', '#a142f4', '#00acc1', '#ff7043', '#8d6e63'];
37
- const RSVP_CHIPS = [
29
+ export const RSVP_CHIPS = [
38
30
  {
39
31
  status: 'accepted',
40
32
  label: 'Accepted',
@@ -56,7 +48,7 @@ const RSVP_CHIPS = [
56
48
  path: 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z',
57
49
  },
58
50
  ];
59
- function RsvpGlyph({ path, size = 16, strokeWidth = 2.2 }) {
51
+ export function RsvpGlyph({ path, size = 16, strokeWidth = 2.2 }) {
60
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" }) }));
61
53
  }
62
54
  function RsvpStatusIcon({ status }) {
@@ -123,7 +115,6 @@ function usableUrl(url) {
123
115
  return trimmed === '' ? null : trimmed;
124
116
  }
125
117
  export function CalendarPane(props) {
126
- const isDesktop = useWindowWidth() >= 960;
127
118
  const { sources, controller, selectedRsvpStatuses, theme = 'system' } = props;
128
119
  const popupName = props.popupName ?? DEFAULT_POPUP_NAME;
129
120
  const [version, setVersion] = useState(0);
@@ -160,6 +151,49 @@ export function CalendarPane(props) {
160
151
  const didMountRsvpRef = useRef(false);
161
152
  const savedRsvpRef = useRef(null);
162
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
+ }
163
197
  useEffect(() => {
164
198
  if (selectedRsvpStatuses.size !== 1 || !selectedRsvpStatuses.has('needsAction')) {
165
199
  savedRsvpRef.current = null;
@@ -416,9 +450,8 @@ export function CalendarPane(props) {
416
450
  ? event.selfResponseStatus
417
451
  : 'needsAction';
418
452
  if (event.isAllDay) {
419
- 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));
420
454
  }
421
- const hasLink = usableUrl(event.htmlLink) !== null;
422
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) => {
423
456
  if (el) {
424
457
  timedEventRefs.current.set(eventKey, el);
@@ -426,17 +459,7 @@ export function CalendarPane(props) {
426
459
  else {
427
460
  timedEventRefs.current.delete(eventKey);
428
461
  }
429
- }, 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) => {
430
- if (isDesktop &&
431
- e.button === 0 &&
432
- !e.ctrlKey &&
433
- !e.metaKey &&
434
- !e.shiftKey &&
435
- !e.altKey) {
436
- e.preventDefault();
437
- openEventPopup(event.htmlLink, popupRef, popupName);
438
- }
439
- }, 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));
440
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) => ({
441
464
  id: s.id,
442
465
  calendars: controller.getCalendars(s.id),
@@ -445,5 +468,5 @@ export function CalendarPane(props) {
445
468
  void controller.setSelectedIds(s.id, ids);
446
469
  },
447
470
  heading: multi ? s.email : undefined,
448
- })) }) }))] }));
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) }))] }));
449
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.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",