@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.cjs CHANGED
@@ -49,6 +49,43 @@ function PoolseFonts() {
49
49
  return null;
50
50
  }
51
51
 
52
+ // src/grouping.ts
53
+ function computeGroupPosition(msg, prev, next, windowMs) {
54
+ const continuesPrev = sameGroup(msg, prev, windowMs);
55
+ const continuesNext = sameGroup(next, msg, windowMs);
56
+ if (continuesPrev && continuesNext) return "middle";
57
+ if (continuesPrev) return "last";
58
+ if (continuesNext) return "first";
59
+ return "standalone";
60
+ }
61
+ function sameGroup(a, b, windowMs) {
62
+ if (!a || !b) return false;
63
+ if (a.sender_id !== b.sender_id) return false;
64
+ if (!sameDay(a.inserted_at, b.inserted_at)) return false;
65
+ const ta = new Date(a.inserted_at).getTime();
66
+ const tb = new Date(b.inserted_at).getTime();
67
+ return Math.abs(ta - tb) <= windowMs;
68
+ }
69
+ function sameDay(a, b) {
70
+ const da = new Date(a);
71
+ const db = new Date(b);
72
+ return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
73
+ }
74
+ function formatDayLabel(iso, now = /* @__PURE__ */ new Date()) {
75
+ const d = new Date(iso);
76
+ const startOfDay = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
77
+ const diffDays = Math.floor((startOfDay(now) - startOfDay(d)) / 864e5);
78
+ if (diffDays === 0) return "Today";
79
+ if (diffDays === 1) return "Yesterday";
80
+ if (diffDays < 7) {
81
+ return d.toLocaleDateString(void 0, { weekday: "long" });
82
+ }
83
+ if (d.getFullYear() === now.getFullYear()) {
84
+ return d.toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" });
85
+ }
86
+ return d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" });
87
+ }
88
+
52
89
  // src/listAutocomplete.ts
53
90
  var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
54
91
  var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
@@ -287,6 +324,31 @@ function PoolseIcon({
287
324
  }
288
325
  );
289
326
  }
327
+ var MAX_NAME_CHARS = 24;
328
+ function UserName({
329
+ userId,
330
+ labelFor,
331
+ emptyFallback = "Unknown",
332
+ className
333
+ }) {
334
+ const { profile } = react$1.useUser(labelFor ? null : userId);
335
+ const name = resolveDisplayName(userId, profile?.displayName, labelFor, emptyFallback);
336
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className, children: truncate(name) });
337
+ }
338
+ function useDisplayName(userId, labelFor, emptyFallback = "Unknown") {
339
+ const { profile } = react$1.useUser(labelFor ? null : userId);
340
+ return resolveDisplayName(userId, profile?.displayName, labelFor, emptyFallback);
341
+ }
342
+ function resolveDisplayName(userId, resolved, labelFor, emptyFallback) {
343
+ if (!userId) return emptyFallback;
344
+ if (labelFor) return labelFor(userId);
345
+ if (resolved) return resolved;
346
+ return `User ${userId.slice(0, 6)}`;
347
+ }
348
+ function truncate(s) {
349
+ if (s.length <= MAX_NAME_CHARS) return s;
350
+ return s.slice(0, MAX_NAME_CHARS - 1) + "\u2026";
351
+ }
290
352
  function MentionInput({
291
353
  conversationId,
292
354
  onSend,
@@ -452,7 +514,13 @@ function MentionInput({
452
514
  onChange,
453
515
  onKeyDown,
454
516
  placeholder,
455
- disabled: disabled || sending
517
+ disabled: disabled || sending,
518
+ "aria-label": placeholder,
519
+ role: "combobox",
520
+ "aria-expanded": Boolean(mention && filtered.length > 0),
521
+ "aria-controls": "poolse-mention-menu",
522
+ "aria-autocomplete": "list",
523
+ ...mention && filtered.length > 0 ? { "aria-activedescendant": `poolse-mention-opt-${activeIdx}` } : {}
456
524
  }
457
525
  ),
458
526
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -466,23 +534,33 @@ function MentionInput({
466
534
  }
467
535
  )
468
536
  ] }),
469
- 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(
537
+ mention && filtered.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
470
538
  "div",
471
539
  {
472
- role: "option",
473
- "aria-selected": i === activeIdx,
474
- className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
475
- onMouseDown: (e) => {
476
- e.preventDefault();
477
- insertMention(m);
478
- },
479
- children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
480
- "@",
481
- label(m.user_id)
482
- ] })
483
- },
484
- m.id
485
- )) })
540
+ id: "poolse-mention-menu",
541
+ className: "poolse-mention-menu",
542
+ role: "listbox",
543
+ "aria-label": "Members",
544
+ children: filtered.map((m, i) => /* @__PURE__ */ jsxRuntime.jsxs(
545
+ "div",
546
+ {
547
+ id: `poolse-mention-opt-${i}`,
548
+ role: "option",
549
+ "aria-selected": i === activeIdx,
550
+ className: `poolse-mention-menu__item${i === activeIdx ? " poolse-mention-menu__item--active" : ""}`,
551
+ onMouseDown: (e) => {
552
+ e.preventDefault();
553
+ insertMention(m);
554
+ },
555
+ children: [
556
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "@" }),
557
+ /* @__PURE__ */ jsxRuntime.jsx(UserName, { userId: m.user_id, ...labelFor ? { labelFor } : {} })
558
+ ]
559
+ },
560
+ m.id
561
+ ))
562
+ }
563
+ )
486
564
  ]
