@poolse/react-ui 0.2.0-alpha.7 → 1.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to `@poolse/react-ui` are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [semver](https://semver.org).
6
6
 
7
+ ## [1.0.0-beta.0] — 2026-06-01
8
+
9
+ First beta of the stable component surface. Promotes the full 0.2.x
10
+ UI kit (ConversationView with reactions / mentions / attachments /
11
+ threads / quotations / readReceipts flags, MessageRow with thread
12
+ pill + quote card, MessageComposer / MentionInput with the quote
13
+ chip, MessageBubble with the WhatsApp-style QuotedCard + fallback
14
+ placeholder, ConversationList with unread badges) to a stable
15
+ namespace. No breaking changes relative to `0.2.0-alpha.7`.
16
+
7
17
  ## [0.2.0] — 2026-06-01
8
18
 
9
19
  ### Changed — quote card polish
package/dist/index.cjs CHANGED
@@ -4,6 +4,13 @@
4
4
  var react$1 = require('@poolse/react');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
+ var ReactMarkdown = require('react-markdown');
8
+ var remarkGfm = require('remark-gfm');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
13
+ var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
7
14
 
8
15
  // src/ConversationView.tsx
9
16
  var FONT_HREF = "https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap";
@@ -42,6 +49,40 @@ function PoolseFonts() {
42
49
  return null;
43
50
  }
44
51
 
52
+ // src/listAutocomplete.ts
53
+ var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
54
+ var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
55
+ function handleListEnter(value, caret) {
56
+ const lineStart = value.lastIndexOf("\n", caret - 1) + 1;
57
+ const lineEnd = (() => {
58
+ const nl = value.indexOf("\n", caret);
59
+ return nl === -1 ? value.length : nl;
60
+ })();
61
+ const currentLine = value.slice(lineStart, lineEnd);
62
+ const unordered = UNORDERED_RE.exec(currentLine);
63
+ const ordered = ORDERED_RE.exec(currentLine);
64
+ const match = unordered ?? ordered;
65
+ if (!match) return null;
66
+ const indent = match[1] ?? "";
67
+ const marker = match[2] ?? "";
68
+ const content = match[3] ?? "";
69
+ if (content === "") {
70
+ const before2 = value.slice(0, lineStart);
71
+ const after2 = value.slice(lineEnd);
72
+ return { kind: "end", value: before2 + after2, caret: lineStart };
73
+ }
74
+ const nextMarker = ordered ? `${parseInt(marker, 10) + 1}.` : marker;
75
+ const prefix = `
76
+ ${indent}${nextMarker} `;
77
+ const before = value.slice(0, caret);
78
+ const after = value.slice(caret);
79
+ return {
80
+ kind: "continue",
81
+ value: before + prefix + after,
82
+ caret: caret + prefix.length
83
+ };
84
+ }
85
+
45
86
  // src/icons-data.ts
46
87
  var ICONS = {
47
88
  attachment: {
@@ -350,6 +391,17 @@ function MentionInput({
350
391
  }
351
392
  }
352
393
  if (e.key === "Enter" && !e.shiftKey) {
394
+ const ta = e.currentTarget;
395
+ const caret = ta.selectionStart;
396
+ const result = handleListEnter(value, caret);
397
+ if (result) {
398
+ e.preventDefault();
399
+ setValue(result.value);
400
+ requestAnimationFrame(() => {
401
+ taRef.current?.setSelectionRange(result.caret, result.caret);
402
+ });
403
+ return;
404
+ }
353
405
  e.preventDefault();
354
406
  void submit();
355
407
  }
@@ -446,6 +498,7 @@ function MessageComposer({
446
498
  }) {
447
499
  const [value, setValue] = react.useState("");
448
500
  const [sending, setSending] = react.useState(false);
501
+ const taRef = react.useRef(null);
449
502
  const submit = async () => {
450
503
  const trimmed = value.trim();
451
504
  if (!trimmed || sending) return;
@@ -459,6 +512,17 @@ function MessageComposer({
459
512
  };
460
513
  const onKeyDown = (e) => {
461
514
  if (e.key === "Enter" && !e.shiftKey) {
515
+ const ta = e.currentTarget;
516
+ const caret = ta.selectionStart;
517
+ const result = handleListEnter(value, caret);
518
+ if (result) {
519
+ e.preventDefault();
520
+ setValue(result.value);
521
+ requestAnimationFrame(() => {
522
+ taRef.current?.setSelectionRange(result.caret, result.caret);
523
+ });
524
+ return;
525
+ }
462
526
  e.preventDefault();
463
527
  void submit();
464
528
  }
@@ -492,6 +556,7 @@ function MessageComposer({
492
556
  /* @__PURE__ */ jsxRuntime.jsx(
493
557
  "textarea",
494
558
  {
559
+ ref: taRef,
495
560
  className: "poolse-composer__input",
496
561
  rows: 1,
497
562
  value,
@@ -638,24 +703,88 @@ function formatBytes(n) {
638
703
  if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
639
704
  return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
640
705
  }
706
+ function Avatar({ src, name, online, size = "md", className }) {
707
+ const initials = computeInitials(name);
708
+ const classes = [
709
+ "poolse-avatar",
710
+ size === "sm" ? "poolse-avatar--sm" : null,
711
+ size === "lg" ? "poolse-avatar--lg" : null,
712
+ className
713
+ ].filter(Boolean).join(" ");
714
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: classes, "aria-label": name ?? "avatar", role: "img", children: [
715
+ src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: name ?? "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: initials }),
716
+ online ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-avatar__presence", "aria-hidden": "true" }) : null
717
+ ] });
718
+ }
719
+ function computeInitials(name) {
720
+ if (!name) return "?";
721
+ const parts = name.trim().split(/\s+/).slice(0, 2);
722
+ return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
723
+ }
724
+
725
+ // src/userColor.ts
726
+ var PALETTE = [
727
+ "#6366f1",
728
+ // indigo
729
+ "#10b981",
730
+ // emerald
731
+ "#f59e0b",
732
+ // amber
733
+ "#ec4899",
734
+ // rose
735
+ "#0ea5e9",
736
+ // sky
737
+ "#8b5cf6",
738
+ // violet
739
+ "#14b8a6",
740
+ // teal
741
+ "#d946ef"
742
+ // fuchsia
743
+ ];
744
+ function userColor(userId) {
745
+ let h = 0;
746
+ for (let i = 0; i < userId.length; i++) {
747
+ h = h * 31 + userId.charCodeAt(i) | 0;
748
+ }
749
+ return PALETTE[Math.abs(h) % PALETTE.length];
750
+ }
641
751
  function MessageBubble({
642
752
  message,
643
753
  currentUserId,
644
754
  readState,
645
755
  labelFor,
646
- onQuotedClick
756
+ onQuotedClick,
757
+ groupPosition = "standalone",
758
+ maxBodyLength = 0,
759
+ markdown = false,
760
+ showSenderName = false
647
761
  }) {
648
762
  const isSelf = currentUserId !== null && message.sender_id === currentUserId;
763
+ const [expanded, setExpanded] = react.useState(false);
764
+ const { profile: sender } = react$1.useUser(!isSelf ? message.sender_id : null);
765
+ const senderFallbackName = message.sender_id ? `User ${message.sender_id.slice(0, 6)}` : "Unknown";
766
+ const senderName = sender?.displayName ?? senderFallbackName;
767
+ const senderColorHex = message.sender_id ? userColor(message.sender_id) : "currentColor";
768
+ const renderSenderName = showSenderName && !isSelf && (groupPosition === "first" || groupPosition === "standalone");
649
769
  const className = [
650
770
  "poolse-message",
651
- isSelf ? "poolse-message--self" : "poolse-message--other"
771
+ isSelf ? "poolse-message--self" : "poolse-message--other",
772
+ // Group-position modifier — CSS uses it to toggle which corners
773
+ // get the asymmetric tail vs. fully-rounded treatment.
774
+ `poolse-message--${groupPosition}`
652
775
  ].join(" ");
776
+ const rawBody = message.body ?? "";
777
+ const TRIM_BUFFER = 40;
778
+ const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength + TRIM_BUFFER;
779
+ const displayBody = shouldTrim ? rawBody.slice(0, maxBodyLength).trimEnd() + "\u2026" : rawBody;
653
780
  const time = message.inserted_at ? new Date(message.inserted_at).toLocaleTimeString(void 0, {
654
781
  hour: "2-digit",
655
782
  minute: "2-digit"
656
783
  }) : "";
784
+ const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
657
785
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
658
- message.quoted_message && /* @__PURE__ */ jsxRuntime.jsx(
786
+ renderSenderName && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }),
787
+ showQuoteCard === "full" && /* @__PURE__ */ jsxRuntime.jsx(
659
788
  QuotedCard,
660
789
  {
661
790
  quoted: message.quoted_message,
@@ -664,7 +793,45 @@ function MessageBubble({
664
793
  ...onQuotedClick ? { onClick: onQuotedClick } : {}
665
794
  }
666
795
  ),
667
- message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: message.body ?? "" }),
796
+ showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
797
+ message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-message__body", children: [
798
+ markdown ? /* @__PURE__ */ jsxRuntime.jsx(
799
+ ReactMarkdown__default.default,
800
+ {
801
+ remarkPlugins: [remarkGfm__default.default],
802
+ components: {
803
+ // Force links to a new tab + no opener — chat content
804
+ // is user-supplied so security defaults matter.
805
+ a: ({ node: _node, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
806
+ },
807
+ children: displayBody
808
+ }
809
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayBody }),
810
+ shouldTrim && /* @__PURE__ */ jsxRuntime.jsx(
811
+ "button",
812
+ {
813
+ type: "button",
814
+ className: "poolse-message__read-more",
815
+ onClick: (e) => {
816
+ e.stopPropagation();
817
+ setExpanded(true);
818
+ },
819
+ children: "Read more"
820
+ }
821
+ ),
822
+ !shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER && /* @__PURE__ */ jsxRuntime.jsx(
823
+ "button",
824
+ {
825
+ type: "button",
826
+ className: "poolse-message__read-more",
827
+ onClick: (e) => {
828
+ e.stopPropagation();
829
+ setExpanded(false);
830
+ },
831
+ children: "Show less"
832
+ }
833
+ )
834
+ ] }),
668
835
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-message__meta", children: [
669
836
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
670
837
  message.edited_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: " \xB7 edited" }) : null,
@@ -679,6 +846,22 @@ function MessageBubble({
679
846
  ] })
680
847
  ] });
681
848
  }
