@poolse/react-ui 2.19.0 → 2.21.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,36 @@ 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
+ ## [2.20.0] — 2026-10-13
8
+
9
+ ### Changed
10
+
11
+ - **The message bubble, rebuilt.** Same props, new rendering:
12
+ - The timestamp (with `edited` and the read ticks) sits on the last
13
+ line of plain-text bodies — an invisible spacer twin reserves its
14
+ exact footprint, so it shares the line or wraps flush right.
15
+ - Media bleeds to a 3px frame of bubble color, capped at 420px
16
+ (`.poolse-message--has-media`), and squares its bottom corners
17
+ into a following caption. Mosaic seams carry the bubble's color
18
+ instead of a grey backing. Bubble radius 16px → 18px.
19
+ - 1–3 emoji and nothing else render large, without bubble chrome
20
+ (`.poolse-message--jumbo`).
21
+ - Markdown bodies no longer inherit `white-space: pre-wrap`, which
22
+ rendered react-markdown's inter-element newlines as phantom blank
23
+ lines in lists.
24
+ - The hover actions chevron floats half outside the bubble's
25
+ top-right corner as a bordered disc, instead of a translucent
26
+ stamp overlapping the corner radius. The bubble no longer clips
27
+ its contents (`overflow: hidden` removed); the mosaic clips
28
+ itself.
29
+ - Quote cards: 10px radius; deleted messages read "Message deleted".
30
+
31
+ ### Fixed
32
+
33
+ - **In-bubble file cards overflowed the bubble** — `width: 100%` plus
34
+ padding with no `box-sizing: border-box`, previously masked by the
35
+ bubble's overflow clip.
36
+
7
37
  ## [2.19.0] — 2026-08-25
8
38
 
9
39
  ### Changed
package/dist/index.cjs CHANGED
@@ -1476,6 +1476,35 @@ function computeInitials(name) {
1476
1476
  const parts = name.trim().split(/\s+/).slice(0, 2);
1477
1477
  return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
1478
1478
  }
