@poolse/react-ui 0.2.0-alpha.4 → 0.2.0-alpha.7
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 +37 -0
- package/dist/index.cjs +259 -65
- 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 +259 -65
- package/dist/index.js.map +1 -1
- package/dist/styles.css +184 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,43 @@ 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
|
+
### Changed — quote card polish
|
|
10
|
+
|
|
11
|
+
- WhatsApp-style quote card visuals: compact padding, 4px Pulse Coral
|
|
12
|
+
accent stripe flush with the bubble edge, body text at 0.62 opacity
|
|
13
|
+
so the eye lands on the actual message. Self-bubble variant tints
|
|
14
|
+
with a dark overlay; other-bubble variant tints slightly darker than
|
|
15
|
+
the surface for visual "depth."
|
|
16
|
+
- Optimistic quote preview: when you quote-reply, the card renders
|
|
17
|
+
immediately on the locally-inserted bubble (looked up from the
|
|
18
|
+
in-memory message list) instead of flashing in once the realtime
|
|
19
|
+
echo arrives ~100ms later.
|
|
20
|
+
|
|
21
|
+
### Added — quote replies (WhatsApp-style)
|
|
22
|
+
|
|
23
|
+
- `<ConversationView quotations?>` (default `true`) — new feature
|
|
24
|
+
toggle. Adds a "Reply" action to the hover menu distinct from
|
|
25
|
+
"Reply in thread". Reply pre-fills the composer with a quote chip
|
|
26
|
+
above the input; on send, the new message carries `quoted_message_id`
|
|
27
|
+
and stays in the main feed (no thread promotion).
|
|
28
|
+
- `<MessageBubble>` renders a small quoted-message card above the body
|
|
29
|
+
when `message.quoted_message` is set. Click → scroll-to-original
|
|
30
|
+
with a 1.6s highlight pulse on the target row.
|
|
31
|
+
- `<MessageComposer>` + `<MentionInput>` gain controlled
|
|
32
|
+
`replyingTo?: Message` and `onCancelReply?: () => void` props.
|
|
33
|
+
Renders a quote chip above the input with an (x) to cancel; Esc
|
|
34
|
+
also dismisses.
|
|
35
|
+
- `<MessageActions>` gains `onQuote?: () => void` — wired in
|
|
36
|
+
`<MessageRow>` to call back to the caller's quote state.
|
|
37
|
+
|
|
38
|
+
### Added — unread badges on `<ConversationList>`
|
|
39
|
+
|
|
40
|
+
- `<ConversationList unreadCounts>` now accepts a per-conversation
|
|
41
|
+
unread map and renders a small Pulse Coral pill on each row when
|
|
42
|
+
`unread > 0`. Auto-falls-back to `useConversations().unreadCounts`
|
|
43
|
+
when the component runs in uncontrolled mode, so sidebars work
|
|
44
|
+
out of the box with no extra wiring.
|
|
45
|
+
|
|
9
46
|
### Added — thread pill + copy action
|
|
10
47
|
|
|
11
48
|
- `<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,7 @@ function MessageComposer({
|
|
|
418
451
|
if (!trimmed || sending) return;
|
|
419
452
|
setSending(true);
|
|
420
453
|
try {
|
|
421
|
-
await onSend(trimmed);
|
|
454
|
+
await onSend(trimmed, replyingTo ? { quoted_message_id: replyingTo.id } : void 0);
|
|
422
455
|
setValue("");
|
|
423
456
|
} finally {
|
|
424
457
|
setSending(false);
|
|
@@ -429,6 +462,10 @@ function MessageComposer({
|
|
|
429
462
|
e.preventDefault();
|
|
430
463
|
void submit();
|
|
431
464
|
}
|
|
465
|
+
if (e.key === "Escape" && replyingTo && onCancelReply) {
|
|
466
|
+
e.preventDefault();
|
|
467
|
+
onCancelReply();
|
|
468
|
+
}
|
|
432
469
|
};
|
|
433
470
|
const onChange = (e) => {
|
|
434
471
|
setValue(e.target.value);
|
|
@@ -443,32 +480,70 @@ function MessageComposer({
|
|
|
443
480
|
void submit();
|
|
444
481
|
},
|
|
445
482
|
children: [
|
|
446
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
447
|
-
|
|
483
|
+
replyingTo && /* @__PURE__ */ jsxRuntime.jsx(
|
|
484
|
+
ReplyChip,
|
|
448
485
|
{
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
onChange,
|
|
453
|
-
onKeyDown,
|
|
454
|
-
placeholder,
|
|
455
|
-
disabled: disabled || sending
|
|
486
|
+
message: replyingTo,
|
|
487
|
+
...labelFor ? { labelFor } : {},
|
|
488
|
+
...onCancelReply ? { onCancel: onCancelReply } : {}
|
|
456
489
|
}
|
|
457
490
|
),
|
|
458
|
-
/* @__PURE__ */ jsxRuntime.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
491
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__row", children: [
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
493
|
+
"textarea",
|
|
494
|
+
{
|
|
495
|
+
className: "poolse-composer__input",
|
|
496
|
+
rows: 1,
|
|
497
|
+
value,
|
|
498
|
+
onChange,
|
|
499
|
+
onKeyDown,
|
|
500
|
+
placeholder,
|
|
501
|
+
disabled: disabled || sending
|
|
502
|
+
}
|
|
503
|
+
),
|
|
504
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
505
|
+
"button",
|
|
506
|
+
{
|
|
507
|
+
type: "submit",
|
|
508
|
+
className: "poolse-composer__send",
|
|
509
|
+
disabled: disabled || sending || value.trim() === "",
|
|
510
|
+
"aria-label": "Send message",
|
|
511
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "send-fill", label: null })
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] })
|
|
468
515
|
]
|
|
469
516
|
}
|
|
470
517
|
);
|
|
471
518
|
}
|
|
519
|
+
function ReplyChip({
|
|
520
|
+
message,
|
|
521
|
+
labelFor,
|
|
522
|
+
onCancel
|
|
523
|
+
}) {
|
|
524
|
+
const senderLabel = message.sender_id ? labelFor?.(message.sender_id) ?? `User ${message.sender_id.slice(0, 6)}` : "Unknown";
|
|
525
|
+
const preview = message.body ?? "";
|
|
526
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply", role: "status", children: [
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-composer__reply-body", children: [
|
|
528
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-composer__reply-label", children: [
|
|
529
|
+
"Replying to ",
|
|
530
|
+
senderLabel
|
|
531
|
+
] }),
|
|
532
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-composer__reply-preview", children: preview })
|
|
533
|
+
] }),
|
|
534
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx(
|
|
535
|
+
"button",
|
|
536
|
+
{
|
|
537
|
+
type: "button",
|
|
538
|
+
className: "poolse-composer__reply-cancel",
|
|
539
|
+
onClick: onCancel,
|
|
540
|
+
"aria-label": "Cancel reply",
|
|
541
|
+
title: "Cancel reply",
|
|
542
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 14, label: null })
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
] });
|
|
546
|
+
}
|
|
472
547
|
function AttachmentPreview({ attachment, onClick }) {
|
|
473
548
|
const isFullRow = "content_type" in attachment;
|
|
474
549
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -563,7 +638,13 @@ function formatBytes(n) {
|
|
|
563
638
|
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
564
639
|
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
565
640
|
}
|
|
566
|
-
function MessageBubble({
|
|
641
|
+
function MessageBubble({
|
|
642
|
+
message,
|
|
643
|
+
currentUserId,
|
|
644
|
+
readState,
|
|
645
|
+
labelFor,
|
|
646
|
+
onQuotedClick
|
|
647
|
+
}) {
|
|
567
648
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
568
649
|
const className = [
|
|
569
650
|
"poolse-message",
|
|
@@ -574,6 +655,15 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
574
655
|
minute: "2-digit"
|
|
575
656
|
}) : "";
|
|
576
657
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
658
|
+
message.quoted_message && /* @__PURE__ */ jsxRuntime.jsx(
|
|
659
|
+
QuotedCard,
|
|
660
|
+
{
|
|
661
|
+
quoted: message.quoted_message,
|
|
662
|
+
isSelf,
|
|
663
|
+
...labelFor ? { labelFor } : {},
|
|
664
|
+
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
665
|
+
}
|
|
666
|
+
),
|
|
577
667
|
message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: message.body ?? "" }),
|
|
578
668
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-message__meta", children: [
|
|
579
669
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
|
|
@@ -589,6 +679,30 @@ function MessageBubble({ message, currentUserId, readState }) {
|
|
|
589
679
|
] })
|
|
590
680
|
] });
|
|
591
681
|
}
|
|
682
|
+
function QuotedCard({
|
|
683
|
+
quoted,
|
|
684
|
+
isSelf,
|
|
685
|
+
labelFor,
|
|
686
|
+
onClick
|
|
687
|
+
}) {
|
|
688
|
+
const senderLabel = quoted.sender_id ? labelFor?.(quoted.sender_id) ?? `User ${quoted.sender_id.slice(0, 6)}` : "Unknown";
|
|
689
|
+
const isDeleted = !!quoted.deleted_at;
|
|
690
|
+
const handleClick = onClick ? () => onClick(quoted.id) : void 0;
|
|
691
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
692
|
+
"button",
|
|
693
|
+
{
|
|
694
|
+
type: "button",
|
|
695
|
+
className: `poolse-quote ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
|
|
696
|
+
onClick: handleClick,
|
|
697
|
+
disabled: !handleClick,
|
|
698
|
+
"aria-label": `Quoted message from ${senderLabel}`,
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__sender", children: senderLabel }),
|
|
701
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__body", children: isDeleted ? "Original message deleted" : quoted.body ?? "" })
|
|
702
|
+
]
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
592
706
|
function EditableMessageBubble({
|
|
593
707
|
message,
|
|
594
708
|
currentUserId,
|
|
@@ -768,6 +882,7 @@ function ReactionPicker({
|
|
|
768
882
|
function MessageActions({
|
|
769
883
|
onReact,
|
|
770
884
|
onReply,
|
|
885
|
+
onQuote,
|
|
771
886
|
onCopy,
|
|
772
887
|
onEdit,
|
|
773
888
|
onDelete,
|
|
@@ -796,7 +911,8 @@ function MessageActions({
|
|
|
796
911
|
}
|
|
797
912
|
) })
|
|
798
913
|
] }),
|
|
799
|
-
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "
|
|
914
|
+
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
915
|
+
onQuote && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
800
916
|
onCopy && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
801
917
|
onEdit && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
802
918
|
onDelete && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
@@ -824,13 +940,17 @@ function MessageRow({
|
|
|
824
940
|
attachments = true,
|
|
825
941
|
actions = true,
|
|
826
942
|
threads = true,
|
|
943
|
+
quotations = true,
|
|
827
944
|
readState,
|
|
828
945
|
editing = false,
|
|
829
946
|
onStartEdit,
|
|
830
947
|
onCancelEdit,
|
|
831
948
|
onSaveEdit,
|
|
832
949
|
onDelete,
|
|
833
|
-
onOpenThread
|
|
950
|
+
onOpenThread,
|
|
951
|
+
onQuote,
|
|
952
|
+
labelFor,
|
|
953
|
+
onQuotedClick
|
|
834
954
|
}) {
|
|
835
955
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
836
956
|
const reactionsHook = react$1.useReactions(reactions ? msg.id : "", {
|
|
@@ -856,7 +976,16 @@ function MessageRow({
|
|
|
856
976
|
onSave: handleSave,
|
|
857
977
|
onCancel: handleCancel
|
|
858
978
|
}
|
|
859
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
979
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
980
|
+
MessageBubble,
|
|
981
|
+
{
|
|
982
|
+
message: msg,
|
|
983
|
+
currentUserId: meId,
|
|
984
|
+
...readState ? { readState } : {},
|
|
985
|
+
...labelFor ? { labelFor } : {},
|
|
986
|
+
...onQuotedClick ? { onQuotedClick } : {}
|
|
987
|
+
}
|
|
988
|
+
),
|
|
860
989
|
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
990
|
showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
862
991
|
InlineReactions,
|
|
@@ -897,6 +1026,7 @@ function MessageRow({
|
|
|
897
1026
|
}
|
|
898
1027
|
} : {},
|
|
899
1028
|
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1029
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
900
1030
|
...msg.body ? {
|
|
901
1031
|
onCopy: () => {
|
|
902
1032
|
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
@@ -1027,6 +1157,7 @@ function ConversationView({
|
|
|
1027
1157
|
attachments = TRUE,
|
|
1028
1158
|
actions = TRUE,
|
|
1029
1159
|
threads = TRUE,
|
|
1160
|
+
quotations = TRUE,
|
|
1030
1161
|
readReceipts = TRUE,
|
|
1031
1162
|
onMarkedRead
|
|
1032
1163
|
}) {
|
|
@@ -1126,6 +1257,21 @@ function ConversationView({
|
|
|
1126
1257
|
() => threadRootId ? messages.find((m) => m.id === threadRootId) ?? null : null,
|
|
1127
1258
|
[threadRootId, messages]
|
|
1128
1259
|
);
|
|
1260
|
+
const [replyingTo, setReplyingTo] = react.useState(null);
|
|
1261
|
+
react.useEffect(() => {
|
|
1262
|
+
setReplyingTo(null);
|
|
1263
|
+
setEditingId(null);
|
|
1264
|
+
setThreadRootId(null);
|
|
1265
|
+
}, [conversationId]);
|
|
1266
|
+
const scrollToOriginal = (id) => {
|
|
1267
|
+
const root = listRef.current;
|
|
1268
|
+
if (!root) return;
|
|
1269
|
+
const el = root.querySelector(`[data-message-id="${id}"]`);
|
|
1270
|
+
if (!(el instanceof HTMLElement)) return;
|
|
1271
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1272
|
+
el.classList.add("poolse-message-row--highlight");
|
|
1273
|
+
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
1274
|
+
};
|
|
1129
1275
|
const { upload, uploading } = react$1.useAttachmentUpload();
|
|
1130
1276
|
const onPickFile = async (file) => {
|
|
1131
1277
|
try {
|
|
@@ -1140,20 +1286,35 @@ function ConversationView({
|
|
|
1140
1286
|
console.error("attachment upload failed:", err);
|
|
1141
1287
|
}
|
|
1142
1288
|
};
|
|
1143
|
-
const onSendBody = async (body) => {
|
|
1144
|
-
await send({
|
|
1289
|
+
const onSendBody = async (body, opts) => {
|
|
1290
|
+
await send({
|
|
1291
|
+
body,
|
|
1292
|
+
...opts?.quoted_message_id ? { quoted_message_id: opts.quoted_message_id } : {}
|
|
1293
|
+
});
|
|
1294
|
+
setReplyingTo(null);
|
|
1145
1295
|
};
|
|
1146
1296
|
const onSendWithMentions = async (req) => {
|
|
1147
1297
|
await send(req);
|
|
1298
|
+
setReplyingTo(null);
|
|
1148
1299
|
};
|
|
1149
1300
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1150
1301
|
MentionInput,
|
|
1151
1302
|
{
|
|
1152
1303
|
conversationId,
|
|
1153
1304
|
onSend: onSendWithMentions,
|
|
1154
|
-
onTyping: signalTyping
|
|
1305
|
+
onTyping: signalTyping,
|
|
1306
|
+
...labelFor ? { labelFor } : {},
|
|
1307
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1308
|
+
}
|
|
1309
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1310
|
+
MessageComposer,
|
|
1311
|
+
{
|
|
1312
|
+
onSend: onSendBody,
|
|
1313
|
+
onTyping: signalTyping,
|
|
1314
|
+
...labelFor ? { labelFor } : {},
|
|
1315
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1155
1316
|
}
|
|
1156
|
-
)
|
|
1317
|
+
);
|
|
1157
1318
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
1158
1319
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation", children: [
|
|
1159
1320
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__status", children: [
|
|
@@ -1167,18 +1328,34 @@ function ConversationView({
|
|
|
1167
1328
|
if (renderMessage) {
|
|
1168
1329
|
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|
|
1169
1330
|
}
|
|
1331
|
+
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
1332
|
+
const original = messages.find((m) => m.id === msg.quoted_message_id);
|
|
1333
|
+
if (!original) return msg;
|
|
1334
|
+
return {
|
|
1335
|
+
...msg,
|
|
1336
|
+
quoted_message: {
|
|
1337
|
+
id: original.id,
|
|
1338
|
+
sender_id: original.sender_id,
|
|
1339
|
+
body: original.body,
|
|
1340
|
+
deleted_at: original.deleted_at,
|
|
1341
|
+
inserted_at: original.inserted_at
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
})() : msg;
|
|
1170
1345
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1171
1346
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1172
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1347
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1173
1348
|
MessageRow,
|
|
1174
1349
|
{
|
|
1175
|
-
msg,
|
|
1350
|
+
msg: enriched,
|
|
1176
1351
|
meId: me?.id ?? null,
|
|
1177
1352
|
reactions,
|
|
1178
1353
|
attachments,
|
|
1179
1354
|
actions,
|
|
1180
1355
|
threads,
|
|
1356
|
+
quotations,
|
|
1181
1357
|
...readState ? { readState } : {},
|
|
1358
|
+
...labelFor ? { labelFor } : {},
|
|
1182
1359
|
editing: editingId === msg.id,
|
|
1183
1360
|
onStartEdit: () => setEditingId(msg.id),
|
|
1184
1361
|
onCancelEdit: () => setEditingId(null),
|
|
@@ -1187,10 +1364,11 @@ function ConversationView({
|
|
|
1187
1364
|
setEditingId(null);
|
|
1188
1365
|
},
|
|
1189
1366
|
onDelete: () => void deleteMsg(msg.id),
|
|
1190
|
-
onOpenThread: () => setThreadRootId(msg.id)
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1367
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
1368
|
+
onQuote: () => setReplyingTo(msg),
|
|
1369
|
+
onQuotedClick: scrollToOriginal
|
|
1370
|
+
}
|
|
1371
|
+
) }, msg.id);
|
|
1194
1372
|
}),
|
|
1195
1373
|
error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1196
1374
|
"Failed to load: ",
|
|
@@ -1286,13 +1464,15 @@ function ConversationList({
|
|
|
1286
1464
|
emptyState,
|
|
1287
1465
|
conversations: controlledConversations,
|
|
1288
1466
|
loading: controlledLoading,
|
|
1289
|
-
error: controlledError
|
|
1467
|
+
error: controlledError,
|
|
1468
|
+
unreadCounts
|
|
1290
1469
|
}) {
|
|
1291
1470
|
const auto = react$1.useConversations();
|
|
1292
1471
|
const isControlled = controlledConversations !== void 0;
|
|
1293
1472
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
1294
1473
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
1295
1474
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
1475
|
+
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
1296
1476
|
if (loading && conversations.length === 0) {
|
|
1297
1477
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading conversations\u2026" });
|
|
1298
1478
|
}
|
|
@@ -1304,7 +1484,8 @@ function ConversationList({
|
|
|
1304
1484
|
}
|
|
1305
1485
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
1306
1486
|
const selected = selectedId === conv.id;
|
|
1307
|
-
const
|
|
1487
|
+
const unread = counts?.[conv.id] ?? 0;
|
|
1488
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsxRuntime.jsx(DefaultRow, { conv, selected, unread });
|
|
1308
1489
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1309
1490
|
"li",
|
|
1310
1491
|
{
|
|
@@ -1325,18 +1506,31 @@ function ConversationList({
|
|
|
1325
1506
|
);
|
|
1326
1507
|
}) });
|
|
1327
1508
|
}
|
|
1328
|
-
function DefaultRow({
|
|
1509
|
+
function DefaultRow({
|
|
1510
|
+
conv,
|
|
1511
|
+
selected: _selected,
|
|
1512
|
+
unread
|
|
1513
|
+
}) {
|
|
1329
1514
|
const title = conv.name ?? "Untitled conversation";
|
|
1330
1515
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
1516
|
+
const hasUnread = unread > 0;
|
|
1331
1517
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1332
1518
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: conv.avatar_url ?? null, name: conv.name, size: "md" }),
|
|
1333
1519
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
|
|
1334
1520
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__head", children: [
|
|
1335
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__title"
|
|
1521
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
1336
1522
|
time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__time", children: time })
|
|
1337
1523
|
] }),
|
|
1338
1524
|
/* @__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
|
-
] })
|
|
1525
|
+
] }),
|
|
1526
|
+
hasUnread && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
|
+
"span",
|
|
1528
|
+
{
|
|
1529
|
+
className: "poolse-list__unread-badge",
|
|
1530
|
+
"aria-label": `${unread} unread ${unread === 1 ? "message" : "messages"}`,
|
|
1531
|
+
children: unread > 99 ? "99+" : unread
|
|
1532
|
+
}
|
|
1533
|
+
)
|
|
1340
1534
|
] });
|
|
1341
1535
|
}
|
|
1342
1536
|
function formatRelative(iso) {
|