@remit/ui 0.0.239 → 0.0.241

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.
@@ -13,6 +13,7 @@ export interface ErrorBannerEntry {
13
13
  title: string;
14
14
  detail?: string;
15
15
  action?: ErrorBannerAction;
16
+ onRetry?: () => void;
16
17
  createdAt: number;
17
18
  }
18
19
  interface ErrorBannerProps {
@@ -21,7 +22,8 @@ interface ErrorBannerProps {
21
22
  title: string;
22
23
  detail?: string;
23
24
  action?: ErrorBannerAction;
25
+ onRetry?: () => void;
24
26
  onDismiss: (id: string) => void;
25
27
  }
26
- export declare const ErrorBanner: ({ id, severity, title, detail, action, onDismiss, }: ErrorBannerProps) => import("react").JSX.Element;
28
+ export declare const ErrorBanner: ({ id, severity, title, detail, action, onRetry, onDismiss, }: ErrorBannerProps) => import("react").JSX.Element;
27
29
  export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CircleAlert, Info, TriangleAlert, X } from "../icons.js";
3
3
  import { cn } from "../lib/cn.js";
4
+ import { Button } from "./button.js";
4
5
  const SEVERITY_STYLES = {
5
6
  error: {
6
7
  container: "border-danger/50 bg-danger-soft",
@@ -28,12 +29,15 @@ const SEVERITY_LABEL = {
28
29
  warning: "Warning",
29
30
  info: "Information",
30
31
  };
31
- export const ErrorBanner = ({ id, severity, title, detail, action, onDismiss, }) => {
32
+ export const ErrorBanner = ({ id, severity, title, detail, action, onRetry, onDismiss, }) => {
32
33
  const styles = SEVERITY_STYLES[severity];
33
34
  const Icon = SEVERITY_ICONS[severity];
34
35
  return (_jsxs("div", { role: severity === "error" ? "alert" : "status", "aria-live": severity === "error" ? "assertive" : "polite", className: cn(
35
36
  // Opaque, not translucent: a banner overlaps the toolbar and the
36
37
  // message list, and see-through text on top of see-through text is
37
38
  // unreadable (issue #55).
38
- "pointer-events-auto flex items-start gap-3 rounded-md border bg-canvas px-3 py-2 shadow-lg", styles.container), children: [_jsx(Icon, { className: cn("size-5 shrink-0 mt-0.5", styles.icon), "aria-hidden": "true" }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: cn("text-sm font-medium", styles.title), children: title }), detail && (_jsx("p", { className: "mt-0.5 text-xs text-fg-muted break-words", children: detail })), action && (_jsx("a", { href: action.href, target: "_blank", rel: "noopener noreferrer", className: "mt-1 inline-block text-xs font-medium text-accent-2 underline underline-offset-2", children: action.label }))] }), _jsx("button", { type: "button", onClick: () => onDismiss(id), className: "shrink-0 rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors", "aria-label": `Dismiss ${SEVERITY_LABEL[severity].toLowerCase()}`, children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] }));
39
+ "pointer-events-auto flex items-start gap-3 rounded-md border bg-canvas px-3 py-2 shadow-lg", styles.container), children: [_jsx(Icon, { className: cn("size-5 shrink-0 mt-0.5", styles.icon), "aria-hidden": "true" }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: cn("text-sm font-medium", styles.title), children: title }), detail && (_jsx("p", { className: "mt-0.5 text-xs text-fg-muted break-words", children: detail })), (onRetry || action) && (_jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-x-4 gap-y-1", children: [onRetry && (_jsx(Button, { variant: "secondary", size: "sm", onClick: () => {
40
+ onDismiss(id);
41
+ onRetry();
42
+ }, children: "Try again" })), action && (_jsx("a", { href: action.href, target: "_blank", rel: "noopener noreferrer", className: "inline-block text-xs font-medium text-accent-2 underline underline-offset-2", children: action.label }))] }))] }), _jsx("button", { type: "button", onClick: () => onDismiss(id), className: "shrink-0 rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors", "aria-label": `Dismiss ${SEVERITY_LABEL[severity].toLowerCase()}`, children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] }));
39
43
  };
