@open-webapp/calendar 0.10.0 → 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 +21 -7
- package/dist/core/events.d.ts +1 -4
- package/dist/core/events.js +11 -12
- package/dist/react/CalendarPane.js +23 -3
- package/dist/testing/storageContract.js +2 -0
- package/package.json +1 -1
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.
|
|
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
|
|
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).
|
|
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
|
|
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
|
|
|
@@ -215,6 +215,10 @@ The host owns theme-picker UI and preference persistence (for example, saving a
|
|
|
215
215
|
|
|
216
216
|
The exported standalone selector keeps its single-list props and behavior; Select all adds only search matches while retaining existing selections.
|
|
217
217
|
|
|
218
|
+
### Day headers
|
|
219
|
+
|
|
220
|
+
Sticky day headers show `Today · Sunday`, `Tomorrow · Monday`, or just the full English weekday for other dates. The weekday follows the date key without timezone shifts, including across year boundaries; Today remains the browser-local date. Vertical ribbon labels continue to show Month Day (for example, `Oct 26`), with the existing layout and styling.
|
|
221
|
+
|
|
218
222
|
### Host CSS
|
|
219
223
|
|
|
220
224
|
Day ribbon styling: each day's ribbon alternates between two tones by day parity (`data-parity="even|odd"`), set with `--calendar-day-ribbon-a` and `--calendar-day-ribbon-b`. Parity is stable across scroll, filtering and month boundaries, and the ribbon does not mark today. Labels center in the actual ribbon/viewport intersection below the measured chips and that day's header, including empty Today before an event day. Short ribbons center within their bounds. Scroll, resize, rendered-content and mounted theme changes update measurements; `--calendar-day-header-height` no longer positions the label.
|
|
@@ -231,6 +235,16 @@ The shared `.calendar-selector-trigger` uses border-box inline-flex, centered al
|
|
|
231
235
|
|
|
232
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.
|
|
233
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
|
+
|
|
244
|
+
## 0.11.1 (patch)
|
|
245
|
+
|
|
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.
|
|
247
|
+
|
|
234
248
|
## 0.10.0 (BREAKING pre-1.0 minor)
|
|
235
249
|
|
|
236
250
|
- Approved CalendarPane selector-popup geometry correction: the upward popup is aligned to the trigger's left edge, adapts to the pane's 16px content inset, and uses the pane/viewport space above the trigger as its complete height budget. Options shrink and scroll before search/actions become inaccessible.
|
|
@@ -242,8 +256,8 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
|
|
|
242
256
|
|
|
243
257
|
## 0.8.0 (BREAKING pre-1.0 minor)
|
|
244
258
|
|
|
245
|
-
- Unaccepted independently
|
|
246
|
-
- Defaults and last-deselection fallback
|
|
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.
|
|
247
261
|
- Ribbon labels center in the measured visible intersection, including empty Today, scrolling, resizing and mounted theme changes.
|
|
248
262
|
|
|
249
263
|
## 0.7.0 (minor, breaking-visual)
|
|
@@ -274,7 +288,7 @@ Done, Select all and Clear use the approved action-only flat styling via `.calen
|
|
|
274
288
|
|
|
275
289
|
## 0.3.0 (minor, additive)
|
|
276
290
|
|
|
277
|
-
- Added the Unaccepted exclusive shortcut after Accepted, Maybe, and Declined, with local selection restoration and default fallback.
|
|
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.
|
|
278
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`.
|
|
279
293
|
- Adds the `.calendar-rsvp-chip-badge` host styling hook. Public props and default RSVP statuses remain compatible.
|
|
280
294
|
|
package/dist/core/events.d.ts
CHANGED
|
@@ -54,10 +54,7 @@ export interface DayGroup {
|
|
|
54
54
|
export declare function groupByDay(events: CalendarEvent[], todayIso?: string): DayGroup[];
|
|
55
55
|
/** Short "Mmm D" label for the day ribbon: no year, no Today/Tomorrow. */
|
|
56
56
|
export declare function formatRibbonLabel(dateKey: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* "Today · Sept 26" / "Tomorrow · Sept 27" / else "Sept 28"-style.
|
|
59
|
-
* Includes year only when the event's year differs from today's year.
|
|
60
|
-
*/
|
|
57
|
+
/** Full English weekday, prefixed with Today/Tomorrow relative to the local today key. */
|
|
61
58
|
export declare function formatDayHeader(dateKey: string, today: string): string;
|
|
62
59
|
interface RawEvent {
|
|
63
60
|
id?: unknown;
|
package/dist/core/events.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
2
|
-
export const DEFAULT_RSVP_STATUSES = ['accepted', 'tentative'
|
|
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));
|
|
@@ -176,20 +176,19 @@ function addDaysToIso(dateKey, days) {
|
|
|
176
176
|
// d is built from pure UTC parts (not "now"), so the UTC date is the right one.
|
|
177
177
|
return d.toISOString().slice(0, 10);
|
|
178
178
|
}
|
|
179
|
-
/**
|
|
180
|
-
* "Today · Sept 26" / "Tomorrow · Sept 27" / else "Sept 28"-style.
|
|
181
|
-
* Includes year only when the event's year differs from today's year.
|
|
182
|
-
*/
|
|
179
|
+
/** Full English weekday, prefixed with Today/Tomorrow relative to the local today key. */
|
|
183
180
|
export function formatDayHeader(dateKey, today) {
|
|
184
|
-
const { year
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
181
|
+
const { year, month, day } = parseIsoDateParts(dateKey);
|
|
182
|
+
// The key is a calendar date, not an instant to shift into the browser timezone.
|
|
183
|
+
const weekday = new Date(Date.UTC(year, month - 1, day)).toLocaleDateString('en-US', {
|
|
184
|
+
weekday: 'long',
|
|
185
|
+
timeZone: 'UTC',
|
|
186
|
+
});
|
|
188
187
|
if (dateKey === today)
|
|
189
|
-
return `Today · ${
|
|
188
|
+
return `Today · ${weekday}`;
|
|
190
189
|
if (dateKey === addDaysToIso(today, 1))
|
|
191
|
-
return `Tomorrow · ${
|
|
192
|
-
return
|
|
190
|
+
return `Tomorrow · ${weekday}`;
|
|
191
|
+
return weekday;
|
|
193
192
|
}
|
|
194
193
|
const JOIN_URL_REGEX = /https?:\/\/[^\s<>"']*(?:zoom\.us|meet\.google\.com|teams\.microsoft\.com)[^\s<>"']*/i;
|
|
195
194
|
export function deriveSelfResponseStatus(raw) {
|
|
@@ -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
|
|
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
|
-
|
|
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') {
|
|
@@ -33,6 +33,8 @@ export function runStorageAdapterContract(factory) {
|
|
|
33
33
|
getToken: async () => 't',
|
|
34
34
|
storage: h.storage,
|
|
35
35
|
crypto,
|
|
36
|
+
// Keep literal legacy fixtures inside the read-time window, regardless of wall clock.
|
|
37
|
+
now: () => new Date('2026-10-09T12:00:00.000Z'),
|
|
36
38
|
});
|
|
37
39
|
await c.refresh();
|
|
38
40
|
return { events: c.getEvents(), selected: c.getSelectedIds('src') };
|