@remit/web-client 0.0.329 → 0.0.331

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.
Files changed (79) hide show
  1. package/dist/src/components/calendar/CalendarEventEditor.js +57 -7
  2. package/dist/src/components/calendar/CalendarEventPopup.js +74 -9
  3. package/dist/src/components/calendar/CalendarQuickCreate.js +78 -5
  4. package/dist/src/components/calendar/CalendarScreen.js +49 -10
  5. package/dist/src/components/calendar/CalendarSession.d.ts +3 -0
  6. package/dist/src/components/calendar/CalendarTaskPopup.d.ts +4 -0
  7. package/dist/src/components/calendar/CalendarTaskPopup.js +95 -0
  8. package/dist/src/components/calendar/CalendarWaiting.d.ts +3 -3
  9. package/dist/src/components/calendar/CalendarWaiting.js +5 -10
  10. package/dist/src/components/compose/ComposeForm.js +1 -1
  11. package/dist/src/components/layout/AppFrame.d.ts +2 -3
  12. package/dist/src/components/layout/AppFrame.js +7 -8
  13. package/dist/src/components/layout/CalendarTopBar.d.ts +1 -0
  14. package/dist/src/components/layout/CalendarTopBar.js +9 -0
  15. package/dist/src/components/layout/DesktopAppBar.d.ts +1 -0
  16. package/dist/src/components/layout/DesktopAppBar.js +7 -0
  17. package/dist/src/components/layout/DesktopChrome.d.ts +6 -0
  18. package/dist/src/components/layout/DesktopChrome.js +9 -0
  19. package/dist/src/components/layout/MailShell.d.ts +1 -0
  20. package/dist/src/components/layout/MailShell.js +1 -0
  21. package/dist/src/components/mail/BulkRunProvider.js +1 -1
  22. package/dist/src/components/mail/MessageActionMenu.js +1 -1
  23. package/dist/src/components/mail/MessageList.js +1 -1
  24. package/dist/src/components/mail/OutboxPane.js +1 -1
  25. package/dist/src/components/mail/ThreadListInteraction.js +1 -1
  26. package/dist/src/components/settings/CalendarDefaultSenderCard.d.ts +2 -0
  27. package/dist/src/components/settings/CalendarDefaultSenderCard.js +16 -0
  28. package/dist/src/components/ui/ErrorBannerProvider.d.ts +0 -23
  29. package/dist/src/components/ui/ErrorBannerProvider.js +3 -39
  30. package/dist/src/components/ui/error-banner-context.d.ts +23 -0
  31. package/dist/src/components/ui/error-banner-context.js +38 -0
  32. package/dist/src/hooks/calendar/draft-session.d.ts +2 -1
  33. package/dist/src/hooks/calendar/draft-session.js +1 -0
  34. package/dist/src/hooks/calendar/draft.d.ts +8 -2
  35. package/dist/src/hooks/calendar/draft.js +17 -4
  36. package/dist/src/hooks/calendar/index.d.ts +4 -2
  37. package/dist/src/hooks/calendar/index.js +4 -2
  38. package/dist/src/hooks/calendar/instance.d.ts +2 -1
  39. package/dist/src/hooks/calendar/instance.js +14 -1
  40. package/dist/src/hooks/calendar/useCalendarScheduling.d.ts +33 -0
  41. package/dist/src/hooks/calendar/useCalendarScheduling.js +118 -0
  42. package/dist/src/hooks/calendar/useCalendarTasks.d.ts +53 -0
  43. package/dist/src/hooks/calendar/useCalendarTasks.js +105 -0
  44. package/dist/src/hooks/calendar/useCalendarWrites.d.ts +7 -1
  45. package/dist/src/hooks/calendar/useCalendarWrites.js +12 -4
  46. package/dist/src/hooks/calendar/useCalendars.d.ts +2 -0
  47. package/dist/src/hooks/calendar/useCalendars.js +8 -3
  48. package/dist/src/hooks/calendar/useDraftSession.js +1 -1
  49. package/dist/src/hooks/calendar/useMoveEvent.js +1 -0
  50. package/dist/src/hooks/useApplyLabel.js +1 -1
  51. package/dist/src/hooks/useCalendarData.d.ts +7 -2
  52. package/dist/src/hooks/useCalendarData.js +17 -5
  53. package/dist/src/hooks/useComposeLanguages.js +1 -1
  54. package/dist/src/hooks/useDeleteMessages.js +1 -1
  55. package/dist/src/hooks/useEmptyTrash.js +1 -1
  56. package/dist/src/hooks/useEscalatedActions.js +1 -1
  57. package/dist/src/hooks/useFilters.d.ts +1 -1
  58. package/dist/src/hooks/useLabels.d.ts +1 -1
  59. package/dist/src/hooks/useMarkAsRead.js +1 -1
  60. package/dist/src/hooks/useMoveMessages.js +1 -1
  61. package/dist/src/hooks/useReportSpam.js +1 -1
  62. package/dist/src/hooks/useSignature.js +1 -1
  63. package/dist/src/hooks/useStarredThreads.d.ts +1 -1
  64. package/dist/src/hooks/useToggleStar.js +1 -1
  65. package/dist/src/hooks/useToggleTrusted.js +1 -1
  66. package/dist/src/hooks/useTriggerSync.d.ts +1 -1
  67. package/dist/src/hooks/useUpdateAddressFlags.js +1 -1
  68. package/dist/src/routeTree.gen.d.ts +20 -3
  69. package/dist/src/routeTree.gen.js +7 -0
  70. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.d.ts +5 -0
  71. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.js +16 -0
  72. package/dist/src/routes/calendar.js +6 -4
  73. package/dist/src/routes/mail.js +6 -3
  74. package/dist/src/routes/settings/calendars.js +2 -1
  75. package/dist/src/routing/calendar.d.ts +4 -0
  76. package/dist/src/routing/calendar.js +15 -1
  77. package/dist/src/routing/index.d.ts +1 -1
  78. package/dist/src/routing/index.js +1 -1
  79. package/package.json +2 -2
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CalendarPopover, CalendarTaskPopupCard, } from "@remit/ui";
3
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
4
+ import { deviceTimeZone, isoAtInZone, isoOnClock, useCalendars, useCalendarTask, useCalendarTaskWrites, } from "../../hooks/calendar";
5
+ import { calendarEventReportHref } from "../../lib/calendar-report";
6
+ import { useCalendarNavigation } from "../../routing";
7
+ import { CalendarLoadFailed } from "./CalendarLoadFailed";
8
+ const dueText = (due, allDay) => {
9
+ const date = new Date(`${due.slice(0, 10)}T00:00:00Z`);
10
+ const day = new Intl.DateTimeFormat(undefined, {
11
+ weekday: "long",
12
+ day: "numeric",
13
+ month: "long",
14
+ timeZone: "UTC",
15
+ }).format(date);
16
+ return allDay ? `Due ${day}` : `Due ${day} · ${due.slice(11, 16)}`;
17
+ };
18
+ /** The task the address names, in a popup beside its chip. */
19
+ export function CalendarTaskPopup({ calendarTaskId, }) {
20
+ const read = useCalendarTask(calendarTaskId);
21
+ const { closeToView } = useCalendarNavigation();
22
+ const headingId = useId();
23
+ const closeRef = useRef(null);
24
+ const gone = read.kind === "gone";
25
+ useEffect(() => {
26
+ if (gone)
27
+ closeRef.current?.focus();
28
+ }, [gone]);
29
+ if (read.kind === "loading")
30
+ return null;
31
+ if (read.kind === "found")
32
+ return _jsx(OpenTask, { task: read.task });
33
+ if (read.kind === "failed")
34
+ return (_jsx(CalendarPopover, { anchor: null, anchorKey: "failed", labelledBy: headingId, children: _jsx("div", { id: headingId, className: "p-4", children: _jsx(CalendarLoadFailed, { title: "Couldn't open this task", error: read.error, onRetry: read.retry, compact: true }) }) }));
35
+ return (_jsx(CalendarPopover, { anchor: null, anchorKey: "gone", labelledBy: headingId, children: _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("h2", { id: headingId, className: "text-base font-medium text-fg", children: "This task was deleted or moved" }), _jsx("button", { ref: closeRef, type: "button", onClick: closeToView, className: "self-end rounded-md border border-line px-3 py-1.5 text-sm font-medium hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring", children: "Close" })] }) }));
36
+ }
37
+ function OpenTask({ task }) {
38
+ const { taskLists } = useCalendars();
39
+ const { closeToView } = useCalendarNavigation();
40
+ const { updateTask, deleteTask, isWriting } = useCalendarTaskWrites();
41
+ const headingId = useId();
42
+ const headingRef = useRef(null);
43
+ const [failure, setFailure] = useState();
44
+ const [anchor, setAnchor] = useState(null);
45
+ const { calendarTaskId } = task;
46
+ useLayoutEffect(() => {
47
+ setAnchor(document.querySelector(`[data-task-id="${CSS.escape(calendarTaskId)}"]`));
48
+ }, [calendarTaskId]);
49
+ useEffect(() => {
50
+ headingRef.current?.focus();
51
+ }, []);
52
+ const clock = deviceTimeZone();
53
+ const shownDue = task.allDay ? task.due : isoOnClock(task.due, clock);
54
+ const fields = {
55
+ title: task.summary,
56
+ dueDate: shownDue.slice(0, 10),
57
+ dueTime: task.allDay ? "" : shownDue.slice(11, 16),
58
+ description: task.description,
59
+ };
60
+ const settle = (retry) => (outcome) => {
61
+ if (outcome.kind === "written") {
62
+ setFailure(undefined);
63
+ return;
64
+ }
65
+ const text = `Couldn't save the task: ${outcome.message}`;
66
+ setFailure({
67
+ text,
68
+ reportHref: calendarEventReportHref(text),
69
+ onRetry: retry,
70
+ });
71
+ };
72
+ const toggle = () => {
73
+ void updateTask(task, { completed: !task.completed }).then(settle(toggle));
74
+ };
75
+ const save = (next) => {
76
+ void updateTask(task, {
77
+ summary: next.title,
78
+ description: next.description,
79
+ allDay: next.dueTime === "",
80
+ due: next.dueTime === ""
81
+ ? next.dueDate
82
+ : isoAtInZone(next.dueDate, next.dueTime, clock),
83
+ }).then(settle(() => save(next)));
84
+ };
85
+ const remove = () => {
86
+ void deleteTask(task).then((outcome) => {
87
+ if (outcome.kind === "written") {
88
+ closeToView();
89
+ return;
90
+ }
91
+ settle(remove)(outcome);
92
+ });
93
+ };
94
+ return (_jsx(CalendarPopover, { anchor: anchor, anchorKey: `${calendarTaskId}:${anchor ? "chip" : "none"}`, labelledBy: headingId, children: _jsx(CalendarTaskPopupCard, { headingId: headingId, headingRef: headingRef, fields: fields, dueText: dueText(shownDue, task.allDay), listName: taskLists.find((list) => list.id === task.calendarId)?.name ?? "Tasks", completed: task.completed, onToggle: toggle, onSave: save, onDelete: remove, onClose: closeToView, busy: isWriting, failure: failure }) }));
95
+ }
@@ -2,15 +2,15 @@ import { type CalendarSuggestionIntel } from "@remit/ui";
2
2
  import type { ReactNode } from "react";
