@arbidocs/blocks 0.4.84 → 0.4.86
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/MailBodyEditor-5PIQLYVY.js +217 -0
- package/dist/MailBodyEditor-5PIQLYVY.js.map +1 -0
- package/dist/MailBodyEditor-D7MGJMLH.cjs +223 -0
- package/dist/MailBodyEditor-D7MGJMLH.cjs.map +1 -0
- package/dist/agents/index.cjs +282 -281
- package/dist/agents/index.js +7 -6
- package/dist/agents/workflows/StepBarFrame.d.ts +3 -1
- package/dist/agents/workflows/WorkflowRunner.d.ts +10 -1
- package/dist/agents/workflows/run.d.ts +24 -3
- package/dist/agents/workflows/stepWindow.d.ts +4 -2
- package/dist/agents/workflows/types.d.ts +5 -0
- package/dist/agents/workflows/useWorkflowView.d.ts +16 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/chunk-3R6XBYL7.cjs +576 -0
- package/dist/chunk-3R6XBYL7.cjs.map +1 -0
- package/dist/{chunk-CKB64Z4R.js → chunk-4XJZ6AAY.js} +6 -245
- package/dist/chunk-4XJZ6AAY.js.map +1 -0
- package/dist/{chunk-B3WCKBJ7.cjs → chunk-5YXG342J.cjs} +6 -18
- package/dist/chunk-5YXG342J.cjs.map +1 -0
- package/dist/{chunk-SB5ZKOYN.js → chunk-7C35WXYB.js} +4 -63
- package/dist/chunk-7C35WXYB.js.map +1 -0
- package/dist/chunk-7RJTEWYM.js +362 -0
- package/dist/chunk-7RJTEWYM.js.map +1 -0
- package/dist/chunk-AFSOUS5X.cjs +253 -0
- package/dist/chunk-AFSOUS5X.cjs.map +1 -0
- package/dist/{chunk-F4RUCUXF.cjs → chunk-C2HRZSAT.cjs} +2 -63
- package/dist/chunk-C2HRZSAT.cjs.map +1 -0
- package/dist/{chunk-XA5S4776.cjs → chunk-IHYVK6F7.cjs} +52 -51
- package/dist/chunk-IHYVK6F7.cjs.map +1 -0
- package/dist/{chunk-CONIA2ZA.js → chunk-KHY4PYU7.js} +246 -146
- package/dist/chunk-KHY4PYU7.js.map +1 -0
- package/dist/chunk-LGX6UFYG.js +557 -0
- package/dist/chunk-LGX6UFYG.js.map +1 -0
- package/dist/chunk-O4YPVYPO.cjs +373 -0
- package/dist/chunk-O4YPVYPO.cjs.map +1 -0
- package/dist/chunk-R26OHONI.js +250 -0
- package/dist/chunk-R26OHONI.js.map +1 -0
- package/dist/{chunk-RYYYHPFU.cjs → chunk-RZUMQM7W.cjs} +246 -146
- package/dist/chunk-RZUMQM7W.cjs.map +1 -0
- package/dist/{chunk-RX35SMPR.js → chunk-S2NFD4QV.js} +8 -7
- package/dist/chunk-S2NFD4QV.js.map +1 -0
- package/dist/{chunk-YJQVLVBJ.cjs → chunk-S5HZBXZA.cjs} +2 -243
- package/dist/chunk-S5HZBXZA.cjs.map +1 -0
- package/dist/{chunk-GJV2G4FC.js → chunk-W7NZRZ54.js} +6 -18
- package/dist/chunk-W7NZRZ54.js.map +1 -0
- package/dist/{chunk-ZQYE7J3J.cjs → chunk-WRSBM6QN.cjs} +332 -94
- package/dist/chunk-WRSBM6QN.cjs.map +1 -0
- package/dist/{chunk-RSKSXEPW.js → chunk-X23U6QEJ.js} +324 -88
- package/dist/chunk-X23U6QEJ.js.map +1 -0
- package/dist/collaboration/index.cjs +100 -49
- package/dist/collaboration/index.js +4 -1
- package/dist/collaboration/mail/MailBodyEditor.d.ts +7 -0
- package/dist/collaboration/mail/MailDeliveryList.d.ts +8 -0
- package/dist/collaboration/mail/MailDocumentPicker.d.ts +15 -0
- package/dist/collaboration/mail/MailGrid.d.ts +17 -0
- package/dist/collaboration/mail/MailMessageView.d.ts +27 -0
- package/dist/collaboration/mail/PlainMailBodyEditor.d.ts +12 -0
- package/dist/collaboration/mail/index.d.ts +6 -0
- package/dist/collaboration/mail/mailCompose.d.ts +24 -0
- package/dist/connect/index.cjs +1673 -96
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +2 -1
- package/dist/connect/index.js +1634 -63
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedSettings.d.ts +1 -4
- package/dist/connection/ConnectedTagTable.d.ts +32 -0
- package/dist/connection/mail/ConnectedMailAccounts.d.ts +21 -0
- package/dist/connection/mail/ConnectedMailComposer.d.ts +40 -0
- package/dist/connection/mail/ConnectedMailSetup.d.ts +16 -0
- package/dist/connection/mail/ConnectedMailbox.d.ts +65 -0
- package/dist/connection/mail/MailComposerForm.d.ts +25 -0
- package/dist/connection/mail/attachments.d.ts +13 -0
- package/dist/connection/mail/index.d.ts +6 -0
- package/dist/connection/mail/mailbox.d.ts +6 -0
- package/dist/connection/mail/types.d.ts +92 -0
- package/dist/connection/useConnectedWorkNotifications.d.ts +6 -0
- package/dist/connection/useWorkflowThread.d.ts +7 -2
- package/dist/facts/index.cjs +3 -3
- package/dist/facts/index.js +3 -3
- package/dist/files/index.cjs +48 -368
- package/dist/files/index.cjs.map +1 -1
- package/dist/files/index.js +11 -361
- package/dist/files/index.js.map +1 -1
- package/dist/home/index.cjs +1 -1
- package/dist/home/index.js +1 -1
- package/dist/index.cjs +496 -437
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/settings/PasswordChangeDialog.d.ts +9 -12
- package/dist/settings/index.cjs +44 -43
- package/dist/settings/index.cjs.map +1 -1
- package/dist/settings/index.js +3 -2
- package/dist/settings/index.js.map +1 -1
- package/dist/shell/index.cjs +2 -2
- package/dist/shell/index.js +2 -2
- package/dist/studio/index.cjs +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/tags/TagColumnsEditor.d.ts +34 -0
- package/dist/tags/TagDetail.d.ts +13 -11
- package/dist/tags/TagTable.d.ts +99 -0
- package/dist/tags/TagsNav.d.ts +2 -2
- package/dist/tags/index.d.ts +7 -5
- package/dist/tags/{tagMatrixDocx.d.ts → tagTableDocx.d.ts} +12 -12
- package/dist/tags/tagTableModel.d.ts +47 -0
- package/dist/workflow-canvas/index.cjs +50 -49
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/dist/workflow-canvas/index.js +7 -6
- package/dist/workflow-canvas/index.js.map +1 -1
- package/package.json +29 -4
- package/dist/chunk-B3WCKBJ7.cjs.map +0 -1
- package/dist/chunk-CKB64Z4R.js.map +0 -1
- package/dist/chunk-CONIA2ZA.js.map +0 -1
- package/dist/chunk-F4RUCUXF.cjs.map +0 -1
- package/dist/chunk-GJV2G4FC.js.map +0 -1
- package/dist/chunk-RSKSXEPW.js.map +0 -1
- package/dist/chunk-RX35SMPR.js.map +0 -1
- package/dist/chunk-RYYYHPFU.cjs.map +0 -1
- package/dist/chunk-SB5ZKOYN.js.map +0 -1
- package/dist/chunk-XA5S4776.cjs.map +0 -1
- package/dist/chunk-YJQVLVBJ.cjs.map +0 -1
- package/dist/chunk-ZQYE7J3J.cjs.map +0 -1
- package/dist/connection/ConnectedTagMatrix.d.ts +0 -23
- package/dist/tags/TagMatrix.d.ts +0 -87
- package/dist/tags/tagMatrixModel.d.ts +0 -43
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { GridView } from './chunk-ZPLG7QYF.js';
|
|
3
|
+
import { Paperclip, Mail, AlertCircle, Clock, CheckCircle2, Send, ArrowLeft, Reply, Forward, Archive, Trash2, FolderOpen } from 'lucide-react';
|
|
4
|
+
import { cn, Button, Popover, PopoverTrigger, PopoverContent, Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from '@arbidocs/react/ui';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
import { useMemo, useState } from 'react';
|
|
7
|
+
import DOMPurify from 'dompurify';
|
|
8
|
+
|
|
9
|
+
var DELIVERY_BADGE = {
|
|
10
|
+
bounced: {
|
|
11
|
+
label: "Bounced",
|
|
12
|
+
title: "Not delivered: the recipient's mail server sent this message back.",
|
|
13
|
+
tone: "bg-destructive/10 text-destructive"
|
|
14
|
+
},
|
|
15
|
+
partially_bounced: {
|
|
16
|
+
label: "Partly bounced",
|
|
17
|
+
title: "Some recipients did not get this message. Open it to see who.",
|
|
18
|
+
tone: "bg-destructive/10 text-destructive"
|
|
19
|
+
},
|
|
20
|
+
delayed: {
|
|
21
|
+
label: "Delayed",
|
|
22
|
+
title: "Delivery is delayed; the recipient's server will keep retrying.",
|
|
23
|
+
tone: "bg-muted text-muted-foreground"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function MailDeliveryBadge({
|
|
27
|
+
problem,
|
|
28
|
+
className
|
|
29
|
+
}) {
|
|
30
|
+
const badge = DELIVERY_BADGE[problem];
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"span",
|
|
33
|
+
{
|
|
34
|
+
className: cn("shrink-0 rounded-full px-2 py-0.5 text-xs font-medium", badge.tone, className),
|
|
35
|
+
title: badge.title,
|
|
36
|
+
"data-testid": "mail-delivery-badge",
|
|
37
|
+
children: badge.label
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function MailMessagePreview({
|
|
42
|
+
participants,
|
|
43
|
+
subject,
|
|
44
|
+
preview,
|
|
45
|
+
date,
|
|
46
|
+
dateTime,
|
|
47
|
+
unread,
|
|
48
|
+
hasAttachments,
|
|
49
|
+
deliveryProblem: deliveryProblem2
|
|
50
|
+
}) {
|
|
51
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full min-w-0 flex-col justify-center gap-0.5 text-sm leading-5", children: [
|
|
52
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
53
|
+
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 flex-1 truncate", unread && "font-semibold"), children: participants }),
|
|
54
|
+
hasAttachments && /* @__PURE__ */ jsx(
|
|
55
|
+
Paperclip,
|
|
56
|
+
{
|
|
57
|
+
className: "size-3.5 shrink-0 text-muted-foreground",
|
|
58
|
+
"aria-label": "Has attachments"
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
deliveryProblem2 && /* @__PURE__ */ jsx(MailDeliveryBadge, { problem: deliveryProblem2 }),
|
|
62
|
+
/* @__PURE__ */ jsx("time", { dateTime, className: "shrink-0 text-xs font-normal text-muted-foreground", children: date })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ jsx("div", { className: cn("truncate", unread && "font-semibold"), children: subject || "(No subject)" }),
|
|
65
|
+
/* @__PURE__ */ jsx("div", { className: "truncate font-normal text-muted-foreground", children: preview || "\xA0" })
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/collaboration/mail/mailCompose.ts
|
|
70
|
+
var emptyMailCompose = () => ({
|
|
71
|
+
to: [],
|
|
72
|
+
cc: [],
|
|
73
|
+
bcc: [],
|
|
74
|
+
subject: "",
|
|
75
|
+
text: "",
|
|
76
|
+
attachments: []
|
|
77
|
+
});
|
|
78
|
+
var mailAddressLabel = (person) => person.name || person.email;
|
|
79
|
+
function parseMailRecipients(value) {
|
|
80
|
+
const addresses = (value.match(/(?:[^,;"\n]|"[^"]*")+/g) ?? []).map((entry) => entry.trim()).filter(Boolean).map((entry) => {
|
|
81
|
+
const named = entry.match(/^(.*?)\s*<([^<>]+)>$/);
|
|
82
|
+
return named ? { email: named[2].trim(), name: named[1].trim().replace(/^"|"$/g, "") } : { email: entry };
|
|
83
|
+
});
|
|
84
|
+
return addresses.filter(
|
|
85
|
+
(address, index) => addresses.findIndex((item) => item.email.toLowerCase() === address.email.toLowerCase()) === index
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function replyMailCompose(message, {
|
|
89
|
+
account,
|
|
90
|
+
folderRole,
|
|
91
|
+
forward = false,
|
|
92
|
+
all = false,
|
|
93
|
+
attachments = []
|
|
94
|
+
}) {
|
|
95
|
+
return {
|
|
96
|
+
...emptyMailCompose(),
|
|
97
|
+
to: forward ? [] : folderRole === "sent" ? message.to : message.sender,
|
|
98
|
+
cc: all ? [...message.to, ...message.cc].filter(
|
|
99
|
+
(r) => r.email.toLowerCase() !== account.email.toLowerCase() && !message.sender.some((s) => s.email.toLowerCase() === r.email.toLowerCase())
|
|
100
|
+
).filter(
|
|
101
|
+
(r, i, values) => values.findIndex((v) => v.email.toLowerCase() === r.email.toLowerCase()) === i
|
|
102
|
+
) : [],
|
|
103
|
+
subject: `${forward ? "Fwd" : "Re"}: ${message.subject.replace(/^(Re|Fwd):\s*/i, "")}`,
|
|
104
|
+
text: `
|
|
105
|
+
|
|
106
|
+
${message.sender.map((s) => s.email).join(", ")} wrote:
|
|
107
|
+
${message.text}`,
|
|
108
|
+
in_reply_to: forward ? void 0 : message.message_id,
|
|
109
|
+
references: [...message.references, ...message.message_id ? [message.message_id] : []],
|
|
110
|
+
attachments,
|
|
111
|
+
secure_delivery: message.secure_delivery
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function draftMailCompose(message, attachments) {
|
|
115
|
+
return {
|
|
116
|
+
to: message.to,
|
|
117
|
+
cc: message.cc,
|
|
118
|
+
bcc: message.bcc,
|
|
119
|
+
subject: message.subject,
|
|
120
|
+
text: message.text,
|
|
121
|
+
html: message.html,
|
|
122
|
+
attachments,
|
|
123
|
+
draft_id: message.id,
|
|
124
|
+
secure_delivery: message.secure_delivery
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
var hasCalendarPart = (attachments) => attachments.some(
|
|
128
|
+
(a) => /^text\/calendar\b|^application\/ics\b/i.test(a.content_type) || /\.ics$/i.test(a.name)
|
|
129
|
+
);
|
|
130
|
+
function deliveryProblem(status) {
|
|
131
|
+
return status === "bounced" || status === "partially_bounced" || status === "delayed" ? status : void 0;
|
|
132
|
+
}
|
|
133
|
+
function MailGrid({
|
|
134
|
+
messages,
|
|
135
|
+
loading,
|
|
136
|
+
selected,
|
|
137
|
+
onSelect,
|
|
138
|
+
outgoing = false,
|
|
139
|
+
personLabel = mailAddressLabel,
|
|
140
|
+
gridState,
|
|
141
|
+
onGridStateChange
|
|
142
|
+
}) {
|
|
143
|
+
const columns = useMemo(
|
|
144
|
+
() => [
|
|
145
|
+
{
|
|
146
|
+
colId: "unread",
|
|
147
|
+
cellStyle: { padding: 0, justifyContent: "center" },
|
|
148
|
+
headerName: "",
|
|
149
|
+
width: 34,
|
|
150
|
+
minWidth: 34,
|
|
151
|
+
maxWidth: 34,
|
|
152
|
+
sortable: false,
|
|
153
|
+
resizable: false,
|
|
154
|
+
cellRenderer: ({ data }) => data?.unread ? /* @__PURE__ */ jsx("span", { className: "inline-block size-2 rounded-full bg-primary", "aria-label": "Unread" }) : null
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
colId: "message",
|
|
158
|
+
cellClass: "[&_.ag-cell-value]:h-full [&_.ag-cell-value]:w-full [&_.ag-cell-wrapper]:h-full [&_.ag-cell-wrapper]:w-full",
|
|
159
|
+
headerName: "Message",
|
|
160
|
+
flex: 1,
|
|
161
|
+
minWidth: 240,
|
|
162
|
+
sortable: false,
|
|
163
|
+
valueGetter: (p) => p.data?.subject ?? "",
|
|
164
|
+
cellRenderer: ({ data }) => data ? /* @__PURE__ */ jsx(
|
|
165
|
+
MailMessagePreview,
|
|
166
|
+
{
|
|
167
|
+
participants: (outgoing ? data.to : data.sender).map(personLabel).join(", "),
|
|
168
|
+
subject: data.subject,
|
|
169
|
+
preview: data.preview,
|
|
170
|
+
unread: data.unread,
|
|
171
|
+
hasAttachments: Boolean(data.attachments.length),
|
|
172
|
+
deliveryProblem: deliveryProblem(data.delivery_status),
|
|
173
|
+
dateTime: data.received_at,
|
|
174
|
+
date: data.received_at ? new Date(data.received_at).toLocaleString(void 0, {
|
|
175
|
+
month: "short",
|
|
176
|
+
day: "numeric",
|
|
177
|
+
hour: "2-digit",
|
|
178
|
+
minute: "2-digit"
|
|
179
|
+
}) : ""
|
|
180
|
+
}
|
|
181
|
+
) : null
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
[outgoing, personLabel]
|
|
185
|
+
);
|
|
186
|
+
return /* @__PURE__ */ jsx(
|
|
187
|
+
GridView,
|
|
188
|
+
{
|
|
189
|
+
items: messages,
|
|
190
|
+
columnDefs: columns,
|
|
191
|
+
getItemId: (m) => m.id,
|
|
192
|
+
onRowClick: (m) => onSelect(m.id),
|
|
193
|
+
height: "100%",
|
|
194
|
+
rowHeight: 84,
|
|
195
|
+
persistState: Boolean(onGridStateChange),
|
|
196
|
+
gridId: "personal-mail-grid-v2",
|
|
197
|
+
gridState,
|
|
198
|
+
onGridStateChange,
|
|
199
|
+
testId: "mail-grid",
|
|
200
|
+
isLoading: loading,
|
|
201
|
+
getRowTestId: (m) => `mail-row-${m.id}`,
|
|
202
|
+
emptyState: {
|
|
203
|
+
icon: /* @__PURE__ */ jsx(Mail, { className: "size-10 text-muted-foreground/50" }),
|
|
204
|
+
title: "No messages",
|
|
205
|
+
message: "Messages in this folder will appear here."
|
|
206
|
+
},
|
|
207
|
+
gridOptions: {
|
|
208
|
+
headerHeight: 0,
|
|
209
|
+
suppressCellFocus: false,
|
|
210
|
+
onCellKeyDown: (event) => {
|
|
211
|
+
if (event.event?.key === "Enter" && event.data) onSelect(event.data.id);
|
|
212
|
+
},
|
|
213
|
+
defaultColDef: {
|
|
214
|
+
sortable: true,
|
|
215
|
+
resizable: true,
|
|
216
|
+
filter: false
|
|
217
|
+
},
|
|
218
|
+
rowClassRules: { "bg-muted/60": (p) => p.data?.id === selected }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
var ICONS = {
|
|
224
|
+
accepted: Send,
|
|
225
|
+
relayed: Send,
|
|
226
|
+
expanded: Send,
|
|
227
|
+
delivered: CheckCircle2,
|
|
228
|
+
delayed: Clock,
|
|
229
|
+
rejected: AlertCircle,
|
|
230
|
+
failed: AlertCircle
|
|
231
|
+
};
|
|
232
|
+
var LABELS = {
|
|
233
|
+
accepted: "Sent",
|
|
234
|
+
relayed: "Sent",
|
|
235
|
+
expanded: "Sent",
|
|
236
|
+
delivered: "Delivered",
|
|
237
|
+
delayed: "Delayed",
|
|
238
|
+
rejected: "Not delivered",
|
|
239
|
+
failed: "Not delivered"
|
|
240
|
+
};
|
|
241
|
+
function MailDeliveryList({
|
|
242
|
+
recipients
|
|
243
|
+
}) {
|
|
244
|
+
if (recipients.length === 0) return null;
|
|
245
|
+
return /* @__PURE__ */ jsxs(
|
|
246
|
+
"section",
|
|
247
|
+
{
|
|
248
|
+
"aria-label": "Delivery",
|
|
249
|
+
className: "mb-5 rounded-md border border-border/60 px-3 py-2",
|
|
250
|
+
"data-testid": "mail-delivery-list",
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ jsx("h3", { className: "mb-1 text-xs font-medium text-muted-foreground", children: "Delivery" }),
|
|
253
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: recipients.map((recipient) => {
|
|
254
|
+
const Icon = ICONS[recipient.status];
|
|
255
|
+
const failed = recipient.status === "failed" || recipient.status === "rejected";
|
|
256
|
+
return /* @__PURE__ */ jsxs(
|
|
257
|
+
"li",
|
|
258
|
+
{
|
|
259
|
+
className: "flex flex-wrap items-baseline gap-x-2 text-sm",
|
|
260
|
+
"data-testid": `mail-delivery-${recipient.email}`,
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ jsx(
|
|
263
|
+
Icon,
|
|
264
|
+
{
|
|
265
|
+
"aria-hidden": "true",
|
|
266
|
+
className: cn(
|
|
267
|
+
"size-3.5 shrink-0 self-center",
|
|
268
|
+
failed ? "text-destructive" : "text-muted-foreground"
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
),
|
|
272
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: recipient.email }),
|
|
273
|
+
/* @__PURE__ */ jsxs("span", { className: cn(failed ? "text-destructive" : "text-muted-foreground"), children: [
|
|
274
|
+
LABELS[recipient.status],
|
|
275
|
+
": ",
|
|
276
|
+
recipient.description
|
|
277
|
+
] })
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
recipient.email
|
|
281
|
+
);
|
|
282
|
+
}) })
|
|
283
|
+
]
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
var NEEDS_CONNECTION = "Available when you are back online";
|
|
288
|
+
var SANITIZE = {
|
|
289
|
+
ALLOWED_TAGS: [
|
|
290
|
+
"p",
|
|
291
|
+
"br",
|
|
292
|
+
"strong",
|
|
293
|
+
"b",
|
|
294
|
+
"em",
|
|
295
|
+
"i",
|
|
296
|
+
"u",
|
|
297
|
+
"s",
|
|
298
|
+
"ul",
|
|
299
|
+
"ol",
|
|
300
|
+
"li",
|
|
301
|
+
"a",
|
|
302
|
+
"span",
|
|
303
|
+
"blockquote"
|
|
304
|
+
],
|
|
305
|
+
ALLOWED_ATTR: ["href"],
|
|
306
|
+
ALLOW_DATA_ATTR: false
|
|
307
|
+
};
|
|
308
|
+
function MailMessageView({
|
|
309
|
+
account,
|
|
310
|
+
message,
|
|
311
|
+
folderRole,
|
|
312
|
+
folders,
|
|
313
|
+
isOnline,
|
|
314
|
+
loading,
|
|
315
|
+
uploadPending,
|
|
316
|
+
onBack,
|
|
317
|
+
onEditDraft,
|
|
318
|
+
onReply,
|
|
319
|
+
onUpdate,
|
|
320
|
+
onDownloadAttachment,
|
|
321
|
+
onDownloadOriginal,
|
|
322
|
+
onSaveToWorkspace,
|
|
323
|
+
personLabel = mailAddressLabel,
|
|
324
|
+
renderInvite
|
|
325
|
+
}) {
|
|
326
|
+
const offlineTitle = isOnline ? void 0 : NEEDS_CONNECTION;
|
|
327
|
+
return /* @__PURE__ */ jsxs("article", { className: "min-w-0 flex-1 overflow-auto p-4 sm:p-5", children: [
|
|
328
|
+
/* @__PURE__ */ jsxs(Button, { className: "mb-3", variant: "ghost", onClick: onBack, children: [
|
|
329
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2 size-4" }),
|
|
330
|
+
"Back"
|
|
331
|
+
] }),
|
|
332
|
+
loading && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Loading message\u2026" }),
|
|
333
|
+
/* @__PURE__ */ jsxs("div", { className: "-mx-4 mb-5 flex flex-wrap items-center gap-1 border-b bg-muted/20 px-3 py-1.5 sm:-mx-5 [&_button]:h-8 [&_button]:px-2 [&_button]:text-xs", children: [
|
|
334
|
+
folderRole === "drafts" ? /* @__PURE__ */ jsx(Button, { onClick: onEditDraft, children: "Edit draft" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
335
|
+
/* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: () => onReply(), children: [
|
|
336
|
+
/* @__PURE__ */ jsx(Reply, { className: "mr-2 size-4" }),
|
|
337
|
+
"Reply"
|
|
338
|
+
] }),
|
|
339
|
+
message.to.length + message.cc.length > 1 && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => onReply(false, true), children: "Reply all" }),
|
|
340
|
+
/* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: () => onReply(true), children: [
|
|
341
|
+
/* @__PURE__ */ jsx(Forward, { className: "mr-2 size-4" }),
|
|
342
|
+
"Forward"
|
|
343
|
+
] })
|
|
344
|
+
] }),
|
|
345
|
+
/* @__PURE__ */ jsx(
|
|
346
|
+
Button,
|
|
347
|
+
{
|
|
348
|
+
variant: "ghost",
|
|
349
|
+
disabled: !isOnline,
|
|
350
|
+
title: offlineTitle,
|
|
351
|
+
onClick: () => onUpdate({ unread: !message.unread }),
|
|
352
|
+
children: message.unread ? "Mark read" : "Mark unread"
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
(folderRole === "archive" || folderRole === "trash") && /* @__PURE__ */ jsx(
|
|
356
|
+
Button,
|
|
357
|
+
{
|
|
358
|
+
variant: "ghost",
|
|
359
|
+
disabled: !isOnline,
|
|
360
|
+
title: offlineTitle,
|
|
361
|
+
onClick: () => onUpdate({ folder_id: folders?.find((f) => f.role === "inbox")?.id ?? "inbox" }),
|
|
362
|
+
children: "Move to Inbox"
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
/* @__PURE__ */ jsx(
|
|
366
|
+
Button,
|
|
367
|
+
{
|
|
368
|
+
variant: "ghost",
|
|
369
|
+
"aria-label": "Archive message",
|
|
370
|
+
disabled: !isOnline,
|
|
371
|
+
title: offlineTitle,
|
|
372
|
+
onClick: () => onUpdate({ folder_id: folders?.find((f) => f.role === "archive")?.id ?? "archive" }),
|
|
373
|
+
children: /* @__PURE__ */ jsx(Archive, { className: "size-4" })
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
/* @__PURE__ */ jsx(
|
|
377
|
+
Button,
|
|
378
|
+
{
|
|
379
|
+
variant: "ghost",
|
|
380
|
+
"aria-label": "Trash message",
|
|
381
|
+
disabled: !isOnline,
|
|
382
|
+
title: offlineTitle,
|
|
383
|
+
onClick: () => onUpdate({ action: "trash" }),
|
|
384
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4" })
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-wrap items-center gap-2", children: [
|
|
389
|
+
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold leading-snug tracking-tight", children: message.subject || "(No subject)" }),
|
|
390
|
+
(message.delivery_status === "bounced" || message.delivery_status === "partially_bounced" || message.delivery_status === "delayed") && /* @__PURE__ */ jsx(MailDeliveryBadge, { problem: message.delivery_status })
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-5 flex gap-3 border-b border-border/60 pb-4", children: [
|
|
393
|
+
/* @__PURE__ */ jsx(
|
|
394
|
+
"span",
|
|
395
|
+
{
|
|
396
|
+
"aria-hidden": "true",
|
|
397
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10 text-sm font-semibold text-primary",
|
|
398
|
+
children: (message.sender[0]?.name || message.sender[0]?.email || "?").split(/\s+/).slice(0, 2).map((part) => part[0]).join("").toUpperCase()
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
402
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-1", children: [
|
|
403
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: message.sender.map((person) => person.name || person.email).join(", ") }),
|
|
404
|
+
/* @__PURE__ */ jsx("time", { className: "text-[11px] text-muted-foreground", children: message.received_at ? new Date(message.received_at).toLocaleString() : "" })
|
|
405
|
+
] }),
|
|
406
|
+
/* @__PURE__ */ jsx("p", { className: "break-all text-xs text-muted-foreground", children: message.sender.map((person) => person.email).join(", ") }),
|
|
407
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-2 break-all text-xs text-muted-foreground", children: [
|
|
408
|
+
"To: ",
|
|
409
|
+
message.to.map(personLabel).join(", "),
|
|
410
|
+
message.cc.length > 0 && ` \xB7 Cc: ${message.cc.map(personLabel).join(", ")}`
|
|
411
|
+
] })
|
|
412
|
+
] })
|
|
413
|
+
] }),
|
|
414
|
+
/* @__PURE__ */ jsx(MailDeliveryList, { recipients: message.delivery ?? [] }),
|
|
415
|
+
renderInvite && hasCalendarPart(message.attachments) && renderInvite(),
|
|
416
|
+
/* @__PURE__ */ jsx("div", { className: "mb-4 flex flex-wrap gap-2", children: message.attachments.map((a) => /* @__PURE__ */ jsxs(
|
|
417
|
+
Button,
|
|
418
|
+
{
|
|
419
|
+
className: "h-auto min-h-12 justify-start rounded-md border-border/70 bg-muted/20 px-3 py-2 text-left shadow-none hover:bg-muted/60",
|
|
420
|
+
variant: "outline",
|
|
421
|
+
onClick: () => onDownloadAttachment(a),
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ jsx(Paperclip, { className: "mr-2 size-4" }),
|
|
424
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
425
|
+
/* @__PURE__ */ jsx("span", { className: "block truncate text-xs font-medium", children: a.name }),
|
|
426
|
+
/* @__PURE__ */ jsx(
|
|
427
|
+
"span",
|
|
428
|
+
{
|
|
429
|
+
"aria-hidden": "true",
|
|
430
|
+
className: "block text-[11px] font-normal text-muted-foreground",
|
|
431
|
+
children: a.size < 1024 ? `${a.size} B` : `${Math.ceil(a.size / 1024)} KB`
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
] })
|
|
435
|
+
]
|
|
436
|
+
},
|
|
437
|
+
a.id
|
|
438
|
+
)) }),
|
|
439
|
+
message.html && message.text ? /* @__PURE__ */ jsx(
|
|
440
|
+
"div",
|
|
441
|
+
{
|
|
442
|
+
className: "text-sm leading-7 [&_p]:mb-3 [&_ul]:list-disc [&_ul]:pl-6 [&_ol]:list-decimal [&_ol]:pl-6 [&_a]:text-primary [&_a]:underline",
|
|
443
|
+
dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(message.html, SANITIZE) }
|
|
444
|
+
}
|
|
445
|
+
) : message.text ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap break-words font-sans text-sm leading-7 text-foreground/90", children: message.text.split(/(https?:\/\/[^\s]+)/g).map(
|
|
446
|
+
(part, index) => /^https?:\/\//.test(part) ? /* @__PURE__ */ jsx(
|
|
447
|
+
"a",
|
|
448
|
+
{
|
|
449
|
+
href: part,
|
|
450
|
+
className: "text-primary underline underline-offset-2",
|
|
451
|
+
rel: "noreferrer",
|
|
452
|
+
children: part
|
|
453
|
+
},
|
|
454
|
+
index
|
|
455
|
+
) : part
|
|
456
|
+
) }) : message.html ? /* @__PURE__ */ jsx(
|
|
457
|
+
"iframe",
|
|
458
|
+
{
|
|
459
|
+
title: "Email body",
|
|
460
|
+
sandbox: "",
|
|
461
|
+
referrerPolicy: "no-referrer",
|
|
462
|
+
className: "min-h-96 w-full border-0 bg-white",
|
|
463
|
+
srcDoc: `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">${message.html}`
|
|
464
|
+
}
|
|
465
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Empty message" }),
|
|
466
|
+
account.provider === "native" && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
467
|
+
/* @__PURE__ */ jsx(
|
|
468
|
+
Button,
|
|
469
|
+
{
|
|
470
|
+
className: "mt-5",
|
|
471
|
+
variant: "outline",
|
|
472
|
+
disabled: !isOnline,
|
|
473
|
+
title: offlineTitle,
|
|
474
|
+
onClick: onDownloadOriginal,
|
|
475
|
+
children: "Download original email"
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
onSaveToWorkspace && /* @__PURE__ */ jsx(
|
|
479
|
+
Button,
|
|
480
|
+
{
|
|
481
|
+
className: "mt-5",
|
|
482
|
+
variant: "outline",
|
|
483
|
+
disabled: uploadPending || !isOnline,
|
|
484
|
+
title: offlineTitle,
|
|
485
|
+
onClick: onSaveToWorkspace,
|
|
486
|
+
children: "Save to workspace"
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
] })
|
|
490
|
+
] });
|
|
491
|
+
}
|
|
492
|
+
function MailDocumentPicker({
|
|
493
|
+
documents,
|
|
494
|
+
onAttach,
|
|
495
|
+
disabled = false
|
|
496
|
+
}) {
|
|
497
|
+
const [open, setOpen] = useState(false);
|
|
498
|
+
const [query, setQuery] = useState("");
|
|
499
|
+
const filtered = useMemo(() => {
|
|
500
|
+
const q = query.trim().toLowerCase();
|
|
501
|
+
return q ? documents.filter((d) => d.title.toLowerCase().includes(q)) : documents;
|
|
502
|
+
}, [documents, query]);
|
|
503
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
504
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
505
|
+
Button,
|
|
506
|
+
{
|
|
507
|
+
type: "button",
|
|
508
|
+
variant: "ghost",
|
|
509
|
+
disabled,
|
|
510
|
+
"data-testid": "mail-attach-workspace-document",
|
|
511
|
+
children: [
|
|
512
|
+
/* @__PURE__ */ jsx(FolderOpen, { className: "mr-2 size-4" }),
|
|
513
|
+
"From workspace"
|
|
514
|
+
]
|
|
515
|
+
}
|
|
516
|
+
) }),
|
|
517
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-80 p-0", align: "start", sideOffset: 4, children: /* @__PURE__ */ jsxs(Command, { shouldFilter: false, children: [
|
|
518
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search documents...", value: query, onValueChange: setQuery }),
|
|
519
|
+
/* @__PURE__ */ jsxs(CommandList, { className: "max-h-72", children: [
|
|
520
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No documents in this workspace" }),
|
|
521
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: filtered.map((doc) => /* @__PURE__ */ jsxs(
|
|
522
|
+
CommandItem,
|
|
523
|
+
{
|
|
524
|
+
value: doc.id,
|
|
525
|
+
onSelect: () => {
|
|
526
|
+
setOpen(false);
|
|
527
|
+
setQuery("");
|
|
528
|
+
onAttach(doc);
|
|
529
|
+
},
|
|
530
|
+
"data-testid": `document-search-item-${doc.id}`,
|
|
531
|
+
children: [
|
|
532
|
+
doc.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: doc.icon }),
|
|
533
|
+
/* @__PURE__ */ jsx("span", { className: "ml-1.5 flex-1 truncate text-sm", children: doc.title })
|
|
534
|
+
]
|
|
535
|
+
},
|
|
536
|
+
doc.id
|
|
537
|
+
)) })
|
|
538
|
+
] })
|
|
539
|
+
] }) })
|
|
540
|
+
] });
|
|
541
|
+
}
|
|
542
|
+
function PlainMailBodyEditor({ text, disabled, onChange }) {
|
|
543
|
+
return /* @__PURE__ */ jsx(
|
|
544
|
+
"textarea",
|
|
545
|
+
{
|
|
546
|
+
"aria-label": "Message",
|
|
547
|
+
className: "my-3 min-h-48 w-full resize-y bg-transparent text-sm outline-none",
|
|
548
|
+
value: text,
|
|
549
|
+
disabled,
|
|
550
|
+
onChange: (event) => onChange(event.target.value, "")
|
|
551
|
+
}
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export { MailDeliveryBadge, MailDeliveryList, MailDocumentPicker, MailGrid, MailMessagePreview, MailMessageView, NEEDS_CONNECTION, PlainMailBodyEditor, draftMailCompose, emptyMailCompose, hasCalendarPart, mailAddressLabel, parseMailRecipients, replyMailCompose };
|
|
556
|
+
//# sourceMappingURL=chunk-LGX6UFYG.js.map
|
|
557
|
+
//# sourceMappingURL=chunk-LGX6UFYG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/collaboration/mail/MailMessagePreview.tsx","../src/collaboration/mail/mailCompose.ts","../src/collaboration/mail/MailGrid.tsx","../src/collaboration/mail/MailDeliveryList.tsx","../src/collaboration/mail/MailMessageView.tsx","../src/collaboration/mail/MailDocumentPicker.tsx","../src/collaboration/mail/PlainMailBodyEditor.tsx"],"names":["deliveryProblem","jsx","jsxs","cn","Paperclip","useMemo","Button"],"mappings":";;;;;;;AAiBA,IAAM,cAAA,GACJ;AAAA,EACE,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,SAAA;AAAA,IACP,KAAA,EAAO,oEAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA,iBAAA,EAAmB;AAAA,IACjB,KAAA,EAAO,gBAAA;AAAA,IACP,KAAA,EAAO,+DAAA;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,SAAA;AAAA,IACP,KAAA,EAAO,iEAAA;AAAA,IACP,IAAA,EAAM;AAAA;AAEV,CAAA;AAGK,SAAS,iBAAA,CAAkB;AAAA,EAChC,OAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,MAAM,KAAA,GAAQ,eAAe,OAAO,CAAA;AACpC,EAAA,uBACE,GAAA;AAAA,IA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AAO,GAAA,CAAI,EAAA;AAAA,YACX,UAAU,MAAM;AACd,cAAA,OAAA,CAAQ,KAAK,CAAA;AACb,cAAA,QAAA,CAAS,EAAE,CAAA;AACX,cAAA,QAAA,CAAS,GAAG,CAAA;AAAA,YACd,CAAA;AAAA,YACA,aAAA,EAAa,CAAA,qBAAA,EAAwB,GAAA,CAAI,EAAE,CAAA,CAAA;AAAA,YAE1C,QAAA,EAAA;AAAA,cAAA,GAAA,CAAI,wBAAQD,GAAAA,CAAC,UAAK,SAAA,EAAU,gCAAA,EAAkC,cAAI,IAAA,EAAK,CAAA;AAAA,8BACxEA,GAAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,gCAAA,EAAkC,cAAI,KAAA,EAAM;AAAA;AAAA,WAAA;AAAA,UAVvD,GAAA,CAAI;AAAA,SAYZ,CAAA,EACH;AAAA,OAAA,EACF;AAAA,KAAA,EACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ;ACtEO,SAAS,mBAAA,CAAoB,EAAE,IAAA,EAAM,QAAA,EAAU,UAAS,EAAwB;AACrF,EAAA,uBACEA,GAAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAU,mEAAA;AAAA,MACV,KAAA,EAAO,IAAA;AAAA,MACP,QAAA;AAAA,MACA,UAAU,CAAC,KAAA,KAAU,SAAS,KAAA,CAAM,MAAA,CAAO,OAAO,EAAE;AAAA;AAAA,GACtD;AAEJ","file":"chunk-LGX6UFYG.js","sourcesContent":["import { Paperclip } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\n\nexport interface MailMessagePreviewProps {\n participants: string\n subject: string\n preview?: string\n date: string\n dateTime?: string\n unread?: boolean\n hasAttachments?: boolean\n /** A sent message's delivery problem; sent and delivered mail shows nothing, as in other clients. */\n deliveryProblem?: MailDeliveryProblem\n}\n\nexport type MailDeliveryProblem = 'bounced' | 'partially_bounced' | 'delayed'\n\nconst DELIVERY_BADGE: Record<MailDeliveryProblem, { label: string; title: string; tone: string }> =\n {\n bounced: {\n label: 'Bounced',\n title: \"Not delivered: the recipient's mail server sent this message back.\",\n tone: 'bg-destructive/10 text-destructive',\n },\n partially_bounced: {\n label: 'Partly bounced',\n title: 'Some recipients did not get this message. Open it to see who.',\n tone: 'bg-destructive/10 text-destructive',\n },\n delayed: {\n label: 'Delayed',\n title: \"Delivery is delayed; the recipient's server will keep retrying.\",\n tone: 'bg-muted text-muted-foreground',\n },\n }\n\n/** A pill for a sent message that bounced, partly bounced, or is delayed. */\nexport function MailDeliveryBadge({\n problem,\n className,\n}: {\n problem: MailDeliveryProblem\n className?: string\n}) {\n const badge = DELIVERY_BADGE[problem]\n return (\n <span\n className={cn('shrink-0 rounded-full px-2 py-0.5 text-xs font-medium', badge.tone, className)}\n title={badge.title}\n data-testid=\"mail-delivery-badge\"\n >\n {badge.label}\n </span>\n )\n}\n\n/** Compact inbox identity: sender/date, subject, then a body preview. */\nexport function MailMessagePreview({\n participants,\n subject,\n preview,\n date,\n dateTime,\n unread,\n hasAttachments,\n deliveryProblem,\n}: MailMessagePreviewProps) {\n return (\n <div className=\"flex h-full w-full min-w-0 flex-col justify-center gap-0.5 text-sm leading-5\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <span className={cn('min-w-0 flex-1 truncate', unread && 'font-semibold')}>\n {participants}\n </span>\n {hasAttachments && (\n <Paperclip\n className=\"size-3.5 shrink-0 text-muted-foreground\"\n aria-label=\"Has attachments\"\n />\n )}\n {deliveryProblem && <MailDeliveryBadge problem={deliveryProblem} />}\n <time dateTime={dateTime} className=\"shrink-0 text-xs font-normal text-muted-foreground\">\n {date}\n </time>\n </div>\n <div className={cn('truncate', unread && 'font-semibold')}>{subject || '(No subject)'}</div>\n <div className=\"truncate font-normal text-muted-foreground\">{preview || '\\u00a0'}</div>\n </div>\n )\n}\n","/** Pure helpers for writing mail: an empty message, recipient parsing, replies and forwards. */\n\nimport type {\n MailAccount,\n MailAddress,\n MailAttachment,\n MailCompose,\n MailMessage,\n} from '@arbidocs/react'\n\nexport const emptyMailCompose = (): MailCompose => ({\n to: [],\n cc: [],\n bcc: [],\n subject: '',\n text: '',\n attachments: [],\n})\n\n/** A person as shown: the name on the message, else the address. */\nexport const mailAddressLabel = (person: MailAddress): string => person.name || person.email\n\n/**\n * Typed or pasted recipients (`a@x.org; Pat <pat@y.org>`), separated by commas, semicolons or\n * lines, deduplicated by address.\n */\nexport function parseMailRecipients(value: string): MailAddress[] {\n const addresses = (value.match(/(?:[^,;\"\\n]|\"[^\"]*\")+/g) ?? [])\n .map((entry) => entry.trim())\n .filter(Boolean)\n .map((entry) => {\n const named = entry.match(/^(.*?)\\s*<([^<>]+)>$/)\n return named\n ? { email: named[2].trim(), name: named[1].trim().replace(/^\"|\"$/g, '') }\n : { email: entry }\n })\n return addresses.filter(\n (address, index) =>\n addresses.findIndex((item) => item.email.toLowerCase() === address.email.toLowerCase()) ===\n index\n )\n}\n\n/** A reply (to the sender, or everyone with `all`) or a forward of `message`. */\nexport function replyMailCompose(\n message: MailMessage,\n {\n account,\n folderRole,\n forward = false,\n all = false,\n attachments = [],\n }: {\n account: MailAccount\n /** The folder the message is in: replying from Sent goes to its recipients. */\n folderRole: string\n forward?: boolean\n all?: boolean\n /** A forward's attachments, with their content. */\n attachments?: MailAttachment[]\n }\n): MailCompose {\n return {\n ...emptyMailCompose(),\n to: forward ? [] : folderRole === 'sent' ? message.to : message.sender,\n cc: all\n ? [...message.to, ...message.cc]\n .filter(\n (r) =>\n r.email.toLowerCase() !== account.email.toLowerCase() &&\n !message.sender.some((s) => s.email.toLowerCase() === r.email.toLowerCase())\n )\n .filter(\n (r, i, values) =>\n values.findIndex((v) => v.email.toLowerCase() === r.email.toLowerCase()) === i\n )\n : [],\n subject: `${forward ? 'Fwd' : 'Re'}: ${message.subject.replace(/^(Re|Fwd):\\s*/i, '')}`,\n text: `\\n\\n${message.sender.map((s) => s.email).join(', ')} wrote:\\n${message.text}`,\n in_reply_to: forward ? undefined : message.message_id,\n references: [...message.references, ...(message.message_id ? [message.message_id] : [])],\n attachments,\n secure_delivery: message.secure_delivery,\n }\n}\n\n/** A saved draft, reopened for editing (`attachments` with their content). */\nexport function draftMailCompose(message: MailMessage, attachments: MailAttachment[]): MailCompose {\n return {\n to: message.to,\n cc: message.cc,\n bcc: message.bcc,\n subject: message.subject,\n text: message.text,\n html: message.html,\n attachments,\n draft_id: message.id,\n secure_delivery: message.secure_delivery,\n }\n}\n\n/** Whether a message carries a calendar invite (an .ics part). */\nexport const hasCalendarPart = (attachments: MailAttachment[]): boolean =>\n attachments.some(\n (a) => /^text\\/calendar\\b|^application\\/ics\\b/i.test(a.content_type) || /\\.ics$/i.test(a.name)\n )\n","import { useMemo } from 'react'\nimport type { ColDef, GridState } from 'ag-grid-community'\nimport { Mail } from 'lucide-react'\nimport type { MailAddress, MailMessage } from '@arbidocs/react'\nimport { GridView } from '../../files/GridView'\nimport { MailMessagePreview, type MailDeliveryProblem } from './MailMessagePreview'\nimport { mailAddressLabel } from './mailCompose'\n\n/** The list shows only delivery problems; sent and delivered mail stays quiet. */\nfunction deliveryProblem(status: MailMessage['delivery_status']): MailDeliveryProblem | undefined {\n return status === 'bounced' || status === 'partially_bounced' || status === 'delayed'\n ? status\n : undefined\n}\n\nexport interface MailGridProps {\n messages: MailMessage[]\n loading: boolean\n selected: string | null\n /** Sent, Drafts or Outbox: rows show recipients instead of the sender. */\n outgoing?: boolean\n onSelect: (id: string) => void\n /** How a person is named (default: the name on the message, else the address). */\n personLabel?: (person: MailAddress) => string\n /** Column state to restore at mount, and where to persist changes (both optional). */\n gridState?: GridState\n onGridStateChange?: (state: GridState) => void\n}\n\n/** A folder's messages: one row per message, unread dot, participants, subject and preview. */\nexport function MailGrid({\n messages,\n loading,\n selected,\n onSelect,\n outgoing = false,\n personLabel = mailAddressLabel,\n gridState,\n onGridStateChange,\n}: MailGridProps) {\n const columns = useMemo<ColDef<MailMessage>[]>(\n () => [\n {\n colId: 'unread',\n cellStyle: { padding: 0, justifyContent: 'center' },\n headerName: '',\n width: 34,\n minWidth: 34,\n maxWidth: 34,\n sortable: false,\n resizable: false,\n cellRenderer: ({ data }: { data?: MailMessage }) =>\n data?.unread ? (\n <span className=\"inline-block size-2 rounded-full bg-primary\" aria-label=\"Unread\" />\n ) : null,\n },\n {\n colId: 'message',\n cellClass:\n '[&_.ag-cell-value]:h-full [&_.ag-cell-value]:w-full [&_.ag-cell-wrapper]:h-full [&_.ag-cell-wrapper]:w-full',\n headerName: 'Message',\n flex: 1,\n minWidth: 240,\n sortable: false,\n valueGetter: (p) => p.data?.subject ?? '',\n cellRenderer: ({ data }: { data?: MailMessage }) =>\n data ? (\n <MailMessagePreview\n participants={(outgoing ? data.to : data.sender).map(personLabel).join(', ')}\n subject={data.subject}\n preview={data.preview}\n unread={data.unread}\n hasAttachments={Boolean(data.attachments.length)}\n deliveryProblem={deliveryProblem(data.delivery_status)}\n dateTime={data.received_at}\n date={\n data.received_at\n ? new Date(data.received_at).toLocaleString(undefined, {\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n })\n : ''\n }\n />\n ) : null,\n },\n ],\n [outgoing, personLabel]\n )\n return (\n <GridView<MailMessage>\n items={messages}\n columnDefs={columns}\n getItemId={(m) => m.id}\n onRowClick={(m) => onSelect(m.id)}\n height=\"100%\"\n rowHeight={84}\n persistState={Boolean(onGridStateChange)}\n gridId=\"personal-mail-grid-v2\"\n gridState={gridState}\n onGridStateChange={onGridStateChange}\n testId=\"mail-grid\"\n isLoading={loading}\n getRowTestId={(m) => `mail-row-${m.id}`}\n emptyState={{\n icon: <Mail className=\"size-10 text-muted-foreground/50\" />,\n title: 'No messages',\n message: 'Messages in this folder will appear here.',\n }}\n gridOptions={{\n headerHeight: 0,\n suppressCellFocus: false,\n onCellKeyDown: (event) => {\n if ((event.event as KeyboardEvent)?.key === 'Enter' && event.data) onSelect(event.data.id)\n },\n defaultColDef: {\n sortable: true,\n resizable: true,\n filter: false,\n },\n rowClassRules: { 'bg-muted/60': (p) => p.data?.id === selected },\n }}\n />\n )\n}\n","import { AlertCircle, CheckCircle2, Clock, Send } from 'lucide-react'\nimport type { MailDeliveryRecipient } from '@arbidocs/react'\nimport { cn } from '@arbidocs/react/ui'\n\nconst ICONS: Record<MailDeliveryRecipient['status'], typeof Send> = {\n accepted: Send,\n relayed: Send,\n expanded: Send,\n delivered: CheckCircle2,\n delayed: Clock,\n rejected: AlertCircle,\n failed: AlertCircle,\n}\n\nconst LABELS: Record<MailDeliveryRecipient['status'], string> = {\n accepted: 'Sent',\n relayed: 'Sent',\n expanded: 'Sent',\n delivered: 'Delivered',\n delayed: 'Delayed',\n rejected: 'Not delivered',\n failed: 'Not delivered',\n}\n\n/**\n * Where a sent message got to, per recipient: the relay's answer and any delivery reports that came\n * back, in plain words. Shown on sent native mail only.\n */\nexport function MailDeliveryList({\n recipients,\n}: {\n recipients: MailDeliveryRecipient[]\n}): React.ReactElement | null {\n if (recipients.length === 0) return null\n return (\n <section\n aria-label=\"Delivery\"\n className=\"mb-5 rounded-md border border-border/60 px-3 py-2\"\n data-testid=\"mail-delivery-list\"\n >\n <h3 className=\"mb-1 text-xs font-medium text-muted-foreground\">Delivery</h3>\n <ul className=\"space-y-1\">\n {recipients.map((recipient) => {\n const Icon = ICONS[recipient.status]\n const failed = recipient.status === 'failed' || recipient.status === 'rejected'\n return (\n <li\n key={recipient.email}\n className=\"flex flex-wrap items-baseline gap-x-2 text-sm\"\n data-testid={`mail-delivery-${recipient.email}`}\n >\n <Icon\n aria-hidden=\"true\"\n className={cn(\n 'size-3.5 shrink-0 self-center',\n failed ? 'text-destructive' : 'text-muted-foreground'\n )}\n />\n <span className=\"font-medium\">{recipient.email}</span>\n <span className={cn(failed ? 'text-destructive' : 'text-muted-foreground')}>\n {LABELS[recipient.status]}: {recipient.description}\n </span>\n </li>\n )\n })}\n </ul>\n </section>\n )\n}\n","import type { ReactNode } from 'react'\nimport DOMPurify from 'dompurify'\nimport { Archive, ArrowLeft, Forward, Paperclip, Reply, Trash2 } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport type {\n MailAccount,\n MailAddress,\n MailAttachment,\n MailFolder,\n MailMessage,\n MailMessageUpdate,\n} from '@arbidocs/react'\nimport { MailDeliveryBadge } from './MailMessagePreview'\nimport { MailDeliveryList } from './MailDeliveryList'\nimport { hasCalendarPart, mailAddressLabel } from './mailCompose'\n\n/** Why an action that changes the mailbox on the server can't run right now. */\nexport const NEEDS_CONNECTION = 'Available when you are back online'\n\nexport interface MailMessageViewProps {\n account: MailAccount\n message: MailMessage\n folderRole: string\n folders: MailFolder[] | undefined\n isOnline: boolean\n loading: boolean\n uploadPending?: boolean\n onBack: () => void\n onEditDraft: () => void\n onReply: (forward?: boolean, all?: boolean) => void\n onUpdate: (body: MailMessageUpdate) => void\n onDownloadAttachment: (attachment: MailAttachment) => void\n onDownloadOriginal: () => void\n /** Native mail: save the email to a workspace. Absent: not offered. */\n onSaveToWorkspace?: () => void\n /** How a person is named (default: the name on the message, else the address). */\n personLabel?: (person: MailAddress) => string\n /** A calendar invite card, for a message that carries an .ics part. */\n renderInvite?: () => ReactNode\n}\n\nconst SANITIZE = {\n ALLOWED_TAGS: [\n 'p',\n 'br',\n 'strong',\n 'b',\n 'em',\n 'i',\n 'u',\n 's',\n 'ul',\n 'ol',\n 'li',\n 'a',\n 'span',\n 'blockquote',\n ],\n ALLOWED_ATTR: ['href'],\n ALLOW_DATA_ATTR: false,\n}\n\n/** An opened message: its actions, sender, recipients, delivery, attachments and body. */\nexport function MailMessageView({\n account,\n message,\n folderRole,\n folders,\n isOnline,\n loading,\n uploadPending,\n onBack,\n onEditDraft,\n onReply,\n onUpdate,\n onDownloadAttachment,\n onDownloadOriginal,\n onSaveToWorkspace,\n personLabel = mailAddressLabel,\n renderInvite,\n}: MailMessageViewProps) {\n // Moving, marking and saving change the server's mailbox; offline they are unavailable, with why.\n const offlineTitle = isOnline ? undefined : NEEDS_CONNECTION\n return (\n <article className=\"min-w-0 flex-1 overflow-auto p-4 sm:p-5\">\n <Button className=\"mb-3\" variant=\"ghost\" onClick={onBack}>\n <ArrowLeft className=\"mr-2 size-4\" />\n Back\n </Button>\n {loading && <p className=\"text-muted-foreground\">Loading message…</p>}\n <div className=\"-mx-4 mb-5 flex flex-wrap items-center gap-1 border-b bg-muted/20 px-3 py-1.5 sm:-mx-5 [&_button]:h-8 [&_button]:px-2 [&_button]:text-xs\">\n {folderRole === 'drafts' ? (\n <Button onClick={onEditDraft}>Edit draft</Button>\n ) : (\n <>\n <Button variant=\"ghost\" onClick={() => onReply()}>\n <Reply className=\"mr-2 size-4\" />\n Reply\n </Button>\n {message.to.length + message.cc.length > 1 && (\n <Button variant=\"ghost\" onClick={() => onReply(false, true)}>\n Reply all\n </Button>\n )}\n <Button variant=\"ghost\" onClick={() => onReply(true)}>\n <Forward className=\"mr-2 size-4\" />\n Forward\n </Button>\n </>\n )}\n <Button\n variant=\"ghost\"\n disabled={!isOnline}\n title={offlineTitle}\n onClick={() => onUpdate({ unread: !message.unread })}\n >\n {message.unread ? 'Mark read' : 'Mark unread'}\n </Button>\n {(folderRole === 'archive' || folderRole === 'trash') && (\n <Button\n variant=\"ghost\"\n disabled={!isOnline}\n title={offlineTitle}\n onClick={() =>\n onUpdate({ folder_id: folders?.find((f) => f.role === 'inbox')?.id ?? 'inbox' })\n }\n >\n Move to Inbox\n </Button>\n )}\n <Button\n variant=\"ghost\"\n aria-label=\"Archive message\"\n disabled={!isOnline}\n title={offlineTitle}\n onClick={() =>\n onUpdate({ folder_id: folders?.find((f) => f.role === 'archive')?.id ?? 'archive' })\n }\n >\n <Archive className=\"size-4\" />\n </Button>\n <Button\n variant=\"ghost\"\n aria-label=\"Trash message\"\n disabled={!isOnline}\n title={offlineTitle}\n onClick={() => onUpdate({ action: 'trash' })}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n </div>\n <div className=\"mb-4 flex flex-wrap items-center gap-2\">\n <h2 className=\"text-xl font-semibold leading-snug tracking-tight\">\n {message.subject || '(No subject)'}\n </h2>\n {(message.delivery_status === 'bounced' ||\n message.delivery_status === 'partially_bounced' ||\n message.delivery_status === 'delayed') && (\n <MailDeliveryBadge problem={message.delivery_status} />\n )}\n </div>\n <div className=\"mb-5 flex gap-3 border-b border-border/60 pb-4\">\n <span\n aria-hidden=\"true\"\n className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-primary/10 text-sm font-semibold text-primary\"\n >\n {(message.sender[0]?.name || message.sender[0]?.email || '?')\n .split(/\\s+/)\n .slice(0, 2)\n .map((part) => part[0])\n .join('')\n .toUpperCase()}\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-baseline justify-between gap-1\">\n <p className=\"text-sm font-semibold\">\n {message.sender.map((person) => person.name || person.email).join(', ')}\n </p>\n <time className=\"text-[11px] text-muted-foreground\">\n {message.received_at ? new Date(message.received_at).toLocaleString() : ''}\n </time>\n </div>\n <p className=\"break-all text-xs text-muted-foreground\">\n {message.sender.map((person) => person.email).join(', ')}\n </p>\n <p className=\"mt-2 break-all text-xs text-muted-foreground\">\n To: {message.to.map(personLabel).join(', ')}\n {message.cc.length > 0 && ` · Cc: ${message.cc.map(personLabel).join(', ')}`}\n </p>\n </div>\n </div>\n <MailDeliveryList recipients={message.delivery ?? []} />\n {renderInvite && hasCalendarPart(message.attachments) && renderInvite()}\n <div className=\"mb-4 flex flex-wrap gap-2\">\n {message.attachments.map((a) => (\n <Button\n key={a.id}\n className=\"h-auto min-h-12 justify-start rounded-md border-border/70 bg-muted/20 px-3 py-2 text-left shadow-none hover:bg-muted/60\"\n variant=\"outline\"\n onClick={() => onDownloadAttachment(a)}\n >\n <Paperclip className=\"mr-2 size-4\" />\n <span className=\"min-w-0\">\n <span className=\"block truncate text-xs font-medium\">{a.name}</span>\n <span\n aria-hidden=\"true\"\n className=\"block text-[11px] font-normal text-muted-foreground\"\n >\n {a.size < 1024 ? `${a.size} B` : `${Math.ceil(a.size / 1024)} KB`}\n </span>\n </span>\n </Button>\n ))}\n </div>\n {message.html && message.text ? (\n <div\n className=\"text-sm leading-7 [&_p]:mb-3 [&_ul]:list-disc [&_ul]:pl-6 [&_ol]:list-decimal [&_ol]:pl-6 [&_a]:text-primary [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(message.html, SANITIZE) }}\n />\n ) : message.text ? (\n <pre className=\"whitespace-pre-wrap break-words font-sans text-sm leading-7 text-foreground/90\">\n {message.text.split(/(https?:\\/\\/[^\\s]+)/g).map((part, index) =>\n /^https?:\\/\\//.test(part) ? (\n <a\n key={index}\n href={part}\n className=\"text-primary underline underline-offset-2\"\n rel=\"noreferrer\"\n >\n {part}\n </a>\n ) : (\n part\n )\n )}\n </pre>\n ) : message.html ? (\n <iframe\n title=\"Email body\"\n sandbox=\"\"\n referrerPolicy=\"no-referrer\"\n className=\"min-h-96 w-full border-0 bg-white\"\n srcDoc={`<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; img-src data:; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'\">${message.html}`}\n />\n ) : (\n <p className=\"text-muted-foreground\">Empty message</p>\n )}\n {account.provider === 'native' && (\n <div className=\"flex flex-wrap gap-2\">\n <Button\n className=\"mt-5\"\n variant=\"outline\"\n disabled={!isOnline}\n title={offlineTitle}\n onClick={onDownloadOriginal}\n >\n Download original email\n </Button>\n {onSaveToWorkspace && (\n <Button\n className=\"mt-5\"\n variant=\"outline\"\n disabled={uploadPending || !isOnline}\n title={offlineTitle}\n onClick={onSaveToWorkspace}\n >\n Save to workspace\n </Button>\n )}\n </div>\n )}\n </article>\n )\n}\n","import { useMemo, useState, type ReactNode } from 'react'\nimport { FolderOpen } from 'lucide-react'\nimport {\n Button,\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@arbidocs/react/ui'\n\n/** A workspace document that can be attached to an email. */\nexport interface MailAttachableDocument {\n id: string\n title: string\n /** Its file-type icon. */\n icon?: ReactNode\n}\n\nexport interface MailDocumentPickerProps {\n documents: MailAttachableDocument[]\n onAttach: (document: MailAttachableDocument) => void\n disabled?: boolean\n}\n\n/** \"From workspace\": a searchable list of the workspace's documents, attached as their files. */\nexport function MailDocumentPicker({\n documents,\n onAttach,\n disabled = false,\n}: MailDocumentPickerProps): React.ReactElement {\n const [open, setOpen] = useState(false)\n const [query, setQuery] = useState('')\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase()\n return q ? documents.filter((d) => d.title.toLowerCase().includes(q)) : documents\n }, [documents, query])\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n disabled={disabled}\n data-testid=\"mail-attach-workspace-document\"\n >\n <FolderOpen className=\"mr-2 size-4\" />\n From workspace\n </Button>\n </PopoverTrigger>\n <PopoverContent className=\"w-80 p-0\" align=\"start\" sideOffset={4}>\n <Command shouldFilter={false}>\n <CommandInput placeholder=\"Search documents...\" value={query} onValueChange={setQuery} />\n <CommandList className=\"max-h-72\">\n <CommandEmpty>No documents in this workspace</CommandEmpty>\n <CommandGroup>\n {filtered.map((doc) => (\n <CommandItem\n key={doc.id}\n value={doc.id}\n onSelect={() => {\n setOpen(false)\n setQuery('')\n onAttach(doc)\n }}\n data-testid={`document-search-item-${doc.id}`}\n >\n {doc.icon && <span className=\"shrink-0 text-muted-foreground\">{doc.icon}</span>}\n <span className=\"ml-1.5 flex-1 truncate text-sm\">{doc.title}</span>\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n","export interface MailBodyEditorProps {\n text: string\n html?: string\n disabled: boolean\n /** Every edit: the plain text and, from the rich editor, its HTML (`''` from this one). */\n onChange: (text: string, html: string) => void\n}\n\n/**\n * The message body as plain text: used when the rich editor (an optional peer, `lexical`) is not\n * installed or could not be loaded.\n */\nexport function PlainMailBodyEditor({ text, disabled, onChange }: MailBodyEditorProps) {\n return (\n <textarea\n aria-label=\"Message\"\n className=\"my-3 min-h-48 w-full resize-y bg-transparent text-sm outline-none\"\n value={text}\n disabled={disabled}\n onChange={(event) => onChange(event.target.value, '')}\n />\n )\n}\n"]}
|