@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.
Files changed (116) hide show
  1. package/dist/src/components/calendar/CalendarEventEditor.d.ts +6 -0
  2. package/dist/src/components/calendar/CalendarEventEditor.js +321 -0
  3. package/dist/src/components/calendar/CalendarEventPopup.d.ts +10 -0
  4. package/dist/src/components/calendar/CalendarEventPopup.js +133 -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 +131 -0
  11. package/dist/src/components/calendar/CalendarScreen.d.ts +11 -0
  12. package/dist/src/components/calendar/CalendarScreen.js +145 -0
  13. package/dist/src/components/calendar/CalendarSession.d.ts +21 -0
  14. package/dist/src/components/calendar/CalendarSession.js +12 -0
  15. package/dist/src/components/calendar/ChangeCalendarSuggestion.js +39 -5
  16. package/dist/src/components/calendar/EventMoves.d.ts +17 -0
  17. package/dist/src/components/calendar/EventMoves.js +103 -0
  18. package/dist/src/components/calendar/calendar-story-fixtures.js +8 -2
  19. package/dist/src/components/calendar/calendar-story-server.d.ts +2 -5
  20. package/dist/src/components/calendar/calendar-story-server.js +5 -6
  21. package/dist/src/components/layout/AppFrame.d.ts +11 -0
  22. package/dist/src/components/layout/AppFrame.js +16 -0
  23. package/dist/src/components/mail/MailSidebarAdapter.js +1 -1
  24. package/dist/src/components/ui/SignedOutOverlay.d.ts +6 -0
  25. package/dist/src/components/ui/SignedOutOverlay.js +29 -0
  26. package/dist/src/hooks/calendar/draft-session.d.ts +77 -0
  27. package/dist/src/hooks/calendar/draft-session.js +109 -0
  28. package/dist/src/hooks/calendar/index.d.ts +2 -1
  29. package/dist/src/hooks/calendar/index.js +1 -0
  30. package/dist/src/hooks/calendar/useCalendarJump.d.ts +0 -2
  31. package/dist/src/hooks/calendar/useCalendarJump.js +3 -5
  32. package/dist/src/hooks/calendar/useCalendarWrites.d.ts +11 -1
  33. package/dist/src/hooks/calendar/useCalendarWrites.js +7 -2
  34. package/dist/src/hooks/calendar/useCalendars.d.ts +1 -0
  35. package/dist/src/hooks/calendar/useCalendars.js +5 -2
  36. package/dist/src/hooks/calendar/useDraftSession.d.ts +32 -0
  37. package/dist/src/hooks/calendar/useDraftSession.js +106 -0
  38. package/dist/src/hooks/calendar/useMoveEvent.d.ts +4 -0
  39. package/dist/src/hooks/calendar/useMoveEvent.js +61 -0
  40. package/dist/src/hooks/use-system-update.js +3 -5
  41. package/dist/src/hooks/useCalendarData.d.ts +2 -0
  42. package/dist/src/hooks/useCalendarData.js +6 -1
  43. package/dist/src/hooks/useCalendarSidePane.d.ts +14 -0
  44. package/dist/src/hooks/useCalendarSidePane.js +30 -0
  45. package/dist/src/hooks/useRefreshControl.js +4 -8
  46. package/dist/src/hooks/useStaleAccountSync.js +4 -4
  47. package/dist/src/hooks/useWarningsAttention.js +1 -3
  48. package/dist/src/lib/calendar-route.d.ts +6 -0
  49. package/dist/src/lib/calendar-route.js +14 -0
  50. package/dist/src/lib/calendar-side-pane-pref.d.ts +14 -0
  51. package/dist/src/lib/calendar-side-pane-pref.js +27 -0
  52. package/dist/src/lib/error-classifier.d.ts +5 -30
  53. package/dist/src/lib/error-classifier.js +7 -10
  54. package/dist/src/lib/escalate.d.ts +6 -0
  55. package/dist/src/lib/escalate.js +16 -0
  56. package/dist/src/lib/intelligence-pref.js +3 -2
  57. package/dist/src/lib/new-event-range.d.ts +26 -0
  58. package/dist/src/lib/new-event-range.js +69 -0
  59. package/dist/src/lib/query-error-handler.d.ts +2 -6
  60. package/dist/src/lib/query-error-handler.js +5 -14
  61. package/dist/src/lib/signed-out.d.ts +13 -0
  62. package/dist/src/lib/signed-out.js +28 -0
  63. package/dist/src/routeTree.gen.d.ts +81 -19
  64. package/dist/src/routeTree.gen.js +25 -1
  65. package/dist/src/routes/__root.js +8 -2
  66. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.d.ts +5 -0
  67. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/edit.js +11 -0
  68. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.d.ts +5 -0
  69. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId/index.js +12 -0
  70. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.d.ts +1 -1
  71. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/$recurrenceId.js +4 -13
  72. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.d.ts +5 -0
  73. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/edit.js +14 -0
  74. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.d.ts +1 -1
  75. package/dist/src/routes/calendar/$view.$date/$calendarObjectId/index.js +4 -4
  76. package/dist/src/routes/calendar/$view.$date/$calendarObjectId.d.ts +1 -1
  77. package/dist/src/routes/calendar/$view.$date/index.d.ts +1 -6
  78. package/dist/src/routes/calendar/$view.$date/index.js +3 -10
  79. package/dist/src/routes/calendar/$view.$date/new.d.ts +6 -2
  80. package/dist/src/routes/calendar/$view.$date/new.js +8 -13
  81. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.d.ts +1 -1
  82. package/dist/src/routes/calendar/$view.$date/suggestion.$suggestionId.js +2 -2
  83. package/dist/src/routes/calendar/$view.$date.d.ts +1 -1
  84. package/dist/src/routes/calendar/$view.$date.js +14 -50
  85. package/dist/src/routes/calendar/index.d.ts +1 -1
  86. package/dist/src/routes/calendar/index.js +2 -1
  87. package/dist/src/routes/calendar.d.ts +4 -9
  88. package/dist/src/routes/calendar.js +10 -35
  89. package/dist/src/routes/mail/index.d.ts +1 -1
  90. package/dist/src/routes/mail/index.js +7 -2
  91. package/dist/src/routes/mail.js +6 -5
  92. package/dist/src/routing/app-switch.d.ts +11 -0
  93. package/dist/src/routing/app-switch.js +35 -0
  94. package/dist/src/routing/calendar.d.ts +41 -4
  95. package/dist/src/routing/calendar.js +121 -13
  96. package/dist/src/routing/fragment.d.ts +1 -1
  97. package/dist/src/routing/fragment.js +6 -1
  98. package/dist/src/routing/index.d.ts +2 -1
  99. package/dist/src/routing/index.js +2 -1
  100. package/package.json +2 -2
  101. package/dist/src/components/calendar/CalendarComposePane.d.ts +0 -49
  102. package/dist/src/components/calendar/CalendarComposePane.js +0 -8
  103. package/dist/src/components/calendar/CalendarComposeSeed.d.ts +0 -7
  104. package/dist/src/components/calendar/CalendarComposeSeed.js +0 -19
  105. package/dist/src/components/calendar/CalendarEventPane.d.ts +0 -48
  106. package/dist/src/components/calendar/CalendarEventPane.js +0 -48
  107. package/dist/src/components/calendar/CalendarShell.d.ts +0 -43
  108. package/dist/src/components/calendar/CalendarShell.js +0 -35
  109. package/dist/src/components/calendar/CalendarViewPlaceholder.d.ts +0 -1
  110. package/dist/src/components/calendar/CalendarViewPlaceholder.js +0 -5
  111. package/dist/src/components/calendar/CalendarWorkspace.d.ts +0 -49
  112. package/dist/src/components/calendar/CalendarWorkspace.js +0 -65
  113. package/dist/src/components/calendar/OpenCalendarEvent.d.ts +0 -20
  114. package/dist/src/components/calendar/OpenCalendarEvent.js +0 -169
  115. package/dist/src/components/calendar/WriteCalendarEvent.d.ts +0 -13
  116. package/dist/src/components/calendar/WriteCalendarEvent.js +0 -59
