@remit/ui 0.0.233 → 0.0.235
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/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/swipeable-row.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/lib/merge-props.d.ts +8 -0
- package/dist/lib/merge-props.js +29 -0
- package/dist/lib/use-long-press.js +1 -1
- package/package.json +1 -3
|
@@ -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
|
+
}
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useDrag } from "@use-gesture/react";
|
|
3
3
|
import { Check, Mail, MailOpen, Trash2 } from "lucide-react";
|
|
4
4
|
import { useRef, useState } from "react";
|
|
5
|
-
import { mergeProps } from "react-aria";
|
|
6
5
|
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { mergeProps } from "../lib/merge-props.js";
|
|
7
7
|
import { SWIPE_AXIS_THRESHOLD, SWIPE_DRAG_CONFIG, } from "../lib/swipe-config.js";
|
|
8
8
|
import { holdConfig, isHold, LONG_PRESS_DELAY_MS, swallowReleaseClick, touchMenuSuppressionProps, } from "../lib/use-long-press.js";
|
|
9
9
|
import { Avatar } from "./avatar.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { mergeProps } from "react-aria";
|
|
2
1
|
export { type BriefCategoryFilter, CATEGORY_PRESENTATION, CATEGORY_SECTION_ORDER, type CategoryPresentation, categoryChips, categoryLabels, categoryTone, getCategoryLabel, isBriefCategory, isThreadCategory, type ThreadCategory, } from "./category-presentation.js";
|
|
3
2
|
export { AccountMenu, type AccountMenuProps, type AccountMenuSection, } from "./components/account-menu.js";
|
|
4
3
|
export { type AccountServiceChange, type AccountServiceChangeCopy, AccountServiceChangeDialog, type AccountServiceChangeDialogProps, accountServiceChangeCopy, } from "./components/account-service-change-dialog.js";
|
|
@@ -98,7 +97,8 @@ export { FolderSyncBadge, type FolderSyncBadgeProps, type FolderSyncMailbox, typ
|
|
|
98
97
|
export { type FolderTreeNode, FolderTreePicker, type FolderTreePickerLabels, type FolderTreePickerProps, type FolderTreeRow, } from "./components/folder-tree-picker.js";
|
|
99
98
|
export { Input, type InputProps, type InputVariant, } from "./components/input.js";
|
|
100
99
|
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";
|
|
100
|
+
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";
|
|
101
|
+
export type { PlacementIntel } from "./components/intelligence-placement.js";
|
|
102
102
|
export { IntelligenceSection } from "./components/intelligence-section.js";
|
|
103
103
|
export { IntelligenceToggle, type IntelligenceToggleProps, } from "./components/intelligence-toggle.js";
|
|
104
104
|
export { IsolatedEmailFrame, type IsolatedEmailFrameProps, measureContentAxis, } from "./components/isolated-email-frame.js";
|
|
@@ -207,6 +207,7 @@ export { defaultKeyboardHints, KEY_HINT_GROUPS, type KeyboardHint, type KeyHint,
|
|
|
207
207
|
export { type DispatchResult, dispatchKey, isControlTarget, isEditableTarget, type KeyStroke, ROW_ATTRIBUTE, type SequencePrefix, } from "./lib/keymap-dispatch.js";
|
|
208
208
|
export { isLabelColorValue, type LabelColorValue, labelColorOptions, labelDotClass, } from "./lib/label-color.js";
|
|
209
209
|
export { DESKTOP_MEDIA_QUERY, DESKTOP_MIN_WIDTH, } from "./lib/layout-breakpoints.js";
|
|
210
|
+
export { mergeProps } from "./lib/merge-props.js";
|
|
210
211
|
export { miniMonthWeeks, shiftMonth } from "./lib/mini-month.js";
|
|
211
212
|
export { type OverlayAnswers, type OverlayScopeOptions, overlayStack, resolveAgainstOverlays, useOverlayScope, } from "./lib/overlay-scope.js";
|
|
212
213
|
export { placePopup } from "./lib/popup-placement.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { mergeProps } from "react-aria";
|
|
2
1
|
export { CATEGORY_PRESENTATION, CATEGORY_SECTION_ORDER, categoryChips, categoryLabels, categoryTone, getCategoryLabel, isBriefCategory, isThreadCategory, } from "./category-presentation.js";
|
|
3
2
|
export { AccountMenu, } from "./components/account-menu.js";
|
|
4
3
|
export { AccountServiceChangeDialog, accountServiceChangeCopy, } from "./components/account-service-change-dialog.js";
|
|
@@ -206,6 +205,7 @@ export { defaultKeyboardHints, KEY_HINT_GROUPS, keyboardHintsFor, keysForAction,
|
|
|
206
205
|
export { dispatchKey, isControlTarget, isEditableTarget, ROW_ATTRIBUTE, } from "./lib/keymap-dispatch.js";
|
|
207
206
|
export { isLabelColorValue, labelColorOptions, labelDotClass, } from "./lib/label-color.js";
|
|
208
207
|
export { DESKTOP_MEDIA_QUERY, DESKTOP_MIN_WIDTH, } from "./lib/layout-breakpoints.js";
|
|
208
|
+
export { mergeProps } from "./lib/merge-props.js";
|
|
209
209
|
export { miniMonthWeeks, shiftMonth } from "./lib/mini-month.js";
|
|
210
210
|
export { overlayStack, resolveAgainstOverlays, useOverlayScope, } from "./lib/overlay-scope.js";
|
|
211
211
|
export { placePopup } from "./lib/popup-placement.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Props = object;
|
|
2
|
+
type TupleTypes<T extends readonly unknown[]> = T[number];
|
|
3
|
+
type UnionToIntersection<U> = (U extends unknown ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
|
|
4
|
+
type MergedProps<T extends readonly (Props | null | undefined)[]> = UnionToIntersection<TupleTypes<{
|
|
5
|
+
[K in keyof T]: NonNullable<T[K]>;
|
|
6
|
+
}>>;
|
|
7
|
+
export declare function mergeProps<T extends readonly (Props | null | undefined)[]>(...sources: T): MergedProps<T>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function isEventHandlerKey(key) {
|
|
2
|
+
return /^on[A-Z]/.test(key);
|
|
3
|
+
}
|
|
4
|
+
function isHandler(value) {
|
|
5
|
+
return typeof value === "function";
|
|
6
|
+
}
|
|
7
|
+
function chainHandlers(first, second) {
|
|
8
|
+
return (...args) => {
|
|
9
|
+
first(...args);
|
|
10
|
+
second(...args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function mergeProps(...sources) {
|
|
14
|
+
const merged = {};
|
|
15
|
+
for (const source of sources) {
|
|
16
|
+
if (!source)
|
|
17
|
+
continue;
|
|
18
|
+
for (const [key, value] of Object.entries(source)) {
|
|
19
|
+
const previous = merged[key];
|
|
20
|
+
if (isEventHandlerKey(key) && isHandler(previous) && isHandler(value)) {
|
|
21
|
+
merged[key] = chainHandlers(previous, value);
|
|
22
|
+
}
|
|
23
|
+
else if (value !== undefined || !(key in merged)) {
|
|
24
|
+
merged[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return merged;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.235",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"@lexical/selection": "0.49.0",
|
|
51
51
|
"@lexical/table": "0.49.0",
|
|
52
52
|
"@lexical/utils": "0.49.0",
|
|
53
|
-
"@react-types/shared": "3.36.0",
|
|
54
53
|
"@use-gesture/react": "10.3.1",
|
|
55
54
|
"@use-gesture/vanilla": "10.3.1",
|
|
56
55
|
"clsx": "2.1.1",
|
|
@@ -58,7 +57,6 @@
|
|
|
58
57
|
"franc-min": "6.2.0",
|
|
59
58
|
"lexical": "0.49.0",
|
|
60
59
|
"lucide-react": "0.468.0",
|
|
61
|
-
"react-aria": "3.50.0",
|
|
62
60
|
"react-resizable-panels": "2.1.9",
|
|
63
61
|
"react-simple-pull-to-refresh": "1.3.4",
|
|
64
62
|
"tailwind-merge": "2.6.1",
|