@poolse/react-ui 0.2.0-alpha.3 → 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 +41 -0
- package/dist/index.cjs +277 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -9
- package/dist/index.d.ts +69 -9
- package/dist/index.js +277 -65
- package/dist/index.js.map +1 -1
- package/dist/styles.css +213 -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,8 @@ function ReactionPicker({
|
|
|
766
883
|
function MessageActions({
|
|
767
884
|
onReact,
|
|
768
885
|
onReply,
|
|
886
|
+
onQuote,
|
|
887
|
+
onCopy,
|
|
769
888
|
onEdit,
|
|
770
889
|
onDelete,
|
|
771
890
|
children
|
|
@@ -793,7 +912,9 @@ function MessageActions({
|
|
|
793
912
|
}
|
|
794
913
|
) })
|
|
795
914
|
] }),
|
|
796
|
-
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 }),
|
|
917
|
+
onCopy && /* @__PURE__ */ jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
797
918
|
onEdit && /* @__PURE__ */ jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
798
919
|
onDelete && /* @__PURE__ */ jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
799
920
|
children
|
|
@@ -820,13 +941,17 @@ function MessageRow({
|
|
|
820
941
|
attachments = true,
|
|
821
942
|
actions = true,
|
|
822
943
|
threads = true,
|
|
944
|
+
quotations = true,
|
|
823
945
|
readState,
|
|
824
946
|
editing = false,
|
|
825
947
|
onStartEdit,
|
|
826
948
|
onCancelEdit,
|
|
827
949
|
onSaveEdit,
|
|
828
950
|
onDelete,
|
|
829
|
-
onOpenThread
|
|
951
|
+
onOpenThread,
|
|
952
|
+
onQuote,
|
|
953
|
+
labelFor,
|
|
954
|
+
onQuotedClick
|
|
830
955
|
}) {
|
|
831
956
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
832
957
|
const reactionsHook = useReactions(reactions ? msg.id : "", {
|
|
@@ -837,6 +962,8 @@ function MessageRow({
|
|
|
837
962
|
const showReactions = reactions && !msg.deleted_at;
|
|
838
963
|
const showAttachments = attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
|
|
839
964
|
const showActions = actions && !msg.deleted_at && !editing;
|
|
965
|
+
const replyCount = msg.reply_count ?? 0;
|
|
966
|
+
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
840
967
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
841
968
|
const handleCancel = onCancelEdit ?? (() => void 0);
|
|
842
969
|
return /* @__PURE__ */ jsxs("div", { className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`, children: [
|
|
@@ -850,7 +977,16 @@ function MessageRow({
|
|
|
850
977
|
onSave: handleSave,
|
|
851
978
|
onCancel: handleCancel
|
|
852
979
|
}
|
|
853
|
-
) : /* @__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
|
+
),
|
|
854
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)) }),
|
|
855
991
|
showReactions && /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
|
|
856
992
|
InlineReactions,
|
|
@@ -861,6 +997,23 @@ function MessageRow({
|
|
|
861
997
|
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
862
998
|
}
|
|
863
999
|
) }),
|
|
1000
|
+
showThreadPill && /* @__PURE__ */ jsxs(
|
|
1001
|
+
"button",
|
|
1002
|
+
{
|
|
1003
|
+
type: "button",
|
|
1004
|
+
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
1005
|
+
onClick: onOpenThread,
|
|
1006
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
1007
|
+
children: [
|
|
1008
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
1009
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1010
|
+
replyCount,
|
|
1011
|
+
" ",
|
|
1012
|
+
replyCount === 1 ? "reply" : "replies"
|
|
1013
|
+
] })
|
|
1014
|
+
]
|
|
1015
|
+
}
|
|
1016
|
+
),
|
|
864
1017
|
showActions && /* @__PURE__ */ jsx(
|
|
865
1018
|
"div",
|
|
866
1019
|
{
|
|
@@ -874,6 +1027,12 @@ function MessageRow({
|
|
|
874
1027
|
}
|
|
875
1028
|
} : {},
|
|
876
1029
|
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1030
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
1031
|
+
...msg.body ? {
|
|
1032
|
+
onCopy: () => {
|
|
1033
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
1034
|
+
}
|
|
1035
|
+
} : {},
|
|
877
1036
|
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
878
1037
|
...isSelf && onDelete ? { onDelete } : {}
|
|
879
1038
|
}
|
|
@@ -999,6 +1158,7 @@ function ConversationView({
|
|
|
999
1158
|
attachments = TRUE,
|
|
1000
1159
|
actions = TRUE,
|
|
1001
1160
|
threads = TRUE,
|
|
1161
|
+
quotations = TRUE,
|
|
1002
1162
|
readReceipts = TRUE,
|
|
1003
1163
|
onMarkedRead
|
|
1004
1164
|
}) {
|
|
@@ -1098,6 +1258,21 @@ function ConversationView({
|
|
|
1098
1258
|
() => threadRootId ? messages.find((m) => m.id === threadRootId) ?? null : null,
|
|
1099
1259
|
[threadRootId, messages]
|
|
1100
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
|
+
};
|
|
1101
1276
|
const { upload, uploading } = useAttachmentUpload();
|
|
1102
1277
|
const onPickFile = async (file) => {
|
|
1103
1278
|
try {
|
|
@@ -1112,20 +1287,35 @@ function ConversationView({
|
|
|
1112
1287
|
console.error("attachment upload failed:", err);
|
|
1113
1288
|
}
|
|
1114
1289
|
};
|
|
1115
|
-
const onSendBody = async (body) => {
|
|
1116
|
-
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);
|
|
1117
1296
|
};
|
|
1118
1297
|
const onSendWithMentions = async (req) => {
|
|
1119
1298
|
await send(req);
|
|
1299
|
+
setReplyingTo(null);
|
|
1120
1300
|
};
|
|
1121
1301
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsx(
|
|
1122
1302
|
MentionInput,
|
|
1123
1303
|
{
|
|
1124
1304
|
conversationId,
|
|
1125
1305
|
onSend: onSendWithMentions,
|
|
1126
|
-
onTyping: signalTyping
|
|
1306
|
+
onTyping: signalTyping,
|
|
1307
|
+
...labelFor ? { labelFor } : {},
|
|
1308
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1309
|
+
}
|
|
1310
|
+
) : /* @__PURE__ */ jsx(
|
|
1311
|
+
MessageComposer,
|
|
1312
|
+
{
|
|
1313
|
+
onSend: onSendBody,
|
|
1314
|
+
onTyping: signalTyping,
|
|
1315
|
+
...labelFor ? { labelFor } : {},
|
|
1316
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1127
1317
|
}
|
|
1128
|
-
)
|
|
1318
|
+
);
|
|
1129
1319
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
1130
1320
|
/* @__PURE__ */ jsxs("div", { className: "poolse-conversation", children: [
|
|
1131
1321
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__status", children: [
|
|
@@ -1141,7 +1331,7 @@ function ConversationView({
|
|
|
1141
1331
|
}
|
|
1142
1332
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1143
1333
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1144
|
-
return /* @__PURE__ */ jsx(
|
|
1334
|
+
return /* @__PURE__ */ jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsx(
|
|
1145
1335
|
MessageRow,
|
|
1146
1336
|
{
|
|
1147
1337
|
msg,
|
|
@@ -1150,7 +1340,9 @@ function ConversationView({
|
|
|
1150
1340
|
attachments,
|
|
1151
1341
|
actions,
|
|
1152
1342
|
threads,
|
|
1343
|
+
quotations,
|
|
1153
1344
|
...readState ? { readState } : {},
|
|
1345
|
+
...labelFor ? { labelFor } : {},
|
|
1154
1346
|
editing: editingId === msg.id,
|
|
1155
1347
|
onStartEdit: () => setEditingId(msg.id),
|
|
1156
1348
|
onCancelEdit: () => setEditingId(null),
|
|
@@ -1159,10 +1351,11 @@ function ConversationView({
|
|
|
1159
1351
|
setEditingId(null);
|
|
1160
1352
|
},
|
|
1161
1353
|
onDelete: () => void deleteMsg(msg.id),
|
|
1162
|
-
onOpenThread: () => setThreadRootId(msg.id)
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1354
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
1355
|
+
onQuote: () => setReplyingTo(msg),
|
|
1356
|
+
onQuotedClick: scrollToOriginal
|
|
1357
|
+
}
|
|
1358
|
+
) }, msg.id);
|
|
1166
1359
|
}),
|
|
1167
1360
|
error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1168
1361
|
"Failed to load: ",
|
|
@@ -1258,13 +1451,15 @@ function ConversationList({
|
|
|
1258
1451
|
emptyState,
|
|
1259
1452
|
conversations: controlledConversations,
|
|
1260
1453
|
loading: controlledLoading,
|
|
1261
|
-
error: controlledError
|
|
1454
|
+
error: controlledError,
|
|
1455
|
+
unreadCounts
|
|
1262
1456
|
}) {
|
|
1263
1457
|
const auto = useConversations();
|
|
1264
1458
|
const isControlled = controlledConversations !== void 0;
|
|
1265
1459
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
1266
1460
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
1267
1461
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
1462
|
+
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
1268
1463
|
if (loading && conversations.length === 0) {
|
|
1269
1464
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading conversations\u2026" });
|
|
1270
1465
|
}
|
|
@@ -1276,7 +1471,8 @@ function ConversationList({
|
|
|
1276
1471
|
}
|
|
1277
1472
|
return /* @__PURE__ */ jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
1278
1473
|
const selected = selectedId === conv.id;
|
|
1279
|
-
const
|
|
1474
|
+
const unread = counts?.[conv.id] ?? 0;
|
|
1475
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsx(DefaultRow, { conv, selected, unread });
|
|
1280
1476
|
return /* @__PURE__ */ jsx(
|
|
1281
1477
|
"li",
|
|
1282
1478
|
{
|
|
@@ -1297,18 +1493,31 @@ function ConversationList({
|
|
|
1297
1493
|
);
|
|
1298
1494
|
}) });
|
|
1299
1495
|
}
|
|
1300
|
-
function DefaultRow({
|
|
1496
|
+
function DefaultRow({
|
|
1497
|
+
conv,
|
|
1498
|
+
selected: _selected,
|
|
1499
|
+
unread
|
|
1500
|
+
}) {
|
|
1301
1501
|
const title = conv.name ?? "Untitled conversation";
|
|
1302
1502
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
1503
|
+
const hasUnread = unread > 0;
|
|
1303
1504
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1304
1505
|
/* @__PURE__ */ jsx(Avatar, { src: conv.avatar_url ?? null, name: conv.name, size: "md" }),
|
|
1305
1506
|
/* @__PURE__ */ jsxs("div", { className: "poolse-list__body", children: [
|
|
1306
1507
|
/* @__PURE__ */ jsxs("div", { className: "poolse-list__head", children: [
|
|
1307
|
-
/* @__PURE__ */ jsx("span", { className: "poolse-list__title"
|
|
1508
|
+
/* @__PURE__ */ jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
1308
1509
|
time && /* @__PURE__ */ jsx("span", { className: "poolse-list__time", children: time })
|
|
1309
1510
|
] }),
|
|
1310
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" })
|
|
1311
|
-
] })
|
|
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
|
+
)
|
|
1312
1521
|
] });
|
|
1313
1522
|
}
|
|
1314
1523
|
function formatRelative(iso) {
|
|
@@ -1334,7 +1543,10 @@ function MemberList({
|
|
|
1334
1543
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
|
|
1335
1544
|
}
|
|
1336
1545
|
if (error) {
|
|
1337
|
-
return /* @__PURE__ */
|
|
1546
|
+
return /* @__PURE__ */ jsxs("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: [
|
|
1547
|
+
/* @__PURE__ */ jsx("div", { children: "Failed to load members." }),
|
|
1548
|
+
error.message && /* @__PURE__ */ jsx("div", { className: "poolse-list__error-detail", children: /* @__PURE__ */ jsx("code", { children: error.message }) })
|
|
1549
|
+
] });
|
|
1338
1550
|
}
|
|
1339
1551
|
if (members.length === 0) {
|
|
1340
1552
|
return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState ?? "No members yet." });
|