487
565
  }
488
566
  );
@@ -563,7 +641,8 @@ function MessageComposer({
563
641
  onChange,
564
642
  onKeyDown,
565
643
  placeholder,
566
- disabled: disabled || sending
644
+ disabled: disabled || sending,
645
+ "aria-label": placeholder
567
646
  }
568
647
  ),
569
648
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -612,6 +691,7 @@ function ReplyChip({
612
691
  function AttachmentPreview({ attachment, onClick }) {
613
692
  const isFullRow = "content_type" in attachment;
614
693
  const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
694
+ const [lightboxOpen, setLightboxOpen] = react.useState(false);
615
695
  if (loading) {
616
696
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-attachment poolse-list--placeholder", "aria-busy": "true", children: "Loading attachment\u2026" });
617
697
  }
@@ -622,29 +702,33 @@ function AttachmentPreview({ attachment, onClick }) {
622
702
  const isImage = ct.startsWith("image/");
623
703
  if (isImage) {
624
704
  const filename2 = isFullRow ? attachment.original_filename : null;
625
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-attachment", children: /* @__PURE__ */ jsxRuntime.jsx(
626
- "a",
627
- {
628
- href: url,
629
- target: "_blank",
630
- rel: "noopener noreferrer",
631
- onClick: (e) => {
632
- if (onClick) {
633
- e.preventDefault();
634
- onClick({ id: attachment.id });
635
- }
636
- },
637
- children: /* @__PURE__ */ jsxRuntime.jsx(
638
- "img",
639
- {
640
- className: "poolse-attachment__image",
641
- src: url,
642
- alt: filename2 ?? "attachment",
643
- loading: "lazy"
644
- }
645
- )
646
- }
647
- ) });
705
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-attachment", children: [
706
+ /* @__PURE__ */ jsxRuntime.jsx(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ className: "poolse-attachment__image-button",
711
+ "aria-label": filename2 ? `Open ${filename2}` : "Open image",
712
+ onClick: () => {
713
+ if (onClick) {
714
+ onClick({ id: attachment.id });
715
+ return;
716
+ }
717
+ setLightboxOpen(true);
718
+ },
719
+ children: /* @__PURE__ */ jsxRuntime.jsx(
720
+ "img",
721
+ {
722
+ className: "poolse-attachment__image",
723
+ src: url,
724
+ alt: filename2 ?? "attachment",
725
+ loading: "lazy"
726
+ }
727
+ )
728
+ }
729
+ ),
730
+ lightboxOpen && /* @__PURE__ */ jsxRuntime.jsx(Lightbox, { url, filename: filename2, onClose: () => setLightboxOpen(false) })
731
+ ] });
648
732
  }
649
733
  const filename = isFullRow ? attachment.original_filename ?? "file" : "file";
650
734
  const byteSize = isFullRow ? attachment.byte_size : null;
@@ -689,6 +773,70 @@ function AttachmentPreview({ attachment, onClick }) {
689
773
  }
690
774
  ) });
691
775
  }
