@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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,47 @@ 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
|
+
|
|
34
|
+
### Added — thread pill + copy action
|
|
35
|
+
|
|
36
|
+
- `<MessageRow>` renders a subtle "💬 N replies" pill below any message
|
|
37
|
+
whose `reply_count > 0`. Clicking the pill opens the thread side-pane
|
|
38
|
+
via the existing `onOpenThread` callback. Hidden in `<ThreadView>`
|
|
39
|
+
(threads-within-threads aren't supported in 0.2).
|
|
40
|
+
- `<MessageActions>` gains an optional `onCopy` action. `<MessageRow>`
|
|
41
|
+
wires it to `navigator.clipboard.writeText(message.body)` whenever
|
|
42
|
+
the message has a non-empty body.
|
|
43
|
+
|
|
44
|
+
### Changed — better error visibility
|
|
45
|
+
|
|
46
|
+
- `<MemberList>` now renders `error.message` under the "Failed to load
|
|
47
|
+
members." headline so callers see the actual cause without opening
|
|
48
|
+
DevTools.
|
|
49
|
+
|
|
9
50
|
### Added — new components
|
|
10
51
|
|
|
11
52
|
- `<MessageActions>` — hover-triggered popover with react / reply
|
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,8 @@ function ReactionPicker({
|
|
|
768
885
|
function MessageActions({
|
|
769
886
|
onReact,
|
|
770
887
|
onReply,
|
|
888
|
+
onQuote,
|
|
889
|
+
onCopy,
|
|
771
890
|
onEdit,
|
|
772
891
|
onDelete,
|
|
773
892
|
children
|
|
@@ -795,7 +914,9 @@ function MessageActions({
|
|
|
795
914
|
}
|
|
796
915
|
) })
|
|
797
916
|
] }),
|
|
798
|
-
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 }),
|
|
919
|
+
onCopy && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
799
920
|
onEdit && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
800
921
|
onDelete && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
801
922
|
children
|
|
@@ -822,13 +943,17 @@ function MessageRow({
|
|
|
822
943
|
attachments = true,
|
|
823
944
|
actions = true,
|
|
824
945
|
threads = true,
|
|
946
|
+
quotations = true,
|
|
825
947
|
readState,
|
|
826
948
|
editing = false,
|
|
827
949
|
onStartEdit,
|
|
828
950
|
onCancelEdit,
|
|
829
951
|
onSaveEdit,
|
|
830
952
|
onDelete,
|
|
831
|
-
onOpenThread
|
|
953
|
+
onOpenThread,
|
|
954
|
+
onQuote,
|
|
955
|
+
labelFor,
|
|
956
|
+
onQuotedClick
|
|
832
957
|
}) {
|
|
833
958
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
834
959
|
const reactionsHook = react$1.useReactions(reactions ? msg.id : "", {
|
|
@@ -839,6 +964,8 @@ function MessageRow({
|
|
|
839
964
|
const showReactions = reactions && !msg.deleted_at;
|
|
840
965
|
const showAttachments = attachments && Array.isArray(msg.attachments) && msg.attachments.length > 0;
|
|
841
966
|
const showActions = actions && !msg.deleted_at && !editing;
|
|
967
|
+
const replyCount = msg.reply_count ?? 0;
|
|
968
|
+
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
842
969
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
843
970
|
const handleCancel = onCancelEdit ?? (() => void 0);
|
|
844
971
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`, children: [
|
|
@@ -852,7 +979,16 @@ function MessageRow({
|
|
|
852
979
|
onSave: handleSave,
|
|
853
980
|
onCancel: handleCancel
|
|
854
981
|
}
|
|
855
|
-
) : /* @__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
|
+
),
|
|
856
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)) }),
|
|
857
993
|
showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
858
994
|
InlineReactions,
|
|
@@ -863,6 +999,23 @@ function MessageRow({
|
|
|
863
999
|
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
864
1000
|
}
|
|
865
1001
|
) }),
|
|
1002
|
+
showThreadPill && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1003
|
+
"button",
|
|
1004
|
+
{
|
|
1005
|
+
type: "button",
|
|
1006
|
+
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
1007
|
+
onClick: onOpenThread,
|
|
1008
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
1009
|
+
children: [
|
|
1010
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
1011
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
1012
|
+
replyCount,
|
|
1013
|
+
" ",
|
|
1014
|
+
replyCount === 1 ? "reply" : "replies"
|
|
1015
|
+
] })
|
|
1016
|
+
]
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
866
1019
|
showActions && /* @__PURE__ */ jsxRuntime.jsx(
|
|
867
1020
|
"div",
|
|
868
1021
|
{
|
|
@@ -876,6 +1029,12 @@ function MessageRow({
|
|
|
876
1029
|
}
|
|
877
1030
|
} : {},
|
|
878
1031
|
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
1032
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
1033
|
+
...msg.body ? {
|
|
1034
|
+
onCopy: () => {
|
|
1035
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
1036
|
+
}
|
|
1037
|
+
} : {},
|
|
879
1038
|
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
880
1039
|
...isSelf && onDelete ? { onDelete } : {}
|
|
881
1040
|
}
|
|
@@ -1001,6 +1160,7 @@ function ConversationView({
|
|
|
1001
1160
|
attachments = TRUE,
|
|
1002
1161
|
actions = TRUE,
|
|
1003
1162
|
threads = TRUE,
|
|
1163
|
+
quotations = TRUE,
|
|
1004
1164
|
readReceipts = TRUE,
|
|
1005
1165
|
onMarkedRead
|
|
1006
1166
|
}) {
|
|
@@ -1100,6 +1260,21 @@ function ConversationView({
|
|
|
1100
1260
|
() => threadRootId ? messages.find((m) => m.id === threadRootId) ?? null : null,
|
|
1101
1261
|
[threadRootId, messages]
|
|
1102
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
|
+
};
|
|
1103
1278
|
const { upload, uploading } = react$1.useAttachmentUpload();
|
|
1104
1279
|
const onPickFile = async (file) => {
|
|
1105
1280
|
try {
|
|
@@ -1114,20 +1289,35 @@ function ConversationView({
|
|
|
1114
1289
|
console.error("attachment upload failed:", err);
|
|
1115
1290
|
}
|
|
1116
1291
|
};
|
|
1117
|
-
const onSendBody = async (body) => {
|
|
1118
|
-
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);
|
|
1119
1298
|
};
|
|
1120
1299
|
const onSendWithMentions = async (req) => {
|
|
1121
1300
|
await send(req);
|
|
1301
|
+
setReplyingTo(null);
|
|
1122
1302
|
};
|
|
1123
1303
|
const Composer = mentions && members.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1124
1304
|
MentionInput,
|
|
1125
1305
|
{
|
|
1126
1306
|
conversationId,
|
|
1127
1307
|
onSend: onSendWithMentions,
|
|
1128
|
-
onTyping: signalTyping
|
|
1308
|
+
onTyping: signalTyping,
|
|
1309
|
+
...labelFor ? { labelFor } : {},
|
|
1310
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1311
|
+
}
|
|
1312
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1313
|
+
MessageComposer,
|
|
1314
|
+
{
|
|
1315
|
+
onSend: onSendBody,
|
|
1316
|
+
onTyping: signalTyping,
|
|
1317
|
+
...labelFor ? { labelFor } : {},
|
|
1318
|
+
...quotations ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
1129
1319
|
}
|
|
1130
|
-
)
|
|
1320
|
+
);
|
|
1131
1321
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
1132
1322
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation", children: [
|
|
1133
1323
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__status", children: [
|
|
@@ -1143,7 +1333,7 @@ function ConversationView({
|
|
|
1143
1333
|
}
|
|
1144
1334
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
1145
1335
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
1146
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1336
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1147
1337
|
MessageRow,
|
|
1148
1338
|
{
|
|
1149
1339
|
msg,
|
|
@@ -1152,7 +1342,9 @@ function ConversationView({
|
|
|
1152
1342
|
attachments,
|
|
1153
1343
|
actions,
|
|
1154
1344
|
threads,
|
|
1345
|
+
quotations,
|
|
1155
1346
|
...readState ? { readState } : {},
|
|
1347
|
+
...labelFor ? { labelFor } : {},
|
|
1156
1348
|
editing: editingId === msg.id,
|
|
1157
1349
|
onStartEdit: () => setEditingId(msg.id),
|
|
1158
1350
|
onCancelEdit: () => setEditingId(null),
|
|
@@ -1161,10 +1353,11 @@ function ConversationView({
|
|
|
1161
1353
|
setEditingId(null);
|
|
1162
1354
|
},
|
|
1163
1355
|
onDelete: () => void deleteMsg(msg.id),
|
|
1164
|
-
onOpenThread: () => setThreadRootId(msg.id)
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1356
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
1357
|
+
onQuote: () => setReplyingTo(msg),
|
|
1358
|
+
onQuotedClick: scrollToOriginal
|
|
1359
|
+
}
|
|
1360
|
+
) }, msg.id);
|
|
1168
1361
|
}),
|
|
1169
1362
|
error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
|
|
1170
1363
|
"Failed to load: ",
|
|
@@ -1260,13 +1453,15 @@ function ConversationList({
|
|
|
1260
1453
|
emptyState,
|
|
1261
1454
|
conversations: controlledConversations,
|
|
1262
1455
|
loading: controlledLoading,
|
|
1263
|
-
error: controlledError
|
|
1456
|
+
error: controlledError,
|
|
1457
|
+
unreadCounts
|
|
1264
1458
|
}) {
|
|
1265
1459
|
const auto = react$1.useConversations();
|
|
1266
1460
|
const isControlled = controlledConversations !== void 0;
|
|
1267
1461
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
1268
1462
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
1269
1463
|
const error = isControlled ? controlledError ?? null : auto.error;
|
|
1464
|
+
const counts = unreadCounts ?? (isControlled ? void 0 : auto.unreadCounts);
|
|
1270
1465
|
if (loading && conversations.length === 0) {
|
|
1271
1466
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading conversations\u2026" });
|
|
1272
1467
|
}
|
|
@@ -1278,7 +1473,8 @@ function ConversationList({
|
|
|
1278
1473
|
}
|
|
1279
1474
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list", role: "listbox", "aria-label": "Conversations", children: conversations.map((conv) => {
|
|
1280
1475
|
const selected = selectedId === conv.id;
|
|
1281
|
-
const
|
|
1476
|
+
const unread = counts?.[conv.id] ?? 0;
|
|
1477
|
+
const content = renderItem ? renderItem(conv, selected) : /* @__PURE__ */ jsxRuntime.jsx(DefaultRow, { conv, selected, unread });
|
|
1282
1478
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1283
1479
|
"li",
|
|
1284
1480
|
{
|
|
@@ -1299,18 +1495,31 @@ function ConversationList({
|
|
|
1299
1495
|
);
|
|
1300
1496
|
}) });
|
|
1301
1497
|
}
|
|
1302
|
-
function DefaultRow({
|
|
1498
|
+
function DefaultRow({
|
|
1499
|
+
conv,
|
|
1500
|
+
selected: _selected,
|
|
1501
|
+
unread
|
|
1502
|
+
}) {
|
|
1303
1503
|
const title = conv.name ?? "Untitled conversation";
|
|
1304
1504
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
1505
|
+
const hasUnread = unread > 0;
|
|
1305
1506
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1306
1507
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: conv.avatar_url ?? null, name: conv.name, size: "md" }),
|
|
1307
1508
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
|
|
1308
1509
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__head", children: [
|
|
1309
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__title"
|
|
1510
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `poolse-list__title${hasUnread ? " poolse-list__title--unread" : ""}`, children: title }),
|
|
1310
1511
|
time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-list__time", children: time })
|
|
1311
1512
|
] }),
|
|
1312
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" })
|
|
1313
|
-
] })
|
|
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
|
+
)
|
|
1314
1523
|
] });
|
|
1315
1524
|
}
|
|
1316
1525
|
function formatRelative(iso) {
|
|
@@ -1336,7 +1545,10 @@ function MemberList({
|
|
|
1336
1545
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
|
|
1337
1546
|
}
|
|
1338
1547
|
if (error) {
|
|
1339
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
1548
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list poolse-list--placeholder poolse-list--error", children: [
|
|
1549
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "Failed to load members." }),
|
|
1550
|
+
error.message && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list__error-detail", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: error.message }) })
|
|
1551
|
+
] });
|
|
1340
1552
|
}
|
|
1341
1553
|
if (members.length === 0) {
|
|
1342
1554
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState ?? "No members yet." });
|