@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.d.cts
CHANGED
|
@@ -149,6 +149,14 @@ interface MessageBubbleProps {
|
|
|
149
149
|
* `userResolver` config.
|
|
150
150
|
*/
|
|
151
151
|
showSenderName?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Slot for a "show actions" affordance — typically a chevron
|
|
154
|
+
* rendered by `<MessageRow>` that toggles the actions popover on
|
|
155
|
+
* desktop click. Positioned absolutely at the top-trailing corner
|
|
156
|
+
* inside the bubble so it overlays the message border; hidden by
|
|
157
|
+
* CSS until the row is hovered.
|
|
158
|
+
*/
|
|
159
|
+
actionsTrigger?: ReactNode;
|
|
152
160
|
}
|
|
153
161
|
/**
|
|
154
162
|
* One message bubble. The default renderer for `<ConversationView>` —
|
|
@@ -159,7 +167,7 @@ interface MessageBubbleProps {
|
|
|
159
167
|
* (coral for self, surface-with-border for others), matching the
|
|
160
168
|
* brand-kit chat showcase.
|
|
161
169
|
*/
|
|
162
|
-
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
170
|
+
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
163
171
|
|
|
164
172
|
interface EditableMessageBubbleProps {
|
|
165
173
|
message: Message;
|
package/dist/index.d.ts
CHANGED
|
@@ -149,6 +149,14 @@ interface MessageBubbleProps {
|
|
|
149
149
|
* `userResolver` config.
|
|
150
150
|
*/
|
|
151
151
|
showSenderName?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Slot for a "show actions" affordance — typically a chevron
|
|
154
|
+
* rendered by `<MessageRow>` that toggles the actions popover on
|
|
155
|
+
* desktop click. Positioned absolutely at the top-trailing corner
|
|
156
|
+
* inside the bubble so it overlays the message border; hidden by
|
|
157
|
+
* CSS until the row is hovered.
|
|
158
|
+
*/
|
|
159
|
+
actionsTrigger?: ReactNode;
|
|
152
160
|
}
|
|
153
161
|
/**
|
|
154
162
|
* One message bubble. The default renderer for `<ConversationView>` —
|
|
@@ -159,7 +167,7 @@ interface MessageBubbleProps {
|
|
|
159
167
|
* (coral for self, surface-with-border for others), matching the
|
|
160
168
|
* brand-kit chat showcase.
|
|
161
169
|
*/
|
|
162
|
-
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
170
|
+
declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
163
171
|
|
|
164
172
|
interface EditableMessageBubbleProps {
|
|
165
173
|
message: Message;
|
package/dist/index.js
CHANGED
|
@@ -898,7 +898,8 @@ function MessageBubble({
|
|
|
898
898
|
groupPosition = "standalone",
|
|
899
899
|
maxBodyLength = 0,
|
|
900
900
|
markdown = false,
|
|
901
|
-
showSenderName = false
|
|
901
|
+
showSenderName = false,
|
|
902
|
+
actionsTrigger
|
|
902
903
|
}) {
|
|
903
904
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
904
905
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -924,6 +925,7 @@ function MessageBubble({
|
|
|
924
925
|
}) : "";
|
|
925
926
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
926
927
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
928
|
+
actionsTrigger,
|
|
927
929
|
renderSenderName && /* @__PURE__ */ jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }),
|
|
928
930
|
showQuoteCard === "full" && /* @__PURE__ */ jsx(
|
|
929
931
|
QuotedCard,
|
|
@@ -1344,6 +1346,12 @@ function MessageRow({
|
|
|
1344
1346
|
document.addEventListener("pointerdown", onDown);
|
|
1345
1347
|
return () => document.removeEventListener("pointerdown", onDown);
|
|
1346
1348
|
}, [actionsOpen]);
|
|
1349
|
+
const onRowClick = (e) => {
|
|
1350
|
+
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
1351
|
+
const target = e.target;
|
|
1352
|
+
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
1353
|
+
setActionsOpen((o) => !o);
|
|
1354
|
+
};
|
|
1347
1355
|
return /* @__PURE__ */ jsxs(
|
|
1348
1356
|
"div",
|
|
1349
1357
|
{
|
|
@@ -1359,6 +1367,8 @@ function MessageRow({
|
|
|
1359
1367
|
].filter(Boolean).join(" "),
|
|
1360
1368
|
"data-message-id": msg.id,
|
|
1361
1369
|
"data-actions-open": actionsOpen || void 0,
|
|
1370
|
+
"data-avatar": showAvatar && !isSelf ? true : void 0,
|
|
1371
|
+
onClick: onRowClick,
|
|
1362
1372
|
children: [
|
|
1363
1373
|
editing ? /* @__PURE__ */ jsx(
|
|
1364
1374
|
EditableMessageBubble,
|
|
@@ -1389,7 +1399,23 @@ function MessageRow({
|
|
|
1389
1399
|
showSenderName,
|
|
1390
1400
|
...readState ? { readState } : {},
|
|
1391
1401
|
...labelFor ? { labelFor } : {},
|
|
1392
|
-
...onQuotedClick ? { onQuotedClick } : {}
|
|
1402
|
+
...onQuotedClick ? { onQuotedClick } : {},
|
|
1403
|
+
...showActions ? {
|
|
1404
|
+
actionsTrigger: /* @__PURE__ */ jsx(
|
|
1405
|
+
"button",
|
|
1406
|
+
{
|
|
1407
|
+
type: "button",
|
|
1408
|
+
className: "poolse-message__chevron",
|
|
1409
|
+
"aria-label": "Show message actions",
|
|
1410
|
+
"aria-expanded": actionsOpen,
|
|
1411
|
+
onClick: (e) => {
|
|
1412
|
+
e.stopPropagation();
|
|
1413
|
+
setActionsOpen((o) => !o);
|
|
1414
|
+
},
|
|
1415
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "chevron-down", size: 14, label: null })
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
} : {}
|
|
1393
1419
|
}
|
|
1394
1420
|
)
|
|
1395
1421
|
}
|
|
@@ -1421,17 +1447,6 @@ function MessageRow({
|
|
|
1421
1447
|
]
|
|
1422
1448
|
}
|
|
1423
1449
|
),
|
|
1424
|
-
showActions && /* @__PURE__ */ jsx(
|
|
1425
|
-
"button",
|
|
1426
|
-
{
|
|
1427
|
-
type: "button",
|
|
1428
|
-
className: "poolse-message-row__more",
|
|
1429
|
-
"aria-label": "Show message actions",
|
|
1430
|
-
"aria-expanded": actionsOpen,
|
|
1431
|
-
onClick: () => setActionsOpen((o) => !o),
|
|
1432
|
-
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "more-h", size: 16, label: null })
|
|
1433
|
-
}
|
|
1434
|
-
),
|
|
1435
1450
|
showActions && /* @__PURE__ */ jsx(
|
|
1436
1451
|
"div",
|
|
1437
1452
|
{
|
|
@@ -1578,7 +1593,18 @@ function ThreadView({
|
|
|
1578
1593
|
);
|
|
1579
1594
|
}
|
|
1580
1595
|
function defaultRenderReply(msg, currentUserId) {
|
|
1581
|
-
return /* @__PURE__ */ jsx(
|
|
1596
|
+
return /* @__PURE__ */ jsx(
|
|
1597
|
+
MessageRow,
|
|
1598
|
+
{
|
|
1599
|
+
msg,
|
|
1600
|
+
meId: currentUserId,
|
|
1601
|
+
reactions: true,
|
|
1602
|
+
attachments: true,
|
|
1603
|
+
actions: true,
|
|
1604
|
+
threads: false,
|
|
1605
|
+
quotations: false
|
|
1606
|
+
}
|
|
1607
|
+
);
|
|
1582
1608
|
}
|
|
1583
1609
|
function TypingIndicator({ typing, labelFor }) {
|
|
1584
1610
|
const ids = Array.from(typing);
|
|
@@ -1727,8 +1753,32 @@ function ConversationView({
|
|
|
1727
1753
|
const listRef = useRef(null);
|
|
1728
1754
|
const lastMessageIdRef = useRef(null);
|
|
1729
1755
|
const bottomSentinelRef = useRef(null);
|
|
1756
|
+
const topSentinelRef = useRef(null);
|
|
1757
|
+
const loadingMoreRef = useRef(false);
|
|
1730
1758
|
const [atBottom, setAtBottom] = useState(true);
|
|
1731
1759
|
const [newCountWhileAway, setNewCountWhileAway] = useState(0);
|
|
1760
|
+
useEffect(() => {
|
|
1761
|
+
const sentinel = topSentinelRef.current;
|
|
1762
|
+
const root = listRef.current;
|
|
1763
|
+
if (!sentinel || !root) return;
|
|
1764
|
+
if (!hasMore) return;
|
|
1765
|
+
const io = new IntersectionObserver(
|
|
1766
|
+
(entries) => {
|
|
1767
|
+
const entry = entries[0];
|
|
1768
|
+
if (!entry?.isIntersecting) return;
|
|
1769
|
+
if (loadingMoreRef.current) return;
|
|
1770
|
+
loadingMoreRef.current = true;
|
|
1771
|
+
void Promise.resolve(loadMore()).finally(() => {
|
|
1772
|
+
loadingMoreRef.current = false;
|
|
1773
|
+
});
|
|
1774
|
+
},
|
|
1775
|
+
// Fire when sentinel is within ~400px above the viewport — the
|
|
1776
|
+
// user is approaching the top of loaded history, fetch ahead.
|
|
1777
|
+
{ root, rootMargin: "400px 0px 0px 0px", threshold: 0 }
|
|
1778
|
+
);
|
|
1779
|
+
io.observe(sentinel);
|
|
1780
|
+
return () => io.disconnect();
|
|
1781
|
+
}, [hasMore, loadMore]);
|
|
1732
1782
|
useEffect(() => {
|
|
1733
1783
|
const el = bottomSentinelRef.current;
|
|
1734
1784
|
if (!el) return;
|
|
@@ -1931,7 +1981,7 @@ function ConversationView({
|
|
|
1931
1981
|
"aria-live": "polite",
|
|
1932
1982
|
"aria-relevant": "additions",
|
|
1933
1983
|
children: [
|
|
1934
|
-
hasMore &&
|
|
1984
|
+
hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
1935
1985
|
loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
|
|
1936
1986
|
if (renderMessage) {
|
|
1937
1987
|
return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|