776
+ function Lightbox({
777
+ url,
778
+ filename,
779
+ onClose
780
+ }) {
781
+ react.useEffect(() => {
782
+ const onKey = (e) => {
783
+ if (e.key === "Escape") onClose();
784
+ };
785
+ document.addEventListener("keydown", onKey);
786
+ const prev = document.body.style.overflow;
787
+ document.body.style.overflow = "hidden";
788
+ return () => {
789
+ document.removeEventListener("keydown", onKey);
790
+ document.body.style.overflow = prev;
791
+ };
792
+ }, [onClose]);
793
+ return /* @__PURE__ */ jsxRuntime.jsxs(
794
+ "div",
795
+ {
796
+ className: "poolse-lightbox",
797
+ role: "dialog",
798
+ "aria-modal": "true",
799
+ "aria-label": filename ?? "Image preview",
800
+ onClick: onClose,
801
+ children: [
802
+ /* @__PURE__ */ jsxRuntime.jsx(
803
+ "button",
804
+ {
805
+ type: "button",
806
+ className: "poolse-lightbox__close",
807
+ "aria-label": "Close",
808
+ onClick: (e) => {
809
+ e.stopPropagation();
810
+ onClose();
811
+ },
812
+ children: "\xD7"
813
+ }
814
+ ),
815
+ /* @__PURE__ */ jsxRuntime.jsx(
816
+ "img",
817
+ {
818
+ className: "poolse-lightbox__image",
819
+ src: url,
820
+ alt: filename ?? "attachment",
821
+ onClick: (e) => e.stopPropagation()
822
+ }
823
+ ),
824
+ /* @__PURE__ */ jsxRuntime.jsx(
825
+ "a",
826
+ {
827
+ className: "poolse-lightbox__download",
828
+ href: url,
829
+ download: filename ?? void 0,
830
+ target: "_blank",
831
+ rel: "noopener noreferrer",
832
+ onClick: (e) => e.stopPropagation(),
833
+ children: "Download"
834
+ }
835
+ )
836
+ ]
837
+ }
838
+ );
839
+ }
692
840
  function guessContentType(url) {
693
841
  const m = url.match(/\.([a-z0-9]+)(?:\?|#|$)/i);
694
842
  if (!m) return "application/octet-stream";
@@ -1039,19 +1187,53 @@ function ReactionPicker({
1039
1187
  onPick,
1040
1188
  onClose
1041
1189
  }) {
1190
+ const rootRef = react.useRef(null);
1191
+ react.useEffect(() => {
1192
+ const firstBtn = rootRef.current?.querySelector("button");
1193
+ if (firstBtn instanceof HTMLElement) firstBtn.focus();
1194
+ }, []);
1195
+ react.useEffect(() => {
1196
+ if (!onClose) return;
1197
+ const onPointer = (e) => {
1198
+ const t = e.target;
1199
+ if (t instanceof Node && rootRef.current && !rootRef.current.contains(t)) {
1200
+ onClose();
1201
+ }
1202
+ };
1203
+ document.addEventListener("pointerdown", onPointer, true);
1204
+ return () => document.removeEventListener("pointerdown", onPointer, true);
1205
+ }, [onClose]);
1206
+ const onKey = (e) => {
1207
+ if (e.key === "Escape") {
1208
+ e.stopPropagation();
1209
+ onClose?.();
1210
+ return;
1211
+ }
1212
+ if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
1213
+ const buttons = Array.from(
1214
+ rootRef.current?.querySelectorAll("button") ?? []
1215
+ );
1216
+ const idx = buttons.findIndex((b) => b === document.activeElement);
1217
+ if (idx === -1) return;
1218
+ const nextIdx = e.key === "ArrowRight" ? (idx + 1) % buttons.length : (idx - 1 + buttons.length) % buttons.length;
1219
+ buttons[nextIdx]?.focus();
1220
+ e.preventDefault();
1221
+ }
1222
+ };
1042
1223
  return /* @__PURE__ */ jsxRuntime.jsx(
1043
1224
  "div",
1044
1225
  {
1226
+ ref: rootRef,
1045
1227
  className: "poolse-reaction-picker",
1046
1228
  role: "menu",
1229
+ "aria-label": "Pick a reaction",
1047
1230
  style: { position: "absolute", bottom: "100%", left: 0, marginBottom: 6 },
1048
- onKeyDown: (e) => {
1049
- if (e.key === "Escape") onClose?.();
1050
- },
1231
+ onKeyDown: onKey,
1051
1232
  children: COMMON_EMOJIS.map((e) => /* @__PURE__ */ jsxRuntime.jsx(
1052
1233
  "button",
1053
1234
  {
1054
1235
  type: "button",
1236
+ role: "menuitem",
1055
1237
  className: "poolse-reaction-picker__btn",
1056
1238
  onClick: () => onPick(e),
1057
1239
  "aria-label": `React with ${e}`,
@@ -1156,9 +1338,23 @@ function MessageRow({
1156
1338
  const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
1157
1339
  const handleSave = onSaveEdit ?? (async () => void 0);
1158
1340
  const handleCancel = onCancelEdit ?? (() => void 0);
1341
+ const [actionsOpen, setActionsOpen] = react.useState(false);
1342
+ const rowRef = react.useRef(null);
1343
+ react.useEffect(() => {
1344
+ if (!actionsOpen) return;
1345
+ const onDown = (e) => {
1346
+ const t = e.target;
1347
+ if (t instanceof Node && rowRef.current && !rowRef.current.contains(t)) {
1348
+ setActionsOpen(false);
1349
+ }
1350
+ };
1351
+ document.addEventListener("pointerdown", onDown);
1352
+ return () => document.removeEventListener("pointerdown", onDown);
1353
+ }, [actionsOpen]);
1159
1354
  return /* @__PURE__ */ jsxRuntime.jsxs(
1160
1355
  "div",
1161
1356
  {
1357
+ ref: rowRef,
1162
1358
  className: [
1163
1359
  "poolse-message-row",
1164
1360
  isSelf ? "poolse-message-row--right" : "",
@@ -1169,6 +1365,7 @@ function MessageRow({
1169
1365
  `poolse-message-row--${groupPosition}`
1170
1366
  ].filter(Boolean).join(" "),
1171
1367
  "data-message-id": msg.id,
1368
+ "data-actions-open": actionsOpen || void 0,
1172
1369
  children: [
1173
1370
  editing ? /* @__PURE__ */ jsxRuntime.jsx(
1174
1371
  EditableMessageBubble,
@@ -1231,6 +1428,17 @@ function MessageRow({
1231
1428
  ]
1232
1429
  }
1233
1430
  ),
1431
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(
1432
+ "button",
1433
+ {
1434
+ type: "button",
1435
+ className: "poolse-message-row__more",
1436
+ "aria-label": "Show message actions",
1437
+ "aria-expanded": actionsOpen,
1438
+ onClick: () => setActionsOpen((o) => !o),
1439
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "more-h", size: 16, label: null })
1440
+ }
1441
+ ),
1234
1442
  showActions && /* @__PURE__ */ jsxRuntime.jsx(
1235
1443
  "div",
1236
1444
  {
@@ -1317,6 +1525,7 @@ function ThreadView({
1317
1525
  rootMessage.id
1318
1526
  );
1319
1527
  const listRef = react.useRef(null);
1528
+ const closeBtnRef = react.useRef(null);
1320
1529
  const lastReplyIdRef = react.useRef(null);
1321
1530
  react.useEffect(() => {
1322
1531
  const tail = replies[replies.length - 1];
@@ -1326,60 +1535,158 @@ function ThreadView({
1326
1535
  const el = listRef.current;
1327
1536
  if (el) el.scrollTop = el.scrollHeight;
1328
1537
  }, [replies]);
1538
+ react.useEffect(() => {
1539
+ closeBtnRef.current?.focus();
1540
+ if (!onClose) return;
1541
+ const onKey = (e) => {
1542
+ if (e.key === "Escape") onClose();
1543
+ };
1544
+ document.addEventListener("keydown", onKey);
1545
+ return () => document.removeEventListener("keydown", onKey);
1546
+ }, [onClose]);
1329
1547
  const renderOne = renderMessage ?? defaultRenderReply;
1330
- return /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "poolse-thread", "aria-label": "Thread", children: [
1331
- /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-thread__header", children: [
1332
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__title", children: "Thread" }),
1333
- onClose && /* @__PURE__ */ jsxRuntime.jsx(
1334
- "button",
1335
- {
1336
- type: "button",
1337
- className: "poolse-icon-btn",
1338
- onClick: onClose,
1339
- "aria-label": "Close thread",
1340
- children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 18, label: null })
1341
- }
1342
- )
1343
- ] }),
1344
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
1345
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
1346
- hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
1347
- loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "No replies yet \u2014 start the thread." }) : (
1348
- // Same Fragment trick as ConversationView so MessageBubble
1349
- // remains the direct flex child for align-self to work.
1350
- replies.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderOne(msg, me?.id ?? null) }, msg.id))
1351
- ),
1352
- error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
1353
- "Failed to load: ",
1354
- error.message
1355
- ] })
1356
- ] }),
1357
- /* @__PURE__ */ jsxRuntime.jsx(MessageComposer, { onSend: (body) => sendReply({ body }), placeholder: "Reply in thread\u2026" })
1358
- ] });
1548
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1549
+ "aside",
1550
+ {
1551
+ className: "poolse-thread",
1552
+ role: "complementary",
1553
+ "aria-label": "Message thread",
1554
+ children: [
1555
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "poolse-thread__header", children: [
1556
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__title", children: "Thread" }),
1557
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(
1558
+ "button",
1559
+ {
1560
+ ref: closeBtnRef,
1561
+ type: "button",
1562
+ className: "poolse-icon-btn",
1563
+ onClick: onClose,
1564
+ "aria-label": "Close thread",
1565
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "close", size: 18, label: null })
1566
+ }
1567
+ )
1568
+ ] }),
1569
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-thread__root", children: /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: rootMessage, currentUserId: me?.id ?? null }) }),
1570
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-thread__messages", ref: listRef, children: [
1571
+ hasMore && !loading && replies.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older replies" }),
1572
+ loading && replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading replies\u2026" }) : replies.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "No replies yet \u2014 start the thread." }) : (
1573
+ // Same Fragment trick as ConversationView so MessageBubble
1574
+ // remains the direct flex child for align-self to work.
1575
+ replies.map((msg) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderOne(msg, me?.id ?? null) }, msg.id))
1576
+ ),
1577
+ error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
1578
+ "Failed to load: ",
1579
+ error.message
1580
+ ] })
1581
+ ] }),
1582
+ /* @__PURE__ */ jsxRuntime.jsx(MessageComposer, { onSend: (body) => sendReply({ body }), placeholder: "Reply in thread\u2026" })
1583
+ ]
1584
+ }
1585
+ );
1359
1586
  }
