@poolse/react-ui 1.0.1-beta.0 → 1.0.2

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useMembers, useAttachmentUrl, useUser, useReactions, useMe, useThread, useMessages, useTyping, useRealtimeStatus, useAttachmentUpload, useConversations } from '@poolse/react';
2
+ import { useUser, useMembers, useAttachmentUrl, useReactions, useMe, useThread, useMessages, useTyping, useRealtimeStatus, useAttachmentUpload, useConversations, usePresence } from '@poolse/react';
3
3
  import { useEffect, useState, useRef, Fragment as Fragment$1, useMemo } from 'react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import ReactMarkdown from 'react-markdown';
@@ -42,6 +42,43 @@ function PoolseFonts() {
42
42
  return null;
43
43
  }
44
44
 
45
+ // src/grouping.ts
46
+ function computeGroupPosition(msg, prev, next, windowMs) {
47
+ const continuesPrev = sameGroup(msg, prev, windowMs);
48
+ const continuesNext = sameGroup(next, msg, windowMs);
49
+ if (continuesPrev && continuesNext) return "middle";
50
+ if (continuesPrev) return "last";
51
+ if (continuesNext) return "first";
52
+ return "standalone";
53
+ }
54
+ function sameGroup(a, b, windowMs) {
55
+ if (!a || !b) return false;
56
+ if (a.sender_id !== b.sender_id) return false;
57
+ if (!sameDay(a.inserted_at, b.inserted_at)) return false;
58
+ const ta = new Date(a.inserted_at).getTime();
59
+ const tb = new Date(b.inserted_at).getTime();
60
+ return Math.abs(ta - tb) <= windowMs;
61
+ }
62
+ function sameDay(a, b) {
63
+ const da = new Date(a);
64
+ const db = new Date(b);
65
+ return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
66
+ }
67
+ function formatDayLabel(iso, now = /* @__PURE__ */ new Date()) {
68
+ const d = new Date(iso);
69
+ const startOfDay = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
70
+ const diffDays = Math.floor((startOfDay(now) - startOfDay(d)) / 864e5);
71
+ if (diffDays === 0) return "Today";
72
+ if (diffDays === 1) return "Yesterday";
73
+ if (diffDays < 7) {
74
+ return d.toLocaleDateString(void 0, { weekday: "long" });
75
+ }
76
+ if (d.getFullYear() === now.getFullYear()) {
77
+ return d.toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" });
78
+ }
79
+ return d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" });
80
+ }
81
+
45
82
  // src/listAutocomplete.ts
46
83
  var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
47
84
  var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
@@ -280,6 +317,31 @@ function PoolseIcon({
280
317
  }
281
318
  );
282
319
  }
320
+ var MAX_NAME_CHARS = 24;
321
+ function UserName({
322
+ userId,
323
+ labelFor,
324
+ emptyFallback = "Unknown",
325
+ className
326
+ }) {
327
+ const { profile } = useUser(labelFor ? null : userId);
328
+ const name = resolveDisplayName(userId, profile?.displayName, labelFor, emptyFallback);
329
+ return /* @__PURE__ */ jsx("span", { className, children: truncate(name) });
330
+ }
331
+ function useDisplayName(userId, labelFor, emptyFallback = "Unknown") {
332
+ const { profile } = useUser(labelFor ? null : userId);
333
+ return resolveDisplayName(userId, profile?.displayName, labelFor, emptyFallback);
334
+ }
335
+ function resolveDisplayName(userId, resolved, labelFor, emptyFallback) {
336
+ if (!userId) return emptyFallback;
337
+ if (labelFor) return labelFor(userId);
338
+ if (resolved) return resolved;
339
+ return `User ${userId.slice(0, 6)}`;
340
+ }
341
+ function truncate(s) {
342
+ if (s.length <= MAX_NAME_CHARS) return s;
343
+ return s.slice(0, MAX_NAME_CHARS - 1) + "\u2026";
344
+ }
283
345
  function MentionInput({
284
346
  conversationId,
285
347
  onSend,
@@ -445,7 +507,13 @@ function MentionInput({
445
507
  onChange,
446
508
  onKeyDown,
447
509
  placeholder,
448
- disabled: disabled || sending
510
+ disabled: disabled || sending,
511
+ "aria-label": placeholder,
512
+ role: "combobox",
513
+ "aria-expanded": Boolean(mention && filtered.length > 0),
514
+ "aria-controls": "poolse-mention-menu",
515
+ "aria-autocomplete": "list",
516
+ ...mention && filtered.length > 0 ? { "aria-activedescendant": `poolse-mention-opt-${activeIdx}` } : {}
449
517
  }
450
518
  ),
451
519
  /* @__PURE__ */ jsx(
@@ -459,23 +527,33 @@ function MentionInput({
459
527
  }
460
528
  )
461
529
  ] }),
