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

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,23 @@ 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]);
1152
1347
  return /* @__PURE__ */ jsxs(
1153
1348
  "div",
1154
1349
  {
1350
+ ref: rowRef,
1155
1351
  className: [
1156
1352
  "poolse-message-row",
1157
1353
  isSelf ? "poolse-message-row--right" : "",
@@ -1162,6 +1358,7 @@ function MessageRow({
1162
1358
  `poolse-message-row--${groupPosition}`
1163
1359
  ].filter(Boolean).join(" "),
1164
1360
  "data-message-id": msg.id,
1361
+ "data-actions-open": actionsOpen || void 0,
1165
1362
  children: [
1166
1363
  editing ? /* @__PURE__ */ jsx(
1167
1364
  EditableMessageBubble,
@@ -1224,6 +1421,17 @@ function MessageRow({
1224
1421
  ]
1225
1422
  }
1226
1423
  ),
1424
+ showActions && /* @__PURE__ */ jsx(
1425
+ "button",
1426
+ {
1427
+ type: "button",
1428
+ className: "poolse-message-row__more",
1429
+ "aria-label": "Show message actions",
1430
+ "aria-expanded": actionsOpen,
1431
+ onClick: () => setActionsOpen((o) => !o),
1432
+ children: /* @__PURE__ */ jsx(PoolseIcon, { name: "more-h", size: 16, label: null })
1433
+ }
1434
+ ),
1227
1435
  showActions && /* @__PURE__ */ jsx(
1228
1436
  "div",
1229
1437
  {
@@ -1310,6 +1518,7 @@ function ThreadView({
1310
1518
  rootMessage.id
1311
1519
  );
1312
1520
  const listRef = useRef(null);
1521
+ const closeBtnRef = useRef(null);
1313
1522
  const lastReplyIdRef = useRef(null);
1314
1523
  useEffect(() => {
1315
1524
  const tail = replies[replies.length - 1];
@@ -1319,60 +1528,158 @@ function ThreadView({
1319
1528
  const el = listRef.current;
1320
1529
  if (el) el.scrollTop = el.scrollHeight;
1321
1530
  }, [replies]);
1531
+ useEffect(() => {
1532
+ closeBtnRef.current?.focus();
1533
+ if (!onClose) return;
1534
+ const onKey = (e) => {
1535
+ if (e.key === "Escape") onClose();
1536
+ };
1537
+ document.addEventListener("keydown", onKey);
1538
+ return () => document.removeEventListener("keydown", onKey);
1539
+ }, [onClose]);
1322
1540
  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
- ] });
1541
+ return /* @__PURE__ */ jsxs(
1542
+ "aside",
1543
+ {
1544
+ className: "poolse-thread",
1545
+ role: "complementary",
1546
+ "aria-label": "Message thread",
1547
+ children: [
1548
+ /* @__PURE__ */ jsxs("header", { className: "poolse-thread__header", children: [
1549
+ /* @__PURE__ */ jsx("div", { className: "poolse-thread__title", children: "Thread" }),
1550
+ onClose && /* @__PURE__ */ jsx(
1551
+ "button",
1552
+ {
1553
+ ref: closeBtnRef,
1554
+ type: "button",
1555
+ className: "poolse-icon-btn",
1556
+ onClick: onClose,
1557
+ "aria-label": "Close thread",
1558
+ children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 18, label: null })
1559
+ }
1560
+ )
1561
+ ] }),
1562
+ /* @__PURE__ */ jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
1563
+ /* @__PURE__ */ jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
1564
+ hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
1565
+ 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." }) : (
1566
+ // Same Fragment trick as ConversationView so MessageBubble
1567
+ // remains the direct flex child for align-self to work.
1568
+ replies.map((msg) => /* @__PURE__ */ jsx(Fragment$1, { children: renderOne(msg, me?.id ?? null) }, msg.id))
1569
+ ),
1570
+ error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1571
+ "Failed to load: ",
1572
+ error.message
1573
+ ] })
1574
+ ] }),
1575
+ /* @__PURE__ */ jsx(MessageComposer, { onSend: (body) => sendReply({ body }), placeholder: "Reply in thread\u2026" })
1576
+ ]
1577
+ }
1578
+ );
1352
1579
  }
