@poolse/react-ui 3.2.0 → 3.3.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 +24 -0
- package/README.md +10 -1
- package/dist/index.cjs +107 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -90
- package/dist/index.d.ts +129 -90
- package/dist/index.js +107 -16
- package/dist/index.js.map +1 -1
- package/dist/styles.css +27 -0
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1635,6 +1635,7 @@ function MessageBubble({
|
|
|
1635
1635
|
maxBodyLength = 0,
|
|
1636
1636
|
markdown = false,
|
|
1637
1637
|
showSenderName = false,
|
|
1638
|
+
onSenderPress,
|
|
1638
1639
|
actionsTrigger,
|
|
1639
1640
|
showAttachments = true
|
|
1640
1641
|
}) {
|
|
@@ -1678,7 +1679,16 @@ function MessageBubble({
|
|
|
1678
1679
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
1679
1680
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1680
1681
|
actionsTrigger,
|
|
1681
|
-
renderSenderName && /* @__PURE__ */ jsx(
|
|
1682
|
+
renderSenderName && (onSenderPress ? /* @__PURE__ */ jsx(
|
|
1683
|
+
"button",
|
|
1684
|
+
{
|
|
1685
|
+
type: "button",
|
|
1686
|
+
className: "poolse-message__sender poolse-message__sender--button",
|
|
1687
|
+
style: { color: senderColorHex },
|
|
1688
|
+
onClick: onSenderPress,
|
|
1689
|
+
children: senderName
|
|
1690
|
+
}
|
|
1691
|
+
) : /* @__PURE__ */ jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName })),
|
|
1682
1692
|
showQuoteCard === "full" && /* @__PURE__ */ jsx(
|
|
1683
1693
|
QuotedCard,
|
|
1684
1694
|
{
|
|
@@ -2135,12 +2145,20 @@ function BubbleMessageRow({
|
|
|
2135
2145
|
maxBodyLength = 0,
|
|
2136
2146
|
markdown = false,
|
|
2137
2147
|
showSenderName = false,
|
|
2138
|
-
showAvatar = false
|
|
2148
|
+
showAvatar = false,
|
|
2149
|
+
onSenderPress,
|
|
2150
|
+
onAvatarPress
|
|
2139
2151
|
}) {
|
|
2140
|
-
const { profile: senderProfile } = useUser(msg.
|
|
2141
|
-
const senderFallbackName = msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown";
|
|
2152
|
+
const { profile: senderProfile } = useUser(msg.sender_external_id);
|
|
2153
|
+
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
2142
2154
|
const senderName = senderProfile?.displayName ?? senderFallbackName;
|
|
2143
2155
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
2156
|
+
const sender = {
|
|
2157
|
+
userId: msg.sender_id,
|
|
2158
|
+
externalId: msg.sender_external_id,
|
|
2159
|
+
displayName: senderName,
|
|
2160
|
+
avatarUrl: senderProfile?.avatarUrl ?? null
|
|
2161
|
+
};
|
|
2144
2162
|
const reactionsHook = useReactions(reactions ? msg.id : "", {
|
|
2145
2163
|
conversationId: msg.conversation_id,
|
|
2146
2164
|
initialReactions: msg.reactions,
|
|
@@ -2207,6 +2225,7 @@ function BubbleMessageRow({
|
|
|
2207
2225
|
groupPosition,
|
|
2208
2226
|
senderName,
|
|
2209
2227
|
avatarUrl: senderProfile?.avatarUrl ?? null,
|
|
2228
|
+
...onAvatarPress ? { onAvatarPress: () => onAvatarPress(sender) } : {},
|
|
2210
2229
|
children: /* @__PURE__ */ jsx(
|
|
2211
2230
|
MessageBubble,
|
|
2212
2231
|
{
|
|
@@ -2216,6 +2235,7 @@ function BubbleMessageRow({
|
|
|
2216
2235
|
maxBodyLength,
|
|
2217
2236
|
markdown,
|
|
2218
2237
|
showSenderName,
|
|
2238
|
+
...onSenderPress ? { onSenderPress: () => onSenderPress(sender) } : {},
|
|
2219
2239
|
showAttachments: attachments,
|
|
2220
2240
|
...readState ? { readState } : {},
|
|
2221
2241
|
...labelFor ? { labelFor } : {},
|
|
@@ -2331,12 +2351,22 @@ function BubbleWithAvatar({
|
|
|
2331
2351
|
groupPosition,
|
|
2332
2352
|
senderName,
|
|
2333
2353
|
avatarUrl,
|
|
2354
|
+
onAvatarPress,
|
|
2334
2355
|
children
|
|
2335
2356
|
}) {
|
|
2336
2357
|
if (isSelf || !showAvatar) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2337
2358
|
const isLastOfCluster = groupPosition === "last" || groupPosition === "standalone";
|
|
2338
2359
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-bubble-shell", children: [
|
|
2339
|
-
/* @__PURE__ */ jsx("div", { className: "poolse-bubble-shell__avatar", children: isLastOfCluster ? /* @__PURE__ */ jsx(
|
|
2360
|
+
/* @__PURE__ */ jsx("div", { className: "poolse-bubble-shell__avatar", children: !isLastOfCluster ? null : onAvatarPress ? /* @__PURE__ */ jsx(
|
|
2361
|
+
"button",
|
|
2362
|
+
{
|
|
2363
|
+
type: "button",
|
|
2364
|
+
className: "poolse-bubble-shell__avatar-button",
|
|
2365
|
+
"aria-label": senderName,
|
|
2366
|
+
onClick: onAvatarPress,
|
|
2367
|
+
children: /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name: senderName, size: "sm" })
|
|
2368
|
+
}
|
|
2369
|
+
) : /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name: senderName, size: "sm" }) }),
|
|
2340
2370
|
children
|
|
2341
2371
|
] });
|
|
2342
2372
|
}
|
|
@@ -2548,11 +2578,20 @@ function ConversationView({
|
|
|
2548
2578
|
senderLabels = "auto",
|
|
2549
2579
|
avatars = "auto",
|
|
2550
2580
|
onMarkedRead,
|
|
2581
|
+
focusMessageId = null,
|
|
2582
|
+
onFocusMessageNotFound,
|
|
2583
|
+
onSenderPress,
|
|
2584
|
+
onAvatarPress,
|
|
2585
|
+
composer = TRUE,
|
|
2586
|
+
readOnly = false,
|
|
2551
2587
|
onCallBack,
|
|
2552
2588
|
onJoinCall,
|
|
2553
2589
|
currentCallId = null
|
|
2554
2590
|
}) {
|
|
2555
2591
|
usePoolseFonts(loadFonts);
|
|
2592
|
+
const showComposer = composer && !readOnly;
|
|
2593
|
+
const canQuote = quotations && showComposer;
|
|
2594
|
+
const canDrop = attachments && showComposer;
|
|
2556
2595
|
const { me } = useMe();
|
|
2557
2596
|
const {
|
|
2558
2597
|
messages,
|
|
@@ -2560,6 +2599,7 @@ function ConversationView({
|
|
|
2560
2599
|
error,
|
|
2561
2600
|
hasMore,
|
|
2562
2601
|
loadMore,
|
|
2602
|
+
loadUntil,
|
|
2563
2603
|
send,
|
|
2564
2604
|
edit,
|
|
2565
2605
|
delete: deleteMsg,
|
|
@@ -2673,6 +2713,49 @@ function ConversationView({
|
|
|
2673
2713
|
() => messages.filter((m) => isMessageVisibleTo(m, meIdForFeed)),
|
|
2674
2714
|
[messages, meIdForFeed]
|
|
2675
2715
|
);
|
|
2716
|
+
const [pendingFocusId, setPendingFocusId] = useState(null);
|
|
2717
|
+
const [focusMissing, setFocusMissing] = useState(false);
|
|
2718
|
+
const onFocusNotFoundRef = useRef(onFocusMessageNotFound);
|
|
2719
|
+
onFocusNotFoundRef.current = onFocusMessageNotFound;
|
|
2720
|
+
const conversationIdRef = useRef(conversationId);
|
|
2721
|
+
conversationIdRef.current = conversationId;
|
|
2722
|
+
const focusMiss = useCallback((id) => {
|
|
2723
|
+
setFocusMissing(true);
|
|
2724
|
+
onFocusNotFoundRef.current?.(id);
|
|
2725
|
+
}, []);
|
|
2726
|
+
useEffect(() => {
|
|
2727
|
+
setPendingFocusId(null);
|
|
2728
|
+
setFocusMissing(false);
|
|
2729
|
+
if (!focusMessageId || loading) return;
|
|
2730
|
+
const forConversation = conversationId;
|
|
2731
|
+
let current = true;
|
|
2732
|
+
loadUntil(focusMessageId).then((found) => {
|
|
2733
|
+
if (!current || conversationIdRef.current !== forConversation) return;
|
|
2734
|
+
if (found) setPendingFocusId(focusMessageId);
|
|
2735
|
+
else focusMiss(focusMessageId);
|
|
2736
|
+
}).catch(() => {
|
|
2737
|
+
if (current) focusMiss(focusMessageId);
|
|
2738
|
+
});
|
|
2739
|
+
return () => {
|
|
2740
|
+
current = false;
|
|
2741
|
+
};
|
|
2742
|
+
}, [focusMessageId, conversationId, loading, loadUntil, focusMiss]);
|
|
2743
|
+
useEffect(() => {
|
|
2744
|
+
if (!pendingFocusId) return;
|
|
2745
|
+
const root = listRef.current;
|
|
2746
|
+
const el = root?.querySelector(`[data-message-id="${pendingFocusId}"]`);
|
|
2747
|
+
setPendingFocusId(null);
|
|
2748
|
+
if (!(el instanceof HTMLElement)) {
|
|
2749
|
+
focusMiss(pendingFocusId);
|
|
2750
|
+
return;
|
|
2751
|
+
}
|
|
2752
|
+
highlightRow(el);
|
|
2753
|
+
}, [pendingFocusId, visibleMessages, focusMiss]);
|
|
2754
|
+
useEffect(() => {
|
|
2755
|
+
if (!focusMissing) return;
|
|
2756
|
+
const t = setTimeout(() => setFocusMissing(false), 4e3);
|
|
2757
|
+
return () => clearTimeout(t);
|
|
2758
|
+
}, [focusMissing]);
|
|
2676
2759
|
const receiptsVisible = receiptsOf(me).visible;
|
|
2677
2760
|
const showReadState = readReceipts && receiptsVisible;
|
|
2678
2761
|
const maxReadByOthers = useMemo(() => {
|
|
@@ -2709,33 +2792,31 @@ function ConversationView({
|
|
|
2709
2792
|
if (!root) return;
|
|
2710
2793
|
const el = root.querySelector(`[data-message-id="${id}"]`);
|
|
2711
2794
|
if (!(el instanceof HTMLElement)) return;
|
|
2712
|
-
el
|
|
2713
|
-
el.classList.add("poolse-message-row--highlight");
|
|
2714
|
-
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
2795
|
+
highlightRow(el);
|
|
2715
2796
|
};
|
|
2716
2797
|
const composerRef = useRef(null);
|
|
2717
2798
|
const [dragActive, setDragActive] = useState(false);
|
|
2718
2799
|
const dragDepthRef = useRef(0);
|
|
2719
2800
|
const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
|
|
2720
2801
|
const onDragEnter = (e) => {
|
|
2721
|
-
if (!
|
|
2802
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2722
2803
|
e.preventDefault();
|
|
2723
2804
|
dragDepthRef.current += 1;
|
|
2724
2805
|
setDragActive(true);
|
|
2725
2806
|
};
|
|
2726
2807
|
const onDragOver = (e) => {
|
|
2727
|
-
if (!
|
|
2808
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2728
2809
|
e.preventDefault();
|
|
2729
2810
|
if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
|
|
2730
2811
|
};
|
|
2731
2812
|
const onDragLeave = (e) => {
|
|
2732
|
-
if (!
|
|
2813
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2733
2814
|
e.preventDefault();
|
|
2734
2815
|
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
|
|
2735
2816
|
if (dragDepthRef.current === 0) setDragActive(false);
|
|
2736
2817
|
};
|
|
2737
2818
|
const onDrop = (e) => {
|
|
2738
|
-
if (!
|
|
2819
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2739
2820
|
e.preventDefault();
|
|
2740
2821
|
dragDepthRef.current = 0;
|
|
2741
2822
|
setDragActive(false);
|
|
@@ -2763,7 +2844,7 @@ function ConversationView({
|
|
|
2763
2844
|
onTyping: signalTyping,
|
|
2764
2845
|
attachments,
|
|
2765
2846
|
...labelFor ? { labelFor } : {},
|
|
2766
|
-
...
|
|
2847
|
+
...canQuote ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
2767
2848
|
}
|
|
2768
2849
|
) : /* @__PURE__ */ jsx(
|
|
2769
2850
|
MessageComposer,
|
|
@@ -2773,7 +2854,7 @@ function ConversationView({
|
|
|
2773
2854
|
onTyping: signalTyping,
|
|
2774
2855
|
attachments,
|
|
2775
2856
|
...labelFor ? { labelFor } : {},
|
|
2776
|
-
...
|
|
2857
|
+
...canQuote ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
2777
2858
|
}
|
|
2778
2859
|
);
|
|
2779
2860
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
@@ -2809,6 +2890,7 @@ function ConversationView({
|
|
|
2809
2890
|
]
|
|
2810
2891
|
}
|
|
2811
2892
|
),
|
|
2893
|
+
focusMissing && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__status", role: "status", "aria-live": "polite", children: "That message isn't available." }),
|
|
2812
2894
|
/* @__PURE__ */ jsxs(
|
|
2813
2895
|
"div",
|
|
2814
2896
|
{
|
|
@@ -2856,12 +2938,14 @@ function ConversationView({
|
|
|
2856
2938
|
attachments,
|
|
2857
2939
|
actions,
|
|
2858
2940
|
threads,
|
|
2859
|
-
quotations,
|
|
2941
|
+
quotations: canQuote,
|
|
2860
2942
|
groupPosition,
|
|
2861
2943
|
maxBodyLength,
|
|
2862
2944
|
markdown,
|
|
2863
2945
|
showSenderName: showSenderLabelsResolved,
|
|
2864
2946
|
showAvatar: showAvatarsResolved,
|
|
2947
|
+
...onSenderPress ? { onSenderPress } : {},
|
|
2948
|
+
...onAvatarPress ? { onAvatarPress } : {},
|
|
2865
2949
|
...readState ? { readState } : {},
|
|
2866
2950
|
...labelFor ? { labelFor } : {},
|
|
2867
2951
|
editing: editingId === msg.id,
|
|
@@ -2926,7 +3010,7 @@ function ConversationView({
|
|
|
2926
3010
|
}
|
|
2927
3011
|
),
|
|
2928
3012
|
/* @__PURE__ */ jsx(TypingIndicator, { typing, ...labelFor ? { labelFor } : {} }),
|
|
2929
|
-
/* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-row", children: /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer }) }),
|
|
3013
|
+
showComposer && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-row", children: /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer }) }),
|
|
2930
3014
|
dragActive && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
|
|
2931
3015
|
/* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
|
|
2932
3016
|
/* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
|
|
@@ -2945,6 +3029,13 @@ function ConversationView({
|
|
|
2945
3029
|
) })
|
|
2946
3030
|
] });
|
|
2947
3031
|
}
|
|
3032
|
+
function highlightRow(el) {
|
|
3033
|
+
if (typeof el.scrollIntoView === "function") {
|
|
3034
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
3035
|
+
}
|
|
3036
|
+
el.classList.add("poolse-message-row--highlight");
|
|
3037
|
+
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
3038
|
+
}
|
|
2948
3039
|
function JoinBanner({
|
|
2949
3040
|
conversationId,
|
|
2950
3041
|
meId,
|