3
3
  /**
4
4
  * What the mail is still asking about time, beside the calendar it would land
5
- * on. One reading at a time, as a deck: each is a decision, and the reader
6
- * makes it with the week in view rather than from a list of them.
5
+ * on. Every reading at once, one under the other, each with its own Add and
6
+ * Dismiss, beside the week it would land on.
7
7
  *
8
8
  * Presentational. The readings, the answer on its way and the refusal all come
9
9
  * in from the host, which reads them off the server.
10
10
  */
11
11
  export interface CalendarWaitingProps {
12
12
  suggestions: CalendarSuggestionIntel[];
13
- /** An answer to the top reading is on its way. */
13
+ /** An answer to one of the readings is on its way. */
14
14
  busy: boolean;
15
15
  /** Why the last answer did not land. Empty when it did. */
16
16
  failure: string;
@@ -1,14 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CalendarFailureNote, CalendarSuggestionDeck, EventSuggestionCard, settleZone, ZONE_UNSETTLED_REASON, } from "@remit/ui";
2
+ import { CalendarFailureNote, CalendarSuggestionList, EventSuggestionCard, } from "@remit/ui";
3
3
  import { Sparkles } from "lucide-react";
4
4
  export function CalendarWaiting({ suggestions, busy, failure, reportHref, addBlocked, onAdd, onChangeFirst, onDismiss, }) {
5
- const top = suggestions[0];
6
- const settlement = top ? settleZone(top.suggestion, "") : undefined;
7
- return (_jsxs("aside", { "aria-label": "Waiting for you", className: "hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line bg-surface-sunken py-3 lg:flex", children: [_jsxs("h3", { className: "flex items-center gap-1.5 px-row-inset text-2xs font-semibold uppercase tracking-wider text-fg-subtle", children: [_jsx(Sparkles, { className: "size-3", "aria-hidden": true }), "Waiting for you"] }), failure !== "" && (_jsx(CalendarFailureNote, { text: failure, reportHref: reportHref, className: "mx-row-inset" })), addBlocked !== undefined && (_jsx("div", { className: "mx-row-inset rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg", children: addBlocked })), _jsx(CalendarSuggestionDeck, { className: "px-row-inset", hasCard: top !== undefined, remaining: suggestions.length, blocked: settlement !== undefined && !settlement.settled, blockedReason: ZONE_UNSETTLED_REASON, onConfirm: () => {
8
- if (top && !busy && addBlocked === undefined)
9
- onAdd(top.suggestion.id);
10
- }, onReject: () => {
11
- if (top && !busy)
12
- onDismiss(top.suggestion.id);
13
- }, children: top && (_jsx(EventSuggestionCard, { suggestion: top.suggestion, whenText: top.whenText, onAdd: () => onAdd(top.suggestion.id), onReview: onChangeFirst && (() => onChangeFirst(top.suggestion.id)), onDismiss: () => onDismiss(top.suggestion.id), addLabel: "Add to calendar", busy: busy, addBlocked: addBlocked !== undefined })) }), _jsx("p", { className: "px-row-inset text-2xs text-fg-subtle", children: "None of this is on your calendar until you add it. Adding sends the organiser nothing." })] }));
5
+ return (_jsxs("aside", { "aria-label": "Waiting for you", className: "hidden w-72 shrink-0 flex-col gap-2 overflow-y-auto border-r border-line bg-surface-sunken py-3 lg:flex", children: [_jsxs("h3", { className: "flex items-center gap-1.5 px-row-inset text-2xs font-semibold uppercase tracking-wider text-fg-subtle", children: [_jsx(Sparkles, { className: "size-3", "aria-hidden": true }), "Waiting for you"] }), failure !== "" && (_jsx(CalendarFailureNote, { text: failure, reportHref: reportHref, className: "mx-row-inset" })), addBlocked !== undefined && (_jsx("div", { className: "mx-row-inset rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg", children: addBlocked })), _jsx(CalendarSuggestionList, { className: "px-row-inset", items: suggestions.map(({ suggestion, whenText }) => ({
6
+ id: suggestion.id,
7
+ card: (_jsx(EventSuggestionCard, { suggestion: suggestion, whenText: whenText, onAdd: () => onAdd(suggestion.id), onReview: onChangeFirst && (() => onChangeFirst(suggestion.id)), onDismiss: () => onDismiss(suggestion.id), addLabel: "Add to calendar", busy: busy, addBlocked: addBlocked !== undefined })),
8
+ })) }), _jsx("p", { className: "px-row-inset text-2xs text-fg-subtle", children: "None of this is on your calendar until you add it. Adding sends the organiser nothing." })] }));
14
9
  }
