@remit/ui 0.0.225 → 0.0.226

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.
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode, Ref } from "react";
2
2
  import { type CalendarFailure } from "./calendar-event-popup.js";
3
+ import { type CalendarSender, type GuestSuggestion } from "./calendar-guests.js";
3
4
  import type { CalendarDescriptor, EventDraft } from "./calendar-types.js";
4
5
  export interface CalendarEventSidebarProps {
5
6
  heading: string;
@@ -29,6 +30,16 @@ export interface CalendarEventSidebarProps {
29
30
  touch?: boolean;
30
31
  /** The scope question or the discard confirm, over the form. */
31
32
  children?: ReactNode;
33
+ /** Absent where the reader cannot change the guest list: an invitation from someone else. */
34
+ guests?: {
35
+ suggestions: readonly GuestSuggestion[];
36
+ onQuery: (query: string) => void;
37
+ senders: readonly CalendarSender[];
38
+ sender: string;
39
+ onSender: (accountId: string) => void;
40
+ /** A stored event keeps the organizer it was sent from. */
41
+ senderEditable: boolean;
42
+ };
32
43
  }
33
44
  /** The full editor beside the grid, after Google Calendar's event page. */
34
- export declare function CalendarEventSidebar({ heading, draft, onChange, calendars, calendarEditable, repeatEditable, timeZone, timeZones, onTimeZone, busy, onBusy, onSave, onCancel, saving, saveLabel, problem, failure, failureRef, titleRef, touch, children, }: CalendarEventSidebarProps): import("react").JSX.Element;
45
+ export declare function CalendarEventSidebar({ heading, draft, onChange, calendars, calendarEditable, repeatEditable, timeZone, timeZones, onTimeZone, busy, onBusy, onSave, onCancel, saving, saveLabel, problem, failure, failureRef, titleRef, touch, children, guests, }: CalendarEventSidebarProps): import("react").JSX.Element;
@@ -1,16 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { X } from "lucide-react";
3
3
  import { cn } from "../lib/cn.js";
4
+ import { invalidGuest } from "../lib/guest-list.js";
4
5
  import { CalendarFailureBlock, } from "./calendar-event-popup.js";
6
+ import { CalendarGuestsField, CalendarSenderField, } from "./calendar-guests.js";
5
7
  import { EventField, EventRepeatField, EventWhenField, endsBeforeStart, } from "./event-editor.js";
6
8
  const control = "h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60";
7
9
  /** The full editor beside the grid, after Google Calendar's event page. */
8
- export function CalendarEventSidebar({ heading, draft, onChange, calendars, calendarEditable, repeatEditable, timeZone, timeZones, onTimeZone, busy, onBusy, onSave, onCancel, saving = false, saveLabel = "Save", problem = "", failure, failureRef, titleRef, touch = false, children, }) {
10
+ export function CalendarEventSidebar({ heading, draft, onChange, calendars, calendarEditable, repeatEditable, timeZone, timeZones, onTimeZone, busy, onBusy, onSave, onCancel, saving = false, saveLabel = "Save", problem = "", failure, failureRef, titleRef, touch = false, children, guests, }) {
9
11
  const field = cn(control, touch && "h-11");
10
12
  const backwards = endsBeforeStart(draft);
13
+ const blocked = guests !== undefined && invalidGuest(draft.guests) !== undefined;
11
14
  return (_jsxs("form", { "aria-label": heading, "data-event-sidebar": "", className: "flex h-full min-h-0 flex-col bg-surface", onSubmit: (event) => {
12
15
  event.preventDefault();
13
- if (!saving && !backwards)
16
+ if (!saving && !backwards && !blocked)
14
17
  onSave();
15
- }, children: [_jsxs("div", { className: "flex shrink-0 items-center justify-between border-b border-line px-4 py-2", children: [_jsx("h2", { className: "text-base font-medium text-fg", children: heading }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onCancel, className: cn("flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-8"), children: _jsx(X, { className: "size-4" }) })] }), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4", children: [_jsx("input", { ref: titleRef, "aria-label": "Title", placeholder: "Add title", value: draft.title, onChange: (event) => onChange({ ...draft, title: event.target.value }), className: "border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent" }), _jsx(EventWhenField, { draft: draft, onChange: onChange, touch: touch }), _jsx(EventField, { label: "Time zone", children: _jsx("select", { "aria-label": "Time zone", value: timeZone, onChange: (event) => onTimeZone(event.target.value), className: field, children: timeZones.map((zone) => (_jsx("option", { value: zone, children: zone }, zone))) }) }), _jsx(EventField, { label: "Repeat", children: _jsx(EventRepeatField, { draft: draft, onChange: onChange, touch: touch, repeatEditable: repeatEditable }) }), _jsx(EventField, { label: "Calendar", children: _jsx("select", { "aria-label": "Calendar", value: draft.calendarId, disabled: !calendarEditable, onChange: (event) => onChange({ ...draft, calendarId: event.target.value }), className: field, children: calendars.map((calendar) => (_jsx("option", { value: calendar.id, children: calendar.name }, calendar.id))) }) }), _jsx(EventField, { label: "Location", children: _jsx("input", { "aria-label": "Location", placeholder: "Add location", value: draft.location, onChange: (event) => onChange({ ...draft, location: event.target.value }), className: field }) }), _jsx(EventField, { label: "Show as", children: _jsxs("select", { "aria-label": "Show as", value: busy ? "busy" : "free", onChange: (event) => onBusy(event.target.value === "busy"), className: field, children: [_jsx("option", { value: "busy", children: "Busy" }), _jsx("option", { value: "free", children: "Free" })] }) }), _jsx(EventField, { label: "Description", children: _jsx("textarea", { "aria-label": "Description", placeholder: "Add description", rows: 5, value: draft.notes, onChange: (event) => onChange({ ...draft, notes: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30" }) }), children] }), _jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-t border-line px-4 py-3", children: [problem !== "" && (_jsx("p", { role: "alert", className: "text-sm text-danger", children: problem })), failure && (_jsx(CalendarFailureBlock, { failure: failure, focusRef: failureRef })), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx("button", { type: "button", onClick: onCancel, className: cn("rounded-md border border-line px-4 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "Cancel" }), _jsx("button", { type: "submit", disabled: saving || backwards, className: cn("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", touch ? "min-h-11" : "h-9"), children: saving ? "Saving…" : saveLabel })] })] })] }));
18
+ }, children: [_jsxs("div", { className: "flex shrink-0 items-center justify-between border-b border-line px-4 py-2", children: [_jsx("h2", { className: "text-base font-medium text-fg", children: heading }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onCancel, className: cn("flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-8"), children: _jsx(X, { className: "size-4" }) })] }), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-4", children: [_jsx("input", { ref: titleRef, "aria-label": "Title", placeholder: "Add title", value: draft.title, onChange: (event) => onChange({ ...draft, title: event.target.value }), className: "border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent" }), _jsx(EventWhenField, { draft: draft, onChange: onChange, touch: touch }), _jsx(EventField, { label: "Time zone", children: _jsx("select", { "aria-label": "Time zone", value: timeZone, onChange: (event) => onTimeZone(event.target.value), className: field, children: timeZones.map((zone) => (_jsx("option", { value: zone, children: zone }, zone))) }) }), _jsx(EventField, { label: "Repeat", children: _jsx(EventRepeatField, { draft: draft, onChange: onChange, touch: touch, repeatEditable: repeatEditable }) }), _jsx(EventField, { label: "Calendar", children: _jsx("select", { "aria-label": "Calendar", value: draft.calendarId, disabled: !calendarEditable, onChange: (event) => onChange({ ...draft, calendarId: event.target.value }), className: field, children: calendars.map((calendar) => (_jsx("option", { value: calendar.id, children: calendar.name }, calendar.id))) }) }), _jsx(EventField, { label: "Location", children: _jsx("input", { "aria-label": "Location", placeholder: "Add location", value: draft.location, onChange: (event) => onChange({ ...draft, location: event.target.value }), className: field }) }), _jsx(EventField, { label: "Show as", children: _jsxs("select", { "aria-label": "Show as", value: busy ? "busy" : "free", onChange: (event) => onBusy(event.target.value === "busy"), className: field, children: [_jsx("option", { value: "busy", children: "Busy" }), _jsx("option", { value: "free", children: "Free" })] }) }), _jsx(EventField, { label: "Description", children: _jsx("textarea", { "aria-label": "Description", placeholder: "Add description", rows: 5, value: draft.notes, onChange: (event) => onChange({ ...draft, notes: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30" }) }), guests && (_jsx(EventField, { label: "Guests", children: _jsx(CalendarGuestsField, { value: draft.guests, onChange: (value) => onChange({ ...draft, guests: value }), suggestions: guests.suggestions, onQuery: guests.onQuery, touch: touch }) })), guests && draft.guests.length > 0 && guests.senders.length > 0 && (_jsxs(EventField, { label: "Send invitations from", children: [_jsx(CalendarSenderField, { label: "Send invitations from", senders: guests.senders, value: guests.sender, onChange: guests.onSender, disabled: !guests.senderEditable, touch: touch }), _jsx("p", { className: "mt-1 text-xs text-fg-muted", children: "Default set in Settings, Calendars" })] })), children] }), _jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-t border-line px-4 py-3", children: [problem !== "" && (_jsx("p", { role: "alert", className: "text-sm text-danger", children: problem })), failure && (_jsx(CalendarFailureBlock, { failure: failure, focusRef: failureRef })), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx("button", { type: "button", onClick: onCancel, className: cn("rounded-md border border-line px-4 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "Cancel" }), _jsx("button", { type: "submit", disabled: saving || backwards || blocked, className: cn("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", touch ? "min-h-11" : "h-9"), children: saving ? "Saving…" : saveLabel })] })] })] }));
16
19
  }
@@ -1,6 +1,6 @@
1
1
  import "../calendar.css";
2
2
  import type { Density } from "./app-shell-types.js";
