@open-webapp/calendar 0.14.2 → 0.15.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.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
+ >
5
7
  > **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).
6
8
  >
7
9
  > **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).
@@ -165,13 +167,13 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
165
167
  | `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 |
166
168
  | `onClose?` | `() => void` | |
167
169
  | `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 |
168
- | `onRsvpChange?` | `(event: CalendarEvent, status: RsvpStatus) => Promise<void>` | 0.14.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) |
170
+ | `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) |
169
171
 
170
172
  #### Event details overlay
171
173
 
172
174
  A plain left click on an event title opens a bottom-sheet overlay inside the pane (`role="dialog"`, `aria-modal="true"`). The sheet is laid out like the event card, but larger, top to bottom:
173
175
 
174
- 1. Top row, same information as the card: time range (or `All day`), Join (only when `joinUrl` is set), a read-only RSVP status, and the close (×) button.
176
+ 1. Top row, same information as the card: time range (or `All day`), Join (only when `joinUrl` is set), a status tint (no glyph since 0.15.0), and the close (×) button.
175
177
  2. Title (the dialog's accessible name, an `h2`).
176
178
  3. Organizer row: the label "Organizer", the organizer label, and "(you)" when `organizer.self` is true. Hidden when there is no organizer label.
177
179
  4. Calendar line: calendar color dot, calendar name, source (account) label, and location when set.
@@ -209,7 +211,7 @@ A plain left click on an event title opens a bottom-sheet overlay inside the pan
209
211
  `onRsvpChange` is an optional prop on `CalendarPane`. The host does the write; the package makes no Google request for it and asks for no new OAuth scopes. Recurring events are handled per instance: the `event` passed to the host is the instance the user opened.
210
212
 
211
213
  - The row is a radiogroup labeled "Change RSVP" with three options: Yes (accepted), Maybe (tentative), and No (declined). Unaccepted is not offered. Each option is a radio with `aria-checked`. Arrow keys move between options. The row shows only when the prop is set, you are an attendee, and the event has attendees.
212
- - Choosing an option calls `onRsvpChange(event, status)` once. Choosing the already selected option still calls it, so a host can rely on one call per click.
214
+ - Choosing an option only selects it; nothing is written. A "Note to organizer (optional)" input (max 500 chars) and a Send button appear. Send calls `onRsvpChange(event, status, note)` once; `note` is trimmed, or `undefined` when empty. Re-clicking the saved status or pressing Escape in the note field cancels the draft (Escape does not close the overlay). Retry resends status and note. Pass the note to Google as `attendees[].comment` with `sendUpdates`; only the organizer sees it.
213
215
  - Optimistic update: the overlay and the event card show the new status at once. The options are disabled while the write is pending, and a live region reads "Updating RSVP...".
214
216
  - Success: the override stays until a controller refresh delivers that event, so the server's status takes over then. If the new status is hidden by the RSVP filter chips, the overlay stays open, and the card leaves the list only after the overlay closes. Changing filter chips still closes the overlay, as before.
215
217
  - Failure: if the promise rejects or throws, or does not settle within **60 seconds** (`RSVP_PENDING_TIMEOUT_MS = 60000`), the previous status comes back and the live region shows "Couldn't update RSVP. Retry". Retry sends the last chosen status again. A result that arrives after the timeout is ignored. The timer is not cleared by closing the overlay, so a timed-out write still rolls back. In that case no error message shows, because the overlay is closed.
@@ -334,6 +336,13 @@ The shared `.calendar-selector-trigger` uses border-box inline-flex, centered al
334
336
 
335
337
  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.
336
338
 
339
+ ## 0.15.0 (minor, additive, non-breaking)
340
+
341
+ - `onRsvpChange` gains an optional third argument `note?: string`.
342
+ - Overlay RSVP is now select, optional note, then Send. Selecting alone no longer calls the host.
343
+ - The overlay top row no longer shows the RSVP glyph (status tint and Join colors remain).
344
+ - Update hosts that relied on one call per click: the call now happens on Send.
345
+
337
346
  ## 0.14.2 (patch)
338
347
 
339
348
  - The overlay top row carries the card's `calendar-event-row--rsvp-{status}` class so the Join link gets the same status-coloured styling as on the card. The Organizer row under the title is dropped when the invitee list is shown (the organizer is tagged in the list), and invitee statuses use the card's icon-only status badge instead of a text pill. No API change.
@@ -23,8 +23,10 @@ export interface CalendarPaneProps {
23
23
  /**
24
24
  * Optional host-provided RSVP writer. When present, the event details overlay shows a
25
25
  * "Change RSVP" row. The package never writes to Google itself; the host performs the write.
26
+ * `comment` is the optional trimmed note to the organizer (omitted when empty); hosts may pass it
27
+ * to Google `attendees[].comment`.
26
28
  */
27
- onRsvpChange?: (event: CalendarEvent, status: RsvpStatus) => Promise<void>;
29
+ onRsvpChange?: (event: CalendarEvent, status: RsvpStatus, comment?: string) => Promise<void>;
28
30
  }
29
31
  export declare const RSVP_PENDING_TIMEOUT_MS = 60000;
30
32
  export declare const RSVP_CHIPS: {
@@ -196,7 +196,7 @@ export function CalendarPane(props) {
196
196
  setRsvpPending(false);
197
197
  setRsvpError(false);
198
198
  }, [detailKey]);
199
- function handleRsvpChange(_event, status) {
199
+ function handleRsvpChange(_event, status, comment) {
200
200
  const onRsvpChange = props.onRsvpChange;
201
201
  const raw = detail?.snapshot;
202
202
  if (!onRsvpChange || !raw || rsvpPendingRef.current)
@@ -234,7 +234,7 @@ export function CalendarPane(props) {
234
234
  rsvpTimerRef.current = setTimeout(() => finish(false), RSVP_PENDING_TIMEOUT_MS);
235
235
  let p;
236
236
  try {
237
- p = Promise.resolve(onRsvpChange(raw, status));
237
+ p = Promise.resolve(onRsvpChange(raw, status, comment));
238
238
  }
239
239
  catch {
240
240
  p = Promise.reject(new Error('rsvp failed'));
@@ -5,7 +5,7 @@ export interface EventDetailsProps {
5
5
  sourceLabel: string;
6
6
  onClose: () => void;
7
7
  onOpenLink: (url: string) => void;
8
- onRsvpChange?: (event: CalendarEvent, status: RsvpStatus) => void | Promise<void>;
8
+ onRsvpChange?: (event: CalendarEvent, status: RsvpStatus, note?: string) => void | Promise<void>;
9
9
  pending?: boolean;
10
10
  error?: boolean | string;
11
11
  onRetry?: () => void;
@@ -16,8 +16,21 @@ function rsvpOf(status) {
16
16
  }
17
17
  export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink, onRsvpChange, pending, error, onRetry }) {
18
18
  const sheetRef = useRef(null);
19
- const lastStatus = useRef(null);
20
19
  const [expanded, setExpanded] = useState(false);
20
+ const [selected, setSelected] = useState(null);
21
+ const [note, setNote] = useState('');
22
+ const wasPending = useRef(false);
23
+ useEffect(() => {
24
+ if (pending)
25
+ wasPending.current = true;
26
+ else if (wasPending.current) {
27
+ wasPending.current = false;
28
+ if (!error) {
29
+ setSelected(null);
30
+ setNote('');
31
+ }
32
+ }
33
+ }, [pending, error]);
21
34
  useEffect(() => {
22
35
  sheetRef.current?.focus();
23
36
  }, []);
@@ -32,16 +45,25 @@ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink
32
45
  const sorted = showInvitees ? sortInvitees(attendees) : [];
33
46
  const visible = expanded ? sorted : sorted.slice(0, MAX_INVITEES);
34
47
  function choose(status) {
35
- if (pending || !onRsvpChange)
48
+ if (pending)
49
+ return;
50
+ if (status === event.selfResponseStatus || status === selected) {
51
+ setSelected(null);
52
+ setNote('');
53
+ return;
54
+ }
55
+ setSelected(status);
56
+ }
57
+ function send() {
58
+ if (pending || !onRsvpChange || !selected)
36
59
  return;
37
- lastStatus.current = status;
38
- void onRsvpChange(event, status);
60
+ void onRsvpChange(event, selected, note.trim() || undefined);
39
61
  }
40
62
  function retry() {
41
63
  if (onRetry)
42
64
  onRetry();
43
- else if (lastStatus.current)
44
- choose(lastStatus.current);
65
+ else
66
+ send();
45
67
  }
46
68
  function onRadioKeyDown(e) {
47
69
  const dir = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? -1 : 0;
@@ -78,7 +100,18 @@ export function EventDetails({ event, calendar, sourceLabel, onClose, onOpenLink
78
100
  const checkedStatus = RSVP_OPTIONS.some((o) => o.status === event.selfResponseStatus)
79
101
  ? event.selfResponseStatus
80
102
  : RSVP_OPTIONS[0].status;
81
- 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(RsvpStatusIcon, { status: event.selfResponseStatus }), _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": event.selfResponseStatus === o.status, tabIndex: o.status === checkedStatus ? 0 : -1, disabled: !!pending, onClick: () => choose(o.status), onKeyDown: onRadioKeyDown, children: o.label }, o.status))) }), _jsx("div", { "aria-live": "polite", className: "calendar-event-details-rsvp-status", children: pending ? ('Updating RSVP...') : error ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Couldn't update RSVP." }), ' ', _jsx("button", { type: "button", onClick: retry, children: "Retry" })] })) : null })] })), event.htmlLink && (_jsx("section", { className: "calendar-event-details-open", children: _jsx("a", { href: event.htmlLink, target: "_blank", rel: "noopener noreferrer", onClick: (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) => (_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) => {
104
+ if (e.key === 'Escape') {
105
+ e.stopPropagation();
106
+ setSelected(null);
107
+ setNote('');
108
+ sheetRef.current?.querySelector('[role="radio"][tabindex="0"]')?.focus();
109
+ }
110
+ else if (e.key === 'Enter') {
111
+ e.preventDefault();
112
+ send();
113
+ }
114
+ } })] }), _jsx("button", { type: "button", className: "calendar-event-details-rsvp-send", disabled: !!pending, onClick: send, children: "Send" })] })), _jsx("div", { "aria-live": "polite", className: "calendar-event-details-rsvp-status", children: pending ? ('Updating RSVP...') : error ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Couldn't update RSVP." }), ' ', _jsx("button", { type: "button", onClick: retry, children: "Retry" })] })) : null })] })), event.htmlLink && (_jsx("section", { className: "calendar-event-details-open", children: _jsx("a", { href: event.htmlLink, target: "_blank", rel: "noopener noreferrer", onClick: (e) => {
82
115
  e.preventDefault();
83
116
  onOpenLink(event.htmlLink);
84
117
  }, children: "Open in Google Calendar" }) }))] })] }) }));
package/dist/styles.css CHANGED
@@ -985,6 +985,56 @@
985
985
  cursor: default;
986
986
  }
987
987
 
988
+ .calendar-event-details-rsvp-note {
989
+ display: flex;
990
+ align-items: flex-end;
991
+ gap: 6px;
992
+ margin-top: 8px;
993
+ }
994
+
995
+ .calendar-event-details-rsvp-note label {
996
+ flex: 1 1 auto;
997
+ min-width: 0;
998
+ display: flex;
999
+ flex-direction: column;
1000
+ gap: 2px;
1001
+ font-size: 0.85em;
1002
+ }
1003
+
1004
+ .calendar-event-details-rsvp-note input {
1005
+ width: 100%;
1006
+ box-sizing: border-box;
1007
+ padding: 4px 8px;
1008
+ border: 1px solid var(--calendar-chip-border);
1009
+ border-radius: 6px;
1010
+ background: transparent;
1011
+ color: inherit;
1012
+ font: inherit;
1013
+ }
1014
+
1015
+ .calendar-event-details-rsvp-note input:focus-visible,
1016
+ .calendar-event-details-rsvp-send:focus-visible {
1017
+ outline: 2px solid var(--calendar-focus);
1018
+ outline-offset: 2px;
1019
+ }
1020
+
1021
+ .calendar-event-details-rsvp-send {
1022
+ flex: 0 0 auto;
1023
+ padding: 4px 12px;
1024
+ border: 1px solid var(--calendar-chip-selected);
1025
+ border-radius: 14px;
1026
+ background: var(--calendar-chip-selected);
1027
+ color: var(--calendar-chip-selected-text);
1028
+ font: inherit;
1029
+ cursor: pointer;
1030
+ }
1031
+
1032
+ .calendar-event-details-rsvp-send:disabled,
1033
+ .calendar-event-details-rsvp-note input:disabled {
1034
+ opacity: 0.6;
1035
+ cursor: default;
1036
+ }
1037
+
988
1038
  .calendar-event-details-rsvp-status {
989
1039
  margin-top: 6px;
990
1040
  font-size: 0.85em;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-webapp/calendar",
3
- "version": "0.14.2",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,8 @@
25
25
  "scripts": {
26
26
  "build": "tsc && cp src/react/styles.css dist/styles.css",
27
27
  "test": "vitest run",
28
- "test:theme-browser": "vitest run --config vitest.browser.config.ts"
28
+ "test:theme-browser": "vitest run --config vitest.browser.config.ts",
29
+ "lint": "oxlint --type-aware src"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "react": "^19",
@@ -41,6 +42,8 @@
41
42
  "@vitest/browser": "2.1.9",
42
43
  "fake-indexeddb": "^6.0.0",
43
44
  "jsdom": "^30.0.1",
45
+ "oxlint": "^1.94.0",
46
+ "oxlint-tsgolint": "^7.0.2007",
44
47
  "playwright": "1.51.1",
45
48
  "react": "^19.0.0",
46
49
  "react-dom": "^19.0.0",