@open-workspace/email 0.3.0 → 0.4.1
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/README.md +22 -22
- package/alchemy/index.ts +273 -0
- package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
- package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
- package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
- package/drizzle/mailbox/meta/_journal.json +20 -0
- package/drizzle/mailbox/migrations.js +12 -0
- package/index.ts +3 -1
- package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
- package/migrations/meta/0000_snapshot.json +125 -109
- package/migrations/meta/_journal.json +2 -2
- package/package.json +74 -68
- package/shared/attachment-preview.ts +37 -27
- package/shared/folder-order.ts +106 -0
- package/shared/mail-authentication.ts +8 -3
- package/shared/mail-feedback.ts +18 -25
- package/shared/mail-headers.ts +114 -39
- package/shared/mail-import.ts +38 -0
- package/shared/mail-path.ts +42 -0
- package/shared/mail-received.ts +174 -31
- package/shared/mail-remote.ts +59 -2
- package/shared/mail-sender-intel.ts +22 -4
- package/shared/mail.ts +77 -28
- package/shared/module.ts +33 -0
- package/shared/office-preview.ts +14 -2
- package/shared/pdfjs-assets.ts +35 -0
- package/shared/permissions.ts +73 -0
- package/shared/webhooks.ts +41 -0
- package/src/admin/blocked-senders.tsx +189 -0
- package/src/client.tsx +97 -0
- package/src/lib/mail-api.ts +9 -0
- package/src/mail/attachment-preview-dialog.tsx +161 -0
- package/src/mail/blocked-senders.tsx +138 -0
- package/src/mail/compose-window-chrome.tsx +194 -0
- package/src/mail/compose-window.tsx +486 -0
- package/src/mail/composer-asset-bookmarks.ts +409 -0
- package/src/mail/composer-asset.tsx +229 -0
- package/src/mail/composer-attachment-list.tsx +138 -0
- package/src/mail/composer-editor-document.ts +65 -0
- package/src/mail/composer-editor.tsx +284 -0
- package/src/mail/composer-linked-attachment-text.ts +12 -0
- package/src/mail/composer-recipient-fields.tsx +165 -0
- package/src/mail/composer-recipients.ts +208 -0
- package/src/mail/composer-session.ts +562 -0
- package/src/mail/composer-toolbar.tsx +303 -0
- package/src/mail/composer-upload-client.ts +105 -0
- package/src/mail/composer-upload-progress.ts +53 -0
- package/src/mail/conversation-list.tsx +550 -0
- package/src/mail/conversation-loading-skeleton.tsx +119 -0
- package/src/mail/conversation-message.tsx +346 -0
- package/src/mail/conversation-reply.tsx +470 -0
- package/src/mail/conversation-selection-toolbar.tsx +322 -0
- package/src/mail/conversation-view.tsx +437 -0
- package/src/mail/delivery-indicator.tsx +272 -0
- package/src/mail/email-html-body.tsx +203 -0
- package/src/mail/folder-glyph.tsx +46 -0
- package/src/mail/folder-manager.tsx +532 -0
- package/src/mail/format-bytes.ts +7 -0
- package/src/mail/mail-app-bar.tsx +253 -0
- package/src/mail/mail-background.tsx +12 -0
- package/src/mail/mail-dock.tsx +137 -0
- package/src/mail/mail-folders.ts +44 -0
- package/src/mail/mail-layout.css +236 -0
- package/src/mail/mail-location.ts +73 -0
- package/src/mail/mail-mailbox-sheet.tsx +275 -0
- package/src/mail/mail-nav-rail.tsx +129 -0
- package/src/mail/mail-nav.tsx +324 -0
- package/src/mail/mail-prefetch.ts +59 -0
- package/src/mail/mail-primitives.tsx +66 -0
- package/src/mail/mail-queries.ts +209 -0
- package/src/mail/mail-query-cache.ts +486 -0
- package/src/mail/mail-seed.ts +47 -0
- package/src/mail/mail-shell.tsx +126 -0
- package/src/mail/mailbox-ai-settings.tsx +185 -0
- package/src/mail/mailbox-realtime.tsx +251 -0
- package/src/mail/mailbox-route.tsx +15 -0
- package/src/mail/message-actions.tsx +353 -0
- package/src/mail/message-attachments.tsx +200 -0
- package/src/mail/message-format.ts +75 -0
- package/src/mail/message-header.tsx +260 -0
- package/src/mail/message-translation.tsx +225 -0
- package/src/mail/original-message-sheet.tsx +619 -0
- package/src/mail/original-message.ts +191 -0
- package/src/mail/outbound-notification.ts +53 -0
- package/src/mail/pane-splitter.tsx +117 -0
- package/src/mail/pdf-preview-toolbar.tsx +152 -0
- package/src/mail/pdf-preview.css +44 -0
- package/src/mail/pdf-preview.tsx +156 -0
- package/src/mail/pdf-translation-layout.ts +95 -0
- package/src/mail/print-message.ts +92 -0
- package/src/mail/reader-pane.tsx +535 -0
- package/src/mail/recipient-combobox.tsx +335 -0
- package/src/mail/recipient-field-row.tsx +34 -0
- package/src/mail/reply-to-warning.tsx +50 -0
- package/src/mail/sanitize-email-html.ts +430 -0
- package/src/mail/sender-actions.tsx +149 -0
- package/src/mail/sender-authentication.tsx +485 -0
- package/src/mail/sender-dialogs.tsx +384 -0
- package/src/mail/sender-security.tsx +545 -0
- package/src/mail/toolbar-tooltip.tsx +29 -0
- package/src/mail/translation-html.ts +49 -0
- package/src/mail/translation-language.ts +21 -0
- package/src/mail/types.ts +53 -0
- package/src/mail/unread-document-indicator.tsx +60 -0
- package/src/mail/use-compose-submission.ts +208 -0
- package/src/mail/use-composer-attachment-preflight.ts +184 -0
- package/src/mail/use-composer-submission.ts +117 -0
- package/src/mail/use-conversation-selection.ts +186 -0
- package/src/mail/use-mail-controller.ts +427 -0
- package/src/mail/use-mail-data.ts +279 -0
- package/src/mail/use-mail-safety.ts +155 -0
- package/src/mail/use-mail-send.ts +142 -0
- package/src/mail/use-pdf-translation-overlay.ts +156 -0
- package/src/mail/use-pdf-translation.ts +100 -0
- package/src/mail/use-pdf-viewer.ts +215 -0
- package/src/mail/use-reply-submission.ts +114 -0
- package/src/mail/use-sanitized-email-html.ts +20 -0
- package/src/mail/use-visible-message-read.ts +138 -0
- package/src/pwa/push-subscription.ts +151 -0
- package/src/settings/mail-apps-page.tsx +235 -0
- package/src/settings/notifications-page.tsx +291 -0
- package/worker/admin/blocked-sender-routes.ts +166 -0
- package/worker/admin/schemas.ts +11 -0
- package/worker/bindings.d.ts +14 -10
- package/worker/db/schema.ts +63 -40
- package/worker/jmap/eventsource.ts +84 -16
- package/worker/jmap/methods.ts +1630 -524
- package/worker/jmap/push-types.ts +27 -0
- package/worker/jmap/push.ts +140 -56
- package/worker/jmap/routes.ts +366 -105
- package/worker/mail/access.ts +258 -21
- package/worker/mail/ai-classification.ts +36 -20
- package/worker/mail/ai-translation.ts +13 -6
- package/worker/mail/auth-headers.ts +395 -137
- package/worker/mail/bimi.ts +200 -73
- package/worker/mail/bootstrap.ts +79 -0
- package/worker/mail/capped-body.ts +36 -0
- package/worker/mail/classification-signals.ts +35 -25
- package/worker/mail/conversation-cursor.ts +30 -19
- package/worker/mail/delivery-events.ts +88 -62
- package/worker/mail/delivery-facts.ts +46 -10
- package/worker/mail/demo-routes.ts +34 -10
- package/worker/mail/doh.ts +62 -23
- package/worker/mail/downloads.ts +75 -40
- package/worker/mail/edge-cache.ts +155 -0
- package/worker/mail/header-metadata.ts +88 -22
- package/worker/mail/impersonation.ts +160 -38
- package/worker/mail/import-routes.ts +313 -0
- package/worker/mail/inbound-delivery.ts +19 -9
- package/worker/mail/inbound-threading.ts +18 -8
- package/worker/mail/inbound.ts +82 -40
- package/worker/mail/ip-intel.ts +110 -27
- package/worker/mail/isolate-cache.ts +35 -0
- package/worker/mail/link-domains.ts +29 -7
- package/worker/mail/mailbox-deletion.ts +10 -4
- package/worker/mail/mailbox-directory.ts +16 -6
- package/worker/mail/mailing-list.ts +94 -39
- package/worker/mail/message-security.ts +90 -15
- package/worker/mail/message-view.ts +18 -6
- package/worker/mail/office-conversion.ts +31 -9
- package/worker/mail/office-preview-container.ts +40 -13
- package/worker/mail/office-preview-queue.ts +76 -32
- package/worker/mail/org-domain.ts +8 -1
- package/worker/mail/outbound-content.ts +71 -26
- package/worker/mail/outbound-delivery.ts +31 -17
- package/worker/mail/outbound-service.ts +48 -30
- package/worker/mail/outbound-threading.ts +30 -17
- package/worker/mail/outbound.ts +97 -70
- package/worker/mail/outgoing-context.ts +25 -15
- package/worker/mail/participants.ts +44 -29
- package/worker/mail/push-notifications.ts +271 -173
- package/worker/mail/quote-parser.ts +21 -10
- package/worker/mail/r2-presigned-urls.ts +31 -25
- package/worker/mail/receive.ts +23 -11
- package/worker/mail/recipients.ts +6 -1
- package/worker/mail/remote-proxy.ts +187 -31
- package/worker/mail/remote-routes.ts +87 -0
- package/worker/mail/remote-token.ts +104 -0
- package/worker/mail/repeat.ts +19 -0
- package/worker/mail/reply-plan.ts +62 -33
- package/worker/mail/rfc.ts +32 -7
- package/worker/mail/routes.ts +870 -541
- package/worker/mail/safety-routes.ts +328 -200
- package/worker/mail/schemas.ts +84 -105
- package/worker/mail/search.ts +1 -0
- package/worker/mail/security-settings.ts +41 -9
- package/worker/mail/sender-intel.ts +206 -51
- package/worker/mail/spamhaus.ts +92 -45
- package/worker/mail/unsubscribe.ts +76 -18
- package/worker/mail/uploads.ts +126 -93
- package/worker/mail/webhook-source.ts +35 -12
- package/worker/mail/workspace-safety.ts +97 -38
- package/worker/mailbox/demo-html.ts +7 -7
- package/worker/mailbox/demo-seed.ts +10 -44
- package/worker/mailbox/demo.ts +595 -225
- package/worker/mailbox/email-index.ts +53 -0
- package/worker/mailbox/folder-model.ts +53 -17
- package/worker/mailbox/import-placement.ts +88 -0
- package/worker/mailbox/inbox-counts.ts +106 -0
- package/worker/mailbox/index.ts +1734 -721
- package/worker/mailbox/jmap-store.ts +139 -35
- package/worker/mailbox/model.ts +8 -6
- package/worker/mailbox/office-preview-jobs.ts +56 -25
- package/worker/mailbox/schema.ts +87 -66
- package/worker/mailbox/senders.ts +176 -70
- package/worker/mcp/mail-action-tools.ts +128 -87
- package/worker/mcp/mail-compose-tools.ts +133 -82
- package/worker/mcp/mail-query-tools.ts +120 -71
- package/worker/mcp/mail-safety-tools.ts +321 -248
- package/worker/mcp/schemas.ts +43 -0
- package/worker/mcp/tools.ts +13 -10
- package/worker/module.ts +43 -18
- package/worker/sql.d.ts +8 -0
- package/alchemy.ts +0 -142
- package/containers/office-preview/Dockerfile +0 -10
- package/shared/mail-rules.ts +0 -156
- package/worker/admin/report-routes.ts +0 -164
- package/worker/mail/reported-messages.ts +0 -68
- package/worker/mailbox/migrations.ts +0 -10
- package/worker/mailbox/rules.ts +0 -110
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Combobox,
|
|
3
|
+
ComboboxChip,
|
|
4
|
+
ComboboxChips,
|
|
5
|
+
ComboboxChipsInput,
|
|
6
|
+
ComboboxContent,
|
|
7
|
+
ComboboxItem,
|
|
8
|
+
ComboboxList,
|
|
9
|
+
useDebouncedValue,
|
|
10
|
+
cn,
|
|
11
|
+
} from "@open-workspace/core/ui";
|
|
12
|
+
import { Check, LoaderCircle } from "lucide-react";
|
|
13
|
+
import { useMemo, useRef, useState } from "react";
|
|
14
|
+
import type {
|
|
15
|
+
ClipboardEvent,
|
|
16
|
+
FocusEvent,
|
|
17
|
+
KeyboardEvent,
|
|
18
|
+
ReactNode,
|
|
19
|
+
} from "react";
|
|
20
|
+
|
|
21
|
+
import { normalizeExternalEmailAddress } from "../../shared/mail";
|
|
22
|
+
import {
|
|
23
|
+
normalizeComposerRecipient,
|
|
24
|
+
parseComposerRecipients,
|
|
25
|
+
RECIPIENT_SEPARATOR,
|
|
26
|
+
} from "./composer-recipients";
|
|
27
|
+
import type {
|
|
28
|
+
ComposerRecipient,
|
|
29
|
+
RecipientFieldValue,
|
|
30
|
+
} from "./composer-recipients";
|
|
31
|
+
import { Monogram } from "./mail-primitives";
|
|
32
|
+
import { useRecipientSuggestions } from "./use-mail-data";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A recipients field: chosen addresses as chips, typed text committed on
|
|
36
|
+
* Enter, comma, semicolon, Tab or leaving the field, pasted lists split into
|
|
37
|
+
* chips, and contact suggestions in a list that Escape closes.
|
|
38
|
+
*/
|
|
39
|
+
export function RecipientCombobox({
|
|
40
|
+
mailboxId,
|
|
41
|
+
label,
|
|
42
|
+
value,
|
|
43
|
+
excludedAddresses,
|
|
44
|
+
autoFocus = false,
|
|
45
|
+
disabled = false,
|
|
46
|
+
actions,
|
|
47
|
+
onChange,
|
|
48
|
+
}: {
|
|
49
|
+
mailboxId: string;
|
|
50
|
+
label: string;
|
|
51
|
+
value: RecipientFieldValue;
|
|
52
|
+
excludedAddresses: ReadonlySet<string>;
|
|
53
|
+
autoFocus?: boolean;
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
actions?: ReactNode;
|
|
56
|
+
onChange: (value: RecipientFieldValue) => void;
|
|
57
|
+
}) {
|
|
58
|
+
const [focused, setFocused] = useState(false);
|
|
59
|
+
const [invalid, setInvalid] = useState(false);
|
|
60
|
+
// Escape, or a click outside, hides the list until the text changes.
|
|
61
|
+
const [dismissed, setDismissed] = useState(false);
|
|
62
|
+
// The option the arrow keys or pointer are on. Without one, Enter takes the
|
|
63
|
+
// first suggestion, which looks highlighted for that reason.
|
|
64
|
+
const [highlighted, setHighlighted] = useState<ComposerRecipient>();
|
|
65
|
+
const chipsRef = useRef<HTMLDivElement>(null);
|
|
66
|
+
const query = useDebouncedValue(value.input.trim(), 120);
|
|
67
|
+
|
|
68
|
+
const suggestionsQuery = useRecipientSuggestions(
|
|
69
|
+
mailboxId,
|
|
70
|
+
query,
|
|
71
|
+
focused && !disabled && Boolean(value.input.trim())
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const selected = useMemo(
|
|
75
|
+
() =>
|
|
76
|
+
new Set(
|
|
77
|
+
value.recipients.map((recipient) =>
|
|
78
|
+
normalizeExternalEmailAddress(recipient.address)
|
|
79
|
+
)
|
|
80
|
+
),
|
|
81
|
+
[value.recipients]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const suggestions = (suggestionsQuery.data?.suggestions ?? []).flatMap(
|
|
85
|
+
(suggestion) => {
|
|
86
|
+
const normalized = normalizeComposerRecipient(suggestion);
|
|
87
|
+
|
|
88
|
+
if (
|
|
89
|
+
!normalized ||
|
|
90
|
+
selected.has(normalized.address) ||
|
|
91
|
+
excludedAddresses.has(normalized.address)
|
|
92
|
+
) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return [normalized];
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const open =
|
|
101
|
+
!disabled &&
|
|
102
|
+
focused &&
|
|
103
|
+
!dismissed &&
|
|
104
|
+
Boolean(value.input.trim()) &&
|
|
105
|
+
suggestions.length > 0;
|
|
106
|
+
|
|
107
|
+
function addRecipients(recipients: ComposerRecipient[]) {
|
|
108
|
+
if (!recipients.length) return;
|
|
109
|
+
const seen = new Set([...selected, ...excludedAddresses]);
|
|
110
|
+
|
|
111
|
+
const next = recipients.flatMap((recipient) => {
|
|
112
|
+
const normalized = normalizeComposerRecipient(recipient);
|
|
113
|
+
|
|
114
|
+
if (!normalized || seen.has(normalized.address)) return [];
|
|
115
|
+
seen.add(normalized.address);
|
|
116
|
+
|
|
117
|
+
return [normalized];
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (!next.length) {
|
|
121
|
+
onChange({ ...value, input: "" });
|
|
122
|
+
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setInvalid(false);
|
|
127
|
+
onChange({
|
|
128
|
+
recipients: [...value.recipients, ...next],
|
|
129
|
+
input: "",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function commitInput() {
|
|
134
|
+
const parsed = parseComposerRecipients(value.input);
|
|
135
|
+
const hasInvalid = parsed.invalidParts.length > 0;
|
|
136
|
+
setInvalid(hasInvalid);
|
|
137
|
+
|
|
138
|
+
if (hasInvalid || !parsed.recipients.length) return false;
|
|
139
|
+
addRecipients(parsed.recipients);
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Runs before the combobox's own keys: an Enter on a highlighted suggestion
|
|
145
|
+
// and Backspace on an empty field (removing the last chip) are left to it.
|
|
146
|
+
function handleKeyDown(
|
|
147
|
+
event: KeyboardEvent<HTMLInputElement> & {
|
|
148
|
+
preventBaseUIHandler: () => void;
|
|
149
|
+
}
|
|
150
|
+
) {
|
|
151
|
+
if (event.key === "Escape") {
|
|
152
|
+
// With the list closed the combobox would clear every chip; leave the
|
|
153
|
+
// key to the page instead (the phone composer closes on it).
|
|
154
|
+
if (!open) event.preventBaseUIHandler();
|
|
155
|
+
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (event.key === "Enter" && open) {
|
|
160
|
+
if (highlighted) return;
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
event.preventBaseUIHandler();
|
|
163
|
+
const [first] = suggestions;
|
|
164
|
+
|
|
165
|
+
if (first) addRecipients([first]);
|
|
166
|
+
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (
|
|
171
|
+
event.key === "Enter" ||
|
|
172
|
+
event.key === "Tab" ||
|
|
173
|
+
event.key === "," ||
|
|
174
|
+
event.key === ";"
|
|
175
|
+
) {
|
|
176
|
+
if (!value.input.trim()) return;
|
|
177
|
+
|
|
178
|
+
if (event.key === "Tab") {
|
|
179
|
+
// An address that does not parse keeps focus here, marked invalid.
|
|
180
|
+
if (!commitInput()) event.preventDefault();
|
|
181
|
+
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
event.preventBaseUIHandler();
|
|
187
|
+
commitInput();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function handlePaste(event: ClipboardEvent<HTMLInputElement>) {
|
|
192
|
+
const text = event.clipboardData.getData("text");
|
|
193
|
+
|
|
194
|
+
if (!RECIPIENT_SEPARATOR.test(text)) return;
|
|
195
|
+
const parsed = parseComposerRecipients(text);
|
|
196
|
+
|
|
197
|
+
if (parsed.invalidParts.length || !parsed.recipients.length) {
|
|
198
|
+
setInvalid(parsed.invalidParts.length > 0);
|
|
199
|
+
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
addRecipients(parsed.recipients);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function handleBlur(event: FocusEvent<HTMLDivElement>) {
|
|
208
|
+
const next = event.relatedTarget;
|
|
209
|
+
|
|
210
|
+
if (event.currentTarget.contains(next)) return;
|
|
211
|
+
|
|
212
|
+
// The suggestion list is portalled; moving into it is not leaving the field.
|
|
213
|
+
if (
|
|
214
|
+
next instanceof Element &&
|
|
215
|
+
next.closest("[data-slot=combobox-content]")
|
|
216
|
+
) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setFocused(false);
|
|
221
|
+
|
|
222
|
+
if (value.input.trim()) commitInput();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<Combobox<ComposerRecipient, true>
|
|
227
|
+
multiple
|
|
228
|
+
items={suggestions}
|
|
229
|
+
filter={null}
|
|
230
|
+
value={value.recipients}
|
|
231
|
+
inputValue={value.input}
|
|
232
|
+
open={open}
|
|
233
|
+
disabled={disabled}
|
|
234
|
+
autoHighlight
|
|
235
|
+
openOnInputClick={false}
|
|
236
|
+
isItemEqualToValue={(item, other) => item.address === other.address}
|
|
237
|
+
itemToStringLabel={(recipient) => recipient.name || recipient.address}
|
|
238
|
+
onItemHighlighted={(recipient) => setHighlighted(recipient)}
|
|
239
|
+
onOpenChange={(next) => setDismissed(!next)}
|
|
240
|
+
onInputValueChange={(next, details) => {
|
|
241
|
+
// The combobox clears its text when the list closes; typed addresses stay until committed.
|
|
242
|
+
if (details.reason !== "input-change") return;
|
|
243
|
+
setInvalid(false);
|
|
244
|
+
setDismissed(false);
|
|
245
|
+
onChange({ ...value, input: next });
|
|
246
|
+
}}
|
|
247
|
+
onValueChange={(next, details) => {
|
|
248
|
+
if (details.reason === "escape-key") return;
|
|
249
|
+
|
|
250
|
+
if (next.length > value.recipients.length) {
|
|
251
|
+
addRecipients(
|
|
252
|
+
next.filter((recipient) => !selected.has(recipient.address))
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
onChange({ ...value, recipients: next });
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
262
|
+
className="relative flex min-h-11 items-start gap-2 py-2"
|
|
263
|
+
onFocus={() => setFocused(true)}
|
|
264
|
+
onBlur={handleBlur}
|
|
265
|
+
>
|
|
266
|
+
<span className="text-muted-foreground flex h-7 w-14 shrink-0 items-center text-xs font-medium">
|
|
267
|
+
{label}
|
|
268
|
+
</span>
|
|
269
|
+
<ComboboxChips ref={chipsRef} className="flex-1">
|
|
270
|
+
{value.recipients.map((recipient) => (
|
|
271
|
+
<ComboboxChip
|
|
272
|
+
key={recipient.address}
|
|
273
|
+
title={recipient.address}
|
|
274
|
+
removeLabel={`Remove ${recipient.address}`}
|
|
275
|
+
disabled={disabled}
|
|
276
|
+
>
|
|
277
|
+
<span className="max-w-44 truncate">
|
|
278
|
+
{recipient.name || recipient.address}
|
|
279
|
+
</span>
|
|
280
|
+
</ComboboxChip>
|
|
281
|
+
))}
|
|
282
|
+
<ComboboxChipsInput
|
|
283
|
+
className={cn(
|
|
284
|
+
invalid && "text-destructive placeholder:text-destructive/70"
|
|
285
|
+
)}
|
|
286
|
+
aria-label={`${label} recipients`}
|
|
287
|
+
aria-invalid={invalid}
|
|
288
|
+
autoFocus={autoFocus}
|
|
289
|
+
placeholder={value.recipients.length ? "" : "name@example.com"}
|
|
290
|
+
onKeyDown={handleKeyDown}
|
|
291
|
+
onPaste={handlePaste}
|
|
292
|
+
/>
|
|
293
|
+
</ComboboxChips>
|
|
294
|
+
{focused && suggestionsQuery.isFetching ? (
|
|
295
|
+
<LoaderCircle className="text-muted-foreground mt-1.5 size-3.5 shrink-0 animate-spin" />
|
|
296
|
+
) : null}
|
|
297
|
+
{actions}
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
<ComboboxContent
|
|
301
|
+
anchor={chipsRef}
|
|
302
|
+
sideOffset={2}
|
|
303
|
+
aria-label={`${label} suggestions`}
|
|
304
|
+
className="rounded-xl p-1.5 shadow-xl"
|
|
305
|
+
>
|
|
306
|
+
<ComboboxList>
|
|
307
|
+
{(suggestion: ComposerRecipient, index: number) => (
|
|
308
|
+
<ComboboxItem
|
|
309
|
+
key={suggestion.address}
|
|
310
|
+
value={suggestion}
|
|
311
|
+
data-default={(index === 0 && !highlighted) || undefined}
|
|
312
|
+
className="group/suggestion data-default:bg-accent data-default:text-accent-foreground gap-2 rounded-lg px-2.5 py-2"
|
|
313
|
+
>
|
|
314
|
+
<Monogram
|
|
315
|
+
name={suggestion.name || suggestion.address}
|
|
316
|
+
className="size-7 rounded-full text-[10px]"
|
|
317
|
+
/>
|
|
318
|
+
<span className="min-w-0 flex-1">
|
|
319
|
+
{suggestion.name ? (
|
|
320
|
+
<span className="block truncate font-medium">
|
|
321
|
+
{suggestion.name}
|
|
322
|
+
</span>
|
|
323
|
+
) : null}
|
|
324
|
+
<span className="text-muted-foreground block truncate text-xs">
|
|
325
|
+
{suggestion.address}
|
|
326
|
+
</span>
|
|
327
|
+
</span>
|
|
328
|
+
<Check className="size-3.5 opacity-0 group-data-default/suggestion:opacity-100 group-data-highlighted/suggestion:opacity-100" />
|
|
329
|
+
</ComboboxItem>
|
|
330
|
+
)}
|
|
331
|
+
</ComboboxList>
|
|
332
|
+
</ComboboxContent>
|
|
333
|
+
</Combobox>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputGroup,
|
|
3
|
+
InputGroupAddon,
|
|
4
|
+
InputGroupInput,
|
|
5
|
+
InputGroupText,
|
|
6
|
+
} from "@open-workspace/core/ui";
|
|
7
|
+
|
|
8
|
+
export function RecipientFieldRow({
|
|
9
|
+
label,
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
disabled = false,
|
|
13
|
+
}: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: (value: string) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<InputGroup className="h-11 rounded-none border-0 bg-transparent shadow-none has-[[data-slot=input-group-control]:focus-visible]:border-0 has-[[data-slot=input-group-control]:focus-visible]:ring-0 dark:bg-transparent">
|
|
21
|
+
<InputGroupAddon className="w-14 justify-start pl-0">
|
|
22
|
+
<InputGroupText className="text-xs font-medium">{label}</InputGroupText>
|
|
23
|
+
</InputGroupAddon>
|
|
24
|
+
<InputGroupInput
|
|
25
|
+
className="px-2 dark:hover:bg-transparent"
|
|
26
|
+
aria-label={label}
|
|
27
|
+
value={value}
|
|
28
|
+
disabled={disabled}
|
|
29
|
+
onChange={(event) => onChange(event.target.value)}
|
|
30
|
+
placeholder="name@example.com"
|
|
31
|
+
/>
|
|
32
|
+
</InputGroup>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cn } from "@open-workspace/core/ui";
|
|
2
|
+
import { CornerUpLeft } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
import type { MessageDetail } from "./types";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A calm note when replies would reach another organization than the one in
|
|
8
|
+
* From (a common invoice-fraud pattern). Shown only while that address is a
|
|
9
|
+
* recipient.
|
|
10
|
+
*/
|
|
11
|
+
export function ReplyToWarning({
|
|
12
|
+
message,
|
|
13
|
+
recipients,
|
|
14
|
+
className,
|
|
15
|
+
}: {
|
|
16
|
+
message: Pick<MessageDetail, "fromAddress" | "security">;
|
|
17
|
+
recipients: readonly string[];
|
|
18
|
+
className?: string;
|
|
19
|
+
}) {
|
|
20
|
+
const mismatch = message.security?.replyToMismatch;
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
!mismatch ||
|
|
24
|
+
!recipients.some((address) => address.toLowerCase() === mismatch.address)
|
|
25
|
+
) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const fromDomain =
|
|
30
|
+
message.security?.fromDomain ?? message.fromAddress.split("@").at(-1);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<p
|
|
34
|
+
role="note"
|
|
35
|
+
data-testid="reply-to-warning"
|
|
36
|
+
className={cn(
|
|
37
|
+
"bg-warning/10 text-foreground flex items-start gap-2 px-3.5 py-2 text-xs leading-5",
|
|
38
|
+
className
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<CornerUpLeft className="mt-0.5 size-3.5 shrink-0 text-amber-700 dark:text-amber-300" />
|
|
42
|
+
<span>
|
|
43
|
+
Replies go to <span className="font-medium">{mismatch.address}</span>,
|
|
44
|
+
not the sender's domain
|
|
45
|
+
{fromDomain ? <> ({fromDomain})</> : null}. Check the address before
|
|
46
|
+
sending anything sensitive.
|
|
47
|
+
</span>
|
|
48
|
+
</p>
|
|
49
|
+
);
|
|
50
|
+
}
|