@@ -3,5 +3,5 @@ import { ErrorBanner } from "./ErrorBanner.js";
3
3
  export const ErrorBannerStack = ({ errors, onDismiss, }) => {
4
4
  if (errors.length === 0)
5
5
  return null;
6
- return (_jsx("section", { "aria-label": "Notifications", className: "pointer-events-none fixed inset-x-0 top-0 z-[60] flex flex-col items-center gap-2 px-4 pt-[calc(1rem+env(safe-area-inset-top,0px))] sm:items-end sm:pr-6", children: _jsx("div", { className: "flex w-full max-w-md flex-col gap-2", children: errors.map((entry) => (_jsx(ErrorBanner, { id: entry.id, severity: entry.severity, title: entry.title, detail: entry.detail, action: entry.action, onDismiss: onDismiss }, entry.id))) }) }));
6
+ return (_jsx("section", { "aria-label": "Notifications", className: "pointer-events-none fixed inset-x-0 top-0 z-[60] flex flex-col items-center gap-2 px-4 pt-[calc(1rem+env(safe-area-inset-top,0px))] sm:items-end sm:pr-6", children: _jsx("div", { className: "flex w-full max-w-md flex-col gap-2", children: errors.map((entry) => (_jsx(ErrorBanner, { id: entry.id, severity: entry.severity, title: entry.title, detail: entry.detail, action: entry.action, onRetry: entry.onRetry, onDismiss: onDismiss }, entry.id))) }) }));
7
7
  };
@@ -3,6 +3,7 @@ import type { BriefCategoryFilter, ThreadCategory } from "../category-presentati
3
3
  import type { TriageHandlers } from "../lib/keymap.js";
4
4
  import type { SelectionModifiers } from "../lib/use-selection.js";
5
5
  import type { AccountService } from "./account-service-choice.js";
6
+ import type { ResultFolder } from "./folder-role.js";
6
7
  import type { IntelligenceData, SenderTrustLevel } from "./intelligence-panel.js";
7
8
  import type { ResultCount } from "./list-result-header.js";
8
9
  import type { ListState } from "./message-list-state.js";
@@ -125,6 +126,7 @@ export interface NavLabel {
125
126
  name: string;
126
127
  /** The label's color name; a value the kit has no swatch for renders as Default. */
127
128
  color: string;
129
+ unseen?: number;
128
130
  }
129
131
  /** Per-account mailbox-load status, so the nav can show loading/error inline. */
130
132
  export type NavAccountStatus = "loading" | "error" | "ready";
