@open-webapp/calendar 0.15.0 → 0.16.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.16.0 is additive and non-breaking.** New optional `resolveContact` prop supplies contact names and avatars in the event details overlay. See [0.16.0](#0160-minor-additive-non-breaking).
6
+
5
7
  > **0.15.0 is additive and non-breaking.** RSVP changes in the overlay now take an optional note and are sent with a Send button; `onRsvpChange` gets an optional third `note` argument. See [0.15.0](#0150-minor-additive-non-breaking).
6
8
  >
7
9
  > **0.14.0 is additive and non-breaking.** The event details overlay is redesigned, and the optional `onRsvpChange` prop lets the host write RSVP changes. See [0.14.0](#0140-minor-additive-non-breaking).
@@ -167,6 +169,7 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
167
169
  | `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 |
168
170
  | `onClose?` | `() => void` | |
169
171
  | `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 |
172
+ | `resolveContact?` | `(email: string) => { name?: string; photoUrl?: string } \| undefined` | 0.16.0. Contact lookup for overlay invitee and organizer rows and list-row organizer labels: `name` beats `displayName`; avatar only when `photoUrl`, overlay only. Absent = unchanged. No dependency on contacts. |
170
173
  | `onRsvpChange?` | `(event: CalendarEvent, status: RsvpStatus, note?: string) => Promise<void>` | 0.14.0 (`note` added in 0.15.0). Host-owned RSVP writer. When absent, the overlay has no "Change RSVP" row. The package never writes to Google itself. See [Change RSVP](#change-rsvp-onrsvpchange) |
171
174
 
172
175
  #### Event details overlay
@@ -336,6 +339,10 @@ The shared `.calendar-selector-trigger` uses border-box inline-flex, centered al
336
339
 
337
340
  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.
338
341
 
342
+ ## 0.16.0 (minor, additive, non-breaking)
343
+
344
+ - Optional `resolveContact?: (email: string) => { name?: string; photoUrl?: string } | undefined` on `CalendarPane`: in the event details overlay, a returned `name` wins over the event `displayName` (and email) on invitee rows and the organizer row, and the organizer label in list rows resolves the same way (via `getOrganizerLabel(event, resolveContact?)`, "You" kept when `organizer.self` and nothing resolves, multi-source rows keep the `· <account email>` suffix); a 20px round avatar `img` renders only when `photoUrl` is returned, in the overlay only (list rows never render avatars). The host normalizes emails; the package passes the email as given by the event. Absent prop or `undefined` result leaves output unchanged. Calendar has no dependency on `@open-webapp/contacts`; hosts wire any lookup.
345
+
339
346
  ## 0.15.0 (minor, additive, non-breaking)
340
347
 
341
348
  - `onRsvpChange` gains an optional third argument `note?: string`.
@@ -23,8 +23,14 @@ export declare function getRollingWindow(now: Date): {
23
23
  * declined is a normal, independently-selectable status now, not hard-excluded.
24
24
  */
25
25
  export declare function filterByRsvp(events: CalendarEvent[], selected: ReadonlySet<RsvpStatus>): CalendarEvent[];
26
- /** displayName -> email -> "You" (only when organizer.self is true and both above are absent). */
27
- export declare function getOrganizerLabel(event: CalendarEvent): string;
26
+ /**
27
+ * contact name (optional resolver) -> displayName -> email -> "You" (only when organizer.self
28
+ * is true and all above are absent).
29
+ */
30
+ export declare function getOrganizerLabel(event: CalendarEvent, resolveContact?: (email: string) => {
31
+ name?: string;
32
+ photoUrl?: string;
33
+ } | undefined): string;
28
34
  /**
29
35
  * True iff `event` is a timed (non-all-day) event currently in progress at `now`:
30
36
  * both `start.dateTime` and `end.dateTime` exist and parse to valid instants,
@@ -46,9 +46,17 @@ export function getRollingWindow(now) {
46
46
  export function filterByRsvp(events, selected) {
47
47
  return events.filter((e) => selected.has(e.selfResponseStatus));
48
48
  }
49
- /** displayName -> email -> "You" (only when organizer.self is true and both above are absent). */
50
- export function getOrganizerLabel(event) {
49
+ /**
50
+ * contact name (optional resolver) -> displayName -> email -> "You" (only when organizer.self
51
+ * is true and all above are absent).
52
+ */
53
+ export function getOrganizerLabel(event, resolveContact) {
51
54
  const { organizer } = event;
55
+ if (resolveContact && organizer.email) {
56
+ const name = resolveContact(organizer.email)?.name;
57
+ if (name)
58
+ return name;
59
+ }
52
60
  if (organizer.displayName)
53
61
  return organizer.displayName;
54
62
  if (organizer.email)
@@ -3,6 +3,14 @@ import type { CalendarEvent, RsvpStatus, Source } from '../core/types.js';
3
3
  import type { CalendarController } from '../core/controller.js';
4
4
  export type RsvpSelection = Set<RsvpStatus>;
5
5
  export interface CalendarPaneProps {
6
+ /**
7
+ * Optional host lookup by attendee/organizer email (as given by the event). A returned `name` wins
8
+ * over the event displayName; an avatar renders only when `photoUrl` is returned. Absent = unchanged.
9
+ */
10
+ resolveContact?: (email: string) => {
11
+ name?: string;
12
+ photoUrl?: string;
13
+ } | undefined;
6
14
  theme?: 'system' | 'light' | 'dark';
7
15
  sources: Source[];
8
16
  controller: CalendarController;
@@ -528,7 +528,7 @@ export function CalendarPane(props) {
528
528
  const eventKey = getCalendarEventKey(event);
529
529
  const calendar = calendarsByKey.get(`${event.sourceId}\u0000${event.calendarId}`);
530
530
  const showCalendarLabel = calendar && !calendar.primary;
531
- const organizerLabel = getOrganizerLabel(event);
531
+ const organizerLabel = getOrganizerLabel(event, props.resolveContact);
532
532
  const showOrganizerLabel = multi
533
533
  ? true
534
534
  : organizerLabel && (!showCalendarLabel || organizerLabel !== calendar.summary);
@@ -566,5 +566,5 @@ export function CalendarPane(props) {
566
566
  })) }) })), detail && (_jsx(EventDetails, { event: (() => {
567
567
  const o = overrides.get(detailKey);
568
568
  return o ? { ...detail.snapshot, selfResponseStatus: o } : detail.snapshot;
569
- })(), onRsvpChange: props.onRsvpChange ? handleRsvpChange : undefined, pending: rsvpPending, error: rsvpError, 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) }))] }));
569
+ })(), onRsvpChange: props.onRsvpChange ? handleRsvpChange : undefined, resolveContact: props.resolveContact, pending: rsvpPending, error: rsvpError, 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) }))] }));
570
570
  }
