@open-webapp/calendar 0.11.1 → 0.12.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,7 @@
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.12.0 is BREAKING.** See [0.12.0](#0120-breaking-pre-10-minor) for exclusive Unaccepted filtering and new RSVP defaults.
6
6
  >
7
7
  > **0.10.0 is BREAKING.** See [0.10.0](#0100-breaking-pre-10-minor) for the approved CalendarPane selector-popup geometry correction.
8
8
 
@@ -150,7 +150,7 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
150
150
  | `sources` | `Source[]` | shown accounts; 2+ enables multi-source UI (per-source color and email) |
151
151
  | `controller` | `CalendarController` | |
152
152
  | `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) |
153
+ | `selectedRsvpStatuses` | `Set<RsvpStatus>` | host-controlled filter; `DEFAULT_RSVP_STATUSES` = accepted, tentative (O unpressed) |
154
154
  | `onRsvpStatusesChange` | `(next) => void` | |
155
155
  | `renderEventAction?` | `(event) => ReactNode` | per-event slot |
156
156
  | `connected?` | `boolean` | defaults to `sources.length > 0` (back-compat). `false` shows the not-connected block |
@@ -164,9 +164,9 @@ Call at top level of a vitest file; it registers a `describe('StorageAdapter con
164
164
 
165
165
  #### RSVP chips
166
166
 
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.
167
+ 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
168
 
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.
169
+ 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
170
 
171
171
  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
172
 
@@ -235,6 +235,12 @@ The shared `.calendar-selector-trigger` uses border-box inline-flex, centered al
235
235
 
236
236
  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
237
 
238
+ ## 0.12.0 (BREAKING pre-1.0 minor)
239
+
240
+ - 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.
241
+ - `DEFAULT_RSVP_STATUSES` now contains only accepted and tentative, so O is unpressed by default.
242
+ - Hosts that persist RSVP selections, including selections containing `needsAction`, must adapt to the exclusive O and new-default behavior.
243
+
238
244
  ## 0.11.1 (patch)
239
245
 
240
246
  - 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 +256,8 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
250
256
 
251
257
  ## 0.8.0 (BREAKING pre-1.0 minor)
252
258
 
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.
259
+ - Unaccepted independently toggled `needsAction` at this release. This behavior changed in 0.12.0.
260
+ - Defaults and last-deselection fallback were accepted/tentative/needsAction at this release.
255
261
  - Ribbon labels center in the measured visible intersection, including empty Today, scrolling, resizing and mounted theme changes.
256
262
 
257
263
  ## 0.7.0 (minor, breaking-visual)
@@ -282,7 +288,7 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
282
288
 
283
289
  ## 0.3.0 (minor, additive)
284
290
 
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.
291
+ - 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
292
  - 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
293
  - Adds the `.calendar-rsvp-chip-badge` host styling hook. Public props and default RSVP statuses remain compatible.
288
294
 
@@ -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));
@@ -2,7 +2,19 @@ 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
+ function nextRsvpSelection(selection, status, saved) {
6
+ const isUnacceptedOnly = selection.size === 1 && selection.has('needsAction');
7
+ if (status === 'needsAction') {
8
+ if (isUnacceptedOnly) {
9
+ return { next: new Set(saved ?? DEFAULT_RSVP_STATUSES), saved: null };
10
+ }
11
+ if (!selection.has('needsAction')) {
12
+ return { next: new Set(['needsAction']), saved: new Set(selection) };
13
+ }
14
+ }
15
+ else if (isUnacceptedOnly) {
16
+ return { next: new Set([status]), saved: null };
17
+ }
6
18
  const next = new Set(selection);
7
19
  if (next.has(status)) {
8
20
  next.delete(status);
@@ -10,7 +22,7 @@ function toggleRsvpStatus(selection, status) {
10
22
  else {
11
23
  next.add(status);
12
24
  }
13
- return next.size === 0 ? new Set(DEFAULT_RSVP_STATUSES) : next;
25
+ return { next: next.size === 0 ? new Set(DEFAULT_RSVP_STATUSES) : next, saved: null };
14
26
  }
15
27
  function useWindowWidth() {
16
28
  const [width, setWidth] = useState(typeof window !== 'undefined' ? window.innerWidth : 1024);
@@ -146,7 +158,13 @@ export function CalendarPane(props) {
146
158
  const popupRef = useRef(null);
147
159
  const anchorSnapshotRef = useRef(null);
148
160
  const didMountRsvpRef = useRef(false);
161
+ const savedRsvpRef = useRef(null);
149
162
  const [now, setNow] = useState(() => new Date());
163
+ useEffect(() => {
164
+ if (selectedRsvpStatuses.size !== 1 || !selectedRsvpStatuses.has('needsAction')) {
165
+ savedRsvpRef.current = null;
166
+ }
167
+ }, [selectedRsvpStatuses]);
150
168
  const unacceptedCount = useMemo(() => events.filter((event) => event.selfResponseStatus === 'needsAction').length, [events]);
151
169
  const filteredEvents = useMemo(() => filterByRsvp(events, selectedRsvpStatuses), [events, selectedRsvpStatuses]);
152
170
  const calendarsByKey = useMemo(() => {
@@ -217,7 +235,9 @@ export function CalendarPane(props) {
217
235
  // eslint-disable-next-line react-hooks/exhaustive-deps
218
236
  }, [selectedRsvpStatuses]);
219
237
  function handleToggle(status) {
220
- props.onRsvpStatusesChange(toggleRsvpStatus(selectedRsvpStatuses, status));
238
+ const selection = nextRsvpSelection(selectedRsvpStatuses, status, savedRsvpRef.current);
239
+ savedRsvpRef.current = selection.saved;
240
+ props.onRsvpStatusesChange(selection.next);
221
241
  }
222
242
  const dayGroups = groupByDay(filteredEvents, todayIso);
223
243
  function scrollToToday(behavior = 'auto') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-webapp/calendar",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",