@@ -140,6 +142,7 @@ export interface NavAccount {
140
142
  * nav with every mailbox it already synced, labelled rather than dropped.
141
143
  */
142
144
  syncedServices?: AccountService[];
145
+ hierarchyDelimiter: string;
143
146
  mailboxes: NavMailbox[];
144
147
  /**
145
148
  * Number of outbox messages pending send. When provided, an Outbox entry
@@ -212,6 +215,8 @@ export interface ThreadRowData {
212
215
  category?: ThreadCategory;
213
216
  /** Number of messages when the row is a thread. */
214
217
  messageCount?: number;
218
+ /** Where the message sits, for a row shown outside its own folder. */
219
+ folder?: ResultFolder;
215
220
  /** The Remit Spam or Phishing label the message carries. */
216
221
  spam?: ThreadRowSpam;
217
222
  /** Labels applied to this message (issue #26) — filter-, organize-, and manually-applied alike. */
@@ -6,9 +6,16 @@ import { ROW_ATTRIBUTE } from "../lib/keymap-dispatch.js";
6
6
  import { LIST_ROW_ATTRIBUTE } from "../lib/roving-focus.js";
7
7
  import { Avatar } from "./avatar.js";
8
8
  import { Badge } from "./badge.js";
9
+ import { provenanceFolderLabel } from "./folder-role.js";
9
10
  import { LabelChip } from "./label-chip.js";
10
11
  import { MessageSettlementBadge } from "./message-settlement.js";
11
12
  import { SpamRowMarker } from "./spam-row-marker.js";
13
+ function FolderChip({ folder }) {
14
+ const label = folder ? provenanceFolderLabel(folder) : undefined;
15
+ if (!label)
16
+ return null;
17
+ return (_jsx(Badge, { tone: "neutral", className: "shrink-0", children: label }));
18
+ }
12
19
  /** Visible keyboard-focus ring for a row reached by the list's arrow-key cursor. */
13
20
  const ROW_FOCUS_RING = "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset";
14
21
  /**
@@ -41,7 +48,7 @@ export const comfortableRowClass = ({ active, focused, }) => cn(
41
48
  */
42
49
  export function CompactRowBody({ thread }) {
43
50
  const unread = !thread.isRead;
44
- return (_jsxs(_Fragment, { children: [_jsx("span", { className: "flex w-4 shrink-0 items-center justify-center", children: thread.spam ? (thread.spam.label.name === "Phishing" ? (_jsx(ShieldAlert, { className: "size-3.5 text-danger", role: "img", "aria-label": "Phishing" })) : (_jsx(TriangleAlert, { className: "size-3.5 text-warning", role: "img", "aria-label": "Spam" }))) : thread.starred ? (_jsx(Star, { className: "size-3 fill-warning text-warning" })) : unread ? (_jsx("span", { className: "size-1.5 rounded-full bg-accent" })) : null }), _jsx("span", { className: cn("w-36 shrink-0 truncate text-xs", unread ? "font-semibold text-fg" : "text-fg-muted"), children: thread.fromName }), _jsxs("span", { className: "min-w-0 flex-1 truncate text-xs", children: [_jsx("span", { className: cn(unread ? "font-medium text-fg" : "text-fg-muted"), children: thread.subject }), _jsxs("span", { className: "text-fg-subtle", children: [" \u2014 ", thread.snippet] })] }), thread.hasAttachment && (_jsx(Paperclip, { className: "size-3 shrink-0 text-fg-subtle", role: "img", "aria-label": "Has an attachment" })), thread.settlement && (_jsx(MessageSettlementBadge, { settlement: thread.settlement })), _jsx("span", { className: "w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums", children: thread.timeLabel })] }));
51
+ return (_jsxs(_Fragment, { children: [_jsx("span", { className: "flex w-4 shrink-0 items-center justify-center", children: thread.spam ? (thread.spam.label.name === "Phishing" ? (_jsx(ShieldAlert, { className: "size-3.5 text-danger", role: "img", "aria-label": "Phishing" })) : (_jsx(TriangleAlert, { className: "size-3.5 text-warning", role: "img", "aria-label": "Spam" }))) : thread.starred ? (_jsx(Star, { className: "size-3 fill-warning text-warning" })) : unread ? (_jsx("span", { className: "size-1.5 rounded-full bg-accent" })) : null }), _jsx("span", { className: cn("w-36 shrink-0 truncate text-xs", unread ? "font-semibold text-fg" : "text-fg-muted"), children: thread.fromName }), _jsxs("span", { className: "min-w-0 flex-1 truncate text-xs", children: [_jsx("span", { className: cn(unread ? "font-medium text-fg" : "text-fg-muted"), children: thread.subject }), _jsxs("span", { className: "text-fg-subtle", children: [" \u2014 ", thread.snippet] })] }), thread.hasAttachment && (_jsx(Paperclip, { className: "size-3 shrink-0 text-fg-subtle", role: "img", "aria-label": "Has an attachment" })), _jsx(FolderChip, { folder: thread.folder }), thread.settlement && (_jsx(MessageSettlementBadge, { settlement: thread.settlement })), _jsx("span", { className: "w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums", children: thread.timeLabel })] }));
45
52
  }
46
53
  /**
47
54
  * Bold the literal (case-insensitive) occurrences of `query` in `text`. Used by
@@ -77,7 +84,7 @@ function highlightMatches(text, query) {
77
84
  */
78
85
  export function ComfortableRowTextContent({ thread, badge, highlightQuery, }) {
79
86
  const unread = !thread.isRead;
80
- return (_jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-baseline justify-between gap-2", children: [_jsxs("span", { className: cn("flex min-w-0 items-center gap-1.5 truncate text-sm", unread ? "font-semibold text-fg" : "font-medium text-fg-muted"), children: [thread.trust === "vip" && (_jsx("span", { className: "size-1.5 shrink-0 rounded-full bg-accent-2" })), _jsx("span", { className: "truncate", children: thread.fromName }), thread.messageCount != null && thread.messageCount > 1 && (_jsx("span", { className: "shrink-0 text-2xs font-normal text-fg-subtle", children: thread.messageCount }))] }), _jsx("span", { className: "shrink-0 text-2xs text-fg-subtle tabular-nums", children: thread.timeLabel })] }), _jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: cn("truncate text-sm", unread ? "text-fg" : "text-fg-muted"), children: highlightMatches(thread.subject, highlightQuery) }), thread.starred && (_jsx(Star, { className: "size-3 shrink-0 fill-warning text-warning" })), thread.hasAttachment && (_jsx(Paperclip, { className: "size-3 shrink-0 text-fg-subtle", role: "img", "aria-label": "Has an attachment" }))] }), _jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle", children: highlightMatches(thread.snippet, highlightQuery) }), thread.category && thread.category !== "personal" && (_jsx(Badge, { tone: categoryTone[thread.category], className: "shrink-0", children: getCategoryLabel(thread.category) })), thread.spam && (_jsx(SpamRowMarker, { label: thread.spam.label, suspected: thread.spam.suspected })), thread.labels
87
+ return (_jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-baseline justify-between gap-2", children: [_jsxs("span", { className: cn("flex min-w-0 items-center gap-1.5 truncate text-sm", unread ? "font-semibold text-fg" : "font-medium text-fg-muted"), children: [thread.trust === "vip" && (_jsx("span", { className: "size-1.5 shrink-0 rounded-full bg-accent-2" })), _jsx("span", { className: "truncate", children: thread.fromName }), thread.messageCount != null && thread.messageCount > 1 && (_jsx("span", { className: "shrink-0 text-2xs font-normal text-fg-subtle", children: thread.messageCount }))] }), _jsx("span", { className: "shrink-0 text-2xs text-fg-subtle tabular-nums", children: thread.timeLabel })] }), _jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: cn("truncate text-sm", unread ? "text-fg" : "text-fg-muted"), children: highlightMatches(thread.subject, highlightQuery) }), thread.starred && (_jsx(Star, { className: "size-3 shrink-0 fill-warning text-warning" })), thread.hasAttachment && (_jsx(Paperclip, { className: "size-3 shrink-0 text-fg-subtle", role: "img", "aria-label": "Has an attachment" }))] }), _jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "line-clamp-1 min-w-0 flex-1 text-xs text-fg-subtle", children: highlightMatches(thread.snippet, highlightQuery) }), _jsx(FolderChip, { folder: thread.folder }), thread.category && thread.category !== "personal" && (_jsx(Badge, { tone: categoryTone[thread.category], className: "shrink-0", children: getCategoryLabel(thread.category) })), thread.spam && (_jsx(SpamRowMarker, { label: thread.spam.label, suspected: thread.spam.suspected })), thread.labels
81
88
  ?.filter((label) => label.labelId !== thread.spam?.label.labelId)
82
89
  .map((label) => (_jsx(LabelChip, { label: label, className: "max-w-20" }, label.labelId))), thread.settlement && (_jsx(MessageSettlementBadge, { settlement: thread.settlement })), badge] })] }));