1479
+ function CallLogRow({ msg, meId }) {
1480
+ const display = react$1.callLogDisplayFor(msg, meId);
1481
+ if (!display) return null;
1482
+ return /* @__PURE__ */ jsxRuntime.jsx(CallLogLine, { display, insertedAt: msg.inserted_at });
1483
+ }
1484
+ function CallLogLine({ display, insertedAt }) {
1485
+ const time = formatTime(insertedAt);
1486
+ const icon = display.media === "video" ? "video" : "phone";
1487
+ const label = [display.title, display.detail, time].filter(Boolean).join(", ");
1488
+ return /* @__PURE__ */ jsxRuntime.jsx(
1489
+ "div",
1490
+ {
1491
+ className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
1492
+ role: "note",
1493
+ "aria-label": label,
1494
+ children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-call-log__chip", children: [
1495
+ /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: 13, label: null, className: "poolse-call-log__icon" }),
1496
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__title", children: display.title }),
1497
+ display.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
1498
+ time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__time", children: time })
1499
+ ] })
1500
+ }
1501
+ );
1502
+ }
1503
+ function formatTime(iso) {
1504
+ const d = new Date(iso);
1505
+ if (Number.isNaN(d.getTime())) return "";
1506
+ return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
1507
+ }
1479
1508
  function AttachmentPreview({ attachment, onClick }) {
1480
1509
  const isFullRow = "content_type" in attachment;
1481
1510
  const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
@@ -1639,6 +1668,27 @@ function formatBytes(n) {
1639
1668
  if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
1640
1669
  return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
1641
1670
  }
1671
+
1672
+ // src/bubbleText.ts
1673
+ function hasMarkdown(body) {
1674
+ return /[*_~`#>|\\]|\[.*\]|^\s*(?:[-+]|\d+[.)])\s|https?:\/\/|www\./ms.test(body);
1675
+ }
1676
+ function emojiOnlyCount(body) {
1677
+ const text = body.trim();
1678
+ if (!text || text.length > 32) return 0;
1679
+ try {
1680
+ const unit = "(?:\\p{Regional_Indicator}{2}|\\p{Extended_Pictographic})[\\u{1F3FB}-\\u{1F3FF}]?\\uFE0F?(?:\\u200D\\p{Extended_Pictographic}[\\u{1F3FB}-\\u{1F3FF}]?\\uFE0F?)*";
1681
+ const whole = new RegExp(`^(?:${unit}){1,3}$`, "u");
1682
+ if (!whole.test(text)) return 0;
1683
+ const each = new RegExp(unit, "gu");
1684
+ return (text.match(each) ?? []).length;
1685
+ } catch {
1686
+ return 0;
1687
+ }
1688
+ }
1689
+ function emojiFontSize(count) {
1690
+ return count === 1 ? 44 : count === 2 ? 38 : 32;
1691
+ }
1642
1692
  function MessageBubble({
1643
1693
  message,
1644
1694
  currentUserId,
@@ -1670,6 +1720,9 @@ function MessageBubble({
1670
1720
  const hasAnyAttachment = imageAttachments.length > 0 || fileAttachments.length > 0;
1671
1721
  const hasVisibleBody = !message.deleted_at && rawBody.length > 0;
1672
1722
  const metaOverlay = hasAnyAttachment && imageAttachments.length > 0 && !hasVisibleBody && fileAttachments.length === 0;
1723
+ const jumboCount = hasVisibleBody && !hasAnyAttachment && !message.quoted_message_id ? emojiOnlyCount(rawBody) : 0;
1724
+ const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength + TRIM_BUFFER;
1725
+ const inlineMeta = hasVisibleBody && jumboCount === 0 && !trimToggleVisible && (!markdown || !hasMarkdown(displayBody));
1673
1726
  const className = [
1674
1727
  "poolse-message",
1675
1728
  isSelf ? "poolse-message--self" : "poolse-message--other",
@@ -1679,7 +1732,8 @@ function MessageBubble({
1679
1732
  // Tells the CSS to round the image mosaic's bottom corners to
1680
1733
  // match the bubble's outer corner when nothing follows the media.
1681
1734
  hasAnyAttachment ? "poolse-message--has-media" : "",
1682
- metaOverlay ? "poolse-message--media-only" : ""
1735
+ metaOverlay ? "poolse-message--media-only" : "",
1736
+ jumboCount > 0 ? "poolse-message--jumbo" : ""
1683
1737
  ].filter(Boolean).join(" ");
1684
1738
  const time = message.inserted_at ? new Date(message.inserted_at).toLocaleTimeString(void 0, {
1685
1739
  hour: "2-digit",
@@ -1701,62 +1755,83 @@ function MessageBubble({
1701
1755
  showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
1702
1756
  imageAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { images: imageAttachments }),
1703
1757
  fileAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__files", children: fileAttachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) }),
1704
- message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "[deleted]" }) : hasVisibleBody ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-message__body", children: [
1705
- markdown ? /* @__PURE__ */ jsxRuntime.jsx(
1706
- ReactMarkdown__default.default,
1707
- {
1708
- remarkPlugins: [remarkGfm__default.default],
1709
- components: {
1710
- // Force links to a new tab + no opener — chat content
1711
- // is user-supplied so security defaults matter.
1712
- a: ({ node: _node, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
1713
- },
1714
- children: displayBody
1715
- }
1716
- ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayBody }),
1717
- shouldTrim && /* @__PURE__ */ jsxRuntime.jsx(
1718
- "button",
1719
- {
1720
- type: "button",
1721
- className: "poolse-message__read-more",
1722
- onClick: (e) => {
1723
- e.stopPropagation();
1724
- setExpanded(true);
1725
- },
1726
- children: "Read more"
1727
- }
1728
- ),
1729
- !shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER && /* @__PURE__ */ jsxRuntime.jsx(
1730
- "button",
1758
+ (() => {
1759
+ const metaContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1760
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
1761
+ message.edited_at && !message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7 edited" }) : null,
1762
+ isSelf && readState ? /* @__PURE__ */ jsxRuntime.jsx(
1763
+ PoolseIcon,
1764
+ {
1765
+ name: readState === "read" ? "check-double" : "check",
1766
+ size: 14,
1767
+ label: readState === "read" ? "Read" : "Sent"
1768
+ }
1769
+ ) : null
1770
+ ] });
1771
+ const body = message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "Message deleted" }) : hasVisibleBody ? /* @__PURE__ */ jsxRuntime.jsxs(
1772
+ "div",
1731
1773
  {
1732
- type: "button",
1733
- className: "poolse-message__read-more",
1734
- onClick: (e) => {
1735
- e.stopPropagation();
1736
- setExpanded(false);
1737
- },
1738
- children: "Show less"
1774
+ className: markdown && !inlineMeta && jumboCount === 0 ? "poolse-message__body poolse-message__body--md" : "poolse-message__body",
1775
+ children: [
1776
+ jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1777
+ "span",
1778
+ {
1779
+ className: "poolse-message__body--jumbo",
1780
+ style: { fontSize: emojiFontSize(jumboCount) },
1781
+ children: displayBody
1782
+ }
1783
+ ) : markdown && !inlineMeta ? /* @__PURE__ */ jsxRuntime.jsx(
1784
+ ReactMarkdown__default.default,
1785
+ {
1786
+ remarkPlugins: [remarkGfm__default.default],
1787
+ components: {
1788
+ // Force links to a new tab + no opener — chat content
1789
+ // is user-supplied so security defaults matter.
1790
+ a: ({ node: _node, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
1791
+ },
1792
+ children: displayBody
1793
+ }
1794
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayBody }),
1795
+ inlineMeta && // Invisible twin of the meta, inline after the text: it
1796
+ // reserves exactly the meta's footprint on the last
1797
+ // line, so the absolutely-positioned real meta never
1798
+ // overlaps a glyph — and when the line is full, the
1799
+ // reservation wraps and the meta drops a line, flush
1800
+ // right. The WhatsApp trick.
1801
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__meta poolse-message__meta--spacer", "aria-hidden": true, children: metaContent }),
1802
+ shouldTrim && /* @__PURE__ */ jsxRuntime.jsx(
1803
+ "button",
1804
+ {
1805
+ type: "button",
1806
+ className: "poolse-message__read-more",
1807
+ onClick: (e) => {
1808
+ e.stopPropagation();
1809
+ setExpanded(true);
1810
+ },
1811
+ children: "Read more"
1812
+ }
1813
+ ),
1814
+ !shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER && /* @__PURE__ */ jsxRuntime.jsx(
1815
+ "button",
1816
+ {
1817
+ type: "button",
1818
+ className: "poolse-message__read-more",
1819
+ onClick: (e) => {
1820
+ e.stopPropagation();
1821
+ setExpanded(false);
1822
+ },
1823
+ children: "Show less"
1824
+ }
1825
+ )
1826
+ ]
1739
1827
  }
1740
- )
1741
- ] }) : null,
1742
- /* @__PURE__ */ jsxRuntime.jsxs(
1743
- "span",
1744
- {
1745
- className: metaOverlay ? "poolse-message__meta poolse-message__meta--overlay" : "poolse-message__meta",
1746
- children: [
1747
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
1748
- message.edited_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: " \xB7 edited" }) : null,
1749
- isSelf && readState ? /* @__PURE__ */ jsxRuntime.jsx(
1750
- PoolseIcon,
1751
- {
1752
- name: readState === "read" ? "check-double" : "check",
1753
- size: 14,
1754
- label: readState === "read" ? "Read" : "Sent"
1755
- }
1756
- ) : null
1757
- ]
1758
- }
1759
- )
1828
+ ) : null;
1829
+ const metaClass = metaOverlay ? "poolse-message__meta poolse-message__meta--overlay" : inlineMeta ? "poolse-message__meta poolse-message__meta--inline" : "poolse-message__meta poolse-message__meta--block";
1830
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1831
+ body,
1832
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: metaClass, children: metaContent })
1833
+ ] });
1834
+ })()
1760
1835
  ] });
1761
1836
  }
1762
1837
  function isImageContentType(ct) {
@@ -2088,7 +2163,14 @@ function ActionButton({
2088
2163
  ].filter(Boolean).join(" ");
2089
2164
  return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: classes, "aria-label": label, title: label, onClick, children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: 16, label: null }) });
2090
2165
  }
2091
- function MessageRow({
2166
+ function MessageRow(props) {
2167
+ const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
2168
+ if (callLog !== void 0) {
2169
+ return callLog ? /* @__PURE__ */ jsxRuntime.jsx(CallLogRow, { msg: props.msg, meId: props.meId }) : null;
2170
+ }
2171
+ return /* @__PURE__ */ jsxRuntime.jsx(BubbleMessageRow, { ...props });
2172
+ }
2173
+ function BubbleMessageRow({
2092
2174
  msg,
2093
2175
  meId,
2094
2176
  reactions = true,
@@ -2625,6 +2707,11 @@ function ConversationView({
2625
2707
  if (el) el.scrollTop = el.scrollHeight;
2626
2708
  setNewCountWhileAway(0);
2627
2709
  };
2710
+ const meIdForFeed = me?.id ?? null;
2711
+ const visibleMessages = react.useMemo(
2712
+ () => messages.filter((m) => react$1.isMessageVisibleTo(m, meIdForFeed)),
2713
+ [messages, meIdForFeed]
2714
+ );
2628
2715
  const maxReadByOthers = react.useMemo(() => {
2629
2716
  if (!readReceipts || !me) return null;
2630
2717
  let max = 0;
@@ -2761,12 +2848,12 @@ function ConversationView({
2761
2848
  "aria-relevant": "additions",
2762
2849
  children: [
2763
2850
  hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
2764
- 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) => {
2851
+ 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." }) : visibleMessages.map((msg, idx) => {
2765
2852
  if (renderMessage) {
2766
2853
  return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
2767
2854
  }
2768
- const prev = idx > 0 ? messages[idx - 1] ?? null : null;
2769
- const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
2855
+ const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
2856
+ const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
2770
2857
  const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
2771
2858
  const showDaySeparator = daySeparators && (prev === null || !react$1.sameDay(msg.inserted_at, prev.inserted_at));
2772
2859
  const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
@@ -2933,6 +3020,7 @@ function ConversationList({
2933
3020
  const auto = react$1.useConversations();
2934
3021
  const { me } = react$1.useMe();
2935
3022
  const meExternalId = me?.external_id ?? null;
3023
+ const meId = me?.id ?? null;
2936
3024
  const isControlled = controlledConversations !== void 0;
2937
3025
  const conversations = isControlled ? controlledConversations : auto.conversations;
2938
3026
  const loading = isControlled ? controlledLoading ?? false : auto.loading;
@@ -2957,6 +3045,7 @@ function ConversationList({
2957
3045
  selected,
2958
3046
  unread,
2959
3047
  meExternalId,
3048
+ meId,
2960
3049
  ...labelFor ? { labelFor } : {},
2961
3050
  ...avatarFor ? { avatarFor } : {}
2962
3051
  }
@@ -2986,6 +3075,7 @@ function DefaultRow({
2986
3075
  selected: _selected,
2987
3076
  unread,
2988
3077
  meExternalId,
3078
+ meId = null,
2989
3079
  labelFor,
2990
3080
  avatarFor
2991
3081
  }) {
@@ -2995,7 +3085,7 @@ function DefaultRow({
2995
3085
  const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
2996
3086
  const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
2997
3087
  const hasUnread = unread > 0;
2998
- const preview = conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
3088
+ const preview = react$1.formatCallLogPreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
2999
3089
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3000
3090
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: title, size: "md" }),
3001
3091
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
@@ -3584,6 +3674,7 @@ exports.AttachmentPreview = AttachmentPreview;
3584
3674
  exports.Avatar = Avatar;
3585
3675
  exports.CallControlButton = CallControlButton;
3586
3676
  exports.CallDeviceMenu = CallDeviceMenu;
3677
+ exports.CallLogRow = CallLogRow;
3587
3678
  exports.CallProvider = CallProvider;
3588
3679
  exports.CallVideoGrid = CallVideoGrid;
3589
3680
  exports.ChatHeader = ChatHeader;