@remit/web-client 0.0.328 → 0.0.330

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 (159) hide show
  1. package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
  2. package/dist/src/components/calendar/CalendarEventEditor.js +371 -0
  3. package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
  4. package/dist/src/components/calendar/CalendarEventPopup.js +198 -0
  5. package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
  6. package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
  7. package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
  8. package/dist/src/components/calendar/CalendarNavPane.js +50 -0
  9. package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
  10. package/dist/src/components/calendar/CalendarQuickCreate.js +204 -0
  11. package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
  12. package/dist/src/components/calendar/CalendarScreen.js +184 -0
  13. package/dist/src/components/calendar/CalendarSession.d.ts +24 -0
  14. package/dist/src/components/calendar/CalendarSession.js +12 -0
  15. package/dist/src/components/calendar/CalendarTaskPopup.d.ts +4 -0
  16. package/dist/src/components/calendar/CalendarTaskPopup.js +95 -0
  17. package/dist/src/components/calendar/CalendarWaiting.d.ts +3 -3
  18. package/dist/src/components/calendar/CalendarWaiting.js +5 -10
  19. package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
  20. package/dist/src/components/calendar/EventMoves.d.ts +17 -0
  21. package/dist/src/components/calendar/EventMoves.js +103 -0
  22. package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
  23. package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
  24. package/dist/src/components/calendar/calendar-story-server.js +5 -6
  25. package/dist/src/components/compose/ComposeForm.js +1 -1
  26. package/dist/src/components/layout/AppFrame.d.ts +11 -0
  27. package/dist/src/components/layout/AppFrame.js +16 -0
  28. package/dist/src/components/mail/BulkRunProvider.js +1 -1
  29. package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
  30. package/dist/src/components/mail/MessageActionMenu.js +1 -1
  31. package/dist/src/components/mail/MessageList.js +1 -1
  32. package/dist/src/components/mail/OutboxPane.js +1 -1
  33. package/dist/src/components/mail/ThreadListInteraction.js +1 -1
  34. package/dist/src/components/settings/CalendarDefaultSenderCard.d.ts +2 -0
  35. package/dist/src/components/settings/CalendarDefaultSenderCard.js +16 -0
  36. package/dist/src/components/ui/ErrorBannerProvider.d.ts +0 -23
  37. package/dist/src/components/ui/ErrorBannerProvider.js +3 -39
  38. package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
  39. package/dist/src/components/ui/SignedOutOverlay.js +29 -0
  40. package/dist/src/components/ui/error-banner-context.d.ts +23 -0
  41. package/dist/src/components/ui/error-banner-context.js +38 -0
  42. package/dist/src/hooks/calendar/draft-session.d.ts +78 -0
  43. package/dist/src/hooks/calendar/draft-session.js +110 -0
  44. package/dist/src/hooks/calendar/draft.d.ts +8 -2
  45. package/dist/src/hooks/calendar/draft.js +17 -4
  46. package/dist/src/hooks/calendar/index.d.ts +6 -3
  47. package/dist/src/hooks/calendar/index.js +5 -2
  48. package/dist/src/hooks/calendar/instance.d.ts +2 -1
  49. package/dist/src/hooks/calendar/instance.js +14 -1
  50. package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
  51. package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
  52. package/dist/src/hooks/calendar/useCalendarScheduling.d.ts +33 -0
  53. package/dist/src/hooks/calendar/useCalendarScheduling.js +118 -0
  54. package/dist/src/hooks/calendar/useCalendarTasks.d.ts +53 -0
  55. package/dist/src/hooks/calendar/useCalendarTasks.js +105 -0
  56. package/dist/src/hooks/calendar/useCalendarWrites.d.ts +18 -2
  57. package/dist/src/hooks/calendar/useCalendarWrites.js +19 -6
  58. package/dist/src/hooks/calendar/useCalendars.d.ts +3 -0
  59. package/dist/src/hooks/calendar/useCalendars.js +13 -5
  60. package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
  61. package/dist/src/hooks/calendar/useDraftSession.js +106 -0
  62. package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
  63. package/dist/src/hooks/calendar/useMoveEvent.js +62 -0
  64. package/dist/src/hooks/use-system-update.js +3 -5
  65. package/dist/src/hooks/useApplyLabel.js +1 -1
  66. package/dist/src/hooks/useCalendarData.d.ts +9 -2
  67. package/dist/src/hooks/useCalendarData.js +22 -5
  68. package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
  69. package/dist/src/hooks/useCalendarSidePane.js +30 -0
  70. package/dist/src/hooks/useComposeLanguages.js +1 -1
  71. package/dist/src/hooks/useDeleteMessages.js +1 -1
  72. package/dist/src/hooks/useEmptyTrash.js +1 -1
  73. package/dist/src/hooks/useEscalatedActions.js +1 -1
  74. package/dist/src/hooks/useFilters.d.ts +1 -1
  75. package/dist/src/hooks/useLabels.d.ts +1 -1
  76. package/dist/src/hooks/useMarkAsRead.js +1 -1
  77. package/dist/src/hooks/useMoveMessages.js +1 -1
  78. package/dist/src/hooks/useRefreshControl.js +4 -8
  79. package/dist/src/hooks/useReportSpam.js +1 -1
  80. package/dist/src/hooks/useSignature.js +1 -1
  81. package/dist/src/hooks/useStaleAccountSync.js +4 -4
  82. package/dist/src/hooks/useStarredThreads.d.ts +1 -1
  83. package/dist/src/hooks/useToggleStar.js +1 -1
  84. package/dist/src/hooks/useToggleTrusted.js +1 -1
  85. package/dist/src/hooks/useTriggerSync.d.ts +1 -1
  86. package/dist/src/hooks/useUpdateAddressFlags.js +1 -1
  87. package/dist/src/hooks/useWarningsAttention.js +1 -3
  88. package/dist/src/lib/calendar-route.d.ts +6 -0
  89. package/dist/src/lib/calendar-route.js +14 -0
  90. package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
  91. package/dist/src/lib/calendar-side-pane-pref.js +27 -0
  92. package/dist/src/lib/error-classifier.d.ts +5 -30
  93. package/dist/src/lib/error-classifier.js +7 -10
  94. package/dist/src/lib/escalate.d.ts +6 -0
  95. package/dist/src/lib/escalate.js +16 -0
  96. package/dist/src/lib/intelligence-pref.js +3 -2
  97. package/dist/src/lib/new-event-range.d.ts +26 -0
  98. package/dist/src/lib/new-event-range.js +69 -0
  99. package/dist/src/lib/query-error-handler.d.ts +2 -6
  100. package/dist/src/lib/query-error-handler.js +5 -14
  101. package/dist/src/lib/signed-out.d.ts +13 -0
  102. package/dist/src/lib/signed-out.js +28 -0
  103. package/dist/src/routeTree.gen.d.ts +98 -19
  104. package/dist/src/routeTree.gen.js +32 -1
  105. package/dist/src/routes/__root.js +8 -2
  106. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
  107. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
  108. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
  109. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
  110. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
  111. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
  112. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
  113. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
  114. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
  115. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
  116. package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
  117. package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
  118. package/dist/src/routes/calendar/$view.$date/index.js +3 -10
  119. package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
  120. package/dist/src/routes/calendar/$view.$date/new.js +8 -13
  121. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
  122. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
  123. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.d.ts +5 -0
  124. package/dist/src/routes/calendar/$view.$date/task.$calendarTaskId.js +16 -0
  125. package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
  126. package/dist/src/routes/calendar/$view.$date.js +14 -50
  127. package/dist/src/routes/calendar/index.d.ts +1 -1
  128. package/dist/src/routes/calendar/index.js +2 -1
  129. package/dist/src/routes/calendar.d.ts +4 -9
  130. package/dist/src/routes/calendar.js +10 -35
  131. package/dist/src/routes/mail/index.d.ts +1 -1
  132. package/dist/src/routes/mail/index.js +7 -2
  133. package/dist/src/routes/mail.js +6 -5
  134. package/dist/src/routes/settings/calendars.js +2 -1
  135. package/dist/src/routing/app-switch.d.ts +11 -0
  136. package/dist/src/routing/app-switch.js +35 -0
  137. package/dist/src/routing/calendar.d.ts +45 -4
  138. package/dist/src/routing/calendar.js +135 -13
  139. package/dist/src/routing/fragment.d.ts +1 -1
  140. package/dist/src/routing/fragment.js +6 -1
  141. package/dist/src/routing/index.d.ts +2 -1
  142. package/dist/src/routing/index.js +2 -1
  143. package/package.json +2 -2
  144. package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
  145. package/dist/src/components/calendar/CalendarComposePane.js +0 -8
  146. package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
  147. package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
  148. package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
  149. package/dist/src/components/calendar/CalendarEventPane.js +0 -48
  150. package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
  151. package/dist/src/components/calendar/CalendarShell.js +0 -35
  152. package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
  153. package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
  154. package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
  155. package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
  156. package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
  157. package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
  158. package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
  159. package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