83
90
  }
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useRef, useState } from "react";
3
3
  import { Archive, BellOff, CalendarDays, ChevronDown, ChevronRight, CircleAlert, CirclePause, FileText, Folder, Inbox, Mails, OctagonAlert, Send, Sparkles, Star, Trash, } from "../icons.js";
4
4
  import { cn } from "../lib/cn.js";
5
+ import { collapseFolderTree, folderAncestors, orderFolderNodes, } from "../lib/folder-tree.js";
5
6
  import { isLabelColorValue, labelDotClass } from "../lib/label-color.js";
6
7
  import { useRovingFocus } from "../lib/roving-focus.js";
7
8
  import { ACCOUNT_SERVICE_OFF_LABEL } from "./account-service-status.js";
@@ -88,6 +89,7 @@ const hasRole = (mb) => mb.role != null;
88
89
  const FOLDER_COLLAPSE_THRESHOLD = 8;
89
90
  const FOLDER_OPEN_KEY = "remit.nav.folders.open.";
90
91
  const ACCOUNT_OPEN_KEY = "remit.nav.account.open.";
92
+ const FOLDER_NODE_OPEN_KEY = "remit.nav.folder.open.";
91
93
  /**
92
94
  * Read a persisted open/closed flag. `fallback` applies only when nothing is
93
95
  * stored yet. Both the account section and the custom-folders section default
@@ -98,17 +100,23 @@ const ACCOUNT_OPEN_KEY = "remit.nav.account.open.";
98
100
  * Exported for unit testing the persistence contract.
99
101
  */
100
102
  export function readOpen(prefix, id, fallback) {
101
- if (typeof localStorage === "undefined")
102
- return fallback;
103
- const stored = localStorage.getItem(prefix + id);
104
- if (stored === null)
103
+ try {
104
+ const stored = localStorage.getItem(prefix + id);
105
+ if (stored === null)
106
+ return fallback;
107
+ return stored !== "0";
108
+ }
109
+ catch {
105
110
  return fallback;
106
- return stored !== "0";
111
+ }
107
112
  }
108
113
  export function writeOpen(prefix, id, open) {
109
- if (typeof localStorage === "undefined")
110
- return;
111
- localStorage.setItem(prefix + id, open ? "1" : "0");
114
+ try {
115
+ localStorage.setItem(prefix + id, open ? "1" : "0");
116
+ }
117
+ catch {
118
+ // Without storage the choice lasts until the page reloads.
119
+ }
112
120
  }
113
121
  export const NAV_FOLDER_OPEN_KEY = FOLDER_OPEN_KEY;
114
122
  export const NAV_ACCOUNT_OPEN_KEY = ACCOUNT_OPEN_KEY;
