@poolse/react-ui 3.3.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 +49 -0
- package/README.md +43 -1
- package/dist/index.cjs +664 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -10
- package/dist/index.d.ts +148 -10
- package/dist/index.js +645 -179
- package/dist/index.js.map +1 -1
- package/dist/styles.css +388 -7
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var react$1 = require('@poolse/react');
|
|
7
7
|
var ReactMarkdown = require('react-markdown');
|
|
8
8
|
var remarkGfm = require('remark-gfm');
|
|
9
|
+
var theme = require('@poolse/theme');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -751,6 +752,31 @@ function PoolseFonts() {
|
|
|
751
752
|
usePoolseFonts(true);
|
|
752
753
|
return null;
|
|
753
754
|
}
|
|
755
|
+
|
|
756
|
+
// src/layout.ts
|
|
757
|
+
function formatMessageTime(iso, format) {
|
|
758
|
+
if (!iso) return "";
|
|
759
|
+
const date = new Date(iso);
|
|
760
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
761
|
+
if (typeof format === "function") return format(date);
|
|
762
|
+
if (format === "12h") {
|
|
763
|
+
return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit", hour12: true });
|
|
764
|
+
}
|
|
765
|
+
if (format === "24h") {
|
|
766
|
+
return date.toLocaleTimeString(void 0, {
|
|
767
|
+
hour: "2-digit",
|
|
768
|
+
minute: "2-digit",
|
|
769
|
+
hourCycle: "h23"
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
return date.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
773
|
+
}
|
|
774
|
+
function mentionsViewer(msg, meId) {
|
|
775
|
+
return meId !== null && msg.sender_id !== meId && (msg.mentions ?? []).includes(meId);
|
|
776
|
+
}
|
|
777
|
+
function renderSlot(slot, ctx, children) {
|
|
778
|
+
return slot && ctx ? slot({ ...ctx, children }) : children;
|
|
779
|
+
}
|
|
754
780
|
function LiveCallBanner({ call, inCall, onJoin }) {
|
|
755
781
|
const what = call.kind === "room" ? call.media === "video" ? "Video room" : "Voice room" : call.media === "video" ? "Video call in progress" : "Voice call in progress";
|
|
756
782
|
const who = inCall > 0 ? `${inCall} ${call.kind === "room" ? "in the room" : "on the call"}` : call.kind === "room" ? "Starting" : "Ringing";
|
|
@@ -1644,7 +1670,10 @@ function MessageBubble({
|
|
|
1644
1670
|
showSenderName = false,
|
|
1645
1671
|
onSenderPress,
|
|
1646
1672
|
actionsTrigger,
|
|
1647
|
-
showAttachments = true
|
|
1673
|
+
showAttachments = true,
|
|
1674
|
+
timeFormat,
|
|
1675
|
+
slots,
|
|
1676
|
+
slotContext
|
|
1648
1677
|
}) {
|
|
1649
1678
|
const isSelf = currentUserId !== null && message.sender_id === currentUserId;
|
|
1650
1679
|
const [expanded, setExpanded] = react.useState(false);
|
|
@@ -1655,8 +1684,8 @@ function MessageBubble({
|
|
|
1655
1684
|
const senderColorHex = senderColorKey ? userColor(senderColorKey) : "currentColor";
|
|
1656
1685
|
const renderSenderName = showSenderName && !isSelf && (groupPosition === "first" || groupPosition === "standalone");
|
|
1657
1686
|
const rawBody = message.body ?? "";
|
|
1658
|
-
const
|
|
1659
|
-
const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength +
|
|
1687
|
+
const TRIM_BUFFER2 = 40;
|
|
1688
|
+
const shouldTrim = !expanded && maxBodyLength > 0 && rawBody.length > maxBodyLength + TRIM_BUFFER2;
|
|
1660
1689
|
const displayBody = shouldTrim ? rawBody.slice(0, maxBodyLength).trimEnd() + "\u2026" : rawBody;
|
|
1661
1690
|
const attachmentList = showAttachments && !message.deleted_at && Array.isArray(message.attachments) ? message.attachments : [];
|
|
1662
1691
|
const imageAttachments = attachmentList.filter((a) => isImageContentType(a.content_type));
|
|
@@ -1665,7 +1694,7 @@ function MessageBubble({
|
|
|
1665
1694
|
const hasVisibleBody = !message.deleted_at && rawBody.length > 0;
|
|
1666
1695
|
const metaOverlay = hasAnyAttachment && imageAttachments.length > 0 && !hasVisibleBody && fileAttachments.length === 0;
|
|
1667
1696
|
const jumboCount = hasVisibleBody && !hasAnyAttachment && !message.quoted_message_id ? emojiOnlyCount(rawBody) : 0;
|
|
1668
|
-
const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength +
|
|
1697
|
+
const trimToggleVisible = shouldTrim || expanded && rawBody.length > maxBodyLength + TRIM_BUFFER2;
|
|
1669
1698
|
const inlineMeta = hasVisibleBody && jumboCount === 0 && !trimToggleVisible && (!markdown || !hasMarkdown(displayBody));
|
|
1670
1699
|
const className = [
|
|
1671
1700
|
"poolse-message",
|
|
@@ -1679,23 +1708,24 @@ function MessageBubble({
|
|
|
1679
1708
|
metaOverlay ? "poolse-message--media-only" : "",
|
|
1680
1709
|
jumboCount > 0 ? "poolse-message--jumbo" : ""
|
|
1681
1710
|
].filter(Boolean).join(" ");
|
|
1682
|
-
const time =
|
|
1683
|
-
hour: "2-digit",
|
|
1684
|
-
minute: "2-digit"
|
|
1685
|
-
}) : "";
|
|
1711
|
+
const time = formatMessageTime(message.inserted_at, timeFormat);
|
|
1686
1712
|
const showQuoteCard = message.quoted_message !== void 0 && message.quoted_message !== null ? "full" : message.quoted_message_id ? "placeholder" : null;
|
|
1687
1713
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
|
|
1688
1714
|
actionsTrigger,
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1715
|
+
renderSlot(
|
|
1716
|
+
slots?.header,
|
|
1717
|
+
slotContext,
|
|
1718
|
+
renderSenderName ? onSenderPress ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1719
|
+
"button",
|
|
1720
|
+
{
|
|
1721
|
+
type: "button",
|
|
1722
|
+
className: "poolse-message__sender poolse-message__sender--button",
|
|
1723
|
+
style: { color: senderColorHex },
|
|
1724
|
+
onClick: onSenderPress,
|
|
1725
|
+
children: senderName
|
|
1726
|
+
}
|
|
1727
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__sender", style: { color: senderColorHex }, children: senderName }) : null
|
|
1728
|
+
),
|
|
1699
1729
|
showQuoteCard === "full" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1700
1730
|
QuotedCard,
|
|
1701
1731
|
{
|
|
@@ -1706,8 +1736,14 @@ function MessageBubble({
|
|
|
1706
1736
|
}
|
|
1707
1737
|
),
|
|
1708
1738
|
showQuoteCard === "placeholder" && /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf, quotedMessageId: message.quoted_message_id }),
|
|
1709
|
-
|
|
1710
|
-
|
|
1739
|
+
renderSlot(
|
|
1740
|
+
slots?.attachments,
|
|
1741
|
+
slotContext,
|
|
1742
|
+
hasAnyAttachment ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1743
|
+
imageAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { images: imageAttachments }),
|
|
1744
|
+
fileAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__files", children: fileAttachments.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) })
|
|
1745
|
+
] }) : null
|
|
1746
|
+
),
|
|
1711
1747
|
(() => {
|
|
1712
1748
|
const metaContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1713
1749
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: time }),
|
|
@@ -1764,7 +1800,7 @@ function MessageBubble({
|
|
|
1764
1800
|
children: "Read more"
|
|
1765
1801
|
}
|
|
1766
1802
|
),
|
|
1767
|
-
!shouldTrim && expanded && rawBody.length > maxBodyLength +
|
|
1803
|
+
!shouldTrim && expanded && rawBody.length > maxBodyLength + TRIM_BUFFER2 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1768
1804
|
"button",
|
|
1769
1805
|
{
|
|
1770
1806
|
type: "button",
|
|
@@ -1781,7 +1817,7 @@ function MessageBubble({
|
|
|
1781
1817
|
) : null;
|
|
1782
1818
|
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";
|
|
1783
1819
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1784
|
-
body,
|
|
1820
|
+
renderSlot(slots?.body, slotContext, body),
|
|
1785
1821
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: metaClass, children: metaContent })
|
|
1786
1822
|
] });
|
|
1787
1823
|
})()
|
|
@@ -2069,9 +2105,12 @@ function MessageActions({
|
|
|
2069
2105
|
onCopy,
|
|
2070
2106
|
onEdit,
|
|
2071
2107
|
onDelete,
|
|
2108
|
+
moreMenu = false,
|
|
2072
2109
|
children
|
|
2073
2110
|
}) {
|
|
2074
2111
|
const [pickerOpen, setPickerOpen] = react.useState(false);
|
|
2112
|
+
const [menuOpen, setMenuOpen] = react.useState(false);
|
|
2113
|
+
const hasMore = !!(onCopy || onEdit || onDelete);
|
|
2075
2114
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-msg-actions", role: "toolbar", "aria-label": "Message actions", children: [
|
|
2076
2115
|
onReact && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2077
2116
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2094,12 +2133,60 @@ function MessageActions({
|
|
|
2094
2133
|
}
|
|
2095
2134
|
) })
|
|
2096
2135
|
] }),
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2136
|
+
moreMenu ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2137
|
+
onQuote && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
2138
|
+
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
2139
|
+
children,
|
|
2140
|
+
hasMore && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2141
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2142
|
+
ActionButton,
|
|
2143
|
+
{
|
|
2144
|
+
label: "More actions",
|
|
2145
|
+
icon: "more-h",
|
|
2146
|
+
onClick: () => setMenuOpen((o) => !o),
|
|
2147
|
+
active: menuOpen
|
|
2148
|
+
}
|
|
2149
|
+
),
|
|
2150
|
+
menuOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2151
|
+
"div",
|
|
2152
|
+
{
|
|
2153
|
+
className: "poolse-msg-actions__menu",
|
|
2154
|
+
role: "menu",
|
|
2155
|
+
onKeyDown: (e) => {
|
|
2156
|
+
if (e.key === "Escape") setMenuOpen(false);
|
|
2157
|
+
},
|
|
2158
|
+
children: [
|
|
2159
|
+
onCopy && { label: "Copy", icon: "copy", run: onCopy },
|
|
2160
|
+
onEdit && { label: "Edit", icon: "edit", run: onEdit },
|
|
2161
|
+
onDelete && { label: "Delete", icon: "trash", run: onDelete }
|
|
2162
|
+
].filter((item) => !!item).map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2163
|
+
"button",
|
|
2164
|
+
{
|
|
2165
|
+
type: "button",
|
|
2166
|
+
role: "menuitem",
|
|
2167
|
+
className: `poolse-msg-actions__menu-item${item.label === "Delete" ? " poolse-msg-actions__menu-item--danger" : ""}`,
|
|
2168
|
+
onClick: () => {
|
|
2169
|
+
setMenuOpen(false);
|
|
2170
|
+
item.run();
|
|
2171
|
+
},
|
|
2172
|
+
children: [
|
|
2173
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: item.icon, size: 15, label: null }),
|
|
2174
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
|
|
2175
|
+
]
|
|
2176
|
+
},
|
|
2177
|
+
item.label
|
|
2178
|
+
))
|
|
2179
|
+
}
|
|
2180
|
+
)
|
|
2181
|
+
] })
|
|
2182
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2183
|
+
onReply && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply in thread", icon: "messages", onClick: onReply }),
|
|
2184
|
+
onQuote && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Reply", icon: "reply", onClick: onQuote }),
|
|
2185
|
+
onCopy && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Copy", icon: "copy", onClick: onCopy }),
|
|
2186
|
+
onEdit && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Edit", icon: "edit", onClick: onEdit }),
|
|
2187
|
+
onDelete && /* @__PURE__ */ jsxRuntime.jsx(ActionButton, { label: "Delete", icon: "trash", danger: true, onClick: onDelete }),
|
|
2188
|
+
children
|
|
2189
|
+
] })
|
|
2103
2190
|
] });
|
|
2104
2191
|
}
|
|
2105
2192
|
function ActionButton({
|
|
@@ -2116,6 +2203,319 @@ function ActionButton({
|
|
|
2116
2203
|
].filter(Boolean).join(" ");
|
|
2117
2204
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: classes, "aria-label": label, title: label, onClick, children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: 16, label: null }) });
|
|
2118
2205
|
}
|
|
2206
|
+
function useRowActions() {
|
|
2207
|
+
const [actionsOpen, setActionsOpen] = react.useState(false);
|
|
2208
|
+
const rowRef = react.useRef(null);
|
|
2209
|
+
react.useEffect(() => {
|
|
2210
|
+
if (!actionsOpen) return;
|
|
2211
|
+
const onDown = (e) => {
|
|
2212
|
+
const t = e.target;
|
|
2213
|
+
if (t instanceof Node && rowRef.current && !rowRef.current.contains(t)) {
|
|
2214
|
+
setActionsOpen(false);
|
|
2215
|
+
}
|
|
2216
|
+
};
|
|
2217
|
+
document.addEventListener("pointerdown", onDown);
|
|
2218
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
2219
|
+
}, [actionsOpen]);
|
|
2220
|
+
const onRowClick = (e) => {
|
|
2221
|
+
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
2222
|
+
const target = e.target;
|
|
2223
|
+
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
2224
|
+
setActionsOpen((o) => !o);
|
|
2225
|
+
};
|
|
2226
|
+
return { actionsOpen, setActionsOpen, rowRef, onRowClick };
|
|
2227
|
+
}
|
|
2228
|
+
function InlineReactions({
|
|
2229
|
+
reactions,
|
|
2230
|
+
currentUserId,
|
|
2231
|
+
onAdd,
|
|
2232
|
+
onRemove
|
|
2233
|
+
}) {
|
|
2234
|
+
const entries = Object.entries(reactions);
|
|
2235
|
+
if (entries.length === 0) return null;
|
|
2236
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-reactions", children: entries.map(([emoji, users]) => {
|
|
2237
|
+
const mine = currentUserId !== null && currentUserId !== void 0 && users.includes(currentUserId);
|
|
2238
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2239
|
+
"button",
|
|
2240
|
+
{
|
|
2241
|
+
type: "button",
|
|
2242
|
+
className: `poolse-reaction-pill${mine ? " poolse-reaction-pill--mine" : ""}`,
|
|
2243
|
+
onClick: () => {
|
|
2244
|
+
if (mine) onRemove(emoji);
|
|
2245
|
+
else onAdd(emoji);
|
|
2246
|
+
},
|
|
2247
|
+
"aria-pressed": mine,
|
|
2248
|
+
"aria-label": `${emoji} reacted by ${users.length} ${users.length === 1 ? "user" : "users"}`,
|
|
2249
|
+
children: [
|
|
2250
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: emoji }),
|
|
2251
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-reaction-pill__count", children: users.length })
|
|
2252
|
+
]
|
|
2253
|
+
},
|
|
2254
|
+
emoji
|
|
2255
|
+
);
|
|
2256
|
+
}) });
|
|
2257
|
+
}
|
|
2258
|
+
var TRIM_BUFFER = 40;
|
|
2259
|
+
function FlatMessageRow({
|
|
2260
|
+
msg,
|
|
2261
|
+
meId,
|
|
2262
|
+
layout,
|
|
2263
|
+
reactions = true,
|
|
2264
|
+
attachments = true,
|
|
2265
|
+
actions = true,
|
|
2266
|
+
threads = true,
|
|
2267
|
+
quotations = true,
|
|
2268
|
+
readState,
|
|
2269
|
+
editing = false,
|
|
2270
|
+
onStartEdit,
|
|
2271
|
+
onCancelEdit,
|
|
2272
|
+
onSaveEdit,
|
|
2273
|
+
onDelete,
|
|
2274
|
+
onOpenThread,
|
|
2275
|
+
onQuote,
|
|
2276
|
+
labelFor,
|
|
2277
|
+
onQuotedClick,
|
|
2278
|
+
groupPosition = "standalone",
|
|
2279
|
+
maxBodyLength = 0,
|
|
2280
|
+
markdown = false,
|
|
2281
|
+
showAvatar = layout === "list",
|
|
2282
|
+
onSenderPress,
|
|
2283
|
+
onAvatarPress,
|
|
2284
|
+
timeFormat,
|
|
2285
|
+
slots,
|
|
2286
|
+
mentionsMe = false
|
|
2287
|
+
}) {
|
|
2288
|
+
const compact = layout === "compact";
|
|
2289
|
+
const isSelf = meId !== null && msg.sender_id === meId;
|
|
2290
|
+
const { profile } = react$1.useUser(msg.sender_external_id);
|
|
2291
|
+
const senderName = profile?.displayName ?? msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
2292
|
+
const sender = {
|
|
2293
|
+
userId: msg.sender_id,
|
|
2294
|
+
externalId: msg.sender_external_id,
|
|
2295
|
+
displayName: senderName,
|
|
2296
|
+
avatarUrl: profile?.avatarUrl ?? null
|
|
2297
|
+
};
|
|
2298
|
+
const isRunStart = compact || groupPosition === "first" || groupPosition === "standalone";
|
|
2299
|
+
const ctx = { message: msg, isSelf, sender, layout, isRunStart };
|
|
2300
|
+
const reactionsHook = react$1.useReactions(reactions ? msg.id : "", {
|
|
2301
|
+
conversationId: msg.conversation_id,
|
|
2302
|
+
initialReactions: msg.reactions,
|
|
2303
|
+
currentUserId: meId
|
|
2304
|
+
});
|
|
2305
|
+
const { actionsOpen, rowRef, onRowClick } = useRowActions();
|
|
2306
|
+
const deleted = !!msg.deleted_at;
|
|
2307
|
+
const time = formatMessageTime(msg.inserted_at, timeFormat);
|
|
2308
|
+
const replyCount = msg.reply_count ?? 0;
|
|
2309
|
+
const showThreadLink = threads && !deleted && !msg.thread_root_id && replyCount > 0;
|
|
2310
|
+
const showActions = actions && !deleted && !editing;
|
|
2311
|
+
const timeEl = (className) => /* @__PURE__ */ jsxRuntime.jsx("time", { className, dateTime: msg.inserted_at, children: time });
|
|
2312
|
+
const avatarSize = compact ? "sm" : "md";
|
|
2313
|
+
const avatar = !showAvatar ? null : onAvatarPress && !isSelf ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2314
|
+
"button",
|
|
2315
|
+
{
|
|
2316
|
+
type: "button",
|
|
2317
|
+
className: "poolse-row__avatar-button",
|
|
2318
|
+
"aria-label": senderName,
|
|
2319
|
+
onClick: () => onAvatarPress(sender),
|
|
2320
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: sender.avatarUrl, name: senderName, size: avatarSize })
|
|
2321
|
+
}
|
|
2322
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: sender.avatarUrl, name: senderName, size: avatarSize });
|
|
2323
|
+
const nameStyle = compact ? { color: userColor(msg.sender_external_id ?? msg.sender_id ?? "") } : void 0;
|
|
2324
|
+
const name = onSenderPress && !isSelf ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2325
|
+
"button",
|
|
2326
|
+
{
|
|
2327
|
+
type: "button",
|
|
2328
|
+
className: "poolse-row__name poolse-row__name--button",
|
|
2329
|
+
style: nameStyle,
|
|
2330
|
+
onClick: () => onSenderPress(sender),
|
|
2331
|
+
children: senderName
|
|
2332
|
+
}
|
|
2333
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-row__name", style: nameStyle, children: senderName });
|
|
2334
|
+
const header = compact ? name : isRunStart ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-row__header", children: [
|
|
2335
|
+
name,
|
|
2336
|
+
timeEl("poolse-row__time")
|
|
2337
|
+
] }) : null;
|
|
2338
|
+
const quote = msg.quoted_message !== void 0 && msg.quoted_message !== null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2339
|
+
QuotedCard,
|
|
2340
|
+
{
|
|
2341
|
+
quoted: msg.quoted_message,
|
|
2342
|
+
isSelf: false,
|
|
2343
|
+
...labelFor ? { labelFor } : {},
|
|
2344
|
+
...onQuotedClick ? { onClick: onQuotedClick } : {}
|
|
2345
|
+
}
|
|
2346
|
+
) : msg.quoted_message_id ? /* @__PURE__ */ jsxRuntime.jsx(QuotedPlaceholder, { isSelf: false, quotedMessageId: msg.quoted_message_id }) : null;
|
|
2347
|
+
const attachmentList = attachments && !deleted && Array.isArray(msg.attachments) ? msg.attachments : [];
|
|
2348
|
+
const images = attachmentList.filter((a) => isImageContentType(a.content_type));
|
|
2349
|
+
const files = attachmentList.filter((a) => !isImageContentType(a.content_type));
|
|
2350
|
+
const attachmentsEl = images.length > 0 || files.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-row__attachments", children: [
|
|
2351
|
+
images.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ImageMosaic, { images }),
|
|
2352
|
+
files.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__files", children: files.map((att) => /* @__PURE__ */ jsxRuntime.jsx(AttachmentPreview, { attachment: att }, att.id)) })
|
|
2353
|
+
] }) : null;
|
|
2354
|
+
const meta = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2355
|
+
msg.edited_at && !deleted ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-row__edited", children: "(edited)" }) : null,
|
|
2356
|
+
isSelf && readState ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-row__receipt", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2357
|
+
PoolseIcon,
|
|
2358
|
+
{
|
|
2359
|
+
name: readState === "read" ? "check-double" : "check",
|
|
2360
|
+
size: 14,
|
|
2361
|
+
label: readState === "read" ? "Read" : "Sent"
|
|
2362
|
+
}
|
|
2363
|
+
) }) : null
|
|
2364
|
+
] });
|
|
2365
|
+
const body = editing ? (
|
|
2366
|
+
// `currentUserId={null}` styles the editor as a neutral card rather
|
|
2367
|
+
// than an own-message bubble, which would look out of place in a row.
|
|
2368
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2369
|
+
EditableMessageBubble,
|
|
2370
|
+
{
|
|
2371
|
+
message: msg,
|
|
2372
|
+
currentUserId: null,
|
|
2373
|
+
editing: true,
|
|
2374
|
+
onSave: onSaveEdit ?? (async () => void 0),
|
|
2375
|
+
onCancel: onCancelEdit ?? (() => void 0)
|
|
2376
|
+
}
|
|
2377
|
+
)
|
|
2378
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2379
|
+
FlatBody,
|
|
2380
|
+
{
|
|
2381
|
+
message: msg,
|
|
2382
|
+
markdown,
|
|
2383
|
+
maxBodyLength,
|
|
2384
|
+
hasAttachments: attachmentList.length > 0,
|
|
2385
|
+
meta
|
|
2386
|
+
}
|
|
2387
|
+
);
|
|
2388
|
+
const reactionsEl = reactions && !deleted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2389
|
+
InlineReactions,
|
|
2390
|
+
{
|
|
2391
|
+
reactions: reactionsHook.reactions,
|
|
2392
|
+
currentUserId: meId,
|
|
2393
|
+
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
2394
|
+
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
2395
|
+
}
|
|
2396
|
+
) : null;
|
|
2397
|
+
const threadEl = showThreadLink ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2398
|
+
"button",
|
|
2399
|
+
{
|
|
2400
|
+
type: "button",
|
|
2401
|
+
className: "poolse-row__thread",
|
|
2402
|
+
onClick: onOpenThread,
|
|
2403
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2404
|
+
children: [
|
|
2405
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 14, label: null }),
|
|
2406
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
2407
|
+
replyCount,
|
|
2408
|
+
" ",
|
|
2409
|
+
replyCount === 1 ? "reply" : "replies"
|
|
2410
|
+
] })
|
|
2411
|
+
]
|
|
2412
|
+
}
|
|
2413
|
+
) : null;
|
|
2414
|
+
const toolbar = showActions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-row__toolbar", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2415
|
+
MessageActions,
|
|
2416
|
+
{
|
|
2417
|
+
moreMenu: true,
|
|
2418
|
+
...reactions ? { onReact: (emoji) => void reactionsHook.addReaction(emoji) } : {},
|
|
2419
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
2420
|
+
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
2421
|
+
...msg.body ? {
|
|
2422
|
+
onCopy: () => {
|
|
2423
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
2424
|
+
}
|
|
2425
|
+
} : {},
|
|
2426
|
+
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
2427
|
+
...isSelf && onDelete ? { onDelete } : {}
|
|
2428
|
+
}
|
|
2429
|
+
) }) : null;
|
|
2430
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-row__content", children: [
|
|
2431
|
+
!compact && renderSlot(slots?.header, ctx, header),
|
|
2432
|
+
quote,
|
|
2433
|
+
renderSlot(slots?.attachments, ctx, attachmentsEl),
|
|
2434
|
+
renderSlot(slots?.body, ctx, body),
|
|
2435
|
+
renderSlot(slots?.reactions, ctx, reactionsEl),
|
|
2436
|
+
renderSlot(slots?.thread, ctx, threadEl)
|
|
2437
|
+
] });
|
|
2438
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2439
|
+
"div",
|
|
2440
|
+
{
|
|
2441
|
+
ref: rowRef,
|
|
2442
|
+
className: [
|
|
2443
|
+
"poolse-row",
|
|
2444
|
+
`poolse-row--${layout}`,
|
|
2445
|
+
isRunStart ? "poolse-row--run-start" : "poolse-row--continued",
|
|
2446
|
+
isSelf ? "poolse-row--self" : "",
|
|
2447
|
+
mentionsMe ? "poolse-row--mention" : "",
|
|
2448
|
+
editing ? "poolse-row--editing" : ""
|
|
2449
|
+
].filter(Boolean).join(" "),
|
|
2450
|
+
"data-message-id": msg.id,
|
|
2451
|
+
"data-actions-open": actionsOpen || void 0,
|
|
2452
|
+
onClick: onRowClick,
|
|
2453
|
+
children: [
|
|
2454
|
+
compact ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2455
|
+
timeEl("poolse-row__time"),
|
|
2456
|
+
avatar ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-row__avatar", children: avatar }) : null,
|
|
2457
|
+
renderSlot(slots?.header, ctx, header),
|
|
2458
|
+
content
|
|
2459
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2460
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-row__gutter", children: isRunStart ? avatar : timeEl("poolse-row__gutter-time") }),
|
|
2461
|
+
content
|
|
2462
|
+
] }),
|
|
2463
|
+
renderSlot(slots?.actions, ctx, toolbar)
|
|
2464
|
+
]
|
|
2465
|
+
}
|
|
2466
|
+
);
|
|
2467
|
+
}
|
|
2468
|
+
function FlatBody({
|
|
2469
|
+
message,
|
|
2470
|
+
markdown,
|
|
2471
|
+
maxBodyLength,
|
|
2472
|
+
hasAttachments,
|
|
2473
|
+
meta
|
|
2474
|
+
}) {
|
|
2475
|
+
const [expanded, setExpanded] = react.useState(false);
|
|
2476
|
+
if (message.deleted_at) {
|
|
2477
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-message__body poolse-row__body", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--deleted", children: "Message deleted" }) });
|
|
2478
|
+
}
|
|
2479
|
+
const raw = message.body ?? "";
|
|
2480
|
+
if (!raw) {
|
|
2481
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-row__meta-only", children: meta });
|
|
2482
|
+
}
|
|
2483
|
+
const long = maxBodyLength > 0 && raw.length > maxBodyLength + TRIM_BUFFER;
|
|
2484
|
+
const shown = long && !expanded ? raw.slice(0, maxBodyLength).trimEnd() + "\u2026" : raw;
|
|
2485
|
+
const jumbo = !hasAttachments && !message.quoted_message_id ? emojiOnlyCount(raw) : 0;
|
|
2486
|
+
const md = markdown && jumbo === 0 && hasMarkdown(shown);
|
|
2487
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2488
|
+
"div",
|
|
2489
|
+
{
|
|
2490
|
+
className: md ? "poolse-message__body poolse-message__body--md poolse-row__body" : "poolse-message__body poolse-row__body",
|
|
2491
|
+
children: [
|
|
2492
|
+
jumbo > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-message__body--jumbo", style: { fontSize: emojiFontSize(jumbo) }, children: shown }) : md ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2493
|
+
ReactMarkdown__default.default,
|
|
2494
|
+
{
|
|
2495
|
+
remarkPlugins: [remarkGfm__default.default],
|
|
2496
|
+
components: {
|
|
2497
|
+
a: ({ node: _node, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("a", { ...props, target: "_blank", rel: "noopener noreferrer nofollow" })
|
|
2498
|
+
},
|
|
2499
|
+
children: shown
|
|
2500
|
+
}
|
|
2501
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: shown }),
|
|
2502
|
+
long && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2503
|
+
"button",
|
|
2504
|
+
{
|
|
2505
|
+
type: "button",
|
|
2506
|
+
className: "poolse-message__read-more",
|
|
2507
|
+
onClick: (e) => {
|
|
2508
|
+
e.stopPropagation();
|
|
2509
|
+
setExpanded((x) => !x);
|
|
2510
|
+
},
|
|
2511
|
+
children: expanded ? "Show less" : "Read more"
|
|
2512
|
+
}
|
|
2513
|
+
),
|
|
2514
|
+
meta
|
|
2515
|
+
]
|
|
2516
|
+
}
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2119
2519
|
function MessageRow(props) {
|
|
2120
2520
|
const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
|
|
2121
2521
|
if (callLog !== void 0) {
|
|
@@ -2128,6 +2528,9 @@ function MessageRow(props) {
|
|
|
2128
2528
|
}
|
|
2129
2529
|
) : null;
|
|
2130
2530
|
}
|
|
2531
|
+
if (props.layout === "list" || props.layout === "compact") {
|
|
2532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FlatMessageRow, { ...props, layout: props.layout });
|
|
2533
|
+
}
|
|
2131
2534
|
return /* @__PURE__ */ jsxRuntime.jsx(BubbleMessageRow, { ...props });
|
|
2132
2535
|
}
|
|
2133
2536
|
function BubbleMessageRow({
|
|
@@ -2154,7 +2557,9 @@ function BubbleMessageRow({
|
|
|
2154
2557
|
showSenderName = false,
|
|
2155
2558
|
showAvatar = false,
|
|
2156
2559
|
onSenderPress,
|
|
2157
|
-
onAvatarPress
|
|
2560
|
+
onAvatarPress,
|
|
2561
|
+
timeFormat,
|
|
2562
|
+
slots
|
|
2158
2563
|
}) {
|
|
2159
2564
|
const { profile: senderProfile } = react$1.useUser(msg.sender_external_id);
|
|
2160
2565
|
const senderFallbackName = msg.sender_external_id ?? (msg.sender_id ? `User ${msg.sender_id.slice(0, 6)}` : "Unknown");
|
|
@@ -2177,24 +2582,13 @@ function BubbleMessageRow({
|
|
|
2177
2582
|
const showThreadPill = threads && !msg.deleted_at && !msg.thread_root_id && replyCount > 0;
|
|
2178
2583
|
const handleSave = onSaveEdit ?? (async () => void 0);
|
|
2179
2584
|
const handleCancel = onCancelEdit ?? (() => void 0);
|
|
2180
|
-
const
|
|
2181
|
-
const
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
setActionsOpen(false);
|
|
2188
|
-
}
|
|
2189
|
-
};
|
|
2190
|
-
document.addEventListener("pointerdown", onDown);
|
|
2191
|
-
return () => document.removeEventListener("pointerdown", onDown);
|
|
2192
|
-
}, [actionsOpen]);
|
|
2193
|
-
const onRowClick = (e) => {
|
|
2194
|
-
if (typeof window === "undefined" || !window.matchMedia("(hover: none)").matches) return;
|
|
2195
|
-
const target = e.target;
|
|
2196
|
-
if (target.closest("a, button, input, textarea, label, select")) return;
|
|
2197
|
-
setActionsOpen((o) => !o);
|
|
2585
|
+
const { actionsOpen, setActionsOpen, rowRef, onRowClick } = useRowActions();
|
|
2586
|
+
const slotContext = {
|
|
2587
|
+
message: msg,
|
|
2588
|
+
isSelf,
|
|
2589
|
+
sender,
|
|
2590
|
+
layout: "bubbles",
|
|
2591
|
+
isRunStart: groupPosition === "first" || groupPosition === "standalone"
|
|
2198
2592
|
};
|
|
2199
2593
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2200
2594
|
"div",
|
|
@@ -2247,6 +2641,8 @@ function BubbleMessageRow({
|
|
|
2247
2641
|
...readState ? { readState } : {},
|
|
2248
2642
|
...labelFor ? { labelFor } : {},
|
|
2249
2643
|
...onQuotedClick ? { onQuotedClick } : {},
|
|
2644
|
+
...timeFormat ? { timeFormat } : {},
|
|
2645
|
+
...slots ? { slots, slotContext } : {},
|
|
2250
2646
|
...showActions ? {
|
|
2251
2647
|
actionsTrigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2252
2648
|
"button",
|
|
@@ -2267,91 +2663,73 @@ function BubbleMessageRow({
|
|
|
2267
2663
|
)
|
|
2268
2664
|
}
|
|
2269
2665
|
),
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
type: "button",
|
|
2283
|
-
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
2284
|
-
onClick: onOpenThread,
|
|
2285
|
-
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2286
|
-
children: [
|
|
2287
|
-
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
2288
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
2289
|
-
replyCount,
|
|
2290
|
-
" ",
|
|
2291
|
-
replyCount === 1 ? "reply" : "replies"
|
|
2292
|
-
] })
|
|
2293
|
-
]
|
|
2294
|
-
}
|
|
2666
|
+
renderSlot(
|
|
2667
|
+
slots?.reactions,
|
|
2668
|
+
slotContext,
|
|
2669
|
+
showReactions ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `poolse-message-row__reactions ${isSelf ? "is-self" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2670
|
+
InlineReactions,
|
|
2671
|
+
{
|
|
2672
|
+
reactions: reactionsHook.reactions,
|
|
2673
|
+
currentUserId: meId,
|
|
2674
|
+
onAdd: (e) => void reactionsHook.addReaction(e),
|
|
2675
|
+
onRemove: (e) => void reactionsHook.removeReaction(e)
|
|
2676
|
+
}
|
|
2677
|
+
) }) : null
|
|
2295
2678
|
),
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2679
|
+
renderSlot(
|
|
2680
|
+
slots?.thread,
|
|
2681
|
+
slotContext,
|
|
2682
|
+
showThreadPill ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2683
|
+
"button",
|
|
2684
|
+
{
|
|
2685
|
+
type: "button",
|
|
2686
|
+
className: `poolse-thread-pill ${isSelf ? "poolse-thread-pill--right" : "poolse-thread-pill--left"}`,
|
|
2687
|
+
onClick: onOpenThread,
|
|
2688
|
+
"aria-label": `View ${replyCount} ${replyCount === 1 ? "reply" : "replies"}`,
|
|
2689
|
+
children: [
|
|
2690
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "messages", size: 12, label: null }),
|
|
2691
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
2692
|
+
replyCount,
|
|
2693
|
+
" ",
|
|
2694
|
+
replyCount === 1 ? "reply" : "replies"
|
|
2695
|
+
] })
|
|
2696
|
+
]
|
|
2697
|
+
}
|
|
2698
|
+
) : null
|
|
2699
|
+
),
|
|
2700
|
+
renderSlot(
|
|
2701
|
+
slots?.actions,
|
|
2702
|
+
slotContext,
|
|
2703
|
+
showActions ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2704
|
+
"div",
|
|
2705
|
+
{
|
|
2706
|
+
className: `poolse-message-row__actions ${isSelf ? "poolse-message-row__actions--right" : "poolse-message-row__actions--left"}`,
|
|
2707
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2708
|
+
MessageActions,
|
|
2709
|
+
{
|
|
2710
|
+
...reactions ? {
|
|
2711
|
+
onReact: (emoji) => {
|
|
2712
|
+
void reactionsHook.addReaction(emoji);
|
|
2713
|
+
}
|
|
2714
|
+
} : {},
|
|
2715
|
+
...threads && onOpenThread ? { onReply: onOpenThread } : {},
|
|
2716
|
+
...quotations && onQuote ? { onQuote } : {},
|
|
2717
|
+
...msg.body ? {
|
|
2718
|
+
onCopy: () => {
|
|
2719
|
+
void navigator?.clipboard?.writeText(msg.body ?? "").catch(() => void 0);
|
|
2720
|
+
}
|
|
2721
|
+
} : {},
|
|
2722
|
+
...isSelf && onStartEdit ? { onEdit: onStartEdit } : {},
|
|
2723
|
+
...isSelf && onDelete ? { onDelete } : {}
|
|
2724
|
+
}
|
|
2725
|
+
)
|
|
2726
|
+
}
|
|
2727
|
+
) : null
|
|
2320
2728
|
)
|
|
2321
2729
|
]
|
|
2322
2730
|
}
|
|
2323
2731
|
);
|
|
2324
2732
|
}
|
|
2325
|
-
function InlineReactions({
|
|
2326
|
-
reactions,
|
|
2327
|
-
currentUserId,
|
|
2328
|
-
onAdd: _onAdd,
|
|
2329
|
-
onRemove
|
|
2330
|
-
}) {
|
|
2331
|
-
const entries = Object.entries(reactions);
|
|
2332
|
-
if (entries.length === 0) return null;
|
|
2333
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-reactions", children: entries.map(([emoji, users]) => {
|
|
2334
|
-
const mine = currentUserId !== null && currentUserId !== void 0 && users.includes(currentUserId);
|
|
2335
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2336
|
-
"button",
|
|
2337
|
-
{
|
|
2338
|
-
type: "button",
|
|
2339
|
-
className: `poolse-reaction-pill${mine ? " poolse-reaction-pill--mine" : ""}`,
|
|
2340
|
-
onClick: () => {
|
|
2341
|
-
if (mine) onRemove(emoji);
|
|
2342
|
-
else _onAdd(emoji);
|
|
2343
|
-
},
|
|
2344
|
-
"aria-pressed": mine,
|
|
2345
|
-
"aria-label": `${emoji} reacted by ${users.length} ${users.length === 1 ? "user" : "users"}`,
|
|
2346
|
-
children: [
|
|
2347
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: emoji }),
|
|
2348
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-reaction-pill__count", children: users.length })
|
|
2349
|
-
]
|
|
2350
|
-
},
|
|
2351
|
-
emoji
|
|
2352
|
-
);
|
|
2353
|
-
}) });
|
|
2354
|
-
}
|
|
2355
2733
|
function BubbleWithAvatar({
|
|
2356
2734
|
isSelf,
|
|
2357
2735
|
showAvatar,
|
|
@@ -2381,7 +2759,9 @@ function ThreadView({
|
|
|
2381
2759
|
conversationId,
|
|
2382
2760
|
rootMessage,
|
|
2383
2761
|
onClose,
|
|
2384
|
-
renderMessage
|
|
2762
|
+
renderMessage,
|
|
2763
|
+
layout,
|
|
2764
|
+
timeFormat
|
|
2385
2765
|
}) {
|
|
2386
2766
|
const { me } = react$1.useMe();
|
|
2387
2767
|
const {
|
|
@@ -2464,7 +2844,9 @@ function ThreadView({
|
|
|
2464
2844
|
await edit(msg.id, body);
|
|
2465
2845
|
setEditingId(null);
|
|
2466
2846
|
},
|
|
2467
|
-
onDelete: () => void deleteReply(msg.id)
|
|
2847
|
+
onDelete: () => void deleteReply(msg.id),
|
|
2848
|
+
...layout ? { layout } : {},
|
|
2849
|
+
...timeFormat ? { timeFormat } : {}
|
|
2468
2850
|
}
|
|
2469
2851
|
);
|
|
2470
2852
|
const renderOne = renderMessage ? (msg, currentUserId) => renderMessage(msg, currentUserId) : (msg) => renderDefault(msg);
|
|
@@ -2580,7 +2962,13 @@ function ConversationView({
|
|
|
2580
2962
|
markdown = TRUE,
|
|
2581
2963
|
maxBodyLength = 200,
|
|
2582
2964
|
grouping = TRUE,
|
|
2583
|
-
groupingWindowMs
|
|
2965
|
+
groupingWindowMs,
|
|
2966
|
+
groupWindowMinutes,
|
|
2967
|
+
layout = "bubbles",
|
|
2968
|
+
density = "comfortable",
|
|
2969
|
+
showAvatars,
|
|
2970
|
+
timeFormat,
|
|
2971
|
+
slots,
|
|
2584
2972
|
daySeparators = TRUE,
|
|
2585
2973
|
senderLabels = "auto",
|
|
2586
2974
|
avatars = "auto",
|
|
@@ -2628,7 +3016,13 @@ function ConversationView({
|
|
|
2628
3016
|
const { members } = react$1.useMembers(membersOn ? conversationId : "");
|
|
2629
3017
|
const isGroupChat = members.length > 2;
|
|
2630
3018
|
const showSenderLabelsResolved = senderLabels === "always" || senderLabels === "auto" && isGroupChat;
|
|
2631
|
-
const showAvatarsResolved = avatars === "always" || avatars === "auto" && isGroupChat;
|
|
3019
|
+
const showAvatarsResolved = showAvatars ?? (layout === "list" ? true : layout === "compact" ? false : avatars === "always" || avatars === "auto" && isGroupChat);
|
|
3020
|
+
const groupWindowMs = groupWindowMinutes !== void 0 ? groupWindowMinutes * 60 * 1e3 : groupingWindowMs ?? 5 * 60 * 1e3;
|
|
3021
|
+
const layoutProps = {
|
|
3022
|
+
layout,
|
|
3023
|
+
...timeFormat ? { timeFormat } : {},
|
|
3024
|
+
...slots ? { slots } : {}
|
|
3025
|
+
};
|
|
2632
3026
|
const listRef = react.useRef(null);
|
|
2633
3027
|
const lastMessageIdRef = react.useRef(null);
|
|
2634
3028
|
const bottomSentinelRef = react.useRef(null);
|
|
@@ -2868,7 +3262,12 @@ function ConversationView({
|
|
|
2868
3262
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2869
3263
|
"div",
|
|
2870
3264
|
{
|
|
2871
|
-
className:
|
|
3265
|
+
className: [
|
|
3266
|
+
"poolse-conversation",
|
|
3267
|
+
`poolse-conversation--layout-${layout}`,
|
|
3268
|
+
`poolse-conversation--density-${density}`,
|
|
3269
|
+
dragActive ? "is-drag-active" : ""
|
|
3270
|
+
].filter(Boolean).join(" "),
|
|
2872
3271
|
onDragEnter,
|
|
2873
3272
|
onDragOver,
|
|
2874
3273
|
onDragLeave,
|
|
@@ -2910,12 +3309,9 @@ function ConversationView({
|
|
|
2910
3309
|
children: [
|
|
2911
3310
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
2912
3311
|
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." }) : visibleMessages.map((msg, idx) => {
|
|
2913
|
-
if (renderMessage) {
|
|
2914
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|
|
2915
|
-
}
|
|
2916
3312
|
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
2917
3313
|
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
2918
|
-
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next,
|
|
3314
|
+
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupWindowMs) : "standalone";
|
|
2919
3315
|
const showDaySeparator = daySeparators && (prev === null || !react$1.sameDay(msg.inserted_at, prev.inserted_at));
|
|
2920
3316
|
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
2921
3317
|
const original = messages.find((m) => m.id === msg.quoted_message_id);
|
|
@@ -2934,47 +3330,58 @@ function ConversationView({
|
|
|
2934
3330
|
})() : msg;
|
|
2935
3331
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
2936
3332
|
const readState = showReadState && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
3333
|
+
const renderDefault = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3334
|
+
MessageRow,
|
|
3335
|
+
{
|
|
3336
|
+
msg: enriched,
|
|
3337
|
+
meId: me?.id ?? null,
|
|
3338
|
+
reactions,
|
|
3339
|
+
attachments,
|
|
3340
|
+
actions,
|
|
3341
|
+
threads,
|
|
3342
|
+
quotations: canQuote,
|
|
3343
|
+
groupPosition,
|
|
3344
|
+
maxBodyLength,
|
|
3345
|
+
markdown,
|
|
3346
|
+
showSenderName: showSenderLabelsResolved,
|
|
3347
|
+
showAvatar: showAvatarsResolved,
|
|
3348
|
+
...onSenderPress ? { onSenderPress } : {},
|
|
3349
|
+
...onAvatarPress ? { onAvatarPress } : {},
|
|
3350
|
+
...readState ? { readState } : {},
|
|
3351
|
+
...labelFor ? { labelFor } : {},
|
|
3352
|
+
editing: editingId === msg.id,
|
|
3353
|
+
...react$1.canEditOwnMessage({
|
|
3354
|
+
isSelf,
|
|
3355
|
+
deleted: !!msg.deleted_at,
|
|
3356
|
+
receiptsVisible,
|
|
3357
|
+
readState,
|
|
3358
|
+
insertedAt: msg.inserted_at
|
|
3359
|
+
}) ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
3360
|
+
onCancelEdit: () => setEditingId(null),
|
|
3361
|
+
onSaveEdit: async (body) => {
|
|
3362
|
+
await edit(msg.id, body);
|
|
3363
|
+
setEditingId(null);
|
|
3364
|
+
},
|
|
3365
|
+
onDelete: () => void deleteMsg(msg.id),
|
|
3366
|
+
onOpenThread: () => setThreadRootId(msg.id),
|
|
3367
|
+
onQuote: () => setReplyingTo(msg),
|
|
3368
|
+
onQuotedClick: scrollToOriginal,
|
|
3369
|
+
...onCallBack ? { onCallBack } : {},
|
|
3370
|
+
...layoutProps,
|
|
3371
|
+
mentionsMe: mentionsViewer(msg, me?.id ?? null)
|
|
3372
|
+
}
|
|
3373
|
+
);
|
|
3374
|
+
if (renderMessage) {
|
|
3375
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null, {
|
|
3376
|
+
layout,
|
|
3377
|
+
groupPosition,
|
|
3378
|
+
isRunStart: layout === "compact" || groupPosition === "first" || groupPosition === "standalone",
|
|
3379
|
+
renderDefault
|
|
3380
|
+
}) }, msg.id);
|
|
3381
|
+
}
|
|
2937
3382
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
2938
3383
|
showDaySeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: react$1.formatDayLabel(msg.inserted_at) }) }),
|
|
2939
|
-
|
|
2940
|
-
MessageRow,
|
|
2941
|
-
{
|
|
2942
|
-
msg: enriched,
|
|
2943
|
-
meId: me?.id ?? null,
|
|
2944
|
-
reactions,
|
|
2945
|
-
attachments,
|
|
2946
|
-
actions,
|
|
2947
|
-
threads,
|
|
2948
|
-
quotations: canQuote,
|
|
2949
|
-
groupPosition,
|
|
2950
|
-
maxBodyLength,
|
|
2951
|
-
markdown,
|
|
2952
|
-
showSenderName: showSenderLabelsResolved,
|
|
2953
|
-
showAvatar: showAvatarsResolved,
|
|
2954
|
-
...onSenderPress ? { onSenderPress } : {},
|
|
2955
|
-
...onAvatarPress ? { onAvatarPress } : {},
|
|
2956
|
-
...readState ? { readState } : {},
|
|
2957
|
-
...labelFor ? { labelFor } : {},
|
|
2958
|
-
editing: editingId === msg.id,
|
|
2959
|
-
...react$1.canEditOwnMessage({
|
|
2960
|
-
isSelf,
|
|
2961
|
-
deleted: !!msg.deleted_at,
|
|
2962
|
-
receiptsVisible,
|
|
2963
|
-
readState,
|
|
2964
|
-
insertedAt: msg.inserted_at
|
|
2965
|
-
}) ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
2966
|
-
onCancelEdit: () => setEditingId(null),
|
|
2967
|
-
onSaveEdit: async (body) => {
|
|
2968
|
-
await edit(msg.id, body);
|
|
2969
|
-
setEditingId(null);
|
|
2970
|
-
},
|
|
2971
|
-
onDelete: () => void deleteMsg(msg.id),
|
|
2972
|
-
onOpenThread: () => setThreadRootId(msg.id),
|
|
2973
|
-
onQuote: () => setReplyingTo(msg),
|
|
2974
|
-
onQuotedClick: scrollToOriginal,
|
|
2975
|
-
...onCallBack ? { onCallBack } : {}
|
|
2976
|
-
}
|
|
2977
|
-
)
|
|
3384
|
+
renderDefault()
|
|
2978
3385
|
] }, msg.id);
|
|
2979
3386
|
}),
|
|
2980
3387
|
visibleStreams.map(
|
|
@@ -2990,7 +3397,8 @@ function ConversationView({
|
|
|
2990
3397
|
markdown,
|
|
2991
3398
|
showSenderName: showSenderLabelsResolved,
|
|
2992
3399
|
showAvatar: showAvatarsResolved,
|
|
2993
|
-
...labelFor ? { labelFor } : {}
|
|
3400
|
+
...labelFor ? { labelFor } : {},
|
|
3401
|
+
...layoutProps
|
|
2994
3402
|
}
|
|
2995
3403
|
) }, stream.id)
|
|
2996
3404
|
),
|
|
@@ -3031,7 +3439,9 @@ function ConversationView({
|
|
|
3031
3439
|
{
|
|
3032
3440
|
conversationId,
|
|
3033
3441
|
rootMessage: threadRoot,
|
|
3034
|
-
onClose: () => setThreadRootId(null)
|
|
3442
|
+
onClose: () => setThreadRootId(null),
|
|
3443
|
+
layout,
|
|
3444
|
+
...timeFormat ? { timeFormat } : {}
|
|
3035
3445
|
}
|
|
3036
3446
|
) })
|
|
3037
3447
|
] });
|
|
@@ -3940,6 +4350,61 @@ function useElapsed(startedAt, running) {
|
|
|
3940
4350
|
const s = String(total % 60).padStart(2, "0");
|
|
3941
4351
|
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
3942
4352
|
}
|
|
4353
|
+
var ThemeContext = react.createContext(null);
|
|
4354
|
+
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
4355
|
+
function systemScheme() {
|
|
4356
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return "light";
|
|
4357
|
+
return window.matchMedia(DARK_QUERY).matches ? "dark" : "light";
|
|
4358
|
+
}
|
|
4359
|
+
function useSystemColorScheme() {
|
|
4360
|
+
const [scheme, setScheme] = react.useState(systemScheme);
|
|
4361
|
+
react.useEffect(() => {
|
|
4362
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
4363
|
+
const mql = window.matchMedia(DARK_QUERY);
|
|
4364
|
+
const onChange = () => setScheme(mql.matches ? "dark" : "light");
|
|
4365
|
+
onChange();
|
|
4366
|
+
if (typeof mql.addEventListener === "function") {
|
|
4367
|
+
mql.addEventListener("change", onChange);
|
|
4368
|
+
return () => mql.removeEventListener("change", onChange);
|
|
4369
|
+
}
|
|
4370
|
+
mql.addListener(onChange);
|
|
4371
|
+
return () => mql.removeListener(onChange);
|
|
4372
|
+
}, []);
|
|
4373
|
+
return scheme;
|
|
4374
|
+
}
|
|
4375
|
+
function PoolseTheme({
|
|
4376
|
+
theme: theme$1,
|
|
4377
|
+
colorScheme = "system",
|
|
4378
|
+
className,
|
|
4379
|
+
style,
|
|
4380
|
+
children
|
|
4381
|
+
}) {
|
|
4382
|
+
const system = useSystemColorScheme();
|
|
4383
|
+
const scheme = colorScheme === "system" ? system : colorScheme;
|
|
4384
|
+
const value = react.useMemo(
|
|
4385
|
+
() => ({ theme: theme$1 ? theme.resolveTheme(theme$1, scheme) : null, colorScheme: scheme }),
|
|
4386
|
+
[theme$1, scheme]
|
|
4387
|
+
);
|
|
4388
|
+
const vars = react.useMemo(
|
|
4389
|
+
() => value.theme ? theme.tokensToCssVariables(value.theme) : null,
|
|
4390
|
+
[value.theme]
|
|
4391
|
+
);
|
|
4392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4393
|
+
"div",
|
|
4394
|
+
{
|
|
4395
|
+
className: className ? `poolse-theme ${className}` : "poolse-theme",
|
|
4396
|
+
"data-theme": scheme,
|
|
4397
|
+
"data-poolse-theme": value.theme?.id,
|
|
4398
|
+
style: vars || style ? { ...vars, ...style } : void 0,
|
|
4399
|
+
children
|
|
4400
|
+
}
|
|
4401
|
+
) });
|
|
4402
|
+
}
|
|
4403
|
+
function useTheme() {
|
|
4404
|
+
const value = react.useContext(ThemeContext);
|
|
4405
|
+
const system = useSystemColorScheme();
|
|
4406
|
+
return value ?? { theme: null, colorScheme: system };
|
|
4407
|
+
}
|
|
3943
4408
|
var MARK_PATHS = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3944
4409
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3945
4410
|
"path",
|
|
@@ -4048,6 +4513,26 @@ function PoolseLogo({
|
|
|
4048
4513
|
);
|
|
4049
4514
|
}
|
|
4050
4515
|
|
|
4516
|
+
Object.defineProperty(exports, "BUILT_IN_THEME_IDS", {
|
|
4517
|
+
enumerable: true,
|
|
4518
|
+
get: function () { return theme.BUILT_IN_THEME_IDS; }
|
|
4519
|
+
});
|
|
4520
|
+
Object.defineProperty(exports, "DEFAULT_THEME_ID", {
|
|
4521
|
+
enumerable: true,
|
|
4522
|
+
get: function () { return theme.DEFAULT_THEME_ID; }
|
|
4523
|
+
});
|
|
4524
|
+
Object.defineProperty(exports, "createTheme", {
|
|
4525
|
+
enumerable: true,
|
|
4526
|
+
get: function () { return theme.createTheme; }
|
|
4527
|
+
});
|
|
4528
|
+
Object.defineProperty(exports, "decodeTheme", {
|
|
4529
|
+
enumerable: true,
|
|
4530
|
+
get: function () { return theme.decodeTheme; }
|
|
4531
|
+
});
|
|
4532
|
+
Object.defineProperty(exports, "encodeTheme", {
|
|
4533
|
+
enumerable: true,
|
|
4534
|
+
get: function () { return theme.encodeTheme; }
|
|
4535
|
+
});
|
|
4051
4536
|
exports.AttachmentPreview = AttachmentPreview;
|
|
4052
4537
|
exports.Avatar = Avatar;
|
|
4053
4538
|
exports.CallControlButton = CallControlButton;
|
|
@@ -4069,6 +4554,7 @@ exports.PoolseFonts = PoolseFonts;
|
|
|
4069
4554
|
exports.PoolseIcon = PoolseIcon;
|
|
4070
4555
|
exports.PoolseInbox = PoolseInbox;
|
|
4071
4556
|
exports.PoolseLogo = PoolseLogo;
|
|
4557
|
+
exports.PoolseTheme = PoolseTheme;
|
|
4072
4558
|
exports.ReactionPicker = ReactionPicker;
|
|
4073
4559
|
exports.ReactionStrip = ReactionStrip;
|
|
4074
4560
|
exports.RoomJoinBar = RoomJoinBar;
|
|
@@ -4080,5 +4566,7 @@ exports.UserName = UserName;
|
|
|
4080
4566
|
exports.UserPickerSheet = UserPickerSheet;
|
|
4081
4567
|
exports.useDisplayName = useDisplayName;
|
|
4082
4568
|
exports.usePoolseFonts = usePoolseFonts;
|
|
4569
|
+
exports.useSystemColorScheme = useSystemColorScheme;
|
|
4570
|
+
exports.useTheme = useTheme;
|
|
4083
4571
|
//# sourceMappingURL=index.cjs.map
|
|
4084
4572
|
//# sourceMappingURL=index.cjs.map
|