462
- mention && filtered.length > 0 && /* @__PURE__ */ jsx("div", { className: "poolse-mention-menu", role: "listbox", "aria-label": "Members", children: filtered.map((m, i) => /* @__PURE__ */ jsx(
530
+ mention && filtered.length > 0 && /* @__PURE__ */ jsx(
463
531
  "div",
464
532
  {
465
- role: "option",
466
- "aria-selected": i === activeIdx,
467
- className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
468
- onMouseDown: (e) => {
469
- e.preventDefault();
470
- insertMention(m);
471
- },
472
- children: /* @__PURE__ */ jsxs("span", { children: [
473
- "@",
474
- label(m.user_id)
475
- ] })
476
- },
477
- m.id
478
- )) })
533
+ id: "poolse-mention-menu",
534
+ className: "poolse-mention-menu",
535
+ role: "listbox",
536
+ "aria-label": "Members",
537
+ children: filtered.map((m, i) => /* @__PURE__ */ jsxs(
538
+ "div",
539
+ {
540
+ id: `poolse-mention-opt-${i}`,
541
+ role: "option",
542
+ "aria-selected": i === activeIdx,
543
+ className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
544
+ onMouseDown: (e) => {
545
+ e.preventDefault();
546
+ insertMention(m);
547
+ },
548
+ children: [
549
+ /* @__PURE__ */ jsx("span", { children: "@" }),
550
+ /* @__PURE__ */ jsx(UserName, { userId: m.user_id, ...labelFor ? { labelFor } : {} })
551
+ ]
552
+ },
553
+ m.id
554
+ ))
555
+ }
556
+ )
479
557
  ]
480
558
  }
481
559
  );
@@ -556,7 +634,8 @@ function MessageComposer({
556
634
  onChange,
557
635
  onKeyDown,
558
636
  placeholder,
559
- disabled: disabled || sending
637
+ disabled: disabled || sending,
638
+ "aria-label": placeholder
560
639
  }
561
640
  ),