@@ -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
  }
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { CalendarFailureNote, EmptyState, EventEditorPane, } from "@remit/ui";
2
+ import { CalendarClashStrip, CalendarEventSidebar, CalendarFailureNote, EmptyState, EventEditorPane, } from "@remit/ui";
3
3
  import { useEffect, useState } from "react";
4
4
  import { acceptEditedInputFromDrafts, anchorZoneFor, deviceTimeZone, draftFromSuggestion, UNZONED_CALENDAR, useCalendarSuggestionAnswers, useCalendars, useDraftClashes, usePendingCalendarSuggestion, } from "../../hooks/calendar";
5
5
  import { calendarReportHref } from "../../lib/calendar-report";
6
- import { suggestionWhen } from "../../lib/calendar-suggestion";
7
- import { CalendarComposePane } from "./CalendarComposePane";
6
+ import { useOptionalCalendarSession } from "./CalendarSession";
8
7
  const TITLE = "Add from mail";
9
8
  const AMBIGUOUS_NOTICE = "The invitation named a time zone nothing could resolve. The time below is as the mail wrote it — check it before adding.";
10
9
  export function ChangeCalendarSuggestion({ suggestionId, onClose, }) {
@@ -30,7 +29,21 @@ function SuggestionEditor({ suggestion, onClose }) {
30
29
  const answers = useCalendarSuggestionAnswers();
31
30
  const [seed] = useState(() => draftFromSuggestion(suggestion, "", deviceTimeZone()));
32
31
  const [draft, setDraft] = useState(seed);
32
+ const dispatch = useOptionalCalendarSession()?.dispatch;
33
+ useEffect(() => {
34
+ dispatch?.({
35
+ type: "sidebar-range",
36
+ range: {
37
+ date: seed.date,
38
+ endDate: seed.endDate,
39
+ startTime: seed.allDay ? "" : seed.startTime,
40
+ endTime: seed.allDay ? "" : seed.endTime,
41
+ allDay: seed.allDay,
42
+ },
43
+ });
44
+ }, [seed, dispatch]);
33
45
  const [problem, setProblem] = useState("");
46
+ const [failure, setFailure] = useState();
34
47
  const clashes = useDraftClashes(draft);
35
48
  const initialCalendarId = calendars.some((calendar) => calendar.id === defaultCalendarId)
36
49
  ? defaultCalendarId
@@ -59,8 +72,29 @@ function SuggestionEditor({ suggestion, onClose }) {
59
72
  onClose();
60
73
  return;
61
74
  }
62
- setProblem(`Couldn't add this to your calendar: ${answer.message}`);
75
+ const text = `Couldn't add this to your calendar: ${answer.message}`;
76
+ setFailure({
77
+ text,
78
+ reportHref: calendarReportHref(text),
79
+ onRetry: save,
80
+ });
63
81
  });