@@ -1,25 +1,19 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  /**
3
- * /calendar — a sibling of /mail, sharing its nav and nothing else.
3
+ * /calendar — a screen of its own beside /mail, inside the same app frame.
4
4
  *
5
- * The layout owns what the whole calendar needs and no more: the account list
6
- * the sidebar is built from, and the nav slide-over the narrow tiers open. The
7
- * view below it decides what the panes hold.
8
- *
9
- * The fragment keeps the meaning it has in mail. The calendar has no
10
- * intelligence rail, so a reader arriving with `#intelligence` carries it
11
- * through and takes it back to their mail — nothing calendar-specific joins the
12
- * union, because none of the calendar's own chrome is a panel.
5
+ * The layout owns the first-run guard and nothing else: a reader with no
6
+ * account belongs in onboarding. The view below it draws the toolbar, the side
7
+ * pane and the grid.
13
8
  */
14
9
  import { configOperationsGetConfigOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
15
10
  import { ErrorState } from "@remit/ui";
16
11
  import { useQuery } from "@tanstack/react-query";
17
12
  import { createFileRoute, Outlet, useNavigate } from "@tanstack/react-router";
18
- import { useCallback, useEffect } from "react";
19
- import { CalendarShellProvider } from "../components/calendar/CalendarShell";
20
- import { MailNav } from "../components/mail/MailNav";
21
- import { isSinglePaneTier, useLayoutTier } from "../hooks/useLayoutTier";
22
- import { panelsWithOverlay, useOpenPanels, useSetOpenPanels } from "../routing";
13
+ import { useEffect } from "react";
14
+ import { AppFrame } from "../components/layout/AppFrame";
15
+ import { AppShellSkeleton } from "../components/layout/AppShellSkeleton";
16
+ import { useIsWritingEvent } from "../routing";
23
17
  import "../lib/client";
24
18
  export const Route = createFileRoute("/calendar")({
25
19
  loader: ({ context: { queryClient } }) => {
@@ -29,40 +23,21 @@ export const Route = createFileRoute("/calendar")({
29
23
  });
30
24
  function CalendarLayout() {
31
25
  const navigate = useNavigate();
32
- const isSinglePane = isSinglePaneTier(useLayoutTier());
33
- // Only the nav slide-over is the calendar's to open, and it is written as
34
- // the whole set so a pane the reader brought with them from mail survives
35
- // the visit rather than being dropped by the first tap on the hamburger.
36
- const openPanels = useOpenPanels();
37
- const setOpenPanels = useSetOpenPanels();
38
- const navOpen = openPanels.includes("nav");
39
- const showNav = useCallback((open) => {
40
- setOpenPanels(panelsWithOverlay(openPanels, open ? "nav" : undefined));
41
- }, [openPanels, setOpenPanels]);
26
+ const isWriting = useIsWritingEvent();
42
27
  const { data: config, isLoading, isError, error, refetch, } = useQuery({
43
28
  ...configOperationsGetConfigOptions(),
44
29
  staleTime: Infinity,
45
30
  });
46
- // The same first-run guard `/mail` carries: a reader with no account has no
47
- // calendar either, and the onboarding wizard is where they belong.
48
31
  const hasNoAccounts = Boolean(config && (config.accounts?.length ?? 0) === 0);
49
32
  useEffect(() => {
50
33
  if (!hasNoAccounts)
51
34
  return;
52
35
  navigate({ to: "/onboarding", replace: true });
53
36
  }, [hasNoAccounts, navigate]);
54
- const accounts = config?.accounts ?? [];
55
37
  if (isError) {
56
38
  return (_jsx("div", { className: "flex h-full items-center justify-center bg-canvas p-4", children: _jsx(ErrorState, { title: "Couldn't load your account", error: error, onRetry: () => {
57
39
  refetch();
58
40
  } }) }));
59
41
  }
60
- return (_jsx(CalendarShellProvider, { chrome: {
61
- isSinglePane,
62
- isLoading: isLoading || hasNoAccounts,
63
- nav: (_jsx(MailNav, { accounts: accounts, onMailboxSelect: () => showNav(false) })),
64
- navOpen,
65
- onOpenNav: () => showNav(true),
66
- onCloseNav: () => showNav(false),
67
- }, children: _jsx(Outlet, {}) }));
42
+ return (_jsx(AppFrame, { hideTabBar: isWriting, children: isLoading || hasNoAccounts ? _jsx(AppShellSkeleton, {}) : _jsx(Outlet, {}) }));
68
43
  }
@@ -12,7 +12,7 @@ export declare const Route: import("@tanstack/router-core").Route<import("@tanst
12
12
  wizardFrom: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodLiteral<"search">>>;
13
13
  }, import("zod/v4/core").$strip>, import("@tanstack/router-core").ResolveParams<"/mail">, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, ({ context: { queryClient } }: import("@tanstack/router-core").LoaderFnContext<import("@tanstack/react-router").Register, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, import("../../router").RouterContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/mail", import("@tanstack/router-core").ResolveParams<"/mail">, {}, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, unknown, undefined>) => void, unknown, unknown, unknown, unknown, undefined>, "/", "/mail/", "/mail/", "/mail/", import("zod").ZodObject<{
14
14
  q: import("zod").ZodOptional<import("zod").ZodString>;
15
- }, import("zod/v4/core").$strip>, import("@tanstack/router-core").ResolveParams<"/">, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, ({ search }: import("@tanstack/router-core").BeforeLoadContextOptions<import("@tanstack/react-router").Register, import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, import("../../router").RouterContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/mail", "/mail", "/mail", "/mail", import("zod").ZodObject<{
15
+ }, import("zod/v4/core").$strip>, import("@tanstack/router-core").ResolveParams<"/">, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, ({ search, location }: import("@tanstack/router-core").BeforeLoadContextOptions<import("@tanstack/react-router").Register, import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, import("../../router").RouterContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/mail", "/mail", "/mail", "/mail", import("zod").ZodObject<{
16
16
  q: import("zod").ZodOptional<import("zod").ZodString>;
17
17
  wizard: import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodEnum<{
18
18
  name: "name";
@@ -7,7 +7,12 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
7
7
  import { mailIndexSearchSchema } from "../../lib/mail-search";
8
8
  export const Route = createFileRoute("/mail/")({
9
9
  validateSearch: mailIndexSearchSchema,
10
- beforeLoad: ({ search }) => {
11
- throw redirect({ to: "/mail/brief", search, replace: true });
10
+ beforeLoad: ({ search, location }) => {
11
+ throw redirect({
12
+ to: "/mail/brief",
13
+ search,
14
+ hash: location.hash,
15
+ replace: true,
16
+ });
12
17
  },
13
18
  });
@@ -4,6 +4,7 @@ import { ErrorState, KeyboardShortcutsModal, useTriageKeyboard, } from "@remit/u
4
4
  import { useQuery } from "@tanstack/react-query";
5
5
  import { createFileRoute, Outlet, useNavigate, useRouterState, } from "@tanstack/react-router";
6
6
  import { useCallback, useEffect, useMemo } from "react";
7
+ import { AppFrame } from "../components/layout/AppFrame";
7
8
  import { ComposeFab } from "../components/layout/ComposeFab";
8
9
  import { MailShellProvider } from "../components/layout/MailShell";
9
10
  import { MailTopBar } from "../components/layout/MailTopBar";
@@ -171,9 +172,9 @@ function MailLayout() {
171
172
  onOpenNav: () => showOverlay("nav"),
172
173
  onCloseNav: () => showOverlay(undefined),
173
174
  };
174
- return (_jsx(MailContext.Provider, { value: mailContextValue, children: _jsxs(MailFreshnessProvider, { accountIds: accountIds, children: [isConfigError ? (_jsx("div", { className: "flex h-full items-center justify-center bg-canvas p-4", children: _jsx(ErrorState, { title: "Couldn't load your account", error: configError, onRetry: () => {
175
- refetchConfig();
176
- } }) })) : (
177
- // Each list route mounts its own shell around its own panes.
178
- _jsx(MailShellProvider, { chrome: shellChrome, children: _jsx(Outlet, {}) })), _jsx(KeyboardShortcutsModal, { isOpen: showShortcuts, onClose: () => showOverlay(undefined) })] }) }));
175
+ return (_jsx(MailContext.Provider, { value: mailContextValue, children: _jsxs(MailFreshnessProvider, { accountIds: accountIds, children: [_jsx(AppFrame, { children: isConfigError ? (_jsx("div", { className: "flex h-full items-center justify-center bg-canvas p-4", children: _jsx(ErrorState, { title: "Couldn't load your account", error: configError, onRetry: () => {
176
+ refetchConfig();
177
+ } }) })) : (
178
+ // Each list route mounts its own shell around its own panes.
179
+ _jsx(MailShellProvider, { chrome: shellChrome, children: _jsx(Outlet, {}) })) }), _jsx(KeyboardShortcutsModal, { isOpen: showShortcuts, onClose: () => showOverlay(undefined) })] }) }));
179
180
  }
@@ -0,0 +1,11 @@
1
+ import type { AppId, AppSwitchItem } from "@remit/ui";
2
+ export interface AppSwitch {
3
+ items: AppSwitchItem[];
4
+ active: AppId;
5
+ switchTo: (id: AppId) => void;
6
+ }
7
+ /**
8
+ * Mail and calendar as two destinations. The panes the reader has up travel
9
+ * with them, the way a nav link carries them; overlays stay behind.
10
+ */
11
+ export declare function useAppSwitch(): AppSwitch;
@@ -0,0 +1,35 @@
1
+ import { useLocation, useNavigate, useRouter } from "@tanstack/react-router";
2
+ import { useCallback, useMemo } from "react";
3
+ import { useRetainOpenPanels } from "./fragment";
4
+ const appOfPath = (pathname) => pathname.startsWith("/calendar") ? "calendar" : "mail";
5
+ /**
6
+ * Mail and calendar as two destinations. The panes the reader has up travel
7
+ * with them, the way a nav link carries them; overlays stay behind.
8
+ */
9
+ export function useAppSwitch() {
10
+ const navigate = useNavigate();
11
+ const router = useRouter();
12
+ const retainPanels = useRetainOpenPanels();
13
+ const pathname = useLocation({ select: (location) => location.pathname });
14
+ const active = appOfPath(pathname);
15
+ const items = useMemo(() => [
16
+ {
17
+ id: "mail",
18
+ label: "Mail",
19
+ href: router.buildLocation({ to: "/mail", hash: retainPanels }).href,
20
+ },
21
+ {
22
+ id: "calendar",
23
+ label: "Calendar",
24
+ href: router.buildLocation({ to: "/calendar", hash: retainPanels })
25
+ .href,
26
+ },
27
+ ], [router, retainPanels]);
28
+ const switchTo = useCallback((id) => {
29
+ navigate({
30
+ to: id === "calendar" ? "/calendar" : "/mail",
31
+ hash: retainPanels,
32
+ });
33
+ }, [navigate, retainPanels]);
34
+ return { items, active, switchTo };
35
+ }
@@ -1,4 +1,10 @@
1
1
  import type { CalendarViewId } from "@remit/ui";
2
+ declare module "@tanstack/react-router" {
3
+ interface HistoryState {
4
+ /** This entry was opened from the calendar view, so Back returns to it. */
5
+ openedFromView?: boolean;
6
+ }
7
+ }
2
8
  /** Which zoom the calendar is at, on which day, over which calendars. */
3
9
  export interface CalendarAddress {
4
10
  view: CalendarViewId;
@@ -25,14 +31,23 @@ export interface OpenCalendarEvent {
25
31
  export declare function useOpenCalendarEvent(): OpenCalendarEvent | undefined;
26
32
  /** Whether the composer is up, which is a route rather than a flag. */
27
33
  export declare function useChangingSuggestionId(): string | undefined;
34
+ /** The stored event the sidebar is editing, if the address has one open. */
35
+ export declare function useEditingEvent(): OpenCalendarEvent | undefined;
36
+ /** The range `/new` names in its query, unread until a sidebar reads it. */
37
+ export declare function useNewEventBounds(): {
38
+ start: string | undefined;
39
+ end: string | undefined;
40
+ } | undefined;
28
41
  export declare function useIsWritingEvent(): boolean;
29
42
  export interface CalendarNavigation {
30
43
  /** Change zoom, keeping the day on screen. */
31
44
  goToView: (view: CalendarViewId) => void;
32
- /** The previous or next screenful, measured in the view's own unit. */
33
- step: (direction: -1 | 1) => void;
34
45
  /** Home, from every view and every distance away. */
35
46
  goToToday: () => void;
47
+ /** The same view on another day. */
48
+ goToDate: (date: string) => void;
49
+ /** The calendars to draw; every one of them clears the query. */
50
+ setCalendarIds: (calendarIds: readonly string[]) => void;
36
51
  /**
37
52
  * The day the strip has scrolled to, written by `replace`. Scrolling is not
38
53
  * somewhere the reader went — Back belongs to the screen they arrived from,
@@ -47,8 +62,23 @@ export interface CalendarNavigation {
47
62
  * a resource that does not recur names only itself.
48
63
  */
49
64
  openEvent: (calendarObjectId: string, recurrenceId?: string) => void;
50
- closeEvent: () => void;
51
- openComposer: () => void;
65
+ /**
66
+ * Back to the view from an event popup or a sidebar: Back when the view is
67
+ * the entry before, else the view by replace.
68
+ */
69
+ closeToView: () => void;
70
+ /** The advanced sidebar on a new event over a range, as `start` and `end`. */
71
+ openNewEvent: (bounds: {
72
+ start: string;
73
+ end: string;
74
+ }) => void;
75
+ /** A new range for the open sidebar, by replace. */
76
+ setNewEventBounds: (bounds: {
77
+ start: string;
78
+ end: string;
79
+ }) => void;
80
+ /** The advanced sidebar on a stored event. */
81
+ openEditor: (calendarObjectId: string, recurrenceId?: string) => void;
52
82
  changeSuggestionFirst: (suggestionId: string, date: string) => void;
53
83
  }
54
84
  /**
@@ -67,3 +97,10 @@ export declare function useCalendarNavigation(): CalendarNavigation;
67
97
  */
68
98
  export declare function useOpenEventOnCalendar(): (date: string, calendarObjectId: string, recurrenceId: string) => void;
69
99
  export declare function useChangeSuggestionOnCalendar(): (date: string, suggestionId: string) => void;
100
+ /**
101
+ * Back answered by a layer that holds no address of its own: the phone's
102
+ * quick-create sheet, or an editor that asks before a touched draft goes.
103
+ * Only Back is caught, and only while `onBack` says it answered it; a
104
+ * navigation the app starts is never blocked.
105
+ */
106
+ export declare function useBackCloses(active: boolean, onBack: () => boolean): void;
@@ -1,6 +1,6 @@
1
- import { useNavigate, useParams, useRouter, useSearch, } from "@tanstack/react-router";
2
- import { useCallback, useMemo } from "react";
3
- import { canonicalCalendarParams, isoDate, stepCalendarDate, } from "../lib/calendar-route";
1
+ import { useBlocker, useNavigate, useParams, useRouter, useSearch, } from "@tanstack/react-router";
2
+ import { useCallback, useMemo, useRef } from "react";
3
+ import { canonicalCalendarParams, isoDate, } from "../lib/calendar-route";
4
4
  import { useRetainOpenPanels } from "./fragment";
5
5
  const VIEW_ROUTE = "/calendar/$view/$date";
6
6
  const SUGGESTION_ROUTE = "/calendar/$view/$date/suggestion/$suggestionId";
@@ -41,7 +41,33 @@ export function useChangingSuggestionId() {
41
41
  return useParams({ from: SUGGESTION_ROUTE, shouldThrow: false })
42
42
  ?.suggestionId;
43
43
  }
44
+ /** The stored event the sidebar is editing, if the address has one open. */
45
+ export function useEditingEvent() {
46
+ const series = useParams({
47
+ from: "/calendar/$view/$date/$calendarObjectId/edit",
48
+ shouldThrow: false,
49
+ });
50
+ const occurrence = useParams({
51
+ from: "/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",
52
+ shouldThrow: false,
53
+ });
54
+ const calendarObjectId = series?.calendarObjectId ?? occurrence?.calendarObjectId;
55
+ const recurrenceId = occurrence?.recurrenceId;
56
+ return useMemo(() => (calendarObjectId ? { calendarObjectId, recurrenceId } : undefined), [calendarObjectId, recurrenceId]);
57
+ }
58
+ /** The range `/new` names in its query, unread until a sidebar reads it. */
59
+ export function useNewEventBounds() {
60
+ const search = useSearch({
61
+ from: "/calendar/$view/$date/new",
62
+ shouldThrow: false,
63
+ });
64
+ const start = search?.start;
65
+ const end = search?.end;
66
+ const open = search !== undefined;
67
+ return useMemo(() => (open ? { start, end } : undefined), [open, start, end]);
68
+ }
44
69
  export function useIsWritingEvent() {
70
+ const editing = useEditingEvent();
45
71
  const composer = useParams({
46
72
  from: "/calendar/$view/$date/new",
47
73
  shouldThrow: false,
@@ -50,7 +76,7 @@ export function useIsWritingEvent() {
50
76
  from: SUGGESTION_ROUTE,
51
77
  shouldThrow: false,
52
78
  });
53
- return composer !== undefined || changing !== undefined;
79
+ return (composer !== undefined || changing !== undefined || editing !== undefined);
54
80
  }
55
81
  /**
56
82
  * Every move the calendar makes, as an address.
@@ -65,6 +91,8 @@ export function useCalendarNavigation() {
65
91
  const router = useRouter();
66
92
  const retainPanels = useRetainOpenPanels();
67
93
  const { view, date } = useCalendarAddress();
94
+ const openedEvent = useOpenCalendarEvent();
95
+ const popupOpen = openedEvent !== undefined;
68
96
  const goTo = useCallback((params) => {
69
97
  navigate({
70
98
  to: VIEW_ROUTE,
@@ -81,15 +109,31 @@ export function useCalendarNavigation() {
81
109
  }).href, [router, retainPanels]);
82
110
  return useMemo(() => ({
83
111
  goToView: (next) => goTo({ view: next, date }),
84
- step: (direction) => goTo({ view, date: stepCalendarDate(date, view, direction) }),
85
112
  goToToday: () => goTo({ view, date: isoDate(new Date()) }),
86
- setAnchorDate: (next) => navigate({
113
+ goToDate: (next) => goTo({ view, date: next }),
114
+ setCalendarIds: (calendarIds) => navigate({
87
115
  to: VIEW_ROUTE,
88
- params: { view, date: next },
89
- search: true,
90
- hash: retainPanels,
116
+ params: { view, date },
117
+ search: (previous) => ({
118
+ ...previous,
119
+ calendarId: calendarIds.length === 0 ? undefined : [...calendarIds],
120
+ }),
121
+ hash: true,
91
122
  replace: true,
92
123
  }),
124
+ setAnchorDate: (next) => {
125
+ // An open popup is a child of the view; rewriting the day under
126
+ // it would close it, so the strip waits until it is gone.
127
+ if (popupOpen)
128
+ return;
129
+ navigate({
130
+ to: VIEW_ROUTE,
131
+ params: { view, date: next },
132
+ search: true,
133
+ hash: retainPanels,
134
+ replace: true,
135
+ });
136
+ },
93
137
  zoomToDay: (next) => navigate({ href: dayHref(next) }),
94
138
  dayHref,
95
139
  openEvent: (calendarObjectId, recurrenceId) => recurrenceId === undefined || recurrenceId === ""
@@ -98,27 +142,72 @@ export function useCalendarNavigation() {
98
142
  params: { view, date, calendarObjectId },
99
143
  search: true,
100
144
  hash: retainPanels,
145
+ replace: popupOpen,
146
+ state: { openedFromView: true },
101
147
  })
102
148
  : navigate({
103
149
  to: "/calendar/$view/$date/$calendarObjectId/$recurrenceId",
104
150
  params: { view, date, calendarObjectId, recurrenceId },
105
151
  search: true,
106
152
  hash: retainPanels,
153
+ replace: popupOpen,
154
+ state: { openedFromView: true },
107
155
  }),
108
- closeEvent: () => goTo({ view, date }),
109
- openComposer: () => navigate({
156
+ closeToView: () => {
157
+ if (router.state.location.state.openedFromView === true) {
158
+ router.history.back();
159
+ return;
160
+ }
161
+ navigate({
162
+ to: VIEW_ROUTE,
163
+ params: { view, date },
164
+ search: (previous) => ({
165
+ calendarId: previous.calendarId,
166
+ }),
167
+ hash: retainPanels,
168
+ replace: true,
169
+ });
170
+ },
171
+ openNewEvent: (bounds) => navigate({
110
172
  to: "/calendar/$view/$date/new",
111
173
  params: { view, date },
112
- search: true,
174
+ search: (previous) => ({ ...previous, ...bounds }),
113
175
  hash: retainPanels,
176
+ replace: popupOpen,
177
+ state: { openedFromView: true },
178
+ }),
179
+ setNewEventBounds: (bounds) => navigate({
180
+ to: "/calendar/$view/$date/new",
181
+ params: { view, date },
182
+ search: (previous) => ({ ...previous, ...bounds }),
183
+ hash: true,
184
+ replace: true,
185
+ state: (previous) => previous,
114
186
  }),
187
+ openEditor: (calendarObjectId, recurrenceId) => recurrenceId === undefined || recurrenceId === ""
188
+ ? navigate({
189
+ to: "/calendar/$view/$date/$calendarObjectId/edit",
190
+ params: { view, date, calendarObjectId },
191
+ search: true,
192
+ hash: retainPanels,
193
+ replace: popupOpen,
194
+ state: { openedFromView: true },
195
+ })
196
+ : navigate({
197
+ to: "/calendar/$view/$date/$calendarObjectId/$recurrenceId/edit",
198
+ params: { view, date, calendarObjectId, recurrenceId },
199
+ search: true,
200
+ hash: retainPanels,
201
+ replace: popupOpen,
202
+ state: { openedFromView: true },
203
+ }),
115
204
  changeSuggestionFirst: (suggestionId, on) => navigate({
116
205
  to: SUGGESTION_ROUTE,
117
206
  params: { view, date: on, suggestionId },
118
207
  search: true,
119
208
  hash: retainPanels,
120
209
  }),
121
- }), [goTo, navigate, dayHref, retainPanels, view, date]);
210
+ }), [goTo, navigate, dayHref, retainPanels, view, date, router, popupOpen]);
122
211
  }
123
212
  /**
124
213
  * Leave the mail for one event on the calendar, on the day it falls, so the
@@ -150,3 +239,22 @@ export function useChangeSuggestionOnCalendar() {
150
239
  });
151
240
  }, [navigate]);
152
241
  }
242
+ /**
243
+ * Back answered by a layer that holds no address of its own: the phone's
244
+ * quick-create sheet, or an editor that asks before a touched draft goes.
245
+ * Only Back is caught, and only while `onBack` says it answered it; a
246
+ * navigation the app starts is never blocked.
247
+ */
248
+ export function useBackCloses(active, onBack) {
249
+ const latest = useRef(onBack);
250
+ latest.current = onBack;
251
+ useBlocker({
252
+ shouldBlockFn: ({ action }) => {
253
+ if (action !== "BACK")
254
+ return false;
255
+ return latest.current();
256
+ },
257
+ enableBeforeUnload: false,
258
+ disabled: !active,
259
+ });
260
+ }
@@ -4,7 +4,7 @@
4
4
  * independent of in-memory data, so a cold load of the URL reproduces it
5
5
  * exactly.
6
6
  */
7
- export declare const panelFragments: readonly ["intelligence", "nav", "shortcuts"];
7
+ export declare const panelFragments: readonly ["intelligence", "sidebar", "nav", "shortcuts"];
8
8
  export type PanelFragment = (typeof panelFragments)[number];
9
9
  /**
10
10
  * The panels that cover the view rather than sit in it. The rail is a pane in
@@ -8,7 +8,12 @@ import { useIsDesktop } from "../hooks/useMediaQuery";
8
8
  * independent of in-memory data, so a cold load of the URL reproduces it
9
9
  * exactly.
10
10
  */
11
- export const panelFragments = ["intelligence", "nav", "shortcuts"];
11
+ export const panelFragments = [
12
+ "intelligence",
13
+ "sidebar",
14
+ "nav",
15
+ "shortcuts",
16
+ ];
12
17
  /**
13
18
  * The panels that cover the view rather than sit in it. The rail is a pane in
14
19
  * the shell's row and the other two are modal over it, so a sheet opening can
@@ -1,5 +1,6 @@
1
+ export { type AppSwitch, useAppSwitch } from "./app-switch";
1
2
  export { type BrowsedList, useBrowsedList, useOpensDetail, } from "./browsed-list";
2
- export { type CalendarAddress, type CalendarNavigation, type OpenCalendarEvent, useCalendarAddress, useCalendarNavigation, useChangeSuggestionOnCalendar, useChangingSuggestionId, useIsWritingEvent, useOpenCalendarEvent, useOpenEventOnCalendar, } from "./calendar";
3
+ export { type CalendarAddress, type CalendarNavigation, type OpenCalendarEvent, useBackCloses, useCalendarAddress, useCalendarNavigation, useChangeSuggestionOnCalendar, useChangingSuggestionId, useEditingEvent, useIsWritingEvent, useNewEventBounds, useOpenCalendarEvent, useOpenEventOnCalendar, } from "./calendar";
3
4
  export { useAdoptComposeDraft, useCloseCompose, useComposeDraftId, useEditDraft, useIsComposing, useOpenCompose, } from "./compose";
4
5
  export { formatOpenPanels, isOverlayPanel, type OverlayPanel, overlayPanels, type PanelFragment, panelFragments, panelsWithOverlay, parseOpenPanels, retainOpenPanelsAtTier, useOpenPanels, useRetainOpenPanels, useSetOpenPanels, } from "./fragment";
5
6
  export { NavLink, type NavLinkProps } from "./nav-link";
@@ -1,5 +1,6 @@
1
+ export { useAppSwitch } from "./app-switch";
1
2
  export { useBrowsedList, useOpensDetail, } from "./browsed-list";
2
- export { useCalendarAddress, useCalendarNavigation, useChangeSuggestionOnCalendar, useChangingSuggestionId, useIsWritingEvent, useOpenCalendarEvent, useOpenEventOnCalendar, } from "./calendar";
3
+ export { useBackCloses, useCalendarAddress, useCalendarNavigation, useChangeSuggestionOnCalendar, useChangingSuggestionId, useEditingEvent, useIsWritingEvent, useNewEventBounds, useOpenCalendarEvent, useOpenEventOnCalendar, } from "./calendar";
3
4
  export { useAdoptComposeDraft, useCloseCompose, useComposeDraftId, useEditDraft, useIsComposing, useOpenCompose, } from "./compose";
4
5
  export { formatOpenPanels, isOverlayPanel, overlayPanels, panelFragments, panelsWithOverlay, parseOpenPanels, retainOpenPanelsAtTier, useOpenPanels, useRetainOpenPanels, useSetOpenPanels, } from "./fragment";
5
6
  export { NavLink } from "./nav-link";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/web-client",
3
- "version": "0.0.328",
3
+ "version": "0.0.329",
4
4
  "type": "module",
5
5
  "description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
6
6
  "exports": {
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "dependencies": {
93
93
  "@hookform/resolvers": "5.4.0",
94
- "@remit/ui": "0.0.224",
94
+ "@remit/ui": "0.0.225",
95
95
  "@tanstack/react-query": "5.101.2",
96
96
  "@tanstack/react-query-devtools": "5.101.2",
97
97
  "@tanstack/react-router": "1.170.18",
@@ -1,49 +0,0 @@
1
- import { type CalendarClash, type CalendarDescriptor, type EventDraft } from "@remit/ui";
2
- /**
3
- * Writing an event, and editing one.
4
- *
5
- * Presentational, like the pane it sits beside: it holds no draft of its own
6
- * and saves nothing. The route owns the draft and the write, so this renders
7
- * the same form whichever of the two the address named.
8
- *
9
- * Guests are left out because the calendar store has nowhere to put them yet,
10
- * which is the kit's default. A field that takes names and drops them is worse
11
- * than no field: the reader only finds out afterwards, from an event with
12
- * nobody on it.
13
- */
14
- export interface CalendarComposePaneProps {
15
- /** What the pane is doing: "New event", "Edit event". */
16
- title: string;
17
- /** The one line of context the title cannot carry — which day, which series. */
18
- subtitle?: string;
19
- notice?: string;
20
- calendars: CalendarDescriptor[];
21
- draft: EventDraft;
22
- onChange: (draft: EventDraft) => void;
23
- /**
24
- * Why the last save did not happen, in the words the reader needs: what was
25
- * refused and what to do about it. Empty when nothing has been refused.
26
- */
27
- problem: string;
28
- saveLabel: string;
29
- isSaving: boolean;
30
- /**
31
- * The rule belongs to the series rather than to one morning of it, so an
32
- * edit scoped to a single occurrence reads it back instead of offering it.
33
- */
34
- repeatEditable?: boolean;
35
- /**
36
- * Whether the event can still be sent to a different calendar. Writing one
37
- * chooses; editing one cannot, because the collection a resource lives in is
38
- * part of its address and the patch has no field for it.
39
- */
40
- calendarEditable?: boolean;
41
- /**
42
- * What the span on the form runs into. Undefined while there is nothing to
43
- * check or the answer has not landed, which draws no strip at all.
44
- */
45
- clashes?: CalendarClash[];
46
- onSave: () => void;
47
- onCancel: () => void;
48
- }
49
- export declare function CalendarComposePane({ title, subtitle, notice, calendars, draft, onChange, problem, saveLabel, isSaving, repeatEditable, calendarEditable, clashes, onSave, onCancel, }: CalendarComposePaneProps): import("react").JSX.Element;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CalendarClashStrip, EventEditor, EventEditorPane, } from "@remit/ui";
3
- import { AlertCircle, AlertTriangle } from "lucide-react";
4
- export function CalendarComposePane({ title, subtitle, notice = "", calendars, draft, onChange, problem, saveLabel, isSaving, repeatEditable = true, calendarEditable = true, clashes, onSave, onCancel, }) {
5
- return (_jsx(EventEditorPane, { title: title, subtitle: subtitle, onClose: onCancel, children: _jsx(EventEditor, { draft: draft, onChange: onChange, calendars: calendars, layout: "pane", repeatEditable: repeatEditable, calendarEditable: calendarEditable, saveLabel: isSaving ? "Saving…" : saveLabel, onSave: onSave, onCancel: onCancel, header: problem === "" &&
6
- notice === "" &&
7
- clashes === undefined ? undefined : (_jsxs("div", { className: "space-y-2", children: [notice !== "" && (_jsxs("p", { className: "flex items-start gap-2 rounded-md border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-fg", children: [_jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0 text-warning", "aria-hidden": "true" }), _jsx("span", { className: "min-w-0 flex-1 break-words", children: notice })] })), problem !== "" && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm", children: [_jsx(AlertCircle, { className: "mt-0.5 size-4 shrink-0 text-danger", "aria-hidden": "true" }), _jsx("p", { className: "min-w-0 flex-1 break-words text-fg", children: problem })] })), clashes !== undefined && (_jsx(CalendarClashStrip, { clashes: clashes, clearText: "Nothing else is booked at this time." }))] })) }) }));
8
- }
@@ -1,7 +0,0 @@
1
- import type { CalendarSlotPick } from "@remit/ui";
2
- import { type ReactNode } from "react";
3
- export declare const CalendarComposeSeedProvider: ({ pick, children, }: {
4
- pick: CalendarSlotPick | undefined;
5
- children?: ReactNode;
6
- }) => import("react").JSX.Element;
7
- export declare const useCalendarComposeSeed: () => CalendarSlotPick | undefined;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- /**
4
- * The slot a reader dragged out of the grid, handed to the composer the click
5
- * opened.
6
- *
7
- * It is not in the address on purpose. What a half-written event says is not a
8
- * fact about where the reader is, and a link to a composer pre-filled with
9
- * somebody else's Tuesday afternoon is not an address worth being able to send.
10
- * The composer opened without one starts on the day the calendar is showing.
11
- *
12
- * It lives outside the route files for the same reason
13
- * `CalendarShell`'s context does: the generated route tree imports route files
14
- * relatively, so a context declared inside one resolves to a second module
15
- * instance and hands the consumer an empty default.
16
- */
17
- const CalendarComposeSeedCtx = createContext(undefined);
18
- export const CalendarComposeSeedProvider = ({ pick, children, }) => (_jsx(CalendarComposeSeedCtx.Provider, { value: pick, children: children }));
19
- export const useCalendarComposeSeed = () => useContext(CalendarComposeSeedCtx);