@remit/ui 0.0.232 → 0.0.234
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/account-service-toggles.js +2 -7
- package/dist/components/intelligence-calendar-fixtures.js +2 -0
- package/dist/components/intelligence-panel.d.ts +7 -5
- package/dist/components/intelligence-panel.js +4 -2
- package/dist/components/intelligence-placement.d.ts +13 -0
- package/dist/components/intelligence-placement.js +40 -0
- package/dist/components/switch.d.ts +11 -0
- package/dist/components/switch.js +16 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { cn } from "../lib/cn.js";
|
|
4
3
|
import { ACCOUNT_SERVICE_ROWS, } from "./account-service-choice.js";
|
|
5
|
-
|
|
6
|
-
return (_jsx("button", { type: "button", role: "switch", "aria-checked": checked, "aria-label": label, "aria-describedby": describedBy, disabled: disabled, onClick: onToggle, className: cn("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors", "outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface", checked
|
|
7
|
-
? "border-positive bg-positive"
|
|
8
|
-
: "border-line-strong bg-surface-sunken"), children: _jsx("span", { "aria-hidden": true, className: cn("size-4 rounded-full bg-canvas transition-transform", checked ? "translate-x-6" : "translate-x-1") }) }));
|
|
9
|
-
}
|
|
4
|
+
import { Switch } from "./switch.js";
|
|
10
5
|
/**
|
|
11
6
|
* What an account syncs, on the account settings screen (#1179). One switch per
|
|
12
7
|
* service the connector carries, mail first.
|
|
@@ -26,6 +21,6 @@ export function AccountServiceToggles({ providerName, offered, enabled, consente
|
|
|
26
21
|
const needsConsent = !on && !consented.includes(row.id);
|
|
27
22
|
return (_jsxs("div", { className: "flex min-h-11 items-center gap-3 py-2 text-left", children: [_jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "text-sm text-fg", children: row.label }), _jsx("span", { id: noteId, className: "text-xs text-fg-subtle", children: needsConsent
|
|
28
23
|
? `${row.description} Turning this on means signing in with ${providerName} again.`
|
|
29
|
-
: row.description })] }), _jsx(
|
|
24
|
+
: row.description })] }), _jsx(Switch, { checked: on, "aria-label": `Sync ${row.label.toLowerCase()}`, "aria-describedby": noteId, disabled: disabled, onToggle: () => onRequestChange(row.id, on ? "off" : "on") })] }, row.id));
|
|
30
25
|
}) })] }));
|
|
31
26
|
}
|
|
@@ -297,6 +297,7 @@ export const organiserSender = {
|
|
|
297
297
|
summary: "This message was signed by northwind.example.",
|
|
298
298
|
},
|
|
299
299
|
category: { value: "personal" },
|
|
300
|
+
spamAction: "reportSpam",
|
|
300
301
|
flags: { vip: true },
|
|
301
302
|
};
|
|
302
303
|
export const airlineSender = {
|
|
@@ -315,4 +316,5 @@ export const airlineSender = {
|
|
|
315
316
|
summary: "This message was signed by klm.example.",
|
|
316
317
|
},
|
|
317
318
|
category: { value: "transactional" },
|
|
319
|
+
spamAction: "reportSpam",
|
|
318
320
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ThreadCategory } from "../category-presentation.js";
|
|
2
2
|
import { type IntelligenceCalendarActions, type IntelligenceCalendarData } from "./intelligence-calendar.js";
|
|
3
|
+
import { type PlacementIntel } from "./intelligence-placement.js";
|
|
3
4
|
export type SenderTrustLevel = "unknown" | "wellknown" | "vip";
|
|
4
5
|
export interface SenderIntel {
|
|
5
6
|
name: string;
|
|
@@ -66,16 +67,17 @@ export interface IntelligenceData {
|
|
|
66
67
|
overridden?: boolean;
|
|
67
68
|
};
|
|
68
69
|
flags?: SenderFlagsIntel;
|
|
70
|
+
/** Where Remit placed this message and why. Absent when Remit recorded no verdict. */
|
|
71
|
+
placement?: PlacementIntel;
|
|
72
|
+
spamAction: SpamAction;
|
|
69
73
|
}
|
|
74
|
+
/** Which spam control the message offers: undo its spam report, move it out of Junk, or report it. */
|
|
75
|
+
export type SpamAction = "undoSpamReport" | "notSpam" | "reportSpam";
|
|
70
76
|
export interface IntelligenceQuickActions {
|
|
71
77
|
onToggleVip?: () => void;
|
|
72
78
|
onToggleMute?: () => void;
|
|
73
79
|
onReclassify?: () => void;
|
|
74
|
-
/**
|
|
75
|
-
* "Not spam": undo a spam report — clears the sender block and moves the
|
|
76
|
-
* message back where it came from (issue #648). Wired only when the
|
|
77
|
-
* message currently carries a spam report.
|
|
78
|
-
*/
|
|
80
|
+
/** "Not spam": wired only when `spamAction` is not "reportSpam". */
|
|
79
81
|
onNotSpam?: () => void;
|
|
80
82
|
/**
|
|
81
83
|
* "Report spam": move the message into Junk and block the sender (the
|
|
@@ -7,6 +7,7 @@ import { Avatar } from "./avatar.js";
|
|
|
7
7
|
import { Badge } from "./badge.js";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
9
|
import { IntelligenceCalendar, } from "./intelligence-calendar.js";
|
|
10
|
+
import { Placement } from "./intelligence-placement.js";
|
|
10
11
|
import { IntelligenceSection } from "./intelligence-section.js";
|
|
11
12
|
import { SegmentedControl } from "./segmented-control.js";
|
|
12
13
|
const tabOptions = [
|
|
@@ -53,7 +54,8 @@ function QuickAction({ icon, label, active, danger, onClick, pending, }) {
|
|
|
53
54
|
: "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] }));
|
|
54
55
|
}
|
|
55
56
|
export function IntelligencePanel({ data, onClose, actions, className, hideCloseButton = false, reportSpamPending = false, notSpamPending = false, calendar, tab, onTabChange, defaultTab = "sender", touch, }) {
|
|
56
|
-
const { sender, authenticity, category, flags = {} } = data;
|
|
57
|
+
const { sender, authenticity, category, flags = {}, placement, spamAction, } = data;
|
|
58
|
+
const notSpamPendingLabel = spamAction === "undoSpamReport" ? "Undoing…" : "Moving…";
|
|
57
59
|
const [ownTab, setOwnTab] = useState(defaultTab);
|
|
58
60
|
const tabStripName = useId();
|
|
59
61
|
const activeTab = tab ?? ownTab;
|
|
@@ -63,5 +65,5 @@ export function IntelligencePanel({ data, onClose, actions, className, hideClose
|
|
|
63
65
|
setOwnTab(next);
|
|
64
66
|
onTabChange?.(next);
|
|
65
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 }) }), _jsx(IntelligenceSection, { label: "Authenticity", children: _jsx(Authenticity, { auth: authenticity }) }), _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 &&
|
|
66
|
-
"cursor-not-allowed opacity-50 hover:no-underline"), disabled: !actions?.onReclassify, onClick: actions?.onReclassify, children: "reclassify" })] }) }), _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 ?
|
|
68
|
+
"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" })] })] })] }) })] }))] }));
|
|
67
69
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlacementAction, PlacementConfidence } from "@remit/domain-enums";
|
|
2
|
+
export interface PlacementIntel {
|
|
3
|
+
action: (typeof PlacementAction)[keyof typeof PlacementAction];
|
|
4
|
+
confidence: (typeof PlacementConfidence)[keyof typeof PlacementConfidence];
|
|
5
|
+
/** The folder the message sat in when Remit judged it: inbox, junk or other. */
|
|
6
|
+
fromPlacement: string;
|
|
7
|
+
/** Reason codes as the server wrote them. */
|
|
8
|
+
reasons: string[];
|
|
9
|
+
dryRun: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function Placement({ placement }: {
|
|
12
|
+
placement: PlacementIntel;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PlacementAction, PlacementConfidence } from "@remit/domain-enums";
|
|
3
|
+
import { Badge } from "./badge.js";
|
|
4
|
+
const reasonCopy = new Map(Object.entries({
|
|
5
|
+
"sender=blocked": "You blocked this sender.",
|
|
6
|
+
"sender=untrusted": "You have no history with this sender.",
|
|
7
|
+
"classifier=spam": "The classifier judged it spam.",
|
|
8
|
+
"dkim-mismatch": "It was signed by a different domain than its sender.",
|
|
9
|
+
"dmarc=fail": "It failed the sender domain's DMARC check.",
|
|
10
|
+
"dmarc=pass": "It passed the sender domain's DMARC check.",
|
|
11
|
+
"deferred-to-llm": "The signals were left for the classifier to judge.",
|
|
12
|
+
"no-confident-signal": "Nothing marked it as junk.",
|
|
13
|
+
"placed-in-junk": "It was already reported or moved to Junk.",
|
|
14
|
+
"already-moved-by-remit": "Remit had already moved it.",
|
|
15
|
+
"body-unreadable": "Its body could not be read.",
|
|
16
|
+
}));
|
|
17
|
+
function placementReasonCopy(code) {
|
|
18
|
+
return reasonCopy.get(code) ?? code;
|
|
19
|
+
}
|
|
20
|
+
function placementHeadline(placement) {
|
|
21
|
+
const fromJunk = placement.fromPlacement === "junk";
|
|
22
|
+
if (placement.action === PlacementAction.MoveToJunk && fromJunk) {
|
|
23
|
+
return "Remit kept this in Junk";
|
|
24
|
+
}
|
|
25
|
+
const verb = placement.dryRun ? "would move" : "moved";
|
|
26
|
+
if (placement.action === PlacementAction.MoveToInbox) {
|
|
27
|
+
return fromJunk
|
|
28
|
+
? `Remit ${verb} this out of Junk`
|
|
29
|
+
: `Remit ${verb} this to the Inbox`;
|
|
30
|
+
}
|
|
31
|
+
return `Remit ${verb} this to Junk`;
|
|
32
|
+
}
|
|
33
|
+
const confidenceLabel = {
|
|
34
|
+
[PlacementConfidence.Confident]: { label: "Confident", tone: "positive" },
|
|
35
|
+
[PlacementConfidence.Unsure]: { label: "Unsure", tone: "warning" },
|
|
36
|
+
};
|
|
37
|
+
export function Placement({ placement }) {
|
|
38
|
+
const confidence = confidenceLabel[placement.confidence];
|
|
39
|
+
return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-xs text-fg", children: placementHeadline(placement) }), _jsx(Badge, { tone: confidence.tone, dot: true, className: "ml-auto", children: confidence.label })] }), placement.reasons.length > 0 && (_jsx("ul", { className: "mt-2 list-disc space-y-0.5 pl-4 text-2xs text-fg-muted", children: placement.reasons.map((code) => (_jsx("li", { children: placementReasonCopy(code) }, code))) }))] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, Ref } from "react";
|
|
2
|
+
export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "role" | "onClick"> {
|
|
3
|
+
checked: boolean;
|
|
4
|
+
onToggle: () => void;
|
|
5
|
+
ref?: Ref<HTMLButtonElement>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An on/off switch with a 44px hit area. `aria-disabled` keeps it focusable so
|
|
9
|
+
* it can announce why it does not move, and swallows the press like `disabled`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Switch({ checked, onToggle, disabled, className, ref, ...props }: SwitchProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
/**
|
|
4
|
+
* An on/off switch with a 44px hit area. `aria-disabled` keeps it focusable so
|
|
5
|
+
* it can announce why it does not move, and swallows the press like `disabled`.
|
|
6
|
+
*/
|
|
7
|
+
export function Switch({ checked, onToggle, disabled, className, ref, ...props }) {
|
|
8
|
+
const ariaDisabled = props["aria-disabled"];
|
|
9
|
+
const inert = disabled === true || ariaDisabled === true || ariaDisabled === "true";
|
|
10
|
+
return (_jsx("button", { type: "button", role: "switch", ref: ref, "aria-checked": checked, disabled: disabled, onClick: () => {
|
|
11
|
+
if (!inert)
|
|
12
|
+
onToggle();
|
|
13
|
+
}, className: cn("group inline-flex h-11 w-14 shrink-0 items-center justify-center rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring", inert ? "cursor-not-allowed" : "cursor-pointer", className), ...props, children: _jsx("span", { "aria-hidden": true, className: cn("relative inline-flex h-6 w-11 items-center rounded-full border transition-colors", checked
|
|
14
|
+
? "border-positive bg-positive"
|
|
15
|
+
: "border-line-strong bg-surface-sunken", inert && "opacity-60"), children: _jsx("span", { className: cn("size-4 rounded-full bg-canvas transition-transform", checked ? "translate-x-6" : "translate-x-1") }) }) }));
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -98,7 +98,8 @@ export { FolderSyncBadge, type FolderSyncBadgeProps, type FolderSyncMailbox, typ
|
|
|
98
98
|
export { type FolderTreeNode, FolderTreePicker, type FolderTreePickerLabels, type FolderTreePickerProps, type FolderTreeRow, } from "./components/folder-tree-picker.js";
|
|
99
99
|
export { Input, type InputProps, type InputVariant, } from "./components/input.js";
|
|
100
100
|
export { type CalendarDayEntry, type CalendarInviteIntel, type CalendarProseIntel, type CalendarSuggestionIntel, IntelligenceCalendar, type IntelligenceCalendarActions, type IntelligenceCalendarData, type IntelligenceCalendarProps, } from "./components/intelligence-calendar.js";
|
|
101
|
-
export { type AuthenticityIntel, type IntelligenceCalendarSurface, type IntelligenceData, IntelligencePanel, type IntelligencePanelProps, type IntelligenceQuickActions, type IntelligenceTabId, type SenderFlagsIntel, type SenderIntel, type SenderTrustLevel, } from "./components/intelligence-panel.js";
|
|
101
|
+
export { type AuthenticityIntel, type IntelligenceCalendarSurface, type IntelligenceData, IntelligencePanel, type IntelligencePanelProps, type IntelligenceQuickActions, type IntelligenceTabId, type SenderFlagsIntel, type SenderIntel, type SenderTrustLevel, type SpamAction, } from "./components/intelligence-panel.js";
|
|
102
|
+
export type { PlacementIntel } from "./components/intelligence-placement.js";
|
|
102
103
|
export { IntelligenceSection } from "./components/intelligence-section.js";
|
|
103
104
|
export { IntelligenceToggle, type IntelligenceToggleProps, } from "./components/intelligence-toggle.js";
|
|
104
105
|
export { IsolatedEmailFrame, type IsolatedEmailFrameProps, measureContentAxis, } from "./components/isolated-email-frame.js";
|
|
@@ -173,6 +174,7 @@ export { SlidePanel, type SlidePanelProps, } from "./components/slide-panel.js";
|
|
|
173
174
|
export { SpamResultsOffer, type SpamResultsOfferProps, } from "./components/spam-results-offer.js";
|
|
174
175
|
export { type Suggestion, SuggestList, type SuggestListProps, } from "./components/suggest-list.js";
|
|
175
176
|
export { commitPeek, SwipeableRow, type SwipePeek, } from "./components/swipeable-row.js";
|
|
177
|
+
export { Switch, type SwitchProps } from "./components/switch.js";
|
|
176
178
|
export { syncWarningDemoEntries } from "./components/sync-warning-fixtures.js";
|
|
177
179
|
export { formatSyncWarningReport, type SyncWarningEntry, syncWarningIssueTitle, } from "./components/sync-warning-report.js";
|
|
178
180
|
export { SyncWarningRow, type SyncWarningRowProps, } from "./components/sync-warning-row.js";
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,7 @@ export { SlidePanel, } from "./components/slide-panel.js";
|
|
|
172
172
|
export { SpamResultsOffer, } from "./components/spam-results-offer.js";
|
|
173
173
|
export { SuggestList, } from "./components/suggest-list.js";
|
|
174
174
|
export { commitPeek, SwipeableRow, } from "./components/swipeable-row.js";
|
|
175
|
+
export { Switch } from "./components/switch.js";
|
|
175
176
|
export { syncWarningDemoEntries } from "./components/sync-warning-fixtures.js";
|
|
176
177
|
export { formatSyncWarningReport, syncWarningIssueTitle, } from "./components/sync-warning-report.js";
|
|
177
178
|
export { SyncWarningRow, } from "./components/sync-warning-row.js";
|