1353
1580
  function defaultRenderReply(msg, currentUserId) {
1354
1581
  return /* @__PURE__ */ jsx(MessageBubble, { message: msg, currentUserId });
1355
1582
  }
1356
1583
  function TypingIndicator({ typing, labelFor }) {
1357
1584
  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: [
1585
+ const isTyping = ids.length > 0;
1586
+ return /* @__PURE__ */ jsxs("div", { className: "poolse-typing", "data-typing": isTyping || void 0, children: [
1587
+ /* @__PURE__ */ jsxs("span", { className: "poolse-typing__dots", "aria-hidden": "true", children: [
1369
1588
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" }),
1370
1589
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" }),
1371
1590
  /* @__PURE__ */ jsx("span", { className: "poolse-typing__dot" })
1372
1591
  ] }),
1373
- /* @__PURE__ */ jsx("span", { className: "poolse-typing__label", children: text })
1592
+ /* @__PURE__ */ jsx(
1593
+ "span",
1594
+ {
1595
+ className: "poolse-typing__label",
1596
+ role: "status",
1597
+ "aria-live": "polite",
1598
+ "aria-atomic": "true",
1599
+ children: isTyping ? /* @__PURE__ */ jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : ""
1600
+ }
1601
+ )
1602
+ ] });
1603
+ }
1604
+ function TypingLabel({ ids, labelFor }) {
1605
+ const id1 = ids[0] ?? null;
1606
+ const id2 = ids[1] ?? null;
1607
+ const name1 = useDisplayName(id1, labelFor);
1608
+ const name2 = useDisplayName(id2, labelFor);
1609
+ if (ids.length === 1) return /* @__PURE__ */ jsxs(Fragment, { children: [
1610
+ name1,
1611
+ " is typing"
1612
+ ] });
1613
+ if (ids.length === 2) {
1614
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1615
+ name1,
1616
+ " and ",
1617
+ name2,
1618
+ " are typing"
1619
+ ] });
1620
+ }
1621
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1622
+ ids.length,
1623
+ " people are typing"
1374
1624
  ] });
1375
1625
  }
1626
+ function UploadQueueStrip({ items, onCancel, onDismiss }) {
1627
+ if (items.length === 0) return null;
1628
+ return /* @__PURE__ */ jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsx(
1629
+ UploadChip,
1630
+ {
1631
+ item,
1632
+ onCancel: () => onCancel(item.localId),
1633
+ onDismiss: () => onDismiss(item.localId)
1634
+ },
1635
+ item.localId
1636
+ )) });
1637
+ }
1638
+ function UploadChip({
1639
+ item,
1640
+ onCancel,
1641
+ onDismiss
1642
+ }) {
1643
+ const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
1644
+ const isError = item.status === "error";
1645
+ const isInFlight = item.status === "pending" || item.status === "uploading";
1646
+ return /* @__PURE__ */ jsxs(
1647
+ "div",
1648
+ {
1649
+ className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
1650
+ "data-status": item.status,
1651
+ children: [
1652
+ /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(PoolseIcon, { name: isError ? "attachment" : "attachment", size: 18, label: null }) }),
1653
+ /* @__PURE__ */ jsxs("div", { className: "poolse-upload-chip__body", children: [
1654
+ /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
1655
+ isError ? /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : /* @__PURE__ */ jsx(
1656
+ "div",
1657
+ {
1658
+ className: "poolse-upload-chip__bar",
1659
+ role: "progressbar",
1660
+ "aria-valuemin": 0,
1661
+ "aria-valuemax": 100,
1662
+ "aria-valuenow": pct,
1663
+ "aria-label": `Uploading ${item.filename}`,
1664
+ children: /* @__PURE__ */ jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
1665
+ }
1666
+ )
1667
+ ] }),
1668
+ /* @__PURE__ */ jsx(
1669
+ "button",
1670
+ {
1671
+ type: "button",
1672
+ className: "poolse-upload-chip__action",
1673
+ onClick: isInFlight ? onCancel : onDismiss,
1674
+ "aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
1675
+ title: isInFlight ? "Cancel" : "Dismiss",
1676
+ children: "\xD7"
1677
+ }
1678
+ )
1679
+ ]
1680
+ }
1681
+ );
1682
+ }
1376
1683
  var TRUE = true;