@@ -10,7 +10,7 @@ import { useSaveDraft } from "../../hooks/useSaveDraft";
10
10
  import { useSignature } from "../../hooks/useSignature.js";
11
11
  import { isNotFound, softErrorMeta } from "../../lib/error-classifier";
12
12
  import { accountIsMissingSmtp } from "../settings/account-form-helpers.js";
13
- import { useErrorBanners } from "../ui/ErrorBannerProvider.js";
13
+ import { useErrorBanners } from "../ui/error-banner-context";
14
14
  import { buildMutationErrorBanner, formatErrorDetail, } from "../ui/error-banners.js";
15
15
  import { AddressField } from "./AddressField";
16
16
  import { ComposeSmtpMissingBanner } from "./ComposeSmtpMissingBanner";
@@ -1,11 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
2
  export interface AppFrameProps {
3
3
  children: ReactNode;
4
- /** A full-screen surface on a phone takes the tab bar's room too. */
5
4
  hideTabBar?: boolean;
6
5
  }
7
6
  /**
8
- * Mail and calendar side by side as apps: a bar down the left edge on a wide
9
- * screen, a tab bar under the content on a phone.
7
+ * On a phone, the tab bar under the content. Wide screens get their app bar
8
+ * from the shell's own `appBar` slot, so the frame adds nothing there.
10
9
  */
