@remit/ui 0.0.238 → 0.0.240
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/components/app-shell-types.d.ts +12 -2
- package/dist/components/button.d.ts +5 -0
- package/dist/components/button.js +2 -0
- package/dist/components/check-again-panel.d.ts +43 -0
- package/dist/components/check-again-panel.js +60 -0
- package/dist/components/failure-banner.d.ts +11 -0
- package/dist/components/failure-banner.js +7 -0
- package/dist/components/intelligence-calendar-fixtures.js +0 -12
- package/dist/components/intelligence-panel.d.ts +7 -26
- package/dist/components/intelligence-panel.js +4 -16
- package/dist/components/intelligence-section.d.ts +3 -1
- package/dist/components/intelligence-section.js +2 -2
- package/dist/components/message-row.js +13 -3
- package/dist/components/nav-sidebar.js +49 -16
- package/dist/components/search-result-row.d.ts +1 -1
- package/dist/components/search-result-row.js +4 -7
- package/dist/components/selection-top-bar.d.ts +3 -1
- package/dist/components/selection-top-bar.js +10 -2
- package/dist/components/spam-copy.d.ts +25 -0
- package/dist/components/spam-copy.js +100 -0
- package/dist/components/spam-daily-chart.d.ts +17 -0
- package/dist/components/spam-daily-chart.js +18 -0
- package/dist/components/spam-fixtures.d.ts +19 -0
- package/dist/components/spam-fixtures.js +143 -0
- package/dist/components/spam-row-marker.d.ts +12 -0
- package/dist/components/spam-row-marker.js +10 -0
- package/dist/components/spam-verdict-panel.d.ts +37 -0
- package/dist/components/spam-verdict-panel.js +74 -0
- package/dist/components/spam-warning-banner.d.ts +20 -0
- package/dist/components/spam-warning-banner.js +62 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +8 -1
- package/dist/lib/folder-tree.d.ts +2 -1
- package/dist/lib/folder-tree.js +15 -9
- package/package.json +3 -2
|
@@ -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
|
|
@@ -175,6 +178,11 @@ export interface ThreadRowLabel {
|
|
|
175
178
|
name: string;
|
|
176
179
|
color: string;
|
|
177
180
|
}
|
|
181
|
+
export interface ThreadRowSpam {
|
|
182
|
+
label: ThreadRowLabel;
|
|
183
|
+
/** The message still sits where it arrived, under the warning. */
|
|
184
|
+
suspected: boolean;
|
|
185
|
+
}
|
|
178
186
|
export interface ThreadRowData {
|
|
179
187
|
id: string;
|
|
180
188
|
/**
|
|
@@ -207,8 +215,10 @@ export interface ThreadRowData {
|
|
|
207
215
|
category?: ThreadCategory;
|
|
208
216
|
/** Number of messages when the row is a thread. */
|
|
209
217
|
messageCount?: number;
|
|
210
|
-
/**
|
|
211
|
-
|
|
218
|
+
/** Where the message sits, for a row shown outside its own folder. */
|
|
219
|
+
folder?: ResultFolder;
|
|
220
|
+
/** The Remit Spam or Phishing label the message carries. */
|
|
221
|
+
spam?: ThreadRowSpam;
|
|
212
222
|
/** Labels applied to this message (issue #26) — filter-, organize-, and manually-applied alike. */
|
|
213
223
|
labels?: ThreadRowLabel[];
|
|
214
224
|
/**
|
|
@@ -7,6 +7,11 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
7
7
|
icon?: ReactNode;
|
|
8
8
|
ref?: Ref<HTMLButtonElement>;
|
|
9
9
|
}
|
|
10
|
+
/** The button look, for a router link that has to read as a button. */
|
|
11
|
+
export declare const buttonClassName: ({ variant, size, }: {
|
|
12
|
+
variant?: Variant;
|
|
13
|
+
size?: Size;
|
|
14
|
+
}) => string;
|
|
10
15
|
export declare function Button({ variant, size, icon, className, children, ref, ...props }: ButtonProps): import("react").JSX.Element;
|
|
11
16
|
export interface ButtonLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
12
17
|
variant?: Variant;
|
|
@@ -15,6 +15,8 @@ const sizes = {
|
|
|
15
15
|
* with `md` plus an explicit `min-h-11` instead of stretching to square. */
|
|
16
16
|
touch: "h-11 w-11 text-sm",
|
|
17
17
|
};
|
|
18
|
+
/** The button look, for a router link that has to read as a button. */
|
|
19
|
+
export const buttonClassName = ({ variant = "primary", size = "md", }) => cn(base, variants[variant], sizes[size]);
|
|
18
20
|
export function Button({ variant = "primary", size = "md", icon, className, children, ref, ...props }) {
|
|
19
21
|
return (_jsxs("button", { type: "button", ref: ref, className: cn(base, variants[variant], sizes[size], className), ...props, children: [icon, children] }));
|
|
20
22
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RemitImapRescanFailureCode } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
+
export interface CheckAgainFailure {
|
|
3
|
+
messageId: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
code: RemitImapRescanFailureCode;
|
|
6
|
+
retryable: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckAgainSummary {
|
|
9
|
+
nowSpam: number;
|
|
10
|
+
nowSuspected: number;
|
|
11
|
+
noLongerSuspected: number;
|
|
12
|
+
}
|
|
13
|
+
export type CheckAgainPanelProps = {
|
|
14
|
+
state: "Running";
|
|
15
|
+
checked: number;
|
|
16
|
+
total: number;
|
|
17
|
+
onStop: () => void;
|
|
18
|
+
} | {
|
|
19
|
+
state: "Done";
|
|
20
|
+
total: number;
|
|
21
|
+
summary: CheckAgainSummary;
|
|
22
|
+
onDone: () => void;
|
|
23
|
+
} | {
|
|
24
|
+
state: "PartialFailure";
|
|
25
|
+
checked: number;
|
|
26
|
+
total: number;
|
|
27
|
+
failures: CheckAgainFailure[];
|
|
28
|
+
reportIssueHref: string;
|
|
29
|
+
onRetry: () => void;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
};
|
|
32
|
+
export declare function checkAgainSummarySentence(summary: CheckAgainSummary): string;
|
|
33
|
+
/**
|
|
34
|
+
* Progress and outcome of Check again over a selection or one message. Remit
|
|
35
|
+
* sends ten at a time; the run lives in memory and ends with the page.
|
|
36
|
+
*/
|
|
37
|
+
export declare function CheckAgainPanel(props: CheckAgainPanelProps): import("react").JSX.Element;
|
|
38
|
+
export type CheckAgainOutcome = "NowSpam" | "NowSuspected" | "NowClean" | "Unchanged";
|
|
39
|
+
/** The dashed tag a row carries once its Check again batch lands. */
|
|
40
|
+
export declare function CheckAgainResultTag({ outcome, score, }: {
|
|
41
|
+
outcome: CheckAgainOutcome;
|
|
42
|
+
score: number;
|
|
43
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { Button, ButtonLink } from "./button.js";
|
|
4
|
+
import { ProgressBar } from "./progress-bar.js";
|
|
5
|
+
import { CHECK_AGAIN_FAILURE_SENTENCES, formatSpamScore } from "./spam-copy.js";
|
|
6
|
+
export function checkAgainSummarySentence(summary) {
|
|
7
|
+
const parts = [
|
|
8
|
+
summary.nowSpam > 0 && `${summary.nowSpam} now reach Spam`,
|
|
9
|
+
summary.nowSuspected > 0 &&
|
|
10
|
+
`${summary.nowSuspected} ${summary.nowSuspected === 1 ? "is" : "are"} now suspected`,
|
|
11
|
+
summary.noLongerSuspected > 0 &&
|
|
12
|
+
`${summary.noLongerSuspected} ${summary.noLongerSuspected === 1 ? "is" : "are"} no longer suspected`,
|
|
13
|
+
].filter((part) => typeof part === "string");
|
|
14
|
+
const changed = summary.nowSpam + summary.nowSuspected + summary.noLongerSuspected;
|
|
15
|
+
const moved = summary.nowSpam > 0
|
|
16
|
+
? "Nothing moved. Open a message to move it to Spam."
|
|
17
|
+
: "Nothing moved.";
|
|
18
|
+
if (changed === 0)
|
|
19
|
+
return `Nothing changed. ${moved}`;
|
|
20
|
+
return `${changed} changed: ${parts.join(", ")}. ${moved}`;
|
|
21
|
+
}
|
|
22
|
+
const onEscape = (action) => (event) => {
|
|
23
|
+
if (event.key !== "Escape")
|
|
24
|
+
return;
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
action();
|
|
27
|
+
};
|
|
28
|
+
function PanelFrame({ children, onKeyDown, }) {
|
|
29
|
+
return (_jsx("section", { "aria-label": "Check again", onKeyDown: onKeyDown, className: "w-full max-w-md space-y-3 rounded-lg border border-line bg-surface p-4 text-sm shadow-lg", children: children }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Progress and outcome of Check again over a selection or one message. Remit
|
|
33
|
+
* sends ten at a time; the run lives in memory and ends with the page.
|
|
34
|
+
*/
|
|
35
|
+
export function CheckAgainPanel(props) {
|
|
36
|
+
const focusRef = useRef(null);
|
|
37
|
+
const { state } = props;
|
|
38
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: focus moves once per state the panel enters
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
focusRef.current?.focus();
|
|
41
|
+
}, [state]);
|
|
42
|
+
if (props.state === "Running") {
|
|
43
|
+
return (_jsxs(PanelFrame, { onKeyDown: onEscape(props.onStop), children: [_jsx("p", { "aria-live": "polite", className: "font-semibold text-fg tabular-nums", children: `Checked ${props.checked} of ${props.total}` }), _jsx(ProgressBar, { value: props.checked, max: props.total }), _jsx("p", { className: "text-fg-muted", children: "Remit sends ten at a time and waits for each answer. Keep this page open until it finishes." }), _jsx(Button, { ref: focusRef, variant: "secondary", size: "md", onClick: props.onStop, children: "Stop" })] }));
|
|
44
|
+
}
|
|
45
|
+
if (props.state === "Done") {
|
|
46
|
+
return (_jsxs(PanelFrame, { onKeyDown: onEscape(props.onDone), children: [_jsx("p", { "aria-live": "polite", className: "font-semibold text-fg tabular-nums", children: `Checked ${props.total} of ${props.total}` }), _jsx(ProgressBar, { value: props.total, max: props.total, tone: "success" }), _jsx("p", { className: "text-fg-muted", children: checkAgainSummarySentence(props.summary) }), _jsx(Button, { ref: focusRef, variant: "primary", size: "md", onClick: props.onDone, children: "Done" })] }));
|
|
47
|
+
}
|
|
48
|
+
const retryable = props.failures.filter((failure) => failure.retryable).length;
|
|
49
|
+
return (_jsxs(PanelFrame, { onKeyDown: onEscape(props.onClose), children: [_jsx("p", { "aria-live": "polite", className: "font-semibold text-fg tabular-nums", children: `Checked ${props.checked} of ${props.total}. ${props.failures.length} couldn't be checked.` }), _jsx(ProgressBar, { value: props.checked, max: props.total, tone: "warning" }), _jsx("ul", { className: "list-disc space-y-1 pl-4 text-fg-muted marker:text-fg-subtle", children: props.failures.map((failure) => (_jsxs("li", { children: [_jsx("span", { className: "text-fg", children: failure.subject }), ":", " ", CHECK_AGAIN_FAILURE_SENTENCES[failure.code]] }, failure.messageId))) }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [retryable > 0 && (_jsx(Button, { ref: focusRef, variant: "primary", size: "md", onClick: props.onRetry, children: `Try again for ${retryable}` })), _jsx(ButtonLink, { variant: "ghost", size: "md", href: props.reportIssueHref, external: true, children: "Report an issue" }), _jsx(Button, { ref: retryable > 0 ? undefined : focusRef, variant: "secondary", size: "md", onClick: props.onClose, children: "Close" })] })] }));
|
|
50
|
+
}
|
|
51
|
+
const OUTCOME_LABELS = {
|
|
52
|
+
NowSpam: "Now: Spam",
|
|
53
|
+
NowSuspected: "Now: suspected",
|
|
54
|
+
NowClean: "Now: clean",
|
|
55
|
+
Unchanged: "Unchanged",
|
|
56
|
+
};
|
|
57
|
+
/** The dashed tag a row carries once its Check again batch lands. */
|
|
58
|
+
export function CheckAgainResultTag({ outcome, score, }) {
|
|
59
|
+
return (_jsx("span", { className: "inline-flex shrink-0 items-center rounded border border-dashed border-line-strong px-1.5 text-2xs font-medium leading-4 text-fg-muted tabular-nums", children: `${OUTCOME_LABELS[outcome]} ${formatSpamScore(score)}` }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Ref } from "react";
|
|
2
|
+
export interface FailureBannerProps {
|
|
3
|
+
title: string;
|
|
4
|
+
message: string;
|
|
5
|
+
reportHref: string;
|
|
6
|
+
onRetry?: () => void;
|
|
7
|
+
retryLabel?: string;
|
|
8
|
+
retryRef?: Ref<HTMLButtonElement>;
|
|
9
|
+
}
|
|
10
|
+
/** A settings section's failure: what failed, the error, a retry and a report link. */
|
|
11
|
+
export declare function FailureBanner({ title, message, reportHref, onRetry, retryLabel, retryRef, }: FailureBannerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Banner } from "./banner.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
/** A settings section's failure: what failed, the error, a retry and a report link. */
|
|
5
|
+
export function FailureBanner({ title, message, reportHref, onRetry, retryLabel = "Retry", retryRef, }) {
|
|
6
|
+
return (_jsxs(Banner, { tone: "danger", variant: "soft", children: [_jsx("p", { className: "font-medium", children: title }), _jsx("p", { className: "mt-0.5 break-words text-fg-muted", children: message }), _jsxs("p", { className: "flex flex-wrap items-center gap-x-4", children: [onRetry && (_jsx(Button, { ref: retryRef, variant: "secondary", className: "min-h-11", onClick: onRetry, children: retryLabel })), _jsx("a", { href: reportHref, target: "_blank", rel: "noreferrer", className: "inline-flex min-h-11 items-center font-medium text-accent hover:underline", children: "Report an issue" })] })] }));
|
|
7
|
+
}
|
|
@@ -290,12 +290,6 @@ export const organiserSender = {
|
|
|
290
290
|
inboundCount: 214,
|
|
291
291
|
replyCount: 188,
|
|
292
292
|
},
|
|
293
|
-
authenticity: {
|
|
294
|
-
verdict: "aligned",
|
|
295
|
-
fromDomain: "northwind.example",
|
|
296
|
-
dkimDomain: "northwind.example",
|
|
297
|
-
summary: "This message was signed by northwind.example.",
|
|
298
|
-
},
|
|
299
293
|
category: { value: "personal" },
|
|
300
294
|
spamAction: "reportSpam",
|
|
301
295
|
flags: { vip: true },
|
|
@@ -309,12 +303,6 @@ export const airlineSender = {
|
|
|
309
303
|
inboundCount: 31,
|
|
310
304
|
replyCount: 0,
|
|
311
305
|
},
|
|
312
|
-
authenticity: {
|
|
313
|
-
verdict: "aligned",
|
|
314
|
-
fromDomain: "klm.example",
|
|
315
|
-
dkimDomain: "klm.example",
|
|
316
|
-
summary: "This message was signed by klm.example.",
|
|
317
|
-
},
|
|
318
306
|
category: { value: "transactional" },
|
|
319
307
|
spamAction: "reportSpam",
|
|
320
308
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import { type ThreadCategory } from "../category-presentation.js";
|
|
2
3
|
import { type IntelligenceCalendarActions, type IntelligenceCalendarData } from "./intelligence-calendar.js";
|
|
3
4
|
import { type PlacementIntel } from "./intelligence-placement.js";
|
|
@@ -19,31 +20,10 @@ export interface SenderIntel {
|
|
|
19
20
|
/**
|
|
20
21
|
* True when the sender address is missing or unparseable (no valid domain).
|
|
21
22
|
* Drives a red "couldn't verify the address" badge instead of the quiet grey
|
|
22
|
-
* "Unknown sender"
|
|
23
|
+
* "Unknown sender".
|
|
23
24
|
*/
|
|
24
25
|
addressUnverified?: boolean;
|
|
25
26
|
}
|
|
26
|
-
export interface AuthenticityIntel {
|
|
27
|
-
/**
|
|
28
|
-
* Risk tier. `aligned` (green) — verified sender. `caution` (orange) — no
|
|
29
|
-
* verification signal available. `mismatch` (red) — impersonation or an
|
|
30
|
-
* unreadable sender address.
|
|
31
|
-
*/
|
|
32
|
-
verdict: "aligned" | "caution" | "mismatch";
|
|
33
|
-
fromDomain: string;
|
|
34
|
-
/** Signing domain the message was actually sent from, when known. */
|
|
35
|
-
dkimDomain?: string;
|
|
36
|
-
/** Brand the display name claims, when it differs from the mailbox. */
|
|
37
|
-
claimedBrand?: string;
|
|
38
|
-
/** Plain-language verdict shown to the user. */
|
|
39
|
-
summary: string;
|
|
40
|
-
/**
|
|
41
|
-
* True when the red tier is driven by an unreadable sender address rather
|
|
42
|
-
* than an impersonation mismatch — selects the headline and suppresses the
|
|
43
|
-
* domain-comparison line (there is no valid domain to show).
|
|
44
|
-
*/
|
|
45
|
-
addressUnreadable?: boolean;
|
|
46
|
-
}
|
|
47
27
|
export interface SenderFlagsIntel {
|
|
48
28
|
vip?: boolean;
|
|
49
29
|
muted?: boolean;
|
|
@@ -61,7 +41,6 @@ export interface SenderFlagsIntel {
|
|
|
61
41
|
}
|
|
62
42
|
export interface IntelligenceData {
|
|
63
43
|
sender: SenderIntel;
|
|
64
|
-
authenticity: AuthenticityIntel;
|
|
65
44
|
category: {
|
|
66
45
|
value: ThreadCategory;
|
|
67
46
|
overridden?: boolean;
|
|
@@ -69,10 +48,10 @@ export interface IntelligenceData {
|
|
|
69
48
|
flags?: SenderFlagsIntel;
|
|
70
49
|
/** Where Remit placed this message and why. Absent when Remit recorded no verdict. */
|
|
71
50
|
placement?: PlacementIntel;
|
|
72
|
-
spamAction:
|
|
51
|
+
spamAction: SpamQuickAction;
|
|
73
52
|
}
|
|
74
53
|
/** Which spam control the message offers: undo its spam report, move it out of Junk, or report it. */
|
|
75
|
-
export type
|
|
54
|
+
export type SpamQuickAction = "undoSpamReport" | "notSpam" | "reportSpam";
|
|
76
55
|
export interface IntelligenceQuickActions {
|
|
77
56
|
onToggleVip?: () => void;
|
|
78
57
|
onToggleMute?: () => void;
|
|
@@ -143,5 +122,7 @@ export interface IntelligencePanelProps {
|
|
|
143
122
|
defaultTab?: IntelligenceTabId;
|
|
144
123
|
/** Larger hit targets, for the drawer host on a touch screen. */
|
|
145
124
|
touch?: boolean;
|
|
125
|
+
/** The Spam check section, under Sender. */
|
|
126
|
+
spamCheck?: ReactNode;
|
|
146
127
|
}
|
|
147
|
-
export declare function IntelligencePanel({ data, onClose, actions, className, hideCloseButton, reportSpamPending, notSpamPending, calendar, tab, onTabChange, defaultTab, touch, }: IntelligencePanelProps): import("react").JSX.Element;
|
|
128
|
+
export declare function IntelligencePanel({ data, onClose, actions, className, hideCloseButton, reportSpamPending, notSpamPending, calendar, tab, onTabChange, defaultTab, touch, spamCheck, }: IntelligencePanelProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useId, useState } from "react";
|
|
3
3
|
import { categoryLabels, categoryTone, } from "../category-presentation.js";
|
|
4
|
-
import { BellOff, MailCheck,
|
|
4
|
+
import { BellOff, MailCheck, ShieldX, Sparkles, Star, X } from "../icons.js";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
6
|
import { Avatar } from "./avatar.js";
|
|
7
7
|
import { Badge } from "./badge.js";
|
|
@@ -31,18 +31,6 @@ function SenderCard({ sender }) {
|
|
|
31
31
|
: `${sender.inboundCount} received · you've never replied`;
|
|
32
32
|
return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Avatar, { name: sender.name, email: sender.email, size: "md" }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-semibold text-fg", children: sender.name }), _jsx("div", { className: "truncate text-2xs text-fg-subtle", children: sender.email })] })] }), _jsx("div", { className: "mt-2 flex items-center gap-2", children: sender.addressUnverified ? (_jsx(Badge, { tone: "danger", dot: true, children: "Address couldn't be verified" })) : (_jsx(Badge, { tone: trust.tone, dot: true, children: trust.label })) }), _jsxs("p", { className: "mt-2 text-xs text-fg-muted", children: ["First seen ", sender.firstSeenLabel, engagement ? ` · ${engagement}` : ""] })] }));
|
|
33
33
|
}
|
|
34
|
-
function Authenticity({ auth }) {
|
|
35
|
-
if (auth.verdict === "aligned") {
|
|
36
|
-
return (_jsxs("div", { className: "flex items-start gap-2 text-xs text-fg-muted", children: [_jsx(ShieldCheck, { className: "mt-0.5 size-3.5 shrink-0 text-positive" }), _jsx("span", { children: auth.summary })] }));
|
|
37
|
-
}
|
|
38
|
-
if (auth.verdict === "caution") {
|
|
39
|
-
return (_jsxs("div", { className: "flex items-start gap-2 rounded-md bg-warning/10 p-3 text-warning", children: [_jsx(ShieldQuestionMark, { className: "mt-0.5 size-4 shrink-0" }), _jsx("p", { className: "text-xs leading-relaxed", children: auth.summary })] }));
|
|
40
|
-
}
|
|
41
|
-
const headline = auth.addressUnreadable
|
|
42
|
-
? "This sender can't be verified"
|
|
43
|
-
: "This message may be impersonating someone";
|
|
44
|
-
return (_jsx("div", { className: "rounded-md bg-danger-soft p-3", children: _jsxs("div", { className: "flex items-start gap-2", children: [_jsx(ShieldAlert, { className: "mt-0.5 size-4 shrink-0 text-danger" }), _jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "text-sm font-semibold text-danger", children: headline }), _jsx("p", { className: "mt-1 text-xs leading-relaxed text-fg", children: auth.summary }), !auth.addressUnreadable && auth.dkimDomain && (_jsxs("p", { className: "mt-1 text-2xs text-fg-muted", children: ["Sent from", " ", _jsx("code", { className: "rounded bg-surface px-1 py-0.5", children: auth.dkimDomain }), ", claims to be", " ", _jsx("code", { className: "rounded bg-surface px-1 py-0.5", children: auth.fromDomain })] }))] })] }) }));
|
|
45
|
-
}
|
|
46
34
|
function QuickAction({ icon, label, active, danger, onClick, pending, }) {
|
|
47
35
|
// No handler means the action cannot be serviced yet (the sender's address
|
|
48
36
|
// record has not resolved). Render it visibly unavailable rather than as a
|
|
@@ -53,8 +41,8 @@ function QuickAction({ icon, label, active, danger, onClick, pending, }) {
|
|
|
53
41
|
? "border-accent-2 bg-accent-2-soft text-accent-2"
|
|
54
42
|
: "border-line text-fg-muted hover:border-line-strong hover:text-fg", danger && !active && "text-danger hover:bg-danger-soft", disabled && "cursor-not-allowed opacity-50 hover:border-line"), children: [icon, label] }));
|
|
55
43
|
}
|
|
56
|
-
export function IntelligencePanel({ data, onClose, actions, className, hideCloseButton = false, reportSpamPending = false, notSpamPending = false, calendar, tab, onTabChange, defaultTab = "sender", touch, }) {
|
|
57
|
-
const { sender,
|
|
44
|
+
export function IntelligencePanel({ data, onClose, actions, className, hideCloseButton = false, reportSpamPending = false, notSpamPending = false, calendar, tab, onTabChange, defaultTab = "sender", touch, spamCheck, }) {
|
|
45
|
+
const { sender, category, flags = {}, placement, spamAction } = data;
|
|
58
46
|
const notSpamPendingLabel = spamAction === "undoSpamReport" ? "Undoing…" : "Moving…";
|
|
59
47
|
const [ownTab, setOwnTab] = useState(defaultTab);
|
|
60
48
|
const tabStripName = useId();
|
|
@@ -64,6 +52,6 @@ export function IntelligencePanel({ data, onClose, actions, className, hideClose
|
|
|
64
52
|
if (tab === undefined)
|
|
65
53
|
setOwnTab(next);
|
|
66
54
|
onTabChange?.(next);
|
|
67
|
-
} }) })), calendarTab && (_jsx(IntelligenceCalendar, { data: calendarTab.data, actions: calendarTab.actions, selectedEventId: calendarTab.selectedEventId, touch: touch })), calendarTab === undefined && (_jsxs(_Fragment, { children: [_jsx(IntelligenceSection, { label: "Sender", children: _jsx(SenderCard, { sender: sender }) }),
|
|
55
|
+
} }) })), calendarTab && (_jsx(IntelligenceCalendar, { data: calendarTab.data, actions: calendarTab.actions, selectedEventId: calendarTab.selectedEventId, touch: touch })), calendarTab === undefined && (_jsxs(_Fragment, { children: [_jsx(IntelligenceSection, { label: "Sender", children: _jsx(SenderCard, { sender: sender }) }), spamCheck, _jsx(IntelligenceSection, { label: "Category", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Badge, { tone: categoryTone[category.value], children: categoryLabels[category.value] }), category.overridden && (_jsx("span", { className: "text-2xs text-fg-subtle", children: "your override" })), _jsx("button", { type: "button", className: cn("ml-auto text-2xs text-accent hover:underline", !actions?.onReclassify &&
|
|
68
56
|
"cursor-not-allowed opacity-50 hover:no-underline"), disabled: !actions?.onReclassify, onClick: actions?.onReclassify, children: "reclassify" })] }) }), placement && (_jsx(IntelligenceSection, { label: "Placement", children: _jsx(Placement, { placement: placement }) })), _jsxs(IntelligenceSection, { label: "Quick actions", children: [_jsxs("div", { className: "flex flex-wrap gap-1.5", children: [_jsx(QuickAction, { icon: _jsx(Star, { className: "size-3.5" }), label: "VIP", active: flags.vip, onClick: actions?.onToggleVip }), _jsx(QuickAction, { icon: _jsx(BellOff, { className: "size-3.5" }), label: "Mute", active: flags.muted, onClick: actions?.onToggleMute }), actions?.onNotSpam && (_jsx(QuickAction, { icon: _jsx(MailCheck, { className: "size-3.5" }), label: notSpamPending ? notSpamPendingLabel : "Not spam", active: true, onClick: actions.onNotSpam, pending: notSpamPending })), actions?.onReportSpam && (_jsx(QuickAction, { icon: _jsx(ShieldX, { className: "size-3.5" }), label: reportSpamPending ? "Reporting…" : "Report spam", danger: true, onClick: actions.onReportSpam, pending: reportSpamPending }))] }), actions?.onNotSpam && spamAction === "undoSpamReport" && (_jsx("p", { className: "mt-1.5 text-2xs text-fg-subtle", children: "You reported this message as spam" }))] }), _jsx(IntelligenceSection, { label: "Coming soon", className: "border-b-0 opacity-70", children: _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Suggested actions" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "\"Create a filter for messages like this\" \u2014 on-device model" })] })] }), _jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Thread summary" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "One-paragraph digest \u2014 Bedrock" })] })] })] }) })] }))] }));
|
|
69
57
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
/** One labelled band of the intelligence panel, shared by both its tabs. */
|
|
3
|
-
export declare function IntelligenceSection({ label, children, className, }: {
|
|
3
|
+
export declare function IntelligenceSection({ label, headingId, children, className, }: {
|
|
4
4
|
label: string;
|
|
5
|
+
/** Names the heading so a control elsewhere can move focus to it. */
|
|
6
|
+
headingId?: string;
|
|
5
7
|
children: ReactNode;
|
|
6
8
|
className?: string;
|
|
7
9
|
}): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
/** One labelled band of the intelligence panel, shared by both its tabs. */
|
|
4
|
-
export function IntelligenceSection({ label, children, className, }) {
|
|
5
|
-
return (_jsxs("section", { className: cn("border-b border-line px-row-inset py-3", className), children: [_jsx("h3", { className: "text-2xs font-semibold uppercase tracking-wider text-fg-subtle", children: label }), _jsx("div", { className: "mt-2", children: children })] }));
|
|
4
|
+
export function IntelligenceSection({ label, headingId, children, className, }) {
|
|
5
|
+
return (_jsxs("section", { "aria-labelledby": headingId, className: cn("border-b border-line px-row-inset py-3", className), children: [_jsx("h3", { id: headingId, tabIndex: headingId ? -1 : undefined, className: "text-2xs font-semibold uppercase tracking-wider text-fg-subtle outline-none focus-visible:ring-2 focus-visible:ring-ring", children: label }), _jsx("div", { className: "mt-2", children: children })] }));
|
|
6
6
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { categoryTone, getCategoryLabel } from "../category-presentation.js";
|
|
3
|
-
import { Check, Paperclip, ShieldAlert, Star } from "../icons.js";
|
|
3
|
+
import { Check, Paperclip, ShieldAlert, Star, TriangleAlert, } from "../icons.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
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";
|
|
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
|
+
}
|
|
11
19
|
/** Visible keyboard-focus ring for a row reached by the list's arrow-key cursor. */
|
|
12
20
|
const ROW_FOCUS_RING = "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset";
|
|
13
21
|
/**
|
|
@@ -40,7 +48,7 @@ export const comfortableRowClass = ({ active, focused, }) => cn(
|
|
|
40
48
|
*/
|
|
41
49
|
export function CompactRowBody({ thread }) {
|
|
42
50
|
const unread = !thread.isRead;
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "flex w-4 shrink-0 items-center justify-center", children: thread.
|
|
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 })] }));
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
54
|
* Bold the literal (case-insensitive) occurrences of `query` in `text`. Used by
|
|
@@ -76,7 +84,9 @@ function highlightMatches(text, query) {
|
|
|
76
84
|
*/
|
|
77
85
|
export function ComfortableRowTextContent({ thread, badge, highlightQuery, }) {
|
|
78
86
|
const unread = !thread.isRead;
|
|
79
|
-
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.
|
|
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
|
|
88
|
+
?.filter((label) => label.labelId !== thread.spam?.label.labelId)
|
|
89
|
+
.map((label) => (_jsx(LabelChip, { label: label, className: "max-w-20" }, label.labelId))), thread.settlement && (_jsx(MessageSettlementBadge, { settlement: thread.settlement })), badge] })] }));
|
|
80
90
|
}
|
|
81
91
|
/**
|
|
82
92
|
* Leading slot of a comfortable row: the avatar, with a checkbox layered over
|
|
@@ -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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
export function writeOpen(prefix, id, open) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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: [
|
|
148
|
-
|
|
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 (${
|
|
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,7 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
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
|
-
|
|
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
|
}
|
|
@@ -34,6 +34,8 @@ export interface SelectionTopBarProps {
|
|
|
34
34
|
onJunk?: () => void;
|
|
35
35
|
/** Optional — dropped from the overflow menu while `isBusy`. */
|
|
36
36
|
onMarkRead?: () => void;
|
|
37
|
+
/** Runs the spam check again over the selection, ten messages at a time. */
|
|
38
|
+
onCheckAgain?: () => void;
|
|
37
39
|
/**
|
|
38
40
|
* The list header's own chrome, rendered only while nothing is ticked: the
|
|
39
41
|
* nav button, the unread count beside the title, and the search affordance.
|
|
@@ -119,4 +121,4 @@ export interface SelectionTopBarProps {
|
|
|
119
121
|
* row one is a count and the verbs. A back arrow leaves selection at every
|
|
120
122
|
* width, so a partial selection is always one press from being dropped.
|
|
121
123
|
*/
|
|
122
|
-
export declare function SelectionTopBar({ title, count, onCancel, onDelete, onMove, onOrganize, onJunk, onMarkRead, navSlot, titleMeta, searchSlot, searchField, idleSlot, overflowSlot, isBusy, isCounting, selectAll, statusLabel, progress, notice, }: SelectionTopBarProps): import("react").JSX.Element;
|
|
124
|
+
export declare function SelectionTopBar({ title, count, onCancel, onDelete, onMove, onOrganize, onJunk, onMarkRead, onCheckAgain, navSlot, titleMeta, searchSlot, searchField, idleSlot, overflowSlot, isBusy, isCounting, selectAll, statusLabel, progress, notice, }: SelectionTopBarProps): import("react").JSX.Element;
|