64
82
  };
65
- return (_jsx(CalendarComposePane, { title: TITLE, subtitle: suggestionWhen(suggestion), notice: suggestion.zoneCertainty === "Ambiguous" ? AMBIGUOUS_NOTICE : "", calendars: calendars, draft: draft, onChange: setDraft, problem: problem, saveLabel: "Add", isSaving: answers.isAnswering, repeatEditable: false, clashes: clashes, onSave: save, onCancel: onClose }));
83
+ return (_jsx(CalendarEventSidebar, { heading: TITLE, draft: draft, onChange: (next) => {
84
+ setDraft(next);
85
+ dispatch?.({
86
+ type: "sidebar-range",
87
+ range: {
88
+ date: next.date,
89
+ endDate: next.endDate,
90
+ startTime: next.allDay ? "" : next.startTime,
91
+ endTime: next.allDay ? "" : next.endTime,
92
+ allDay: next.allDay,
93
+ },
94
+ });
95
+ }, calendars: calendars, calendarEditable: true, repeatEditable: false, timeZone: deviceTimeZone(), timeZones: [deviceTimeZone()], onTimeZone: () => { }, busy: true, onBusy: () => { }, onSave: save, onCancel: onClose, saving: answers.isAnswering, saveLabel: "Add", failure: failure, problem: problem !== ""
96
+ ? problem
97
+ : suggestion.zoneCertainty === "Ambiguous"
98
+ ? AMBIGUOUS_NOTICE
99
+ : "", children: clashes && _jsx(CalendarClashStrip, { clashes: clashes }) }));
66
100
  }