1360
1587
  function defaultRenderReply(msg, currentUserId) {
1361
1588
  return /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { message: msg, currentUserId });
1362
1589
  }
1363
1590
  function TypingIndicator({ typing, labelFor }) {
1364
1591
  const ids = Array.from(typing);
1365
- if (ids.length === 0) {
1366
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-typing", "aria-hidden": "true" });
1367
- }
1368
- const label = labelFor ?? ((id) => id.slice(0, 6));
1369
- const names = ids.slice(0, 2).map(label);
1370
- let text;
1371
- if (ids.length === 1) text = `${names[0]} is typing`;
1372
- else if (ids.length === 2) text = `${names[0]} and ${names[1]} are typing`;
1373
- else text = `${ids.length} people are typing`;
1374
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-typing", children: [
1375
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-typing__dots", role: "status", "aria-live": "polite", children: [
1592
+ const isTyping = ids.length > 0;
1593
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-typing", "data-typing": isTyping || void 0, children: [
1594
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-typing__dots", "aria-hidden": "true", children: [
1376
1595
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" }),
1377
1596
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" }),
1378
1597
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__dot" })
1379
1598
  ] }),
1380
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-typing__label", children: text })
1599
+ /* @__PURE__ */ jsxRuntime.jsx(
1600
+ "span",
1601
+ {
1602
+ className: "poolse-typing__label",
1603
+ role: "status",
1604
+ "aria-live": "polite",
1605
+ "aria-atomic": "true",
1606
+ children: isTyping ? /* @__PURE__ */ jsxRuntime.jsx(TypingLabel, { ids, ...labelFor ? { labelFor } : {} }) : ""
1607
+ }
1608
+ )
1609
+ ] });
1610
+ }
1611
+ function TypingLabel({ ids, labelFor }) {
1612
+ const id1 = ids[0] ?? null;
1613
+ const id2 = ids[1] ?? null;
1614
+ const name1 = useDisplayName(id1, labelFor);
1615
+ const name2 = useDisplayName(id2, labelFor);
1616
+ if (ids.length === 1) return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1617
+ name1,
1618
+ " is typing"
1619
+ ] });
1620
+ if (ids.length === 2) {
1621
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1622
+ name1,
1623
+ " and ",
1624
+ name2,
1625
+ " are typing"
1626
+ ] });
1627
+ }
1628
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1629
+ ids.length,
1630
+ " people are typing"
1381
1631
  ] });