3
- import type { CalendarColorId, CalendarEventData, CalendarSlotPick } from "./calendar-types.js";
3
+ import type { CalendarColorId, CalendarEventData, CalendarSlotPick, CalendarTaskData } from "./calendar-types.js";
4
4
  export interface CalendarGridProps {
5
5
  /** A day in the month on screen; changing it moves the grid. */
6
6
  date: string;
@@ -21,6 +21,9 @@ export interface CalendarGridProps {
21
21
  canMove?: (eventId: string) => boolean;
22
22
  /** A stored event dropped on other days, or stretched across more. */
23
23
  onMoveEvent?: (eventId: string, range: CalendarSlotPick) => void;
24
+ /** Tasks due in the month, each on its due day. */
25
+ tasks?: readonly CalendarTaskData[];
26
+ onSelectTask?: (calendarTaskId: string) => void;
24
27
  className?: string;
25
28
  }
26
- export declare function CalendarGrid({ date, events, colorByCalendarId, density, selectedEventId, timeZone, now, onSelectEvent, onPickSlot, dayHref, onZoomDay, canMove, onMoveEvent, className, }: CalendarGridProps): import("react").JSX.Element;
29
+ export declare function CalendarGrid({ date, events, colorByCalendarId, density, selectedEventId, timeZone, now, onSelectEvent, onPickSlot, dayHref, onZoomDay, canMove, onMoveEvent, tasks, onSelectTask, className, }: CalendarGridProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import "../calendar.css";
3
3
  import FullCalendar from "@fullcalendar/react";
4
4
  import dayGridPlugin from "@fullcalendar/react/daygrid";
@@ -39,19 +39,29 @@ const isModifiedClick = (click) => click.button !== 0 ||
39
39
  click.ctrlKey ||
40
40
  click.shiftKey ||
41
41
  click.altKey;
42
- export function CalendarGrid({ date, events, colorByCalendarId, density, selectedEventId, timeZone, now, onSelectEvent, onPickSlot, dayHref, onZoomDay, canMove = () => false, onMoveEvent, className, }) {
42
+ export function CalendarGrid({ date, events, colorByCalendarId, density, selectedEventId, timeZone, now, onSelectEvent, onPickSlot, dayHref, onZoomDay, canMove = () => false, onMoveEvent, tasks = [], onSelectTask, className, }) {
43
43
  const calendarRef = useRef(null);
44
44
  useEffect(() => {
45
45
  calendarRef.current?.getApi().gotoDate(date);
46
46
  }, [date]);
47
- const eventInputs = useMemo(() => events.map((event) => ({
48
- id: event.id,
49
- title: event.title,
50
- start: event.start,
51
- end: event.end,
52
- allDay: event.allDay,
53
- editable: onMoveEvent !== undefined && canMove(event.id),
54
- })), [events, canMove, onMoveEvent]);
47
+ const taskById = useMemo(() => new Map(tasks.map((task) => [task.calendarTaskId, task])), [tasks]);
48
+ const eventInputs = useMemo(() => [
49
+ ...events.map((event) => ({
50
+ id: event.id,
51
+ title: event.title,
52
+ start: event.start,
53
+ end: event.end,
54
+ allDay: event.allDay,
55
+ editable: onMoveEvent !== undefined && canMove(event.id),
56
+ })),
57
+ ...tasks.map((task) => ({
58
+ id: task.calendarTaskId,
59
+ title: task.title,
60
+ start: task.due,
61
+ allDay: task.allDay,
62
+ editable: false,
63
+ })),
64
+ ], [events, tasks, canMove, onMoveEvent]);
55
65
  const dropped = (info) => {
56
66
  info.revert();
57
67
  onMoveEvent?.(info.event.id, rangePick(info.event.startStr, info.event.endStr === "" ? info.event.startStr : info.event.endStr, info.event.allDay));
@@ -92,8 +102,10 @@ export function CalendarGrid({ date, events, colorByCalendarId, density, selecte
92
102
  for (const type of ["mousedown", "touchstart", "pointerdown"]) {
93
103
  link?.addEventListener(type, (press) => press.stopPropagation());
94
104
  }
95
- }, moreLinkClick: "popover", moreLinkText: (num) => `+${num}`, displayEventEnd: false, eventTimeFormat: { hour: "2-digit", minute: "2-digit", hour12: false }, dayHeaderFormat: { weekday: "short" }, events: eventInputs, eventClick: (info) => onSelectEvent(info.event.id), eventDrop: dropped, eventResize: dropped, eventDidMount: (info) => {
96
- info.el.setAttribute("data-event-id", info.event.id);
105
+ }, moreLinkClick: "popover", moreLinkText: (num) => `+${num}`, displayEventEnd: false, eventTimeFormat: { hour: "2-digit", minute: "2-digit", hour12: false }, dayHeaderFormat: { weekday: "short" }, events: eventInputs, eventClick: (info) => taskById.has(info.event.id)
106
+ ? onSelectTask?.(info.event.id)
107
+ : onSelectEvent(info.event.id), eventDrop: dropped, eventResize: dropped, eventDidMount: (info) => {
108
+ info.el.setAttribute(taskById.has(info.event.id) ? "data-task-id" : "data-event-id", info.event.id);
97
109
  },
98
110
  /* A point is `dateClick`'s and a dragged run of days is `select`'s;
99
111
  acting on both would report a point twice. */
@@ -114,6 +126,9 @@ export function CalendarGrid({ date, events, colorByCalendarId, density, selecte
114
126
  selected: info.event.id === selectedEventId,
115
127
  stacked: false,
116
128
  }), "my-px cursor-pointer px-1 py-0 outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring"), eventContent: (info) => {
129
+ const task = taskById.get(info.event.id);
130
+ if (task)
131
+ return (_jsxs("span", { className: cn("flex min-w-0 items-center gap-1 truncate", task.completed && "line-through opacity-60"), children: [_jsx("span", { "aria-hidden": "true", children: task.completed ? "☑" : "☐" }), _jsx("span", { className: "truncate", children: task.title === "" ? "(No title)" : task.title })] }));
117
132
  const event = lookup(info.event.id);
118
133
  return (_jsx(CalendarEventChipContent, { title: info.event.title, timeText: density === "compact" ? "" : info.timeText, layout: "row", rsvp: event.rsvp, hasThread: event.hasThread, isRecurring: event.isRecurring, zoneCertainty: event.zoneCertainty }));
119
134
  } }) }));