1377
1684
  function ConversationView({
1378
1685
  conversationId,
@@ -1511,20 +1818,56 @@ function ConversationView({
1511
1818
  el.classList.add("poolse-message-row--highlight");
1512
1819
  setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
1513
1820
  };
1514
- const { upload, uploading } = useAttachmentUpload();
1515
- const onPickFile = async (file) => {
1821
+ const { queue: uploadQueue, uploadAll, cancel: cancelUpload, remove: removeUpload, uploading } = useAttachmentUpload();
1822
+ const visibleUploads = uploadQueue.filter(
1823
+ (it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
1824
+ );
1825
+ const onPickFiles = async (files) => {
1826
+ if (files.length === 0) return;
1516
1827
  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);
1828
+ const atts = await uploadAll(
1829
+ files.map((f) => ({
1830
+ body: f,
1831
+ contentType: f.type || "application/octet-stream",
1832
+ byteSize: f.size,
1833
+ filename: f.name
1834
+ }))
1835
+ );
1836
+ await send({ body: "", attachment_ids: atts.map((a) => a.id) });
1837
+ for (const it of uploadQueue) {
1838
+ if (it.status === "ready") removeUpload(it.localId);
1839
+ }
1840
+ } catch {
1526
1841
  }
1527
1842
  };
1843
+ const [dragActive, setDragActive] = useState(false);
1844
+ const dragDepthRef = useRef(0);
1845
+ const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
1846
+ const onDragEnter = (e) => {
1847
+ if (!attachments || !isFileDrag(e)) return;
1848
+ e.preventDefault();
1849
+ dragDepthRef.current += 1;
1850
+ setDragActive(true);
1851
+ };
1852
+ const onDragOver = (e) => {
1853
+ if (!attachments || !isFileDrag(e)) return;
1854
+ e.preventDefault();
1855
+ if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
1856
+ };
1857
+ const onDragLeave = (e) => {
1858
+ if (!attachments || !isFileDrag(e)) return;
1859
+ e.preventDefault();
1860
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
1861
+ if (dragDepthRef.current === 0) setDragActive(false);
1862
+ };
1863
+ const onDrop = (e) => {
1864
+ if (!attachments || !isFileDrag(e)) return;
1865
+ e.preventDefault();
1866
+ dragDepthRef.current = 0;
1867
+ setDragActive(false);
1868
+ const files = Array.from(e.dataTransfer?.files ?? []);
1869
+ if (files.length > 0) void onPickFiles(files);
1870
+ };
1528
1871
  const onSendBody = async (body, opts) => {
1529
1872
  await send({
1530
1873
  body,
@@ -1555,98 +1898,141 @@ function ConversationView({
1555
1898
  }
1556
1899
  );
1557
1900
  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
- ] }),
1901
+ /* @__PURE__ */ jsxs(
1902
+ "div",
1903
+ {
1904
+ className: `poolse-conversation${dragActive ? " is-drag-active" : ""}`,
1905
+ onDragEnter,
1906
+ onDragOver,
1907
+ onDragLeave,
1908
+ onDrop,
1909
+ children: [
1910
+ status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs(
1911
+ "div",
1912
+ {
1913
+ className: "poolse-conversation__status",
1914
+ role: "status",
1915
+ "aria-live": "polite",
1916
+ "aria-atomic": "true",
1917
+ children: [
1918
+ status === "connecting" && "Connecting\u2026",
1919
+ status === "reconnecting" && "Reconnecting\u2026",
1920
+ status === "closed" && "Disconnected"
1921
+ ]
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ jsxs(
1925
+ "div",
1926
+ {
1927
+ className: "poolse-conversation__messages",
1928
+ ref: listRef,
1929
+ role: "log",
1930
+ "aria-label": "Conversation messages",
1931
+ "aria-live": "polite",
1932
+ "aria-relevant": "additions",
1933
+ children: [
1934
+ hasMore && !loading && /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older messages" }),
1935
+ 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) => {
1936
+ if (renderMessage) {
1937
+ return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1938
+ }
1939
+ const prev = idx > 0 ? messages[idx - 1] ?? null : null;
1940
+ const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
1941
+ const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
1942
+ const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
1943
+ const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1944
+ const original = messages.find((m) => m.id === msg.quoted_message_id);
1945
+ if (!original) return msg;
1946
+ return {
1947
+ ...msg,
1948
+ quoted_message: {
1949
+ id: original.id,
1950
+ sender_id: original.sender_id,
1951
+ body: original.body,
1952
+ deleted_at: original.deleted_at,
1953
+ inserted_at: original.inserted_at
1954
+ }
1955
+ };
1956
+ })() : msg;
1957
+ const isSelf = me !== null && msg.sender_id === me.id;
1958
+ const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1959
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1960
+ showDaySeparator && /* @__PURE__ */ jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
1961
+ /* @__PURE__ */ jsx(
1962
+ MessageRow,
1963
+ {
1964
+ msg: enriched,
1965
+ meId: me?.id ?? null,
1966
+ reactions,
1967
+ attachments,
1968
+ actions,
1969
+ threads,
1970
+ quotations,
1971
+ groupPosition,
1972
+ maxBodyLength,
1973
+ markdown,
1974
+ showSenderName: showSenderLabelsResolved,
1975
+ showAvatar: showAvatarsResolved,
1976
+ ...readState ? { readState } : {},
1977
+ ...labelFor ? { labelFor } : {},
1978
+ editing: editingId === msg.id,
1979
+ onStartEdit: () => setEditingId(msg.id),
1980
+ onCancelEdit: () => setEditingId(null),
1981
+ onSaveEdit: async (body) => {
1982
+ await edit(msg.id, body);
1983
+ setEditingId(null);
1984
+ },
1985
+ onDelete: () => void deleteMsg(msg.id),
1986
+ onOpenThread: () => setThreadRootId(msg.id),
1987
+ onQuote: () => setReplyingTo(msg),
1988
+ onQuotedClick: scrollToOriginal
1989
+ }
1990
+ )
1991
+ ] }, msg.id);
1992
+ }),
1993
+ error && /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__empty", children: [
1994
+ "Failed to load: ",
1995
+ error.message
1996
+ ] }),
1997
+ /* @__PURE__ */ jsx("div", { ref: bottomSentinelRef, "aria-hidden": "true", style: { height: 1 } })
1998
+ ]
1999
+ }
2000
+ ),
2001
+ !atBottom && newCountWhileAway > 0 && /* @__PURE__ */ jsxs(
2002
+ "button",
2003
+ {
2004
+ type: "button",
2005
+ className: "poolse-conversation__scroll-to-new",
2006
+ onClick: scrollToBottom,
2007
+ children: [
2008
+ "\u2193 ",
2009
+ newCountWhileAway,
2010
+ " new ",
2011
+ newCountWhileAway === 1 ? "message" : "messages"
2012
+ ]
2013
+ }
2014
+ ),
2015
+ /* @__PURE__ */ jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
2016
+ attachments && /* @__PURE__ */ jsx(
2017
+ UploadQueueStrip,
2018
+ {
2019
+ items: visibleUploads,
2020
+ onCancel: cancelUpload,
2021
+ onDismiss: removeUpload
2022
+ }
2023
+ ),
2024
+ /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__composer-row", children: [
2025
+ attachments && /* @__PURE__ */ jsx(AttachmentPickerButton, { onPick: onPickFiles, disabled: uploading }),
2026
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
2027
+ ] }),
2028
+ dragActive && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
2029
+ /* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
2030
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
2031
+ /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-hint", children: "They'll be sent in one message" })
2032
+ ] }) })
2033
+ ]
2034
+ }
2035
+ ),
1650
2036
  threads && threadRoot && /* @__PURE__ */ jsx("div", { className: "poolse-conversation-shell__thread", children: /* @__PURE__ */ jsx(
1651
2037
  ThreadView,
1652
2038
  {
@@ -1668,10 +2054,11 @@ function AttachmentPickerButton({
1668
2054
  {
1669
2055
  ref: inputRef,
1670
2056
  type: "file",
2057
+ multiple: true,
1671
2058
  className: "poolse-attach-input",
1672
2059
  onChange: (e) => {
1673
- const f = e.target.files?.[0];
1674
- if (f) onPick(f);
2060
+ const files = Array.from(e.target.files ?? []);
2061
+ if (files.length > 0) onPick(files);
1675
2062
  e.target.value = "";
1676
2063
  }
1677
2064
  }
@@ -1683,49 +2070,13 @@ function AttachmentPickerButton({
1683
2070
  className: "poolse-attach-btn",
1684
2071
  onClick: () => inputRef.current?.click(),
1685
2072
  disabled,
1686
- "aria-label": "Attach file",
1687
- title: "Attach file",
2073
+ "aria-label": "Attach files",
2074
+ title: "Attach files",
1688
2075
  children: /* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
1689
2076
  }
1690
2077
  )
1691
2078
  ] });
1692
2079
  }
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
2080
  function ConversationList({
1730
2081
  selectedId,
1731
2082
  onSelect,
@@ -1821,6 +2172,10 @@ function MemberList({
1821
2172
  emptyState
1822
2173
  }) {
1823
2174
  const { members, loading, error, removeMember } = useMembers(conversationId);
2175
+ const { online: presenceOnline } = usePresence(
2176
+ onlineUserIds === void 0 ? conversationId : ""
2177
+ );
2178
+ const effectiveOnline = onlineUserIds ?? presenceOnline;
1824
2179
  if (loading && members.length === 0) {
1825
2180
  return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
1826
2181
  }
@@ -1833,19 +2188,18 @@ function MemberList({
1833
2188
  if (members.length === 0) {
1834
2189
  return /* @__PURE__ */ jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState ?? "No members yet." });
1835
2190
  }
1836
- const label = labelFor ?? ((id) => id.slice(0, 8));
1837
2191
  return /* @__PURE__ */ jsx("ul", { className: "poolse-list", role: "list", "aria-label": "Members", children: members.map((m) => {
1838
2192
  const content = renderItem ? renderItem(m) : /* @__PURE__ */ jsx(
1839
2193
  DefaultMemberRow,
1840
2194
  {
1841
2195
  membership: m,
1842
- name: label(m.user_id),
1843
2196
  avatarUrl: avatarFor?.(m.user_id) ?? null,
1844
- online: onlineUserIds?.has(m.user_id) ?? false,
2197
+ online: effectiveOnline.has(m.user_id),
1845
2198
  removable: canRemove?.(m) ?? false,
1846
2199
  onRemove: () => {
1847
2200
  void removeMember(m.user_id);
1848
- }
2201
+ },
2202
+ ...labelFor ? { labelFor } : {}
1849
2203
  }
1850
2204
  );
1851
2205
  return /* @__PURE__ */ jsx("li", { className: "poolse-list__item", children: content }, m.id);
@@ -1853,12 +2207,13 @@ function MemberList({
1853
2207
  }
1854
2208
  function DefaultMemberRow({
1855
2209
  membership,
1856
- name,
1857
2210
  avatarUrl,
1858
2211
  online,
1859
2212
  removable,
1860
- onRemove
2213
+ onRemove,
2214
+ labelFor
1861
2215
  }) {
2216
+ const name = useDisplayName(membership.user_id, labelFor);
1862
2217
  return /* @__PURE__ */ jsxs("div", { className: "poolse-member-row", children: [
1863
2218
  /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name, online, size: "md" }),
1864
2219
  /* @__PURE__ */ jsxs("div", { className: "poolse-member-row__body", children: [
@@ -1993,6 +2348,6 @@ function PoolseLogo({
1993
2348
  );
1994
2349
  }
1995
2350
 
1996
- export { AttachmentPreview, Avatar, ConversationList, ConversationView, EditableMessageBubble, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, usePoolseFonts };
2351
+ export { AttachmentPreview, Avatar, ConversationList, ConversationView, EditableMessageBubble, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, useDisplayName, usePoolseFonts };
1997
2352
  //# sourceMappingURL=index.js.map
1998
2353
  //# sourceMappingURL=index.js.map