@@ -116,6 +124,13 @@ function AccountNav({ account, selectedNavId, onSelectNav, linkComponent, }) {
116
124
  const [accountOpen, setAccountOpen] = useState(() => readOpen(ACCOUNT_OPEN_KEY, account.id, true));
117
125
  const [foldersOpen, setFoldersOpen] = useState(() => readOpen(FOLDER_OPEN_KEY, account.id, true));
118
126
  const [showAllFolders, setShowAllFolders] = useState(false);
127
+ const [folderOpen, setFolderOpen] = useState({});
128
+ const isFolderOpen = (id) => folderOpen[id] ?? readOpen(FOLDER_NODE_OPEN_KEY, id, true);
129
+ const toggleFolder = (id) => {
130
+ const next = !isFolderOpen(id);
131
+ writeOpen(FOLDER_NODE_OPEN_KEY, id, next);
132
+ setFolderOpen((open) => ({ ...open, [id]: next }));
133
+ };
119
134
  const toggleAccount = () => {
120
135
  setAccountOpen((open) => {
121
136
  const next = !open;
@@ -134,26 +149,44 @@ function AccountNav({ account, selectedNavId, onSelectNav, linkComponent, }) {
134
149
  .filter(hasRole)
135
150
  .sort((a, b) => ROLE_ORDER[a.role] - ROLE_ORDER[b.role]);
136
151
  const folders = account.mailboxes.filter((mb) => !hasRole(mb));
137
- const visibleFolders = showAllFolders || folders.length <= FOLDER_COLLAPSE_THRESHOLD
138
- ? folders
139
- : folders.slice(0, FOLDER_COLLAPSE_THRESHOLD);
140
- const hiddenCount = folders.length - visibleFolders.length;
152
+ const delimiter = account.hierarchyDelimiter;
153
+ const folderById = new Map(folders.map((mb) => [mb.id, mb]));
154
+ const nodes = folders.map((mb) => ({
155
+ id: mb.id,
156
+ label: mb.name,
157
+ path: mb.fullPath ?? mb.name,
158
+ }));
159
+ const present = new Set(nodes.map((node) => node.path));
160
+ const parents = new Set(nodes.flatMap((node) => folderAncestors(node.path, delimiter).filter((path) => present.has(path))));
161
+ const selected = nodes.find((node) => node.id === selectedNavId);
162
+ const selectedAncestors = new Set(selected ? folderAncestors(selected.path, delimiter) : []);
163
+ const expanded = new Set(nodes
164
+ .filter((node) => selectedAncestors.has(node.path) || isFolderOpen(node.id))
165
+ .map((node) => node.path));
166
+ const rows = collapseFolderTree(orderFolderNodes(nodes, delimiter), expanded, delimiter).flatMap((row) => {
167
+ const mailbox = folderById.get(row.folder.id);
168
+ return mailbox ? [{ ...row, mailbox }] : [];
169
+ });
170
+ const visibleRows = showAllFolders || rows.length <= FOLDER_COLLAPSE_THRESHOLD
171
+ ? rows
172
+ : rows.slice(0, FOLDER_COLLAPSE_THRESHOLD);
173
+ const hiddenCount = rows.length - visibleRows.length;
141
174
  const status = account.status ?? "ready";
142
175
  const mailOff = account.syncedServices !== undefined &&
143
176
  !account.syncedServices.includes("Mail");
144
177
  const isEmpty = status === "ready" && system.length === 0 && folders.length === 0;
145
178
  return (_jsxs("div", { className: "mt-3", children: [_jsxs("button", { type: "button", onClick: toggleAccount, "aria-expanded": accountOpen, className: cn("flex w-full items-center gap-1.5 px-2 pb-1 text-left transition-colors hover:text-fg", FOCUS_RING, account.muted && "opacity-55"), children: [accountOpen ? (_jsx(ChevronDown, { className: "size-3 shrink-0 text-fg-subtle" })) : (_jsx(ChevronRight, { className: "size-3 shrink-0 text-fg-subtle" })), _jsx("span", { className: "truncate text-2xs font-semibold uppercase tracking-wider text-fg-subtle", children: account.label }), account.muted && (_jsxs(_Fragment, { children: [_jsx(BellOff, { className: "size-3 shrink-0 text-fg-subtle" }), _jsx("span", { className: "text-2xs text-fg-subtle", children: "muted" })] })), mailOff && (_jsxs(_Fragment, { children: [_jsx(CirclePause, { className: "size-3 shrink-0 text-fg-subtle" }), _jsx("span", { className: "text-2xs text-fg-subtle", children: ACCOUNT_SERVICE_OFF_LABEL.Mail })] }))] }), accountOpen && (_jsxs(_Fragment, { children: [status === "loading" && (_jsx("div", { className: "px-2 py-1 text-sm text-fg-muted", children: "Loading\u2026" })), status === "error" && (_jsxs("div", { role: "alert", className: "mx-2 my-1 flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-2 py-1.5 text-sm", children: [_jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0 text-danger", "aria-hidden": "true" }), _jsx("div", { className: "min-w-0 flex-1", children: _jsx("p", { className: "font-medium text-danger", children: "Couldn't load mailboxes" }) }), account.onRetry && (_jsx("button", { type: "button", onClick: account.onRetry, className: "shrink-0 text-sm font-medium text-accent hover:underline", children: "Retry" }))] })), isEmpty && (_jsx("div", { className: "px-2 py-1 text-sm text-fg-muted", children: "No mailboxes" })), status === "ready" && (_jsxs(_Fragment, { children: [system.map((mb) => (_jsx(NavItem, { navId: mb.id, linkComponent: linkComponent, icon: roleIcon(mb.role), label: mb.name, ariaLabel: mb.name, title: mb.fullPath ?? mb.name, failure: mb.failure, count: mb.unseen, active: selectedNavId === mb.id, dimmed: account.muted, onClick: () => onSelectNav?.(mb.id) }, mb.id))), account.outboxPending !== undefined && (_jsx(NavItem, { navId: "outbox", linkComponent: linkComponent, icon: _jsx(Send, { className: "size-4" }), label: "Outbox", ariaLabel: "Outbox", count: account.outboxPending > 0
146
179
  ? account.outboxPending
147
- : undefined, active: selectedNavId === "outbox", dimmed: account.muted, onClick: () => onSelectNav?.("outbox") })), folders.length > 0 && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: toggleFolders, "aria-expanded": foldersOpen, className: cn("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg", FOCUS_RING), children: [foldersOpen ? (_jsx(ChevronDown, { className: "size-3 shrink-0" })) : (_jsx(ChevronRight, { className: "size-3 shrink-0" })), _jsx("span", { className: "flex-1", children: "Folders" }), _jsx("span", { className: "tabular-nums opacity-70", children: folders.length })] }), foldersOpen && (_jsxs(_Fragment, { children: [visibleFolders.map((mb) => (_jsx(NavItem, { navId: mb.id, linkComponent: linkComponent, icon: _jsx(Folder, { className: "size-4" }), label: mb.name, ariaLabel: mb.name, title: mb.fullPath ?? mb.name, failure: mb.failure, count: mb.unseen, active: selectedNavId === mb.id, dimmed: account.muted, onClick: () => onSelectNav?.(mb.id) }, mb.id))), (hiddenCount > 0 || showAllFolders) &&
148
- folders.length > FOLDER_COLLAPSE_THRESHOLD && (_jsx("button", { type: "button", onClick: () => setShowAllFolders((all) => !all), className: cn("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline", FOCUS_RING), children: showAllFolders
180
+ : undefined, active: selectedNavId === "outbox", dimmed: account.muted, onClick: () => onSelectNav?.("outbox") })), folders.length > 0 && (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", onClick: toggleFolders, "aria-expanded": foldersOpen, className: cn("mt-1 flex w-full items-center gap-1 px-2 py-1 text-left text-2xs font-semibold uppercase tracking-wider text-fg-subtle transition-colors hover:text-fg", FOCUS_RING), children: [foldersOpen ? (_jsx(ChevronDown, { className: "size-3 shrink-0" })) : (_jsx(ChevronRight, { className: "size-3 shrink-0" })), _jsx("span", { className: "flex-1", children: "Folders" }), _jsx("span", { className: "tabular-nums opacity-70", children: folders.length })] }), foldersOpen && (_jsxs(_Fragment, { children: [visibleRows.map(({ mailbox: mb, folder, depth, expanded: open }) => (_jsxs("div", { className: "flex items-center", style: { paddingLeft: `${depth * 0.75}rem` }, children: [parents.has(folder.path) ? (_jsx("button", { type: "button", onClick: () => toggleFolder(mb.id), "aria-expanded": open, "aria-label": `${open ? "Collapse" : "Expand"} ${mb.name}`, className: cn("flex size-5 shrink-0 items-center justify-center rounded text-fg-subtle transition-colors hover:text-fg", FOCUS_RING), children: open ? (_jsx(ChevronDown, { className: "size-3" })) : (_jsx(ChevronRight, { className: "size-3" })) })) : (_jsx("span", { className: "size-5 shrink-0" })), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(NavItem, { navId: mb.id, linkComponent: linkComponent, icon: _jsx(Folder, { className: "size-4" }), label: mb.name, ariaLabel: mb.name, title: mb.fullPath ?? mb.name, failure: mb.failure, count: mb.unseen, active: selectedNavId === mb.id, dimmed: account.muted, onClick: () => onSelectNav?.(mb.id) }) })] }, mb.id))), (hiddenCount > 0 || showAllFolders) &&
181
+ rows.length > FOLDER_COLLAPSE_THRESHOLD && (_jsx("button", { type: "button", onClick: () => setShowAllFolders((all) => !all), className: cn("ml-7 flex items-center px-2 py-1 text-2xs font-medium text-accent transition-colors hover:underline", FOCUS_RING), children: showAllFolders
149
182
  ? "Show less"
150
- : `Show all (${folders.length})` }))] }))] }))] }))] }))] }));
183
+ : `Show all (${rows.length})` }))] }))] }))] }))] }))] }));
151
184
  }