562
641
  /* @__PURE__ */ jsx(
@@ -605,6 +684,7 @@ function ReplyChip({
605
684
  function AttachmentPreview({ attachment, onClick }) {
606
685
  const isFullRow = "content_type" in attachment;
607
686
  const { url, loading, error } = useAttachmentUrl(attachment.id);
687
+ const [lightboxOpen, setLightboxOpen] = useState(false);
608
688
  if (loading) {
609
689
  return /* @__PURE__ */ jsx("div", { className: "poolse-attachment poolse-list--placeholder", "aria-busy": "true", children: "Loading attachment\u2026" });
610
690
  }
@@ -615,29 +695,33 @@ function AttachmentPreview({ attachment, onClick }) {
615
695
  const isImage = ct.startsWith("image/");
616
696
  if (isImage) {
617
697
  const filename2 = isFullRow ? attachment.original_filename : null;
618
- return /* @__PURE__ */ jsx("div", { className: "poolse-attachment", children: /* @__PURE__ */ jsx(
619
- "a",
620
- {
621
- href: url,
622
- target: "_blank",
623
- rel: "noopener noreferrer",
624
- onClick: (e) => {
625
- if (onClick) {
626
- e.preventDefault();
627
- onClick({ id: attachment.id });
628
- }
629
- },
630
- children: /* @__PURE__ */ jsx(
631
- "img",
632
- {
633
- className: "poolse-attachment__image",
634
- src: url,
635
- alt: filename2 ?? "attachment",
636
- loading: "lazy"
637
- }
638
- )
639
- }
640
- ) });
698
+ return /* @__PURE__ */ jsxs("div", { className: "poolse-attachment", children: [
699
+ /* @__PURE__ */ jsx(
700
+ "button",
701
+ {
702
+ type: "button",
703
+ className: "poolse-attachment__image-button",
704
+ "aria-label": filename2 ? `Open ${filename2}` : "Open image",
705
+ onClick: () => {
706
+ if (onClick) {
707
+ onClick({ id: attachment.id });
708
+ return;
709
+ }
710
+ setLightboxOpen(true);
711
+ },
712
+ children: /* @__PURE__ */ jsx(
713
+ "img",
714
+ {
715
+ className: "poolse-attachment__image",
716
+ src: url,
717
+ alt: filename2 ?? "attachment",
718
+ loading: "lazy"
719
+ }
720
+ )
721
+ }
722
+ ),
723
+ lightboxOpen && /* @__PURE__ */ jsx(Lightbox, { url, filename: filename2, onClose: () => setLightboxOpen(false) })
724
+ ] });
641
725
  }
642
726
  const filename = isFullRow ? attachment.original_filename ?? "file" : "file";
643
727
  const byteSize = isFullRow ? attachment.byte_size : null;
@@ -682,6 +766,70 @@ function AttachmentPreview({ attachment, onClick }) {
682
766
  }
683
767
  ) });
684
768
  }
769
+ function Lightbox({
770
+ url,
771
+ filename,
772
+ onClose
773
+ }) {
774
+ useEffect(() => {
775
+ const onKey = (e) => {
776
+ if (e.key === "Escape") onClose();
777
+ };
778
+ document.addEventListener("keydown", onKey);
779
+ const prev = document.body.style.overflow;
780
+ document.body.style.overflow = "hidden";
781
+ return () => {
782
+ document.removeEventListener("keydown", onKey);
783
+ document.body.style.overflow = prev;
784
+ };
785
+ }, [onClose]);
786
+ return /* @__PURE__ */ jsxs(
787
+ "div",
788
+ {
789
+ className: "poolse-lightbox",
790
+ role: "dialog",
791
+ "aria-modal": "true",
792
+ "aria-label": filename ?? "Image preview",
793
+ onClick: onClose,
794
+ children: [
795
+ /* @__PURE__ */ jsx(
796
+ "button",
797
+ {
798
+ type: "button",
799
+ className: "poolse-lightbox__close",
800
+ "aria-label": "Close",
801
+ onClick: (e) => {
802
+ e.stopPropagation();
803
+ onClose();
804
+ },
805
+ children: "\xD7"
806
+ }
807
+ ),
808
+ /* @__PURE__ */ jsx(
809
+ "img",
810
+ {
811
+ className: "poolse-lightbox__image",
812
+ src: url,
813
+ alt: filename ?? "attachment",
814
+ onClick: (e) => e.stopPropagation()
815
+ }
816
+ ),
817
+ /* @__PURE__ */ jsx(
818
+ "a",
819
+ {
820
+ className: "poolse-lightbox__download",
821
+ href: url,
822
+ download: filename ?? void 0,
823
+ target: "_blank",
824
+ rel: "noopener noreferrer",
825
+ onClick: (e) => e.stopPropagation(),
826
+ children: "Download"
827
+ }
828
+ )
829
+ ]
830
+ }
831
+ );
832
+ }
685
833
  function guessContentType(url) {
686
834
  const m = url.match(/\.([a-z0-9]+)(?:\?|#|$)/i);
687
835
  if (!m) return "application/octet-stream";
@@ -1032,19 +1180,53 @@ function ReactionPicker({
1032
1180
  onPick,
1033
1181
  onClose
1034
1182
  }) {
1183
+ const rootRef = useRef(null);
1184
+ useEffect(() => {
1185
+ const firstBtn = rootRef.current?.querySelector("button");
1186
+ if (firstBtn instanceof HTMLElement) firstBtn.focus();
1187
+ }, []);
1188
+ useEffect(() => {
1189
+ if (!onClose) return;
1190
+ const onPointer = (e) => {
1191
+ const t = e.target;
1192
+ if (t instanceof Node && rootRef.current && !rootRef.current.contains(t)) {
1193
+ onClose();
1194
+ }
1195
+ };
1196
+ document.addEventListener("pointerdown", onPointer, true);
1197
+ return () => document.removeEventListener("pointerdown", onPointer, true);
1198
+ }, [onClose]);
1199
+ const onKey = (e) => {
1200
+ if (e.key === "Escape") {
1201
+ e.stopPropagation();
1202
+ onClose?.();
1203
+ return;
1204
+ }
1205
+ if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
1206
+ const buttons = Array.from(
1207
+ rootRef.current?.querySelectorAll("button") ?? []
1208
+ );
1209
+ const idx = buttons.findIndex((b) => b === document.activeElement);
1210
+ if (idx === -1) return;
1211
+ const nextIdx = e.key === "ArrowRight" ? (idx + 1) % buttons.length : (idx - 1 + buttons.length) % buttons.length;
1212
+ buttons[nextIdx]?.focus();
1213
+ e.preventDefault();
1214
+ }
1215
+ };
1035
1216
  return /* @__PURE__ */ jsx(
1036
1217
  "div",
1037
1218
  {
1219
+ ref: rootRef,
1038
1220
  className: "poolse-reaction-picker",
1039
1221
  role: "menu",
1222
+ "aria-label": "Pick a reaction",
1040
1223
  style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
1041
- onKeyDown: (e) => {
1042
- if (e.key === "Escape") onClose?.();
1043
- },
1224
+ onKeyDown: onKey,
1044
1225
  children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsx(
1045
1226
  "button",
1046
1227
  {
1047
1228
  type: "button",
1229
+ role: "menuitem",
1048
1230
  className: "poolse-reaction-picker__btn",
1049
1231
  onClick: () => onPick(e),
1050
1232
  "aria-label": `React with ${e}`,
@@ -1149,9 +1331,29 @@ function MessageRow({
1149
1331
  const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
1150
1332
  const handleSave = onSaveEdit ?? (async () => void 0);
1151
1333
  const handleCancel = onCancelEdit ?? (() => void 0);
1334
+ const [actionsOpen, setActionsOpen] = useState(false);
1335
+ const rowRef = useRef(null);
1336
+ useEffect(() => {
1337
+ if (!actionsOpen) return;
1338
+ const onDown = (e) => {
1339
+ const t = e.target;
1340
+ if (t instanceof Node && rowRef.current && !rowRef.current.contains(t)) {
1341
+ setActionsOpen(false);
1342
+ }
1343
+ };
1344
+ document.addEventListener("pointerdown", onDown);
1345
+ return () => document.removeEventListener("pointerdown", onDown);
1346
+ }, [actionsOpen]);
1347
+ const onRowClick = (e) => {
1348
+ if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
1349
+ const target = e.target;
1350
+ if (target.closest("a, button, input, textarea, label, select")) return;
1351
+ setActionsOpen((o) => !o);
1352
+ };
1152
1353
  return /* @__PURE__ */ jsxs(
1153
1354
  "div",
1154
1355
  {
1356
+ ref: rowRef,
1155
1357
  className: [
1156
1358
  "poolse-message-row",
1157
1359
  isSelf ? "poolse-message-row--right" : "",
@@ -1162,6 +1364,8 @@ function MessageRow({
1162
1364
  `poolse-message-row--${groupPosition}`
1163
1365
  ].filter(Boolean).join(" "),
1164
1366
  "data-message-id": msg.id,
1367
+ "data-actions-open": actionsOpen || void 0,
1368
+ onClick: onRowClick,
1165
1369
  children: [
1166
1370
  editing ? /* @__PURE__ */ jsx(
1167
1371
  EditableMessageBubble,
@@ -1310,6 +1514,7 @@ function ThreadView({
1310
1514
  rootMessage.id
1311
1515
  );
1312
1516
  const listRef = useRef(null);
1517
+ const closeBtnRef = useRef(null);
1313
1518
  const lastReplyIdRef = useRef(null);
1314
1519
  useEffect(() => {
1315
1520
  const tail = replies[replies.length - 1];
@@ -1319,60 +1524,158 @@ function ThreadView({
1319
1524
  const el = listRef.current;
1320
1525
  if (el) el.scrollTop = el.scrollHeight;
1321
1526
  }, [replies]);
1527
+ useEffect(() => {
1528
+ closeBtnRef.current?.focus();
1529
+ if (!onClose) return;
1530
+ const onKey = (e) => {
1531
+ if (e.key === "Escape") onClose();
1532
+ };
1533
+ document.addEventListener("keydown", onKey);
1534
+ return () => document.removeEventListener("keydown", onKey);
1535
+ }, [onClose]);
1322
1536
  const renderOne = renderMessage ?? defaultRenderReply;
1323
- return /* @__PURE__ */ jsxs("aside", { className: "poolse-thread", "aria-label": "Thread", children: [
1324
- /* @__PURE__ */ jsxs("header", { className: "poolse-thread__header", children: [
1325
- /* @__PURE__ */ jsx("div", { className: "poolse-thread__title", children: "Thread" }),
1326
- onClose && /* @__PURE__ */ jsx(
1327
- "button",
1328
- {
1329
- type: "button",
1330
- className: "poolse-icon-btn",
1331
- onClick: onClose,
1332
- "aria-label": "Close thread",
1333
- children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 18, label: null })
1334
- }
1335
- )
1336
- ] }),
1337
- /* @__PURE__ */ jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
1338
- /* @__PURE__ */ jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
1339
- hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
1340
- loading && replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "No replies yet \u2014 start the thread." }) : (
1341
- // Same Fragment trick as ConversationView so MessageBubble
1342
- // remains the direct flex child for align-self to work.
1343
- replies.map((msg) => /* @__PURE__ */ jsx(Fragment$1, { children: renderOne(msg, me?.id ?? null) }, msg.id))
1344
- ),
1345
- error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1346
- "Failed to load: ",
1347
- error.message
1348
- ] })
1349
- ] }),
1350
- /* @__PURE__ */ jsx(MessageComposer, { onSend: (body) => sendReply({ body }), placeholder: "Reply in thread\u2026" })
1351
- ] });
1537
+ return /* @__PURE__ */ jsxs(
1538
+ "aside",
1539
+ {
1540
+ className: "poolse-thread",
1541
+ role: "complementary",
1542
+ "aria-label": "Message thread",
1543
+ children: [
1544
+ /* @__PURE__ */ jsxs("header", { className: "poolse-thread__header", children: [
1545
+ /* @__PURE__ */ jsx("div", { className: "poolse-thread__title", children: "Thread" }),
1546
+ onClose && /* @__PURE__ */ jsx(
1547
+ "button",
1548
+ {
1549
+ ref: closeBtnRef,
1550
+ type: "button",
1551
+ className: "poolse-icon-btn",
1552
+ onClick: onClose,
1553
+ "aria-label": "Close thread",
1554
+ children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 18, label: null })
1555
+ }
1556
+ )
1557
+ ] }),
1558
+ /* @__PURE__ */ jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
1559
+ /* @__PURE__ */ jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
1560
+ hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
1561
+ loading && replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "No replies yet \u2014 start the thread." }) : (
1562
+ // Same Fragment trick as ConversationView so MessageBubble
1563
+ // remains the direct flex child for align-self to work.
1564
+ replies.map((msg) => /* @__PURE__ */ jsx(Fragment$1, { children: renderOne(msg, me?.id ?? null) }, msg.id))
1565
+ ),
1566
+ error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1567
+ "Failed to load: ",
1568
+ error.message
1569
+ ] })
1570
+ ] }),
1571
+ /* @__PURE__ */ jsx(MessageComposer, { onSend: (body) => sendReply({ body }), placeholder: "Reply in thread\u2026" })
1572
+ ]
1573
+ }
1574
+ );
1352
1575
  }