@@ -0,0 +1,80 @@
1
+ import { type GuestEntry } from "../lib/guest-list.js";
2
+ import { type CalendarFailure } from "./calendar-event-popup.js";
3
+ import type { CalendarAttendee, RsvpState } from "./calendar-types.js";
4
+ /** A contact the Guests field offers while the reader types. */
5
+ export interface GuestSuggestion {
6
+ email: string;
7
+ name: string;
8
+ }
9
+ export interface CalendarGuestsFieldProps {
10
+ value: readonly GuestEntry[];
11
+ onChange: (value: GuestEntry[]) => void;
12
+ /** Contacts matching what is being typed. */
13
+ suggestions: readonly GuestSuggestion[];
14
+ /** What is being typed, so the caller can look contacts up. */
15
+ onQuery: (query: string) => void;
16
+ touch?: boolean;
17
+ }
18
+ /**
19
+ * Guests as chips, added by typing an address or picking a contact. An entry
20
+ * that is not an address stays as a chip marked invalid and named under the
21
+ * field, so the reader fixes or removes it before the event can be saved.
22
+ */
23
+ export declare function CalendarGuestsField({ value, onChange, suggestions, onQuery, touch, }: CalendarGuestsFieldProps): import("react").JSX.Element;
24
+ /** One of the reader's accounts, as a sending-account list offers it. */
25
+ export interface CalendarSender {
26
+ accountId: string;
27
+ email: string;
28
+ }
29
+ export interface CalendarSenderFieldProps {
30
+ label: string;
31
+ senders: readonly CalendarSender[];
32
+ value: string;
33
+ onChange: (accountId: string) => void;
34
+ disabled?: boolean;
35
+ touch?: boolean;
36
+ }
37
+ /** The account an event's invitations go out from. */
38
+ export declare function CalendarSenderField({ label, senders, value, onChange, disabled, touch, }: CalendarSenderFieldProps): import("react").JSX.Element;
39
+ /** How many guests gave each answer, as the server counts them. */
40
+ export interface CalendarGuestCounts {
41
+ accepted: number;
42
+ declined: number;
43
+ tentative: number;
44
+ needsAction: number;
45
+ }
46
+ /**
47
+ * The guest list in the event popup: how many, how they answered, and who,
48
+ * with the organizer marked. Read-only: the guest list changes in the editor.
49
+ */
50
+ export declare function CalendarEventGuests({ attendees, counts, }: {
51
+ attendees: readonly CalendarAttendee[];
52
+ counts: CalendarGuestCounts;
53
+ }): import("react").JSX.Element | null;
54
+ /** An answer a guest can give. */
55
+ export type CalendarAnswer = "accepted" | "declined" | "tentative";
56
+ export interface CalendarReplyRowProps {
57
+ /** The answer the reader has given, `noReply` when none yet. */
58
+ current: RsvpState;
59
+ onAnswer: (answer: CalendarAnswer) => void;
60
+ sending?: boolean;
61
+ failure?: CalendarFailure;
62
+ }
63
+ /** `Going?` with Yes, No and Maybe, the current answer pressed. */
64
+ export declare function CalendarReplyRow({ current, onAnswer, sending, failure, }: CalendarReplyRowProps): import("react").JSX.Element;
65
+ export interface CalendarInvitationsNotSentProps {
66
+ /** The guests whose invitation, update or cancellation did not go out. */
67
+ missed: readonly string[];
68
+ onRetry: () => void;
69
+ reportHref: string;
70
+ onDismiss: () => void;
71
+ }
72
+ /** The event is saved; these guests were not reached. */
73
+ export declare function CalendarInvitationsNotSent({ missed, onRetry, reportHref, onDismiss, }: CalendarInvitationsNotSentProps): import("react").JSX.Element | null;
74
+ export interface CalendarCancellationsSentProps {
75
+ /** The guests a deleted event's cancellation is going to. */
76
+ guests: readonly string[];
77
+ onDismiss: () => void;
78
+ }
79
+ /** The event is deleted; these guests are being told. */
80
+ export declare function CalendarCancellationsSent({ guests, onDismiss, }: CalendarCancellationsSentProps): import("react").JSX.Element | null;
@@ -0,0 +1,102 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Check, CircleHelp, Clock3, Crown, X } from "lucide-react";
3
+ import { useId, useState } from "react";
4
+ import { cn } from "../lib/cn.js";
5
+ import { parseGuest, withGuest } from "../lib/guest-list.js";
6
+ import { CalendarFailureBlock, } from "./calendar-event-popup.js";
7
+ const chip = "inline-flex max-w-full items-center gap-1 rounded-full border px-2 py-0.5 text-sm";
8
+ /**
9
+ * Guests as chips, added by typing an address or picking a contact. An entry
10
+ * that is not an address stays as a chip marked invalid and named under the
11
+ * field, so the reader fixes or removes it before the event can be saved.
12
+ */
13
+ export function CalendarGuestsField({ value, onChange, suggestions, onQuery, touch = false, }) {
14
+ const listId = useId();
15
+ const noteId = useId();
16
+ const [draft, setDraft] = useState("");
17
+ const guests = value;
18
+ const invalid = guests.find((guest) => !guest.valid);
19
+ const commit = (text) => {
20
+ if (text.trim() === "")
21
+ return;
22
+ const picked = suggestions.find((suggestion) => suggestion.email === text.trim().toLowerCase());
23
+ const entry = picked
24
+ ? parseGuest(picked.name === ""
25
+ ? picked.email
26
+ : `${picked.name} <${picked.email}>`)
27
+ : parseGuest(text);
28
+ onChange(withGuest(guests, entry));
29
+ setDraft("");
30
+ onQuery("");
31
+ };
32
+ const remove = (guest) => onChange(guests.filter((other) => other !== guest));
33
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [guests.length > 0 && (_jsx("ul", { "aria-label": "Guests", className: "flex flex-wrap gap-1.5", children: guests.map((guest) => (_jsxs("li", { className: cn(chip, guest.valid
34
+ ? "border-line bg-surface-sunken text-fg"
35
+ : "border-danger bg-danger-soft text-danger"), children: [_jsx("span", { className: "truncate", children: guest.valid ? guest.displayName : guest.text }), _jsx("button", { type: "button", "aria-label": `Remove ${guest.valid ? guest.email : guest.text}`, onClick: () => remove(guest), className: "rounded-full p-0.5 hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-3" }) })] }, guest.text))) })), _jsx("input", { "aria-label": "Guests", "aria-describedby": invalid ? noteId : undefined, "aria-invalid": invalid ? true : undefined, placeholder: "Add guests", list: listId, value: draft, onChange: (event) => {
36
+ const text = event.target.value;
37
+ if (/[,;]$/.test(text)) {
38
+ commit(text.slice(0, -1));
39
+ return;
40
+ }
41
+ setDraft(text);
42
+ onQuery(text);
43
+ }, onKeyDown: (event) => {
44
+ if (event.key !== "Enter" || draft.trim() === "")
45
+ return;
46
+ event.preventDefault();
47
+ commit(draft);
48
+ }, onBlur: () => commit(draft), className: cn("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30", touch && "h-11") }), _jsx("datalist", { id: listId, children: suggestions.map((suggestion) => (_jsx("option", { value: suggestion.email, children: suggestion.name }, suggestion.email))) }), invalid && (_jsxs("p", { id: noteId, role: "status", className: "text-sm text-danger", children: [invalid.text, " is not an email address. Fix or remove it to save."] }))] }));
49
+ }
50
+ /** The account an event's invitations go out from. */
51
+ export function CalendarSenderField({ label, senders, value, onChange, disabled = false, touch = false, }) {
52
+ return (_jsx("select", { "aria-label": label, value: value, disabled: disabled, onChange: (event) => onChange(event.target.value), className: cn("h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30 disabled:opacity-60", touch && "h-11"), children: senders.map((sender) => (_jsx("option", { value: sender.accountId, children: sender.email }, sender.accountId))) }));
53
+ }
54
+ const TALLY_WORDS = [
55
+ ["accepted", "yes"],
56
+ ["declined", "no"],
57
+ ["tentative", "maybe"],
58
+ ["needsAction", "awaiting"],
59
+ ];
60
+ const tallyOf = (counts) => TALLY_WORDS.flatMap(([answer, word]) => counts[answer] === 0 ? [] : [`${counts[answer]} ${word}`]).join(", ");
61
+ const answerMark = (rsvp) => {
62
+ if (rsvp === "accepted")
63
+ return _jsx(Check, { className: "size-3.5 text-positive", "aria-label": "Yes" });
64
+ if (rsvp === "declined")
65
+ return _jsx(X, { className: "size-3.5 text-danger", "aria-label": "No" });
66
+ if (rsvp === "tentative")
67
+ return _jsx(CircleHelp, { className: "size-3.5 text-fg-muted", "aria-label": "Maybe" });
68
+ return _jsx(Clock3, { className: "size-3.5 text-fg-subtle", "aria-label": "Awaiting" });
69
+ };
70
+ /**
71
+ * The guest list in the event popup: how many, how they answered, and who,
72
+ * with the organizer marked. Read-only: the guest list changes in the editor.
73
+ */
74
+ export function CalendarEventGuests({ attendees, counts, }) {
75
+ if (attendees.length === 0)
76
+ return null;
77
+ return (_jsxs("section", { "aria-label": "Guests", className: "flex flex-col gap-1.5 px-2 text-sm", children: [_jsxs("p", { className: "font-medium text-fg", children: [attendees.length, " ", attendees.length === 1 ? "guest" : "guests"] }), _jsx("p", { className: "text-fg-muted", children: tallyOf(counts) }), _jsx("ul", { className: "flex flex-col gap-1", children: attendees.map((attendee) => (_jsxs("li", { className: "flex items-center gap-2", children: [answerMark(attendee.rsvp), _jsx("span", { className: "min-w-0 truncate", children: attendee.name === "" ? attendee.email : attendee.name }), attendee.role === "organizer" && (_jsxs("span", { className: "inline-flex items-center gap-0.5 text-xs text-fg-muted", children: [_jsx(Crown, { className: "size-3", "aria-hidden": "true" }), "Organizer"] }))] }, attendee.email))) })] }));
78
+ }
79
+ const ANSWERS = [
80
+ ["accepted", "Yes"],
81
+ ["declined", "No"],
82
+ ["tentative", "Maybe"],
83
+ ];
84
+ /** `Going?` with Yes, No and Maybe, the current answer pressed. */
85
+ export function CalendarReplyRow({ current, onAnswer, sending = false, failure, }) {
86
+ return (_jsxs("div", { className: "flex flex-col gap-2 border-t border-line px-2 pt-3", children: [_jsxs("fieldset", { className: "flex items-center gap-2", children: [_jsx("legend", { className: "sr-only", children: "Going?" }), _jsx("span", { "aria-hidden": "true", className: "mr-1 text-sm text-fg", children: "Going?" }), ANSWERS.map(([answer, label]) => (_jsx("button", { type: "button", "aria-pressed": current === answer, disabled: sending, onClick: () => onAnswer(answer), className: cn("h-8 rounded-full border px-3 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60", current === answer
87
+ ? "border-accent bg-accent text-accent-fg"
88
+ : "border-line hover:bg-surface-sunken"), children: label }, answer)))] }), failure && _jsx(CalendarFailureBlock, { failure: failure })] }));
89
+ }
90
+ /** The event is saved; these guests were not reached. */
91
+ export function CalendarInvitationsNotSent({ missed, onRetry, reportHref, onDismiss, }) {
92
+ if (missed.length === 0)
93
+ return null;
94
+ const names = missed.join(", ");
95
+ return (_jsxs("div", { role: "alert", className: "flex flex-wrap items-center gap-3 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm", children: [_jsxs("p", { className: "text-danger", children: ["Saved, but the ", missed.length === 1 ? "invitation" : "invitations", " to", " ", names, " didn't go out."] }), _jsx("button", { type: "button", onClick: onRetry, className: "rounded-md border border-line bg-surface px-3 py-1 font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", children: "Try again" }), _jsx("a", { href: reportHref, target: "_blank", rel: "noreferrer", className: "font-medium text-accent hover:underline", children: "Report an issue" }), _jsx("button", { type: "button", "aria-label": "Dismiss", onClick: onDismiss, className: "ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) })] }));
96
+ }
97
+ /** The event is deleted; these guests are being told. */
98
+ export function CalendarCancellationsSent({ guests, onDismiss, }) {
99
+ if (guests.length === 0)
100
+ return null;
101
+ return (_jsxs("div", { role: "status", className: "flex flex-wrap items-center gap-3 rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm", children: [_jsxs("p", { className: "text-fg", children: ["Deleted. A cancellation is going to ", guests.join(", "), "."] }), _jsx("button", { type: "button", "aria-label": "Dismiss", onClick: onDismiss, className: "ml-auto rounded-full p-1 text-fg-muted hover:bg-surface focus-visible:ring-2 focus-visible:ring-ring", children: _jsx(X, { className: "size-4" }) })] }));
102
+ }
@@ -1,17 +1,35 @@
1
1
  import type { PointerEvent, Ref } from "react";
2
+ import { type GuestEntry } from "../lib/guest-list.js";
2
3
  import { type CalendarFailure } from "./calendar-event-popup.js";
4
+ import { type GuestSuggestion } from "./calendar-guests.js";
5
+ import type { CalendarTaskFields } from "./calendar-task-popup.js";
3
6
  import type { CalendarDescriptor, CalendarSlotPick } from "./calendar-types.js";
4
7
  export interface QuickCreateFields {
5
8
  title: string;
6
9
  range: CalendarSlotPick;
7
10
  location: string;
8
11
  calendarId: string;
12
+ guests: GuestEntry[];
9
13
  }
14
+ /** A new task: a due date with an optional time, in a task list. */
15
+ export interface QuickTaskFields extends CalendarTaskFields {
16
+ calendarId: string;
17
+ }
18
+ /** What the card is making: an event over the range, or a task due on its day. */
19
+ export type QuickCreateMode = "event" | "task";
10
20
  export interface CalendarQuickCreateCardProps {
11
21
  headingId: string;
22
+ mode: QuickCreateMode;
23
+ onMode: (mode: QuickCreateMode) => void;
12
24
  fields: QuickCreateFields;
25
+ taskFields: QuickTaskFields;
26
+ onTaskChange: (fields: QuickTaskFields) => void;
13
27
  /** Only the calendars that accept writes. */
14
28
  calendars: readonly CalendarDescriptor[];
29
+ /** The lists a task can go into. */
30
+ taskLists: readonly CalendarDescriptor[];
31
+ guestSuggestions: readonly GuestSuggestion[];
32
+ onGuestQuery: (query: string) => void;
15
33
  onChange: (fields: QuickCreateFields) => void;
16
34
  onSave: () => void;
17
35
  onMoreOptions: () => void;
@@ -32,4 +50,4 @@ export interface CalendarQuickCreateCardProps {
32
50
  touch?: boolean;
33
51
  }
34
52
  /** Google Calendar's small create popup: title, when, where, which calendar. */
35
- export declare function CalendarQuickCreateCard({ headingId, fields, calendars, onChange, onSave, onMoreOptions, onClose, saving, problem, failure, failureRef, titleRef, settingsHref, dragHandle, touch, }: CalendarQuickCreateCardProps): import("react").JSX.Element;
53
+ export declare function CalendarQuickCreateCard({ headingId, mode, onMode, fields, taskFields, onTaskChange, calendars, taskLists, guestSuggestions, onGuestQuery, onChange, onSave, onMoreOptions, onClose, saving, problem, failure, failureRef, titleRef, settingsHref, dragHandle, touch, }: CalendarQuickCreateCardProps): import("react").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { GripHorizontal, X } from "lucide-react";
3
3
  import { cn } from "../lib/cn.js";
4
+ import { invalidGuest } from "../lib/guest-list.js";
4
5
  import { CalendarFailureBlock, } from "./calendar-event-popup.js";
6
+ import { CalendarGuestsField, } from "./calendar-guests.js";
5
7
  const field = "h-9 rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30";
6
8
  const withRange = (fields, patch) => {
7
9
  const range = { ...fields.range, ...patch };
@@ -12,15 +14,30 @@ const withRange = (fields, patch) => {
12
14
  return { ...fields, range };
13
15
  };
14
16
  /** Google Calendar's small create popup: title, when, where, which calendar. */
15
- export function CalendarQuickCreateCard({ headingId, fields, calendars, onChange, onSave, onMoreOptions, onClose, saving = false, problem = "", failure, failureRef, titleRef, settingsHref, dragHandle, touch = false, }) {
16
- const noWritable = calendars.length === 0;
17
+ export function CalendarQuickCreateCard({ headingId, mode, onMode, fields, taskFields, onTaskChange, calendars, taskLists, guestSuggestions, onGuestQuery, onChange, onSave, onMoreOptions, onClose, saving = false, problem = "", failure, failureRef, titleRef, settingsHref, dragHandle, touch = false, }) {
18
+ const isTask = mode === "task";
19
+ const lists = isTask ? taskLists : calendars;
20
+ const noWritable = lists.length === 0;
21
+ const blocked = !isTask && invalidGuest(fields.guests) !== undefined;
17
22
  const control = cn(field, touch && "h-11");
23
+ const title = isTask ? taskFields.title : fields.title;
24
+ const setTitle = (next) => isTask
25
+ ? onTaskChange({ ...taskFields, title: next })
26
+ : onChange({ ...fields, title: next });
18
27
  return (_jsxs("form", { className: "relative flex flex-col", onSubmit: (event) => {
19
28
  event.preventDefault();
20
- if (!noWritable && !saving)
29
+ if (!noWritable && !saving && !blocked)
21
30
  onSave();
22
- }, children: [_jsxs("div", { onPointerDown: dragHandle?.onPointerDown, className: cn("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1", dragHandle && "cursor-grab"), children: [_jsx(GripHorizontal, { className: "size-4 text-fg-subtle", "aria-hidden": "true" }), _jsx("h2", { id: headingId, className: "sr-only", children: "New event" })] }), _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("input", { ref: titleRef, "aria-label": "Title", placeholder: "Add title", value: fields.title, onChange: (event) => onChange({ ...fields, title: event.target.value }), className: cn("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent") }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx("input", { type: "date", "aria-label": "Date", value: fields.range.date, onChange: (event) => event.target.value !== "" &&
31
+ }, children: [_jsxs("div", { onPointerDown: dragHandle?.onPointerDown, className: cn("flex items-center justify-between rounded-t-xl bg-surface-sunken px-2 py-1", dragHandle && "cursor-grab"), children: [_jsx(GripHorizontal, { className: "size-4 text-fg-subtle", "aria-hidden": "true" }), _jsx("h2", { id: headingId, className: "sr-only", children: isTask ? "New task" : "New event" })] }), _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("input", { ref: titleRef, "aria-label": "Title", placeholder: "Add title", value: title, onChange: (event) => setTitle(event.target.value), className: cn("border-b-2 border-line bg-transparent pb-1 text-xl text-fg outline-none placeholder:text-fg-subtle focus:border-accent") }), _jsxs("fieldset", { className: "flex gap-1 self-start rounded-md bg-surface-sunken p-0.5 text-sm", children: [_jsx("legend", { className: "sr-only", children: "Kind" }), ["event", "task"].map((kind) => (_jsxs("label", { className: cn("cursor-pointer rounded px-3 py-1 font-medium has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring", mode === kind
32
+ ? "bg-surface text-fg shadow-sm"
33
+ : "text-fg-muted", touch && "min-h-11"), children: [_jsx("input", { type: "radio", name: `${headingId}-kind`, value: kind, checked: mode === kind, onChange: () => onMode(kind), className: "sr-only" }), kind === "event" ? "Event" : "Task"] }, kind)))] }), isTask ? (_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx("span", { className: "text-fg-muted", children: "Due" }), _jsx("input", { type: "date", "aria-label": "Due date", value: taskFields.dueDate, onChange: (event) => event.target.value !== "" &&
34
+ onTaskChange({ ...taskFields, dueDate: event.target.value }), className: control }), taskFields.dueTime === "" ? (_jsx("button", { type: "button", onClick: () => onTaskChange({ ...taskFields, dueTime: "09:00" }), className: "rounded-md px-2 font-medium text-accent hover:bg-accent-soft", children: "Add time" })) : (_jsx("input", { type: "time", "aria-label": "Due time", step: 900, value: taskFields.dueTime, onChange: (event) => onTaskChange({ ...taskFields, dueTime: event.target.value }), className: control }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx("input", { type: "date", "aria-label": "Date", value: fields.range.date, onChange: (event) => event.target.value !== "" &&
23
35
  onChange(withRange(fields, { date: event.target.value })), className: control }), fields.range.allDay ? (_jsx("span", { className: "text-fg-muted", children: "All day" })) : (_jsxs(_Fragment, { children: [_jsx("input", { type: "time", "aria-label": "Start time", step: 900, value: fields.range.startTime, onChange: (event) => event.target.value !== "" &&
24
36
  onChange(withRange(fields, { startTime: event.target.value })), className: control }), _jsx("span", { "aria-hidden": "true", children: "\u2013" }), _jsx("input", { type: "time", "aria-label": "End time", step: 900, value: fields.range.endTime, onChange: (event) => event.target.value !== "" &&
25
- onChange(withRange(fields, { endTime: event.target.value })), className: control })] }))] }), _jsx("input", { "aria-label": "Location", placeholder: "Add location", value: fields.location, onChange: (event) => onChange({ ...fields, location: event.target.value }), className: control }), noWritable ? (_jsxs("p", { role: "status", tabIndex: -1, className: "text-sm text-fg-muted", children: ["None of your calendars accepts new events.", " ", _jsx("a", { href: settingsHref, className: "font-medium text-accent hover:underline", children: "Calendar settings" })] })) : (_jsx("select", { "aria-label": "Calendar", value: fields.calendarId, onChange: (event) => onChange({ ...fields, calendarId: event.target.value }), className: control, children: calendars.map((calendar) => (_jsx("option", { value: calendar.id, children: calendar.name }, calendar.id))) })), problem !== "" && (_jsx("p", { className: "text-sm text-danger", role: "status", children: problem })), failure && (_jsx(CalendarFailureBlock, { failure: failure, focusRef: failureRef }))] }), _jsxs("div", { className: "flex items-center justify-between px-4 pb-4", children: [_jsx("button", { type: "button", onClick: onMoreOptions, className: cn("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "More options" }), _jsx("button", { type: "submit", disabled: noWritable || saving, className: cn("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", touch ? "min-h-11" : "h-9"), children: saving ? "Saving…" : "Save" })] }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: cn("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-8"), children: _jsx(X, { className: "size-4" }) })] }));
37
+ onChange(withRange(fields, { endTime: event.target.value })), className: control })] }))] })), !isTask && (_jsx(CalendarGuestsField, { value: fields.guests, onChange: (guests) => onChange({ ...fields, guests }), suggestions: guestSuggestions, onQuery: onGuestQuery, touch: touch })), isTask ? (_jsx("textarea", { "aria-label": "Description", placeholder: "Add description", rows: 2, value: taskFields.description, onChange: (event) => onTaskChange({ ...taskFields, description: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30" })) : (_jsx("input", { "aria-label": "Location", placeholder: "Add location", value: fields.location, onChange: (event) => onChange({ ...fields, location: event.target.value }), className: control })), noWritable ? (_jsxs("p", { role: "status", tabIndex: -1, className: "text-sm text-fg-muted", children: ["None of your calendars accepts new events.", " ", _jsx("a", { href: settingsHref, className: "font-medium text-accent hover:underline", children: "Calendar settings" })] })) : (_jsx("select", { "aria-label": isTask ? "Task list" : "Calendar", value: isTask ? taskFields.calendarId : fields.calendarId, onChange: (event) => isTask
38
+ ? onTaskChange({
39
+ ...taskFields,
40
+ calendarId: event.target.value,
41
+ })
42
+ : onChange({ ...fields, calendarId: event.target.value }), className: control, children: lists.map((calendar) => (_jsx("option", { value: calendar.id, children: calendar.name }, calendar.id))) })), problem !== "" && (_jsx("p", { className: "text-sm text-danger", role: "status", children: problem })), failure && (_jsx(CalendarFailureBlock, { failure: failure, focusRef: failureRef }))] }), _jsxs("div", { className: "flex items-center justify-between px-4 pb-4", children: [isTask ? (_jsx("span", {})) : (_jsx("button", { type: "button", onClick: onMoreOptions, className: cn("rounded-md px-3 text-sm font-medium text-accent outline-none hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring", touch ? "min-h-11" : "h-9"), children: "More options" })), _jsx("button", { type: "submit", disabled: noWritable || saving || blocked, className: cn("rounded-md bg-accent px-5 text-sm font-medium text-accent-fg outline-none hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", touch ? "min-h-11" : "h-9"), children: saving ? "Saving…" : "Save" })] }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: cn("absolute top-0 right-1 flex items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface hover:text-fg focus-visible:ring-2 focus-visible:ring-ring", touch ? "size-11" : "size-8"), children: _jsx(X, { className: "size-4" }) })] }));
26
43
  }
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ export interface CalendarSuggestionListItem {
3
+ id: string;
4
+ card: ReactNode;
5
+ }
6
+ export interface CalendarSuggestionListProps {
7
+ items: readonly CalendarSuggestionListItem[];
8
+ className?: string;
9
+ }
10
+ /** Readings waiting on a decision, one under the other, each with its own buttons. */
11
+ export declare function CalendarSuggestionList({ items, className, }: CalendarSuggestionListProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Sparkles } from "lucide-react";
3
+ import { cn } from "../lib/cn.js";
4
+ /** Readings waiting on a decision, one under the other, each with its own buttons. */
5
+ export function CalendarSuggestionList({ items, className, }) {
6
+ if (items.length === 0)
7
+ return (_jsxs("div", { className: cn("flex flex-col items-center gap-2 p-6 text-center", className), children: [_jsx(Sparkles, { className: "size-6 text-fg-subtle", "aria-hidden": true }), _jsx("p", { className: "text-sm text-fg-muted", children: "Nothing in your mail is waiting on a decision about time." })] }));
8
+ return (_jsx("ul", { "aria-label": "Suggested events", className: cn("flex min-h-0 flex-col gap-3 overflow-y-auto", className), children: items.map((item) => (_jsx("li", { children: item.card }, item.id))) }));
9
+ }
@@ -0,0 +1,28 @@
1
+ import { type Ref } from "react";
2
+ import { type CalendarFailure } from "./calendar-event-popup.js";
3
+ /** A task's editable fields, in the form the popup edits them. */
4
+ export interface CalendarTaskFields {
5
+ title: string;
6
+ /** `YYYY-MM-DD`. */
7
+ dueDate: string;
8
+ /** `HH:MM`, empty for a task due on a day. */
9
+ dueTime: string;
10
+ description: string;
11
+ }
12
+ export interface CalendarTaskPopupCardProps {
13
+ headingId: string;
14
+ headingRef?: Ref<HTMLHeadingElement>;
15
+ fields: CalendarTaskFields;
16
+ /** "Due Thursday 5 November". */
17
+ dueText: string;
18
+ listName: string;
19
+ completed: boolean;
20
+ onToggle: () => void;
21
+ onSave: (fields: CalendarTaskFields) => void;
22
+ onDelete: () => void;
23
+ onClose: () => void;
24
+ busy?: boolean;
25
+ failure?: CalendarFailure;
26
+ }
27
+ /** A task's popup: title, due date, list and description, with Mark done, Edit and Delete. */
28
+ export declare function CalendarTaskPopupCard({ headingId, headingRef, fields, dueText, listName, completed, onToggle, onSave, onDelete, onClose, busy, failure, }: CalendarTaskPopupCardProps): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CalendarDays, CheckSquare, Square, Trash2, X } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { cn } from "../lib/cn.js";
5
+ import { CalendarFailureBlock, } from "./calendar-event-popup.js";
6
+ const iconButton = "flex size-9 items-center justify-center rounded-full text-fg-muted outline-none hover:bg-surface-sunken hover:text-fg focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";
7
+ const field = "h-9 w-full rounded-md border border-line bg-surface-sunken px-2 text-sm text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring/30";
8
+ /** A task's popup: title, due date, list and description, with Mark done, Edit and Delete. */
9
+ export function CalendarTaskPopupCard({ headingId, headingRef, fields, dueText, listName, completed, onToggle, onSave, onDelete, onClose, busy = false, failure, }) {
10
+ const [editing, setEditing] = useState(null);
11
+ return (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsxs("div", { className: "flex justify-end gap-1", children: [editing === null && (_jsx("button", { type: "button", onClick: () => setEditing(fields), className: "rounded-md px-3 text-sm font-medium text-accent hover:bg-accent-soft focus-visible:ring-2 focus-visible:ring-ring", children: "Edit" })), _jsx("button", { type: "button", "aria-label": "Delete", onClick: onDelete, disabled: busy, className: iconButton, children: _jsx(Trash2, { className: "size-4" }) }), _jsx("button", { type: "button", "aria-label": "Close", onClick: onClose, className: iconButton, children: _jsx(X, { className: "size-4" }) })] }), editing === null ? (_jsxs("div", { className: "flex flex-col gap-2 px-2", children: [_jsx("h2", { id: headingId, ref: headingRef, tabIndex: -1, className: cn("text-xl font-normal break-words text-fg outline-none", completed && "text-fg-muted line-through"), children: fields.title === "" ? "(No title)" : fields.title }), _jsx("p", { className: "text-sm text-fg-muted", children: dueText }), _jsxs("p", { className: "flex items-center gap-2 text-sm", children: [_jsx(CalendarDays, { className: "size-4 text-fg-subtle", "aria-label": "List" }), listName] }), fields.description !== "" && (_jsx("p", { className: "text-sm whitespace-pre-wrap break-words", children: fields.description }))] })) : (_jsxs("form", { className: "flex flex-col gap-2 px-2", onSubmit: (event) => {
12
+ event.preventDefault();
13
+ onSave(editing);
14
+ setEditing(null);
15
+ }, children: [_jsx("h2", { id: headingId, className: "sr-only", children: "Edit task" }), _jsx("input", { "aria-label": "Title", value: editing.title, onChange: (event) => setEditing({ ...editing, title: event.target.value }), className: field }), _jsxs("div", { className: "flex gap-2", children: [_jsx("input", { type: "date", "aria-label": "Due date", value: editing.dueDate, onChange: (event) => event.target.value !== "" &&
16
+ setEditing({ ...editing, dueDate: event.target.value }), className: field }), _jsx("input", { type: "time", "aria-label": "Due time", value: editing.dueTime, onChange: (event) => setEditing({ ...editing, dueTime: event.target.value }), className: field })] }), _jsx("textarea", { "aria-label": "Description", rows: 3, value: editing.description, onChange: (event) => setEditing({ ...editing, description: event.target.value }), className: "w-full rounded-md border border-line bg-surface-sunken px-2 py-1 text-sm" }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsx("button", { type: "button", onClick: () => setEditing(null), className: "h-9 rounded-md border border-line px-3 text-sm font-medium", children: "Cancel" }), _jsx("button", { type: "submit", disabled: busy, className: "h-9 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg disabled:opacity-50", children: "Save" })] })] })), failure && _jsx(CalendarFailureBlock, { failure: failure }), editing === null && (_jsx("div", { className: "flex justify-end px-2", children: _jsxs("button", { type: "button", onClick: onToggle, disabled: busy, className: "inline-flex h-9 items-center gap-2 rounded-md border border-line px-3 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50", children: [completed ? (_jsx(Square, { className: "size-4", "aria-hidden": "true" })) : (_jsx(CheckSquare, { className: "size-4", "aria-hidden": "true" })), completed ? "Mark not done" : "Mark done"] }) }))] }));
17
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Density } from "./app-shell-types.js";
2
- import type { CalendarColorId, CalendarEventData, CalendarSlotPick } from "./calendar-types.js";
2
+ import type { CalendarColorId, CalendarEventData, CalendarSlotPick, CalendarTaskData } from "./calendar-types.js";
3
3
  /** What a reader did on the grid, for whoever holds the draft to decide. */