@@ -9,5 +9,9 @@ export interface EventDetailsProps {
9
9
  pending?: boolean;
10
10
  error?: boolean | string;
11
11
  onRetry?: () => void;
12
+ resolveContact?: (email: string) => {
13
+ name?: string;
14
+ photoUrl?: string;
15
+ } | undefined;
12
16
  }
13
- export declare function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink, onRsvpChange, pending, error, onRetry }: EventDetailsProps): import("react").JSX.Element;
17
+ export declare function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink, onRsvpChange, pending, error, onRetry, resolveContact }: EventDetailsProps): import("react").JSX.Element;
@@ -14,7 +14,7 @@ const FOCUSABLE = 'a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"]
14
14
  function rsvpOf(status) {
15
15
  return RSVP_CHIPS.find((c) => c.status === status) ?? RSVP_CHIPS[3];
16
16
  }
17
- export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink, onRsvpChange, pending, error, onRetry }) {
17
+ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink, onRsvpChange, pending, error, onRetry, resolveContact }) {
18
18
  const sheetRef = useRef(null);
19
19
  const [expanded, setExpanded] = useState(false);
20
20
  const [selected, setSelected] = useState(null);
@@ -35,7 +35,7 @@ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink
35
35
  sheetRef.current?.focus();
36
36
  }, []);
37
37
  const time = event.isAllDay ? 'All day' : formatTimeRange(event);