1353
1576
  function defaultRenderReply(msg, currentUserId) {
1354
1577
  return /* @__PURE__ */ jsx(MessageBubble, { message: msg, currentUserId });
1355
1578
  }
1356
1579
  function TypingIndicator({ typing, labelFor }) {
1357
1580
  const ids = Array.from(typing);
1358
- if (ids.length === 0) {
1359
- return /* @__PURE__ */ jsx("div", { className: "poolse-typing", "aria-hidden": "true" });
1360
- }
1361
- const label = labelFor ?? ((id) => id.slice(0, 6));
1362
- const names = ids.slice(0, 2).map(label);
1363
- let text;
1364
- if (ids.length === 1) text = `${names[0]} is typing`;
1365
- else if (ids.length === 2) text = `${names[0]} and ${names[1]} are typing`;
1366
- else text = `${ids.length} people are typing`;
1367
- return /* @__PURE__ */ jsxs("div", { className: "poolse-typing", children: [
1368
- /* @__PURE__ */ jsxs("span", { className: "poolse-typing__dots", role: "status", "aria-live": "polite", children: [
1581
+ const isTyping = ids.length > 0;
1582
+ return /* @__PURE__ */ jsxs("div", { className: "poolse-typing", "data-typing": isTyping || void 0, children: [
1583
+ /* @__PURE__ */ jsxs("span", { className: "poolse-typing__dots", "aria-hidden": "true", children: [
1369
1584
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" }),
1370
1585
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" }),
1371
1586
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" })
1372
1587
  ] }),
1373
- /* @__PURE__ */ jsx("span", { className: "poolse-typing__label", children: text })
1588
+ /* @__PURE__ */ jsx(
1589
+ "span",
1590
+ {
1591
+ className: "poolse-typing__label",
1592
+ role: "status",
1593
+ "aria-live": "polite",
1594
+ "aria-atomic": "true",
1595
+ children: isTyping ? /* @__PURE__ */ jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : ""
1596
+ }
1597
+ )
1374
1598
  ] });
1375
1599
  }
1600
+ function TypingLabel({ ids, labelFor }) {
1601
+ const id1 = ids[0] ?? null;
1602
+ const id2 = ids[1] ?? null;
1603
+ const name1 = useDisplayName(id1, labelFor);
1604
+ const name2 = useDisplayName(id2, labelFor);
1605
+ if (ids.length === 1) return /* @__PURE__ */ jsxs(Fragment, { children: [
1606
+ name1,
1607
+ " is typing"
1608
+ ] });
1609
+ if (ids.length === 2) {
1610
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1611
+ name1,
1612
+ " and ",
1613
+ name2,
1614
+ " are typing"
1615
+ ] });
1616
+ }
1617
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1618
+ ids.length,
1619
+ " people are typing"
1620
+ ] });
1621
+ }
1622
+ function UploadQueueStrip({ items, onCancel, onDismiss }) {
1623
+ if (items.length === 0) return null;
1624
+ return /* @__PURE__ */ jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsx(
1625
+ UploadChip,
1626
+ {
1627
+ item,
1628
+ onCancel: () => onCancel(item.localId),
1629
+ onDismiss: () => onDismiss(item.localId)
1630
+ },
1631
+ item.localId
1632
+ )) });
1633
+ }
1634
+ function UploadChip({
1635
+ item,
1636
+ onCancel,
1637
+ onDismiss
1638
+ }) {
1639
+ const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
1640
+ const isError = item.status === "error";
1641
+ const isInFlight = item.status === "pending" || item.status === "uploading";
1642
+ return /* @__PURE__ */ jsxs(
1643
+ "div",
1644
+ {
1645
+ className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
1646
+ "data-status": item.status,
1647
+ children: [
1648
+ /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(PoolseIcon, { name: isError ? "attachment" : "attachment", size: 18, label: null }) }),
1649
+ /* @__PURE__ */ jsxs("div", { className: "poolse-upload-chip__body", children: [
1650
+ /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
1651
+ isError ? /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : /* @__PURE__ */ jsx(
1652
+ "div",
1653
+ {
1654
+ className: "poolse-upload-chip__bar",
1655
+ role: "progressbar",
1656
+ "aria-valuemin": 0,
1657
+ "aria-valuemax": 100,
1658
+ "aria-valuenow": pct,
1659
+ "aria-label": `Uploading ${item.filename}`,
1660
+ children: /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
1661
+ }
1662
+ )
1663
+ ] }),
1664
+ /* @__PURE__ */ jsx(
1665
+ "button",
1666
+ {
1667
+ type: "button",
1668
+ className: "poolse-upload-chip__action",
1669
+ onClick: isInFlight ? onCancel : onDismiss,
1670
+ "aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
1671
+ title: isInFlight ? "Cancel" : "Dismiss",
1672
+ children: "\xD7"
1673
+ }
1674
+ )
1675
+ ]
1676
+ }
1677
+ );
1678
+ }
1376
1679
  var TRUE = true;