1382
1632
  }
1633
+ function UploadQueueStrip({ items, onCancel, onDismiss }) {
1634
+ if (items.length === 0) return null;
1635
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1636
+ UploadChip,
1637
+ {
1638
+ item,
1639
+ onCancel: () => onCancel(item.localId),
1640
+ onDismiss: () => onDismiss(item.localId)
1641
+ },
1642
+ item.localId
1643
+ )) });
1644
+ }
1645
+ function UploadChip({
1646
+ item,
1647
+ onCancel,
1648
+ onDismiss
1649
+ }) {
1650
+ const pct = item.byteSize > 0 ? Math.min(100, Math.round(item.loaded / item.byteSize * 100)) : 0;
1651
+ const isError = item.status === "error";
1652
+ const isInFlight = item.status === "pending" || item.status === "uploading";
1653
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1654
+ "div",
1655
+ {
1656
+ className: `poolse-upload-chip poolse-upload-chip--${item.status}`,
1657
+ "data-status": item.status,
1658
+ children: [
1659
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: isError ? "attachment" : "attachment", size: 18, label: null }) }),
1660
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-upload-chip__body", children: [
1661
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__filename", title: item.filename, children: item.filename }),
1662
+ isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__error", children: item.error?.message ?? "Upload failed" }) : /* @__PURE__ */ jsxRuntime.jsx(
1663
+ "div",
1664
+ {
1665
+ className: "poolse-upload-chip__bar",
1666
+ role: "progressbar",
1667
+ "aria-valuemin": 0,
1668
+ "aria-valuemax": 100,
1669
+ "aria-valuenow": pct,
1670
+ "aria-label": `Uploading ${item.filename}`,
1671
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-chip__bar-fill", style: { width: `${pct}%` } })
1672
+ }
1673
+ )
1674
+ ] }),
1675
+ /* @__PURE__ */ jsxRuntime.jsx(
1676
+ "button",
1677
+ {
1678
+ type: "button",
1679
+ className: "poolse-upload-chip__action",
1680
+ onClick: isInFlight ? onCancel : onDismiss,
1681
+ "aria-label": isInFlight ? `Cancel upload of ${item.filename}` : `Dismiss ${item.filename}`,
1682
+ title: isInFlight ? "Cancel" : "Dismiss",
1683
+ children: "\xD7"
1684
+ }
1685
+ )
1686
+ ]
1687
+ }
1688
+ );
1689
+ }
1383
1690
  var TRUE = true;