@@ -0,0 +1,17 @@
1
+ import { type CalendarDescriptor, type CalendarEventData, type CalendarSlotPick } from "@remit/ui";
2
+ import { type ReactNode } from "react";
3
+ export interface EventMoves {
4
+ /** The events with a drop that is still saving drawn where it landed. */
5
+ events: CalendarEventData[];
6
+ canMove: (eventId: string) => boolean;
7
+ onMoveEvent: (eventId: string, range: CalendarSlotPick) => void;
8
+ /** The failure above the grid, when the last drop did not save. */
9
+ banner: ReactNode;
10
+ /** The scope question for a repeating event. */
11
+ prompt: ReactNode;
12
+ }
13
+ /**
14
+ * Dragging a stored event: the drop shows where it landed while it saves, a
15
+ * repeating event asks its scope first, and a failure puts it back and says so.
16
+ */
17
+ export declare function useEventMoves(events: CalendarEventData[], calendars: CalendarDescriptor[], timeZoneByCalendarId: Record<string, string>, reloadWeek: () => void): EventMoves;
@@ -0,0 +1,103 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CalendarFailureBlock, Dialog, RecurrenceScopePrompt, } from "@remit/ui";
3
+ import { X } from "lucide-react";
4
+ import { useCallback, useMemo, useRef, useState } from "react";
5
+ import { deviceTimeZone, isoAtInZone, useMoveEvent, } from "../../hooks/calendar";
6
+ import { formatEventWhen } from "../../lib/calendar-format";
7
+ import { calendarEventReportHref } from "../../lib/calendar-report";
8
+ const CONFLICT = "This calendar changed while you were writing.";
9
+ const placed = (event, range) => {
10
+ if (range.allDay)
11
+ return {
12
+ ...event,
13
+ start: `${range.date}T00:00:00`,
14
+ end: `${addDay(range.endDate)}T00:00:00`,
15
+ };
16
+ const zone = deviceTimeZone();
17
+ return {
18
+ ...event,
19
+ start: isoAtInZone(range.date, range.startTime, zone),
20
+ end: isoAtInZone(range.endDate, range.endTime, zone),
21
+ };
22
+ };
23
+ function addDay(date) {
24
+ const [year, month, day] = date.split("-").map(Number);
25
+ return new Date(Date.UTC(year, month - 1, day + 1))
26
+ .toISOString()
27
+ .slice(0, 10);
28
+ }
29
+ /**
30
+ * Dragging a stored event: the drop shows where it landed while it saves, a
31
+ * repeating event asks its scope first, and a failure puts it back and says so.
32
+ */
33
+ export function useEventMoves(events, calendars, timeZoneByCalendarId, reloadWeek) {
34
+ const move = useMoveEvent();
35
+ const [pending, setPending] = useState(() => new Map());
36
+ const [asking, setAsking] = useState();
37
+ const [failure, setFailure] = useState();
38
+ const failureRef = useRef(null);
39
+ const readOnly = useMemo(() => new Set(calendars
40
+ .filter((calendar) => calendar.readOnly)
41
+ .map((calendar) => calendar.id)), [calendars]);
42
+ const run = useCallback((drop, scope) => {
43
+ setAsking(undefined);
44
+ setFailure(undefined);
45
+ setPending((current) => new Map(current).set(drop.event.id, drop.range));
46
+ void move(drop.event, drop.range, scope, timeZoneByCalendarId[drop.event.calendarId] ?? "").then((outcome) => {
47
+ setPending((current) => {
48
+ const next = new Map(current);
49
+ next.delete(drop.event.id);
50
+ return next;
51
+ });
52
+ if (outcome.kind === "written")
53
+ return;
54
+ setFailure({
55
+ text: outcome.kind === "conflict"
56
+ ? CONFLICT
57
+ : `Couldn't move ${drop.event.title}: ${outcome.message}`,
58
+ retry: () => run(drop, scope),
59
+ conflict: outcome.kind === "conflict",
60
+ });
61
+ requestAnimationFrame(() => failureRef.current?.focus());
62
+ });
63
+ }, [move, timeZoneByCalendarId]);
64
+ const onMoveEvent = useCallback((eventId, range) => {
65
+ const event = events.find((candidate) => candidate.id === eventId);
66
+ if (!event)
67
+ return;
68
+ const drop = { event, range };
69
+ if (event.seriesId !== "") {
70
+ setAsking(drop);
71
+ return;
72
+ }
73
+ run(drop, undefined);
74
+ }, [events, run]);
75
+ const drawn = useMemo(() => pending.size === 0
76
+ ? events
77
+ : events.map((event) => {
78
+ const range = pending.get(event.id);
79
+ return range ? placed(event, range) : event;
80
+ }), [events, pending]);
81
+ const banner = failure && (_jsxs("div", { className: "flex items-start gap-2 border-b border-line px-3 py-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(CalendarFailureBlock, { focusRef: failureRef, failure: {
82
+ text: failure.text,
83
+ reportHref: calendarEventReportHref(failure.text),
84
+ onRetry: failure.conflict
85
+ ? () => {
86
+ setFailure(undefined);
87
+ reloadWeek();
88
+ }
89
+ : failure.retry,
90
+ retryLabel: failure.conflict ? "Reload the week" : undefined,
91
+ } }) }), _jsx("button", { type: "button", "aria-label": "Dismiss", onClick: () => setFailure(undefined), className: "flex size-8 items-center justify-center rounded-full text-fg-muted hover:bg-surface-sunken", children: _jsx(X, { className: "size-4" }) })] }));
92
+ const prompt = (_jsx(Dialog, { open: asking !== undefined, onClose: () => setAsking(undefined), title: "Move a repeating event", children: asking && (_jsx(RecurrenceScopePrompt, { title: asking.event.title, ruleText: "It repeats", instanceText: formatEventWhen(asking.event), onChoose: (scope) => run(asking, scope), onCancel: () => setAsking(undefined) })) }));
93
+ return {
94
+ events: drawn,
95
+ canMove: (eventId) => {
96
+ const event = events.find((candidate) => candidate.id === eventId);
97
+ return event !== undefined && !readOnly.has(event.calendarId);
98
+ },
99
+ onMoveEvent,
100
+ banner,
101
+ prompt,
102
+ };
103
+ }
@@ -59,8 +59,14 @@ export const standup = at("Standup", "10", "09:15", "09:30", {
59
59
  export const fortnight = [
60
60
  standup,
61
61
  roadmap,
62
- at("Dentist", "11", "11:00", "12:00", { icalUid: "uid-dentist" }),
63
- at("Retro", "18", "16:00", "17:00", { icalUid: "uid-retro" }),
62
+ at("Dentist", "11", "11:00", "12:00", {
63
+ icalUid: "uid-dentist",
64
+ calendarObjectId: "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
65
+ }),
66
+ at("Retro", "18", "16:00", "17:00", {
67
+ icalUid: "uid-retro",
68
+ calendarObjectId: "dddddddd-dddd-4ddd-8ddd-dddddddddddd",
69
+ }),
64
70
  ];
65
71
  export const roadmapResource = {
66
72
  calendarObjectId: ROADMAP_OBJECT,
@@ -1,9 +1,8 @@
1
- import type { CalendarSlotPick } from "@remit/ui";
2
1
  import { type ReactNode } from "react";
3
2
  /**
4
3
  * The calendar's addresses and its server, stood up for a story.
5
4
  *
6
- * `AgendaView`, `OpenCalendarEvent` and `WriteCalendarEvent` are the three panes
5
+ * `AgendaView` and `ChangeCalendarSuggestion` are the panes
7
6
  * that read the address and read the API, so a story cannot hand them props:
8
7
  * what they draw comes out of a URL and a response. Both are supplied here, with
9
8
  * synthetic answers, so the story still names one state and asserts it.
@@ -31,7 +30,5 @@ export interface CalendarStoryProps {
31
30
  entry: string;
32
31
  /** What the server answers, request by request. */
33
32
  server: CalendarServer;
34
- /** The slot a reader dragged out of the grid, for the composer. */
35
- pick?: CalendarSlotPick;
36
33
  }
37
- export declare function CalendarStory({ pane, entry, server, pick, }: CalendarStoryProps): import("react").JSX.Element;
34
+ export declare function CalendarStory({ pane, entry, server }: CalendarStoryProps): import("react").JSX.Element;
@@ -5,11 +5,10 @@ import { useState } from "react";
5
5
  import { calendarSearchSchema } from "../../lib/calendar-route";
6
6
  import { client } from "../../lib/client";
7
7
  import { stringifySearch } from "../../lib/search-params";
8
- import { CalendarComposeSeedProvider } from "./CalendarComposeSeed";
9
8
  /**
10
9
  * The calendar's addresses and its server, stood up for a story.
11
10
  *
12
- * `AgendaView`, `OpenCalendarEvent` and `WriteCalendarEvent` are the three panes
11
+ * `AgendaView` and `ChangeCalendarSuggestion` are the panes
13
12
  * that read the address and read the API, so a story cannot hand them props:
14
13
  * what they draw comes out of a URL and a response. Both are supplied here, with
15
14
  * synthetic answers, so the story still names one state and asserts it.
@@ -34,14 +33,14 @@ export const json = (body, status = 200) => new Response(JSON.stringify(body), {
34
33
  export const never = () => new Promise(() => { });
35
34
  /** Nowhere. Every request is answered before it can leave. */
36
35
  const STORY_BASE_URL = "https://calendar.story.invalid";
37
- function storyRouter(entry, pane, pick) {
36
+ function storyRouter(entry, pane) {
38
37
  const leaf = () => _jsx(_Fragment, { children: pane });
39
38
  const rootRoute = createRootRoute({ component: Outlet });
40
39
  const viewRoute = createRoute({
41
40
  getParentRoute: () => rootRoute,
42
41
  path: "/calendar/$view/$date",
43
42
  validateSearch: calendarSearchSchema,
44
- component: () => (_jsx(CalendarComposeSeedProvider, { pick: pick, children: _jsx(Outlet, {}) })),
43
+ component: () => _jsx(Outlet, {}),
45
44
  });
46
45
  const eventRoute = createRoute({
47
46
  getParentRoute: () => viewRoute,
@@ -85,7 +84,7 @@ function storyRouter(entry, pane, pick) {
85
84
  history: createMemoryHistory({ initialEntries: [entry] }),
86
85
  });
87
86
  }
88
- export function CalendarStory({ pane, entry, server, pick, }) {
87
+ export function CalendarStory({ pane, entry, server }) {
89
88
  // Built once, and the client configured before anything can ask it a
90
89
  // question: a pane that fetched against the default host would reach for the
91
90
  // network on its first render.
@@ -95,7 +94,7 @@ export function CalendarStory({ pane, entry, server, pick, }) {
95
94
  fetch: ((input) => Promise.resolve(server(input instanceof Request ? input : new Request(String(input))))),
96
95
  });
97
96
  return {
98
- router: storyRouter(entry, pane, pick),
97
+ router: storyRouter(entry, pane),
99
98
  queryClient: new QueryClient({
100
99
  defaultOptions: {
101
100
  queries: { retry: false },
@@ -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";
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ export interface AppFrameProps {
3
+ children: ReactNode;
4
+ /** A full-screen surface on a phone takes the tab bar's room too. */
5
+ hideTabBar?: boolean;
6
+ }
7
+ /**
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.
10
+ */
11
+ export declare function AppFrame({ children, hideTabBar }: AppFrameProps): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AppBar, AppTabBar } from "@remit/ui";
3
+ import { useLayoutTier } from "../../hooks/useLayoutTier";
4
+ import { useAppSwitch } from "../../routing";
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.
8
+ */
9
+ export function AppFrame({ children, hideTabBar = false }) {
10
+ const isPhone = useLayoutTier() === "phone";
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 })] }));
16
+ }
@@ -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";
@@ -157,5 +157,5 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
157
157
  onSearchChange("");
158
158
  onMailboxSelect?.();
159
159
  };
160
- return (_jsx(NavSidebar, { accounts: navAccounts, selectedNavId: selectedNavId, onSelectNav: handleSelectNav, linkComponent: linkComponent, calendarNav: "shown", variant: variant }));
160
+ return (_jsx(NavSidebar, { accounts: navAccounts, selectedNavId: selectedNavId, onSelectNav: handleSelectNav, linkComponent: linkComponent, variant: variant }));
161
161
  }
