@poolse/react-ui 2.20.0 → 2.21.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.d.cts CHANGED
@@ -627,6 +627,16 @@ interface MessageBubbleProps {
627
627
  */
628
628
  declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, showAttachments, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
629
629
 
630
+ interface CallLogRowProps {
631
+ /** The call-log message. Rows that aren't call logs render nothing. */
632
+ msg: Pick<Message, 'type' | 'body' | 'inserted_at'> & {
633
+ deleted_at?: string | null;
634
+ };
635
+ /** Current user's id — decides whether a missed-call marker is shown. */
636
+ meId: string | null;
637
+ }
638
+ declare function CallLogRow({ msg, meId }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
639
+
630
640
  interface EditableMessageBubbleProps {
631
641
  message: Message;
632
642
  currentUserId: string | null;
@@ -974,4 +984,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
974
984
  */
975
985
  declare function PoolseFonts(): null;
976
986
 
977
- export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, type CallInvite, CallProvider, type CallProviderProps, CallVideoGrid, type CallVideoGridProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, useCallInvite, useDisplayName, usePoolseFonts };
987
+ export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, type CallInvite, CallLogRow, type CallLogRowProps, CallProvider, type CallProviderProps, CallVideoGrid, type CallVideoGridProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, useCallInvite, useDisplayName, usePoolseFonts };
package/dist/index.d.ts CHANGED
@@ -627,6 +627,16 @@ interface MessageBubbleProps {
627
627
  */
628
628
  declare function MessageBubble({ message, currentUserId, readState, labelFor, onQuotedClick, groupPosition, maxBodyLength, markdown, showSenderName, actionsTrigger, showAttachments, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
629
629
 
630
+ interface CallLogRowProps {
631
+ /** The call-log message. Rows that aren't call logs render nothing. */
632
+ msg: Pick<Message, 'type' | 'body' | 'inserted_at'> & {
633
+ deleted_at?: string | null;
634
+ };
635
+ /** Current user's id — decides whether a missed-call marker is shown. */
636
+ meId: string | null;
637
+ }
638
+ declare function CallLogRow({ msg, meId }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
639
+
630
640
  interface EditableMessageBubbleProps {
631
641
  message: Message;
632
642
  currentUserId: string | null;
@@ -974,4 +984,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
974
984
  */
975
985
  declare function PoolseFonts(): null;
976
986
 
977
- export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, type CallInvite, CallProvider, type CallProviderProps, CallVideoGrid, type CallVideoGridProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, useCallInvite, useDisplayName, usePoolseFonts };
987
+ export { AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, CallControlButton, type CallControlButtonProps, CallDeviceMenu, type CallDeviceMenuProps, type CallInvite, CallLogRow, type CallLogRowProps, CallProvider, type CallProviderProps, CallVideoGrid, type CallVideoGridProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, EditableMessageBubble, type EditableMessageBubbleProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, PoolseFonts, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, ReactionPicker, ReactionStrip, type ReactionStripProps, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, UserName, type UserNameProps, UserPickerSheet, type UserPickerSheetProps, useCallInvite, useDisplayName, usePoolseFonts };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { createContext, forwardRef, useState, useRef, useCallback, useImperativeHandle, useEffect, useMemo, 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, useRealtimeStatus, computeGroupPosition, sameDay, formatDayLabel, useReactions, useThread, useAttachmentUrl, useCalls, useCallRoom, useVoiceRoom } from '@poolse/react';
4
+ import { useMembers, useAttachmentUpload, useMe, useConversations, useUser, useConversation, usePresence, useMessages, useTyping, useRealtimeStatus, isMessageVisibleTo, computeGroupPosition, sameDay, formatDayLabel, formatCallLogPreview, callLogDisplayFor, useThread, useReactions, useAttachmentUrl, useCalls, useCallRoom, useVoiceRoom } from '@poolse/react';
5
5
  import ReactMarkdown from 'react-markdown';
6
6
  import remarkGfm from 'remark-gfm';
7
7
 
@@ -1469,6 +1469,35 @@ function computeInitials(name) {
1469
1469
  const parts = name.trim().split(/\s+/).slice(0, 2);
1470
1470
  return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
1471
1471
  }
1472
+ function CallLogRow({ msg, meId }) {
1473
+ const display = callLogDisplayFor(msg, meId);
1474
+ if (!display) return null;
1475
+ return /* @__PURE__ */ jsx(CallLogLine, { display, insertedAt: msg.inserted_at });
1476
+ }
1477
+ function CallLogLine({ display, insertedAt }) {
1478
+ const time = formatTime(insertedAt);
1479
+ const icon = display.media === "video" ? "video" : "phone";
1480
+ const label = [display.title, display.detail, time].filter(Boolean).join(", ");
1481
+ return /* @__PURE__ */ jsx(
1482
+ "div",
1483
+ {
1484
+ className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
1485
+ role: "note",
1486
+ "aria-label": label,
1487
+ children: /* @__PURE__ */ jsxs("span", { className: "poolse-call-log__chip", children: [
1488
+ /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: 13, label: null, className: "poolse-call-log__icon" }),
1489
+ /* @__PURE__ */ jsx("span", { className: "poolse-call-log__title", children: display.title }),
1490
+ display.detail && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
1491
+ time && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__time", children: time })
1492
+ ] })
1493
+ }
1494
+ );
1495
+ }
1496
+ function formatTime(iso) {
1497
+ const d = new Date(iso);
1498
+ if (Number.isNaN(d.getTime())) return "";
1499
+ return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
1500
+ }
1472
1501
  function AttachmentPreview({ attachment, onClick }) {
1473
1502
  const isFullRow = "content_type" in attachment;
1474
1503
  const { url, loading, error } = useAttachmentUrl(attachment.id);
@@ -2127,7 +2156,14 @@ function ActionButton({
2127
2156
  ].filter(Boolean).join(" ");
2128
2157
  return /* @__PURE__ */ jsx("button", { type: "button", className: classes, "aria-label": label, title: label, onClick, children: /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: 16, label: null }) });
2129
2158
  }
2130
- function MessageRow({
2159
+ function MessageRow(props) {
2160
+ const callLog = callLogDisplayFor(props.msg, props.meId);
2161
+ if (callLog !== void 0) {
2162
+ return callLog ? /* @__PURE__ */ jsx(CallLogRow, { msg: props.msg, meId: props.meId }) : null;
2163
+ }
2164
+ return /* @__PURE__ */ jsx(BubbleMessageRow, { ...props });
2165
+ }
2166
+ function BubbleMessageRow({
2131
2167
  msg,
2132
2168
  meId,
2133
2169
  reactions = true,
@@ -2664,6 +2700,11 @@ function ConversationView({
2664
2700
  if (el) el.scrollTop = el.scrollHeight;
2665
2701
  setNewCountWhileAway(0);
2666
2702
  };
2703
+ const meIdForFeed = me?.id ?? null;
2704
+ const visibleMessages = useMemo(
2705
+ () => messages.filter((m) => isMessageVisibleTo(m, meIdForFeed)),
2706
+ [messages, meIdForFeed]
2707
+ );
2667
2708
  const maxReadByOthers = useMemo(() => {
2668
2709
  if (!readReceipts || !me) return null;
2669
2710
  let max = 0;
@@ -2800,12 +2841,12 @@ function ConversationView({
2800
2841
  "aria-relevant": "additions",
2801
2842
  children: [
2802
2843
  hasMore && /* @__PURE__ */ jsx("div", { ref: topSentinelRef, "aria-hidden": "true", style: { height: 1 } }),
2803
- loading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: "Loading\u2026" }) : messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "poolse-conversation__empty", children: emptyState ?? "No messages yet." }) : messages.map((msg, idx) => {
2844
+ 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) => {
2804
2845
  if (renderMessage) {
2805
2846
  return /* @__PURE__ */ jsx(Fragment$1, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
2806
2847
  }
2807
- const prev = idx > 0 ? messages[idx - 1] ?? null : null;
2808
- const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
2848
+ const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
2849
+ const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
2809
2850
  const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
2810
2851
  const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
2811
2852
  const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
@@ -2972,6 +3013,7 @@ function ConversationList({
2972
3013
  const auto = useConversations();
2973
3014
  const { me } = useMe();
2974
3015
  const meExternalId = me?.external_id ?? null;
3016
+ const meId = me?.id ?? null;
2975
3017
  const isControlled = controlledConversations !== void 0;
2976
3018
  const conversations = isControlled ? controlledConversations : auto.conversations;
2977
3019
  const loading = isControlled ? controlledLoading ?? false : auto.loading;
@@ -2996,6 +3038,7 @@ function ConversationList({
2996
3038
  selected,
2997
3039
  unread,
2998
3040
  meExternalId,
3041
+ meId,
2999
3042
  ...labelFor ? { labelFor } : {},
3000
3043
  ...avatarFor ? { avatarFor } : {}
3001
3044
  }
@@ -3025,6 +3068,7 @@ function DefaultRow({
3025
3068
  selected: _selected,
3026
3069
  unread,
3027
3070
  meExternalId,
3071
+ meId = null,
3028
3072
  labelFor,
3029
3073
  avatarFor
3030
3074
  }) {
@@ -3034,7 +3078,7 @@ function DefaultRow({
3034
3078
  const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
3035
3079
  const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
3036
3080
  const hasUnread = unread > 0;
3037
- const preview = conv.last_message_preview ?? (conv.last_sequence > 0 ? `${conv.last_sequence} message${conv.last_sequence === 1 ? "" : "s"}` : "No messages yet");
3081
+ const preview = 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");
3038
3082
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3039
3083
  /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name: title, size: "md" }),
3040
3084
  /* @__PURE__ */ jsxs("div", { className: "poolse-list__body", children: [
@@ -3619,6 +3663,6 @@ function PoolseLogo({
3619
3663
  );
3620
3664
  }
3621
3665
 
3622
- export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallProvider, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, GroupDetailsSheet, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, useCallInvite, useDisplayName, usePoolseFonts };
3666
+ export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallProvider, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, GroupDetailsSheet, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, useCallInvite, useDisplayName, usePoolseFonts };
3623
3667
  //# sourceMappingURL=index.js.map
3624
3668
  //# sourceMappingURL=index.js.map