1384
1691
  function ConversationView({
1385
1692
  conversationId,
@@ -1518,20 +1825,56 @@ function ConversationView({
1518
1825
  el.classList.add("poolse-message-row--highlight");
1519
1826
  setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
1520
1827
  };
1521
- const { upload, uploading } = react$1.useAttachmentUpload();
1522
- const onPickFile = async (file) => {
1828
+ const { queue: uploadQueue, uploadAll, cancel: cancelUpload, remove: removeUpload, uploading } = react$1.useAttachmentUpload();
1829
+ const visibleUploads = uploadQueue.filter(
1830
+ (it) => it.status === "pending" || it.status === "uploading" || it.status === "error"
1831
+ );
1832
+ const onPickFiles = async (files) => {
1833
+ if (files.length === 0) return;
1523
1834
  try {
1524
- const att = await upload({
1525
- body: file,
1526
- contentType: file.type || "application/octet-stream",
1527
- byteSize: file.size,
1528
- filename: file.name
1529
- });
1530
- await send({ body: "", attachment_ids: [att.id] });
1531
- } catch (err) {
1532
- console.error("attachment upload failed:", err);
1835
+ const atts = await uploadAll(
1836
+ files.map((f) => ({
1837
+ body: f,
1838
+ contentType: f.type || "application/octet-stream",
1839
+ byteSize: f.size,
1840
+ filename: f.name
1841
+ }))
1842
+ );
1843
+ await send({ body: "", attachment_ids: atts.map((a) => a.id) });
1844
+ for (const it of uploadQueue) {
1845
+ if (it.status === "ready") removeUpload(it.localId);
1846
+ }
1847
+ } catch {
1533
1848
  }
1534
1849
  };
1850
+ const [dragActive, setDragActive] = react.useState(false);
1851
+ const dragDepthRef = react.useRef(0);
1852
+ const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
1853
+ const onDragEnter = (e) => {
1854
+ if (!attachments || !isFileDrag(e)) return;
1855
+ e.preventDefault();
1856
+ dragDepthRef.current += 1;
1857
+ setDragActive(true);
1858
+ };
1859
+ const onDragOver = (e) => {
1860
+ if (!attachments || !isFileDrag(e)) return;
1861
+ e.preventDefault();
1862
+ if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
1863
+ };
1864
+ const onDragLeave = (e) => {
1865
+ if (!attachments || !isFileDrag(e)) return;
1866
+ e.preventDefault();
1867
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
1868
+ if (dragDepthRef.current === 0) setDragActive(false);
1869
+ };
1870
+ const onDrop = (e) => {
1871
+ if (!attachments || !isFileDrag(e)) return;
1872
+ e.preventDefault();
1873
+ dragDepthRef.current = 0;
1874
+ setDragActive(false);
1875
+ const files = Array.from(e.dataTransfer?.files ?? []);
1876
+ if (files.length > 0) void onPickFiles(files);
1877
+ };
1535
1878
  const onSendBody = async (body, opts) => {
1536
1879
  await send({
1537
1880
  body,
@@ -1562,98 +1905,141 @@ function ConversationView({
1562
1905
  }
1563
1906
  );
1564
1907
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation-shell", children: [
1565
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation", children: [
1566
- status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__status", children: [
1567
- status === "connecting" && "Connecting\u2026",
1568
- status === "reconnecting" && "Reconnecting\u2026",
1569
- status === "closed" && "Disconnected"
1570
- ] }),
1571
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__messages", ref: listRef, children: [
1572
- hasMore && !loading && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older messages" }),
1573
- loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
1574
- if (renderMessage) {
1575
- return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1576
- }
1577
- const prev = idx > 0 ? messages[idx - 1] ?? null : null;
1578
- const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
1579
- const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
1580
- const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
1581
- const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1582
- const original = messages.find((m) => m.id === msg.quoted_message_id);
1583
- if (!original) return msg;
1584
- return {
1585
- ...msg,
1586
- quoted_message: {
1587
- id: original.id,
1588
- sender_id: original.sender_id,
1589
- body: original.body,
1590
- deleted_at: original.deleted_at,
1591
- inserted_at: original.inserted_at
1592
- }
1593
- };
1594
- })() : msg;
1595
- const isSelf = me !== null && msg.sender_id === me.id;
1596
- const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1597
- return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1598
- showDaySeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
1599
- /* @__PURE__ */ jsxRuntime.jsx(
1600
- MessageRow,
1601
- {
1602
- msg: enriched,
1603
- meId: me?.id ?? null,
1604
- reactions,
1605
- attachments,
1606
- actions,
1607
- threads,
1608
- quotations,
1609
- groupPosition,
1610
- maxBodyLength,
1611
- markdown,
1612
- showSenderName: showSenderLabelsResolved,
1613
- showAvatar: showAvatarsResolved,
1614
- ...readState ? { readState } : {},
1615
- ...labelFor ? { labelFor } : {},
1616
- editing: editingId === msg.id,
1617
- onStartEdit: () => setEditingId(msg.id),
1618
- onCancelEdit: () => setEditingId(null),
1619
- onSaveEdit: async (body) => {
1620
- await edit(msg.id, body);
1621
- setEditingId(null);
1622
- },
1623
- onDelete: () => void deleteMsg(msg.id),
1624
- onOpenThread: () => setThreadRootId(msg.id),
1625
- onQuote: () => setReplyingTo(msg),
1626
- onQuotedClick: scrollToOriginal
1627
- }
1628
- )
1629
- ] }, msg.id);
1630
- }),
1631
- error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
1632
- "Failed to load: ",
1633
- error.message
1634
- ] }),
1635
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: bottomSentinelRef, "aria-hidden": "true", style: { height: 1 } })
1636
- ] }),
1637
- !atBottom && newCountWhileAway > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
1638
- "button",
1639
- {
1640
- type: "button",
1641
- className: "poolse-conversation__scroll-to-new",
1642
- onClick: scrollToBottom,
1643
- children: [
1644
- "\u2193 ",
1645
- newCountWhileAway,
1646
- " new ",
1647
- newCountWhileAway === 1 ? "message" : "messages"
1648
- ]
1649
- }
1650
- ),
1651
- /* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
1652
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__composer-row", children: [
1653
- attachments && /* @__PURE__ */ jsxRuntime.jsx(AttachmentPickerButton, { onPick: onPickFile, disabled: uploading }),
1654
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
1655
- ] })
1656
- ] }),
1908
+ /* @__PURE__ */ jsxRuntime.jsxs(
1909
+ "div",
1910
+ {
1911
+ className: `poolse-conversation${dragActive ? " is-drag-active" : ""}`,
1912
+ onDragEnter,
1913
+ onDragOver,
1914
+ onDragLeave,
1915
+ onDrop,
1916
+ children: [
1917
+ status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs(
1918
+ "div",
1919
+ {
1920
+ className: "poolse-conversation__status",
1921
+ role: "status",
1922
+ "aria-live": "polite",
1923
+ "aria-atomic": "true",
1924
+ children: [
1925
+ status === "connecting" && "Connecting\u2026",
1926
+ status === "reconnecting" && "Reconnecting\u2026",
1927
+ status === "closed" && "Disconnected"
1928
+ ]
1929
+ }
1930
+ ),
1931
+ /* @__PURE__ */ jsxRuntime.jsxs(
1932
+ "div",
1933
+ {
1934
+ className: "poolse-conversation__messages",
1935
+ ref: listRef,
1936
+ role: "log",
1937
+ "aria-label": "Conversation messages",
1938
+ "aria-live": "polite",
1939
+ "aria-relevant": "additions",
1940
+ children: [
1941
+ hasMore && !loading && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older messages" }),
1942
+ loading && messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
1943
+ if (renderMessage) {
1944
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1945
+ }
1946
+ const prev = idx > 0 ? messages[idx - 1] ?? null : null;
1947
+ const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
1948
+ const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
1949
+ const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
1950
+ const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1951
+ const original = messages.find((m) => m.id === msg.quoted_message_id);
1952
+ if (!original) return msg;
1953
+ return {
1954
+ ...msg,
1955
+ quoted_message: {
1956
+ id: original.id,
1957
+ sender_id: original.sender_id,
1958
+ body: original.body,
1959
+ deleted_at: original.deleted_at,
1960
+ inserted_at: original.inserted_at
1961
+ }
1962
+ };
1963
+ })() : msg;
1964
+ const isSelf = me !== null && msg.sender_id === me.id;
1965
+ const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1966
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
1967
+ showDaySeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
1968
+ /* @__PURE__ */ jsxRuntime.jsx(
1969
+ MessageRow,
1970
+ {
1971
+ msg: enriched,
1972
+ meId: me?.id ?? null,
1973
+ reactions,
1974
+ attachments,
1975
+ actions,
1976
+ threads,
1977
+ quotations,
1978
+ groupPosition,
1979
+ maxBodyLength,
1980
+ markdown,
1981
+ showSenderName: showSenderLabelsResolved,
1982
+ showAvatar: showAvatarsResolved,
1983
+ ...readState ? { readState } : {},
1984
+ ...labelFor ? { labelFor } : {},
1985
+ editing: editingId === msg.id,
1986
+ onStartEdit: () => setEditingId(msg.id),
1987
+ onCancelEdit: () => setEditingId(null),
1988
+ onSaveEdit: async (body) => {
1989
+ await edit(msg.id, body);
1990
+ setEditingId(null);
1991
+ },
1992
+ onDelete: () => void deleteMsg(msg.id),
1993
+ onOpenThread: () => setThreadRootId(msg.id),
1994
+ onQuote: () => setReplyingTo(msg),
1995
+ onQuotedClick: scrollToOriginal
1996
+ }
1997
+ )
1998
+ ] }, msg.id);
1999
+ }),
2000
+ error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
2001
+ "Failed to load: ",
2002
+ error.message
2003
+ ] }),
2004
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: bottomSentinelRef, "aria-hidden": "true", style: { height: 1 } })
2005
+ ]
2006
+ }
2007
+ ),
2008
+ !atBottom && newCountWhileAway > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
2009
+ "button",
2010
+ {
2011
+ type: "button",
2012
+ className: "poolse-conversation__scroll-to-new",
2013
+ onClick: scrollToBottom,
2014
+ children: [
2015
+ "\u2193 ",
2016
+ newCountWhileAway,
2017
+ " new ",
2018
+ newCountWhileAway === 1 ? "message" : "messages"
2019
+ ]
2020
+ }
2021
+ ),
2022
+ /* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
2023
+ attachments && /* @__PURE__ */ jsxRuntime.jsx(
2024
+ UploadQueueStrip,
2025
+ {
2026
+ items: visibleUploads,
2027
+ onCancel: cancelUpload,
2028
+ onDismiss: removeUpload
2029
+ }
2030
+ ),
2031
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__composer-row", children: [
2032
+ attachments && /* @__PURE__ */ jsxRuntime.jsx(AttachmentPickerButton, { onPick: onPickFiles, disabled: uploading }),
2033
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__composer-flex", children: Composer })
2034
+ ] }),
2035
+ dragActive && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
2036
+ /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
2037
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
2038
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation__drop-overlay-hint", children: "They'll be sent in one message" })
2039
+ ] }) })
2040
+ ]
2041
+ }
2042
+ ),
1657
2043
  threads && threadRoot && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-conversation-shell__thread", children: /* @__PURE__ */ jsxRuntime.jsx(