152
185
  export function NavSidebar({ accounts, selectedNavId, briefUnseen, onSelectNav, variant = "desktop", linkComponent, labels = [], calendarNav = "hidden", }) {
153
186
  const containerRef = useRef(null);
154
187
  useRovingFocus({ containerRef, itemSelector: NAV_ITEM_SELECTOR });
155
188
  const isDrawer = variant === "drawer";
156
- const navBody = (_jsxs("nav", { ref: isDrawer ? containerRef : undefined, className: isDrawer ? "px-2 py-2" : "flex-1 overflow-y-auto px-2 py-2", "aria-label": "Mailboxes", children: [_jsx(NavItem, { navId: "brief", linkComponent: linkComponent, icon: _jsx(Sparkles, { className: "size-4" }), label: "Daily brief", ariaLabel: "Daily brief", count: briefUnseen, active: selectedNavId === "brief", onClick: () => onSelectNav?.("brief") }), labels.map((label) => (_jsx(NavItem, { navId: label.id, linkComponent: linkComponent, icon: labelIcon(label.color), label: label.name, ariaLabel: label.name, active: selectedNavId === label.id, onClick: () => onSelectNav?.(label.id) }, label.id))), calendarNav === "shown" && (_jsx(NavItem, { navId: "calendar", linkComponent: linkComponent, icon: _jsx(CalendarDays, { className: "size-4" }), label: "Calendar", ariaLabel: "Calendar", active: selectedNavId === "calendar", onClick: () => onSelectNav?.("calendar") })), _jsx(NavItem, { navId: "flagged", linkComponent: linkComponent, icon: _jsx(Star, { className: "size-4" }), label: "Starred", ariaLabel: "Starred", active: selectedNavId === "flagged", onClick: () => onSelectNav?.("flagged") }), accounts.length === 0 ? (_jsx("div", { className: "px-2 py-4 text-center text-sm text-fg-muted", children: "No accounts configured" })) : (accounts.map((account) => (_jsx(AccountNav, { account: account, selectedNavId: selectedNavId, onSelectNav: onSelectNav, linkComponent: linkComponent }, account.id))))] }));
189
+ const navBody = (_jsxs("nav", { ref: isDrawer ? containerRef : undefined, className: isDrawer ? "px-2 py-2" : "flex-1 overflow-y-auto px-2 py-2", "aria-label": "Mailboxes", children: [_jsx(NavItem, { navId: "brief", linkComponent: linkComponent, icon: _jsx(Sparkles, { className: "size-4" }), label: "Daily brief", ariaLabel: "Daily brief", count: briefUnseen, active: selectedNavId === "brief", onClick: () => onSelectNav?.("brief") }), labels.map((label) => (_jsx(NavItem, { navId: label.id, linkComponent: linkComponent, icon: labelIcon(label.color), label: label.name, ariaLabel: label.name, count: label.unseen, active: selectedNavId === label.id, onClick: () => onSelectNav?.(label.id) }, label.id))), calendarNav === "shown" && (_jsx(NavItem, { navId: "calendar", linkComponent: linkComponent, icon: _jsx(CalendarDays, { className: "size-4" }), label: "Calendar", ariaLabel: "Calendar", active: selectedNavId === "calendar", onClick: () => onSelectNav?.("calendar") })), _jsx(NavItem, { navId: "flagged", linkComponent: linkComponent, icon: _jsx(Star, { className: "size-4" }), label: "Starred", ariaLabel: "Starred", active: selectedNavId === "flagged", onClick: () => onSelectNav?.("flagged") }), accounts.length === 0 ? (_jsx("div", { className: "px-2 py-4 text-center text-sm text-fg-muted", children: "No accounts configured" })) : (accounts.map((account) => (_jsx(AccountNav, { account: account, selectedNavId: selectedNavId, onSelectNav: onSelectNav, linkComponent: linkComponent }, account.id))))] }));
157
190
  if (isDrawer)
158
191
  return navBody;
159
192
  return (_jsx("aside", { ref: containerRef, className: "flex h-full w-full flex-col bg-surface-sunken", children: navBody }));
@@ -1,4 +1,4 @@
1
- import { type ResultFolder } from "./folder-role.js";
1
+ import type { ResultFolder } from "./folder-role.js";
2
2
  export type SearchResultTone = "neutral" | "accent" | "positive" | "warning" | "danger";
3
3
  export interface SearchResult {
4
4
  id: string;
@@ -1,7 +1,6 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from "../lib/cn.js";
3
3
  import { Badge } from "./badge.js";
4
- import { provenanceFolderLabel } from "./folder-role.js";
5
4
  import { ComfortableRowBody, comfortableRowClass } from "./message-row.js";
6
5
  /**
7
6
  * A search result as list-row data. The engines return less than a list row
@@ -9,7 +8,7 @@ import { ComfortableRowBody, comfortableRowClass } from "./message-row.js";
9
8
  * rather than being invented. The category is not mapped here: the search
10
9
  * carries its own labelled chip, which the row renders in the badge slot.
11
10
  */
12
- function searchResultRowData(result) {
11
+ function searchResultRowData(result, showFolder) {
13
12
  return {
14
13
  id: result.id,
15
14
  fromName: result.sender,
@@ -20,6 +19,7 @@ function searchResultRowData(result) {
20
19
  isRead: !result.unread,
21
20
  starred: result.flagged,
22
21
  ...(result.mailboxId ? { mailboxId: result.mailboxId } : {}),
22
+ ...(showFolder && result.folder ? { folder: result.folder } : {}),
23
23
  };
24
24
  }
25
25
  /**
@@ -34,8 +34,5 @@ function searchResultRowData(result) {
34
34
  * optional `query` to bold literal matches.
35
35
  */
36
36
  export function SearchResultRow({ result, onClick, query, showFolder = true, }) {
37
- const folderLabel = showFolder && result.folder
38
- ? provenanceFolderLabel(result.folder)
39
- : undefined;
40
- return (_jsx("button", { type: "button", onClick: onClick, className: cn("group", comfortableRowClass({}), "border-b border-line"), children: _jsx(ComfortableRowBody, { thread: searchResultRowData(result), highlightQuery: query, badge: _jsxs(_Fragment, { children: [folderLabel && (_jsx(Badge, { tone: "neutral", className: "shrink-0", children: folderLabel })), result.category && (_jsx(Badge, { tone: result.category.tone ?? "neutral", className: "shrink-0", children: result.category.label }))] }) }) }));
37
+ return (_jsx("button", { type: "button", onClick: onClick, className: cn("group", comfortableRowClass({}), "border-b border-line"), children: _jsx(ComfortableRowBody, { thread: searchResultRowData(result, showFolder), highlightQuery: query, badge: result.category && (_jsx(Badge, { tone: result.category.tone ?? "neutral", className: "shrink-0", children: result.category.label })) }) }));
41
38
  }
@@ -68,7 +68,8 @@ export declare const filterFolderTree: (ordered: readonly FolderTreeNode[], quer
68
68
  /**
69
69
  * The unfiltered list: roots always, and a child only while every ancestor it
70
70
  * has on screen is open. A folder whose parent is absent from the list is a
71
- * root, so it never hides behind something that was never there.
71
+ * root, so it never hides behind something that was never there, and it
72
+ * indents only by the ancestors the list holds.
72
73
  */
73
74
  export declare const collapseFolderTree: (ordered: readonly FolderTreeNode[], expanded: ReadonlySet<string>, delimiter: string) => FolderTreeRow[];
74
75
  /**
@@ -107,18 +107,24 @@ export const filterFolderTree = (ordered, query, delimiter, expanded = new Set()
107
107
  /**
108
108
  * The unfiltered list: roots always, and a child only while every ancestor it
109
109
  * has on screen is open. A folder whose parent is absent from the list is a
110
- * root, so it never hides behind something that was never there.
110
+ * root, so it never hides behind something that was never there, and it
111
+ * indents only by the ancestors the list holds.
111
112
  */
112
113
  export const collapseFolderTree = (ordered, expanded, delimiter) => {
113
114
  const present = new Set(ordered.map((folder) => folder.path));
114
- return ordered
115
- .filter((folder) => folderAncestors(folder.path, delimiter).every((ancestor) => !present.has(ancestor) || expanded.has(ancestor)))
116
- .map((folder) => ({
117
- folder,
118
- depth: folderDepth(folder.path, delimiter),
119
- context: false,
120
- expanded: expanded.has(folder.path),
121
- }));
115
+ return ordered.flatMap((folder) => {
116
+ const shown = folderAncestors(folder.path, delimiter).filter((ancestor) => present.has(ancestor));
117
+ if (!shown.every((ancestor) => expanded.has(ancestor)))
118
+ return [];
119
+ return [
120
+ {
121
+ folder,
122
+ depth: shown.length,
123
+ context: false,
124
+ expanded: expanded.has(folder.path),
125
+ },
126
+ ];
127
+ });
122
128
  };
123
129
  /**
124
130
  * Drops a create action at the end of every open folder's children, so "New
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.239",
3
+ "version": "0.0.241",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",