@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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ All notable changes to `@poolse/react-ui` are documented here. Format follows
|
|
|
6
6
|
|
|
7
7
|
## [0.2.0] — 2026-06-01
|
|
8
8
|
|
|
9
|
+
### Added — quote replies (WhatsApp-style)
|
|
10
|
+
|
|
11
|
+
- `<ConversationView quotations?>` (default `true`) — new feature
|
|
12
|
+
toggle. Adds a "Reply" action to the hover menu distinct from
|
|
13
|
+
"Reply in thread". Reply pre-fills the composer with a quote chip
|
|
14
|
+
above the input; on send, the new message carries `quoted_message_id`
|
|
15
|
+
and stays in the main feed (no thread promotion).
|
|
16
|
+
- `<MessageBubble>` renders a small quoted-message card above the body
|
|
17
|
+
when `message.quoted_message` is set. Click → scroll-to-original
|
|
18
|
+
with a 1.6s highlight pulse on the target row.
|
|
19
|
+
- `<MessageComposer>` + `<MentionInput>` gain controlled
|
|
20
|
+
`replyingTo?: Message` and `onCancelReply?: () => void` props.
|
|
21
|
+
Renders a quote chip above the input with an (x) to cancel; Esc
|
|
22
|
+
also dismisses.
|
|
23
|
+
- `<MessageActions>` gains `onQuote?: () => void` — wired in
|
|
24
|
+
`<MessageRow>` to call back to the caller's quote state.
|
|
25
|
+
|
|
26
|
+
### Added — unread badges on `<ConversationList>`
|
|
27
|
+
|
|
28
|
+
- `<ConversationList unreadCounts>` now accepts a per-conversation
|
|
29
|
+
unread map and renders a small Pulse Coral pill on each row when
|
|
30
|
+
`unread > 0`. Auto-falls-back to `useConversations().unreadCounts`
|
|
31
|
+
when the component runs in uncontrolled mode, so sidebars work
|
|
32
|
+
out of the box with no extra wiring.
|
|
33
|
+
|
|
9
34
|
### Added — thread pill + copy action
|
|
10
35
|
|
|
11
36
|
- `<MessageRow>` renders a subtle "💬 N replies" pill below any message
|
package/dist/index.cjs
CHANGED
|
@@ -252,7 +252,9 @@ function MentionInput({
|
|
|
252
252
|
onTyping,
|
|
253
253
|
placeholder = "Type a message\u2026",
|
|
254
254
|
disabled = false,
|
|
255
|
-
labelFor
|
|
255
|
+
labelFor,
|
|
256
|
+
replyingTo,
|
|
257
|
+
onCancelReply
|
|
256
258
|
}) {
|
|
257
259
|
const { members } = react$1.useMembers(conversationId);
|
|
258
260
|
const [value, setValue] = react.useState("");
|
|
@@ -274,7 +276,8 @@ function MentionInput({
|
|
|
274
276
|
const mentions = Array.from(selectedMentions.current);
|
|
275
277
|
await onSend({
|
|
276
278
|
body: trimmed,
|
|
277
|
-
...mentions.length > 0 ? { mentions } : {}
|
|
279
|
+
...mentions.length > 0 ? { mentions } : {},
|
|
280
|
+
...replyingTo ? { quoted_message_id: replyingTo.id } : {}
|
|
278
281
|
});
|
|
279
282
|
setValue("");
|
|
280
283
|
selectedMentions.current = /* @__PURE__ */ new Set();
|
|
@@ -350,7 +353,12 @@ function MentionInput({
|
|
|
350
353
|
e.preventDefault();
|
|
351
354
|
void submit();
|
|
352
355
|
}
|
|
356
|
+
if (e.key === "Escape" && replyingTo && onCancelReply && !mention) {
|
|
357
|
+
e.preventDefault();
|
|
358
|
+
onCancelReply();
|
|
359
|
+
}
|
|
353
360
|
};
|
|
361
|
+
const replyLabel = replyingTo?.sender_id ? labelFor?.(replyingTo.sender_id) ?? `User ${replyingTo.sender_id.slice(0, 6)}` : "Unknown";
|
|
354
362
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
355
363
|
"form",
|
|
356
364
|
{
|
|
@@ -361,29 +369,51 @@ function MentionInput({
|
|
|
361
369
|
},
|
|
362
370
|
style: { position: "relative" },
|
|
363
371
|
children: [
|
|
364
|
-
/* @__PURE__ */ jsxRuntime.
|
|
365
|
-
"
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
372
|
+
replyingTo && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
373
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
374
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
375
|
+
"Replying to ",
|
|
376
|
+
replyLabel
|
|
377
|
+
] }),
|
|
378
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-composer__reply-preview", children: replyingTo.body ?? "" })
|
|
379
|
+
] }),
|
|
380
|
+
onCancelReply && /* @__PURE__ */ jsxRuntime.jsx(
|
|
381
|
+
"button",
|
|
382
|
+
{
|
|
383
|
+
type: "button",
|
|
384
|
+
className: "poolse-composer__reply-cancel",
|
|
385
|
+
onClick: onCancelReply,
|
|
386
|
+
"aria-label": "Cancel reply",
|
|
387
|
+
title: "Cancel reply",
|
|
388
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
389
|
+
}
|
|
390
|
+
)
|
|
391
|
+
] }),
|
|
392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
393
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
394
|
+
"textarea",
|
|
395
|
+
{
|
|
396
|
+
ref: taRef,
|
|
397
|
+
className: "poolse-composer__input",
|
|
398
|
+
rows: 1,
|
|
399
|
+
value,
|
|
400
|
+
onChange,
|
|
401
|
+
onKeyDown,
|
|
402
|
+
placeholder,
|
|
403
|
+
disabled: disabled || sending
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
407
|
+
"button",
|
|
408
|
+
{
|
|
409
|
+
type: "submit",
|
|
410
|
+
className: "poolse-composer__send",
|
|
411
|
+
disabled: disabled || sending || value.trim() === "",
|
|
412
|
+
"aria-label": "Send message",
|
|
413
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
] }),
|
|
387
417
|
mention && filtered.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-mention-menu", role: "listbox", "aria-label": "Members", children: filtered.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
388
418
|
"div",
|
|
389
419
|
{
|
|
@@ -409,7 +439,10 @@ function MessageComposer({
|
|
|
409
439
|
onSend,
|
|
410
440
|
onTyping,
|
|
411
441
|
placeholder = "Type a message\u2026",
|
|
412
|
-
disabled = false
|
|
442
|
+
disabled = false,
|
|
443
|
+
replyingTo,
|
|
444
|
+
onCancelReply,
|
|
445
|
+
labelFor
|
|
413
446
|
}) {
|
|
414
447
|
const [value, setValue] = react.useState("");
|
|
415
448
|
const [sending, setSending] = react.useState(false);
|
|
@@ -418,7 +451,10 @@ function MessageComposer({
|
|
|
418
451
|
if (!trimmed || sending) return;
|
|
419
452
|
setSending(true);
|
|
420
453
|
try {
|
|
421
|
-
await onSend(
|
|
454
|
+
await onSend(
|
|
455
|
+
trimmed,
|
|
456
|
+
replyingTo ? { quoted_message_id: replyingTo.id } : void 0
|
|
457
|
+
);
|
|
422
458
|
setValue("");
|
|
423
459
|
} finally {
|
|
424
460
|
setSending(false);
|
|
@@ -429,6 +465,10 @@ function MessageComposer({
|
|
|
429
465
|
e.preventDefault();
|
|
430
466
|
void submit();
|
|
431
467
|
}
|
|
468
|
+
if (e.key === "Escape" && replyingTo && onCancelReply) {
|
|
469
|
+
e.preventDefault();
|
|
470
|
+
onCancelReply();
|
|
471
|
+
}
|
|
432
472
|
};
|
|
433
473
|
const onChange = (e) => {
|
|
434
474
|
setValue(e.target.value);
|
|
@@ -443,32 +483,70 @@ function MessageComposer({
|
|
|
443
483
|
void submit();
|
|
444
484
|
},
|
|
445
485
|
children: [
|
|
446
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
447
|
-
|
|
486
|
+
replyingTo && /* @__PURE__ */ jsxRuntime.jsx(
|
|
487
|
+
ReplyChip,
|
|
448
488
|
{
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
onChange,
|
|
453
|
-
onKeyDown,
|
|
454
|
-
placeholder,
|
|
455
|
-
disabled: disabled || sending
|
|
489
|
+
message: replyingTo,
|
|
490
|
+
...labelFor ? { labelFor } : {},
|
|
491
|
+
...onCancelReply ? { onCancel: onCancelReply } : {}
|
|
456
492
|
}
|
|
457
493
|
),
|
|
458
|
-
/* @__PURE__ */ jsxRuntime.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
494
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
495
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
496
|
+
"textarea",
|
|
497
|
+
{
|
|
498
|
+
className: "poolse-composer__input",
|
|
499
|
+
rows: 1,
|
|
500
|
+
value,
|
|
501
|
+
onChange,
|
|
502
|
+
onKeyDown,
|
|
503
|
+
placeholder,
|
|
504
|
+
disabled: disabled || sending
|
|
505
|
+
}
|
|
506
|
+
),
|
|
507
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
508
|
+
"button",
|
|
509
|
+
{
|
|
510
|
+
type: "submit",
|
|
511
|
+
className: "poolse-composer__send",
|
|
512
|
+
disabled: disabled || sending || value.trim() === "",
|
|
513
|
+
"aria-label": "Send message",
|
|
514
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
] })
|
|
468
518
|
]
|
|
469
519
|
}
|
|
470
520
|
);
|
|
471
521
|
}
|
|
522
|
+
function ReplyChip({
|
|
523
|
+
message,
|
|
524
|
+
labelFor,
|
|
525
|
+
onCancel
|
|
526
|
+
}) {
|
|
527
|
+
const senderLabel = message.sender_id ? labelFor?.(message.sender_id) ?? `User ${message.sender_id.slice(0, 6)}` : "Unknown";
|
|
528
|
+
const preview = message.body ?? "";
|
|
529
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
530
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
531
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
532
|
+
"Replying to ",
|
|
533
|
+
senderLabel
|
|
534
|
+
] }),
|
|
535
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-composer__reply-preview", children: preview })
|
|
536
|
+
] }),
|
|
537
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
538
|
+
"button",
|
|
539
|
+
{
|
|
540
|
+
type: "button",
|
|
541
|
+
className: "poolse-composer__reply-cancel",
|
|
542
|
+
onClick: onCancel,
|
|
543
|
+
"aria-label": "Cancel reply",
|
|
544
|
+
title: "Cancel reply",
|
|
545
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
546
|
+
}
|
|
547
|
+
)
|
|
548
|
+
] });
|
|
549
|
+
}
|
|
472
550
|
function AttachmentPreview({ attachment, onClick }) {
|
|
473
551
|
const isFullRow = "content_type" in attachment;
|
|
474
552
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -563,7 +641,13 @@ function formatBytes(n) {
|
|
|
563
641
|
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
564
642
|
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
565
643
|
}
|
|
566
|
-
function MessageBubble({
|
|
644
|
+
function MessageBubble({
|
|
645
|
+
message,
|
|
646
|
+
currentUserId,
|
|
647
|
+
readState,
|
|
648
|
+
labelFor,
|
|
649
|
+
onQuotedClick
|
|
650
|
+
}) {
|
|
567
651
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
568
652
|
const className = [
|
|
569
653
|
"poolse-message",
|
|
@@ -574,6 +658,15 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
574
658
|
minute: "2-digit"
|
|
575
659
|
}) : "";
|
|
576
660
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
661
|
+
message.quoted_message && /* @__PURE__ */ jsxRuntime.jsx(
|
|
662
|
+
QuotedCard,
|
|
663
|
+
{
|
|
664
|
+
quoted: message.quoted_message,
|
|
665
|
+
isSelf,
|
|
666
|
+
...labelFor ? { labelFor } : {},
|
|
667
|
+
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
668
|
+
}
|
|
669
|
+
),
|
|
577
670
|
message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: message.body ?? "" }),
|
|
578
671
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-message__meta", children: [
|
|
579
672
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
|
|
@@ -589,6 +682,30 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
589
682
|
] })
|
|
590
683
|
] });
|
|
591
684
|
}
|
|
685
|
+
function QuotedCard({
|
|
686
|
+
quoted,
|
|
687
|
+
isSelf,
|
|
688
|
+
labelFor,
|
|
689
|
+
onClick
|
|
690
|
+
}) {
|
|
691
|
+
const senderLabel = quoted.sender_id ? labelFor?.(quoted.sender_id) ?? `User ${quoted.sender_id.slice(0, 6)}` : "Unknown";
|
|
692
|
+
const isDeleted = !!quoted.deleted_at;
|
|
693
|
+
const handleClick = onClick ? () => onClick(quoted.id) : void 0;
|
|
694
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
type: "button",
|
|
698
|
+
className: `poolse-quote ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
|
|
699
|
+
onClick: handleClick,
|
|
700
|
+
disabled: !handleClick,
|
|
701
|
+
"aria-label": `Quoted message from ${senderLabel}`,
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__sender", children: senderLabel }),
|
|
704
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__body", children: isDeleted ? "Original message deleted" : quoted.body ?? "" })
|
|
705
|
+
]
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
}
|
|
592
709
|
function EditableMessageBubble({
|
|
593
710
|
message,
|
|
594
711
|
currentUserId,
|
|
@@ -768,6 +885,7 @@ function ReactionPicker({
|
|
|
768
885
|
function MessageActions({
|
|
769
886
|
onReact,
|
|
770
887
|
onReply,
|
|
888
|
+
onQuote,
|
|
771
889
|
onCopy,
|
|
772
890
|
onEdit,
|
|
773
891
|
onDelete,
|
|
@@ -796,7 +914,8 @@ function MessageActions({
|
|
|
796
914
|
}
|
|
797
915
|
) })
|
|
798
916
|
] }),
|
|
799
|
-
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "
|
|
917
|
+
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
918
|
+
onQuote && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
800
919
|
onCopy && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
801
920
|
onEdit && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
802
921
|
onDelete && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
@@ -824,13 +943,17 @@ function MessageRow({
|
|
|
824
943
|
attachments = true,
|
|
825
944
|
actions = true,
|
|
826
945
|
threads = true,
|
|
946
|
+
quotations = true,
|
|
827
947
|
readState,
|
|
828
948
|
editing = false,
|
|
829
949
|
onStartEdit,
|
|
830
950
|
onCancelEdit,
|
|
831
951
|
onSaveEdit,
|
|
832
952
|
onDelete,
|
|
833
|
-
onOpenThread
|
|
953
|
+
onOpenThread,
|
|
954
|
+
onQuote,
|
|
955
|
+
labelFor,
|
|
956
|
+
onQuotedClick
|
|
834
957
|
}) {
|
|
835
958
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
836
959
|
const reactionsHook = react$1.useReactions(reactions ? msg.id : "", {
|
|
@@ -856,7 +979,16 @@ function MessageRow({
|
|
|
856
979
|
onSave: handleSave,
|
|
857
980
|
onCancel: handleCancel
|
|
858
981
|
}
|
|
859
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
982
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
983
|
+
MessageBubble,
|
|
984
|
+
{
|
|
985
|
+
message: msg,
|
|
986
|
+
currentUserId: meId,
|
|
987
|
+
...readState ? { readState } : {},
|
|
988
|
+
...labelFor ? { labelFor } : {},
|
|
989
|
+
...onQuotedClick ? { onQuotedClick } : {}
|
|
990
|
+
}
|
|
991
|
+
),
|
|
860
992
|
showAttachments && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
|
|
861
993
|
showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
862
994
|
InlineReactions,
|
|
@@ -897,6 +1029,7 @@ function MessageRow({
|
|
|
897
1029
|
}
|
|
898
1030
|
} : {},
|
|
899
1031
|
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1032
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
900
1033
|
...msg.body ? {
|
|
901
1034
|
onCopy: () => {
|
|
902
1035
|
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
@@ -1027,6 +1160,7 @@ function ConversationView({
|
|
|
1027
1160
|
attachments = TRUE,
|
|
1028
1161
|
actions = TRUE,
|
|
1029
1162
|
threads = TRUE,
|
|
1163
|
+
quotations = TRUE,
|
|
1030
1164
|
readReceipts = TRUE,
|
|
1031
1165
|
onMarkedRead
|
|
1032
1166
|
}) {
|
|
@@ -1126,6 +1260,21 @@ function ConversationView({
|
|
|
1126
1260
|
() => threadRootId ? messages.find((m) => m.id === threadRootId) ?? null : null,
|
|
1127
1261
|
[threadRootId, messages]
|
|
1128
1262
|
);
|
|
1263
|
+
const [replyingTo, setReplyingTo] = react.useState(null);
|
|
1264
|
+
react.useEffect(() => {
|
|
1265
|
+
setReplyingTo(null);
|
|
1266
|
+
setEditingId(null);
|
|
1267
|
+
setThreadRootId(null);
|
|
1268
|
+
}, [conversationId]);
|
|
1269
|
+
const scrollToOriginal = (id) => {
|
|
1270
|
+
const root = listRef.current;
|
|
1271
|
+
if (!root) return;
|
|
1272
|
+
const el = root.querySelector(`[data-message-id="${id}"]`);
|
|
1273
|
+
if (!(el instanceof HTMLElement)) return;
|
|
1274
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1275
|
+
el.classList.add("poolse-message-row--highlight");
|
|
1276
|
+
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
1277
|
+
};
|
|
1129
1278
|
const { upload, uploading } = react$1.useAttachmentUpload();
|
|
1130
1279
|
const onPickFile = async (file) => {
|
|
1131
1280
|
try {
|
|
@@ -1140,20 +1289,35 @@ function ConversationView({
|
|
|
1140
1289
|
console.error("attachment upload failed:", err);
|
|
1141
1290
|
}
|
|
1142
1291
|
};
|
|
1143
|
-
const onSendBody = async (body) => {
|
|
1144
|
-
await send({
|
|
1292
|
+
const onSendBody = async (body, opts) => {
|
|
1293
|
+
await send({
|
|
1294
|
+
body,
|
|
1295
|
+
...opts?.quoted_message_id ? { quoted_message_id: opts.quoted_message_id } : {}
|
|
1296
|
+
});
|
|
1297
|
+
setReplyingTo(null);
|
|
1145
1298
|
};
|
|
1146
1299
|
const onSendWithMentions = async (req) => {
|
|
1147
1300
|
await send(req);
|
|
1301
|
+
setReplyingTo(null);
|
|
1148
1302
|
};
|
|
1149
1303
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1150
1304
|
MentionInput,
|
|
1151
1305
|
{
|
|
1152
1306
|
conversationId,
|
|
1153
1307
|
onSend: onSendWithMentions,
|
|
1154
|
-
onTyping: signalTyping
|
|
1308
|
+
onTyping: signalTyping,
|
|
1309
|
+
...labelFor ? { labelFor } : {},
|
|
1310
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1155
1311
|
}
|
|
1156
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1312
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1313
|
+
MessageComposer,
|
|
1314
|
+
{
|
|
1315
|
+
onSend: onSendBody,
|
|
1316
|
+
onTyping: signalTyping,
|
|
1317
|
+
...labelFor ? { labelFor } : {},
|
|
1318
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1319
|
+
}
|
|
1320
|
+
);
|
|
1157
1321
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
1158
1322
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation", children: [
|
|
1159
1323
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__status", children: [
|
|
@@ -1169,7 +1333,7 @@ function ConversationView({
|
|
|
1169
1333
|
}
|
|
1170
1334
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1171
1335
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1172
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1336
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1173
1337
|
MessageRow,
|
|
1174
1338
|
{
|
|
1175
1339
|
msg,
|
|
@@ -1178,7 +1342,9 @@ function ConversationView({
|
|
|
1178
1342
|
attachments,
|
|
1179
1343
|
actions,
|
|
1180
1344
|
threads,
|
|
1345
|
+
quotations,
|
|
1181
1346
|
...readState ? { readState } : {},
|
|
1347
|
+
...labelFor ? { labelFor } : {},
|
|
1182
1348
|
editing: editingId === msg.id,
|
|
1183
1349
|
onStartEdit: () => setEditingId(msg.id),
|
|
1184
1350
|
onCancelEdit: () => setEditingId(null),
|
|
@@ -1187,10 +1353,11 @@ function ConversationView({
|
|
|
1187
1353
|
setEditingId(null);
|
|
1188
1354
|
},
|
|
1189
1355
|
onDelete: () => void deleteMsg(msg.id),
|
|
1190
|
-
onOpenThread: () => setThreadRootId(msg.id)
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1356
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
1357
|
+
onQuote: () => setReplyingTo(msg),
|
|
1358
|
+
onQuotedClick: scrollToOriginal
|
|
1359
|
+
}
|
|
1360
|
+
) }, msg.id);
|
|
1194
1361
|
}),
|
|
1195
1362
|
error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1196
1363
|
"Failed to load: ",
|
|
@@ -1286,13 +1453,15 @@ function ConversationList({
|
|
|
1286
1453
|
emptyState,
|
|
1287
1454
|
conversations: controlledConversations,
|
|
1288
1455
|
loading: controlledLoading,
|
|
1289
|
-
error: controlledError
|
|
1456
|
+
error: controlledError,
|
|
1457
|
+
unreadCounts
|
|
1290
1458
|
}) {
|
|
1291
1459
|
const auto = react$1.useConversations();
|
|
1292
1460
|
const isControlled = controlledConversations !== void 0;
|
|
1293
1461
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
1294
1462
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
1295
1463
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
1464
|
+
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
1296
1465
|
if (loading && conversations.length === 0) {
|
|
1297
1466
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading conversations\u2026" });
|
|
1298
1467
|
}
|
|
@@ -1304,7 +1473,8 @@ function ConversationList({
|
|
|
1304
1473
|
}
|
|
1305
1474
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
1306
1475
|
const selected = selectedId === conv.id;
|
|
1307
|
-
const
|
|
1476
|
+
const unread = counts?.[conv.id] ?? 0;
|
|
1477
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsxRuntime.jsx(DefaultRow, { conv, selected, unread });
|
|
1308
1478
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1309
1479
|
"li",
|
|
1310
1480
|
{
|
|
@@ -1325,18 +1495,31 @@ function ConversationList({
|
|
|
1325
1495
|
);
|
|
1326
1496
|
}) });
|
|
1327
1497
|
}
|
|
1328
|
-
function DefaultRow({
|
|
1498
|
+
function DefaultRow({
|
|
1499
|
+
conv,
|
|
1500
|
+
selected: _selected,
|
|
1501
|
+
unread
|
|
1502
|
+
}) {
|
|
1329
1503
|
const title = conv.name ?? "Untitled conversation";
|
|
1330
1504
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
1505
|
+
const hasUnread = unread > 0;
|
|
1331
1506
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1332
1507
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: conv.avatar_url ?? null, name: conv.name, size: "md" }),
|
|
1333
1508
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
|
|
1334
1509
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__head", children: [
|
|
1335
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__title"
|
|
1510
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
1336
1511
|
time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__time", children: time })
|
|
1337
1512
|
] }),
|
|
1338
1513
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__preview", children: conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet" })
|
|
1339
|
-
] })
|
|
1514
|
+
] }),
|
|
1515
|
+
hasUnread && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1516
|
+
"span",
|
|
1517
|
+
{
|
|
1518
|
+
className: "poolse-list__unread-badge",
|
|
1519
|
+
"aria-label": `${unread} unread ${unread === 1 ? "message" : "messages"}`,
|
|
1520
|
+
children: unread > 99 ? "99+" : unread
|
|
1521
|
+
}
|
|
1522
|
+
)
|
|
1340
1523
|
] });
|
|
1341
1524
|
}
|
|
1342
1525
|
function formatRelative(iso) {
|