@poolse/react-ui 1.0.1 → 1.0.3
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 +65 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +65 -15
- package/dist/index.js.map +1 -1
- package/dist/styles.css +78 -38
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -905,7 +905,8 @@ function MessageBubble({
|
|
|
905
905
|
groupPosition = "standalone",
|
|
906
906
|
maxBodyLength = 0,
|
|
907
907
|
markdown = false,
|
|
908
|
-
showSenderName = false
|
|
908
|
+
showSenderName = false,
|
|
909
|
+
actionsTrigger
|
|
909
910
|
}) {
|
|
910
911
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
911
912
|
const [expanded, setExpanded] = react.useState(false);
|
|
@@ -931,6 +932,7 @@ function MessageBubble({
|
|
|
931
932
|
}) : "";
|
|
932
933
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
933
934
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
935
|
+
actionsTrigger,
|
|
934
936
|
renderSenderName && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }),
|
|
935
937
|
showQuoteCard === "full" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
936
938
|
QuotedCard,
|
|
@@ -1351,6 +1353,12 @@ function MessageRow({
|
|
|
1351
1353
|
document.addEventListener("pointerdown", onDown);
|
|
1352
1354
|
return () => document.removeEventListener("pointerdown", onDown);
|
|
1353
1355
|
}, [actionsOpen]);
|
|
1356
|
+
const onRowClick = (e) => {
|
|
1357
|
+
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
1358
|
+
const target = e.target;
|
|
1359
|
+
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
1360
|
+
setActionsOpen((o) => !o);
|
|
1361
|
+
};
|
|
1354
1362
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1355
1363
|
"div",
|
|
1356
1364
|
{
|
|
@@ -1366,6 +1374,8 @@ function MessageRow({
|
|
|
1366
1374
|
].filter(Boolean).join(" "),
|
|
1367
1375
|
"data-message-id": msg.id,
|
|
1368
1376
|
"data-actions-open": actionsOpen || void 0,
|
|
1377
|
+
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
1378
|
+
onClick: onRowClick,
|
|
1369
1379
|
children: [
|
|
1370
1380
|
editing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1371
1381
|
EditableMessageBubble,
|
|
@@ -1396,7 +1406,23 @@ function MessageRow({
|
|
|
1396
1406
|
showSenderName,
|
|
1397
1407
|
...readState ? { readState } : {},
|
|
1398
1408
|
...labelFor ? { labelFor } : {},
|
|
1399
|
-
...onQuotedClick ? { onQuotedClick } : {}
|
|
1409
|
+
...onQuotedClick ? { onQuotedClick } : {},
|
|
1410
|
+
...showActions ? {
|
|
1411
|
+
actionsTrigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1412
|
+
"button",
|
|
1413
|
+
{
|
|
1414
|
+
type: "button",
|
|
1415
|
+
className: "poolse-message__chevron",
|
|
1416
|
+
"aria-label": "Show message actions",
|
|
1417
|
+
"aria-expanded": actionsOpen,
|
|
1418
|
+
onClick: (e) => {
|
|
1419
|
+
e.stopPropagation();
|
|
1420
|
+
setActionsOpen((o) => !o);
|
|
1421
|
+
},
|
|
1422
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "chevron-down", size: 14, label: null })
|
|
1423
|
+
}
|
|
1424
|
+
)
|
|
1425
|
+
} : {}
|
|
1400
1426
|
}
|
|
1401
1427
|
)
|
|
1402
1428
|
}
|
|
@@ -1428,17 +1454,6 @@ function MessageRow({
|
|
|
1428
1454
|
]
|
|
1429
1455
|
}
|
|
1430
1456
|
),
|
|
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
|
-
),
|
|
1442
1457
|
showActions && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1443
1458
|
"div",
|
|
1444
1459
|
{
|
|
@@ -1585,7 +1600,18 @@ function ThreadView({
|
|
|
1585
1600
|
);
|
|
1586
1601
|
}
|
|
1587
1602
|
function defaultRenderReply(msg, currentUserId) {
|
|
1588
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1603
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1604
|
+
MessageRow,
|
|
1605
|
+
{
|
|
1606
|
+
msg,
|
|
1607
|
+
meId: currentUserId,
|
|
1608
|
+
reactions: true,
|
|
1609
|
+
attachments: true,
|
|
1610
|
+
actions: true,
|
|
1611
|
+
threads: false,
|
|
1612
|
+
quotations: false
|
|
1613
|
+
}
|
|
1614
|
+
);
|
|
1589
1615
|
}
|
|
1590
1616
|
function TypingIndicator({ typing, labelFor }) {
|
|
1591
1617
|
const ids = Array.from(typing);
|
|
@@ -1734,8 +1760,32 @@ function ConversationView({
|
|
|
1734
1760
|
const listRef = react.useRef(null);
|
|
1735
1761
|
const lastMessageIdRef = react.useRef(null);
|
|
1736
1762
|
const bottomSentinelRef = react.useRef(null);
|
|
1763
|
+
const topSentinelRef = react.useRef(null);
|
|
1764
|
+
const loadingMoreRef = react.useRef(false);
|
|
1737
1765
|
const [atBottom, setAtBottom] = react.useState(true);
|
|
1738
1766
|
const [newCountWhileAway, setNewCountWhileAway] = react.useState(0);
|
|
1767
|
+
react.useEffect(() => {
|
|
1768
|
+
const sentinel = topSentinelRef.current;
|
|
1769
|
+
const root = listRef.current;
|
|
1770
|
+
if (!sentinel || !root) return;
|
|
1771
|
+
if (!hasMore) return;
|
|
1772
|
+
const io = new IntersectionObserver(
|
|
1773
|
+
(entries) => {
|
|
1774
|
+
const entry = entries[0];
|
|
1775
|
+
if (!entry?.isIntersecting) return;
|
|
1776
|
+
if (loadingMoreRef.current) return;
|
|
1777
|
+
loadingMoreRef.current = true;
|
|
1778
|
+
void Promise.resolve(loadMore()).finally(() => {
|
|
1779
|
+
loadingMoreRef.current = false;
|
|
1780
|
+
});
|
|
1781
|
+
},
|
|
1782
|
+
// Fire when sentinel is within ~400px above the viewport — the
|
|
1783
|
+
// user is approaching the top of loaded history, fetch ahead.
|
|
1784
|
+
{ root, rootMargin: "400px 0px 0px 0px", threshold: 0 }
|
|
1785
|
+
);
|
|
1786
|
+
io.observe(sentinel);
|
|
1787
|
+
return () => io.disconnect();
|
|
1788
|
+
}, [hasMore, loadMore]);
|
|
1739
1789
|
react.useEffect(() => {
|
|
1740
1790
|
const el = bottomSentinelRef.current;
|
|
1741
1791
|
if (!el) return;
|
|
@@ -1938,7 +1988,7 @@ function ConversationView({
|
|
|
1938
1988
|
"aria-live": "polite",
|
|
1939
1989
|
"aria-relevant": "additions",
|
|
1940
1990
|
children: [
|
|
1941
|
-
hasMore &&
|
|
1991
|
+
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
1942
1992
|
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
1993
|
if (renderMessage) {
|
|
1944
1994
|
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|