@poolse/react-ui 3.2.0 → 3.4.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 +73 -0
- package/README.md +53 -2
- package/dist/index.cjs +757 -178
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +274 -97
- package/dist/index.d.ts +274 -97
- package/dist/index.js +738 -181
- package/dist/index.js.map +1 -1
- package/dist/styles.css +415 -7
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { forwardRef, useState, useRef, useCallback, useImperativeHandle, useEffect, useMemo, Fragment as Fragment$1 } from 'react';
|
|
2
|
+
import { forwardRef, useState, useRef, useCallback, useImperativeHandle, useEffect, useMemo, createContext, Fragment as Fragment$1, useContext } from 'react';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { useMembers, useAttachmentUpload, useMe, useConversations, useUser, useConversation, usePresence, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, receiptsOf, computeGroupPosition, sameDay, formatDayLabel,
|
|
4
|
+
import { useMembers, useAttachmentUpload, useMe, useConversations, useUser, useConversation, usePresence, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, receiptsOf, computeGroupPosition, sameDay, formatDayLabel, formatCallLogPreview, useLiveCall, canEditOwnMessage, callLogDisplayFor, useThread, useReactions, useAttachmentUrl } from '@poolse/react';
|
|
5
5
|
import ReactMarkdown from 'react-markdown';
|
|
6
6
|
import remarkGfm from 'remark-gfm';
|
|
7
|
+
import { resolveTheme, tokensToCssVariables } from '@poolse/theme';
|
|
8
|
+
export { BUILT_IN_THEME_IDS, DEFAULT_THEME_ID, createTheme, decodeTheme, encodeTheme } from '@poolse/theme';
|
|
7
9
|
|
|
8
10
|
// src/CallVideoGrid.tsx
|
|
9
11
|
|
|
@@ -744,6 +746,31 @@ function PoolseFonts() {
|
|
|
744
746
|
usePoolseFonts(true);
|
|
745
747
|
return null;
|
|
746
748
|
}
|
|
749
|
+
|
|
750
|
+
// src/layout.ts
|
|
751
|
+
function formatMessageTime(iso, format) {
|
|
752
|
+
if (!iso) return "";
|
|
753
|
+
const date = new Date(iso);
|
|
754
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
755
|
+
if (typeof format === "function") return format(date);
|
|
756
|
+
if (format === "12h") {
|
|
757
|
+
return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit", hour12: true });
|
|
758
|
+
}
|
|
759
|
+
if (format === "24h") {
|
|
760
|
+
return date.toLocaleTimeString(void 0, {
|
|
761
|
+
hour: "2-digit",
|
|
762
|
+
minute: "2-digit",
|
|
763
|
+
hourCycle: "h23"
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
return date.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
767
|
+
}
|
|
768
|
+
function mentionsViewer(msg, meId) {
|
|
769
|
+
return meId !== null && msg.sender_id !== meId && (msg.mentions ?? []).includes(meId);
|
|
770
|
+
}
|
|
771
|
+
function renderSlot(slot, ctx, children) {
|
|
772
|
+
return slot && ctx ? slot({ ...ctx, children }) : children;
|
|
773
|
+
}
|
|
747
774
|
function LiveCallBanner({ call, inCall, onJoin }) {
|
|
748
775
|
const what = call.kind === "room" ? call.media === "video" ? "Video room" : "Voice room" : call.media === "video" ? "Video call in progress" : "Voice call in progress";
|
|
749
776
|
const who = inCall > 0 ? `${inCall} ${call.kind === "room" ? "in the room" : "on the call"}` : call.kind === "room" ? "Starting" : "Ringing";
|
|
@@ -1635,8 +1662,12 @@ function MessageBubble({
|
|
|
1635
1662
|
maxBodyLength = 0,
|
|
1636
1663
|
markdown = false,
|
|
1637
1664
|
showSenderName = false,
|
|
1665
|
+
onSenderPress,
|
|
1638
1666
|
actionsTrigger,
|
|
1639
|
-
showAttachments = true
|
|
1667
|
+
showAttachments = true,
|
|
1668
|
+
timeFormat,
|
|
1669
|
+
slots,
|
|
1670
|
+
slotContext
|
|
1640
1671
|
}) {
|
|
1641
1672
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
1642
1673
|
const [expanded, setExpanded] = useState(false);
|
|
@@ -1647,8 +1678,8 @@ function MessageBubble({
|
|
|
1647
1678
|
const senderColorHex = senderColorKey ? userColor(senderColorKey) : "currentColor";
|
|
1648
1679
|
const renderSenderName = showSenderName && !isSelf && (groupPosition === "first" || groupPosition === "standalone");
|
|
1649
1680
|
const rawBody = message.body ?? "";
|
|
1650
|
-
const
|
|
1651
|
-
const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength +
|
|
1681
|
+
const TRIM_BUFFER2 = 40;
|
|
1682
|
+
const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength + TRIM_BUFFER2;
|
|
1652
1683
|
const displayBody = shouldTrim ? rawBody.slice(0, maxBodyLength).trimEnd() + "\u2026" : rawBody;
|
|
1653
1684
|
const attachmentList = showAttachments && !message.deleted_at && Array.isArray(message.attachments) ? message.attachments : [];
|
|
1654
1685
|
const imageAttachments = attachmentList.filter((a) => isImageContentType(a.content_type));
|
|
@@ -1657,7 +1688,7 @@ function MessageBubble({
|
|
|
1657
1688
|
const hasVisibleBody = !message.deleted_at && rawBody.length > 0;
|
|
1658
1689
|
const metaOverlay = hasAnyAttachment && imageAttachments.length > 0 && !hasVisibleBody && fileAttachments.length === 0;
|
|
1659
1690
|
const jumboCount = hasVisibleBody && !hasAnyAttachment && !message.quoted_message_id ? emojiOnlyCount(rawBody) : 0;
|
|
1660
|
-
const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength +
|
|
1691
|
+
const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength + TRIM_BUFFER2;
|
|
1661
1692
|
const inlineMeta = hasVisibleBody && jumboCount === 0 && !trimToggleVisible && (!markdown || !hasMarkdown(displayBody));
|
|
1662
1693
|
const className = [
|
|
1663
1694
|
"poolse-message",
|
|
@@ -1671,14 +1702,24 @@ function MessageBubble({
|
|
|
1671
1702
|
metaOverlay ? "poolse-message--media-only" : "",
|
|
1672
1703
|
jumboCount > 0 ? "poolse-message--jumbo" : ""
|
|
1673
1704
|
].filter(Boolean).join(" ");
|
|
1674
|
-
const time =
|
|
1675
|
-
hour: "2-digit",
|
|
1676
|
-
minute: "2-digit"
|
|
1677
|
-
}) : "";
|
|
1705
|
+
const time = formatMessageTime(message.inserted_at, timeFormat);
|
|
1678
1706
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
1679
1707
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
1680
1708
|
actionsTrigger,
|
|
1681
|
-
|
|
1709
|
+
renderSlot(
|
|
1710
|
+
slots?.header,
|
|
1711
|
+
slotContext,
|
|
1712
|
+
renderSenderName ? onSenderPress ? /* @__PURE__ */ jsx(
|
|
1713
|
+
"button",
|
|
1714
|
+
{
|
|
1715
|
+
type: "button",
|
|
1716
|
+
className: "poolse-message__sender poolse-message__sender--button",
|
|
1717
|
+
style: { color: senderColorHex },
|
|
1718
|
+
onClick: onSenderPress,
|
|
1719
|
+
children: senderName
|
|
1720
|
+
}
|
|
1721
|
+
) : /* @__PURE__ */ jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }) : null
|
|
1722
|
+
),
|
|
1682
1723
|
showQuoteCard === "full" && /* @__PURE__ */ jsx(
|
|
1683
1724
|
QuotedCard,
|
|
1684
1725
|
{
|
|
@@ -1689,8 +1730,14 @@ function MessageBubble({
|
|
|
1689
1730
|
}
|
|
1690
1731
|
),
|
|
1691
1732
|
showQuoteCard === "placeholder" && /* @__PURE__ */ jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
|
|
1692
|
-
|
|
1693
|
-
|
|
1733
|
+
renderSlot(
|
|
1734
|
+
slots?.attachments,
|
|
1735
|
+
slotContext,
|
|
1736
|
+
hasAnyAttachment ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1737
|
+
imageAttachments.length > 0 && /* @__PURE__ */ jsx(ImageMosaic, { images: imageAttachments }),
|
|
1738
|
+
fileAttachments.length > 0 && /* @__PURE__ */ jsx("div", { className: "poolse-message__files", children: fileAttachments.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) })
|
|
1739
|
+
] }) : null
|
|
1740
|
+
),
|
|
1694
1741
|
(() => {
|
|
1695
1742
|
const metaContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1696
1743
|
/* @__PURE__ */ jsx("span", { children: time }),
|
|
@@ -1747,7 +1794,7 @@ function MessageBubble({
|
|
|
1747
1794
|
children: "Read more"
|
|
1748
1795
|
}
|
|
1749
1796
|
),
|
|
1750
|
-
!shouldTrim && expanded && rawBody.length > maxBodyLength +
|
|
1797
|
+
!shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER2 && /* @__PURE__ */ jsx(
|
|
1751
1798
|
"button",
|
|
1752
1799
|
{
|
|
1753
1800
|
type: "button",
|
|
@@ -1764,7 +1811,7 @@ function MessageBubble({
|
|
|
1764
1811
|
) : null;
|
|
1765
1812
|
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";
|
|
1766
1813
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1767
|
-
body,
|
|
1814
|
+
renderSlot(slots?.body, slotContext, body),
|
|
1768
1815
|
/* @__PURE__ */ jsx("span", { className: metaClass, children: metaContent })
|
|
1769
1816
|
] });
|
|
1770
1817
|
})()
|
|
@@ -2052,9 +2099,12 @@ function MessageActions({
|
|
|
2052
2099
|
onCopy,
|
|
2053
2100
|
onEdit,
|
|
2054
2101
|
onDelete,
|
|
2102
|
+
moreMenu = false,
|
|
2055
2103
|
children
|
|
2056
2104
|
}) {
|
|
2057
2105
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
2106
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
2107
|
+
const hasMore = !!(onCopy || onEdit || onDelete);
|
|
2058
2108
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-msg-actions", role: "toolbar", "aria-label": "Message actions", children: [
|
|
2059
2109
|
onReact && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2060
2110
|
/* @__PURE__ */ jsx(
|
|
@@ -2077,12 +2127,60 @@ function MessageActions({
|
|
|
2077
2127
|
}
|
|
2078
2128
|
) })
|
|
2079
2129
|
] }),
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2130
|
+
moreMenu ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2131
|
+
onQuote && /* @__PURE__ */ jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
2132
|
+
onReply && /* @__PURE__ */ jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
2133
|
+
children,
|
|
2134
|
+
hasMore && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2135
|
+
/* @__PURE__ */ jsx(
|
|
2136
|
+
ActionButton,
|
|
2137
|
+
{
|
|
2138
|
+
label: "More actions",
|
|
2139
|
+
icon: "more-h",
|
|
2140
|
+
onClick: () => setMenuOpen((o) => !o),
|
|
2141
|
+
active: menuOpen
|
|
2142
|
+
}
|
|
2143
|
+
),
|
|
2144
|
+
menuOpen && /* @__PURE__ */ jsx(
|
|
2145
|
+
"div",
|
|
2146
|
+
{
|
|
2147
|
+
className: "poolse-msg-actions__menu",
|
|
2148
|
+
role: "menu",
|
|
2149
|
+
onKeyDown: (e) => {
|
|
2150
|
+
if (e.key === "Escape") setMenuOpen(false);
|
|
2151
|
+
},
|
|
2152
|
+
children: [
|
|
2153
|
+
onCopy && { label: "Copy", icon: "copy", run: onCopy },
|
|
2154
|
+
onEdit && { label: "Edit", icon: "edit", run: onEdit },
|
|
2155
|
+
onDelete && { label: "Delete", icon: "trash", run: onDelete }
|
|
2156
|
+
].filter((item) => !!item).map((item) => /* @__PURE__ */ jsxs(
|
|
2157
|
+
"button",
|
|
2158
|
+
{
|
|
2159
|
+
type: "button",
|
|
2160
|
+
role: "menuitem",
|
|
2161
|
+
className: `poolse-msg-actions__menu-item${item.label === "Delete" ? " poolse-msg-actions__menu-item--danger" : ""}`,
|
|
2162
|
+
onClick: () => {
|
|
2163
|
+
setMenuOpen(false);
|
|
2164
|
+
item.run();
|
|
2165
|
+
},
|
|
2166
|
+
children: [
|
|
2167
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: item.icon, size: 15, label: null }),
|
|
2168
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
2169
|
+
]
|
|
2170
|
+
},
|
|
2171
|
+
item.label
|
|
2172
|
+
))
|
|
2173
|
+
}
|
|
2174
|
+
)
|
|
2175
|
+
] })
|
|
2176
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2177
|
+
onReply && /* @__PURE__ */ jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
2178
|
+
onQuote && /* @__PURE__ */ jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
2179
|
+
onCopy && /* @__PURE__ */ jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
2180
|
+
onEdit && /* @__PURE__ */ jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
2181
|
+
onDelete && /* @__PURE__ */ jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
2182
|
+
children
|
|
2183
|
+
] })
|
|
2086
2184
|
] });
|
|
2087
2185
|
}
|
|
2088
2186
|
function ActionButton({
|
|
@@ -2099,6 +2197,319 @@ function ActionButton({
|
|
|
2099
2197
|
].filter(Boolean).join(" ");
|
|
2100
2198
|
return /* @__PURE__ */ jsx("button", { type: "button", className: classes, "aria-label": label, title: label, onClick, children: /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: 16, label: null }) });
|
|
2101
2199
|
}
|
|
2200
|
+
function useRowActions() {
|
|
2201
|
+
const [actionsOpen, setActionsOpen] = useState(false);
|
|
2202
|
+
const rowRef = useRef(null);
|
|
2203
|
+
useEffect(() => {
|
|
2204
|
+
if (!actionsOpen) return;
|
|
2205
|
+
const onDown = (e) => {
|
|
2206
|
+
const t = e.target;
|
|
2207
|
+
if (t instanceof Node && rowRef.current && !rowRef.current.contains(t)) {
|
|
2208
|
+
setActionsOpen(false);
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
document.addEventListener("pointerdown", onDown);
|
|
2212
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
2213
|
+
}, [actionsOpen]);
|
|
2214
|
+
const onRowClick = (e) => {
|
|
2215
|
+
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
2216
|
+
const target = e.target;
|
|
2217
|
+
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
2218
|
+
setActionsOpen((o) => !o);
|
|
2219
|
+
};
|
|
2220
|
+
return { actionsOpen, setActionsOpen, rowRef, onRowClick };
|
|
2221
|
+
}
|
|
2222
|
+
function InlineReactions({
|
|
2223
|
+
reactions,
|
|
2224
|
+
currentUserId,
|
|
2225
|
+
onAdd,
|
|
2226
|
+
onRemove
|
|
2227
|
+
}) {
|
|
2228
|
+
const entries = Object.entries(reactions);
|
|
2229
|
+
if (entries.length === 0) return null;
|
|
2230
|
+
return /* @__PURE__ */ jsx("div", { className: "poolse-reactions", children: entries.map(([emoji, users]) => {
|
|
2231
|
+
const mine = currentUserId !== null && currentUserId !== void 0 && users.includes(currentUserId);
|
|
2232
|
+
return /* @__PURE__ */ jsxs(
|
|
2233
|
+
"button",
|
|
2234
|
+
{
|
|
2235
|
+
type: "button",
|
|
2236
|
+
className: `poolse-reaction-pill${mine ? " poolse-reaction-pill--mine" : ""}`,
|
|
2237
|
+
onClick: () => {
|
|
2238
|
+
if (mine) onRemove(emoji);
|
|
2239
|
+
else onAdd(emoji);
|
|
2240
|
+
},
|
|
2241
|
+
"aria-pressed": mine,
|
|
2242
|
+
"aria-label": `${emoji} reacted by ${users.length} ${users.length === 1 ? "user" : "users"}`,
|
|
2243
|
+
children: [
|
|
2244
|
+
/* @__PURE__ */ jsx("span", { children: emoji }),
|
|
2245
|
+
/* @__PURE__ */ jsx("span", { className: "poolse-reaction-pill__count", children: users.length })
|
|
2246
|
+
]
|
|
2247
|
+
},
|
|
2248
|
+
emoji
|
|
2249
|
+
);
|
|
2250
|
+
}) });
|
|
2251
|
+
}
|
|
2252
|
+
var TRIM_BUFFER = 40;
|
|
2253
|
+
function FlatMessageRow({
|
|
2254
|
+
msg,
|
|
2255
|
+
meId,
|
|
2256
|
+
layout,
|
|
2257
|
+
reactions = true,
|
|
2258
|
+
attachments = true,
|
|
2259
|
+
actions = true,
|
|
2260
|
+
threads = true,
|
|
2261
|
+
quotations = true,
|
|
2262
|
+
readState,
|
|
2263
|
+
editing = false,
|
|
2264
|
+
onStartEdit,
|
|
2265
|
+
onCancelEdit,
|
|
2266
|
+
onSaveEdit,
|
|
2267
|
+
onDelete,
|
|
2268
|
+
onOpenThread,
|
|
2269
|
+
onQuote,
|
|
2270
|
+
labelFor,
|
|
2271
|
+
onQuotedClick,
|
|
2272
|
+
groupPosition = "standalone",
|
|
2273
|
+
maxBodyLength = 0,
|
|
2274
|
+
markdown = false,
|
|
2275
|
+
showAvatar = layout === "list",
|
|
2276
|
+
onSenderPress,
|
|
2277
|
+
onAvatarPress,
|
|
2278
|
+
timeFormat,
|
|
2279
|
+
slots,
|
|
2280
|
+
mentionsMe = false
|
|
2281
|
+
}) {
|
|
2282
|
+
const compact = layout === "compact";
|
|
2283
|
+
const isSelf = meId !== null && msg.sender_id === meId;
|
|
2284
|
+
const { profile } = useUser(msg.sender_external_id);
|
|
2285
|
+
const senderName = profile?.displayName ?? msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
2286
|
+
const sender = {
|
|
2287
|
+
userId: msg.sender_id,
|
|
2288
|
+
externalId: msg.sender_external_id,
|
|
2289
|
+
displayName: senderName,
|
|
2290
|
+
avatarUrl: profile?.avatarUrl ?? null
|
|
2291
|
+
};
|
|
2292
|
+
const isRunStart = compact || groupPosition === "first" || groupPosition === "standalone";
|
|
2293
|
+
const ctx = { message: msg, isSelf, sender, layout, isRunStart };
|
|
2294
|
+
const reactionsHook = useReactions(reactions ? msg.id : "", {
|
|
2295
|
+
conversationId: msg.conversation_id,
|
|
2296
|
+
initialReactions: msg.reactions,
|
|
2297
|
+
currentUserId: meId
|
|
2298
|
+
});
|
|
2299
|
+
const { actionsOpen, rowRef, onRowClick } = useRowActions();
|
|
2300
|
+
const deleted = !!msg.deleted_at;
|
|
2301
|
+
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
2302
|
+
const replyCount = msg.reply_count ?? 0;
|
|
2303
|
+
const showThreadLink = threads && !deleted && !msg.thread_root_id && replyCount > 0;
|
|
2304
|
+
const showActions = actions && !deleted && !editing;
|
|
2305
|
+
const timeEl = (className) => /* @__PURE__ */ jsx("time", { className, dateTime: msg.inserted_at, children: time });
|
|
2306
|
+
const avatarSize = compact ? "sm" : "md";
|
|
2307
|
+
const avatar = !showAvatar ? null : onAvatarPress && !isSelf ? /* @__PURE__ */ jsx(
|
|
2308
|
+
"button",
|
|
2309
|
+
{
|
|
2310
|
+
type: "button",
|
|
2311
|
+
className: "poolse-row__avatar-button",
|
|
2312
|
+
"aria-label": senderName,
|
|
2313
|
+
onClick: () => onAvatarPress(sender),
|
|
2314
|
+
children: /* @__PURE__ */ jsx(Avatar, { src: sender.avatarUrl, name: senderName, size: avatarSize })
|
|
2315
|
+
}
|
|
2316
|
+
) : /* @__PURE__ */ jsx(Avatar, { src: sender.avatarUrl, name: senderName, size: avatarSize });
|
|
2317
|
+
const nameStyle = compact ? { color: userColor(msg.sender_external_id ?? msg.sender_id ?? "") } : void 0;
|
|
2318
|
+
const name = onSenderPress && !isSelf ? /* @__PURE__ */ jsx(
|
|
2319
|
+
"button",
|
|
2320
|
+
{
|
|
2321
|
+
type: "button",
|
|
2322
|
+
className: "poolse-row__name poolse-row__name--button",
|
|
2323
|
+
style: nameStyle,
|
|
2324
|
+
onClick: () => onSenderPress(sender),
|
|
2325
|
+
children: senderName
|
|
2326
|
+
}
|
|
2327
|
+
) : /* @__PURE__ */ jsx("span", { className: "poolse-row__name", style: nameStyle, children: senderName });
|
|
2328
|
+
const header = compact ? name : isRunStart ? /* @__PURE__ */ jsxs("div", { className: "poolse-row__header", children: [
|
|
2329
|
+
name,
|
|
2330
|
+
timeEl("poolse-row__time")
|
|
2331
|
+
] }) : null;
|
|
2332
|
+
const quote = msg.quoted_message !== void 0 && msg.quoted_message !== null ? /* @__PURE__ */ jsx(
|
|
2333
|
+
QuotedCard,
|
|
2334
|
+
{
|
|
2335
|
+
quoted: msg.quoted_message,
|
|
2336
|
+
isSelf: false,
|
|
2337
|
+
...labelFor ? { labelFor } : {},
|
|
2338
|
+
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
2339
|
+
}
|
|
2340
|
+
) : msg.quoted_message_id ? /* @__PURE__ */ jsx(QuotedPlaceholder, { isSelf: false, quotedMessageId: msg.quoted_message_id }) : null;
|
|
2341
|
+
const attachmentList = attachments && !deleted && Array.isArray(msg.attachments) ? msg.attachments : [];
|
|
2342
|
+
const images = attachmentList.filter((a) => isImageContentType(a.content_type));
|
|
2343
|
+
const files = attachmentList.filter((a) => !isImageContentType(a.content_type));
|
|
2344
|
+
const attachmentsEl = images.length > 0 || files.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "poolse-row__attachments", children: [
|
|
2345
|
+
images.length > 0 && /* @__PURE__ */ jsx(ImageMosaic, { images }),
|
|
2346
|
+
files.length > 0 && /* @__PURE__ */ jsx("div", { className: "poolse-message__files", children: files.map((att) => /* @__PURE__ */ jsx(AttachmentPreview, { attachment: att }, att.id)) })
|
|
2347
|
+
] }) : null;
|
|
2348
|
+
const meta = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2349
|
+
msg.edited_at && !deleted ? /* @__PURE__ */ jsx("span", { className: "poolse-row__edited", children: "(edited)" }) : null,
|
|
2350
|
+
isSelf && readState ? /* @__PURE__ */ jsx("span", { className: "poolse-row__receipt", children: /* @__PURE__ */ jsx(
|
|
2351
|
+
PoolseIcon,
|
|
2352
|
+
{
|
|
2353
|
+
name: readState === "read" ? "check-double" : "check",
|
|
2354
|
+
size: 14,
|
|
2355
|
+
label: readState === "read" ? "Read" : "Sent"
|
|
2356
|
+
}
|
|
2357
|
+
) }) : null
|
|
2358
|
+
] });
|
|
2359
|
+
const body = editing ? (
|
|
2360
|
+
// `currentUserId={null}` styles the editor as a neutral card rather
|
|
2361
|
+
// than an own-message bubble, which would look out of place in a row.
|
|
2362
|
+
/* @__PURE__ */ jsx(
|
|
2363
|
+
EditableMessageBubble,
|
|
2364
|
+
{
|
|
2365
|
+
message: msg,
|
|
2366
|
+
currentUserId: null,
|
|
2367
|
+
editing: true,
|
|
2368
|
+
onSave: onSaveEdit ?? (async () => void 0),
|
|
2369
|
+
onCancel: onCancelEdit ?? (() => void 0)
|
|
2370
|
+
}
|
|
2371
|
+
)
|
|
2372
|
+
) : /* @__PURE__ */ jsx(
|
|
2373
|
+
FlatBody,
|
|
2374
|
+
{
|
|
2375
|
+
message: msg,
|
|
2376
|
+
markdown,
|
|
2377
|
+
maxBodyLength,
|
|
2378
|
+
hasAttachments: attachmentList.length > 0,
|
|
2379
|
+
meta
|
|
2380
|
+
}
|
|
2381
|
+
);
|
|
2382
|
+
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsx(
|
|
2383
|
+
InlineReactions,
|
|
2384
|
+
{
|
|
2385
|
+
reactions: reactionsHook.reactions,
|
|
2386
|
+
currentUserId: meId,
|
|
2387
|
+
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
2388
|
+
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
2389
|
+
}
|
|
2390
|
+
) : null;
|
|
2391
|
+
const threadEl = showThreadLink ? /* @__PURE__ */ jsxs(
|
|
2392
|
+
"button",
|
|
2393
|
+
{
|
|
2394
|
+
type: "button",
|
|
2395
|
+
className: "poolse-row__thread",
|
|
2396
|
+
onClick: onOpenThread,
|
|
2397
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2398
|
+
children: [
|
|
2399
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 14, label: null }),
|
|
2400
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
2401
|
+
replyCount,
|
|
2402
|
+
" ",
|
|
2403
|
+
replyCount === 1 ? "reply" : "replies"
|
|
2404
|
+
] })
|
|
2405
|
+
]
|
|
2406
|
+
}
|
|
2407
|
+
) : null;
|
|
2408
|
+
const toolbar = showActions ? /* @__PURE__ */ jsx("div", { className: "poolse-row__toolbar", children: /* @__PURE__ */ jsx(
|
|
2409
|
+
MessageActions,
|
|
2410
|
+
{
|
|
2411
|
+
moreMenu: true,
|
|
2412
|
+
...reactions ? { onReact: (emoji) => void reactionsHook.addReaction(emoji) } : {},
|
|
2413
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
2414
|
+
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
2415
|
+
...msg.body ? {
|
|
2416
|
+
onCopy: () => {
|
|
2417
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
2418
|
+
}
|
|
2419
|
+
} : {},
|
|
2420
|
+
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
2421
|
+
...isSelf && onDelete ? { onDelete } : {}
|
|
2422
|
+
}
|
|
2423
|
+
) }) : null;
|
|
2424
|
+
const content = /* @__PURE__ */ jsxs("div", { className: "poolse-row__content", children: [
|
|
2425
|
+
!compact && renderSlot(slots?.header, ctx, header),
|
|
2426
|
+
quote,
|
|
2427
|
+
renderSlot(slots?.attachments, ctx, attachmentsEl),
|
|
2428
|
+
renderSlot(slots?.body, ctx, body),
|
|
2429
|
+
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
2430
|
+
renderSlot(slots?.thread, ctx, threadEl)
|
|
2431
|
+
] });
|
|
2432
|
+
return /* @__PURE__ */ jsxs(
|
|
2433
|
+
"div",
|
|
2434
|
+
{
|
|
2435
|
+
ref: rowRef,
|
|
2436
|
+
className: [
|
|
2437
|
+
"poolse-row",
|
|
2438
|
+
`poolse-row--${layout}`,
|
|
2439
|
+
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
2440
|
+
isSelf ? "poolse-row--self" : "",
|
|
2441
|
+
mentionsMe ? "poolse-row--mention" : "",
|
|
2442
|
+
editing ? "poolse-row--editing" : ""
|
|
2443
|
+
].filter(Boolean).join(" "),
|
|
2444
|
+
"data-message-id": msg.id,
|
|
2445
|
+
"data-actions-open": actionsOpen || void 0,
|
|
2446
|
+
onClick: onRowClick,
|
|
2447
|
+
children: [
|
|
2448
|
+
compact ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2449
|
+
timeEl("poolse-row__time"),
|
|
2450
|
+
avatar ? /* @__PURE__ */ jsx("span", { className: "poolse-row__avatar", children: avatar }) : null,
|
|
2451
|
+
renderSlot(slots?.header, ctx, header),
|
|
2452
|
+
content
|
|
2453
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2454
|
+
/* @__PURE__ */ jsx("div", { className: "poolse-row__gutter", children: isRunStart ? avatar : timeEl("poolse-row__gutter-time") }),
|
|
2455
|
+
content
|
|
2456
|
+
] }),
|
|
2457
|
+
renderSlot(slots?.actions, ctx, toolbar)
|
|
2458
|
+
]
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2462
|
+
function FlatBody({
|
|
2463
|
+
message,
|
|
2464
|
+
markdown,
|
|
2465
|
+
maxBodyLength,
|
|
2466
|
+
hasAttachments,
|
|
2467
|
+
meta
|
|
2468
|
+
}) {
|
|
2469
|
+
const [expanded, setExpanded] = useState(false);
|
|
2470
|
+
if (message.deleted_at) {
|
|
2471
|
+
return /* @__PURE__ */ jsx("div", { className: "poolse-message__body poolse-row__body", children: /* @__PURE__ */ jsx("span", { className: "poolse-message__body--deleted", children: "Message deleted" }) });
|
|
2472
|
+
}
|
|
2473
|
+
const raw = message.body ?? "";
|
|
2474
|
+
if (!raw) {
|
|
2475
|
+
return /* @__PURE__ */ jsx("div", { className: "poolse-row__meta-only", children: meta });
|
|
2476
|
+
}
|
|
2477
|
+
const long = maxBodyLength > 0 && raw.length > maxBodyLength + TRIM_BUFFER;
|
|
2478
|
+
const shown = long && !expanded ? raw.slice(0, maxBodyLength).trimEnd() + "\u2026" : raw;
|
|
2479
|
+
const jumbo = !hasAttachments && !message.quoted_message_id ? emojiOnlyCount(raw) : 0;
|
|
2480
|
+
const md = markdown && jumbo === 0 && hasMarkdown(shown);
|
|
2481
|
+
return /* @__PURE__ */ jsxs(
|
|
2482
|
+
"div",
|
|
2483
|
+
{
|
|
2484
|
+
className: md ? "poolse-message__body poolse-message__body--md poolse-row__body" : "poolse-message__body poolse-row__body",
|
|
2485
|
+
children: [
|
|
2486
|
+
jumbo > 0 ? /* @__PURE__ */ jsx("span", { className: "poolse-message__body--jumbo", style: { fontSize: emojiFontSize(jumbo) }, children: shown }) : md ? /* @__PURE__ */ jsx(
|
|
2487
|
+
ReactMarkdown,
|
|
2488
|
+
{
|
|
2489
|
+
remarkPlugins: [remarkGfm],
|
|
2490
|
+
components: {
|
|
2491
|
+
a: ({ node: _node, ...props }) => /* @__PURE__ */ jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
|
|
2492
|
+
},
|
|
2493
|
+
children: shown
|
|
2494
|
+
}
|
|
2495
|
+
) : /* @__PURE__ */ jsx("span", { children: shown }),
|
|
2496
|
+
long && /* @__PURE__ */ jsx(
|
|
2497
|
+
"button",
|
|
2498
|
+
{
|
|
2499
|
+
type: "button",
|
|
2500
|
+
className: "poolse-message__read-more",
|
|
2501
|
+
onClick: (e) => {
|
|
2502
|
+
e.stopPropagation();
|
|
2503
|
+
setExpanded((x) => !x);
|
|
2504
|
+
},
|
|
2505
|
+
children: expanded ? "Show less" : "Read more"
|
|
2506
|
+
}
|
|
2507
|
+
),
|
|
2508
|
+
meta
|
|
2509
|
+
]
|
|
2510
|
+
}
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2102
2513
|
function MessageRow(props) {
|
|
2103
2514
|
const callLog = callLogDisplayFor(props.msg, props.meId);
|
|
2104
2515
|
if (callLog !== void 0) {
|
|
@@ -2111,6 +2522,9 @@ function MessageRow(props) {
|
|
|
2111
2522
|
}
|
|
2112
2523
|
) : null;
|
|
2113
2524
|
}
|
|
2525
|
+
if (props.layout === "list" || props.layout === "compact") {
|
|
2526
|
+
return /* @__PURE__ */ jsx(FlatMessageRow, { ...props, layout: props.layout });
|
|
2527
|
+
}
|
|
2114
2528
|
return /* @__PURE__ */ jsx(BubbleMessageRow, { ...props });
|
|
2115
2529
|
}
|
|
2116
2530
|
function BubbleMessageRow({
|
|
@@ -2135,12 +2549,22 @@ function BubbleMessageRow({
|
|
|
2135
2549
|
maxBodyLength = 0,
|
|
2136
2550
|
markdown = false,
|
|
2137
2551
|
showSenderName = false,
|
|
2138
|
-
showAvatar = false
|
|
2552
|
+
showAvatar = false,
|
|
2553
|
+
onSenderPress,
|
|
2554
|
+
onAvatarPress,
|
|
2555
|
+
timeFormat,
|
|
2556
|
+
slots
|
|
2139
2557
|
}) {
|
|
2140
|
-
const { profile: senderProfile } = useUser(msg.
|
|
2141
|
-
const senderFallbackName = msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown";
|
|
2558
|
+
const { profile: senderProfile } = useUser(msg.sender_external_id);
|
|
2559
|
+
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
2142
2560
|
const senderName = senderProfile?.displayName ?? senderFallbackName;
|
|
2143
2561
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
2562
|
+
const sender = {
|
|
2563
|
+
userId: msg.sender_id,
|
|
2564
|
+
externalId: msg.sender_external_id,
|
|
2565
|
+
displayName: senderName,
|
|
2566
|
+
avatarUrl: senderProfile?.avatarUrl ?? null
|
|
2567
|
+
};
|
|
2144
2568
|
const reactionsHook = useReactions(reactions ? msg.id : "", {
|
|
2145
2569
|
conversationId: msg.conversation_id,
|
|
2146
2570
|
initialReactions: msg.reactions,
|
|
@@ -2152,24 +2576,13 @@ function BubbleMessageRow({
|
|
|
2152
2576
|
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
2153
2577
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
2154
2578
|
const handleCancel = onCancelEdit ?? (() => void 0);
|
|
2155
|
-
const
|
|
2156
|
-
const
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
setActionsOpen(false);
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
document.addEventListener("pointerdown", onDown);
|
|
2166
|
-
return () => document.removeEventListener("pointerdown", onDown);
|
|
2167
|
-
}, [actionsOpen]);
|
|
2168
|
-
const onRowClick = (e) => {
|
|
2169
|
-
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
2170
|
-
const target = e.target;
|
|
2171
|
-
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
2172
|
-
setActionsOpen((o) => !o);
|
|
2579
|
+
const { actionsOpen, setActionsOpen, rowRef, onRowClick } = useRowActions();
|
|
2580
|
+
const slotContext = {
|
|
2581
|
+
message: msg,
|
|
2582
|
+
isSelf,
|
|
2583
|
+
sender,
|
|
2584
|
+
layout: "bubbles",
|
|
2585
|
+
isRunStart: groupPosition === "first" || groupPosition === "standalone"
|
|
2173
2586
|
};
|
|
2174
2587
|
return /* @__PURE__ */ jsxs(
|
|
2175
2588
|
"div",
|
|
@@ -2207,6 +2620,7 @@ function BubbleMessageRow({
|
|
|
2207
2620
|
groupPosition,
|
|
2208
2621
|
senderName,
|
|
2209
2622
|
avatarUrl: senderProfile?.avatarUrl ?? null,
|
|
2623
|
+
...onAvatarPress ? { onAvatarPress: () => onAvatarPress(sender) } : {},
|
|
2210
2624
|
children: /* @__PURE__ */ jsx(
|
|
2211
2625
|
MessageBubble,
|
|
2212
2626
|
{
|
|
@@ -2216,10 +2630,13 @@ function BubbleMessageRow({
|
|
|
2216
2630
|
maxBodyLength,
|
|
2217
2631
|
markdown,
|
|
2218
2632
|
showSenderName,
|
|
2633
|
+
...onSenderPress ? { onSenderPress: () => onSenderPress(sender) } : {},
|
|
2219
2634
|
showAttachments: attachments,
|
|
2220
2635
|
...readState ? { readState } : {},
|
|
2221
2636
|
...labelFor ? { labelFor } : {},
|
|
2222
2637
|
...onQuotedClick ? { onQuotedClick } : {},
|
|
2638
|
+
...timeFormat ? { timeFormat } : {},
|
|
2639
|
+
...slots ? { slots, slotContext } : {},
|
|
2223
2640
|
...showActions ? {
|
|
2224
2641
|
actionsTrigger: /* @__PURE__ */ jsx(
|
|
2225
2642
|
"button",
|
|
@@ -2240,103 +2657,95 @@ function BubbleMessageRow({
|
|
|
2240
2657
|
)
|
|
2241
2658
|
}
|
|
2242
2659
|
),
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
type: "button",
|
|
2256
|
-
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
2257
|
-
onClick: onOpenThread,
|
|
2258
|
-
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2259
|
-
children: [
|
|
2260
|
-
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
2261
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
2262
|
-
replyCount,
|
|
2263
|
-
" ",
|
|
2264
|
-
replyCount === 1 ? "reply" : "replies"
|
|
2265
|
-
] })
|
|
2266
|
-
]
|
|
2267
|
-
}
|
|
2660
|
+
renderSlot(
|
|
2661
|
+
slots?.reactions,
|
|
2662
|
+
slotContext,
|
|
2663
|
+
showReactions ? /* @__PURE__ */ jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsx(
|
|
2664
|
+
InlineReactions,
|
|
2665
|
+
{
|
|
2666
|
+
reactions: reactionsHook.reactions,
|
|
2667
|
+
currentUserId: meId,
|
|
2668
|
+
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
2669
|
+
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
2670
|
+
}
|
|
2671
|
+
) }) : null
|
|
2268
2672
|
),
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2673
|
+
renderSlot(
|
|
2674
|
+
slots?.thread,
|
|
2675
|
+
slotContext,
|
|
2676
|
+
showThreadPill ? /* @__PURE__ */ jsxs(
|
|
2677
|
+
"button",
|
|
2678
|
+
{
|
|
2679
|
+
type: "button",
|
|
2680
|
+
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
2681
|
+
onClick: onOpenThread,
|
|
2682
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2683
|
+
children: [
|
|
2684
|
+
/* @__PURE__ */ jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
2685
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
2686
|
+
replyCount,
|
|
2687
|
+
" ",
|
|
2688
|
+
replyCount === 1 ? "reply" : "replies"
|
|
2689
|
+
] })
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
) : null
|
|
2693
|
+
),
|
|
2694
|
+
renderSlot(
|
|
2695
|
+
slots?.actions,
|
|
2696
|
+
slotContext,
|
|
2697
|
+
showActions ? /* @__PURE__ */ jsx(
|
|
2698
|
+
"div",
|
|
2699
|
+
{
|
|
2700
|
+
className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
|
|
2701
|
+
children: /* @__PURE__ */ jsx(
|
|
2702
|
+
MessageActions,
|
|
2703
|
+
{
|
|
2704
|
+
...reactions ? {
|
|
2705
|
+
onReact: (emoji) => {
|
|
2706
|
+
void reactionsHook.addReaction(emoji);
|
|
2707
|
+
}
|
|
2708
|
+
} : {},
|
|
2709
|
+
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
2710
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
2711
|
+
...msg.body ? {
|
|
2712
|
+
onCopy: () => {
|
|
2713
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
2714
|
+
}
|
|
2715
|
+
} : {},
|
|
2716
|
+
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
2717
|
+
...isSelf && onDelete ? { onDelete } : {}
|
|
2718
|
+
}
|
|
2719
|
+
)
|
|
2720
|
+
}
|
|
2721
|
+
) : null
|
|
2293
2722
|
)
|
|
2294
2723
|
]
|
|
2295
2724
|
}
|
|
2296
2725
|
);
|
|
2297
2726
|
}
|
|
2298
|
-
function InlineReactions({
|
|
2299
|
-
reactions,
|
|
2300
|
-
currentUserId,
|
|
2301
|
-
onAdd: _onAdd,
|
|
2302
|
-
onRemove
|
|
2303
|
-
}) {
|
|
2304
|
-
const entries = Object.entries(reactions);
|
|
2305
|
-
if (entries.length === 0) return null;
|
|
2306
|
-
return /* @__PURE__ */ jsx("div", { className: "poolse-reactions", children: entries.map(([emoji, users]) => {
|
|
2307
|
-
const mine = currentUserId !== null && currentUserId !== void 0 && users.includes(currentUserId);
|
|
2308
|
-
return /* @__PURE__ */ jsxs(
|
|
2309
|
-
"button",
|
|
2310
|
-
{
|
|
2311
|
-
type: "button",
|
|
2312
|
-
className: `poolse-reaction-pill${mine ? " poolse-reaction-pill--mine" : ""}`,
|
|
2313
|
-
onClick: () => {
|
|
2314
|
-
if (mine) onRemove(emoji);
|
|
2315
|
-
else _onAdd(emoji);
|
|
2316
|
-
},
|
|
2317
|
-
"aria-pressed": mine,
|
|
2318
|
-
"aria-label": `${emoji} reacted by ${users.length} ${users.length === 1 ? "user" : "users"}`,
|
|
2319
|
-
children: [
|
|
2320
|
-
/* @__PURE__ */ jsx("span", { children: emoji }),
|
|
2321
|
-
/* @__PURE__ */ jsx("span", { className: "poolse-reaction-pill__count", children: users.length })
|
|
2322
|
-
]
|
|
2323
|
-
},
|
|
2324
|
-
emoji
|
|
2325
|
-
);
|
|
2326
|
-
}) });
|
|
2327
|
-
}
|
|
2328
2727
|
function BubbleWithAvatar({
|
|
2329
2728
|
isSelf,
|
|
2330
2729
|
showAvatar,
|
|
2331
2730
|
groupPosition,
|
|
2332
2731
|
senderName,
|
|
2333
2732
|
avatarUrl,
|
|
2733
|
+
onAvatarPress,
|
|
2334
2734
|
children
|
|
2335
2735
|
}) {
|
|
2336
2736
|
if (isSelf || !showAvatar) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2337
2737
|
const isLastOfCluster = groupPosition === "last" || groupPosition === "standalone";
|
|
2338
2738
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-bubble-shell", children: [
|
|
2339
|
-
/* @__PURE__ */ jsx("div", { className: "poolse-bubble-shell__avatar", children: isLastOfCluster ? /* @__PURE__ */ jsx(
|
|
2739
|
+
/* @__PURE__ */ jsx("div", { className: "poolse-bubble-shell__avatar", children: !isLastOfCluster ? null : onAvatarPress ? /* @__PURE__ */ jsx(
|
|
2740
|
+
"button",
|
|
2741
|
+
{
|
|
2742
|
+
type: "button",
|
|
2743
|
+
className: "poolse-bubble-shell__avatar-button",
|
|
2744
|
+
"aria-label": senderName,
|
|
2745
|
+
onClick: onAvatarPress,
|
|
2746
|
+
children: /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name: senderName, size: "sm" })
|
|
2747
|
+
}
|
|
2748
|
+
) : /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name: senderName, size: "sm" }) }),
|
|
2340
2749
|
children
|
|
2341
2750
|
] });
|
|
2342
2751
|
}
|
|
@@ -2344,7 +2753,9 @@ function ThreadView({
|
|
|
2344
2753
|
conversationId,
|
|
2345
2754
|
rootMessage,
|
|
2346
2755
|
onClose,
|
|
2347
|
-
renderMessage
|
|
2756
|
+
renderMessage,
|
|
2757
|
+
layout,
|
|
2758
|
+
timeFormat
|
|
2348
2759
|
}) {
|
|
2349
2760
|
const { me } = useMe();
|
|
2350
2761
|
const {
|
|
@@ -2427,7 +2838,9 @@ function ThreadView({
|
|
|
2427
2838
|
await edit(msg.id, body);
|
|
2428
2839
|
setEditingId(null);
|
|
2429
2840
|
},
|
|
2430
|
-
onDelete: () => void deleteReply(msg.id)
|
|
2841
|
+
onDelete: () => void deleteReply(msg.id),
|
|
2842
|
+
...layout ? { layout } : {},
|
|
2843
|
+
...timeFormat ? { timeFormat } : {}
|
|
2431
2844
|
}
|
|
2432
2845
|
);
|
|
2433
2846
|
const renderOne = renderMessage ? (msg, currentUserId) => renderMessage(msg, currentUserId) : (msg) => renderDefault(msg);
|
|
@@ -2543,16 +2956,31 @@ function ConversationView({
|
|
|
2543
2956
|
markdown = TRUE,
|
|
2544
2957
|
maxBodyLength = 200,
|
|
2545
2958
|
grouping = TRUE,
|
|
2546
|
-
groupingWindowMs
|
|
2959
|
+
groupingWindowMs,
|
|
2960
|
+
groupWindowMinutes,
|
|
2961
|
+
layout = "bubbles",
|
|
2962
|
+
density = "comfortable",
|
|
2963
|
+
showAvatars,
|
|
2964
|
+
timeFormat,
|
|
2965
|
+
slots,
|
|
2547
2966
|
daySeparators = TRUE,
|
|
2548
2967
|
senderLabels = "auto",
|
|
2549
2968
|
avatars = "auto",
|
|
2550
2969
|
onMarkedRead,
|
|
2970
|
+
focusMessageId = null,
|
|
2971
|
+
onFocusMessageNotFound,
|
|
2972
|
+
onSenderPress,
|
|
2973
|
+
onAvatarPress,
|
|
2974
|
+
composer = TRUE,
|
|
2975
|
+
readOnly = false,
|
|
2551
2976
|
onCallBack,
|
|
2552
2977
|
onJoinCall,
|
|
2553
2978
|
currentCallId = null
|
|
2554
2979
|
}) {
|
|
2555
2980
|
usePoolseFonts(loadFonts);
|
|
2981
|
+
const showComposer = composer && !readOnly;
|
|
2982
|
+
const canQuote = quotations && showComposer;
|
|
2983
|
+
const canDrop = attachments && showComposer;
|
|
2556
2984
|
const { me } = useMe();
|
|
2557
2985
|
const {
|
|
2558
2986
|
messages,
|
|
@@ -2560,6 +2988,7 @@ function ConversationView({
|
|
|
2560
2988
|
error,
|
|
2561
2989
|
hasMore,
|
|
2562
2990
|
loadMore,
|
|
2991
|
+
loadUntil,
|
|
2563
2992
|
send,
|
|
2564
2993
|
edit,
|
|
2565
2994
|
delete: deleteMsg,
|
|
@@ -2581,7 +3010,13 @@ function ConversationView({
|
|
|
2581
3010
|
const { members } = useMembers(membersOn ? conversationId : "");
|
|
2582
3011
|
const isGroupChat = members.length > 2;
|
|
2583
3012
|
const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
|
|
2584
|
-
const showAvatarsResolved = avatars === "always" || avatars === "auto" && isGroupChat;
|
|
3013
|
+
const showAvatarsResolved = showAvatars ?? (layout === "list" ? true : layout === "compact" ? false : avatars === "always" || avatars === "auto" && isGroupChat);
|
|
3014
|
+
const groupWindowMs = groupWindowMinutes !== void 0 ? groupWindowMinutes * 60 * 1e3 : groupingWindowMs ?? 5 * 60 * 1e3;
|
|
3015
|
+
const layoutProps = {
|
|
3016
|
+
layout,
|
|
3017
|
+
...timeFormat ? { timeFormat } : {},
|
|
3018
|
+
...slots ? { slots } : {}
|
|
3019
|
+
};
|
|
2585
3020
|
const listRef = useRef(null);
|
|
2586
3021
|
const lastMessageIdRef = useRef(null);
|
|
2587
3022
|
const bottomSentinelRef = useRef(null);
|
|
@@ -2673,6 +3108,49 @@ function ConversationView({
|
|
|
2673
3108
|
() => messages.filter((m) => isMessageVisibleTo(m, meIdForFeed)),
|
|
2674
3109
|
[messages, meIdForFeed]
|
|
2675
3110
|
);
|
|
3111
|
+
const [pendingFocusId, setPendingFocusId] = useState(null);
|
|
3112
|
+
const [focusMissing, setFocusMissing] = useState(false);
|
|
3113
|
+
const onFocusNotFoundRef = useRef(onFocusMessageNotFound);
|
|
3114
|
+
onFocusNotFoundRef.current = onFocusMessageNotFound;
|
|
3115
|
+
const conversationIdRef = useRef(conversationId);
|
|
3116
|
+
conversationIdRef.current = conversationId;
|
|
3117
|
+
const focusMiss = useCallback((id) => {
|
|
3118
|
+
setFocusMissing(true);
|
|
3119
|
+
onFocusNotFoundRef.current?.(id);
|
|
3120
|
+
}, []);
|
|
3121
|
+
useEffect(() => {
|
|
3122
|
+
setPendingFocusId(null);
|
|
3123
|
+
setFocusMissing(false);
|
|
3124
|
+
if (!focusMessageId || loading) return;
|
|
3125
|
+
const forConversation = conversationId;
|
|
3126
|
+
let current = true;
|
|
3127
|
+
loadUntil(focusMessageId).then((found) => {
|
|
3128
|
+
if (!current || conversationIdRef.current !== forConversation) return;
|
|
3129
|
+
if (found) setPendingFocusId(focusMessageId);
|
|
3130
|
+
else focusMiss(focusMessageId);
|
|
3131
|
+
}).catch(() => {
|
|
3132
|
+
if (current) focusMiss(focusMessageId);
|
|
3133
|
+
});
|
|
3134
|
+
return () => {
|
|
3135
|
+
current = false;
|
|
3136
|
+
};
|
|
3137
|
+
}, [focusMessageId, conversationId, loading, loadUntil, focusMiss]);
|
|
3138
|
+
useEffect(() => {
|
|
3139
|
+
if (!pendingFocusId) return;
|
|
3140
|
+
const root = listRef.current;
|
|
3141
|
+
const el = root?.querySelector(`[data-message-id="${pendingFocusId}"]`);
|
|
3142
|
+
setPendingFocusId(null);
|
|
3143
|
+
if (!(el instanceof HTMLElement)) {
|
|
3144
|
+
focusMiss(pendingFocusId);
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
highlightRow(el);
|
|
3148
|
+
}, [pendingFocusId, visibleMessages, focusMiss]);
|
|
3149
|
+
useEffect(() => {
|
|
3150
|
+
if (!focusMissing) return;
|
|
3151
|
+
const t = setTimeout(() => setFocusMissing(false), 4e3);
|
|
3152
|
+
return () => clearTimeout(t);
|
|
3153
|
+
}, [focusMissing]);
|
|
2676
3154
|
const receiptsVisible = receiptsOf(me).visible;
|
|
2677
3155
|
const showReadState = readReceipts && receiptsVisible;
|
|
2678
3156
|
const maxReadByOthers = useMemo(() => {
|
|
@@ -2709,33 +3187,31 @@ function ConversationView({
|
|
|
2709
3187
|
if (!root) return;
|
|
2710
3188
|
const el = root.querySelector(`[data-message-id="${id}"]`);
|
|
2711
3189
|
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);
|
|
3190
|
+
highlightRow(el);
|
|
2715
3191
|
};
|
|
2716
3192
|
const composerRef = useRef(null);
|
|
2717
3193
|
const [dragActive, setDragActive] = useState(false);
|
|
2718
3194
|
const dragDepthRef = useRef(0);
|
|
2719
3195
|
const isFileDrag = (e) => Array.from(e.dataTransfer?.types ?? []).includes("Files");
|
|
2720
3196
|
const onDragEnter = (e) => {
|
|
2721
|
-
if (!
|
|
3197
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2722
3198
|
e.preventDefault();
|
|
2723
3199
|
dragDepthRef.current += 1;
|
|
2724
3200
|
setDragActive(true);
|
|
2725
3201
|
};
|
|
2726
3202
|
const onDragOver = (e) => {
|
|
2727
|
-
if (!
|
|
3203
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2728
3204
|
e.preventDefault();
|
|
2729
3205
|
if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
|
|
2730
3206
|
};
|
|
2731
3207
|
const onDragLeave = (e) => {
|
|
2732
|
-
if (!
|
|
3208
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2733
3209
|
e.preventDefault();
|
|
2734
3210
|
dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
|
|
2735
3211
|
if (dragDepthRef.current === 0) setDragActive(false);
|
|
2736
3212
|
};
|
|
2737
3213
|
const onDrop = (e) => {
|
|
2738
|
-
if (!
|
|
3214
|
+
if (!canDrop || !isFileDrag(e)) return;
|
|
2739
3215
|
e.preventDefault();
|
|
2740
3216
|
dragDepthRef.current = 0;
|
|
2741
3217
|
setDragActive(false);
|
|
@@ -2763,7 +3239,7 @@ function ConversationView({
|
|
|
2763
3239
|
onTyping: signalTyping,
|
|
2764
3240
|
attachments,
|
|
2765
3241
|
...labelFor ? { labelFor } : {},
|
|
2766
|
-
...
|
|
3242
|
+
...canQuote ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
2767
3243
|
}
|
|
2768
3244
|
) : /* @__PURE__ */ jsx(
|
|
2769
3245
|
MessageComposer,
|
|
@@ -2773,14 +3249,19 @@ function ConversationView({
|
|
|
2773
3249
|
onTyping: signalTyping,
|
|
2774
3250
|
attachments,
|
|
2775
3251
|
...labelFor ? { labelFor } : {},
|
|
2776
|
-
...
|
|
3252
|
+
...canQuote ? { replyingTo, onCancelReply: () => setReplyingTo(null) } : {}
|
|
2777
3253
|
}
|
|
2778
3254
|
);
|
|
2779
3255
|
return /* @__PURE__ */ jsxs("div", { className: "poolse-conversation-shell", children: [
|
|
2780
3256
|
/* @__PURE__ */ jsxs(
|
|
2781
3257
|
"div",
|
|
2782
3258
|
{
|
|
2783
|
-
className:
|
|
3259
|
+
className: [
|
|
3260
|
+
"poolse-conversation",
|
|
3261
|
+
`poolse-conversation--layout-${layout}`,
|
|
3262
|
+
`poolse-conversation--density-${density}`,
|
|
3263
|
+
dragActive ? "is-drag-active" : ""
|
|
3264
|
+
].filter(Boolean).join(" "),
|
|
2784
3265
|
onDragEnter,
|
|
2785
3266
|
onDragOver,
|
|
2786
3267
|
onDragLeave,
|
|
@@ -2809,6 +3290,7 @@ function ConversationView({
|
|
|
2809
3290
|
]
|
|
2810
3291
|
}
|
|
2811
3292
|
),
|
|
3293
|
+
focusMissing && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__status", role: "status", "aria-live": "polite", children: "That message isn't available." }),
|
|
2812
3294
|
/* @__PURE__ */ jsxs(
|
|
2813
3295
|
"div",
|
|
2814
3296
|
{
|
|
@@ -2821,12 +3303,9 @@ function ConversationView({
|
|
|
2821
3303
|
children: [
|
|
2822
3304
|
hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
2823
3305
|
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." }) : visibleMessages.map((msg, idx) => {
|
|
2824
|
-
if (renderMessage) {
|
|
2825
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|
|
2826
|
-
}
|
|
2827
3306
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
2828
3307
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
2829
|
-
const groupPosition = grouping ? computeGroupPosition(msg, prev, next,
|
|
3308
|
+
const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
2830
3309
|
const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
|
|
2831
3310
|
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
2832
3311
|
const original = messages.find((m) => m.id === msg.quoted_message_id);
|
|
@@ -2845,45 +3324,58 @@ function ConversationView({
|
|
|
2845
3324
|
})() : msg;
|
|
2846
3325
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
2847
3326
|
const readState = showReadState && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
3327
|
+
const renderDefault = () => /* @__PURE__ */ jsx(
|
|
3328
|
+
MessageRow,
|
|
3329
|
+
{
|
|
3330
|
+
msg: enriched,
|
|
3331
|
+
meId: me?.id ?? null,
|
|
3332
|
+
reactions,
|
|
3333
|
+
attachments,
|
|
3334
|
+
actions,
|
|
3335
|
+
threads,
|
|
3336
|
+
quotations: canQuote,
|
|
3337
|
+
groupPosition,
|
|
3338
|
+
maxBodyLength,
|
|
3339
|
+
markdown,
|
|
3340
|
+
showSenderName: showSenderLabelsResolved,
|
|
3341
|
+
showAvatar: showAvatarsResolved,
|
|
3342
|
+
...onSenderPress ? { onSenderPress } : {},
|
|
3343
|
+
...onAvatarPress ? { onAvatarPress } : {},
|
|
3344
|
+
...readState ? { readState } : {},
|
|
3345
|
+
...labelFor ? { labelFor } : {},
|
|
3346
|
+
editing: editingId === msg.id,
|
|
3347
|
+
...canEditOwnMessage({
|
|
3348
|
+
isSelf,
|
|
3349
|
+
deleted: !!msg.deleted_at,
|
|
3350
|
+
receiptsVisible,
|
|
3351
|
+
readState,
|
|
3352
|
+
insertedAt: msg.inserted_at
|
|
3353
|
+
}) ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
3354
|
+
onCancelEdit: () => setEditingId(null),
|
|
3355
|
+
onSaveEdit: async (body) => {
|
|
3356
|
+
await edit(msg.id, body);
|
|
3357
|
+
setEditingId(null);
|
|
3358
|
+
},
|
|
3359
|
+
onDelete: () => void deleteMsg(msg.id),
|
|
3360
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
3361
|
+
onQuote: () => setReplyingTo(msg),
|
|
3362
|
+
onQuotedClick: scrollToOriginal,
|
|
3363
|
+
...onCallBack ? { onCallBack } : {},
|
|
3364
|
+
...layoutProps,
|
|
3365
|
+
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
3366
|
+
}
|
|
3367
|
+
);
|
|
3368
|
+
if (renderMessage) {
|
|
3369
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null, {
|
|
3370
|
+
layout,
|
|
3371
|
+
groupPosition,
|
|
3372
|
+
isRunStart: layout === "compact" || groupPosition === "first" || groupPosition === "standalone",
|
|
3373
|
+
renderDefault
|
|
3374
|
+
}) }, msg.id);
|
|
3375
|
+
}
|
|
2848
3376
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2849
3377
|
showDaySeparator && /* @__PURE__ */ jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
|
|
2850
|
-
|
|
2851
|
-
MessageRow,
|
|
2852
|
-
{
|
|
2853
|
-
msg: enriched,
|
|
2854
|
-
meId: me?.id ?? null,
|
|
2855
|
-
reactions,
|
|
2856
|
-
attachments,
|
|
2857
|
-
actions,
|
|
2858
|
-
threads,
|
|
2859
|
-
quotations,
|
|
2860
|
-
groupPosition,
|
|
2861
|
-
maxBodyLength,
|
|
2862
|
-
markdown,
|
|
2863
|
-
showSenderName: showSenderLabelsResolved,
|
|
2864
|
-
showAvatar: showAvatarsResolved,
|
|
2865
|
-
...readState ? { readState } : {},
|
|
2866
|
-
...labelFor ? { labelFor } : {},
|
|
2867
|
-
editing: editingId === msg.id,
|
|
2868
|
-
...canEditOwnMessage({
|
|
2869
|
-
isSelf,
|
|
2870
|
-
deleted: !!msg.deleted_at,
|
|
2871
|
-
receiptsVisible,
|
|
2872
|
-
readState,
|
|
2873
|
-
insertedAt: msg.inserted_at
|
|
2874
|
-
}) ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
2875
|
-
onCancelEdit: () => setEditingId(null),
|
|
2876
|
-
onSaveEdit: async (body) => {
|
|
2877
|
-
await edit(msg.id, body);
|
|
2878
|
-
setEditingId(null);
|
|
2879
|
-
},
|
|
2880
|
-
onDelete: () => void deleteMsg(msg.id),
|
|
2881
|
-
onOpenThread: () => setThreadRootId(msg.id),
|
|
2882
|
-
onQuote: () => setReplyingTo(msg),
|
|
2883
|
-
onQuotedClick: scrollToOriginal,
|
|
2884
|
-
...onCallBack ? { onCallBack } : {}
|
|
2885
|
-
}
|
|
2886
|
-
)
|
|
3378
|
+
renderDefault()
|
|
2887
3379
|
] }, msg.id);
|
|
2888
3380
|
}),
|
|
2889
3381
|
visibleStreams.map(
|
|
@@ -2899,7 +3391,8 @@ function ConversationView({
|
|
|
2899
3391
|
markdown,
|
|
2900
3392
|
showSenderName: showSenderLabelsResolved,
|
|
2901
3393
|
showAvatar: showAvatarsResolved,
|
|
2902
|
-
...labelFor ? { labelFor } : {}
|
|
3394
|
+
...labelFor ? { labelFor } : {},
|
|
3395
|
+
...layoutProps
|
|
2903
3396
|
}
|
|
2904
3397
|
) }, stream.id)
|
|
2905
3398
|
),
|
|
@@ -2926,7 +3419,7 @@ function ConversationView({
|
|
|
2926
3419
|
}
|
|
2927
3420
|
),
|
|
2928
3421
|
/* @__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 }) }),
|
|
3422
|
+
showComposer && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-row", children: /* @__PURE__ */ jsx("div", { className: "poolse-conversation__composer-flex", children: Composer }) }),
|
|
2930
3423
|
dragActive && /* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { className: "poolse-conversation__drop-overlay-inner", children: [
|
|
2931
3424
|
/* @__PURE__ */ jsx(PoolseIcon, { name: "attachment", size: 40, label: null }),
|
|
2932
3425
|
/* @__PURE__ */ jsx("div", { className: "poolse-conversation__drop-overlay-title", children: "Drop files to upload" }),
|
|
@@ -2940,11 +3433,20 @@ function ConversationView({
|
|
|
2940
3433
|
{
|
|
2941
3434
|
conversationId,
|
|
2942
3435
|
rootMessage: threadRoot,
|
|
2943
|
-
onClose: () => setThreadRootId(null)
|
|
3436
|
+
onClose: () => setThreadRootId(null),
|
|
3437
|
+
layout,
|
|
3438
|
+
...timeFormat ? { timeFormat } : {}
|
|
2944
3439
|
}
|
|
2945
3440
|
) })
|
|
2946
3441
|
] });
|
|
2947
3442
|
}
|
|
3443
|
+
function highlightRow(el) {
|
|
3444
|
+
if (typeof el.scrollIntoView === "function") {
|
|
3445
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
3446
|
+
}
|
|
3447
|
+
el.classList.add("poolse-message-row--highlight");
|
|
3448
|
+
setTimeout(() => el.classList.remove("poolse-message-row--highlight"), 1600);
|
|
3449
|
+
}
|
|
2948
3450
|
function JoinBanner({
|
|
2949
3451
|
conversationId,
|
|
2950
3452
|
meId,
|
|
@@ -3842,6 +4344,61 @@ function useElapsed(startedAt, running) {
|
|
|
3842
4344
|
const s = String(total % 60).padStart(2, "0");
|
|
3843
4345
|
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
3844
4346
|
}
|
|
4347
|
+
var ThemeContext = createContext(null);
|
|
4348
|
+
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
4349
|
+
function systemScheme() {
|
|
4350
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "light";
|
|
4351
|
+
return window.matchMedia(DARK_QUERY).matches ? "dark" : "light";
|
|
4352
|
+
}
|
|
4353
|
+
function useSystemColorScheme() {
|
|
4354
|
+
const [scheme, setScheme] = useState(systemScheme);
|
|
4355
|
+
useEffect(() => {
|
|
4356
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
4357
|
+
const mql = window.matchMedia(DARK_QUERY);
|
|
4358
|
+
const onChange = () => setScheme(mql.matches ? "dark" : "light");
|
|
4359
|
+
onChange();
|
|
4360
|
+
if (typeof mql.addEventListener === "function") {
|
|
4361
|
+
mql.addEventListener("change", onChange);
|
|
4362
|
+
return () => mql.removeEventListener("change", onChange);
|
|
4363
|
+
}
|
|
4364
|
+
mql.addListener(onChange);
|
|
4365
|
+
return () => mql.removeListener(onChange);
|
|
4366
|
+
}, []);
|
|
4367
|
+
return scheme;
|
|
4368
|
+
}
|
|
4369
|
+
function PoolseTheme({
|
|
4370
|
+
theme,
|
|
4371
|
+
colorScheme = "system",
|
|
4372
|
+
className,
|
|
4373
|
+
style,
|
|
4374
|
+
children
|
|
4375
|
+
}) {
|
|
4376
|
+
const system = useSystemColorScheme();
|
|
4377
|
+
const scheme = colorScheme === "system" ? system : colorScheme;
|
|
4378
|
+
const value = useMemo(
|
|
4379
|
+
() => ({ theme: theme ? resolveTheme(theme, scheme) : null, colorScheme: scheme }),
|
|
4380
|
+
[theme, scheme]
|
|
4381
|
+
);
|
|
4382
|
+
const vars = useMemo(
|
|
4383
|
+
() => value.theme ? tokensToCssVariables(value.theme) : null,
|
|
4384
|
+
[value.theme]
|
|
4385
|
+
);
|
|
4386
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
4387
|
+
"div",
|
|
4388
|
+
{
|
|
4389
|
+
className: className ? `poolse-theme ${className}` : "poolse-theme",
|
|
4390
|
+
"data-theme": scheme,
|
|
4391
|
+
"data-poolse-theme": value.theme?.id,
|
|
4392
|
+
style: vars || style ? { ...vars, ...style } : void 0,
|
|
4393
|
+
children
|
|
4394
|
+
}
|
|
4395
|
+
) });
|
|
4396
|
+
}
|
|
4397
|
+
function useTheme() {
|
|
4398
|
+
const value = useContext(ThemeContext);
|
|
4399
|
+
const system = useSystemColorScheme();
|
|
4400
|
+
return value ?? { theme: null, colorScheme: system };
|
|
4401
|
+
}
|
|
3845
4402
|
var MARK_PATHS = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3846
4403
|
/* @__PURE__ */ jsx(
|
|
3847
4404
|
"path",
|
|
@@ -3950,6 +4507,6 @@ function PoolseLogo({
|
|
|
3950
4507
|
);
|
|
3951
4508
|
}
|
|
3952
4509
|
|
|
3953
|
-
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, GroupDetailsSheet, LiveCallBanner, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, ReactionPicker, ReactionStrip, RoomJoinBar, RoomStage, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, useDisplayName, usePoolseFonts };
|
|
4510
|
+
export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, GroupDetailsSheet, LiveCallBanner, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, ReactionPicker, ReactionStrip, RoomJoinBar, RoomStage, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, useDisplayName, usePoolseFonts, useSystemColorScheme, useTheme };
|
|
3954
4511
|
//# sourceMappingURL=index.js.map
|
|
3955
4512
|
//# sourceMappingURL=index.js.map
|