4
4
  export type GridGesture = {
5
5
  type: "drag";
@@ -51,6 +51,12 @@ export interface CalendarTimeGridProps {
51
51
  canMove?: (eventId: string) => boolean;
52
52
  /** A stored event dropped at a new time or with a new end. */
53
53
  onMoveEvent?: (eventId: string, range: CalendarSlotPick) => void;
54
+ /** Tasks due in the days on screen, drawn in the all-day row of their day. */
55
+ tasks?: readonly CalendarTaskData[];
56
+ selectedTaskId?: string;
57
+ onSelectTask?: (calendarTaskId: string) => void;
58
+ /** Ticks or unticks a task drawn on the grid. */
59
+ onToggleTask?: (calendarTaskId: string) => void;
54
60
  className?: string;
55
61
  }
56
62
  /** "Wednesday 4 November, 08:00 to 09:45", for the live region and the focused slot. */
@@ -61,4 +67,4 @@ export declare function describeRange(range: CalendarSlotPick): string;
61
67
  * Every gesture leaves through `onGesture`; the grid only draws the draft it
62
68
  * is handed.
63
69
  */
64
- export declare function CalendarTimeGrid({ days, events, colorByCalendarId, density, timeZone, now, selectedEventId, draft, onGesture, onSelectEvent, onOpenDay, touch, canMove, onMoveEvent, className, }: CalendarTimeGridProps): import("react").JSX.Element;
70
+ export declare function CalendarTimeGrid({ days, events, colorByCalendarId, density, timeZone, now, selectedEventId, draft, onGesture, onSelectEvent, onOpenDay, touch, canMove, onMoveEvent, tasks, selectedTaskId, onSelectTask, onToggleTask, className, }: CalendarTimeGridProps): import("react").JSX.Element;
@@ -46,7 +46,7 @@ function zoneLabel(timeZone, now) {
46
46
  * Every gesture leaves through `onGesture`; the grid only draws the draft it
47
47
  * is handed.
48
48
  */
49
- export function CalendarTimeGrid({ days, events, colorByCalendarId, density, timeZone, now, selectedEventId = "", draft, onGesture, onSelectEvent, onOpenDay, touch = false, canMove = () => false, onMoveEvent, className, }) {
49
+ export function CalendarTimeGrid({ days, events, colorByCalendarId, density, timeZone, now, selectedEventId = "", draft, onGesture, onSelectEvent, onOpenDay, touch = false, canMove = () => false, onMoveEvent, tasks = [], selectedTaskId = "", onSelectTask, onToggleTask, className, }) {
50
50
  const hourHeight = HOUR_HEIGHT[density];
51
51
  const scrollRef = useRef(null);
52
52
  const columnsRef = useRef(null);
@@ -68,11 +68,28 @@ export function CalendarTimeGrid({ days, events, colorByCalendarId, density, tim
68
68
  const timed = zoned.filter((entry) => !entry.event.allDay);
69
69
  const allDay = zoned.filter((entry) => entry.event.allDay);
70
70
  const byId = useMemo(() => new Map(zoned.map((entry) => [entry.event.id, entry.event])), [zoned]);
71
- const bars = layoutAllDay(days, allDay.map((entry) => ({
72
- id: entry.event.id,
73
- first: entry.event.start.slice(0, 10),
74
- last: lastDayOf(entry.event),
75
- })));
71
+ const dueDays = useMemo(() => new Map(tasks.map((task) => [
72
+ task.calendarTaskId,
73
+ {
74
+ task,
75
+ date: task.allDay
76
+ ? task.due.slice(0, 10)
77
+ : zonedMoment(task.due, timeZone).date,
78
+ minute: task.allDay ? 0 : zonedMoment(task.due, timeZone).minute,
79
+ },
80
+ ])), [tasks, timeZone]);
81
+ const bars = layoutAllDay(days, [
82
+ ...allDay.map((entry) => ({
83
+ id: entry.event.id,
84
+ first: entry.event.start.slice(0, 10),
85
+ last: lastDayOf(entry.event),
86
+ })),
87
+ ...[...dueDays.values()].map(({ task, date }) => ({
88
+ id: task.calendarTaskId,
89
+ first: date,
90
+ last: date,
91
+ })),
92
+ ]);
76
93
  const draftBar = draft?.range.allDay === true
77
94
  ? layoutAllDay(days, [
78
95
  { id: "draft", first: draft.range.date, last: draft.range.endDate },
@@ -524,6 +541,20 @@ export function CalendarTimeGrid({ days, events, colorByCalendarId, density, tim
524
541
  ? "inset-x-0 bottom-0 h-1.5 cursor-ns-resize"
525
542
  : "inset-y-0 right-0 w-1.5 cursor-ew-resize"), style: { touchAction: "none" } }))] }));
526
543
  };
544
+ const taskChip = (task, minute) => {
545
+ const title = task.title === "" ? "(No title)" : task.title;
546
+ const color = colorByCalendarId[task.calendarId] ?? FALLBACK_COLOR;
547
+ const timeText = minute === undefined ? "" : clock(minute);
548
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "data-task-id": task.calendarTaskId, onPointerDown: (press) => press.stopPropagation(), onClick: () => onSelectTask?.(task.calendarTaskId), "aria-label": `Task: ${title}${timeText === "" ? "" : `, due ${timeText}`}`, className: cn(calendarEventBodyClasses({
549
+ color,
550
+ layout: "row",
551
+ density: "compact",
552
+ rsvp: "accepted",
553
+ status: "confirmed",
554
+ selected: task.calendarTaskId === selectedTaskId,
555
+ stacked: false,
556
+ }), "h-full w-full cursor-pointer truncate pl-5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring", task.completed && "line-through opacity-60"), children: timeText === "" ? title : `${timeText} ${title}` }), _jsx("input", { type: "checkbox", "aria-label": title, checked: task.completed, onPointerDown: (press) => press.stopPropagation(), onChange: () => onToggleTask?.(task.calendarTaskId), className: "absolute top-1 left-1.5 z-10 size-3.5 accent-current" })] }));
557
+ };
527
558
  const ghostLabel = (range) => range.allDay