38
- const organizer = getOrganizerLabel(event);
38
+ const organizer = getOrganizerLabel(event, resolveContact);
39
39
  const description = htmlToPlainText(event.description);
40
40
  const attendees = event.attendees ?? [];
41
41
  const onlySelf = attendees.length === 1 && !!attendees[0].self;
@@ -100,7 +100,10 @@ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink
100
100
  const checkedStatus = RSVP_OPTIONS.some((o) => o.status === event.selfResponseStatus)
101
101
  ? event.selfResponseStatus
102
102
  : RSVP_OPTIONS[0].status;
103
- 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-header calendar-event-details-toprow calendar-event-row--rsvp-${rsvpOf(event.selfResponseStatus).status}`, children: [_jsx("span", { className: "calendar-event-time", children: time }), _jsxs("div", { className: "calendar-event-actions", children: [event.joinUrl && (_jsx("a", { className: "calendar-event-join", href: event.joinUrl, target: "_blank", rel: "noopener noreferrer", children: "Join" })), _jsx("button", { type: "button", className: "calendar-event-details-close", "aria-label": "Close", onClick: onClose, children: "\u00D7" })] })] }), _jsx("div", { className: "calendar-event-details-header", children: _jsx("h2", { className: "calendar-event-details-title", children: event.summary }) }), _jsxs("div", { className: "calendar-event-details-body", children: [organizer && !showInvitees && (_jsxs("section", { className: "calendar-event-details-organizer", children: [_jsx("span", { children: "Organizer" }), " ", _jsx("span", { children: organizer }), event.organizer.self && _jsx("span", { children: " (you)" })] })), (calendar || sourceLabel || event.location) && (_jsxs("section", { className: "calendar-event-details-calendar", children: [_jsx("span", { className: "calendar-event-details-dot", "aria-hidden": "true", style: { background: calendar?.backgroundColor } }), calendar?.summary && _jsx("span", { children: calendar.summary }), sourceLabel && _jsxs("span", { children: [" ", sourceLabel] }), event.location && _jsxs("span", { 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))) })), showInvitees && (_jsxs("section", { className: "calendar-event-details-invitees", children: [_jsxs("h3", { children: ["Invitees (", attendees.length, ")"] }), _jsx("div", { className: "calendar-event-details-invitee-summary", children: summarizeInvitees(attendees) }), _jsx("ul", { children: visible.map((a, i) => (_jsxs("li", { children: [_jsx("span", { children: a.displayName || a.email }), a.organizer && _jsx("span", { className: "calendar-event-details-tag", children: " Organizer" }), a.self && _jsx("span", { className: "calendar-event-details-tag", children: " (you)" }), ' ', _jsx(RsvpStatusIcon, { status: a.responseStatus })] }, `${a.email}-${i}`))) }), sorted.length > MAX_INVITEES && (_jsx("button", { type: "button", "aria-expanded": expanded, onClick: () => setExpanded((v) => !v), children: expanded ? 'Show fewer' : `Show all ${sorted.length}` }))] })), showRsvp && (_jsxs("section", { className: "calendar-event-details-rsvp", children: [_jsx("div", { role: "radiogroup", "aria-label": "Change RSVP", children: RSVP_OPTIONS.map((o) => (_jsx("button", { type: "button", role: "radio", "aria-checked": (selected ?? event.selfResponseStatus) === o.status, tabIndex: o.status === (selected ?? checkedStatus) ? 0 : -1, disabled: !!pending, onClick: () => choose(o.status), onKeyDown: onRadioKeyDown, children: o.label }, o.status))) }), selected && (_jsxs("div", { className: "calendar-event-details-rsvp-note", children: [_jsxs("label", { children: [_jsx("span", { className: "calendar-event-details-rsvp-note-label", children: "Note to organizer (optional)" }), _jsx("input", { type: "text", maxLength: 500, value: note, disabled: !!pending, onChange: (e) => setNote(e.target.value), onKeyDown: (e) => {
103
+ 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-header calendar-event-details-toprow calendar-event-row--rsvp-${rsvpOf(event.selfResponseStatus).status}`, children: [_jsx("span", { className: "calendar-event-time", children: time }), _jsxs("div", { className: "calendar-event-actions", children: [event.joinUrl && (_jsx("a", { className: "calendar-event-join", href: event.joinUrl, target: "_blank", rel: "noopener noreferrer", children: "Join" })), _jsx("button", { type: "button", className: "calendar-event-details-close", "aria-label": "Close", onClick: onClose, children: "\u00D7" })] })] }), _jsx("div", { className: "calendar-event-details-header", children: _jsx("h2", { className: "calendar-event-details-title", children: event.summary }) }), _jsxs("div", { className: "calendar-event-details-body", children: [organizer && !showInvitees && (_jsxs("section", { className: "calendar-event-details-organizer", children: [_jsx("span", { children: "Organizer" }), " ", _jsx("span", { children: organizer }), event.organizer.self && _jsx("span", { children: " (you)" })] })), (calendar || sourceLabel || event.location) && (_jsxs("section", { className: "calendar-event-details-calendar", children: [_jsx("span", { className: "calendar-event-details-dot", "aria-hidden": "true", style: { background: calendar?.backgroundColor } }), calendar?.summary && _jsx("span", { children: calendar.summary }), sourceLabel && _jsxs("span", { children: [" ", sourceLabel] }), event.location && _jsxs("span", { 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))) })), showInvitees && (_jsxs("section", { className: "calendar-event-details-invitees", children: [_jsxs("h3", { children: ["Invitees (", attendees.length, ")"] }), _jsx("div", { className: "calendar-event-details-invitee-summary", children: summarizeInvitees(attendees) }), _jsx("ul", { children: visible.map((a, i) => {
104
+ const contact = resolveContact && a.email ? resolveContact(a.email) : undefined;
105
+ return (_jsxs("li", { children: [contact?.photoUrl && (_jsx("img", { className: "calendar-event-details-avatar", src: contact.photoUrl, alt: "", width: 20, height: 20 })), _jsx("span", { children: contact?.name || a.displayName || a.email }), a.organizer && _jsx("span", { className: "calendar-event-details-tag", children: " Organizer" }), a.self && _jsx("span", { className: "calendar-event-details-tag", children: " (you)" }), ' ', _jsx(RsvpStatusIcon, { status: a.responseStatus })] }, `${a.email}-${i}`));
106
+ }) }), sorted.length > MAX_INVITEES && (_jsx("button", { type: "button", "aria-expanded": expanded, onClick: () => setExpanded((v) => !v), children: expanded ? 'Show fewer' : `Show all ${sorted.length}` }))] })), showRsvp && (_jsxs("section", { className: "calendar-event-details-rsvp", children: [_jsx("div", { role: "radiogroup", "aria-label": "Change RSVP", children: RSVP_OPTIONS.map((o) => (_jsx("button", { type: "button", role: "radio", "aria-checked": (selected ?? event.selfResponseStatus) === o.status, tabIndex: o.status === (selected ?? checkedStatus) ? 0 : -1, disabled: !!pending, onClick: () => choose(o.status), onKeyDown: onRadioKeyDown, children: o.label }, o.status))) }), selected && (_jsxs("div", { className: "calendar-event-details-rsvp-note", children: [_jsxs("label", { children: [_jsx("span", { className: "calendar-event-details-rsvp-note-label", children: "Note to organizer (optional)" }), _jsx("input", { type: "text", maxLength: 500, value: note, disabled: !!pending, onChange: (e) => setNote(e.target.value), onKeyDown: (e) => {
104
107
  if (e.key === 'Escape') {
105
108
  e.stopPropagation();
106
109
  setSelected(null);
package/dist/styles.css CHANGED
@@ -945,6 +945,14 @@
945
945
  font-size: 0.9em;
946
946
  }
947
947
 
948
+ .calendar-event-details-avatar {
949
+ width: 20px;
950
+ height: 20px;
951
+ border-radius: 50%;
952
+ object-fit: cover;
953
+ background: var(--calendar-badge);
954
+ }
955
+
948
956
  .calendar-event-details-tag {
949
957
  padding: 0 6px;
950
958
  border-radius: 8px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-webapp/calendar",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",