@poolse/react-ui 2.20.0 → 2.22.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/dist/index.cjs +126 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +126 -9
- package/dist/index.js.map +1 -1
- package/dist/styles.css +120 -0
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -850,6 +850,26 @@ function PoolseFonts() {
|
|
|
850
850
|
usePoolseFonts(true);
|
|
851
851
|
return null;
|
|
852
852
|
}
|
|
853
|
+
function LiveCallBanner({ call, inCall, onJoin }) {
|
|
854
|
+
const what = call.media === "video" ? "Video call in progress" : "Voice call in progress";
|
|
855
|
+
const who = inCall > 0 ? `${inCall} on the call` : "Ringing";
|
|
856
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-live-call", role: "status", "aria-label": `${what}, ${who}`, children: [
|
|
857
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
858
|
+
PoolseIcon,
|
|
859
|
+
{
|
|
860
|
+
name: call.media === "video" ? "video" : "phone",
|
|
861
|
+
size: 16,
|
|
862
|
+
label: null,
|
|
863
|
+
className: "poolse-live-call__icon"
|
|
864
|
+
}
|
|
865
|
+
),
|
|
866
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-live-call__text", children: [
|
|
867
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-live-call__title", children: what }),
|
|
868
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-live-call__meta", children: who })
|
|
869
|
+
] }),
|
|
870
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "poolse-live-call__join", onClick: () => onJoin(call), children: "Join" })
|
|
871
|
+
] });
|
|
872
|
+
}
|
|
853
873
|
|
|
854
874
|
// src/listAutocomplete.ts
|
|
855
875
|
var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
|
|
@@ -1476,6 +1496,57 @@ function computeInitials(name) {
|
|
|
1476
1496
|
const parts = name.trim().split(/\s+/).slice(0, 2);
|
|
1477
1497
|
return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
|
|
1478
1498
|
}
|
|
1499
|
+
function CallLogRow({ msg, meId, onCallBack }) {
|
|
1500
|
+
const display = react$1.callLogDisplayFor(msg, meId);
|
|
1501
|
+
if (!display) return null;
|
|
1502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1503
|
+
CallLogLine,
|
|
1504
|
+
{
|
|
1505
|
+
display,
|
|
1506
|
+
insertedAt: msg.inserted_at,
|
|
1507
|
+
...onCallBack ? { onCallBack } : {}
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
function CallLogLine({
|
|
1512
|
+
display,
|
|
1513
|
+
insertedAt,
|
|
1514
|
+
onCallBack
|
|
1515
|
+
}) {
|
|
1516
|
+
const time = formatTime(insertedAt);
|
|
1517
|
+
const icon = display.media === "video" ? "video" : "phone";
|
|
1518
|
+
const label = [display.title, display.detail, time].filter(Boolean).join(", ");
|
|
1519
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1520
|
+
"div",
|
|
1521
|
+
{
|
|
1522
|
+
className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
|
|
1523
|
+
role: "note",
|
|
1524
|
+
"aria-label": label,
|
|
1525
|
+
children: [
|
|
1526
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-call-log__chip", children: [
|
|
1527
|
+
/* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: 13, label: null, className: "poolse-call-log__icon" }),
|
|
1528
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__title", children: display.title }),
|
|
1529
|
+
display.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
|
|
1530
|
+
time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__time", children: time })
|
|
1531
|
+
] }),
|
|
1532
|
+
display.callBack && onCallBack && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
"button",
|
|
1534
|
+
{
|
|
1535
|
+
type: "button",
|
|
1536
|
+
className: "poolse-call-log__call-back",
|
|
1537
|
+
onClick: () => onCallBack(display.media),
|
|
1538
|
+
children: "Call back"
|
|
1539
|
+
}
|
|
1540
|
+
)
|
|
1541
|
+
]
|
|
1542
|
+
}
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
function formatTime(iso) {
|
|
1546
|
+
const d = new Date(iso);
|
|
1547
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
1548
|
+
return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
|
|
1549
|
+
}
|
|
1479
1550
|
function AttachmentPreview({ attachment, onClick }) {
|
|
1480
1551
|
const isFullRow = "content_type" in attachment;
|
|
1481
1552
|
const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
|
|
@@ -2134,7 +2205,21 @@ function ActionButton({
|
|
|
2134
2205
|
].filter(Boolean).join(" ");
|
|
2135
2206
|
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 }) });
|
|
2136
2207
|
}
|
|
2137
|
-
function MessageRow({
|
|
2208
|
+
function MessageRow(props) {
|
|
2209
|
+
const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
|
|
2210
|
+
if (callLog !== void 0) {
|
|
2211
|
+
return callLog ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2212
|
+
CallLogRow,
|
|
2213
|
+
{
|
|
2214
|
+
msg: props.msg,
|
|
2215
|
+
meId: props.meId,
|
|
2216
|
+
...props.onCallBack ? { onCallBack: props.onCallBack } : {}
|
|
2217
|
+
}
|
|
2218
|
+
) : null;
|
|
2219
|
+
}
|
|
2220
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BubbleMessageRow, { ...props });
|
|
2221
|
+
}
|
|
2222
|
+
function BubbleMessageRow({
|
|
2138
2223
|
msg,
|
|
2139
2224
|
meId,
|
|
2140
2225
|
reactions = true,
|
|
@@ -2568,7 +2653,10 @@ function ConversationView({
|
|
|
2568
2653
|
daySeparators = TRUE,
|
|
2569
2654
|
senderLabels = "auto",
|
|
2570
2655
|
avatars = "auto",
|
|
2571
|
-
onMarkedRead
|
|
2656
|
+
onMarkedRead,
|
|
2657
|
+
onCallBack,
|
|
2658
|
+
onJoinCall,
|
|
2659
|
+
currentCallId = null
|
|
2572
2660
|
}) {
|
|
2573
2661
|
usePoolseFonts(loadFonts);
|
|
2574
2662
|
const { me } = react$1.useMe();
|
|
@@ -2671,6 +2759,11 @@ function ConversationView({
|
|
|
2671
2759
|
if (el) el.scrollTop = el.scrollHeight;
|
|
2672
2760
|
setNewCountWhileAway(0);
|
|
2673
2761
|
};
|
|
2762
|
+
const meIdForFeed = me?.id ?? null;
|
|
2763
|
+
const visibleMessages = react.useMemo(
|
|
2764
|
+
() => messages.filter((m) => react$1.isMessageVisibleTo(m, meIdForFeed)),
|
|
2765
|
+
[messages, meIdForFeed]
|
|
2766
|
+
);
|
|
2674
2767
|
const maxReadByOthers = react.useMemo(() => {
|
|
2675
2768
|
if (!readReceipts || !me) return null;
|
|
2676
2769
|
let max = 0;
|
|
@@ -2782,6 +2875,15 @@ function ConversationView({
|
|
|
2782
2875
|
onDragLeave,
|
|
2783
2876
|
onDrop,
|
|
2784
2877
|
children: [
|
|
2878
|
+
onJoinCall && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2879
|
+
JoinBanner,
|
|
2880
|
+
{
|
|
2881
|
+
conversationId,
|
|
2882
|
+
meId: me?.id ?? null,
|
|
2883
|
+
currentCallId,
|
|
2884
|
+
onJoin: onJoinCall
|
|
2885
|
+
}
|
|
2886
|
+
),
|
|
2785
2887
|
status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2786
2888
|
"div",
|
|
2787
2889
|
{
|
|
@@ -2807,12 +2909,12 @@ function ConversationView({
|
|
|
2807
2909
|
"aria-relevant": "additions",
|
|
2808
2910
|
children: [
|
|
2809
2911
|
hasMore && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
|
|
2810
|
-
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." }) :
|
|
2912
|
+
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) => {
|
|
2811
2913
|
if (renderMessage) {
|
|
2812
2914
|
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
|
|
2813
2915
|
}
|
|
2814
|
-
const prev = idx > 0 ?
|
|
2815
|
-
const next = idx <
|
|
2916
|
+
const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
|
|
2917
|
+
const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
|
|
2816
2918
|
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
|
|
2817
2919
|
const showDaySeparator = daySeparators && (prev === null || !react$1.sameDay(msg.inserted_at, prev.inserted_at));
|
|
2818
2920
|
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
@@ -2861,7 +2963,8 @@ function ConversationView({
|
|
|
2861
2963
|
onDelete: () => void deleteMsg(msg.id),
|
|
2862
2964
|
onOpenThread: () => setThreadRootId(msg.id),
|
|
2863
2965
|
onQuote: () => setReplyingTo(msg),
|
|
2864
|
-
onQuotedClick: scrollToOriginal
|
|
2966
|
+
onQuotedClick: scrollToOriginal,
|
|
2967
|
+
...onCallBack ? { onCallBack } : {}
|
|
2865
2968
|
}
|
|
2866
2969
|
)
|
|
2867
2970
|
] }, msg.id);
|
|
@@ -2908,6 +3011,17 @@ function ConversationView({
|
|
|
2908
3011
|
) })
|
|
2909
3012
|
] });
|
|
2910
3013
|
}
|
|
3014
|
+
function JoinBanner({
|
|
3015
|
+
conversationId,
|
|
3016
|
+
meId,
|
|
3017
|
+
currentCallId,
|
|
3018
|
+
onJoin
|
|
3019
|
+
}) {
|
|
3020
|
+
const { call, participantIds } = react$1.useLiveCall(conversationId);
|
|
3021
|
+
if (!call || call.id === currentCallId) return null;
|
|
3022
|
+
if (meId !== null && participantIds.includes(meId)) return null;
|
|
3023
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LiveCallBanner, { call, inCall: participantIds.length, onJoin });
|
|
3024
|
+
}
|
|
2911
3025
|
function ChatHeader({
|
|
2912
3026
|
conversationId,
|
|
2913
3027
|
labelFor,
|
|
@@ -2979,6 +3093,7 @@ function ConversationList({
|
|
|
2979
3093
|
const auto = react$1.useConversations();
|
|
2980
3094
|
const { me } = react$1.useMe();
|
|
2981
3095
|
const meExternalId = me?.external_id ?? null;
|
|
3096
|
+
const meId = me?.id ?? null;
|
|
2982
3097
|
const isControlled = controlledConversations !== void 0;
|
|
2983
3098
|
const conversations = isControlled ? controlledConversations : auto.conversations;
|
|
2984
3099
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
@@ -3003,6 +3118,7 @@ function ConversationList({
|
|
|
3003
3118
|
selected,
|
|
3004
3119
|
unread,
|
|
3005
3120
|
meExternalId,
|
|
3121
|
+
meId,
|
|
3006
3122
|
...labelFor ? { labelFor } : {},
|
|
3007
3123
|
...avatarFor ? { avatarFor } : {}
|
|
3008
3124
|
}
|
|
@@ -3032,6 +3148,7 @@ function DefaultRow({
|
|
|
3032
3148
|
selected: _selected,
|
|
3033
3149
|
unread,
|
|
3034
3150
|
meExternalId,
|
|
3151
|
+
meId = null,
|
|
3035
3152
|
labelFor,
|
|
3036
3153
|
avatarFor
|
|
3037
3154
|
}) {
|
|
@@ -3041,7 +3158,7 @@ function DefaultRow({
|
|
|
3041
3158
|
const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
|
|
3042
3159
|
const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
|
|
3043
3160
|
const hasUnread = unread > 0;
|
|
3044
|
-
const preview = conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
|
|
3161
|
+
const preview = react$1.formatCallLogPreview(conv.last_message_preview, meId) ?? conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
|
|
3045
3162
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3046
3163
|
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: title, size: "md" }),
|
|
3047
3164
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
|
|
@@ -3630,6 +3747,7 @@ exports.AttachmentPreview = AttachmentPreview;
|
|
|
3630
3747
|
exports.Avatar = Avatar;
|
|
3631
3748
|
exports.CallControlButton = CallControlButton;
|
|
3632
3749
|
exports.CallDeviceMenu = CallDeviceMenu;
|
|
3750
|
+
exports.CallLogRow = CallLogRow;
|
|
3633
3751
|
exports.CallProvider = CallProvider;
|
|
3634
3752
|
exports.CallVideoGrid = CallVideoGrid;
|
|
3635
3753
|
exports.ChatHeader = ChatHeader;
|
|
@@ -3637,6 +3755,7 @@ exports.ConversationList = ConversationList;
|
|
|
3637
3755
|
exports.ConversationView = ConversationView;
|
|
3638
3756
|
exports.EditableMessageBubble = EditableMessageBubble;
|
|
3639
3757
|
exports.GroupDetailsSheet = GroupDetailsSheet;
|
|
3758
|
+
exports.LiveCallBanner = LiveCallBanner;
|
|
3640
3759
|
exports.MemberList = MemberList;
|
|
3641
3760
|
exports.MentionInput = MentionInput;
|
|
3642
3761
|
exports.MessageActions = MessageActions;
|