@remit/web-client 0.0.328 → 0.0.329
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
- package/dist/src/components/calendar/CalendarEventEditor.js +321 -0
- package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
- package/dist/src/components/calendar/CalendarEventPopup.js +133 -0
- package/dist/src/components/calendar/CalendarLoadFailed.d.ts +8 -0
- package/dist/src/components/calendar/CalendarLoadFailed.js +11 -0
- package/dist/src/components/calendar/CalendarNavPane.d.ts +11 -0
- package/dist/src/components/calendar/CalendarNavPane.js +50 -0
- package/dist/src/components/calendar/CalendarQuickCreate.d.ts +22 -0
- package/dist/src/components/calendar/CalendarQuickCreate.js +131 -0
- package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
- package/dist/src/components/calendar/CalendarScreen.js +145 -0
- package/dist/src/components/calendar/CalendarSession.d.ts +21 -0
- package/dist/src/components/calendar/CalendarSession.js +12 -0
- package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
- package/dist/src/components/calendar/EventMoves.d.ts +17 -0
- package/dist/src/components/calendar/EventMoves.js +103 -0
- package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
- package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
- package/dist/src/components/calendar/calendar-story-server.js +5 -6
- package/dist/src/components/layout/AppFrame.d.ts +11 -0
- package/dist/src/components/layout/AppFrame.js +16 -0
- package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
- package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
- package/dist/src/components/ui/SignedOutOverlay.js +29 -0
- package/dist/src/hooks/calendar/draft-session.d.ts +77 -0
- package/dist/src/hooks/calendar/draft-session.js +109 -0
- package/dist/src/hooks/calendar/index.d.ts +2 -1
- package/dist/src/hooks/calendar/index.js +1 -0
- package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
- package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
- package/dist/src/hooks/calendar/useCalendarWrites.d.ts +11 -1
- package/dist/src/hooks/calendar/useCalendarWrites.js +7 -2
- package/dist/src/hooks/calendar/useCalendars.d.ts +1 -0
- package/dist/src/hooks/calendar/useCalendars.js +5 -2
- package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
- package/dist/src/hooks/calendar/useDraftSession.js +106 -0
- package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
- package/dist/src/hooks/calendar/useMoveEvent.js +61 -0
- package/dist/src/hooks/use-system-update.js +3 -5
- package/dist/src/hooks/useCalendarData.d.ts +2 -0
- package/dist/src/hooks/useCalendarData.js +6 -1
- package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
- package/dist/src/hooks/useCalendarSidePane.js +30 -0
- package/dist/src/hooks/useRefreshControl.js +4 -8
- package/dist/src/hooks/useStaleAccountSync.js +4 -4
- package/dist/src/hooks/useWarningsAttention.js +1 -3
- package/dist/src/lib/calendar-route.d.ts +6 -0
- package/dist/src/lib/calendar-route.js +14 -0
- package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
- package/dist/src/lib/calendar-side-pane-pref.js +27 -0
- package/dist/src/lib/error-classifier.d.ts +5 -30
- package/dist/src/lib/error-classifier.js +7 -10
- package/dist/src/lib/escalate.d.ts +6 -0
- package/dist/src/lib/escalate.js +16 -0
- package/dist/src/lib/intelligence-pref.js +3 -2
- package/dist/src/lib/new-event-range.d.ts +26 -0
- package/dist/src/lib/new-event-range.js +69 -0
- package/dist/src/lib/query-error-handler.d.ts +2 -6
- package/dist/src/lib/query-error-handler.js +5 -14
- package/dist/src/lib/signed-out.d.ts +13 -0
- package/dist/src/lib/signed-out.js +28 -0
- package/dist/src/routeTree.gen.d.ts +81 -19
- package/dist/src/routeTree.gen.js +25 -1
- package/dist/src/routes/__root.js +8 -2
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
- package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
- package/dist/src/routes/calendar/$view.$date/index.js +3 -10
- package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
- package/dist/src/routes/calendar/$view.$date/new.js +8 -13
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
- package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
- package/dist/src/routes/calendar/$view.$date.js +14 -50
- package/dist/src/routes/calendar/index.d.ts +1 -1
- package/dist/src/routes/calendar/index.js +2 -1
- package/dist/src/routes/calendar.d.ts +4 -9
- package/dist/src/routes/calendar.js +10 -35
- package/dist/src/routes/mail/index.d.ts +1 -1
- package/dist/src/routes/mail/index.js +7 -2
- package/dist/src/routes/mail.js +6 -5
- package/dist/src/routing/app-switch.d.ts +11 -0
- package/dist/src/routing/app-switch.js +35 -0
- package/dist/src/routing/calendar.d.ts +41 -4
- package/dist/src/routing/calendar.js +121 -13
- package/dist/src/routing/fragment.d.ts +1 -1
- package/dist/src/routing/fragment.js +6 -1
- package/dist/src/routing/index.d.ts +2 -1
- package/dist/src/routing/index.js +2 -1
- package/package.json +2 -2
- package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
- package/dist/src/components/calendar/CalendarComposePane.js +0 -8
- package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
- package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
- package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
- package/dist/src/components/calendar/CalendarEventPane.js +0 -48
- package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
- package/dist/src/components/calendar/CalendarShell.js +0 -35
- package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
- package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
- package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
- package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
- package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
- package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
- package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
- package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarPopover, CalendarQuickCreateCard, CalendarSheet, } from "@remit/ui";
|
|
3
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
|
+
import { anchorZoneFor, createInputFromDraft, deviceTimeZone, UNZONED_CALENDAR, useCalendars, useCalendarWrites, } from "../../hooks/calendar";
|
|
5
|
+
import { calendarEventReportHref } from "../../lib/calendar-report";
|
|
6
|
+
import { useBackCloses } from "../../routing";
|
|
7
|
+
export const SETTINGS_HREF = "/settings/calendars";
|
|
8
|
+
/** The session's draft as the editor and the write read it. */
|
|
9
|
+
export function eventDraftOf(draft) {
|
|
10
|
+
return {
|
|
11
|
+
title: draft.title,
|
|
12
|
+
date: draft.range.date,
|
|
13
|
+
startTime: draft.range.startTime,
|
|
14
|
+
endDate: draft.range.endDate,
|
|
15
|
+
endTime: draft.range.endTime,
|
|
16
|
+
allDay: draft.range.allDay,
|
|
17
|
+
calendarId: draft.calendarId,
|
|
18
|
+
location: draft.location,
|
|
19
|
+
guests: "",
|
|
20
|
+
notes: "",
|
|
21
|
+
repeat: "",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The small popup on a new range. It sends nothing until Save, and a failure
|
|
26
|
+
* keeps every field and says why.
|
|
27
|
+
*/
|
|
28
|
+
export function CalendarQuickCreate({ session, dispatch, onMoreOptions, onSaved, touch = false, }) {
|
|
29
|
+
const headingId = useId();
|
|
30
|
+
const titleRef = useRef(null);
|
|
31
|
+
const failureRef = useRef(null);
|
|
32
|
+
const [problem, setProblem] = useState("");
|
|
33
|
+
const { calendars: all, defaultCalendarId, timeZoneByCalendarId, } = useCalendars();
|
|
34
|
+
const calendars = all.filter((calendar) => !calendar.readOnly);
|
|
35
|
+
const { createEvent } = useCalendarWrites();
|
|
36
|
+
const { draft } = session;
|
|
37
|
+
const fallbackCalendar = calendars.find((calendar) => calendar.id === defaultCalendarId)?.id ??
|
|
38
|
+
calendars[0]?.id ??
|
|
39
|
+
"";
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
titleRef.current?.focus();
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (draft.calendarId !== "" || fallbackCalendar === "")
|
|
45
|
+
return;
|
|
46
|
+
dispatch({
|
|
47
|
+
type: "change",
|
|
48
|
+
draft: { ...draft, calendarId: fallbackCalendar },
|
|
49
|
+
});
|
|
50
|
+
}, [draft, fallbackCalendar, dispatch]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (session.status === "failed")
|
|
53
|
+
failureRef.current?.focus();
|
|
54
|
+
}, [session.status]);
|
|
55
|
+
const lastFocused = useRef(null);
|
|
56
|
+
const sheetRef = useRef(null);
|
|
57
|
+
useBackCloses(touch, () => {
|
|
58
|
+
dispatch({ type: "outside" });
|
|
59
|
+
return true;
|
|
60
|
+
});
|
|
61
|
+
const rangeKey = `${draft.range.date}T${draft.range.startTime}/${draft.range.endDate}T${draft.range.endTime}`;
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const sheet = sheetRef.current;
|
|
64
|
+
if (rangeKey === "")
|
|
65
|
+
return;
|
|
66
|
+
const block = document.querySelector("[data-draft-block]");
|
|
67
|
+
const grid = document.querySelector("[role='grid'][aria-label='Time grid']");
|
|
68
|
+
if (!sheet || !block || !grid)
|
|
69
|
+
return;
|
|
70
|
+
const overlap = block.getBoundingClientRect().bottom -
|
|
71
|
+
sheet.getBoundingClientRect().top +
|
|
72
|
+
16;
|
|
73
|
+
if (overlap > 0)
|
|
74
|
+
grid.scrollTop += overlap;
|
|
75
|
+
}, [rangeKey]);
|
|
76
|
+
const cardRef = useRef(null);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const card = cardRef.current;
|
|
79
|
+
if (!card)
|
|
80
|
+
return;
|
|
81
|
+
const remember = (event) => {
|
|
82
|
+
if (event.target instanceof HTMLInputElement ||
|
|
83
|
+
event.target instanceof HTMLSelectElement)
|
|
84
|
+
lastFocused.current = event.target;
|
|
85
|
+
};
|
|
86
|
+
card.addEventListener("focusin", remember);
|
|
87
|
+
return () => card.removeEventListener("focusin", remember);
|
|
88
|
+
}, []);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const field = lastFocused.current;
|
|
91
|
+
if (rangeKey === "" || !field || document.activeElement === field)
|
|
92
|
+
return;
|
|
93
|
+
field.focus();
|
|
94
|
+
}, [rangeKey]);
|
|
95
|
+
const save = () => {
|
|
96
|
+
const built = createInputFromDraft(eventDraftOf(draft), {
|
|
97
|
+
clock: deviceTimeZone(),
|
|
98
|
+
anchor: anchorZoneFor(timeZoneByCalendarId[draft.calendarId] ?? UNZONED_CALENDAR),
|
|
99
|
+
});
|
|
100
|
+
if (!built.ok) {
|
|
101
|
+
setProblem(built.problem);
|
|
102
|
+
titleRef.current?.focus();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
setProblem("");
|
|
106
|
+
dispatch({ type: "save" });
|
|
107
|
+
void createEvent(built.input).then((outcome) => {
|
|
108
|
+
if (outcome.kind === "created") {
|
|
109
|
+
dispatch({ type: "saved" });
|
|
110
|
+
onSaved(outcome.calendarObjectId);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
dispatch({
|
|
114
|
+
type: "save-failed",
|
|
115
|
+
problem: outcome.kind === "conflict"
|
|
116
|
+
? "This calendar changed while you were writing. Close the form and try again."
|
|
117
|
+
: `Couldn't save this event: ${outcome.message}`,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const card = (dragHandle) => (_jsx("div", { ref: cardRef, children: _jsx(CalendarQuickCreateCard, { headingId: headingId, fields: draft, calendars: calendars, onChange: (fields) => dispatch({ type: "change", draft: fields }), onSave: save, onMoreOptions: () => onMoreOptions(lastFocused.current?.getAttribute("aria-label") ?? ""), onClose: () => dispatch({ type: "outside" }), saving: session.status === "saving", problem: problem, failure: session.status === "failed"
|
|
122
|
+
? {
|
|
123
|
+
text: session.problem,
|
|
124
|
+
reportHref: calendarEventReportHref(session.problem),
|
|
125
|
+
onRetry: save,
|
|
126
|
+
}
|
|
127
|
+
: undefined, failureRef: failureRef, titleRef: titleRef, settingsHref: SETTINGS_HREF, dragHandle: dragHandle, touch: touch }) }));
|
|
128
|
+
if (touch)
|
|
129
|
+
return (_jsx(CalendarSheet, { labelledBy: headingId, onDismiss: () => dispatch({ type: "outside" }), sheetRef: sheetRef, children: card() }));
|
|
130
|
+
return (_jsx(CalendarPopover, { anchor: "[data-draft-block]", anchorKey: rangeKey, labelledBy: headingId, wrapTab: true, header: (handle) => card(handle), children: null }));
|
|
131
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface CalendarScreenProps {
|
|
3
|
+
isPhone: boolean;
|
|
4
|
+
/** What the route below the view has open: an event, the editor. */
|
|
5
|
+
detail: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The calendar's own screen: the toolbar across the top and the view under it,
|
|
9
|
+
* with the grid taking the whole width the panes leave.
|
|
10
|
+
*/
|
|
11
|
+
export declare function CalendarScreen({ isPhone, detail }: CalendarScreenProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarGrid, CalendarScreenToolbar, CalendarTimeGrid, CalendarYear, calendarRangeTitle, clickRange, Dialog, datesFrom, initialFocus, isoWeek, NewEventSquare, Segmented, weekStart, zonedMoment, } from "@remit/ui";
|
|
3
|
+
import { Loader2 } from "lucide-react";
|
|
4
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { calendarInstanceId, deviceTimeZone } from "../../hooks/calendar";
|
|
6
|
+
import { drawnRange } from "../../hooks/calendar/draft-session";
|
|
7
|
+
import { useDraftSession } from "../../hooks/calendar/useDraftSession";
|
|
8
|
+
import { useCalendarData } from "../../hooks/useCalendarData";
|
|
9
|
+
import { useCalendarSidePane } from "../../hooks/useCalendarSidePane";
|
|
10
|
+
import { readCalendarDensity, writeCalendarDensity, } from "../../lib/calendar-density";
|
|
11
|
+
import { calendarViewMountsAgenda, isoDate, shownCalendarView, stepCalendarDate, } from "../../lib/calendar-route";
|
|
12
|
+
import { searchFromRange } from "../../lib/new-event-range";
|
|
13
|
+
import { useCalendarAddress, useCalendarNavigation, useEditingEvent, useIsWritingEvent, useOpenCalendarEvent, } from "../../routing";
|
|
14
|
+
import { AgendaView } from "./AgendaView";
|
|
15
|
+
import { CalendarLoadFailed } from "./CalendarLoadFailed";
|
|
16
|
+
import { CALENDAR_SIDE_PANE_ID, CalendarNavPane } from "./CalendarNavPane";
|
|
17
|
+
import { CalendarQuickCreate } from "./CalendarQuickCreate";
|
|
18
|
+
import { CalendarSessionContext } from "./CalendarSession";
|
|
19
|
+
import { useEventMoves } from "./EventMoves";
|
|
20
|
+
import { PendingSuggestions } from "./PendingSuggestions";
|
|
21
|
+
const PHONE_VIEWS = ["day", "month", "agenda"];
|
|
22
|
+
const DENSITY_OPTIONS = [
|
|
23
|
+
{ value: "comfortable", label: "Detail", shortLabel: "Detail" },
|
|
24
|
+
{ value: "compact", label: "Glance", shortLabel: "Glance" },
|
|
25
|
+
];
|
|
26
|
+
const FAILED_TITLE = {
|
|
27
|
+
year: "Couldn't load this year",
|
|
28
|
+
month: "Couldn't load this month",
|
|
29
|
+
week: "Couldn't load this week",
|
|
30
|
+
day: "Couldn't load this day",
|
|
31
|
+
agenda: "Couldn't load these days",
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The calendar's own screen: the toolbar across the top and the view under it,
|
|
35
|
+
* with the grid taking the whole width the panes leave.
|
|
36
|
+
*/
|
|
37
|
+
export function CalendarScreen({ isPhone, detail }) {
|
|
38
|
+
const { view, date, calendarIds } = useCalendarAddress();
|
|
39
|
+
const drawsGrid = !calendarViewMountsAgenda(view);
|
|
40
|
+
const { events: storedEvents, calendars, timeZoneByCalendarId, colorByCalendarId, isLoading, error, retry, instanceOf, } = useCalendarData({ view, date, calendarIds, enabled: drawsGrid });
|
|
41
|
+
const moves = useEventMoves(storedEvents, calendars, timeZoneByCalendarId, retry);
|
|
42
|
+
const events = moves.events;
|
|
43
|
+
const { goToView, goToToday, goToDate, openEvent, openNewEvent, closeToView, changeSuggestionFirst, zoomToDay, dayHref, } = useCalendarNavigation();
|
|
44
|
+
const editingEvent = useEditingEvent();
|
|
45
|
+
const routedEvent = useOpenCalendarEvent();
|
|
46
|
+
const openedEvent = editingEvent ? undefined : routedEvent;
|
|
47
|
+
const isWriting = useIsWritingEvent();
|
|
48
|
+
const [density, setDensity] = useState(readCalendarDensity);
|
|
49
|
+
const changeDensity = useCallback((next) => {
|
|
50
|
+
writeCalendarDensity(next);
|
|
51
|
+
setDensity(next);
|
|
52
|
+
}, []);
|
|
53
|
+
const selectEvent = useCallback((eventId) => {
|
|
54
|
+
const instance = instanceOf(eventId);
|
|
55
|
+
openEvent(instance.calendarObjectId, instance.recurrenceId);
|
|
56
|
+
}, [instanceOf, openEvent]);
|
|
57
|
+
const hasDetail = isWriting;
|
|
58
|
+
const sidePane = useCalendarSidePane(isPhone);
|
|
59
|
+
const { session, dispatch, takeGesture, setOrigin, requestClose, carriedFocus, focusSaved, } = useDraftSession({
|
|
60
|
+
layers: {
|
|
61
|
+
eventPopup: openedEvent !== undefined,
|
|
62
|
+
sidebar: isWriting,
|
|
63
|
+
nav: sidePane.navOpen,
|
|
64
|
+
},
|
|
65
|
+
isPhone,
|
|
66
|
+
closeToView,
|
|
67
|
+
closeNav: () => sidePane.setNavOpen(false),
|
|
68
|
+
drawnEvents: events,
|
|
69
|
+
});
|
|
70
|
+
const moreOptions = useCallback((focusedLabel) => {
|
|
71
|
+
if (session.mode !== "quick")
|
|
72
|
+
return;
|
|
73
|
+
carriedFocus.current = focusedLabel;
|
|
74
|
+
dispatch({ type: "expand" });
|
|
75
|
+
openNewEvent(searchFromRange(session.draft.range, deviceTimeZone()));
|
|
76
|
+
}, [session, carriedFocus, dispatch, openNewEvent]);
|
|
77
|
+
const sessionValue = useMemo(() => ({ session, dispatch, requestClose, carriedFocus, focusSaved }), [session, dispatch, requestClose, carriedFocus, focusSaved]);
|
|
78
|
+
const drawn = drawnRange(session);
|
|
79
|
+
const gridDraft = drawn
|
|
80
|
+
? {
|
|
81
|
+
range: drawn,
|
|
82
|
+
title: session.mode === "idle" ? "" : session.draft.title,
|
|
83
|
+
tone: session.mode === "sidebar" && !session.dragging
|
|
84
|
+
? "draft"
|
|
85
|
+
: "selection",
|
|
86
|
+
warning: session.mode === "quick" && session.status === "failed",
|
|
87
|
+
handles: session.mode === "sidebar",
|
|
88
|
+
}
|
|
89
|
+
: undefined;
|
|
90
|
+
const now = new Date().toISOString();
|
|
91
|
+
const shown = shownCalendarView(view, isPhone);
|
|
92
|
+
const pickSlot = (slot) => dispatch({ type: "new-event", range: slot });
|
|
93
|
+
const yearCounts = useMemo(() => {
|
|
94
|
+
const counts = {};
|
|
95
|
+
if (shown !== "year")
|
|
96
|
+
return counts;
|
|
97
|
+
const zone = deviceTimeZone();
|
|
98
|
+
for (const event of events) {
|
|
99
|
+
const day = event.allDay
|
|
100
|
+
? event.start.slice(0, 10)
|
|
101
|
+
: zonedMoment(event.start, zone).date;
|
|
102
|
+
counts[day] = (counts[day] ?? 0) + 1;
|
|
103
|
+
}
|
|
104
|
+
return counts;
|
|
105
|
+
}, [events, shown]);
|
|
106
|
+
const timeGridDays = shown === "day"
|
|
107
|
+
? [date]
|
|
108
|
+
: shown === "week"
|
|
109
|
+
? datesFrom(weekStart(date), 7)
|
|
110
|
+
: undefined;
|
|
111
|
+
const selectedEventId = openedEvent
|
|
112
|
+
? calendarInstanceId(openedEvent.calendarObjectId, openedEvent.recurrenceId ?? "")
|
|
113
|
+
: "";
|
|
114
|
+
const newEventRef = useRef(null);
|
|
115
|
+
const newEvent = useCallback(() => {
|
|
116
|
+
const today = isoDate(new Date());
|
|
117
|
+
const minutes = new Date().getHours() * 60;
|
|
118
|
+
const days = timeGridDays ?? [date];
|
|
119
|
+
const slot = initialFocus(days, today, minutes);
|
|
120
|
+
setOrigin(document.activeElement instanceof HTMLElement
|
|
121
|
+
? document.activeElement
|
|
122
|
+
: newEventRef.current);
|
|
123
|
+
if (openedEvent)
|
|
124
|
+
closeToView();
|
|
125
|
+
dispatch({ type: "new-event", range: clickRange(slot.date, slot.minute) });
|
|
126
|
+
}, [timeGridDays, date, openedEvent, closeToView, setOrigin, dispatch]);
|
|
127
|
+
const weekNumber = shown === "week" || shown === "day"
|
|
128
|
+
? isoWeek(shown === "week" ? weekStart(date) : date)
|
|
129
|
+
: undefined;
|
|
130
|
+
const body = calendarViewMountsAgenda(view) ? (_jsx(AgendaView, { density: density, onPickSlot: pickSlot })) : error !== undefined && error !== null ? (_jsx(CalendarLoadFailed, { title: FAILED_TITLE[view], error: error, onRetry: retry })) : isLoading ? (_jsx("div", { role: "status", "aria-label": "Loading the calendar", className: "flex h-full items-center justify-center bg-surface", children: _jsx(Loader2, { className: "size-6 animate-spin text-fg-subtle" }) })) : shown === "year" ? (_jsx(CalendarYear, { date: date, today: isoDate(new Date()), counts: yearCounts, onPickDay: zoomToDay })) : timeGridDays ? (_jsx(CalendarTimeGrid, { days: timeGridDays, events: events, colorByCalendarId: colorByCalendarId, density: density, timeZone: deviceTimeZone(), now: now, selectedEventId: selectedEventId, draft: gridDraft, onGesture: takeGesture, onSelectEvent: selectEvent, onOpenDay: zoomToDay, touch: isPhone, canMove: moves.canMove, onMoveEvent: moves.onMoveEvent })) : (_jsx(CalendarGrid, { date: date, events: events, colorByCalendarId: colorByCalendarId, density: density, selectedEventId: selectedEventId, timeZone: deviceTimeZone(), now: now, onSelectEvent: selectEvent, onPickSlot: pickSlot, dayHref: dayHref, onZoomDay: zoomToDay, canMove: moves.canMove, onMoveEvent: moves.onMoveEvent }));
|
|
131
|
+
return (_jsxs(CalendarSessionContext.Provider, { value: sessionValue, children: [_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-surface text-fg", children: [_jsx(CalendarScreenToolbar, { view: shown, views: isPhone ? PHONE_VIEWS : undefined, title: isPhone && shown === "day"
|
|
132
|
+
? new Intl.DateTimeFormat(undefined, {
|
|
133
|
+
weekday: "short",
|
|
134
|
+
day: "numeric",
|
|
135
|
+
month: "short",
|
|
136
|
+
timeZone: "UTC",
|
|
137
|
+
}).format(new Date(`${date}T00:00:00Z`))
|
|
138
|
+
: calendarRangeTitle(shown, date), weekNumber: weekNumber, onChangeView: goToView, onPrev: () => goToDate(stepCalendarDate(date, shown, -1)), onNext: () => goToDate(stepCalendarDate(date, shown, 1)), onToday: goToToday, touch: isPhone, sidePane: {
|
|
139
|
+
open: isPhone ? sidePane.navOpen : sidePane.open,
|
|
140
|
+
controls: CALENDAR_SIDE_PANE_ID,
|
|
141
|
+
onToggle: sidePane.toggle,
|
|
142
|
+
}, trailing: shown === "week" || shown === "day" ? (_jsx(Segmented, { ariaLabel: "Calendar density", options: DENSITY_OPTIONS, value: density, onChange: changeDensity, touch: isPhone, className: "shrink-0" })) : undefined }), _jsxs("div", { className: "relative flex min-h-0 flex-1", children: [sidePane.open && (_jsx(CalendarNavPane, { onNewEvent: newEvent, newEventRef: newEventRef })), !(isPhone && hasDetail) && (_jsxs(_Fragment, { children: [isPhone && session.mode === "idle" && (_jsx(NewEventSquare, { onNewEvent: newEvent, newEventRef: newEventRef, className: "fixed right-4 bottom-[calc(var(--app-tab-bar,0px)+1rem)] z-30 size-14 rounded-full" })), !sidePane.open && !isPhone && (_jsx(NewEventSquare, { onNewEvent: newEvent, newEventRef: newEventRef, className: "absolute top-2 left-2 z-20" })), !isWriting && (_jsx(PendingSuggestions, { onChangeFirst: changeSuggestionFirst })), _jsxs("div", { "data-calendar-body": "", className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [moves.banner, body] })] })), !hasDetail && detail, session.mode === "quick" && (_jsx(CalendarQuickCreate, { session: session, dispatch: dispatch, onMoreOptions: moreOptions, onSaved: focusSaved, touch: isPhone })), hasDetail && (_jsx("aside", { "aria-label": "Event", className: isPhone
|
|
143
|
+
? "min-h-0 min-w-0 flex-1"
|
|
144
|
+
: "w-[26rem] shrink-0 border-l border-line", children: detail }))] })] }), moves.prompt, isPhone && (_jsx(Dialog, { open: sidePane.navOpen, onClose: () => sidePane.setNavOpen(false), title: "Calendars", anchor: "left", children: _jsx(CalendarNavPane, { onNewEvent: newEvent, onPicked: () => sidePane.setNavOpen(false), className: "w-full" }) }))] }));
|
|
145
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Dispatch, type MutableRefObject } from "react";
|
|
2
|
+
import type { DraftSession, SessionAction } from "../../hooks/calendar/draft-session";
|
|
3
|
+
/**
|
|
4
|
+
* The calendar screen's one draft, handed to the sidebar the route mounts
|
|
5
|
+
* below it. A context outside the route files, for the reason
|
|
6
|
+
* `CalendarShell` gave: the generated tree imports routes relatively.
|
|
7
|
+
*/
|
|
8
|
+
export interface CalendarSessionValue {
|
|
9
|
+
session: DraftSession;
|
|
10
|
+
dispatch: Dispatch<SessionAction>;
|
|
11
|
+
/** The sidebar's own close, asked by Esc; it confirms a touched draft. */
|
|
12
|
+
requestClose: MutableRefObject<(() => void) | null>;
|
|
13
|
+
/** The field quick-create had focus in when it expanded, by its label. */
|
|
14
|
+
carriedFocus: MutableRefObject<string>;
|
|
15
|
+
/** Focus the saved event once the grid draws it. */
|
|
16
|
+
focusSaved: (calendarObjectId: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const CalendarSessionContext: import("react").Context<CalendarSessionValue | null>;
|
|
19
|
+
export declare function useCalendarSession(): CalendarSessionValue;
|
|
20
|
+
/** The session where a calendar screen holds one; a surface mounted alone has none. */
|
|
21
|
+
export declare function useOptionalCalendarSession(): CalendarSessionValue | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext, } from "react";
|
|
2
|
+
export const CalendarSessionContext = createContext(null);
|
|
3
|
+
export function useCalendarSession() {
|
|
4
|
+
const value = useContext(CalendarSessionContext);
|
|
5
|
+
if (!value)
|
|
6
|
+
throw new Error("the calendar session is not mounted");
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
/** The session where a calendar screen holds one; a surface mounted alone has none. */
|
|
10
|
+
export function useOptionalCalendarSession() {
|
|
11
|
+
return useContext(CalendarSessionContext);
|
|
12
|
+
}
|
|
@@ -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 {
|
|
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
|
-
|
|
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(
|
|
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", {
|
|
63
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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: () =>
|
|
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
|
|
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
|
|
97
|
+
router: storyRouter(entry, pane),
|
|
99
98
|
queryClient: new QueryClient({
|
|
100
99
|
defaultOptions: {
|
|
101
100
|
queries: { retry: false },
|
|
@@ -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
|
+
}
|
|
@@ -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,
|
|
160
|
+
return (_jsx(NavSidebar, { accounts: navAccounts, selectedNavId: selectedNavId, onSelectNav: handleSelectNav, linkComponent: linkComponent, variant: variant }));
|
|
161
161
|
}
|
|
@@ -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;
|