1658
2044
  ThreadView,
1659
2045
  {
@@ -1675,10 +2061,11 @@ function AttachmentPickerButton({
1675
2061
  {
1676
2062
  ref: inputRef,
1677
2063
  type: "file",
2064
+ multiple: true,
1678
2065
  className: "poolse-attach-input",
1679
2066
  onChange: (e) => {
1680
- const f = e.target.files?.[0];
1681
- if (f) onPick(f);
2067
+ const files = Array.from(e.target.files ?? []);
2068
+ if (files.length > 0) onPick(files);
1682
2069
  e.target.value = "";
1683
2070
  }
1684
2071
  }
@@ -1690,49 +2077,13 @@ function AttachmentPickerButton({
1690
2077
  className: "poolse-attach-btn",
1691
2078
  onClick: () => inputRef.current?.click(),
1692
2079
  disabled,
1693
- "aria-label": "Attach file",
1694
- title: "Attach file",
2080
+ "aria-label": "Attach files",
2081
+ title: "Attach files",
1695
2082
  children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "attachment", size: 20, label: null })
1696
2083
  }
1697
2084
  )
1698
2085
  ] });
1699
2086
  }
1700
- function computeGroupPosition(msg, prev, next, windowMs) {
1701
- const continuesPrev = sameGroup(msg, prev, windowMs);
1702
- const continuesNext = sameGroup(next, msg, windowMs);
1703
- if (continuesPrev && continuesNext) return "middle";
1704
- if (continuesPrev) return "last";
1705
- if (continuesNext) return "first";
1706
- return "standalone";
1707
- }
1708
- function sameGroup(a, b, windowMs) {
1709
- if (!a || !b) return false;
1710
- if (a.sender_id !== b.sender_id) return false;
1711
- if (!sameDay(a.inserted_at, b.inserted_at)) return false;
1712
- const ta = new Date(a.inserted_at).getTime();
1713
- const tb = new Date(b.inserted_at).getTime();
1714
- return Math.abs(ta - tb) <= windowMs;
1715
- }
1716
- function sameDay(a, b) {
1717
- const da = new Date(a);
1718
- const db = new Date(b);
1719
- return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
1720
- }
1721
- function formatDayLabel(iso) {
1722
- const d = new Date(iso);
1723
- const now = /* @__PURE__ */ new Date();
1724
- const startOfDay = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
1725
- const diffDays = Math.floor((startOfDay(now) - startOfDay(d)) / 864e5);
1726
- if (diffDays === 0) return "Today";
1727
- if (diffDays === 1) return "Yesterday";
1728
- if (diffDays < 7) {
1729
- return d.toLocaleDateString(void 0, { weekday: "long" });
1730
- }
1731
- if (d.getFullYear() === now.getFullYear()) {
1732
- return d.toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" });
1733
- }
1734
- return d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" });
1735
- }
1736
2087
  function ConversationList({
1737
2088
  selectedId,
1738
2089
  onSelect,
@@ -1828,6 +2179,10 @@ function MemberList({
1828
2179
  emptyState
1829
2180
  }) {
1830
2181
  const { members, loading, error, removeMember } = react$1.useMembers(conversationId);
2182
+ const { online: presenceOnline } = react$1.usePresence(
2183
+ onlineUserIds === void 0 ? conversationId : ""
2184
+ );
2185
+ const effectiveOnline = onlineUserIds ?? presenceOnline;
1831
2186
  if (loading && members.length === 0) {
1832
2187
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: "Loading members\u2026" });
1833
2188
  }
@@ -1840,19 +2195,18 @@ function MemberList({
1840
2195
  if (members.length === 0) {
1841
2196
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-list poolse-list--placeholder", children: emptyState ?? "No members yet." });
1842
2197
  }
1843
- const label = labelFor ?? ((id) => id.slice(0, 8));
1844
2198
  return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "poolse-list", role: "list", "aria-label": "Members", children: members.map((m) => {
1845
2199
  const content = renderItem ? renderItem(m) : /* @__PURE__ */ jsxRuntime.jsx(
1846
2200
  DefaultMemberRow,
1847
2201
  {
1848
2202
  membership: m,
1849
- name: label(m.user_id),
1850
2203
  avatarUrl: avatarFor?.(m.user_id) ?? null,
1851
- online: onlineUserIds?.has(m.user_id) ?? false,
2204
+ online: effectiveOnline.has(m.user_id),
1852
2205
  removable: canRemove?.(m) ?? false,
1853
2206
  onRemove: () => {
1854
2207
  void removeMember(m.user_id);
1855
- }
2208
+ },
2209
+ ...labelFor ? { labelFor } : {}
1856
2210
  }
1857
2211
  );
1858
2212
  return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "poolse-list__item", children: content }, m.id);
@@ -1860,12 +2214,13 @@ function MemberList({
1860
2214
  }
1861
2215
  function DefaultMemberRow({
1862
2216
  membership,
1863
- name,
1864
2217
  avatarUrl,
1865
2218
  online,
1866
2219
  removable,
1867
- onRemove
2220
+ onRemove,
2221
+ labelFor
1868
2222
  }) {
2223
+ const name = useDisplayName(membership.user_id, labelFor);
1869
2224
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-member-row", children: [
1870
2225
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name, online, size: "md" }),
1871
2226
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-member-row__body", children: [
@@ -2017,6 +2372,9 @@ exports.ReactionPicker = ReactionPicker;
2017
2372
  exports.ReactionStrip = ReactionStrip;
2018
2373
  exports.ThreadView = ThreadView;
2019
2374
  exports.TypingIndicator = TypingIndicator;
2375
+ exports.UploadQueueStrip = UploadQueueStrip;
2376
+ exports.UserName = UserName;
2377
+ exports.useDisplayName = useDisplayName;
2020
2378
  exports.usePoolseFonts = usePoolseFonts;
2021
2379
  //# sourceMappingURL=index.cjs.map
2022
2380
  //# sourceMappingURL=index.cjs.map