@poolse/react-ui 0.2.0-alpha.4 → 0.2.0-alpha.6
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/CHANGELOG.md +25 -0
- package/dist/index.cjs +247 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -9
- package/dist/index.d.ts +67 -9
- package/dist/index.js +247 -64
- package/dist/index.js.map +1 -1
- package/dist/styles.css +165 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -250,7 +250,9 @@ function MentionInput({
|
|
|
250
250
|
onTyping,
|
|
251
251
|
placeholder = "Type a message\u2026",
|
|
252
252
|
disabled = false,
|
|
253
|
-
labelFor
|
|
253
|
+
labelFor,
|
|
254
|
+
replyingTo,
|
|
255
|
+
onCancelReply
|
|
254
256
|
}) {
|
|
255
257
|
const { members } = useMembers(conversationId);
|
|
256
258
|
const [value, setValue] = useState("");
|
|
@@ -272,7 +274,8 @@ function MentionInput({
|
|
|
272
274
|
const mentions = Array.from(selectedMentions.current);
|
|
273
275
|
await onSend({
|
|
274
276
|
body: trimmed,
|
|
275
|
-
...mentions.length > 0 ? { mentions } : {}
|
|
277
|
+
...mentions.length > 0 ? { mentions } : {},
|
|
278
|
+
...replyingTo ? { quoted_message_id: replyingTo.id } : {}
|
|
276
279
|
});
|
|
277
280
|
setValue("");
|
|
278
281
|
selectedMentions.current = /* @__PURE__ */ new Set();
|
|
@@ -348,7 +351,12 @@ function MentionInput({
|
|
|
348
351
|
e.preventDefault();
|
|
349
352
|
void submit();
|
|
350
353
|
}
|
|
354
|
+
if (e.key === "Escape" && replyingTo && onCancelReply && !mention) {
|
|
355
|
+
e.preventDefault();
|
|
356
|
+
onCancelReply();
|
|
357
|
+
}
|
|
351
358
|
};
|
|
359
|
+
const replyLabel = replyingTo?.sender_id ? labelFor?.(replyingTo.sender_id) ?? `User ${replyingTo.sender_id.slice(0, 6)}` : "Unknown";
|
|
352
360
|
return /* @__PURE__ */ jsxs(
|
|
353
361
|
"form",
|
|
354
362
|
{
|
|
@@ -359,29 +367,51 @@ function MentionInput({
|
|
|
359
367
|
},
|
|
360
368
|
style: { position: "relative" },
|
|
361
369
|
children: [
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
"
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
370
|
+
replyingTo && /* @__PURE__ */ jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
371
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
372
|
+
/* @__PURE__ */ jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
373
|
+
"Replying to ",
|
|
374
|
+
replyLabel
|
|
375
|
+
] }),
|
|
376
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-composer__reply-preview", children: replyingTo.body ?? "" })
|
|
377
|
+
] }),
|
|
378
|
+
onCancelReply && /* @__PURE__ */ jsx(
|
|
379
|
+
"button",
|
|
380
|
+
{
|
|
381
|
+
type: "button",
|
|
382
|
+
className: "poolse-composer__reply-cancel",
|
|
383
|
+
onClick: onCancelReply,
|
|
384
|
+
"aria-label": "Cancel reply",
|
|
385
|
+
title: "Cancel reply",
|
|
386
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
387
|
+
}
|
|
388
|
+
)
|
|
389
|
+
] }),
|
|
390
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-composer__row", children: [
|
|
391
|
+
/* @__PURE__ */ jsx(
|
|
392
|
+
"textarea",
|
|
393
|
+
{
|
|
394
|
+
ref: taRef,
|
|
395
|
+
className: "poolse-composer__input",
|
|
396
|
+
rows: 1,
|
|
397
|
+
value,
|
|
398
|
+
onChange,
|
|
399
|
+
onKeyDown,
|
|
400
|
+
placeholder,
|
|
401
|
+
disabled: disabled || sending
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
/* @__PURE__ */ jsx(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
type: "submit",
|
|
408
|
+
className: "poolse-composer__send",
|
|
409
|
+
disabled: disabled || sending || value.trim() === "",
|
|
410
|
+
"aria-label": "Send message",
|
|
411
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
] }),
|
|
385
415
|
mention && filtered.length > 0 && /* @__PURE__ */ jsx("div", { className: "poolse-mention-menu", role: "listbox", "aria-label": "Members", children: filtered.map((m, i) => /* @__PURE__ */ jsx(
|
|
386
416
|
"div",
|
|
387
417
|
{
|
|
@@ -407,7 +437,10 @@ function MessageComposer({
|
|
|
407
437
|
onSend,
|
|
408
438
|
onTyping,
|
|
409
439
|
placeholder = "Type a message\u2026",
|
|
410
|
-
disabled = false
|
|
440
|
+
disabled = false,
|
|
441
|
+
replyingTo,
|
|
442
|
+
onCancelReply,
|
|
443
|
+
labelFor
|
|
411
444
|
}) {
|
|
412
445
|
const [value, setValue] = useState("");
|
|
413
446
|
const [sending, setSending] = useState(false);
|
|
@@ -416,7 +449,10 @@ function MessageComposer({
|
|
|
416
449
|
if (!trimmed || sending) return;
|
|
417
450
|
setSending(true);
|
|
418
451
|
try {
|
|
419
|
-
await onSend(
|
|
452
|
+
await onSend(
|
|
453
|
+
trimmed,
|
|
454
|
+
replyingTo ? { quoted_message_id: replyingTo.id } : void 0
|
|
455
|
+
);
|
|
420
456
|
setValue("");
|
|
421
457
|
} finally {
|
|
422
458
|
setSending(false);
|
|
@@ -427,6 +463,10 @@ function MessageComposer({
|
|
|
427
463
|
e.preventDefault();
|
|
428
464
|
void submit();
|
|
429
465
|
}
|
|
466
|
+
if (e.key === "Escape" && replyingTo && onCancelReply) {
|
|
467
|
+
e.preventDefault();
|
|
468
|
+
onCancelReply();
|
|
469
|
+
}
|
|
430
470
|
};
|
|
431
471
|
const onChange = (e) => {
|
|
432
472
|
setValue(e.target.value);
|
|
@@ -441,32 +481,70 @@ function MessageComposer({
|
|
|
441
481
|
void submit();
|
|
442
482
|
},
|
|
443
483
|
children: [
|
|
444
|
-
/* @__PURE__ */ jsx(
|
|
445
|
-
|
|
484
|
+
replyingTo && /* @__PURE__ */ jsx(
|
|
485
|
+
ReplyChip,
|
|
446
486
|
{
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
onChange,
|
|
451
|
-
onKeyDown,
|
|
452
|
-
placeholder,
|
|
453
|
-
disabled: disabled || sending
|
|
487
|
+
message: replyingTo,
|
|
488
|
+
...labelFor ? { labelFor } : {},
|
|
489
|
+
...onCancelReply ? { onCancel: onCancelReply } : {}
|
|
454
490
|
}
|
|
455
491
|
),
|
|
456
|
-
/* @__PURE__ */
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
492
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-composer__row", children: [
|
|
493
|
+
/* @__PURE__ */ jsx(
|
|
494
|
+
"textarea",
|
|
495
|
+
{
|
|
496
|
+
className: "poolse-composer__input",
|
|
497
|
+
rows: 1,
|
|
498
|
+
value,
|
|
499
|
+
onChange,
|
|
500
|
+
onKeyDown,
|
|
501
|
+
placeholder,
|
|
502
|
+
disabled: disabled || sending
|
|
503
|
+
}
|
|
504
|
+
),
|
|
505
|
+
/* @__PURE__ */ jsx(
|
|
506
|
+
"button",
|
|
507
|
+
{
|
|
508
|
+
type: "submit",
|
|
509
|
+
className: "poolse-composer__send",
|
|
510
|
+
disabled: disabled || sending || value.trim() === "",
|
|
511
|
+
"aria-label": "Send message",
|
|
512
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
] })
|
|
466
516
|
]
|
|
467
517
|
}
|
|
468
518
|
);
|
|
469
519
|
}
|
|
520
|
+
function ReplyChip({
|
|
521
|
+
message,
|
|
522
|
+
labelFor,
|
|
523
|
+
onCancel
|
|
524
|
+
}) {
|
|
525
|
+
const senderLabel = message.sender_id ? labelFor?.(message.sender_id) ?? `User ${message.sender_id.slice(0, 6)}` : "Unknown";
|
|
526
|
+
const preview = message.body ?? "";
|
|
527
|
+
return /* @__PURE__ */ jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
528
|
+
/* @__PURE__ */ jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
529
|
+
/* @__PURE__ */ jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
530
|
+
"Replying to ",
|
|
531
|
+
senderLabel
|
|
532
|
+
] }),
|
|
533
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-composer__reply-preview", children: preview })
|
|
534
|
+
] }),
|
|
535
|
+
onCancel && /* @__PURE__ */ jsx(
|
|
536
|
+
"button",
|
|
537
|
+
{
|
|
538
|
+
type: "button",
|
|
539
|
+
className: "poolse-composer__reply-cancel",
|
|
540
|
+
onClick: onCancel,
|
|
541
|
+
"aria-label": "Cancel reply",
|
|
542
|
+
title: "Cancel reply",
|
|
543
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
544
|
+
}
|
|
545
|
+
)
|
|
546
|
+
] });
|
|
547
|
+
}
|
|
470
548
|
function AttachmentPreview({ attachment, onClick }) {
|
|
471
549
|
const isFullRow = "content_type" in attachment;
|
|
472
550
|
const { url, loading, error } = useAttachmentUrl(attachment.id);
|
|
@@ -561,7 +639,13 @@ function formatBytes(n) {
|
|
|
561
639
|
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
562
640
|
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
563
641
|
}
|
|
564
|
-
function MessageBubble({
|
|
642
|
+
function MessageBubble({
|
|
643
|
+
message,
|
|
644
|
+
currentUserId,
|
|
645
|
+
readState,
|
|
646
|
+
labelFor,
|
|
647
|
+
onQuotedClick
|
|
648
|
+
}) {
|
|
565
649
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
566
650
|
const className = [
|
|
567
651
|
"poolse-message",
|
|
@@ -572,6 +656,15 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
572
656
|
minute: "2-digit"
|
|
573
657
|
}) : "";
|
|
574
658
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
659
|
+
message.quoted_message && /* @__PURE__ */ jsx(
|
|
660
|
+
QuotedCard,
|
|
661
|
+
{
|
|
662
|
+
quoted: message.quoted_message,
|
|
663
|
+
isSelf,
|
|
664
|
+
...labelFor ? { labelFor } : {},
|
|
665
|
+
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
666
|
+
}
|
|
667
|
+
),
|
|
575
668
|
message.deleted_at ? /* @__PURE__ */ jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsx("span", { children: message.body ?? "" }),
|
|
576
669
|
/* @__PURE__ */ jsxs("span", { className: "poolse-message__meta", children: [
|
|
577
670
|
/* @__PURE__ */ jsx("span", { children: time }),
|
|
@@ -587,6 +680,30 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
587
680
|
] })
|
|
588
681
|
] });
|
|
589
682
|
}
|
|
683
|
+
function QuotedCard({
|
|
684
|
+
quoted,
|
|
685
|
+
isSelf,
|
|
686
|
+
labelFor,
|
|
687
|
+
onClick
|
|
688
|
+
}) {
|
|
689
|
+
const senderLabel = quoted.sender_id ? labelFor?.(quoted.sender_id) ?? `User ${quoted.sender_id.slice(0, 6)}` : "Unknown";
|
|
690
|
+
const isDeleted = !!quoted.deleted_at;
|
|
691
|
+
const handleClick = onClick ? () => onClick(quoted.id) : void 0;
|
|
692
|
+
return /* @__PURE__ */ jsxs(
|
|
693
|
+
"button",
|
|
694
|
+
{
|
|
695
|
+
type: "button",
|
|
696
|
+
className: `poolse-quote ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
|
|
697
|
+
onClick: handleClick,
|
|
698
|
+
disabled: !handleClick,
|
|
699
|
+
"aria-label": `Quoted message from ${senderLabel}`,
|
|
700
|
+
children: [
|
|
701
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-quote__sender", children: senderLabel }),
|
|
702
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-quote__body", children: isDeleted ? "Original message deleted" : quoted.body ?? "" })
|
|
703
|
+
]
|
|
704
|
+
}
|
|
705
|
+
);
|
|
706
|
+
}
|
|
590
707
|
function EditableMessageBubble({
|
|
591
708
|
message,
|
|
592
709
|
currentUserId,
|
|
@@ -766,6 +883,7 @@ function ReactionPicker({
|
|
|
766
883
|
function MessageActions({
|
|
767
884
|
onReact,
|
|
768
885
|
onReply,
|
|
886
|
+
onQuote,
|
|
769
887
|
onCopy,
|
|
770
888
|
onEdit,
|
|
771
889
|
onDelete,
|
|
@@ -794,7 +912,8 @@ function MessageActions({
|
|
|
794
912
|
}
|
|
795
913
|
) })
|
|
796
914
|
] }),
|
|
797
|
-
onReply && /* @__PURE__ */ jsx(ActionButton, { label: "Reply in thread", icon: "
|
|
915
|
+
onReply && /* @__PURE__ */ jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
916
|
+
onQuote && /* @__PURE__ */ jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
798
917
|
onCopy && /* @__PURE__ */ jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
799
918
|
onEdit && /* @__PURE__ */ jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
800
919
|
onDelete && /* @__PURE__ */ jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
@@ -822,13 +941,17 @@ function MessageRow({
|
|
|
822
941
|
attachments = true,
|
|
823
942
|
actions = true,
|
|
824
943
|
threads = true,
|
|
944
|
+
quotations = true,
|
|
825
945
|
readState,
|
|
826
946
|
editing = false,
|
|
827
947
|
onStartEdit,
|
|
828
948
|
onCancelEdit,
|
|
829
949
|
onSaveEdit,
|
|
830
950
|
onDelete,
|
|
831
|
-
onOpenThread
|
|
951
|
+
onOpenThread,
|
|
952
|
+
onQuote,
|
|
953
|
+
labelFor,
|
|
954
|
+
onQuotedClick
|
|
832
955
|
}) {
|
|
833
956
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
834
957
|
const reactionsHook = useReactions(reactions ? msg.id : "", {
|
|
@@ -854,7 +977,16 @@ function MessageRow({
|
|
|
854
977
|
onSave: handleSave,
|
|
855
978
|
onCancel: handleCancel
|
|
856
979
|
}
|
|
857
|
-
) : /* @__PURE__ */ jsx(
|
|
980
|
+
) : /* @__PURE__ */ jsx(
|
|
981
|
+
MessageBubble,
|
|
982
|
+
{
|
|
983
|
+
message: msg,
|
|
984
|
+
currentUserId: meId,
|
|
985
|
+
...readState ? { readState } : {},
|
|
986
|
+
...labelFor ? { labelFor } : {},
|
|
987
|
+
...onQuotedClick ? { onQuotedClick } : {}
|
|
988
|
+
}
|
|
989
|
+
),
|
|
858
990
|
showAttachments && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
859
991
|
showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
|
|
860
992
|
InlineReactions,
|
|
@@ -895,6 +1027,7 @@ function MessageRow({
|
|
|
895
1027
|
}
|
|
896
1028
|
} : {},
|
|
897
1029
|
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1030
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
898
1031
|
...msg.body ? {
|
|
899
1032
|
onCopy: () => {
|
|
900
1033
|
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
@@ -1025,6 +1158,7 @@ function ConversationView({
|
|
|
1025
1158
|
attachments = TRUE,
|
|
1026
1159
|
actions = TRUE,
|
|
1027
1160
|
threads = TRUE,
|
|
1161
|
+
quotations = TRUE,
|
|
1028
1162
|
readReceipts = TRUE,
|
|
1029
1163
|
onMarkedRead
|
|
1030
1164
|
}) {
|
|
@@ -1124,6 +1258,21 @@ function ConversationView({
|
|
|
1124
1258
|
() => threadRootId ? messages.find((m) => m.id === threadRootId) ?? null : null,
|
|
1125
1259
|
[threadRootId, messages]
|
|
1126
1260
|
);
|
|
1261
|
+
const [replyingTo, setReplyingTo] = useState(null);
|
|
1262
|
+
useEffect(() => {
|
|
1263
|
+
setReplyingTo(null);
|
|
1264
|
+
setEditingId(null);
|
|
1265
|
+
setThreadRootId(null);
|
|
1266
|
+
}, [conversationId]);
|
|
1267
|
+
const scrollToOriginal = (id) => {
|
|
1268
|
+
const root = listRef.current;
|
|
1269
|
+
if (!root) return;
|
|
1270
|
+
const el = root.querySelector(`[data-message-id="${id}"]`);
|
|
1271
|
+
if (!(el instanceof HTMLElement)) return;
|
|
1272
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1273
|
+
el.classList.add("poolse-message-row--highlight");
|
|
1274
|
+
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
1275
|
+
};
|
|
1127
1276
|
const { upload, uploading } = useAttachmentUpload();
|
|
1128
1277
|
const onPickFile = async (file) => {
|
|
1129
1278
|
try {
|
|
@@ -1138,20 +1287,35 @@ function ConversationView({
|
|
|
1138
1287
|
console.error("attachment upload failed:", err);
|
|
1139
1288
|
}
|
|
1140
1289
|
};
|
|
1141
|
-
const onSendBody = async (body) => {
|
|
1142
|
-
await send({
|
|
1290
|
+
const onSendBody = async (body, opts) => {
|
|
1291
|
+
await send({
|
|
1292
|
+
body,
|
|
1293
|
+
...opts?.quoted_message_id ? { quoted_message_id: opts.quoted_message_id } : {}
|
|
1294
|
+
});
|
|
1295
|
+
setReplyingTo(null);
|
|
1143
1296
|
};
|
|
1144
1297
|
const onSendWithMentions = async (req) => {
|
|
1145
1298
|
await send(req);
|
|
1299
|
+
setReplyingTo(null);
|
|
1146
1300
|
};
|
|
1147
1301
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsx(
|
|
1148
1302
|
MentionInput,
|
|
1149
1303
|
{
|
|
1150
1304
|
conversationId,
|
|
1151
1305
|
onSend: onSendWithMentions,
|
|
1152
|
-
onTyping: signalTyping
|
|
1306
|
+
onTyping: signalTyping,
|
|
1307
|
+
...labelFor ? { labelFor } : {},
|
|
1308
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1153
1309
|
}
|
|
1154
|
-
) : /* @__PURE__ */ jsx(
|
|
1310
|
+
) : /* @__PURE__ */ jsx(
|
|
1311
|
+
MessageComposer,
|
|
1312
|
+
{
|
|
1313
|
+
onSend: onSendBody,
|
|
1314
|
+
onTyping: signalTyping,
|
|
1315
|
+
...labelFor ? { labelFor } : {},
|
|
1316
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1317
|
+
}
|
|
1318
|
+
);
|
|
1155
1319
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
1156
1320
|
/* @__PURE__ */ jsxs("div", { className: "poolse-conversation", children: [
|
|
1157
1321
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__status", children: [
|
|
@@ -1167,7 +1331,7 @@ function ConversationView({
|
|
|
1167
1331
|
}
|
|
1168
1332
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1169
1333
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1170
|
-
return /* @__PURE__ */ jsx(
|
|
1334
|
+
return /* @__PURE__ */ jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsx(
|
|
1171
1335
|
MessageRow,
|
|
1172
1336
|
{
|
|
1173
1337
|
msg,
|
|
@@ -1176,7 +1340,9 @@ function ConversationView({
|
|
|
1176
1340
|
attachments,
|
|
1177
1341
|
actions,
|
|
1178
1342
|
threads,
|
|
1343
|
+
quotations,
|
|
1179
1344
|
...readState ? { readState } : {},
|
|
1345
|
+
...labelFor ? { labelFor } : {},
|
|
1180
1346
|
editing: editingId === msg.id,
|
|
1181
1347
|
onStartEdit: () => setEditingId(msg.id),
|
|
1182
1348
|
onCancelEdit: () => setEditingId(null),
|
|
@@ -1185,10 +1351,11 @@ function ConversationView({
|
|
|
1185
1351
|
setEditingId(null);
|
|
1186
1352
|
},
|
|
1187
1353
|
onDelete: () => void deleteMsg(msg.id),
|
|
1188
|
-
onOpenThread: () => setThreadRootId(msg.id)
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1354
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
1355
|
+
onQuote: () => setReplyingTo(msg),
|
|
1356
|
+
onQuotedClick: scrollToOriginal
|
|
1357
|
+
}
|
|
1358
|
+
) }, msg.id);
|
|
1192
1359
|
}),
|
|
1193
1360
|
error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1194
1361
|
"Failed to load: ",
|
|
@@ -1284,13 +1451,15 @@ function ConversationList({
|
|
|
1284
1451
|
emptyState,
|
|
1285
1452
|
conversations: controlledConversations,
|
|
1286
1453
|
loading: controlledLoading,
|
|
1287
|
-
error: controlledError
|
|
1454
|
+
error: controlledError,
|
|
1455
|
+
unreadCounts
|
|
1288
1456
|
}) {
|
|
1289
1457
|
const auto = useConversations();
|
|
1290
1458
|
const isControlled = controlledConversations !== void 0;
|
|
1291
1459
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
1292
1460
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
1293
1461
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
1462
|
+
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
1294
1463
|
if (loading && conversations.length === 0) {
|
|
1295
1464
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading conversations\u2026" });
|
|
1296
1465
|
}
|
|
@@ -1302,7 +1471,8 @@ function ConversationList({
|
|
|
1302
1471
|
}
|
|
1303
1472
|
return /* @__PURE__ */ jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
1304
1473
|
const selected = selectedId === conv.id;
|
|
1305
|
-
const
|
|
1474
|
+
const unread = counts?.[conv.id] ?? 0;
|
|
1475
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsx(DefaultRow, { conv, selected, unread });
|
|
1306
1476
|
return /* @__PURE__ */ jsx(
|
|
1307
1477
|
"li",
|
|
1308
1478
|
{
|
|
@@ -1323,18 +1493,31 @@ function ConversationList({
|
|
|
1323
1493
|
);
|
|
1324
1494
|
}) });
|
|
1325
1495
|
}
|
|
1326
|
-
function DefaultRow({
|
|
1496
|
+
function DefaultRow({
|
|
1497
|
+
conv,
|
|
1498
|
+
selected: _selected,
|
|
1499
|
+
unread
|
|
1500
|
+
}) {
|
|
1327
1501
|
const title = conv.name ?? "Untitled conversation";
|
|
1328
1502
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
1503
|
+
const hasUnread = unread > 0;
|
|
1329
1504
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1330
1505
|
/* @__PURE__ */ jsx(Avatar, { src: conv.avatar_url ?? null, name: conv.name, size: "md" }),
|
|
1331
1506
|
/* @__PURE__ */ jsxs("div", { className: "poolse-list__body", children: [
|
|
1332
1507
|
/* @__PURE__ */ jsxs("div", { className: "poolse-list__head", children: [
|
|
1333
|
-
/* @__PURE__ */ jsx("span", { className: "poolse-list__title"
|
|
1508
|
+
/* @__PURE__ */ jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
1334
1509
|
time && /* @__PURE__ */ jsx("span", { className: "poolse-list__time", children: time })
|
|
1335
1510
|
] }),
|
|
1336
1511
|
/* @__PURE__ */ jsx("div", { className: "poolse-list__preview", children: conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet" })
|
|
1337
|
-
] })
|
|
1512
|
+
] }),
|
|
1513
|
+
hasUnread && /* @__PURE__ */ jsx(
|
|
1514
|
+
"span",
|
|
1515
|
+
{
|
|
1516
|
+
className: "poolse-list__unread-badge",
|
|
1517
|
+
"aria-label": `${unread} unread ${unread === 1 ? "message" : "messages"}`,
|
|
1518
|
+
children: unread > 99 ? "99+" : unread
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1338
1521
|
] });
|
|
1339
1522
|
}
|
|
1340
1523
|
function formatRelative(iso) {
|