1377
1680
  function ConversationView({
1378
1681
  conversationId,
@@ -1420,8 +1723,32 @@ function ConversationView({
1420
1723
  const listRef = useRef(null);
1421
1724
  const lastMessageIdRef = useRef(null);
1422
1725
  const bottomSentinelRef = useRef(null);
1726
+ const topSentinelRef = useRef(null);
1727
+ const loadingMoreRef = useRef(false);
1423
1728
  const [atBottom, setAtBottom] = useState(true);
1424
1729
  const [newCountWhileAway, setNewCountWhileAway] = useState(0);
1730
+ useEffect(() => {
1731
+ const sentinel = topSentinelRef.current;
1732
+ const root = listRef.current;
1733
+ if (!sentinel || !root) return;
1734
+ if (!hasMore) return;
1735
+ const io = new IntersectionObserver(
1736
+ (entries) => {
1737
+ const entry = entries[0];
1738
+ if (!entry?.isIntersecting) return;
1739
+ if (loadingMoreRef.current) return;
1740
+ loadingMoreRef.current = true;
1741
+ void Promise.resolve(loadMore()).finally(() => {
1742
+ loadingMoreRef.current = false;
1743
+ });
1744
+ },
1745
+ // Fire when sentinel is within ~400px above the viewport — the
1746
+ // user is approaching the top of loaded history, fetch ahead.
1747
+ { root, rootMargin: "400px 0px 0px 0px", threshold: 0 }
1748
+ );
1749
+ io.observe(sentinel);
1750
+ return () => io.disconnect();
1751
+ }, [hasMore, loadMore]);
1425
1752
  useEffect(() => {
1426
1753
  const el = bottomSentinelRef.current;
1427
1754
  if (!el) return;
@@ -1511,20 +1838,56 @@ function ConversationView({
1511
1838
  el.classList.add("poolse-message-row--highlight");
1512
1839
  setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
1513
1840
  };
1514
- const { upload, uploading } = useAttachmentUpload();
1515
- const onPickFile = async (file) => {
1841
+ const { queue: uploadQueue, uploadAll, cancel: cancelUpload, remove: removeUpload, uploading } = useAttachmentUpload();
1842
+ const visibleUploads = uploadQueue.filter(
1843
+ (it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
1844
+ );
1845
+ const onPickFiles = async (files) => {
1846
+ if (files.length === 0) return;
1516
1847
  try {
1517
- const att = await upload({
1518
- body: file,
1519
- contentType: file.type || "application/octet-stream",
1520
- byteSize: file.size,
1521
- filename: file.name
1522
- });
1523
- await send({ body: "", attachment_ids: [att.id] });
1524
- } catch (err) {
1525
- console.error("attachment upload failed:", err);
1848
+ const atts = await uploadAll(
1849
+ files.map((f) => ({
1850
+ body: f,
1851
+ contentType: f.type || "application/octet-stream",
1852
+ byteSize: f.size,
1853
+ filename: f.name
1854
+ }))
1855
+ );
1856
+ await send({ body: "", attachment_ids: atts.map((a) => a.id) });
1857
+ for (const it of uploadQueue) {
1858
+ if (it.status === "ready") removeUpload(it.localId);
1859
+ }
1860
+ } catch {
1526
1861
  }
1527
1862
  };
1863
+ const [dragActive, setDragActive] = useState(false);
1864
+ const dragDepthRef = useRef(0);
1865
+ const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
1866
+ const onDragEnter = (e) => {
1867
+ if (!attachments || !isFileDrag(e)) return;
1868
+ e.preventDefault();
1869
+ dragDepthRef.current += 1;
1870
+ setDragActive(true);
1871
+ };
1872
+ const onDragOver = (e) => {
1873
+ if (!attachments || !isFileDrag(e)) return;
1874
+ e.preventDefault();
1875
+ if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
1876
+ };
1877
+ const onDragLeave = (e) => {
1878
+ if (!attachments || !isFileDrag(e)) return;
1879
+ e.preventDefault();
1880
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
1881
+ if (dragDepthRef.current === 0) setDragActive(false);
1882
+ };
1883
+ const onDrop = (e) => {
1884
+ if (!attachments || !isFileDrag(e)) return;
1885
+ e.preventDefault();
1886
+ dragDepthRef.current = 0;
1887
+ setDragActive(false);
1888
+ const files = Array.from(e.dataTransfer?.files ?? []);
1889
+ if (files.length > 0) void onPickFiles(files);
1890
+ };
1528
1891
  const onSendBody = async (body, opts) => {
1529
1892
  await send({
1530
1893
  body,
@@ -1555,98 +1918,141 @@ function ConversationView({
1555
1918
  }
1556
1919
  );
1557
1920
  return /* @__PURE__ */ jsxs("div", { className: "poolse-conversation-shell", children: [
1558
- /* @__PURE__ */ jsxs("div", { className: "poolse-conversation", children: [
1559
- status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__status", children: [
1560
- status === "connecting" && "Connecting\u2026",
1561
- status === "reconnecting" && "Reconnecting\u2026",
1562
- status === "closed" && "Disconnected"
1563
- ] }),
1564
- /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__messages", ref: listRef, children: [
1565
- hasMore && !loading && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older messages" }),
1566
- loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
1567
- if (renderMessage) {
1568
- return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1569
- }
1570
- const prev = idx > 0 ? messages[idx - 1] ?? null : null;
1571
- const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
1572
- const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
1573
- const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
1574
- const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1575
- const original = messages.find((m) => m.id === msg.quoted_message_id);
1576
- if (!original) return msg;
1577
- return {
1578
- ...msg,
1579
- quoted_message: {
1580
- id: original.id,
1581
- sender_id: original.sender_id,
1582
- body: original.body,
1583
- deleted_at: original.deleted_at,
1584
- inserted_at: original.inserted_at
1585
- }
1586
- };
1587
- })() : msg;
1588
- const isSelf = me !== null && msg.sender_id === me.id;
1589
- const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1590
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1591
- showDaySeparator && /* @__PURE__ */ jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
1592
- /* @__PURE__ */ jsx(
1593
- MessageRow,
1594
- {
1595
- msg: enriched,
1596
- meId: me?.id ?? null,
1597
- reactions,
1598
- attachments,
1599
- actions,
1600
- threads,
1601
- quotations,
1602
- groupPosition,
1603
- maxBodyLength,
1604
- markdown,
1605
- showSenderName: showSenderLabelsResolved,
1606
- showAvatar: showAvatarsResolved,
1607
- ...readState ? { readState } : {},
1608
- ...labelFor ? { labelFor } : {},
1609
- editing: editingId === msg.id,
1610
- onStartEdit: () => setEditingId(msg.id),
1611
- onCancelEdit: () => setEditingId(null),
1612
- onSaveEdit: async (body) => {
1613
- await edit(msg.id, body);
1614
- setEditingId(null);
1615
- },
1616
- onDelete: () => void deleteMsg(msg.id),
1617
- onOpenThread: () => setThreadRootId(msg.id),
1618
- onQuote: () => setReplyingTo(msg),
1619
- onQuotedClick: scrollToOriginal
1620
- }
1621
- )
1622
- ] }, msg.id);
1623
- }),
1624
- error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1625
- "Failed to load: ",
1626
- error.message
1627
- ] }),
1628
- /* @__PURE__ */ jsx("div", { ref: bottomSentinelRef, "aria-hidden": "true", style: { height: 1 } })
1629
- ] }),
1630
- !atBottom && newCountWhileAway > 0 && /* @__PURE__ */ jsxs(
1631
- "button",
1632
- {
1633
- type: "button",
1634
- className: "poolse-conversation__scroll-to-new",
1635
- onClick: scrollToBottom,
1636
- children: [
1637
- "\u2193 ",
1638
- newCountWhileAway,
1639
- " new ",
1640
- newCountWhileAway === 1 ? "message" : "messages"
1641
- ]
1642
- }
1643
- ),
1644
- /* @__PURE__ */ jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
1645
- /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__composer-row", children: [
1646
- attachments && /* @__PURE__ */ jsx(AttachmentPickerButton, { onPick: onPickFile, disabled: uploading }),
1647
- /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
1648
- ] })
1649
- ] }),
1921
+ /* @__PURE__ */ jsxs(
1922
+ "div",
1923
+ {
1924
+ className: `poolse-conversation${dragActive ? " is-drag-active" : ""}`,
1925
+ onDragEnter,
1926
+ onDragOver,
1927
+ onDragLeave,
1928
+ onDrop,
1929
+ children: [
1930
+ status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs(
1931
+ "div",
1932
+ {
1933
+ className: "poolse-conversation__status",
1934
+ role: "status",
1935
+ "aria-live": "polite",
1936
+ "aria-atomic": "true",
1937
+ children: [
1938
+ status === "connecting" && "Connecting\u2026",
1939
+ status === "reconnecting" && "Reconnecting\u2026",
1940
+ status === "closed" && "Disconnected"
1941
+ ]
1942
+ }
1943
+ ),
1944
+ /* @__PURE__ */ jsxs(
1945
+ "div",
1946
+ {
1947
+ className: "poolse-conversation__messages",
1948
+ ref: listRef,
1949
+ role: "log",
1950
+ "aria-label": "Conversation messages",
1951
+ "aria-live": "polite",
1952
+ "aria-relevant": "additions",
1953
+ children: [
1954
+ hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
1955
+ loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
1956
+ if (renderMessage) {
1957
+ return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1958
+ }
1959
+ const prev = idx > 0 ? messages[idx - 1] ?? null : null;
1960
+ const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
1961
+ const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
1962
+ const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
1963
+ const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1964
+ const original = messages.find((m) => m.id === msg.quoted_message_id);
1965
+ if (!original) return msg;
1966
+ return {
1967
+ ...msg,
1968
+ quoted_message: {
1969
+ id: original.id,
1970
+ sender_id: original.sender_id,
1971
+ body: original.body,
1972
+ deleted_at: original.deleted_at,
1973
+ inserted_at: original.inserted_at
1974
+ }
1975
+ };
1976
+ })() : msg;
1977
+ const isSelf = me !== null && msg.sender_id === me.id;
1978
+ const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1979
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1980
+ showDaySeparator && /* @__PURE__ */ jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
1981
+ /* @__PURE__ */ jsx(
1982
+ MessageRow,
1983
+ {
1984
+ msg: enriched,
1985
+ meId: me?.id ?? null,
1986
+ reactions,
1987
+ attachments,
1988
+ actions,
1989
+ threads,
1990
+ quotations,
1991
+ groupPosition,
1992
+ maxBodyLength,
1993
+ markdown,
1994
+ showSenderName: showSenderLabelsResolved,
1995
+ showAvatar: showAvatarsResolved,
1996
+ ...readState ? { readState } : {},
1997
+ ...labelFor ? { labelFor } : {},
1998
+ editing: editingId === msg.id,
1999
+ onStartEdit: () => setEditingId(msg.id),
2000
+ onCancelEdit: () => setEditingId(null),
2001
+ onSaveEdit: async (body) => {
2002
+ await edit(msg.id, body);
2003
+ setEditingId(null);
2004
+ },
2005
+ onDelete: () => void deleteMsg(msg.id),
2006
+ onOpenThread: () => setThreadRootId(msg.id),
2007
+ onQuote: () => setReplyingTo(msg),
2008
+ onQuotedClick: scrollToOriginal
2009
+ }
2010
+ )
2011
+ ] }, msg.id);
2012
+ }),
2013
+ error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
2014
+ "Failed to load: ",
2015
+ error.message
2016
+ ] }),
2017
+ /* @__PURE__ */ jsx("div", { ref: bottomSentinelRef, "aria-hidden": "true", style: { height: 1 } })
2018
+ ]
2019
+ }
2020
+ ),
2021
+ !atBottom && newCountWhileAway > 0 && /* @__PURE__ */ jsxs(
2022
+ "button",
2023
+ {
2024
+ type: "button",
2025
+ className: "poolse-conversation__scroll-to-new",
2026
+ onClick: scrollToBottom,
2027
+ children: [
2028
+ "\u2193 ",
2029
+ newCountWhileAway,
2030
+ " new ",
2031
+ newCountWhileAway === 1 ? "message" : "messages"
2032
+ ]
2033
+ }
2034
+ ),
2035
+ /* @__PURE__ */ jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
2036
+ attachments && /* @__PURE__ */ jsx(
2037
+ UploadQueueStrip,
2038
+ {
2039
+ items: visibleUploads,
2040
+ onCancel: cancelUpload,
2041
+ onDismiss: removeUpload
2042
+ }
2043
+ ),
2044
+ /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__composer-row", children: [
2045
+ attachments && /* @__PURE__ */ jsx(AttachmentPickerButton, { onPick: onPickFiles, disabled: uploading }),
2046
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
2047
+ ] }),
2048
+ dragActive && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
2049
+ /* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
2050
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
2051
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-hint", children: "They'll be sent in one message" })
2052
+ ] }) })
2053
+ ]
2054
+ }
2055
+ ),
1650
2056
  threads && threadRoot && /* @__PURE__ */ jsx("div", { className: "poolse-conversation-shell__thread", children: /* @__PURE__ */ jsx(
1651
2057
  ThreadView,
1652
2058
  {
@@ -1668,10 +2074,11 @@ function AttachmentPickerButton({
1668
2074
  {
1669
2075
  ref: inputRef,
1670
2076
  type: "file",
2077
+ multiple: true,
1671
2078
  className: "poolse-attach-input",
1672
2079
  onChange: (e) => {
1673
- const f = e.target.files?.[0];
1674
- if (f) onPick(f);
2080
+ const files = Array.from(e.target.files ?? []);
2081
+ if (files.length > 0) onPick(files);
1675
2082
  e.target.value = "";
1676
2083
  }
1677
2084
  }
@@ -1683,49 +2090,13 @@ function AttachmentPickerButton({
1683
2090
  className: "poolse-attach-btn",
1684
2091
  onClick: () => inputRef.current?.click(),
1685
2092
  disabled,
1686
- "aria-label": "Attach file",
1687
- title: "Attach file",
2093
+ "aria-label": "Attach files",
2094
+ title: "Attach files",
1688
2095
  children: /* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
1689
2096
  }
1690
2097
  )
1691
2098
  ] });
1692
2099
  }
1693
- function computeGroupPosition(msg, prev, next, windowMs) {
1694
- const continuesPrev = sameGroup(msg, prev, windowMs);
1695
- const continuesNext = sameGroup(next, msg, windowMs);
1696
- if (continuesPrev && continuesNext) return "middle";
1697
- if (continuesPrev) return "last";
1698
- if (continuesNext) return "first";
1699
- return "standalone";
1700
- }
1701
- function sameGroup(a, b, windowMs) {
1702
- if (!a || !b) return false;
1703
- if (a.sender_id !== b.sender_id) return false;
1704
- if (!sameDay(a.inserted_at, b.inserted_at)) return false;
1705
- const ta = new Date(a.inserted_at).getTime();
1706
- const tb = new Date(b.inserted_at).getTime();
1707
- return Math.abs(ta - tb) <= windowMs;
1708
- }
1709
- function sameDay(a, b) {
1710
- const da = new Date(a);
1711
- const db = new Date(b);
1712
- return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
1713
- }
1714
- function formatDayLabel(iso) {
1715
- const d = new Date(iso);
1716
- const now = /* @__PURE__ */ new Date();
1717
- const startOfDay = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
1718
- const diffDays = Math.floor((startOfDay(now) - startOfDay(d)) / 864e5);
1719
- if (diffDays === 0) return "Today";
1720
- if (diffDays === 1) return "Yesterday";
1721
- if (diffDays < 7) {
1722
- return d.toLocaleDateString(void 0, { weekday: "long" });
1723
- }
1724
- if (d.getFullYear() === now.getFullYear()) {
1725
- return d.toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" });
1726
- }
1727
- return d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" });
1728
- }
1729
2100
  function ConversationList({
1730
2101
  selectedId,
1731
2102
  onSelect,
@@ -1821,6 +2192,10 @@ function MemberList({
1821
2192
  emptyState
1822
2193
  }) {
1823
2194
  const { members, loading, error, removeMember } = useMembers(conversationId);
2195
+ const { online: presenceOnline } = usePresence(
2196
+ onlineUserIds === void 0 ? conversationId : ""
2197
+ );
2198
+ const effectiveOnline = onlineUserIds ?? presenceOnline;
1824
2199
  if (loading && members.length === 0) {
1825
2200
  return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
1826
2201
  }
@@ -1833,19 +2208,18 @@ function MemberList({
1833
2208
  if (members.length === 0) {
1834
2209
  return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState ?? "No members yet." });
1835
2210
  }
1836
- const label = labelFor ?? ((id) => id.slice(0, 8));
1837
2211
  return /* @__PURE__ */ jsx("ul", { className: "poolse-list", role: "list", "aria-label": "Members", children: members.map((m) => {
1838
2212
  const content = renderItem ? renderItem(m) : /* @__PURE__ */ jsx(
1839
2213
  DefaultMemberRow,
1840
2214
  {
1841
2215
  membership: m,
1842
- name: label(m.user_id),
1843
2216
  avatarUrl: avatarFor?.(m.user_id) ?? null,
1844
- online: onlineUserIds?.has(m.user_id) ?? false,
2217
+ online: effectiveOnline.has(m.user_id),
1845
2218
  removable: canRemove?.(m) ?? false,
1846
2219
  onRemove: () => {
1847
2220
  void removeMember(m.user_id);
1848
- }
2221
+ },
2222
+ ...labelFor ? { labelFor } : {}
1849
2223
  }
1850
2224
  );
1851
2225
  return /* @__PURE__ */ jsx("li", { className: "poolse-list__item", children: content }, m.id);
@@ -1853,12 +2227,13 @@ function MemberList({
1853
2227
  }
1854
2228
  function DefaultMemberRow({
1855
2229
  membership,
1856
- name,
1857
2230
  avatarUrl,
1858
2231
  online,
1859
2232
  removable,
1860
- onRemove
2233
+ onRemove,
2234
+ labelFor
1861
2235
  }) {
2236
+ const name = useDisplayName(membership.user_id, labelFor);
1862
2237
  return /* @__PURE__ */ jsxs("div", { className: "poolse-member-row", children: [
1863
2238
  /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name, online, size: "md" }),
1864
2239
  /* @__PURE__ */ jsxs("div", { className: "poolse-member-row__body", children: [
@@ -1993,6 +2368,6 @@ function PoolseLogo({
1993
2368
  );
1994
2369
  }
1995
2370
 
1996
- export { AttachmentPreview, Avatar, ConversationList, ConversationView, EditableMessageBubble, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, usePoolseFonts };
2371
+ export { AttachmentPreview, Avatar, ConversationList, ConversationView, EditableMessageBubble, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, useDisplayName, usePoolseFonts };
1997
2372
  //# sourceMappingURL=index.js.map
1998
2373
  //# sourceMappingURL=index.js.map