528
559
  ? dayLabel(range.date, { weekday: "short", day: "numeric" })
529
560
  : `${dayLabel(range.date, { weekday: "short", day: "numeric" })} · ${range.startTime} – ${range.endTime}`;
@@ -557,14 +588,18 @@ export function CalendarTimeGrid({ days, events, colorByCalendarId, density, tim
557
588
  gridTemplateColumns: `repeat(${days.length}, minmax(0, 1fr))`,
558
589
  }, children: days.map((date) => (_jsx("div", { className: "border-l border-line" }, date))) }), bars.map((bar) => {
559
590
  const event = byId.get(bar.id);
560
- if (!event)
591
+ const due = dueDays.get(bar.id);
592
+ if (!event && !due)
561
593
  return null;
562
594
  return (_jsx("div", { className: "absolute px-0.5", style: {
563
595
  left: `${(bar.startIndex / days.length) * 100}%`,
564
596
  width: `${(bar.span / days.length) * 100}%`,
565
597
  top: 2 + bar.lane * ALL_DAY_LANE,
566
598
  height: ALL_DAY_LANE - 2,
567
- }, children: chip(event, "row", false) }, bar.id));
599
+ }, children: event
600
+ ? chip(event, "row", false)
601
+ : due &&
602
+ taskChip(due.task, due.task.allDay ? undefined : due.minute) }, bar.id));
568
603
  }), lifted?.range.allDay &&