11
10
  export declare function AppFrame({ children, hideTabBar }: AppFrameProps): import("react").JSX.Element;
@@ -1,16 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AppBar, AppTabBar } from "@remit/ui";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AppTabBar } from "@remit/ui";
3
3
  import { useLayoutTier } from "../../hooks/useLayoutTier";
4
4
  import { useAppSwitch } from "../../routing";
5
5
  /**
6
- * Mail and calendar side by side as apps: a bar down the left edge on a wide
7
- * screen, a tab bar under the content on a phone.
6
+ * On a phone, the tab bar under the content. Wide screens get their app bar
7
+ * from the shell's own `appBar` slot, so the frame adds nothing there.
8
8
  */
9
9
  export function AppFrame({ children, hideTabBar = false }) {
10
10
  const isPhone = useLayoutTier() === "phone";
11
11
  const { items, active, switchTo } = useAppSwitch();
12
- if (isPhone) {
13
- return (_jsxs("div", { className: "flex h-full w-full flex-col", style: hideTabBar ? undefined : { ["--app-tab-bar"]: "3.5rem" }, children: [_jsx("div", { className: "min-h-0 flex-1", children: children }), !hideTabBar && (_jsx(AppTabBar, { items: items, active: active, onNavigate: switchTo }))] }));
14
- }
15
- return (_jsxs("div", { className: "flex h-full w-full", children: [_jsx(AppBar, { items: items, active: active, onNavigate: switchTo }), _jsx("div", { className: "min-w-0 flex-1", children: children })] }));
12
+ if (!isPhone)
13
+ return _jsx(_Fragment, { children: children });
14
+ return (_jsxs("div", { className: "flex h-full w-full flex-col", style: hideTabBar ? undefined : { ["--app-tab-bar"]: "3.5rem" }, children: [_jsx("div", { className: "min-h-0 flex-1", children: children }), !hideTabBar && (_jsx(AppTabBar, { items: items, active: active, onNavigate: switchTo }))] }));
16
15
  }