@@ -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,6 @@
1
+ /**
2
+ * The signed-out notice every screen shares. It covers the screen so nothing
3
+ * behind it reads as empty data, stays until the reader signs in, and its sign
4
+ * in clears the dead session so the sign-in screen opens at the same address.
5
+ */
6
+ export declare function SignedOutOverlay(): import("react").JSX.Element | null;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useModalFocus, useOverlayScope } from "@remit/ui";
3
+ import { LogIn } from "lucide-react";
4
+ import { useEffect, useRef, useState } from "react";
5
+ import { useAuthProvider } from "../../auth/provider";
6
+ import { isSignedOut, resetSignedOut, subscribeSignedOut, } from "../../lib/signed-out";
7
+ const SIGN_IN_CLASS = "mt-6 inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:ring-2 focus-visible:ring-ring";
8
+ /**
9
+ * The signed-out notice every screen shares. It covers the screen so nothing
10
+ * behind it reads as empty data, stays until the reader signs in, and its sign
11
+ * in clears the dead session so the sign-in screen opens at the same address.
12
+ */
13
+ export function SignedOutOverlay() {
14
+ const [open, setOpen] = useState(isSignedOut);
15
+ const { Account } = useAuthProvider();
16
+ const dialogRef = useRef(null);
17
+ useEffect(() => subscribeSignedOut(setOpen), []);
18
+ useOverlayScope({ id: "signed-out", open });
19
+ useModalFocus(dialogRef, open);
20
+ if (!open)
21
+ return null;
22
+ return (_jsx("div", { className: "fixed inset-0 z-[70] flex items-center justify-center bg-canvas/80 p-4 backdrop-blur-sm", children: _jsxs("div", { ref: dialogRef, role: "alertdialog", "aria-modal": "true", "aria-labelledby": "signed-out-title", "aria-describedby": "signed-out-text", tabIndex: -1, className: "w-full max-w-sm rounded-lg border border-line bg-surface p-6 shadow-xl outline-none", children: [_jsx("h2", { id: "signed-out-title", className: "text-lg font-semibold text-fg", children: "You're signed out" }), _jsx("p", { id: "signed-out-text", className: "mt-2 text-sm text-fg-muted", children: "The server no longer accepts this session. Sign in again to carry on here; you will come back to this screen." }), _jsx(Account, { fallback: _jsxs("button", { type: "button", onClick: () => {
23
+ resetSignedOut();
24
+ window.location.reload();
25
+ }, className: SIGN_IN_CLASS, children: [_jsx(LogIn, { className: "size-4", "aria-hidden": "true" }), "Sign in"] }), children: ({ signOut }) => (_jsxs("button", { type: "button", onClick: () => {
26
+ resetSignedOut();
27
+ void signOut();
28
+ }, className: SIGN_IN_CLASS, children: [_jsx(LogIn, { className: "size-4", "aria-hidden": "true" }), "Sign in"] })) })] }) }));
29
+ }
@@ -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
+ };