569
604
  (() => {
570
605
  const bar = layoutAllDay(days, [
@@ -1,3 +1,4 @@
1
+ import type { GuestEntry } from "../lib/guest-list.js";
1
2
  /**
2
3
  * The shapes the calendar surfaces pass around. Presentational only: a
3
4
  * component here takes one of these and renders it, and every mutation leaves
@@ -72,6 +73,16 @@ export interface CalendarEventData {
72
73
  seriesException: boolean;
73
74
  status: "confirmed" | "tentative";
74
75
  }
76
+ /** A task as the grid draws it: a to-do on its due day, with a checkbox. */
77
+ export interface CalendarTaskData {
78
+ calendarTaskId: string;
79
+ calendarId: string;
80
+ title: string;
81
+ /** `YYYY-MM-DD` on an all-day task, else the due instant. */
82
+ due: string;
83
+ allDay: boolean;
84
+ completed: boolean;
85
+ }
75
86
  /**
76
87
  * One day, with everything on it already sorted and measured. The surfaces that
77
88
  * render a day take this rather than a flat event list, so the arithmetic is
@@ -223,8 +234,7 @@ export interface EventDraft {
223
234
  allDay: boolean;
224
235
  calendarId: string;
225
236
  location: string;
226
- /** Free text, one guest per comma — the prototype does not resolve them. */
227
- guests: string;
237
+ guests: GuestEntry[];
228
238
  notes: string;
229
239
  /** Human-readable rule, empty for a one-off. */
230
240
  repeat: string;
@@ -1,8 +1,3 @@
1
- /**
2
- * The shapes the calendar surfaces pass around. Presentational only: a
3
- * component here takes one of these and renders it, and every mutation leaves
4
- * through a callback. Nothing in this file knows where the data came from.
5
- */
6
1
  export const calendarColorIds = [
7
2
  "cal-1",
8
3
  "cal-2",
@@ -6,6 +6,7 @@ import { calendarColorClasses } from "../lib/calendar-color.js";
6
6
  import { cn } from "../lib/cn.js";
7
7
  import { NO_REPEAT, repeatChoices } from "../lib/recurrence.js";
8
8
  import { Button } from "./button.js";
9
+ import { CalendarGuestsField } from "./calendar-guests.js";
9
10
  import { Input } from "./input.js";
10
11
  import { Select } from "./select.js";
11
12
  const NOTES_CLASS = "w-full rounded-md border border-line bg-surface-sunken px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus-visible:border-line-strong focus-visible:ring-2 focus-visible:ring-ring/30";
@@ -95,7 +96,7 @@ export function EventLocationField({ draft, onChange, touch, }) {
95
96
  return (_jsx(Input, { value: draft.location, placeholder: "Location", "aria-label": "Location", onChange: (e) => setField({ draft, onChange }, "location", e.target.value), className: touch ? "min-h-11" : "" }));
96
97
  }
97
98
  export function EventGuestsField({ draft, onChange, touch }) {
98
- return (_jsx(Input, { value: draft.guests, placeholder: "Guests, comma separated", "aria-label": "Guests", onChange: (e) => setField({ draft, onChange }, "guests", e.target.value), className: touch ? "min-h-11" : "" }));
99
+ return (_jsx(CalendarGuestsField, { value: draft.guests, onChange: (guests) => onChange({ ...draft, guests }), suggestions: [], onQuery: () => undefined, touch: touch }));
99
100
  }
100
101
  export function EventNotesField({ draft, onChange, layout = "compact", }) {
101
102
  return (_jsx("textarea", { value: draft.notes, placeholder: "Notes", "aria-label": "Notes", onChange: (e) => setField({ draft, onChange }, "notes", e.target.value), rows: layout === "pane" ? 6 : 3, className: NOTES_CLASS }));
@@ -64,7 +64,7 @@ export interface IntelligenceCalendarData {
64
64
  day: CalendarDayEntry[];
65
65
  /** The day those entries sit on, in words. */
66
66
  dayLabel: string;
67
- /** An answer to the top reading is on its way to the server. */
67
+ /** An answer to one of the readings is on its way to the server. */
68
68
  suggestionsBusy?: boolean;
69
69
  /** What the tab could not read. Empty when it read everything. */
70
70
  failure?: string;
@@ -7,16 +7,13 @@ import { CalendarEventChip } from "./calendar-event-chip.js";
7
7
  import { CalendarFailureNote } from "./calendar-failure-note.js";
8
8
  import { CalendarInviteCard } from "./calendar-invite-card.js";
9
9
  import { CalendarSlotOffers } from "./calendar-slot-offers.js";
10
- import { CalendarSuggestionDeck } from "./calendar-suggestion-deck.js";
11
- import { EventSuggestionCard, settleZone, ZONE_UNSETTLED_REASON, } from "./event-suggestion-card.js";
10
+ import { CalendarSuggestionList } from "./calendar-suggestion-list.js";
11
+ import { EventSuggestionCard } from "./event-suggestion-card.js";
12
12
  import { IntelligenceSection } from "./intelligence-section.js";
13
13
  export function IntelligenceCalendar({ data, actions, selectedEventId = "", touch, className, }) {
14
14
  const { invite, prose, suggestions, day, dayLabel, suggestionsBusy = false, failure = "", suggestionsFailure = "", reportHref, addBlocked, } = data;
15
15
  const { onReviewSuggestion, onOpenThread } = actions;
16
16
  const [zoneChoices, setZoneChoices] = useState({});
17
- const top = suggestions[0];
18
- const topChoice = top === undefined ? "" : (zoneChoices[top.suggestion.id] ?? "");
19
- const topSettlement = top === undefined ? undefined : settleZone(top.suggestion, topChoice);
20
17
  const picked = new Set(prose?.picked ?? []);
21
18
  const nothingToSay = failure === "" &&
22
19
  invite === undefined &&
@@ -29,15 +26,12 @@ export function IntelligenceCalendar({ data, actions, selectedEventId = "", touc
29
26
  ? { sender: invite.sender, onMute: actions.onMuteInvite }
30
27
  : undefined, onAdd: actions.onAddInvite, onTentative: actions.onTentativeInvite, onDecline: actions.onDeclineInvite, onReopen: actions.onReopenInvite, onOfferOtherTimes: actions.onOfferOtherTimes, onRemove: actions.onRemoveInvite, onOpenNewer: actions.onOpenNewerInvite, touch: touch }) })), prose && (_jsxs(IntelligenceSection, { label: prose.proposals.length > 0
31
28
  ? `Times named · ${prose.dayLabel}`
32
- : `Other times · ${prose.dayLabel}`, children: [_jsx("ul", { className: cn("flex flex-col gap-1", prose.proposals.length === 0 && "hidden"), children: prose.proposals.map((proposal) => (_jsxs("li", { className: "flex items-baseline gap-2 text-xs", children: [_jsx("span", { className: "w-24 shrink-0 truncate tabular-nums text-fg", children: proposal.phrase }), proposal.clashTitle === "" ? (_jsx("span", { className: "min-w-0 flex-1 truncate text-positive", children: "Nothing booked" })) : (_jsxs("span", { className: "min-w-0 flex-1 truncate text-danger", children: [proposal.clashTitle, " is already there"] }))] }, proposal.id))) }), _jsx("p", { className: "mt-3 pb-1.5 text-2xs uppercase tracking-wider text-fg-subtle", children: "Free, half an hour each" }), _jsx(CalendarSlotOffers, { slots: prose.slots, picked: picked, onToggle: actions.onToggleSlot, touch: touch, scroll: true }), actions.onReplyWithSlots ? (_jsxs("div", { className: "mt-2 flex flex-col gap-1.5", children: [_jsx(Button, { variant: "secondary", size: touch ? "md" : "sm", icon: _jsx(Reply, { className: "size-3.5" }), onClick: actions.onReplyWithSlots, disabled: picked.size === 0, className: cn("self-start", touch && "min-h-11"), children: "Reply with these times" }), _jsx("p", { className: "text-2xs text-fg-subtle", children: "Picked slots go into the reply as plain text. Nothing is booked." })] })) : (_jsx("p", { className: "mt-1.5 text-2xs text-fg-subtle", children: "Picked slots go into the reply as plain text. Nothing is booked." }))] })), suggestions.length > 0 && (_jsxs(IntelligenceSection, { label: "Read out of this thread", children: [_jsx(CalendarSuggestionDeck, { hasCard: top !== undefined, remaining: suggestions.length, blocked: topSettlement !== undefined && !topSettlement.settled, blockedReason: ZONE_UNSETTLED_REASON, onConfirm: () => {
33
- if (top && topSettlement?.settled && addBlocked === undefined)
34
- actions.onAddSuggestion(top.suggestion.id, topSettlement.timeZone);
35
- }, onReject: () => {
36
- if (top)
37
- actions.onDismissSuggestion(top.suggestion.id);
38
- }, children: top && (_jsx(EventSuggestionCard, { suggestion: top.suggestion, whenText: top.whenText, addLabel: "Add to calendar", zoneChoice: topChoice, onZoneChoice: (timeZone) => setZoneChoices((prev) => ({
39
- ...prev,
40
- [top.suggestion.id]: timeZone,
41
- })), onAdd: (timeZone) => actions.onAddSuggestion(top.suggestion.id, timeZone), onReview: onReviewSuggestion &&
42
- ((timeZone) => onReviewSuggestion(top.suggestion.id, timeZone)), onDismiss: () => actions.onDismissSuggestion(top.suggestion.id), onOpenThread: onOpenThread && (() => onOpenThread(top.suggestion.threadId)), busy: suggestionsBusy, addBlocked: addBlocked !== undefined, touch: touch })) }), addBlocked !== undefined && (_jsx("div", { className: "mt-2 rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg", children: addBlocked })), suggestionsFailure !== "" && (_jsx(CalendarFailureNote, { text: suggestionsFailure, reportHref: reportHref, className: "mt-2" })), _jsx("p", { className: "mt-2 text-2xs text-fg-subtle", children: "None of this is on your calendar, and none of it will be until you say so." })] })), day.length > 0 && (_jsx(IntelligenceSection, { label: dayLabel, className: "border-b-0", children: _jsx("ul", { className: "flex flex-col gap-1", children: day.map((entry) => (_jsx("li", { children: _jsx(CalendarEventChip, { title: entry.event.title, timeText: entry.timeText, color: entry.color, layout: "row", density: "compact", rsvp: entry.event.myRsvp, status: entry.event.status, hasThread: entry.event.threadId !== "", isRecurring: entry.event.recurrenceRule !== "", zoneCertainty: entry.event.zoneCertainty, selected: entry.event.id === selectedEventId, onClick: () => actions.onSelectEvent(entry.event.id) }) }, entry.event.id))) }) }))] }));
29
+ : `Other times · ${prose.dayLabel}`, children: [_jsx("ul", { className: cn("flex flex-col gap-1", prose.proposals.length === 0 && "hidden"), children: prose.proposals.map((proposal) => (_jsxs("li", { className: "flex items-baseline gap-2 text-xs", children: [_jsx("span", { className: "w-24 shrink-0 truncate tabular-nums text-fg", children: proposal.phrase }), proposal.clashTitle === "" ? (_jsx("span", { className: "min-w-0 flex-1 truncate text-positive", children: "Nothing booked" })) : (_jsxs("span", { className: "min-w-0 flex-1 truncate text-danger", children: [proposal.clashTitle, " is already there"] }))] }, proposal.id))) }), _jsx("p", { className: "mt-3 pb-1.5 text-2xs uppercase tracking-wider text-fg-subtle", children: "Free, half an hour each" }), _jsx(CalendarSlotOffers, { slots: prose.slots, picked: picked, onToggle: actions.onToggleSlot, touch: touch, scroll: true }), actions.onReplyWithSlots ? (_jsxs("div", { className: "mt-2 flex flex-col gap-1.5", children: [_jsx(Button, { variant: "secondary", size: touch ? "md" : "sm", icon: _jsx(Reply, { className: "size-3.5" }), onClick: actions.onReplyWithSlots, disabled: picked.size === 0, className: cn("self-start", touch && "min-h-11"), children: "Reply with these times" }), _jsx("p", { className: "text-2xs text-fg-subtle", children: "Picked slots go into the reply as plain text. Nothing is booked." })] })) : (_jsx("p", { className: "mt-1.5 text-2xs text-fg-subtle", children: "Picked slots go into the reply as plain text. Nothing is booked." }))] })), suggestions.length > 0 && (_jsxs(IntelligenceSection, { label: "Read out of this thread", children: [_jsx(CalendarSuggestionList, { items: suggestions.map(({ suggestion, whenText }) => ({
30
+ id: suggestion.id,
31
+ card: (_jsx(EventSuggestionCard, { suggestion: suggestion, whenText: whenText, addLabel: "Add to calendar", zoneChoice: zoneChoices[suggestion.id] ?? "", onZoneChoice: (timeZone) => setZoneChoices((prev) => ({
32
+ ...prev,
33
+ [suggestion.id]: timeZone,
34
+ })), onAdd: (timeZone) => actions.onAddSuggestion(suggestion.id, timeZone), onReview: onReviewSuggestion &&
35
+ ((timeZone) => onReviewSuggestion(suggestion.id, timeZone)), onDismiss: () => actions.onDismissSuggestion(suggestion.id), onOpenThread: onOpenThread && (() => onOpenThread(suggestion.threadId)), busy: suggestionsBusy, addBlocked: addBlocked !== undefined, touch: touch })),
36
+ })) }), addBlocked !== undefined && (_jsx("div", { className: "mt-2 rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg", children: addBlocked })), suggestionsFailure !== "" && (_jsx(CalendarFailureNote, { text: suggestionsFailure, reportHref: reportHref, className: "mt-2" })), _jsx("p", { className: "mt-2 text-2xs text-fg-subtle", children: "None of this is on your calendar, and none of it will be until you say so." })] })), day.length > 0 && (_jsx(IntelligenceSection, { label: dayLabel, className: "border-b-0", children: _jsx("ul", { className: "flex flex-col gap-1", children: day.map((entry) => (_jsx("li", { children: _jsx(CalendarEventChip, { title: entry.event.title, timeText: entry.timeText, color: entry.color, layout: "row", density: "compact", rsvp: entry.event.myRsvp, status: entry.event.status, hasThread: entry.event.threadId !== "", isRecurring: entry.event.recurrenceRule !== "", zoneCertainty: entry.event.zoneCertainty, selected: entry.event.id === selectedEventId, onClick: () => actions.onSelectEvent(entry.event.id) }) }, entry.event.id))) }) }))] }));
43
37
  }