849
+ function QuotedPlaceholder({
850
+ isSelf,
851
+ quotedMessageId: _quotedMessageId
852
+ }) {
853
+ return /* @__PURE__ */ jsxRuntime.jsxs(
854
+ "div",
855
+ {
856
+ className: `poolse-quote poolse-quote--placeholder ${isSelf ? "poolse-quote--self" : "poolse-quote--other"}`,
857
+ "aria-label": "Quoted message",
858
+ children: [
859
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__sender", children: "Replying to a message" }),
860
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-quote__body", children: "Loading preview\u2026" })
861
+ ]
862
+ }
863
+ );
864
+ }
682
865
  function QuotedCard({
683
866
  quoted,
684
867
  isSelf,
@@ -950,8 +1133,16 @@ function MessageRow({
950
1133
  onOpenThread,
951
1134
  onQuote,
952
1135
  labelFor,
953
- onQuotedClick
1136
+ onQuotedClick,
1137
+ groupPosition = "standalone",
1138
+ maxBodyLength = 0,
1139
+ markdown = false,
1140
+ showSenderName = false,
1141
+ showAvatar = false
954
1142
  }) {
1143
+ const { profile: senderProfile } = react$1.useUser(msg.sender_id);
1144
+ const senderFallbackName = msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown";
1145
+ const senderName = senderProfile?.displayName ?? senderFallbackName;
955
1146
  const isSelf = meId !== null && msg.sender_id === meId;
956
1147
  const reactionsHook = react$1.useReactions(reactions ? msg.id : "", {
957
1148
  conversationId: msg.conversation_id,
@@ -965,80 +1156,109 @@ function MessageRow({
965
1156
  const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
966
1157
  const handleSave = onSaveEdit ?? (async () => void 0);
967
1158
  const handleCancel = onCancelEdit ?? (() => void 0);
968
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `poolse-message-row ${isSelf ? "poolse-message-row--right" : ""}`, children: [
969
- editing ? /* @__PURE__ */ jsxRuntime.jsx(
970
- EditableMessageBubble,
971
- {
972
- message: msg,
973
- currentUserId: meId,
974
- ...readState ? { readState } : {},
975
- editing: true,
976
- onSave: handleSave,
977
- onCancel: handleCancel
978
- }
979
- ) : /* @__PURE__ */ jsxRuntime.jsx(
980
- MessageBubble,
981
- {
982
- message: msg,
983
- currentUserId: meId,
984
- ...readState ? { readState } : {},
985
- ...labelFor ? { labelFor } : {},
986
- ...onQuotedClick ? { onQuotedClick } : {}
987
- }
988
- ),
989
- showAttachments && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
990
- showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
991
- InlineReactions,
992
- {
993
- reactions: reactionsHook.reactions,
994
- currentUserId: meId,
995
- onAdd: (e) => void reactionsHook.addReaction(e),
996
- onRemove: (e) => void reactionsHook.removeReaction(e)
997
- }
998
- ) }),
999
- showThreadPill && /* @__PURE__ */ jsxRuntime.jsxs(
1000
- "button",
1001
- {
1002
- type: "button",
1003
- className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
1004
- onClick: onOpenThread,
1005
- "aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
1006
- children: [
1007
- /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
1008
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1009
- replyCount,
1010
- " ",
1011
- replyCount === 1 ? "reply" : "replies"
1012
- ] })
1013
- ]
1014
- }
1015
- ),
1016
- showActions && /* @__PURE__ */ jsxRuntime.jsx(
1017
- "div",
1018
- {
1019
- className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
1020
- children: /* @__PURE__ */ jsxRuntime.jsx(
1021
- MessageActions,
1159
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1160
+ "div",
1161
+ {
1162
+ className: [
1163
+ "poolse-message-row",
1164
+ isSelf ? "poolse-message-row--right" : "",
1165
+ // Modifier mirrors the bubble's groupPosition so the CSS can
1166
+ // tighten the inter-bubble gap inside a cluster (first/middle/
1167
+ // last) and widen it between clusters (standalone or the
1168
+ // first of a new run).
1169
+ `poolse-message-row--${groupPosition}`
1170
+ ].filter(Boolean).join(" "),
1171
+ "data-message-id": msg.id,
1172
+ children: [
1173
+ editing ? /* @__PURE__ */ jsxRuntime.jsx(
1174
+ EditableMessageBubble,
1175
+ {
1176
+ message: msg,
1177
+ currentUserId: meId,
1178
+ ...readState ? { readState } : {},
1179
+ editing: true,
1180
+ onSave: handleSave,
1181
+ onCancel: handleCancel
1182
+ }
1183
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1184
+ BubbleWithAvatar,
1022
1185
  {
1023
- ...reactions ? {
1024
- onReact: (emoji) => {
1025
- void reactionsHook.addReaction(emoji);
1186
+ isSelf,
1187
+ showAvatar,
1188
+ groupPosition,
1189
+ senderName,
1190
+ avatarUrl: senderProfile?.avatarUrl ?? null,
1191
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1192
+ MessageBubble,
1193
+ {
1194
+ message: msg,
1195
+ currentUserId: meId,
1196
+ groupPosition,
1197
+ maxBodyLength,
1198
+ markdown,
1199
+ showSenderName,
1200
+ ...readState ? { readState } : {},
1201
+ ...labelFor ? { labelFor } : {},
1202
+ ...onQuotedClick ? { onQuotedClick } : {}
1026
1203
  }
1027
- } : {},
1028
- ...threads && onOpenThread ? { onReply: onOpenThread } : {},
1029
- ...quotations && onQuote ? { onQuote } : {},
1030
- ...msg.body ? {
1031
- onCopy: () => {
1032
- void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
1204
+ )
1205
+ }
1206
+ ),
1207
+ showAttachments && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__attachments ${isSelf ? "is-self" : ""}`, children: msg.attachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
1208
+ showReactions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
1209
+ InlineReactions,
1210
+ {
1211
+ reactions: reactionsHook.reactions,
1212
+ currentUserId: meId,
1213
+ onAdd: (e) => void reactionsHook.addReaction(e),
1214
+ onRemove: (e) => void reactionsHook.removeReaction(e)
1215
+ }
1216
+ ) }),
1217
+ showThreadPill && /* @__PURE__ */ jsxRuntime.jsxs(
1218
+ "button",
1219
+ {
1220
+ type: "button",
1221
+ className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
1222
+ onClick: onOpenThread,
1223
+ "aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
1224
+ children: [
1225
+ /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
1226
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1227
+ replyCount,
1228
+ " ",
1229
+ replyCount === 1 ? "reply" : "replies"
1230
+ ] })
1231
+ ]
1232
+ }
1233
+ ),
1234
+ showActions && /* @__PURE__ */ jsxRuntime.jsx(
1235
+ "div",
1236
+ {
1237
+ className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
1238
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1239
+ MessageActions,
1240
+ {
1241
+ ...reactions ? {
1242
+ onReact: (emoji) => {
1243
+ void reactionsHook.addReaction(emoji);
1244
+ }
1245
+ } : {},
1246
+ ...threads && onOpenThread ? { onReply: onOpenThread } : {},
1247
+ ...quotations && onQuote ? { onQuote } : {},
1248
+ ...msg.body ? {
1249
+ onCopy: () => {
1250
+ void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
1251
+ }
1252
+ } : {},
1253
+ ...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
1254
+ ...isSelf && onDelete ? { onDelete } : {}
1033
1255
  }
1034
- } : {},
1035
- ...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
1036
- ...isSelf && onDelete ? { onDelete } : {}
1256
+ )
1037
1257
  }
1038
1258
  )
1039
- }
1040
- )
1041
- ] });
1259
+ ]
1260
+ }
1261
+ );
1042
1262
  }
1043
1263
  function InlineReactions({
1044
1264
  reactions,
@@ -1070,6 +1290,21 @@ function InlineReactions({
1070
1290
  );
1071
1291
  }) });
1072
1292
  }
1293
+ function BubbleWithAvatar({
1294
+ isSelf,
1295
+ showAvatar,
1296
+ groupPosition,
1297
+ senderName,
1298
+ avatarUrl,
1299
+ children
1300
+ }) {
1301
+ if (isSelf || !showAvatar) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
1302
+ const isLastOfCluster = groupPosition === "last" || groupPosition === "standalone";
1303
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-bubble-shell", children: [
1304
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-bubble-shell__avatar", children: isLastOfCluster ? /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: senderName, size: "sm" }) : null }),
1305
+ children
1306
+ ] });
1307
+ }
1073
1308
  function ThreadView({
1074
1309
  conversationId,
1075
1310
  rootMessage,
@@ -1159,6 +1394,13 @@ function ConversationView({
1159
1394
  threads = TRUE,
1160
1395
  quotations = TRUE,
1161
1396
  readReceipts = TRUE,
1397
+ markdown = TRUE,
1398
+ maxBodyLength = 200,
1399
+ grouping = TRUE,
1400
+ groupingWindowMs = 5 * 60 * 1e3,
1401
+ daySeparators = TRUE,
1402
+ senderLabels = "auto",
1403
+ avatars = "auto",
1162
1404
  onMarkedRead
1163
1405
  }) {
1164
1406
  usePoolseFonts(loadFonts);
@@ -1176,8 +1418,12 @@ function ConversationView({
1176
1418
  } = react$1.useMessages(conversationId);
1177
1419
  const { typing, signalTyping } = react$1.useTyping(conversationId);
1178
1420
  const status = react$1.useRealtimeStatus();
1179
- const membersOn = mentions || readReceipts;
1421
+ const wantsMemberCount = senderLabels === "auto" || avatars === "auto";
1422
+ const membersOn = mentions || readReceipts || wantsMemberCount;
1180
1423
  const { members } = react$1.useMembers(membersOn ? conversationId : "");
1424
+ const isGroupChat = members.length > 2;
1425
+ const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
1426
+ const showAvatarsResolved = avatars === "always" || avatars === "auto" && isGroupChat;
1181
1427
  const listRef = react.useRef(null);
1182
1428
  const lastMessageIdRef = react.useRef(null);
1183
1429
  const bottomSentinelRef = react.useRef(null);
@@ -1324,10 +1570,14 @@ function ConversationView({
1324
1570
  ] }),
1325
1571
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__messages", ref: listRef, children: [
1326
1572
  hasMore && !loading && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-conversation__load-more", onClick: loadMore, children: "Load older messages" }),
1327
- 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) => {
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) => {
1328
1574
  if (renderMessage) {
1329
1575
  return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
1330
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));
1331
1581
  const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
1332
1582
  const original = messages.find((m) => m.id === msg.quoted_message_id);
1333
1583
  if (!original) return msg;
@@ -1344,31 +1594,39 @@ function ConversationView({
1344
1594
  })() : msg;
1345
1595
  const isSelf = me !== null && msg.sender_id === me.id;
1346
1596
  const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
1347
- return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-message-id": msg.id, children: /* @__PURE__ */ jsxRuntime.jsx(
1348
- MessageRow,
1349
- {
1350
- msg: enriched,
1351
- meId: me?.id ?? null,
1352
- reactions,
1353
- attachments,
1354
- actions,
1355
- threads,
1356
- quotations,
1357
- ...readState ? { readState } : {},
1358
- ...labelFor ? { labelFor } : {},
1359
- editing: editingId === msg.id,
1360
- onStartEdit: () => setEditingId(msg.id),
1361
- onCancelEdit: () => setEditingId(null),
1362
- onSaveEdit: async (body) => {
1363
- await edit(msg.id, body);
1364
- setEditingId(null);
1365
- },
1366
- onDelete: () => void deleteMsg(msg.id),
1367
- onOpenThread: () => setThreadRootId(msg.id),
1368
- onQuote: () => setReplyingTo(msg),
1369
- onQuotedClick: scrollToOriginal
1370
- }
1371
- ) }, msg.id);
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);
1372
1630
  }),
1373
1631
  error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-conversation__empty", children: [
1374
1632
  "Failed to load: ",
@@ -1439,23 +1697,41 @@ function AttachmentPickerButton({
1439
1697
  )
1440
1698
  ] });
1441
1699
  }
1442
- function Avatar({ src, name, online, size = "md", className }) {
1443
- const initials = computeInitials(name);
1444
- const classes = [
1445
- "poolse-avatar",
1446
- size === "sm" ? "poolse-avatar--sm" : null,
1447
- size === "lg" ? "poolse-avatar--lg" : null,
1448
- className
1449
- ].filter(Boolean).join(" ");
1450
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: classes, "aria-label": name ?? "avatar", role: "img", children: [
1451
- src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: name ?? "" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: initials }),
1452
- online ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-avatar__presence", "aria-hidden": "true" }) : null
1453
- ] });
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";
1454
1707
  }
1455
- function computeInitials(name) {
1456
- if (!name) return "?";
1457
- const parts = name.trim().split(/\s+/).slice(0, 2);
1458
- return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
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" });
1459
1735
  }
1460
1736
  function ConversationList({
1461
1737
  selectedId,