@poolse/react-ui 2.19.0 → 2.20.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
@@ -1639,6 +1639,27 @@ function formatBytes(n) {
1639
1639
  if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
1640
1640
  return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
1641
1641
  }
1642
+
1643
+ // src/bubbleText.ts
1644
+ function hasMarkdown(body) {
1645
+ return /[*_~`#>|\\]|\[.*\]|^\s*(?:[-+]|\d+[.)])\s|https?:\/\/|www\./ms.test(body);
1646
+ }
1647
+ function emojiOnlyCount(body) {
1648
+ const text = body.trim();
1649
+ if (!text || text.length > 32) return 0;
1650
+ try {
1651
+ const unit = "(?:\\p{Regional_Indicator}{2}|\\p{Extended_Pictographic})[\\u{1F3FB}-\\u{1F3FF}]?\\uFE0F?(?:\\u200D\\p{Extended_Pictographic}[\\u{1F3FB}-\\u{1F3FF}]?\\uFE0F?)*";
1652
+ const whole = new RegExp(`^(?:${unit}){1,3}$`, "u");
1653
+ if (!whole.test(text)) return 0;
1654
+ const each = new RegExp(unit, "gu");
1655
+ return (text.match(each) ?? []).length;
1656
+ } catch {
1657
+ return 0;
1658
+ }
1659
+ }
1660
+ function emojiFontSize(count) {
1661
+ return count === 1 ? 44 : count === 2 ? 38 : 32;
1662
+ }
1642
1663
  function MessageBubble({
1643
1664
  message,
1644
1665
  currentUserId,
@@ -1670,6 +1691,9 @@ function MessageBubble({
1670
1691
  const hasAnyAttachment = imageAttachments.length > 0 || fileAttachments.length > 0;
1671
1692
  const hasVisibleBody = !message.deleted_at && rawBody.length > 0;
1672
1693
  const metaOverlay = hasAnyAttachment && imageAttachments.length > 0 && !hasVisibleBody && fileAttachments.length === 0;
1694
+ const jumboCount = hasVisibleBody && !hasAnyAttachment && !message.quoted_message_id ? emojiOnlyCount(rawBody) : 0;
1695
+ const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength + TRIM_BUFFER;
1696
+ const inlineMeta = hasVisibleBody && jumboCount === 0 && !trimToggleVisible && (!markdown || !hasMarkdown(displayBody));
1673
1697
  const className = [
1674
1698
  "poolse-message",
1675
1699
  isSelf ? "poolse-message--self" : "poolse-message--other",
@@ -1679,7 +1703,8 @@ function MessageBubble({
1679
1703
  // Tells the CSS to round the image mosaic's bottom corners to
1680
1704
  // match the bubble's outer corner when nothing follows the media.
1681
1705
  hasAnyAttachment ? "poolse-message--has-media" : "",
1682
- metaOverlay ? "poolse-message--media-only" : ""
1706
+ metaOverlay ? "poolse-message--media-only" : "",
1707
+ jumboCount > 0 ? "poolse-message--jumbo" : ""
1683
1708
  ].filter(Boolean).join(" ");
1684
1709
  const time = message.inserted_at ? new Date(message.inserted_at).toLocaleTimeString(void 0, {
1685
1710
  hour: "2-digit",
@@ -1701,62 +1726,83 @@ function MessageBubble({
1701
1726
  showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
1702
1727
  imageAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { images: imageAttachments }),
1703
1728
  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",
1729
+ (() => {
1730
+ const metaContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1731
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
1732
+ message.edited_at && !message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7 edited" }) : null,
1733
+ isSelf && readState ? /* @__PURE__ */ jsxRuntime.jsx(
1734
+ PoolseIcon,
1735
+ {
1736
+ name: readState === "read" ? "check-double" : "check",
1737
+ size: 14,
1738
+ label: readState === "read" ? "Read" : "Sent"
1739
+ }
1740
+ ) : null
1741
+ ] });
1742
+ const body = message.deleted_at ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "Message deleted" }) : hasVisibleBody ? /* @__PURE__ */ jsxRuntime.jsxs(
1743
+ "div",
1731
1744
  {
1732
- type: "button",
1733
- className: "poolse-message__read-more",
1734
- onClick: (e) => {
1735
- e.stopPropagation();
1736
- setExpanded(false);
1737
- },
1738
- children: "Show less"
1745
+ className: markdown && !inlineMeta && jumboCount === 0 ? "poolse-message__body poolse-message__body--md" : "poolse-message__body",
1746
+ children: [
1747
+ jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1748
+ "span",
1749
+ {
1750
+ className: "poolse-message__body--jumbo",
1751
+ style: { fontSize: emojiFontSize(jumboCount) },
1752
+ children: displayBody
1753
+ }
1754
+ ) : markdown && !inlineMeta ? /* @__PURE__ */ jsxRuntime.jsx(
1755
+ ReactMarkdown__default.default,
1756
+ {
1757
+ remarkPlugins: [remarkGfm__default.default],
1758
+ components: {
1759
+ // Force links to a new tab + no opener — chat content
1760
+ // is user-supplied so security defaults matter.
1761
+ a: ({ node: _node, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
1762
+ },
1763
+ children: displayBody
1764
+ }
1765
+ ) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayBody }),
1766
+ inlineMeta && // Invisible twin of the meta, inline after the text: it
1767
+ // reserves exactly the meta's footprint on the last
1768
+ // line, so the absolutely-positioned real meta never
1769
+ // overlaps a glyph — and when the line is full, the
1770
+ // reservation wraps and the meta drops a line, flush
1771
+ // right. The WhatsApp trick.
1772
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__meta poolse-message__meta--spacer", "aria-hidden": true, children: metaContent }),
1773
+ shouldTrim && /* @__PURE__ */ jsxRuntime.jsx(
1774
+ "button",
1775
+ {
1776
+ type: "button",
1777
+ className: "poolse-message__read-more",
1778
+ onClick: (e) => {
1779
+ e.stopPropagation();
1780
+ setExpanded(true);
1781
+ },
1782
+ children: "Read more"
1783
+ }
1784
+ ),
1785
+ !shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER && /* @__PURE__ */ jsxRuntime.jsx(
1786
+ "button",
1787
+ {
1788
+ type: "button",
1789
+ className: "poolse-message__read-more",
1790
+ onClick: (e) => {
1791
+ e.stopPropagation();
1792
+ setExpanded(false);
1793
+ },
1794
+ children: "Show less"
1795
+ }
1796
+ )
1797
+ ]
1739
1798
  }
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
- )
1799
+ ) : null;
1800
+ 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";
1801
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1802
+ body,
1803
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: metaClass, children: metaContent })
1804
+ ] });
1805
+ })()
1760
1806
  ] });
1761
1807
  }
1762
1808
  function isImageContentType(ct) {