@@ -8,6 +8,8 @@ export interface RecurrenceScopePromptProps {
8
8
  instanceText: string;
9
9
  onChoose: (scope: RecurrenceScope) => void;
10
10
  onCancel: () => void;
11
+ /** The scopes offered. An answer to an invitation takes this occurrence or all of them. */
12
+ scopes?: readonly RecurrenceScope[];
11
13
  touch?: boolean;
12
14
  className?: string;
13
15
  }
@@ -17,4 +19,4 @@ export interface RecurrenceScopePromptProps {
17
19
  * settled before the form opens, not confirmed on the way out when the change
18
20
  * has already been typed.
19
21
  */
20
- export declare function RecurrenceScopePrompt({ title, ruleText, instanceText, onChoose, onCancel, touch, className, }: RecurrenceScopePromptProps): import("react").JSX.Element;
22
+ export declare function RecurrenceScopePrompt({ title, ruleText, instanceText, onChoose, onCancel, scopes, touch, className, }: RecurrenceScopePromptProps): import("react").JSX.Element;
@@ -20,6 +20,8 @@ const choices = [
20
20
  * settled before the form opens, not confirmed on the way out when the change
21
21
  * has already been typed.
22
22
  */
23
- export function RecurrenceScopePrompt({ title, ruleText, instanceText, onChoose, onCancel, touch, className, }) {
24
- return (_jsxs("div", { className: cn("flex flex-col gap-3", className), children: [_jsxs("div", { children: [_jsxs("h2", { className: "text-md font-semibold text-fg", children: [title, " repeats"] }), _jsx("p", { className: "text-xs text-fg-muted", children: ruleText }), _jsxs("p", { className: "text-xs text-fg-subtle", children: ["You clicked ", instanceText, "."] })] }), _jsx("p", { className: "text-sm text-fg", children: "What should the change apply to?" }), _jsx("div", { className: "flex flex-col gap-1.5", children: choices.map((choice) => (_jsxs("button", { type: "button", onClick: () => onChoose(choice.scope), className: cn("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch && "min-h-11 justify-center"), children: [_jsx("span", { className: "text-sm font-medium text-fg", children: choice.label }), _jsx("span", { className: "text-2xs text-fg-subtle", children: choice.note })] }, choice.scope))) }), _jsx(Button, { variant: "ghost", size: touch ? "md" : "sm", onClick: onCancel, className: cn("self-start", touch && "min-h-11"), children: "Cancel" })] }));
23
+ export function RecurrenceScopePrompt({ title, ruleText, instanceText, onChoose, onCancel, scopes, touch, className, }) {
24
+ return (_jsxs("div", { className: cn("flex flex-col gap-3", className), children: [_jsxs("div", { children: [_jsxs("h2", { className: "text-md font-semibold text-fg", children: [title, " repeats"] }), _jsx("p", { className: "text-xs text-fg-muted", children: ruleText }), _jsxs("p", { className: "text-xs text-fg-subtle", children: ["You clicked ", instanceText, "."] })] }), _jsx("p", { className: "text-sm text-fg", children: "What should the change apply to?" }), _jsx("div", { className: "flex flex-col gap-1.5", children: choices
25
+ .filter((choice) => scopes === undefined || scopes.includes(choice.scope))
26
+ .map((choice) => (_jsxs("button", { type: "button", onClick: () => onChoose(choice.scope), className: cn("flex flex-col rounded-md border border-line bg-surface px-3 py-2 text-left outline-none transition-colors hover:border-line-strong hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", touch && "min-h-11 justify-center"), children: [_jsx("span", { className: "text-sm font-medium text-fg", children: choice.label }), _jsx("span", { className: "text-2xs text-fg-subtle", children: choice.note })] }, choice.scope))) }), _jsx(Button, { variant: "ghost", size: touch ? "md" : "sm", onClick: onCancel, className: cn("self-start", touch && "min-h-11"), children: "Cancel" })] }));
25
27
  }
package/dist/index.d.ts CHANGED
@@ -37,19 +37,21 @@ export { CalendarEventGone, CalendarEventPopupCard, type CalendarEventPopupCardP
37
37
  export { CalendarEventSidebar, type CalendarEventSidebarProps, } from "./components/calendar-event-sidebar.js";
38
38
  export { CalendarFailureNote, type CalendarFailureNoteProps, } from "./components/calendar-failure-note.js";
39
39
  export { CalendarGrid, type CalendarGridProps, } from "./components/calendar-grid.js";
40
+ export { type CalendarAnswer, CalendarCancellationsSent, type CalendarCancellationsSentProps, CalendarEventGuests, type CalendarGuestCounts, CalendarGuestsField, type CalendarGuestsFieldProps, CalendarInvitationsNotSent, type CalendarInvitationsNotSentProps, CalendarReplyRow, type CalendarReplyRowProps, type CalendarSender, CalendarSenderField, type GuestSuggestion, } from "./components/calendar-guests.js";
40
41
  export { CalendarInviteCard, type CalendarInviteCardProps, } from "./components/calendar-invite-card.js";
41
42
  export { CalendarList, type CalendarListProps, } from "./components/calendar-list.js";
42
43
  export { CalendarParseBadge, type CalendarParseBadgeProps, calendarParseLabel, calendarParseNote, } from "./components/calendar-parse-badge.js";
43
44
  export { CalendarPopover, type CalendarPopoverProps, } from "./components/calendar-popover.js";
44
- export { CalendarQuickCreateCard, type CalendarQuickCreateCardProps, type QuickCreateFields, } from "./components/calendar-quick-create.js";
45
+ export { CalendarQuickCreateCard, type CalendarQuickCreateCardProps, type QuickCreateFields, type QuickCreateMode, type QuickTaskFields, } from "./components/calendar-quick-create.js";
45
46
  export { CalendarScreenToolbar, type CalendarScreenToolbarProps, } from "./components/calendar-screen-toolbar.js";
46
47
  export { CalendarSheet, type CalendarSheetProps, } from "./components/calendar-sheet.js";
47
48
  export { CalendarSidePane, type CalendarSidePaneProps, NewEventSquare, type NewEventSquareProps, } from "./components/calendar-side-pane.js";
48
49
  export { CalendarSlotOffers, type CalendarSlotOffersProps, } from "./components/calendar-slot-offers.js";
49
- export { CalendarSuggestionDeck, type CalendarSuggestionDeckProps, } from "./components/calendar-suggestion-deck.js";
50
+ export { CalendarSuggestionList, type CalendarSuggestionListItem, type CalendarSuggestionListProps, } from "./components/calendar-suggestion-list.js";
51
+ export { type CalendarTaskFields, CalendarTaskPopupCard, type CalendarTaskPopupCardProps, } from "./components/calendar-task-popup.js";
50
52
  export { CalendarTimeGrid, type CalendarTimeGridProps, describeRange, type GridDraft, type GridGesture, } from "./components/calendar-time-grid.js";
51
53
  export { Segmented, type SegmentedProps, type SegmentOption, segmentClassName, } from "./components/calendar-toolbar.js";
52
- export { type CalendarAttendee, type CalendarClash, type CalendarColorId, type CalendarDay, type CalendarDescriptor, type CalendarEventData, type CalendarInvite, type CalendarInviteState, type CalendarParseMethod, type CalendarProposal, type CalendarSlotPick, type CalendarViewId, calendarColorIds, type EventDraft, type EventSuggestion, type RecurrenceScope, type RsvpState, type ZoneCertainty, type ZoneOption, type ZoneOptions, } from "./components/calendar-types.js";
54
+ export { type CalendarAttendee, type CalendarClash, type CalendarColorId, type CalendarDay, type CalendarDescriptor, type CalendarEventData, type CalendarInvite, type CalendarInviteState, type CalendarParseMethod, type CalendarProposal, type CalendarSlotPick, type CalendarTaskData, type CalendarViewId, calendarColorIds, type EventDraft, type EventSuggestion, type RecurrenceScope, type RsvpState, type ZoneCertainty, type ZoneOption, type ZoneOptions, } from "./components/calendar-types.js";
53
55
  export { CalendarYear, type CalendarYearProps, } from "./components/calendar-year.js";
54
56
  export { Card, CardBody, CardHeader, type CardProps, CardTitle, } from "./components/card.js";
55
57
  export { CategoryBadge, type CategoryBadgeProps, } from "./components/category-badge.js";
@@ -197,6 +199,7 @@ export { addMinutesToClock } from "./lib/event-phrase.js";
197
199
  export { collapseFolderTree, filterFolderTree, folderAncestors, folderDepth, folderLeaf, folderParent, matchesQuery, orderFolderNodes, queryExpandedPaths, withCreateRows, } from "./lib/folder-tree.js";
198
200
  export { findFirstFocusable, findLastFocusable, findNextFocusable, findParentRow, isFocusable, isSelectable, } from "./lib/folder-tree-focus.js";
199
201
  export { type GridSlot, initialFocus } from "./lib/grid-keyboard.js";
202
+ export { type GuestEntry, invalidGuest, parseGuest, storedGuest, withGuest, } from "./lib/guest-list.js";
200
203
  export { isoWeek } from "./lib/iso-week.js";
201
204
  export { defaultKeyboardHints, KEY_HINT_GROUPS, type KeyboardHint, type KeyHint, type KeyHintGroup, keyboardHintsFor, keysForAction, shortcutHintForAction, type TriageAction, type TriageHandlers, tooltipForAction, } from "./lib/keymap.js";
202
205
  export { type DispatchResult, dispatchKey, isControlTarget, isEditableTarget, type KeyStroke, ROW_ATTRIBUTE, type SequencePrefix, } from "./lib/keymap-dispatch.js";
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ export { CalendarEventGone, CalendarEventPopupCard, CalendarFailureBlock, } from
37
37
  export { CalendarEventSidebar, } from "./components/calendar-event-sidebar.js";
38
38
  export { CalendarFailureNote, } from "./components/calendar-failure-note.js";
39
39
  export { CalendarGrid, } from "./components/calendar-grid.js";
40
+ export { CalendarCancellationsSent, CalendarEventGuests, CalendarGuestsField, CalendarInvitationsNotSent, CalendarReplyRow, CalendarSenderField, } from "./components/calendar-guests.js";
40
41
  export { CalendarInviteCard, } from "./components/calendar-invite-card.js";
41
42
  export { CalendarList, } from "./components/calendar-list.js";
42
43
  export { CalendarParseBadge, calendarParseLabel, calendarParseNote, } from "./components/calendar-parse-badge.js";
@@ -46,7 +47,8 @@ export { CalendarScreenToolbar, } from "./components/calendar-screen-toolbar.js"
46
47
  export { CalendarSheet, } from "./components/calendar-sheet.js";
47
48
  export { CalendarSidePane, NewEventSquare, } from "./components/calendar-side-pane.js";
48
49
  export { CalendarSlotOffers, } from "./components/calendar-slot-offers.js";
49
- export { CalendarSuggestionDeck, } from "./components/calendar-suggestion-deck.js";
50
+ export { CalendarSuggestionList, } from "./components/calendar-suggestion-list.js";
51
+ export { CalendarTaskPopupCard, } from "./components/calendar-task-popup.js";
50
52
  export { CalendarTimeGrid, describeRange, } from "./components/calendar-time-grid.js";
51
53
  export { Segmented, segmentClassName, } from "./components/calendar-toolbar.js";
52
54
  export { calendarColorIds, } from "./components/calendar-types.js";
@@ -196,6 +198,7 @@ export { addMinutesToClock } from "./lib/event-phrase.js";
196
198
  export { collapseFolderTree, filterFolderTree, folderAncestors, folderDepth, folderLeaf, folderParent, matchesQuery, orderFolderNodes, queryExpandedPaths, withCreateRows, } from "./lib/folder-tree.js";
197
199
  export { findFirstFocusable, findLastFocusable, findNextFocusable, findParentRow, isFocusable, isSelectable, } from "./lib/folder-tree-focus.js";
198
200
  export { initialFocus } from "./lib/grid-keyboard.js";
201
+ export { invalidGuest, parseGuest, storedGuest, withGuest, } from "./lib/guest-list.js";
199
202
  export { isoWeek } from "./lib/iso-week.js";
200
203
  export { defaultKeyboardHints, KEY_HINT_GROUPS, keyboardHintsFor, keysForAction, shortcutHintForAction, tooltipForAction, } from "./lib/keymap.js";
201
204
  export { dispatchKey, isControlTarget, isEditableTarget, ROW_ATTRIBUTE, } from "./lib/keymap-dispatch.js";
@@ -0,0 +1,17 @@
1
+ /** One guest as the Guests field holds them. */
2
+ export interface GuestEntry {
3
+ /** What the reader typed for this guest, kept so an invalid entry can be shown and fixed. */
4
+ text: string;
5
+ email: string;
6
+ /** The name before the address, or the address itself when none was given. */
7
+ displayName: string;
8
+ valid: boolean;
9
+ }
10
+ /** One typed entry: `ann@example.com`, or `Ann Smith <ann@example.com>`. */
11
+ export declare function parseGuest(text: string): GuestEntry;
12
+ /** A guest the server already holds, by address and the name it stored. */
13
+ export declare function storedGuest(email: string, displayName: string): GuestEntry;
14
+ /** The list with one more guest, unless that address is already on it. */
15
+ export declare function withGuest(guests: readonly GuestEntry[], guest: GuestEntry): GuestEntry[];
16
+ /** The first entry that is not an email address, which blocks a save. */
17
+ export declare function invalidGuest(guests: readonly GuestEntry[]): GuestEntry | undefined;
@@ -0,0 +1,34 @@
1
+ const EMAIL = /^[^\s@<>",;]+@[^\s@<>",;]+\.[^\s@<>",;]+$/;
2
+ const NAMED = /^\s*"?([^"<]*?)"?\s*<([^>]+)>\s*$/;
3
+ /** One typed entry: `ann@example.com`, or `Ann Smith <ann@example.com>`. */
4
+ export function parseGuest(text) {
5
+ const trimmed = text.trim();
6
+ const named = NAMED.exec(trimmed);
7
+ const email = (named?.[2] ?? trimmed).trim().toLowerCase();
8
+ const name = named?.[1]?.trim() ?? "";
9
+ return {
10
+ text: trimmed,
11
+ email,
12
+ displayName: name === "" ? email : name,
13
+ valid: EMAIL.test(email),
14
+ };
15
+ }
16
+ /** A guest the server already holds, by address and the name it stored. */
17
+ export function storedGuest(email, displayName) {
18
+ return {
19
+ text: email,
20
+ email,
21
+ displayName: displayName === "" ? email : displayName,
22
+ valid: true,
23
+ };
24
+ }
25
+ /** The list with one more guest, unless that address is already on it. */
26
+ export function withGuest(guests, guest) {
27
+ if (guest.valid && guests.some((other) => other.email === guest.email))
28
+ return [...guests];
29
+ return [...guests, guest];
30
+ }
31
+ /** The first entry that is not an email address, which blocks a save. */
32
+ export function invalidGuest(guests) {
33
+ return guests.find((guest) => !guest.valid);
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.225",
3
+ "version": "0.0.226",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,18 +0,0 @@
1
- import { type ReactNode } from "react";
2
- export interface CalendarSuggestionDeckProps {
3
- children: ReactNode;
4
- /** False when the deck has nothing left. */
5
- hasCard: boolean;
6
- onConfirm: () => void;
7
- onReject: () => void;
8
- /** True while the top card cannot be confirmed — an unsettled clock. */
9
- blocked: boolean;
10
- blockedReason: string;
11
- remaining: number;
12
- /** What the swipe badge says in the confirming direction. */
13
- confirmLabel?: string;
14
- /** What an empty deck says. */
15
- emptyText?: string;
16
- className?: string;
17
- }
18
- export declare function CalendarSuggestionDeck({ children, hasCard, onConfirm, onReject, blocked, blockedReason, remaining, confirmLabel, emptyText, className, }: CalendarSuggestionDeckProps): import("react").JSX.Element;
@@ -1,51 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Sparkles } from "lucide-react";
3
- import { useState } from "react";
4
- import { cn } from "../lib/cn.js";
5
- /**
6
- * Readings one at a time, as a deck rather than a column: one decision fills
7
- * the width it is given, and the swipe is the fast path over the buttons that
8
- * are always there under it. A gesture is never the only way to answer.
9
- */
10
- const COMMIT_DISTANCE = 96;
11
- const DRAG_SLOP = 6;
12
- export function CalendarSuggestionDeck({ children, hasCard, onConfirm, onReject, blocked, blockedReason, remaining, confirmLabel = "Add", emptyText = "Nothing in your mail is waiting on a decision about time.", className, }) {
13
- const [drag, setDrag] = useState(0);
14
- const [from, setFrom] = useState(null);
15
- if (!hasCard)
16
- return (_jsxs("div", { className: cn("flex flex-col items-center gap-2 p-6 text-center", className), children: [_jsx(Sparkles, { className: "size-6 text-fg-subtle", "aria-hidden": true }), _jsx("p", { className: "text-sm text-fg-muted", children: emptyText })] }));
17
- const committing = Math.abs(drag) > COMMIT_DISTANCE;
18
- const towardsConfirm = drag > 0;
19
- return (_jsxs("div", { className: cn("flex flex-col gap-3", className), children: [_jsxs("div", { className: "relative", children: [_jsx("div", { className: "touch-pan-y select-none", style: {
20
- transform: `translateX(${drag}px) rotate(${drag / 40}deg)`,
21
- transition: from === null ? "transform 180ms ease-out" : "none",
22
- }, onPointerDown: (e) => {
23
- setFrom(e.clientX);
24
- }, onPointerMove: (e) => {
25
- if (from === null)
26
- return;
27
- const moved = e.clientX - from;
28
- if (Math.abs(moved) > DRAG_SLOP &&
29
- !e.currentTarget.hasPointerCapture(e.pointerId))
30
- e.currentTarget.setPointerCapture(e.pointerId);
31
- setDrag(moved);
32
- }, onPointerUp: () => {
33
- if (Math.abs(drag) > COMMIT_DISTANCE) {
34
- if (drag > 0 && !blocked)
35
- onConfirm();
36
- if (drag < 0)
37
- onReject();
38
- }
39
- setFrom(null);
40
- setDrag(0);
41
- }, onPointerCancel: () => {
42
- setFrom(null);
43
- setDrag(0);
44
- }, children: children }), committing && (_jsx("span", { className: cn("pointer-events-none absolute top-3 rounded-md px-2 py-1 text-xs font-semibold", towardsConfirm
45
- ? "right-3 bg-accent-soft text-accent"
46
- : "left-3 bg-danger-soft text-danger"), children: towardsConfirm
47
- ? blocked
48
- ? blockedReason
49
- : confirmLabel
50
- : "Not this" }))] }), _jsxs("p", { className: "text-center text-2xs text-fg-subtle", children: [remaining, " left \u00B7 swipe right to accept, left to drop, or use the buttons"] })] }));
51
- }