@@ -0,0 +1 @@
1
+ export declare function CalendarTopBar(): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AppTopBar, Button } from "@remit/ui";
3
+ import { Settings } from "lucide-react";
4
+ import { AccountMenu } from "../../auth/AccountMenu";
5
+ import { useGoToSection } from "../../routing";
6
+ export function CalendarTopBar() {
7
+ const goToSection = useGoToSection();
8
+ return (_jsx(AppTopBar, { search: null, actions: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "sm", icon: _jsx(Settings, { className: "size-4" }), title: "Settings", "aria-label": "Settings", onClick: () => goToSection("accounts") }), _jsx(AccountMenu, {})] }) }));
9
+ }
@@ -0,0 +1 @@
1
+ export declare function DesktopAppBar(): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AppBar } from "@remit/ui";
3
+ import { useAppSwitch } from "../../routing";
4
+ export function DesktopAppBar() {
5
+ const { items, active, switchTo } = useAppSwitch();
6
+ return _jsx(AppBar, { items: items, active: active, onNavigate: switchTo });
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from "react";
2
+ export interface DesktopChromeProps {
3
+ topBar: ReactNode;
4
+ children: ReactNode;
5
+ }
6
+ export declare function DesktopChrome({ topBar, children }: DesktopChromeProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { AppChrome } from "@remit/ui";
3
+ import { useLayoutTier } from "../../hooks/useLayoutTier";
4
+ import { DesktopAppBar } from "./DesktopAppBar";
5
+ export function DesktopChrome({ topBar, children }) {
6
+ if (useLayoutTier() === "phone")
7
+ return _jsx(_Fragment, { children: children });
8
+ return (_jsx("div", { className: "flex h-full w-full flex-col overflow-hidden bg-canvas", children: _jsx(AppChrome, { topBar: topBar, appBar: _jsx(DesktopAppBar, {}), children: children }) }));
9
+ }
@@ -18,6 +18,7 @@ export interface MailShellChrome {
18
18
  intelligenceOpen: boolean;
19
19
  nav: ReactNode;
20
20
  topBar: ReactNode;
21
+ appBar: ReactNode;
21
22
  overlay: ReactNode;
22
23
  navOpen: boolean;
23
24
  onOpenNav: () => void;
@@ -25,6 +25,7 @@ export function MailShell({ phone, list, reading, intelligence, hasThread = fals
25
25
  return _jsx(AppShellSkeleton, {});
26
26
  const shared = {
27
27
  nav: chrome.nav,
28
+ appBar: chrome.appBar,
28
29
  overlay: chrome.overlay,
29
30
  skeleton: _jsx(AppShellSkeleton, {}),
30
31
  isLoading: chrome.isLoading,
@@ -5,7 +5,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, use
5
5
  import { bulkActionFailureDetail, bulkActionFailureTitle, bulkRunBusyRefusal, } from "../../lib/bulk-action-copy";
6
6
  import { honestProgress, mailboxesTouchedBy, runChunkedAction, runPredicateAction, } from "../../lib/bulk-actions";
7
7
  import { invalidateThreadListQueries, threadListCacheKeys, } from "../../lib/thread-list-cache";
8
- import { useErrorBanners } from "../ui/ErrorBannerProvider";
8
+ import { useErrorBanners } from "../ui/error-banner-context";
9
9
  import { buildMutationErrorBanner } from "../ui/error-banners";
10
10
  import { isFolderRoleRefusal } from "../ui/folder-role-refusal";
11
11
  import { useRoleAppointmentPrompt } from "./RoleAppointmentPromptProvider";
@@ -10,7 +10,7 @@ import { useMoveMessages } from "../../hooks/useMoveMessages";
10
10
  import { useToggleTrusted } from "../../hooks/useToggleTrusted";
11
11
  import { cancelThreadListQueries, invalidateThreadListQueries, patchThreadListQueries, restoreThreadListQueries, snapshotThreadListQueries, threadListCacheKeys, } from "../../lib/thread-list-cache";
12
12
  import { useCloseThread, useOpenThreadPath } from "../../routing";
13
- import { useErrorBanners } from "../ui/ErrorBannerProvider";
13
+ import { useErrorBanners } from "../ui/error-banner-context";
14
14
  import { formatErrorDetail } from "../ui/error-banners";
15
15
  import { MoveToTrigger } from "./MoveToTrigger";
16
16
  export const MessageActionMenu = ({ messageId, threadId, mailboxId, isRead, accountId, fromAddressId, isTrusted = false, showRaw = false, onToggleRaw, }) => {
@@ -21,7 +21,7 @@ import { listVerbRequest } from "../../lib/list-verb-request";
21
21
  import { resolveSelectionAccountScope } from "../../lib/selection-account-scope";
22
22
  import { shouldExitSelectionOnNavigate } from "../../lib/selection-mode";
23
23
  import { useOpenThread, useSelectionWizard, useWizardStepValue, } from "../../routing";
24
- import { useErrorBanners } from "../ui/ErrorBannerProvider";
24
+ import { useErrorBanners } from "../ui/error-banner-context";
25
25
  import { DeleteConfirmDialog } from "./DeleteConfirmDialog";
26
26
  import { LabelApplyTrigger } from "./LabelApplyTrigger";
27
27
  import { SelectionWizardHost, } from "./SelectionWizardHost";
@@ -26,7 +26,7 @@ import { isOutboxListRow, showsLastError } from "../../lib/outbox-status";
26
26
  import { normalizeSearchQuery } from "../../lib/search-query";
27
27
  import { parseSearchTokens } from "../../lib/search-tokens";
28
28
  import { useCloseOutboxDraft, useEditDraft, useOpenOutboxDraft, } from "../../routing";
29
- import { useErrorBanners } from "../ui/ErrorBannerProvider";
29
+ import { useErrorBanners } from "../ui/error-banner-context";
30
30
  import { buildMutationErrorBanner } from "../ui/error-banners";
31
31
  import { MessageBody } from "./MessageBody";
32
32
  import { NavMenuButton } from "./NavMenuButton";
@@ -24,7 +24,7 @@ import { useFollowFocusOpen } from "../../hooks/useFollowFocusOpen";
24
24
  import { useIsDesktop } from "../../hooks/useMediaQuery";
25
25
  import { tabStopId } from "../../lib/list-focus";
26
26
  import { useListHeaderChrome } from "../../lib/list-header-chrome";
27
- import { useErrorBanners } from "../ui/ErrorBannerProvider";
27
+ import { useErrorBanners } from "../ui/error-banner-context";
28
28
  import { DeleteConfirmDialog } from "./DeleteConfirmDialog";
29
29
  /** Nothing pending, as a stable identity so the outcome memo does not churn. */
30
30
  const NO_TARGETS = [];
@@ -0,0 +1,2 @@
1
+ /** Settings, Calendars, Invitations: the account invitations go out from by default. */
2
+ export declare function CalendarDefaultSenderCard(): import("react").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CalendarSenderField, formatErrorMessage } from "@remit/ui";
3
+ import { useState } from "react";
4
+ import { useCalendarSenders } from "../../hooks/calendar";
5
+ import { calendarEventReportHref } from "../../lib/calendar-report";
6
+ /** Settings, Calendars, Invitations: the account invitations go out from by default. */
7
+ export function CalendarDefaultSenderCard() {
8
+ const { senders, defaultSenderId, setDefaultSender } = useCalendarSenders();
9
+ const [problem, setProblem] = useState("");
10
+ if (senders.length === 0)
11
+ return null;
12
+ return (_jsxs("section", { "aria-labelledby": "calendar-default-sender", className: "space-y-2 rounded-sm border border-line bg-surface p-4", children: [_jsx("h2", { id: "calendar-default-sender", className: "text-sm font-semibold", children: "Invitations: default sender" }), _jsx("p", { className: "text-sm text-fg-muted", children: "Invitations, updates and cancellations go out from this account unless you pick another on the event." }), _jsx(CalendarSenderField, { label: "Default sender", senders: senders, value: defaultSenderId ?? "", onChange: (accountId) => {
13
+ setProblem("");
14
+ void setDefaultSender(accountId).catch((error) => setProblem(formatErrorMessage(error)));
15
+ } }), problem !== "" && (_jsxs("p", { role: "alert", className: "text-sm text-danger", children: ["Couldn't save the default sender: ", problem, " ", _jsx("a", { href: calendarEventReportHref(problem), target: "_blank", rel: "noreferrer", className: "font-medium text-accent hover:underline", children: "Report an issue" })] }))] }));
16
+ }
@@ -1,27 +1,4 @@
1
- import { type ErrorBannerAction, type ErrorBannerEntry } from "@remit/ui";
2
1
  import { type ReactNode } from "react";
3
- import { type PushErrorInput } from "./error-banners.js";
4
- interface ErrorBannerContextValue {
5
- errors: ErrorBannerEntry[];
6
- pushError: (input: PushErrorInput) => string;
7
- dismissError: (id: string) => void;
8
- clearAll: () => void;
9
- }
10
- /**
11
- * A way out of every failure banner. A soft failure is still a failure the
12
- * user could not prevent and cannot diagnose, and a banner offering only
13
- * "Dismiss" is a dead end — the fatal screen has carried a prefilled report
14
- * since issue #55 and the soft surface never did. The report is seeded from
15
- * the banner it belongs to, so it names the failure instead of asking the
16
- * user to describe it, and it carries the same breadcrumbs — failing request,
17
- * navigation, console — the fatal report does.
18
- *
19
- * A caller that already has a better way out keeps it, and a warning or an
20
- * informational banner gets none: those are not failures to report.
21
- */
22
- export declare const bannerWayOut: (input: PushErrorInput) => ErrorBannerAction | undefined;
23
2
  export declare const ErrorBannerProvider: ({ children }: {
24
3
  children: ReactNode;
25
4
  }) => import("react").JSX.Element;
26
- export declare const useErrorBanners: () => ErrorBannerContextValue;
27
- export {};
@@ -1,39 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ErrorBannerStack, } from "@remit/ui";
3
- import { createContext, useCallback, useContext, useMemo, useState, } from "react";
4
- import { buildBugReportContext, buildGitHubIssueUrl, } from "../../lib/bug-report";
2
+ import { ErrorBannerStack } from "@remit/ui";
3
+ import { useCallback, useMemo, useState } from "react";
5
4
  import { isAlwaysFatal } from "../../lib/error-classifier";
6
5
  import { reportFatalError } from "../../lib/fatal-error";
6
+ import { bannerWayOut, ErrorBannerContext } from "./error-banner-context";
7
7
  import { appendBanner, buildEntry, dismissBanner, } from "./error-banners.js";
8
- const ErrorBannerContext = createContext(undefined);
9
- /**
10
- * A way out of every failure banner. A soft failure is still a failure the
11
- * user could not prevent and cannot diagnose, and a banner offering only
12
- * "Dismiss" is a dead end — the fatal screen has carried a prefilled report
13
- * since issue #55 and the soft surface never did. The report is seeded from
14
- * the banner it belongs to, so it names the failure instead of asking the
15
- * user to describe it, and it carries the same breadcrumbs — failing request,
16
- * navigation, console — the fatal report does.
17
- *
18
- * A caller that already has a better way out keeps it, and a warning or an
19
- * informational banner gets none: those are not failures to report.
20
- */
21
- export const bannerWayOut = (input) => {
22
- if (input.action)
23
- return input.action;
24
- if ((input.severity ?? "error") !== "error")
25
- return undefined;
26
- return {
27
- label: "Report an issue",
28
- href: buildGitHubIssueUrl(buildBugReportContext({
29
- title: `Bug: ${input.title}`,
30
- errorMessage: input.detail
31
- ? `${input.title} — ${input.detail}`
32
- : input.title,
33
- stack: input.error instanceof Error ? input.error.stack : undefined,
34
- })),
35
- };
36
- };
37
8
  const generateId = () => {
38
9
  if (typeof globalThis.crypto !== "undefined" &&
39
10
  typeof globalThis.crypto.randomUUID === "function") {
@@ -73,10 +44,3 @@ export const ErrorBannerProvider = ({ children }) => {
73
44
  const value = useMemo(() => ({ errors, pushError, dismissError, clearAll }), [errors, pushError, dismissError, clearAll]);
74
45
  return (_jsxs(ErrorBannerContext.Provider, { value: value, children: [children, _jsx(ErrorBannerStack, { errors: errors, onDismiss: dismissError })] }));
75
46
  };
76
- export const useErrorBanners = () => {
77
- const context = useContext(ErrorBannerContext);
78
- if (!context) {
79
- throw new Error("useErrorBanners must be used within an ErrorBannerProvider");
80
- }
81
- return context;
82
- };
@@ -0,0 +1,23 @@
1
+ import type { ErrorBannerAction, ErrorBannerEntry } from "@remit/ui";
2
+ import type { PushErrorInput } from "./error-banners.js";
3
+ export interface ErrorBannerContextValue {
4
+ errors: ErrorBannerEntry[];
5
+ pushError: (input: PushErrorInput) => string;
6
+ dismissError: (id: string) => void;
7
+ clearAll: () => void;
8
+ }
9
+ export declare const ErrorBannerContext: import("react").Context<ErrorBannerContextValue | undefined>;
10
+ /**
11
+ * A way out of every failure banner. A soft failure is still a failure the
12
+ * user could not prevent and cannot diagnose, and a banner offering only
13
+ * "Dismiss" is a dead end — the fatal screen has carried a prefilled report
14
+ * since issue #55 and the soft surface never did. The report is seeded from
15
+ * the banner it belongs to, so it names the failure instead of asking the
16
+ * user to describe it, and it carries the same breadcrumbs — failing request,
17
+ * navigation, console — the fatal report does.
18
+ *
19
+ * A caller that already has a better way out keeps it, and a warning or an
20
+ * informational banner gets none: those are not failures to report.
21
+ */
22
+ export declare const bannerWayOut: (input: PushErrorInput) => ErrorBannerAction | undefined;
23
+ export declare const useErrorBanners: () => ErrorBannerContextValue;
@@ -0,0 +1,38 @@
1
+ import { createContext, useContext } from "react";
2
+ import { buildBugReportContext, buildGitHubIssueUrl, } from "../../lib/bug-report";
3
+ export const ErrorBannerContext = createContext(undefined);
4
+ /**
5
+ * A way out of every failure banner. A soft failure is still a failure the
6
+ * user could not prevent and cannot diagnose, and a banner offering only
7
+ * "Dismiss" is a dead end — the fatal screen has carried a prefilled report
8
+ * since issue #55 and the soft surface never did. The report is seeded from
9
+ * the banner it belongs to, so it names the failure instead of asking the
10
+ * user to describe it, and it carries the same breadcrumbs — failing request,
11
+ * navigation, console — the fatal report does.
12
+ *
13
+ * A caller that already has a better way out keeps it, and a warning or an
14
+ * informational banner gets none: those are not failures to report.
15
+ */
16
+ export const bannerWayOut = (input) => {
17
+ if (input.action)
18
+ return input.action;
19
+ if ((input.severity ?? "error") !== "error")
20
+ return undefined;
21
+ return {
22
+ label: "Report an issue",
23
+ href: buildGitHubIssueUrl(buildBugReportContext({
24
+ title: `Bug: ${input.title}`,
25
+ errorMessage: input.detail
26
+ ? `${input.title} — ${input.detail}`
27
+ : input.title,
28
+ stack: input.error instanceof Error ? input.error.stack : undefined,
29
+ })),
30
+ };
31
+ };
32
+ export const useErrorBanners = () => {
33
+ const context = useContext(ErrorBannerContext);
34
+ if (!context) {
35
+ throw new Error("useErrorBanners must be used within an ErrorBannerProvider");
36
+ }
37
+ return context;
38
+ };
@@ -7,12 +7,13 @@
7
7
  * Nothing here reaches the API or the address: the screen reads the state and
8
8
  * runs the save and the navigations itself.
9
9
  */
10
- import type { CalendarSlotPick, GridGesture } from "@remit/ui";
10
+ import type { CalendarSlotPick, GridGesture, GuestEntry } from "@remit/ui";
11
11
  export interface SessionDraft {
12
12
  range: CalendarSlotPick;
13
13
  title: string;
14
14
  location: string;
15
15
  calendarId: string;
16
+ guests: GuestEntry[];
16
17
  }
17
18
  export type DraftStatus = "editing" | "saving" | "failed";
18
19
  export type DraftSession = {
@@ -11,6 +11,7 @@ const blank = (range) => ({
11
11
  title: "",
12
12
  location: "",
13
13
  calendarId: "",
14
+ guests: [],
14
15
  });
15
16
  export function escapeTarget(session, layers) {
16
17
  if (session.dragging)
@@ -10,7 +10,7 @@
10
10
  * `location` and `description` a listing never carried and quietly erase them.
11
11
  */
12
12
  import type { RemitImapCreateCalendarEventInput, RemitImapUpdateCalendarEventInput } from "@remit/api-http-client/types.gen.ts";
13
- import { type CalendarEventData, type EventDraft } from "@remit/ui";
13
+ import { type CalendarEventData, type EventDraft, type GuestEntry } from "@remit/ui";
14
14
  export type DraftRefusal = {
15
15
  ok: false;
16
16
  problem: string;
@@ -45,6 +45,7 @@ export declare function draftFromEvent(event: CalendarEventData, stored: {
45
45
  repeat: string;
46
46
  location: string;
47
47
  notes: string;
48
+ guests: GuestEntry[];
48
49
  }): EventDraft;
49
50
  /**
50
51
  * The draft's wall clock, pinned to an instant on the clock it was read on.
@@ -55,5 +56,10 @@ export declare function timesFor(draft: EventDraft, clock: string): {
55
56
  start: string;
56
57
  end: string;
57
58
  };
58
- export declare function createInputFromDraft(draft: EventDraft, zones: DraftZones): CreateInput;
59
+ /** The guest list as the API takes it: every entry an address, named or not. */
60
+ export declare const attendeesOfDraft: (draft: Pick<EventDraft, "guests">) => {
61
+ email: string;
62
+ displayName: string;
63
+ }[];
64
+ export declare function createInputFromDraft(draft: EventDraft, zones: DraftZones, organizerAccountId: string): CreateInput;
59
65
  export declare function patchFromDrafts(before: EventDraft, after: EventDraft, zones: DraftZones): UpdatePatch;
@@ -1,4 +1,4 @@
1
- import { lastDayOf } from "@remit/ui";
1
+ import { invalidGuest, lastDayOf, } from "@remit/ui";
2
2
  import { moveRule, rruleFromText } from "./recurrence-rule";
3
3
  import { addDays, isoAtInZone, isoOnClock } from "./window";
4
4
  /** A blank event, an hour long, at the start of a working day. */
@@ -12,7 +12,7 @@ export function emptyDraft(date, calendarId) {
12
12
  allDay: false,
13
13
  calendarId,
14
14
  location: "",
15
- guests: "",
15
+ guests: [],
16
16
  notes: "",
17
17
  repeat: "",
18
18
  };
@@ -32,7 +32,7 @@ export function draftFromEvent(event, stored) {
32
32
  allDay: event.allDay,
33
33
  calendarId: event.calendarId,
34
34
  location: stored.location,
35
- guests: "",
35
+ guests: stored.guests,
36
36
  notes: stored.notes,
37
37
  repeat: stored.repeat,
38
38
  };
@@ -82,15 +82,24 @@ function refuse(draft, checkRepeat) {
82
82
  if (!draft.allDay &&
83
83
  `${draft.endDate}T${draft.endTime}` <= `${draft.date}T${draft.startTime}`)
84
84
  return "The end is not after the start. Move one of them.";
85
+ const badGuest = invalidGuest(draft.guests);
86
+ if (badGuest)
87
+ return `${badGuest.text} is not an email address. Fix or remove it to save.`;
85
88
  if (checkRepeat && rruleFromText(draft.repeat) === undefined)
86
89
  return "This calendar can't store that repeat rule. Pick one of the offered rules, or turn the repeat off.";
87
90
  return "";
88
91
  }
89
- export function createInputFromDraft(draft, zones) {
92
+ /** The guest list as the API takes it: every entry an address, named or not. */
93
+ export const attendeesOfDraft = (draft) => draft.guests
94
+ .filter((guest) => guest.valid)
95
+ .map((guest) => ({ email: guest.email, displayName: guest.displayName }));
96
+ const guestKey = (draft) => JSON.stringify(attendeesOfDraft(draft));
97
+ export function createInputFromDraft(draft, zones, organizerAccountId) {
90
98
  const problem = refuse(draft, true);
91
99
  if (problem !== "")
92
100
  return { ok: false, problem };
93
101
  const { start, end } = timesFor(draft, zones.clock);
102
+ const attendees = attendeesOfDraft(draft);
94
103
  return {
95
104
  ok: true,
96
105
  input: {
@@ -103,6 +112,8 @@ export function createInputFromDraft(draft, zones) {
103
112
  allDay: draft.allDay,
104
113
  ...(zones.anchor === "" ? {} : { timeZone: zones.anchor }),
105
114
  recurrenceRule: storedRule(draft, start, zones),
115
+ attendees,
116
+ ...(attendees.length === 0 ? {} : { organizerAccountId }),
106
117
  },
107
118
  };
108
119
  }
@@ -138,5 +149,7 @@ export function patchFromDrafts(before, after, zones) {
138
149
  }
139
150
  if (repeatChanged)
140
151
  patch.recurrenceRule = storedRule(after, start, zones);
152
+ if (guestKey(after) !== guestKey(before))
153
+ patch.attendees = attendeesOfDraft(after);
141
154
  return { ok: true, patch };
142
155
  }
@@ -6,8 +6,8 @@
6
6
  * of them are on screen, and a write invalidates what all of them are showing.
7
7
  */
8
8
  export { type AgendaRange, busySpansByDate, CAP_WEEKS, datesInRange, extendRangeEnd, extendRangeStart, type FreeLookup, freeStretchesByDate, LEAD_IN, LEAD_OUT, liftRangeCeiling, liftRangeFloor, PAGE, rangeAround, rangeAtCeiling, rangeAtFloor, rangeCovering, weekKeyOf, weekWindowsOver, } from "./agenda-window";
9
- export { type CreateInput, createInputFromDraft, type DraftRefusal, type DraftZones, draftFromEvent, emptyDraft, patchFromDrafts, type UpdatePatch, } from "./draft";
10
- export { anchorZoneFor, type CalendarInstanceRef, type CalendarJump, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
9
+ export { attendeesOfDraft, type CreateInput, createInputFromDraft, type DraftRefusal, type DraftZones, draftFromEvent, emptyDraft, patchFromDrafts, type UpdatePatch, } from "./draft";
10
+ export { anchorZoneFor, type CalendarInstanceRef, type CalendarJump, calendarInstanceId, calendarJumpOf, deviceTimeZone, isDrawnInstance, readCalendarInstanceId, rsvpOfParticipation, seriesOccurrenceOf, toCalendarDescriptor, toCalendarEventData, UNZONED_CALENDAR, } from "./instance";
11
11
  export { moveRule, rruleFromText, textFromRrule } from "./recurrence-rule";
12
12
  export { type CalendarResourceText, rruleFromIcalData, storedAnchorZone, textFromIcalData, } from "./resource";
13
13
  export { type CalendarSelection, selectCalendarIds, useCalendarSelection, useDrawnEvents, } from "./selection";
@@ -17,8 +17,10 @@ export { type CalendarEventResource, useCalendarEvent, } from "./useCalendarEven
17
17
  export { CALENDAR_WINDOW_STALE_TIME, type CalendarEventWeeksResult, type CalendarEventWindowRequest, type CalendarEventWindowResult, useCalendarEventWeeks, useCalendarEventWindow, usePrefetchAdjacentWindows, } from "./useCalendarEvents";
18
18
  export { type CalendarFreeBusyResult, useCalendarFreeBusyWeeks, } from "./useCalendarFreeBusy";
19
19
  export { type CalendarJumpSearch, useCalendarJump } from "./useCalendarJump";
20
+ export { type CalendarSenders, type SendsFollowUp, useCalendarSenders, useGuestSuggestions, useSendsFollowUp, } from "./useCalendarScheduling";
20
21
  export { type CalendarSuggestionAnswers, type CalendarSuggestionsResult, type PendingCalendarSuggestionResult, type SuggestionAnswer, useCalendarSuggestionAnswers, useMessageCalendarSuggestions, usePendingCalendarSuggestion, usePendingCalendarSuggestions, } from "./useCalendarSuggestions";
21
22
  export { type CalendarsResult, useCalendars } from "./useCalendars";
23
+ export { type CalendarTaskRead, type TaskWriteOutcome, toTaskData, useCalendarTask, useCalendarTasks, useCalendarTaskWrites, } from "./useCalendarTasks";
22
24
  export { type CalendarCreateOutcome, type CalendarWriteOutcome, type CalendarWrites, type ScopedWrite, useCalendarWrites, useInvalidateCalendarReads, } from "./useCalendarWrites";
23
25
  export { useDraftClashes } from "./useDraftClashes";
24
26
  export { type MoveEvent, useMoveEvent } from "./useMoveEvent";